-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrss.php
executable file
·68 lines (56 loc) · 2.09 KB
/
rss.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
65
66
67
68
<?php
include_once("init.php");
include_once("rss10.inc");
$rss =new RSSWriter(
REPUBLISH_CHANNEL_URL,
REPUBLISH_CHANNEL_TITLE,
REPUBLISH_CHANNEL_DESC
);
$sql="select '$FOF_FEED_TABLE.tags' as 'feed_tags', 'items.read' as 'item_read', '$FOF_FEED_TABLE.title' as 'feed_title', '$FOF_FEED_TABLE.link' as 'feed_link', $FOF_FEED_TABLE.description as feed_description, items.id as item_id, items.link as item_link, items.title as item_title, UNIX_TIMESTAMP(items.timestamp) as timestamp, items.content as item_content, items.dcdate as dcdate, items.dccreator as dccreator, items.dcsubject as dcsubject, items.publish as item_publish, items.star as item_star from $FOF_FEED_TABLE, items where items.feed_id=$FOF_FEED_TABLE.id and items.publish=1 and $FOF_FEED_TABLE.private=0";
$mytags = mysql_escape_string($_REQUEST['tags']);
$sql .= ($_REQUEST['tags']) ? " and $FOF_FEED_TABLE.tags LIKE \"%" . $mytags . "%\"" : "";
$sql.=" order by timestamp desc limit 15";
$result = fof_do_query($sql);
$timestamp;
while($row = mysql_fetch_array($result)) {
$moredata = array();
#$desc = RSSWriter::deTag($row['item_content']);
$desc = $row['item_content'];
if ( $desc && isset($_REQUEST['crop']) ) {
$desc = crop($desc, intval($_REQUEST['crop']));
}
$moredata['description'] = $desc;
if ( $row['dcdate'] ) {
$moredata['dc:date'] = $row['dcdate'];
}
if ( $row['dccreator'] ) {
$moredata['dc:creator'] = $row['dccreator'];
}
if ( $row['dcsubject'] ) {
$moredata['dc:subject'] = $row['dcsubject'];
}
$moredata['dc:identifier'] = $row['item_link'];
$rss->addItem(
$row['item_link'],
$row['item_title'],
$moredata);
}
$rss->serialize();
function crop($str, $len) {
if ( strlen($str) < $len ) {
return $str;
}
if ( strpos($str, '.') && strpos($str, '.') < $len ) {
return substr($str, 0, strpos($str, '.')+1 );
}
elseif ( strpos($str, '?') && strpos($str, '?') < $len ) {
return substr($str, 0, strpos($str, '?')+1 );
}
elseif ( strpos($str, '!') && strpos($str, '!') < $len ) {
return substr($str, 0, strpos($str, '!') +1);
}
else {
return substr($str, 0, strpos($str, ' ', $len)) . '...';
}
}
?>