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,241 @@
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
+function featured( ) {
28
+	global $tableprefix, $dbconnect;
29
+
30
+	if($_GET['retire'])
31
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET featured = 2 WHERE sid = ".$_GET['retire']);
32
+	if($_GET['feature'])
33
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET featured = 1 WHERE sid = ".$_GET['feature']);
34
+	$fquery = "SELECT stories.*, stories.title as title, author.penname, DATE_FORMAT(FROM_UNIXTIME(stories.updated), '%Y.%m.%d') as updatesort, DATE_FORMAT(stories.date, '$datim') as date, DATE_FORMAT(FROM_UNIXTIME(stories.updated), '$datim') as updated FROM ".TABLEPREFIX."fanfiction_authors as author, ".TABLEPREFIX."fanfiction_stories as stories WHERE stories.featured > 0 AND stories.uid = author.uid ORDER BY stories.featured";
35
+	$fresult = dbquery($fquery) or die(_FATALERROR."Query: ".$fquery."<br />Error: (". $dbconnect->errno.") ". $dbconnect->error);
36
+	$output = "<center><table class=\"tblborder\" cellpadding=\"5\"><tr><th colspan=\"2\" align=\"center\">"._FEATUREDSTORIES."</th></tr>";
37
+	if(!dbnumrows($fresult)) $output .= "<tr><td colspan=\"2\" align=\"center\">"._NOSTORIES."</td><tr>";
38
+	while($story = dbassoc($fresult)) {
39
+		$output .= "<tr><td class=\"tblborder\"><a href=\"viewstory.php?sid=".$story['sid']."\">$story[title]</a> "._BY." <a href=\"viewuser.php?uid=".$story['uid']."\">".$story['penname']."</a></td><td class=\"tblborder\" align=\"center\">".($story['featured'] == 1 ? "<a href=\"admin.php?action=featured&retire=".$story['sid']."\">"._CURRENT."</a>" : "<b>"._RETIRED."</b>")."</td></tr>";
40
+	}
41
+	$output .= "</table>"._FEATUREDNOTE;
42
+	return $output;
43
+}
44
+// end featured
45
+
46
+function submitted()
47
+{
48
+	global $tableprefix, $admincats, $allowed_tags, $dbconnect;
49
+		$output = "<center><h4>"._SUBMITTED."</h4></center>";
50
+		$query = "SELECT story.title as storytitle, chapter.uid, chapter.sid, story.catid, chapter.chapid, chapter.inorder, chapter.title, author.penname FROM (".TABLEPREFIX."fanfiction_chapters as chapter, ".TABLEPREFIX."fanfiction_authors as author) LEFT JOIN ".TABLEPREFIX."fanfiction_stories as story ON story.sid = chapter.sid WHERE chapter.validated = '0' AND chapter.uid = author.uid ORDER BY story.title ASC, chapter.inorder ASC";
51
+		$result = dbquery($query) or die(_FATALERROR."Query: ".$query."<br />Error: (". $dbconnect->errno.") ". $dbconnect->error);
52
+		$output .= "<table class=\"tblborder\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\"><tr class=\"tblborder\"><th>"._TITLE."</th><th>"._AUTHOR."</th><th>"._CATEGORY."</th><th>"._OPTIONS."</th></tr>";
53
+		$array = explode(",", $admincats);
54
+		while ($story = dbassoc($result))
55
+		{
56
+			unset($catstring);
57
+			$result3 = dbquery("SELECT catid, category FROM ".TABLEPREFIX."fanfiction_categories WHERE FIND_IN_SET(catid, '".$story['catid']."')");
58
+			while($cats = dbassoc($result3)) {
59
+				$catstring[] = "<a href=\"categories.php?catid=".$cats['catid']."\">".$cats['category']."</a>";
60
+			}
61
+			if(!$admincats || sizeof(array_intersect(explode(",", $story['catid']), explode(",", $admincats)))) {
62
+				$output .= "<tr class=\"tblborder\">";
63
+				$output .= "<td class=\"tblborder\"><a href=\"viewstory.php?sid=".$story['sid']."\">".$story['storytitle']."</a>";
64
+				if($story['title']) $output .= " <b>:</b> <a href=\"viewstory.php?sid=".$story['sid']."&amp;chapter=".$story['inorder']."\">".$story['title']."</a>";
65
+				$output .= "<td class=\"tblborder\"><a href=\"viewuser.php?uid=".$story['uid']."\">".$story['penname']."</a></td>";
66
+				$output .= "<td class=\"tblborder\">".(is_array($catstring) ? implode(", ", $catstring) : "")."</td>";
67
+			$output .= "<td class=\"tblborder\"><a href=\"admin.php?action=validate&amp;chapid=".$story['chapid']."\">"._VALIDATE."</a> | "._DELETE.": <a href=\"stories.php?action=delete&amp;chapid=".$story['chapid']."&amp;sid=".$story['sid']."&amp;admin=1&amp;uid=".$story['uid']."\">"._CHAPTER."</a> "._OR." <a href=\"stories.php?action=delete&amp;sid=".$story['sid']."&amp;admin=1\">"._STORY."</a> | <a href=\"javascript:pop('admin.php?action=yesletter&uid=".$story['uid']."&chapid=".$story['chapid']."', 500, 400, 'yes')\">"._YESLETTER."</a> | <a href=\"javascript:pop('admin.php?action=noletter&uid=".$story['uid']."&chapid=".$story['chapid']."', 500, 400, 'yes')\">"._NOLETTER."</a></td></tr>";
68
+			}
69
+		}
70
+		$output .= "</table>";
71
+
72
+	return $output;
73
+}
74
+// end submitted function
75
+
76
+function validate( ) {
77
+	global $tableprefix, $level, $store, $storiespath, $allowed_tags, $admincats, $sitename, $siteemail, $url, $alertson;
78
+
79
+	$output  = "<center><h4>"._VIEWSUBMITTED."</h4></center>";
80
+	if($_GET['validate'] == "yes") {
81
+		$storyquery = dbquery("SELECT story.validated, story.catid, story.sid, story.title, story.summary, story.uid, author.penname, chapter.inorder FROM ".TABLEPREFIX."fanfiction_stories as story, ".TABLEPREFIX."fanfiction_chapters  as chapter, ".TABLEPREFIX."fanfiction_authors as author WHERE author.uid = story.uid AND chapter.sid = story.sid AND chapter.chapid ='".$_GET['chapid']."' LIMIT 1");
82
+		list($validated, $catid, $sid, $title, $summary, $authoruid, $author, $inorder) = dbassoc($storyquery);
83
+		if($admincats == "0" || sizeof(array_intersect(explode(",", $catid), explode(",", $admincats)))) {
84
+			include("includes/emailer.php");
85
+			if($validated != "1") {
86
+				dbquery("UPDATE ".TABLEPREFIX. "fanfiction_stories SET validated = '1', updated = '".time()."' WHERE sid = '".$_GET['sid']."'");
87
+				$categories = explode(",", $catid);
88
+				include("functions.php");
89
+				foreach($categories as $cat) {
90
+					categoryitems($cat, 1);
91
+				}
92
+				if($alertson) {
93
+					$subject = _NEWSTORYAT;
94
+					$mailtext = sprintf(_AUTHORALERTNOTE, $title, $author, $summary, $sid);
95
+					$favorites = dbquery("SELECT author.uid, email, penname FROM ".TABLEPREFIX."fanfiction_favauth as fav, ".TABLEPREFIX."fanfiction_authors as author WHERE fav.favuid = $authoruid AND fav.uid = author.uid");
96
+					while($favuser = dbassoc($favorites)) { 
97
+						sendemail($favuser['penname'], $favuser['email'], $sitename, $siteemail, $subject, $mailtext, "html");
98
+					}				
99
+				}
100
+			}
101
+			else if($alertson) {
102
+				$subject = _STORYALERT;
103
+				$mailtext = sprintf(_STORYALERTNOTE, $title, $author, $sid, $inorder);
104
+				$favorites = dbquery("SELECT author.uid, penname, email FROM ".TABLEPREFIX."fanfiction_favstor as fav, ".TABLEPREFIX."fanfiction_authors as author WHERE sid = '$sid' AND fav.uid = author.uid");
105
+				while($favuser = dbassoc($favorites)) { 
106
+					sendemail($favuser['penname'], $favuser['email'], $sitename, $siteemail, $subject, $mailtext, "html");
107
+				}
108
+			}
109
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET validated = '1' WHERE chapid = '".$_GET['chapid']."'");
110
+			dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET updated = '" . time() . "' WHERE sid = '$sid'");
111
+			$output .= "<center><b>"._STORYVALIDATED."</b></center>";
112
+		}
113
+		else
114
+			$output .= "<br /><br /><center>"._NOTAUTHORIZEDADMIN."  "._TRYAGAIN."</center><br /><br />";
115
+	}
116
+	else {
117
+			$result = dbquery("SELECT story.title as storytitle, story.sid, story.catid, story.rid, story.gid, story.charid, story.wid, story.summary as storysummary, chapter.chapid, chapter.title, chapter.storytext, author.penname, chapter.uid as uid FROM ".TABLEPREFIX."fanfiction_authors as author, ".TABLEPREFIX."fanfiction_stories as story, ".TABLEPREFIX."fanfiction_chapters as chapter WHERE chapter.chapid = '".$_GET['chapid']."' AND chapter.sid = story.sid AND chapter.uid = author.uid");
118
+			$story = dbassoc($result);
119
+			$output .= "<b>"._AUTHOR.":</b> ".$story['penname']."<br />";
120
+			$output .= "<b>"._TITLE.":</b> ".$story['storytitle'].": ".$story['title'];
121
+			$output .= "<br />";
122
+			$result3 = dbquery("SELECT catid, category FROM ".TABLEPREFIX."fanfiction_categories WHERE FIND_IN_SET(catid, '".$story['catid']."')");
123
+			$catstring = "";
124
+			$count = 0;
125
+			while($cats = dbassoc($result3)) {
126
+				if($count > 0) $catstring .= ", ";
127
+				$catstring .= "<a href=\"categories.php?catid=".$cats['catid']."\">".$cats['category']."</a>";
128
+				$categories[] = $cats['catid'];
129
+				$count++;
130
+			}
131
+			$output .= "<b>"._CATEGORY.":</b> $catstring<br />";
132
+
133
+			$output .= "<b>"._GENRES.":</b> ".(isset($story['gid']) ? preg_replace("/,/", ", ", $story['gid']) : _NONE);
134
+			$output .= "<br />";
135
+			$output .= "<b>"._RATING.":</b> ".$story['rid']."<br />";
136
+			if($story['wid'] != "")
137
+			{
138
+				$output .= "<b>"._WARNINGS.":</b> ".(isset($story['wid']) ? preg_replace("/,/", ", ", $story['wid']) : _NONE);
139
+				$output .= "<br />";
140
+			}
141
+			$output .= "<b>"._CHARACTERS.":</b> ".$story['charid'];
142
+			$output .= "<br />";
143
+			$output .= "<b>"._SUMMARY.":</b> ".$story['storysummary']."<br />";
144
+			$output .= "<a href=\"admin.php?action=validate&amp;sid=".$story['sid']."&amp;chapid=".$story['chapid']."&amp;validate=yes\">"._VALIDATE."</a> | <a href=\"stories.php?action=editstory&amp;sid=$story[sid]&amp;admin=1\">"._EDIT." - "._STORY."</a> | <a href=\"stories.php?action=delete&amp;sid=$story[sid]\">"._DELETE." - "._STORY."</a> | <a href=\"javascript:pop('admin.php?action=yesletter&amp;uid=$story[uid]&amp;chapid=$story[chapid]', 400, 300, 'yes')\">"._YESLETTER."</a> | <a href=\"javascript:pop('admin.php?action=noletter&amp;uid=$story[uid]&amp;chapid=$story[chapid]',400, 300, 'yes')\">"._NOLETTER."</a><br />";
145
+			if($store == "files")
146
+			{
147
+				$file = "$storiespath/".$story['uid']."/".$story['chapid'].".txt";
148
+				$log_file = fopen($file, "r");
149
+				$file_contents = fread($log_file, filesize($file));
150
+				$storytext .= $file_contents;
151
+				fclose($log_file);
152
+			}
153
+			else if($store == "mysql")
154
+			{
155
+				$storytext .= $story['storytext'];
156
+			}
157
+			if(strpos($story, "<br>") === false && strpos($story, "<p>") === false && strpos($story, "<br />") === false) $storytext = nl2br($storytext);
158
+			$storytext = format_story($storytext, $allowed_tags);
159
+			$output .= $storytext;
160
+			$output .= "<br /><br />";
161
+			$output .= "<a href=\"admin.php?action=validate&amp;sid=".$story['sid']."&amp;chapid=".$story['chapid']."&amp;validate=yes\">"._VALIDATE."</a> | <a href=\"stories.php?action=editchapter&amp;chapid=".$story['chapid']."&amp;admin=1\">"._EDIT." - "._CHAPTER."</a> | <a href=\"stories.php?action=delete&amp;chapid=".$story['chapid']."&amp;sid=".$story['sid']."&amp;admin=1&amp;uid=".$story['uid']."\">"._DELETE." - "._CHAPTER."</a> | <a href=\"javascript:pop('admin.php?action=yesletter&amp;uid=".$story['uid']."&amp;chapid=".$story['chapid']."', 400, 300, 'yes')\">"._YESLETTER."</a> | <a href=\"javascript:pop('admin.php?action=noletter&amp;uid=".$story['uid']."&amp;chapid=".$story['chapid']."',400, 300, 'yes')\">"._NOLETTER."</a><br />";
162
+		}
163
+	return $output;
164
+}
165
+// end validate
166
+
167
+function yesletter( ) {
168
+	global $tableprefix, $level, $adminemail, $sitename, $siteemail, $allowed_tags;
169
+	
170
+	if($_POST['submit']) {
171
+
172
+		if($adminemail)
173
+			$ademail = $adminemail;
174
+		else 
175
+			$ademail = $siteemail;
176
+		$subject = stripinput($_POST['subject']);
177
+		$letter = nl2br(stripinput($_POST['letter']));
178
+			
179
+		include("includes/emailer.php");
180
+		$result = sendemail($_POST['email'], $_POST['email'], $adminname, $ademail, $subject, $letter, "html");
181
+
182
+		if($result) echo "<div style='text-align: center;'>"._EMAILSENT."</div>";
183
+		else echo "<div style='text-align: center;'>"._ERROR."</div>";
184
+	}
185
+	else {
186
+			$authorquery = dbquery("SELECT email,penname FROM ".TABLEPREFIX."fanfiction_authors WHERE uid = '".$_GET['uid']."' LIMIT 1");
187
+			$author = dbassoc($authorquery);
188
+			$storyquery = dbquery("SELECT story.title, chapter.title as chapter FROM ".TABLEPREFIX."fanfiction_stories as story, ".TABLEPREFIX."fanfiction_chapters as chapter WHERE chapter.chapid = '".$_GET['chapid']."' AND chapter.sid = story.sid LIMIT 1");
189
+			$story = dbassoc($storyquery);
190
+			$letter = file_get_contents("messages/thankyou.txt");
191
+			echo "<body>";
192
+			echo "<table><tr><td>Story:</td><td>".$story['title'].": ".$story['chapter']."</td></tr>";
193
+			echo "<tr><td>"._BY.":</td><td>".$author['penname']."</td></tr>";
194
+			echo "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=yesletter\">
195
+				<tr><td>To:</td><td><INPUT  type=\"text\" class=\"textbox=\" name=\"email\" value=\"".$author['email']."\"></td></tr>
196
+				<tr><td>From:</td><td><INPUT  type=\"text\" class=\"textbox=\" name=\"ademail\" value=\"$adminemail\"></td></tr>
197
+				<tr><td>Subject:</td><td><INPUT  type=\"text\" class=\"textbox=\" name=\"subject\" value=\"Your Submission to $sitename\"></td></tr>
198
+				<tr><td colspan=\"2\"><textarea class=\"textbox\" name=\"letter\" cols=\"50\" rows=\"8\">$letter</TEXTAREA></td></tr><tr><td colspan=\"2\"><INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\"></form></td></tr></table></body></html>";
199
+	}
200
+	exit( );
201
+}
202
+// end yesletter
203
+
204
+function noletter( ) {
205
+	global $tableprefix, $level, $adminemail, $sitename, $siteemail, $allowed_tags, $adminloggedin;
206
+	if($_POST['submit'])
207
+		{
208
+		if($adminemail)
209
+			$ademail = $adminemail;
210
+		else 
211
+			$ademail = $siteemail;
212
+		$subject = stripinput($_POST['subject']);
213
+		$letter = nl2br(stripinput($_POST['letter']));
214
+			
215
+		include("includes/emailer.php");
216
+		$result = sendemail($_POST['email'], $_POST['email'], $adminname, $ademail, $subject, $letter, "html");
217
+
218
+		if($result) echo "<div style='text-align: center;'>"._EMAILSENT."</div>";
219
+		else echo "<div style='text-align: center;'>"._ERROR."</div>";
220
+	}
221
+	else
222
+	{
223
+		$authorquery = dbquery("SELECT email,penname FROM ".TABLEPREFIX."fanfiction_authors WHERE uid = '".$_GET['uid']."' LIMIT 1");
224
+		$author = dbassoc($authorquery);
225
+		$storyquery = dbquery("SELECT story.title, chapter.title as chapter FROM ".TABLEPREFIX."fanfiction_stories as story, ".TABLEPREFIX."fanfiction_chapters as chapter WHERE chapter.chapid = '".$_GET['chapid']."' AND chapter.sid = story.sid LIMIT 1");
226
+		$story = dbassoc($storyquery);
227
+		$letter = file_get_contents("messages/nothankyou.txt");
228
+		echo "<body>";
229
+		echo "<table><tr><td>Story:</td><td>".$story['title'].": ".$story['chapter']."</td></tr>";
230
+		echo "<tr><td>"._BY.":</td><td>".$author['penname']."</td></tr>";
231
+		echo "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=noletter\">
232
+			<tr><td>To:</td><td><INPUT  type=\"text\" class=\"textbox=\" name=\"email\" value=\"".$author[email]."\"></td></tr>
233
+			<tr><td>From:</td><td><INPUT  type=\"text\" class=\"textbox=\" name=\"ademail\" value=\"$adminemail\"></td></tr>
234
+			<tr><td>Subject:</td><td><INPUT type=\"text\" class=\"textbox=\"  name=\"subject\" value=\"Your Submission to $sitename\"></td></tr>
235
+			<tr><td colspan=\"2\"><textarea class=\"textbox\" name=\"letter\" cols=\"50\" rows=\"8\">$letter</TEXTAREA></td></tr><tr><td colspan=\"2\"><INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\"></form></td></tr></table></body></html>";
236
+	}
237
+	exit( );
238
+}
239
+// end noletter
240
+
241
+?>
0 242
\ No newline at end of file