| ... | ... |
@@ -67,11 +67,19 @@ while($parent) {
|
| 67 | 67 |
if($pst['sid']) $pstorylist[] = $pst['sid']; |
| 68 | 68 |
else if($pst['subseriesid']) $pserieslist[] = $pst['subseriesid']; |
| 69 | 69 |
} |
| 70 |
- $pnewrating = dbquery("SELECT AVG(rating) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews
|
|
| 71 |
- WHERE ((item = '$parent' AND type = 'SE')". |
|
| 72 |
- (count($pstorylist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pstorylist))."') > 0 AND type = 'ST')" : "").
|
|
| 73 |
- (count($pserieslist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pserieslist))."') > 0 AND type = 'SE')" : "").
|
|
| 74 |
- ") AND rating != '-1'"); |
|
| 70 |
+ if($ratings == 3) {
|
|
| 71 |
+ $pnewrating = dbquery("SELECT COUNT(rating) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews
|
|
| 72 |
+ WHERE ((item = '$parent' AND type = 'SE')". |
|
| 73 |
+ (count($pstorylist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pstorylist))."') > 0 AND type = 'ST')" : "").
|
|
| 74 |
+ (count($pserieslist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pserieslist))."') > 0 AND type = 'SE')" : "").
|
|
| 75 |
+ ") AND rating != '-1'"); |
|
| 76 |
+ } else {
|
|
| 77 |
+ $pnewrating = dbquery("SELECT AVG(rating) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews
|
|
| 78 |
+ WHERE ((item = '$parent' AND type = 'SE')". |
|
| 79 |
+ (count($pstorylist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pstorylist))."') > 0 AND type = 'ST')" : "").
|
|
| 80 |
+ (count($pserieslist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pserieslist))."') > 0 AND type = 'SE')" : "").
|
|
| 81 |
+ ") AND rating != '-1'"); |
|
| 82 |
+ } |
|
| 75 | 83 |
$pnewcount = dbquery("SELECT count(review) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews
|
| 76 | 84 |
WHERE ((item = '$parent' AND type = 'SE')". |
| 77 | 85 |
(count($pstorylist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $pstorylist))."') > 0 AND type = 'ST')" : "").
|
| ... | ... |
@@ -34,11 +34,20 @@ while($st = dbassoc($stinseries)) {
|
| 34 | 34 |
if($st['sid']) $storylist[] = $st['sid']; |
| 35 | 35 |
else if($st['subseriesid']) $serieslist[] = $st['subseriesid']; |
| 36 | 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'"); |
|
| 37 |
+if($ratings == 3) {
|
|
| 38 |
+ $newrating = dbquery("SELECT COUNT(rating) as totalreviews FROM ".TABLEPREFIX."fanfiction_reviews
|
|
| 39 |
+ WHERE ((item = '$thisseries' AND type = 'SE')". |
|
| 40 |
+ (count($storylist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $storylist))."') > 0 AND type = 'ST')" : "").
|
|
| 41 |
+ (count($serieslist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $serieslist))."') > 0 AND type = 'SE')" : "").
|
|
| 42 |
+ ") AND rating != '-1'"); |
|
| 43 |
+ } |
|
| 44 |
+else {
|
|
| 45 |
+ $newrating = dbquery("SELECT AVG(rating) as totalreviews FROM ".TABLEPREFIX."fanfiction_reviews
|
|
| 46 |
+ WHERE ((item = '$thisseries' AND type = 'SE')". |
|
| 47 |
+ (count($storylist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $storylist))."') > 0 AND type = 'ST')" : "").
|
|
| 48 |
+ (count($serieslist) > 0 ? " OR (FIND_IN_SET(item, '".(implode(",", $serieslist))."') > 0 AND type = 'SE')" : "").
|
|
| 49 |
+ ") AND rating != '-1'"); |
|
| 50 |
+} |
|
| 42 | 51 |
list($totalreviews) = dbrow($newrating); |
| 43 | 52 |
$newcount = dbquery("SELECT count(reviewid) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews
|
| 44 | 53 |
WHERE ((item = '$thisseries' AND type = 'SE')". |
| ... | ... |
@@ -75,4 +84,4 @@ while($parent) {
|
| 75 | 84 |
if(dbnumrows($parentq)) list($parent) = dbrow($parentq); |
| 76 | 85 |
else $parent = false; |
| 77 | 86 |
} |
| 78 |
-?> |
|
| 79 | 87 |
\ No newline at end of file |
| 88 |
+?> |
| 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??0)."', 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??0)."', 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 |