Browse code

Initial uplad w/ php7 fixes

Rainer Volkrodt authored on 2016/03/12 15:54:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,90 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2007 by Tammy Keefer
4
+// Based on eFiction 1.1
5
+// Copyright (C) 2003 by Rebecca Smallwood.
6
+// http://efiction.sourceforge.net/
7
+// ----------------------------------------------------------------------
8
+// LICENSE
9
+//
10
+// This program is free software; you can redistribute it and/or
11
+// modify it under the terms of the GNU General Public License (GPL)
12
+// as published by the Free Software Foundation; either version 2
13
+// of the License, or (at your option) any later version.
14
+//
15
+// This program is distributed in the hope that it will be useful,
16
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+// GNU General Public License for more details.
19
+//
20
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
21
+// ----------------------------------------------------------------------
22
+
23
+define("_BASEDIR", "");
24
+  include_once("includes/dbfunctions.php");    
25
+  include_once("config.php"); 
26
+$settingsresults = dbquery("SELECT sitename, url, siteemail, slogan, language, tableprefix, dateformat FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'");
27
+$settings = dbassoc($settingsresults);
28
+foreach($settings as $var => $val) {
29
+	$$var = $val;
30
+}
31
+define("TABLEPREFIX", $tableprefix);
32
+define("SITEKEY", $sitekey);
33
+  include_once("includes/queries.php");
34
+  if(file_exists("languages/{$language}.php")) include("languages/{$language}.php");
35
+  else include("languages/en.php");
36
+  ob_start ("ob_gzhandler"); 
37
+
38
+function xmlentities ( $string )
39
+{
40
+   return str_replace ( array ( '&', '"', "'", '<', '>' ), array ( '&amp;' , '&quot;', '&apos;' , '&lt;' , '&gt;' ), $string );
41
+}
42
+
43
+$ratlist = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_ratings");
44
+while($rate = dbassoc($ratlist)) {
45
+	$ratings[$rate['rid']] = $rate['rating'];
46
+}
47
+
48
+  $rss="<?xml version=\"1.0\" encoding=\""._CHARSET."\"?>\n"; 
49
+  $rss.="<rss version=\"2.0\">\n"; 
50
+  $rss.="<channel>\n"; 
51
+  $rss.="<copyright>Copyright ".date("Y")."</copyright>\n"; 
52
+  $rss.="<lastBuildDate>".date("r")."</lastBuildDate>\n"; 
53
+  $rss.="<description>".xmlentities($slogan)."</description>\n"; 
54
+  $rss.="<link>$url</link>\n"; 
55
+  $rss.="<title>".xmlentities( $sitename)."</title>\n"; 
56
+  $rss.="<managingEditor>$siteemail</managingEditor>\n"; 
57
+  $rss.="<webMaster>$siteemail</webMaster>\n"; 
58
+  $rss.="<language>$language</language>\n"; 
59
+
60
+$query = _STORYQUERY." ORDER BY updated DESC LIMIT 20";
61
+$results = dbquery($query);
62
+while($story = dbassoc($results)) {
63
+    $story['authors'][] = $story['penname'];
64
+    if($story['coauthors']) {
65
+		$coauth = dbquery("SELECT "._PENNAMEFIELD." as penname, co.uid FROM ".TABLEPREFIX."fanfiction_coauthors AS co LEFT JOIN "._AUTHORTABLE." ON co.uid = "._UIDFIELD." WHERE co.sid = '".$story['sid']."'");
66
+		while($c = dbassoc($coauth)) {
67
+			$story['authors'][] = $c['penname'];
68
+		}
69
+    }
70
+    foreach($story['authors'] AS $k => $v) {
71
+	$story['authors'][$k] = strip_tags(xmlentities( $v));
72
+    }
73
+    $rss.= "<item>
74
+	<title>".strip_tags(xmlentities($story['title']))." "._BY." ".implode(", ", $story['authors'])." [".$ratings[$story['rid']]."]</title>
75
+	<link>$url/viewstory.php?sid=".$story['sid']."</link>
76
+	<description>".strip_tags(xmlentities($story['summary']))."</description>
77
+	<pubDate>".date("r",$story['updated'])."</pubDate>
78
+     </item>\n";  
79
+} 
80
+
81
+  $rss.="</channel>
82
+</rss>"; 
83
+
84
+  header("Content-type: application/rss+xml"); 
85
+  header("Cache-Control: must-revalidate"); 
86
+  header("Expires: ".gmdate("D, d M Y H:i:s", time() + 3600) . " GMT"); 
87
+
88
+  echo $rss; 
89
+
90
+?>