Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,133 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// eFiction 3.2
4
+// Copyright (c) 2007 by Tammy Keefer
5
+// Valid HTML 4.01 Transitional
6
+// Based on eFiction 1.1
7
+// Copyright (C) 2003 by Rebecca Smallwood.
8
+// http://efiction.sourceforge.net/
9
+// ----------------------------------------------------------------------
10
+// LICENSE
11
+//
12
+// This program is free software; you can redistribute it and/or
13
+// modify it under the terms of the GNU General Public License (GPL)
14
+// as published by the Free Software Foundation; either version 2
15
+// of the License, or (at your option) any later version.
16
+//
17
+// This program is distributed in the hope that it will be useful,
18
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+// GNU General Public License for more details.
21
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+
27
+$stat = isset($_GET['stat']) ? $_GET['stat'] : false;
28
+if(!empty($_GET['favstor'])) $stat = "favstor";
29
+if(!empty($_GET['favseries'])) $stat = "favseries";
30
+if(!empty($_GET['favauthor'])) $stat = "favauthor";
31
+if(!isset($uid)) {
32
+	$uid = USERUID;
33
+	$pagetitle =  "<div id='pagetitle'>"._YOURSTATS."</div>";
34
+	$penname = USERPENNAME;
35
+}
36
+else {
37
+	$authquery = dbquery("SELECT "._PENNAMEFIELD." FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '$uid'");
38
+	list($penname) = dbrow($authquery);
39
+	$pagetitle = "<div class='sectionheader'>"._STATSFOR." ".$penname."</div>";
40
+}
41
+$output = $pagetitle;
42
+$storyquery = dbquery("SELECT s.title, s.sid, s.rating, s.reviews, s.count, count(fs.item) as fscount FROM ".TABLEPREFIX."fanfiction_stories as s LEFT JOIN ".TABLEPREFIX."fanfiction_favorites as fs ON s.sid = fs.item AND fs.type = 'ST' LEFT JOIN ".TABLEPREFIX."fanfiction_coauthors AS c ON s.sid = c.sid WHERE (s.uid = '$uid' OR c.uid = '$uid') AND s.validated > 0 GROUP BY s.sid");
43
+$storycount = dbnumrows($storyquery);
44
+$thislink = basename($_SERVER['PHP_SELF']).(basename($_SERVER['PHP_SELF']) == "viewuser.php" ? "?uid=$uid&amp;" : "?");
45
+$authorof[] = "<a href='".$thislink."action=stats&amp;stat=stories'>$storycount "._STORIES."</a>";
46
+if($stat == "stories" && dbnumrows($storyquery)) {
47
+	$hidechapters = isset($_GET["chapters"]) ? $_GET["chapters"] : false;
48
+	$output .= "<p style=\"text-align: right; margin: 1em;\"><a href=\"{$thislink}action=stats&amp;stat=stories&amp;chapters=".($hidechapters != "view" ? "view\">"._VIEWCHAPTERS : "hide\">"._HIDECHAPTERS)."</a></p>
49
+		<table cellpadding=\"3\" cellspacing=\"0\" style=\"width: 90%; margin: 0 auto;\" class=\"tblborder\"><tr><th>"._STORIES."</th>".($reviewsallowed ? "<th>"._REVIEWS."</th>" : "").($favorites ? "<th>"._FAVORITE."</th>" : "")."<th>"._READS."</th></tr>";
50
+	while($story = dbassoc($storyquery)) {
51
+		$output .= "<tr><td class=\"tblborder\"><a href=\"viewstory.php?sid=".$story['sid']."\">".$story['title']."</a> ".ratingpics($story['rating'])."</td>".
52
+			($reviewsallowed ? "<td class=\"tblborder\" align=\"center\"><a href=\"reviews.php?type=ST&amp;item=".$story['sid']."\">".$story['reviews']."</a></td>" : "").
53
+			($favorites ? "<td class=\"tblborder\" align=\"center\">".($story['fscount'] ? "<a href=\"".$thislink."action=stats&amp;favstor=".$story['sid']."\">".$story['fscount']."</a>" : $story['fscount'])."</td>" : "")."
54
+			<td class=\"tblborder\" align=\"center\">".(isset($story['count']) ? $story['count'] : 0 )."</td></tr>";
55
+		if($hidechapters && $hidechapters != "hide") {
56
+			$query2 = dbquery("SELECT chapid, title, inorder, rating, reviews, validated, count FROM ".TABLEPREFIX."fanfiction_chapters WHERE sid = '".$story['sid']."' ORDER BY inorder"); 
57
+			while($chapter = dbassoc($query2)) {
58
+				$output .= "<tr><td class=\"tblborder\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"viewstory.php?sid=".$story['sid']."&amp;chapid=".$chapter['chapid']."\">".$chapter['title']."</a> ".ratingpics($chapter['rating'])."</td>".
59
+				($reviewsallowed ? "<td class=\"tblborder\" align=\"center\">".($chapter['reviews'] ? "<a href=\"reviews.php?type=ST&amp;item=".$story['sid']."&amp;chapid=".$chapter['chapid']."\">".$chapter['reviews']."</a>" : "0")."</td>" : "").
60
+				($favorites ? "<td class=\"tblborder\" align=\"center\"> --- </td>" : "")."
61
+				<td class=\"tblborder\" align=\"center\">".(isset($chapter['count']) ? $chapter['count'] : 0 )."</td></tr>";			}
62
+		}
63
+	}
64
+	$output .= "</table>";
65
+	if(dbnumrows($storyquery) < 1) $output .= write_message(_NORESULTS);
66
+}
67
+$seriesquery = dbquery("SELECT s.title, s.seriesid, s.rating, s.reviews, count(fs.item) as count FROM ".TABLEPREFIX."fanfiction_series as s LEFT JOIN ".TABLEPREFIX."fanfiction_favorites as fs ON s.seriesid = fs.item AND fs.type = 'SE' WHERE s.uid = '$uid' GROUP BY s.seriesid");
68
+$seriescount = dbnumrows($seriesquery);
69
+$authorof[] =  "<a href='".$thislink."action=stats&amp;stat=series'>$seriescount "._SERIES."</a>";
70
+if($stat == "series" && dbnumrows($seriesquery)) {
71
+	$output .= "<center><h4>"._SERIES."</h4></center><table class=\"tblborder\"  width=\"90%\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><th>"._TITLE."</th>".($reviewsallowed ? "<th>"._REVIEWS."</th>" : "").($favorites ? "<th>"._FAVORITE."</th>" : "")."</tr>";
72
+	while($series = dbassoc($seriesquery)) {
73
+		$output .= "<tr><td class=\"tblborder\"><a href=\"series.php?seriesid=$series[seriesid]\">".stripslashes($series['title'])."</a> ".ratingpics($series['rating'])."</td>".($reviewsallowed ? "<td class=\"tblborder\" align=\"center\"><a href=\"reviews.php?type=SE&amp;item=$series[seriesid]\">$series[reviews]</a></td>" : "").($favorites ? "<td class=\"tblborder\" align=\"center\">".($series['count'] ? "<a href=\"user.php?action=stats&amp;favseries=$series[seriesid]\">$series[count]</a>" : "0")."</td>" : "")."</td></tr>";
74
+		$serieslist[] = $series['seriesid'];
75
+	}
76
+	$output .= "</table>";
77
+}
78
+$reviewquery = dbquery("SELECT count(reviewid) FROM ".TABLEPREFIX."fanfiction_reviews WHERE uid = '$uid' AND review != 'No Review'");
79
+list($reviewcount) = dbrow($reviewquery);
80
+$authorof[] = "<a href='".$thislink."action=reviewsby'>$reviewcount "._REVIEWS."</a>";
81
+$aocode = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'AO'");
82
+while($ao = dbassoc($aocode)) {
83
+	eval($ao['code_text']);
84
+}
85
+if(empty($stat)) $output .= "<div class='authorstats'><span class='label'>"._AUTHOROF."</span> ". implode(", ", $authorof)."</div>";
86
+if($favorites) {
87
+	$favof = dbquery("SELECT count(uid) FROM ".TABLEPREFIX."fanfiction_favorites WHERE item = '$uid' AND type = 'AU'");
88
+	list($favcount) = dbrow($favof);
89
+	if(isset($_GET['favstor']) && isNumber($_GET['favstor'])) {
90
+		$favstor = $_GET['favstor'];
91
+		$squery = "SELECT title FROM ".TABLEPREFIX."fanfiction_stories WHERE sid = '$favstor' LIMIT 1";
92
+		$story = dbquery($squery);
93
+		list($title) = dbrow($story);
94
+		$output =  "<div class='sectionheader'>"._FAVORITE.": $title</div>";
95
+		$countquery = "SELECT count(uid) FROM ".TABLEPREFIX."fanfiction_favorites WHERE type = 'ST' AND item = '$favstor'";
96
+		$authorquery = "SELECT ap.stories, "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid FROM ".TABLEPREFIX."fanfiction_favorites as fav LEFT JOIN "._AUTHORTABLE." ON fav.uid = "._UIDFIELD." LEFT JOIN  ".TABLEPREFIX."fanfiction_authorprefs AS ap ON ap.uid = fav.uid WHERE fav.item = '$favstor' AND fav.type = 'ST' GROUP BY fav.uid";
97
+		$pagelink= $thislink."action=stats&amp;favstor=$favstor".($offset > 0 ? "&amp;offset=$offset" : "")."&amp;";
98
+		include("includes/members_list.php");
99
+	}
100
+	else if(isset($_GET['favseries']) && isNumber($_GET['favseries'])) {
101
+		$favseries = $_GET['favseries'];
102
+		$story = dbquery("SELECT title FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$favseries' LIMIT 1");
103
+		list($title) = dbrow($story);
104
+		$output =  "<div class='sectionheader'>"._FAVORITE.": $title</div>";
105
+		$countquery = "SELECT count(uid) FROM ".TABLEPREFIX."fanfiction_favorites WHERE item = '$favseries' AND type = 'SE'";
106
+		$authorquery = "SELECT ap.stories,"._PENNAMEFIELD." as penname, "._UIDFIELD." as uid FROM ".TABLEPREFIX."fanfiction_favorites as fav LEFT JOIN "._AUTHORTABLE." ON fav.uid = "._UIDFIELD." LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs AS ap ON ap.uid = fav.uid WHERE fav.item = '$favseries' AND fav.type = 'SE' GROUP BY fav.uid";
107
+		$pagelink= $thislink."action=stats&amp;favseries=$favseries".($offset > 0 ? "&amp;offset=$offset" : "")."&amp;";
108
+		include("includes/members_list.php");
109
+	}
110
+	else if($stat == "favauthor") {
111
+		$output =  "<div class='sectionheader'>"._FAVORITE.": $penname</div>";
112
+		$countquery = "SELECT count(uid) FROM ".TABLEPREFIX."fanfiction_favorites WHERE item = '$uid' AND type = 'AU'";
113
+		$authorquery = "SELECT ap.stories, "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid FROM ".TABLEPREFIX."fanfiction_favorites AS fav LEFT JOIN "._AUTHORTABLE." ON fav.uid = "._UIDFIELD." LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs as ap ON ap.uid = fav.uid WHERE  fav.item = '$uid' AND fav.type = 'AU' GROUP BY fav.uid";
114
+		$pagelink= $thislink."action=stats&amp;stat=favauthor".($offset > 0 ? "&amp;offset=$offset" : "")."&amp;";
115
+		include("includes/members_list.php");
116
+	}
117
+
118
+	$favlist = array( );
119
+	$panelquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_type = 'F' AND panel_name != 'favlist' ORDER BY panel_title ASC");
120
+	if(!$panelquery) $output .= write_error(_ERROR);
121
+	while($panel = dbassoc($panelquery)) {
122
+		$panellink = "";
123
+		if(substr($panel['panel_name'], 0, 3) == "fav" && $type = substr($panel['panel_name'], 3)) {
124
+			if($panel['panel_name'] == "favlist") continue;
125
+			$itemcount = 0;
126
+			$countquery = dbquery("SELECT COUNT(item) FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '$uid' AND type = '$type'");
127
+			list($itemcount) = dbrow($countquery);
128
+			$favlist[] = "<a href=\"".$thislink."action=".$panel['panel_name']."&amp;uid=$uid\">".(isset($itemcount) ? " $itemcount " : "").stripslashes($panel['panel_title'])."</a>";
129
+		}
130
+	}
131
+	if(empty($stat)) $output .= "<div class='authorstats'><span class='label'>"._FAVOF.": </span> <a href='".$thislink."action=stats&amp;stat=favauthor'>$favcount "._MEMBERS."</a><br /><span class='label'>".(USERUID == $uid ? _YOURFAVORITES : _FAVORITESOF." $penname").": </span>".implode(", ", $favlist)."</div>";
132
+}
133
+?>
0 134
\ No newline at end of file