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,78 @@
1
+<?php
2
+
3
+// ----------------------------------------------------------------------
4
+// eFiction 3.2
5
+// Copyright (c) 2007 by Tammy Keefer
6
+// Valid HTML 4.01 Transitional
7
+// Based on eFiction 1.1
8
+// Copyright (C) 2003 by Rebecca Smallwood.
9
+// http://efiction.sourceforge.net/
10
+// ----------------------------------------------------------------------
11
+// LICENSE
12
+//
13
+// This program is free software; you can redistribute it and/or
14
+// modify it under the terms of the GNU General Public License (GPL)
15
+// as published by the Free Software Foundation; either version 2
16
+// of the License, or (at your option) any later version.
17
+//
18
+// This program is distributed in the hope that it will be useful,
19
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+// GNU General Public License for more details.
22
+//
23
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
24
+// ----------------------------------------------------------------------
25
+
26
+if(!defined("_CHARSET")) exit( );
27
+
28
+/* This include recalculates the average rating and review count for a series. */
29
+
30
+$storylist = array( );
31
+$serieslist = array( );
32
+$stinseries = dbquery("SELECT sid, subseriesid FROM ".TABLEPREFIX."fanfiction_inseries WHERE seriesid = '$thisseries'");
33
+while($st = dbassoc($stinseries)) {
34
+	if($st['sid']) $storylist[] = $st['sid'];
35
+	else if($st['subseriesid']) $serieslist[] = $st['subseriesid'];
36
+}
37
+$newrating = dbquery("SELECT AVG(rating) as totalreviews FROM ".TABLEPREFIX."fanfiction_reviews 
38
+	WHERE ((item = '$thisseries' AND type = 'SE')".
39
+	(count($storylist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $storylist))."') > 0 AND type = 'ST')" : "").
40
+	(count($serieslist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $serieslist))."') > 0 AND type = 'SE')" : "").
41
+	") AND rating != '-1'");
42
+list($totalreviews) = dbrow($newrating);
43
+$newcount = dbquery("SELECT count(reviewid) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews 
44
+	WHERE ((item = '$thisseries' AND type = 'SE')".
45
+	(count($storylist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $storylist))."') > 0 AND type = 'ST')" : "").
46
+	(count($serieslist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $serieslist))."') > 0 AND type = 'SE')" : "").
47
+	") AND review != 'No Review'");
48
+list($totalcount) = dbrow($newcount);
49
+if($totalcount) $update = dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET rating = '".round($totalreviews)."', reviews = '$totalcount' WHERE seriesid = '$thisseries'");
50
+$parentq = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_inseries WHERE subseriesid = '$thisseries' AND seriesid != '$thisseries'");
51
+if(dbnumrows($parentq) > 0) list($parent) = dbrow($parentq);
52
+else $parent = false;
53
+while($parent) {
54
+	$pstinseries = dbquery("SELECT sid, subseriesid FROM ".TABLEPREFIX."fanfiction_inseries WHERE seriesid = '$thisseries'");
55
+	$pstorylist = array( );
56
+	$pserieslist = array( );
57
+	while($pst = dbassoc($pstinseries)) {
58
+		if($pst['sid']) $pstorylist[] = $pst['sid'];
59
+		else if($pst['subseriesid']) $pserieslist[] = $pst['subseriesid'];
60
+	}
61
+	$pnewrating = dbquery("SELECT AVG(rating) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews 
62
+		WHERE ((item = '$parent' AND type = 'SE')".
63
+		(count($pstorylist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pstorylist))."') > 0 AND type = 'ST')" : "").
64
+		(count($pserieslist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pserieslist))."') > 0 AND type = 'SE')" : "").
65
+		") AND rating != '-1'");
66
+	$pnewcount = dbquery("SELECT count(review) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews 
67
+		WHERE ((item = '$parent' AND type = 'SE')".
68
+		(count($pstorylist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pstorylist))."') > 0 AND type = 'ST')" : "").
69
+		(count($pserieslist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pserieslist))."') > 0 AND type = 'SE')" : "").
70
+		") AND review != 'No Review'");
71
+	list($total) = dbrow($pnewrating);
72
+	list($totalcount) = dbrow($pnewcount);
73
+	if($total) $update = dbquery("UPDATE ".TABLEPREFIX."fanfiction_series SET rating = '".round($total)."', reviews = '$totalcount' WHERE seriesid = '$parent' AND rating != '-1'");
74
+	$parentq = dbquery("SELECT seriesid FROM ".TABLEPREFIX."fanfiction_inseries WHERE subseriesid = '$parent'");
75
+	if(dbnumrows($parentq)) list($parent) = dbrow($parentq);
76
+	else $parent = false;
77
+}
78
+?>
0 79
\ No newline at end of file