-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfeed.php
More file actions
118 lines (99 loc) · 4.54 KB
/
feed.php
File metadata and controls
118 lines (99 loc) · 4.54 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
//===========================================================================\\
// Aardvark Topsites PHP 5.2 \\
// Copyright (c) 2000-2009 Jeremy Scheff. All rights reserved. \\
//---------------------------------------------------------------------------\\
// http://www.aardvarktopsitesphp.com/ http://www.avatic.com/ \\
//---------------------------------------------------------------------------\\
// This program is free software; you can redistribute it and/or modify it \\
// under the terms of the GNU General Public License as published by the \\
// Free Software Foundation; either version 2 of the License, or (at your \\
// option) any later version. \\
// \\
// This program is distributed in the hope that it will be useful, but \\
// WITHOUT ANY WARRANTY; without even the implied warranty of \\
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General \\
// Public License for more details. \\
//===========================================================================\\
// feed.php originally by Matt Wells <cerberus@users.berlios.de>
// Help prevent register_globals injection
define('ATSPHP', 1);
$CONF = array();
$FORM = array();
$TMPL = array();
// Change the path to your full path if necessary
$CONF['path'] = '.';
// Connect to the database
require_once("{$CONF['path']}/settings_sql.php");
require_once("{$CONF['path']}/sources/sql/{$CONF['sql']}.php");
$DB = "sql_{$CONF['sql']}";
$DB = new $DB;
$DB->connect($CONF['sql_host'], $CONF['sql_username'], $CONF['sql_password'], $CONF['sql_database']);
// Settings
$settings = $DB->fetch("SELECT * FROM {$CONF['sql_prefix']}_settings", __FILE__, __LINE__);
$CONF = array_merge($CONF, $settings);
// Combine the GET and POST input
$FORM = array_merge($_GET, $_POST);
// The language file
require_once("{$CONF['path']}/languages/{$CONF['default_language']}.php");
// Get the category, default to no category
if (isset($FORM['cat']) && $FORM['cat']) {
$TMPL['category'] = strip_tags($FORM['cat']);
$category_escaped = $DB->escape($FORM['cat']);
$category_sql = "AND category = '{$category_escaped}'";
$category_url = "/index.php?cat={$TMPL['category']}";
}
else {
$TMPL['category'] = $LNG['main_all'];
$category_sql = '';
$category_url = '';
}
$TMPL['category'] = htmlspecialchars($TMPL['category']);
$CONF['list_url'] = htmlspecialchars($CONF['list_url']);
$CONF['list_name'] = htmlspecialchars($CONF['list_name']);
// Make ORDER BY clause
require_once("{$CONF['path']}/sources/misc/classes.php");
$order_by = base::rank_by()." DESC";
header('Content-Type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"{$LNG['charset']}\"?>";
// Get the category, default to no category
if (isset($FORM['cat']) && $FORM['cat']) {
$TMPL['category'] = strip_tags($FORM['cat']);
$category_escaped = $DB->escape($FORM['cat']);
$category_sql = "AND category = '{$category_escaped}'";
}
$result = $DB->select_limit("SELECT *
FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats
WHERE sites.username = stats.username AND active = 1 {$category_sql}
ORDER BY {$order_by}
", 10, 0, __FILE__, __LINE__);
?>
<rss version="2.0">
<channel>
<title><?php echo "{$CONF['list_name']} - {$TMPL['category']}"; ?></title>
<link><?php echo $CONF['list_url'].$category_url; ?></link>
<description></description>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>Aardvark Topsites PHP</generator>
<item>
<title><?php echo "{$CONF['list_name']} - {$TMPL['category']}"; ?></title>
<link><?php echo $CONF['list_url'].$category_url; ?></link>
<description></description>
<guid><?php echo $CONF['list_url']; ?>/</guid>
</item>
<?php
for($rank = 1; $row = $DB->fetch_array($result); $rank++) {
$row['title'] = htmlspecialchars($row['title']);
$row['description'] = htmlspecialchars($row['description']);
?>
<item>
<title><?php echo $rank . ' - ' . $row['title']; ?></title>
<link><?php echo $CONF['list_url']; ?>/index.php?a=out&u=<?php echo $row['username']; ?>&go=1</link>
<description><?php echo $row['description']; ?></description>
<guid><?php echo $CONF['list_url'] . '/index.php?a=stats&u=' . $row['username']; ?></guid>
</item>
<?php
}
?>
</channel>
</rss>