Browse code

#23 rss output fix

Jimako authored on 2023/09/08 04:26:46
Showing 1 changed files
... ...
@@ -20,9 +20,13 @@
20 20
 // To read the license please visit http://www.gnu.org/copyleft/gpl.html
21 21
 // ----------------------------------------------------------------------
22 22
 
23
+ini_set('display_errors', 0);
24
+ini_set('display_startup_errors', 0);
25
+error_reporting(-1);
26
+
23 27
 define("_BASEDIR", "");
24
-  include_once("includes/dbfunctions.php");    
25
-  include_once("config.php"); 
28
+  require_once("includes/dbfunctions.php");
29
+  require_once("config.php"); 
26 30
 $settingsresults = dbquery("SELECT sitename, url, siteemail, slogan, language, tableprefix, dateformat FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '$sitekey'");
27 31
 $settings = dbassoc($settingsresults);
28 32
 foreach($settings as $var => $val) {
... ...
@@ -30,6 +34,8 @@ foreach($settings as $var => $val) {
30 34
 }
31 35
 define("TABLEPREFIX", $tableprefix);
32 36
 define("SITEKEY", $sitekey);
37
+define("_CHARSET", "utf-8");
38
+
33 39
   include_once("includes/queries.php");
34 40
   if(file_exists("languages/{$language}.php")) include("languages/{$language}.php");
35 41
   else include("languages/en.php");
... ...
@@ -57,31 +63,31 @@ while($rate = dbassoc($ratlist)) {
57 63
   $rss.="<webMaster>$siteemail</webMaster>\n"; 
58 64
   $rss.="<language>$language</language>\n"; 
59 65
 
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
-} 
66
+  $query = _STORYQUERY." ORDER BY updated DESC LIMIT 20";
67
+  $results = dbquery($query);
68
+  while($story = dbassoc($results)) {
69
+      $story['authors'][] = $story['penname'];
70
+      if($story['coauthors']) {
71
+      $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']."'");
72
+      while($c = dbassoc($coauth)) {
73
+        $story['authors'][] = $c['penname'];
74
+      }
75
+      }
76
+      foreach($story['authors'] AS $k => $v) {
77
+    $story['authors'][$k] = strip_tags(xmlentities( $v));
78
+      }
79
+      $rss.= "<item>
80
+    <title>".strip_tags(xmlentities($story['title']))." "._BY." ".implode(", ", $story['authors'])." [".$ratings[$story['rid']]."]</title>
81
+    <link>$url/viewstory.php?sid=".$story['sid']."</link>
82
+    <description>".strip_tags(xmlentities($story['summary']))."</description>
83
+    <pubDate>".date("r",$story['updated'])."</pubDate>
84
+      </item>\n";  
85
+  } 
80 86
 
81
-  $rss.="</channel>
82
-</rss>"; 
87
+    $rss.="</channel>
88
+  </rss>"; 
83 89
 
84
-  header('Content-type: application/xml', TRUE);
90
+  header('Content-type: application/xml');
85 91
   header("Cache-Control: must-revalidate"); 
86 92
   header("Expires: ".gmdate("D, d M Y H:i:s", time() + 3600) . " GMT"); 
87 93
 
Browse code

Start Point - version 3.5.5 + fixes

Jimako authored on 2023/09/05 17:01:08
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/xml', TRUE);
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
+?>