-
Notifications
You must be signed in to change notification settings - Fork 2
/
feeds.php
64 lines (54 loc) · 1.7 KB
/
feeds.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
include 'config/uploadDBconfig.php';
$dir = '';
while (!glob($dir.'hash.php')) {
$dir .= '../';
}
// tell php what type of content follows
header("Content-Type: application/rss+xml; charset=UTF-8");
// uso URI to grab username since user may not be logged in.
$fullURI = $_SERVER['REQUEST_URI'];
$URIArray = explode('/', $fullURI);
$endURL = end($URIArray);
$rawUser = prev($URIArray);
$user = htmlspecialchars($rawUser);
// Get the full path to user profile photo
$proPho = shell_exec('ls '.$dir.'uploads/profiles/ | grep '.$user);
// top of rss feed
$rssfeed = '
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>';
// unchanging rss info
$rssfeed .= '
<title>'.$user.'\'s Archivatory Feed</title>
<link>'.$dir.'u/'.$user.'</link>
<description>This is the Archivatory RSS feed for '.$user.'</description>
<image>
<url>'.$dir.'uploads/profiles/'.$proPho.'</url>
<title>'.$user.'\'s Archivatory Feed</title>
<link>https://archivatory.com/u/'.$user.'</link>
</image>
<language>en-us</language>
<copyright>Copyright (C) '.date("Y").' '.$user.'</copyright>';
// query user data
$sql = "SELECT * FROM ".$user." WHERE playlist=1 ORDER BY date DESC;";
$result = mysqli_query($link, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
// loop through users' table and output into html table body
while ($row = mysqli_fetch_assoc($result)) {
$rssfeed .= '
<item>
<title>'.$row["title"].'</title>
<link>https://ipfs.io/ipfs/'.$row["hash"].'</link>
<description>'.$row["des"].'</description>
<pubDate>'.$row["date"].'</pubDate>
</item>';
}
}
$rssfeed .= '
</channel>
</rss>';
echo $rssfeed;
?>