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,405 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2007 by Tammy Keefer
4
+// Valid HTML 4.01 Transitional
5
+// Based on eFiction 1.1
6
+// Copyright (C) 2003 by Rebecca Smallwood.
7
+// http://efiction.sourceforge.net/
8
+// ----------------------------------------------------------------------
9
+// LICENSE
10
+//
11
+// This program is free software; you can redistribute it and/or
12
+// modify it under the terms of the GNU General Public License (GPL)
13
+// as published by the Free Software Foundation; either version 2
14
+// of the License, or (at your option) any later version.
15
+//
16
+// This program is distributed in the hope that it will be useful,
17
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
+// GNU General Public License for more details.
20
+//
21
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
22
+// ----------------------------------------------------------------------
23
+
24
+
25
+$current = "viewstory";
26
+
27
+include ("header.php");
28
+if(isset($_GET['action'])) $action = $_GET['action'];
29
+else $action = false;
30
+if(isset($_GET['textsize']) && isNumber($_GET['textsize'])) $textsize = $_GET['textsize'];
31
+else $textsize = 0;
32
+if(empty($chapter)) $chapter = isset($_GET['chapter']) && isNumber($_GET['chapter']) ? $_GET['chapter'] : false;
33
+
34
+	// Get the story information
35
+	$storyquery = dbquery("SELECT "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid, story.*, UNIX_TIMESTAMP(story.date) as date, UNIX_TIMESTAMP(story.updated) as updated, story.validated as valid FROM ".TABLEPREFIX."fanfiction_stories as story, "._AUTHORTABLE." WHERE story.sid = '".$sid."' AND story.uid = "._UIDFIELD);
36
+	$storyinfo = dbassoc($storyquery);
37
+	if($storyinfo['coauthors'] == 1) {
38
+		$coauthors = array();
39
+		$coauth = dbquery("SELECT "._PENNAMEFIELD." as penname, co.uid FROM ".TABLEPREFIX."fanfiction_coauthors AS co LEFT JOIN "._AUTHORTABLE." ON co.uid = "._UIDFIELD." WHERE co.sid = '".$sid."'");
40
+		while($c = dbassoc($coauth)) {
41
+			$coauthors[$c['uid']] = $c['penname'];
42
+		}
43
+		$storyinfo['coauthors'] = $coauthors;
44
+		unset($coauthors);
45
+	}
46
+	else $storyinfo['coauthors'] = array();
47
+	//  Check that the story is valid and that the visitor has permissions to read this story
48
+	$warning = "";
49
+	if(!$storyinfo) $warning = _INVALIDSTORY;
50
+	if(!$storyinfo['valid'] && !isADMIN && ($storyinfo['uid'] != USERUID || !in_array(USERUID, $storyinfo['coauthors']))) $warning = _ACCESSDENIED;
51
+	$ratingquery = dbquery("SELECT ratingwarning, warningtext FROM ".TABLEPREFIX."fanfiction_ratings WHERE rid = '".$storyinfo['rid']."' LIMIT 1");
52
+	$rating = dbassoc($ratingquery);
53
+	$warninglevel = sprintf("%03b", $rating['ratingwarning']);
54
+	$title = $storyinfo['title'];
55
+	if($warninglevel[0] && !isMEMBER) $warning = _RUSERSONLY."<br />";
56
+	else if($warninglevel[1] && empty($_SESSION[SITEKEY."_ageconsent"]) && !$ageconsent) $warning = _AGECHECK."<br /><a href='viewstory.php?sid=".$storyinfo['sid']."&amp;ageconsent=ok&amp;warning=".$storyinfo['rid']."'>".$rating['warningtext']."</a>";
57
+	else if($warninglevel[2] && empty($_SESSION[SITEKEY."_warned"][$storyinfo['rid']])) {
58
+		$warning = $rating['warningtext']."<br /><a href='viewstory.php?sid=".$storyinfo['sid']."&amp;warning=".$storyinfo['rid']."'>"._CONTINUE."</a>";
59
+	}
60
+
61
+	// if the above checks came back with a warning, output an error page.
62
+	if(!empty($warning)) {
63
+		$current = "storyerror";
64
+		// load our template files to set up the page.
65
+		if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
66
+		else $tpl = new TemplatePower("default_tpls/default.tpl");
67
+		include("includes/pagesetup.php");
68
+		$tpl->assign("output", "<div id='pagetitle'>".$title."</div>".write_error($warning));
69
+		$tpl->printToScreen( );
70
+		dbclose( );
71
+		exit( ); 
72
+	}
73
+	// End 
74
+
75
+$reviews = ""; $numreviews = ""; $reviewslink = ""; $form = ""; $rr = "";
76
+
77
+if($action == "printable") {
78
+	$settingsresults = dbquery("SELECT store, storiespath FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".SITEKEY."'");
79
+	list($store, $storiespath) = dbrow($settingsresults);
80
+	if(file_exists("$skindir/printstory.tpl")) $tpl = new TemplatePower( "$skindir/printstory.tpl" );
81
+	else $tpl = new TemplatePower("default_tpls/printstory.tpl");
82
+	include("includes/pagesetup.php");
83
+	$tpl->assign("title", stripslashes($storyinfo['title']));
84
+	$tpl->assign("author", author_link($storyinfo));
85
+	if(empty($chapter)) $chapter = "all"; // shouldn't happen but just in case
86
+	$stories = $storyinfo;
87
+	include("includes/storyblock.php");
88
+	unset($stories);
89
+	if($chapter == "all") {
90
+		if($storyinfo['storynotes']) {
91
+			$tpl->newBlock("storynotes");
92
+			$tpl->assign( "storynotes", format_story($storyinfo['storynotes']));
93
+			$tpl->gotoBlock("_ROOT");
94
+		}
95
+		$chapterinfo = dbquery("SELECT *, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX."fanfiction_chapters as c, "._AUTHORTABLE.") WHERE sid = '$sid' AND c.uid = "._UIDFIELD." AND c.validated > 0 ORDER BY inorder");
96
+		while($c = dbassoc($chapterinfo)) {
97
+			$tpl->newBlock("storyindexblock");
98
+			$tpl->assign("chapternumber", $c['inorder']);
99
+			$tpl->assign("title", "<a href='#".$c['inorder']."'>".$c['title']."</a>");
100
+			$tpl->assign("author", $c['penname']);
101
+			$tpl->gotoBlock("_ROOT");
102
+			$tpl->newBlock("chapterblock");
103
+			$tpl->assign("chaptertitle", "<a name='".$c['inorder']."'></a>".$c['title']);
104
+			$tpl->assign("chapterauthor", $c['penname']);
105
+			if(!empty($c['notes'])) {
106
+				$tpl->newBlock("notes");
107
+				$tpl->assign( "notes", format_story($c['notes']));
108
+				$tpl->gotoBlock("chapterblock");
109
+			}
110
+			if($store == "files") {
111
+				//shouldn't happen, but somehow has on occasion. :(
112
+				if(!$c['uid']) {
113
+					errorExit( );
114
+				}
115
+				$file = STORIESPATH."/".$c['uid']."/".$c['chapid'].".txt";
116
+				$log_file = @fopen($file, "r");
117
+				$file_contents = @fread($log_file, filesize($file));
118
+				$story = $file_contents;
119
+				@fclose($log_file);
120
+			}
121
+			else $story = $c['storytext'];
122
+			// The following lines cleans up problems between pre-2.0 stories and 2.0 stories.  If there's html, don't send it through nl2br and then clean up smart quotes.
123
+			$story = format_story($story);
124
+			$tpl->assign("chaptertext", $story);	
125
+			$tpl->assign("back2top", "<a href='#1'>"._BACK2INDEX."</a>");
126
+			if(!empty($c['endnotes'])) {
127
+				$tpl->newBlock("endnotes");
128
+				$tpl->assign( "endnotes", format_story($c['endnotes']));
129
+				$tpl->gotoBlock("chapterblock");
130
+			}
131
+		}
132
+	}
133
+	else {
134
+		$chapterinfo = dbquery("SELECT *, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX."fanfiction_chapters as c, "._AUTHORTABLE.") WHERE sid = '$sid' AND inorder = '$chapter' AND c.uid = "._UIDFIELD." LIMIT 1");
135
+		$c = dbassoc($chapterinfo);
136
+		// if the *CHAPTER* hasn't been validated and the viewer isn't an admin or the author throw them a warning.  
137
+		if(empty($c['validated']) && !isADMIN && USERUID != $c['uid'] && !in_array(USERUID, $stories['coauthors'])) {
138
+			$warning = write_error(_ACCESSDENIED);
139
+			$tpl->assign("archivedat", $warning);
140
+			$tpl->printToScreen( );
141
+			dbclose( );
142
+			exit( );
143
+		}
144
+
145
+		if($c['inorder'] == 1 && !empty($storyinfo['storynotes'])) {
146
+			$tpl->newBlock("storynotes");
147
+			$tpl->assign( "storynotes", format_story($storyinfo['storynotes']));
148
+			$tpl->gotoBlock("_ROOT");
149
+		}
150
+
151
+		$tpl->newBlock("chapterblock");
152
+		$tpl->assign("chaptertitle", $c['title']);
153
+		$tpl->assign("chapternumber", $c['inorder']);
154
+		$tpl->assign("chapterauthor", $c['penname']);
155
+		if(!empty($c['notes'])) {
156
+			$tpl->newBlock("notes");
157
+			$tpl->assign( "notes", format_story($c['notes']));
158
+			$tpl->gotoBlock("chapterblock");
159
+		}
160
+		//shouldn't happen, but somehow has on occasion. :(
161
+		if($store == "files") {
162
+			if(!$c['uid']) {
163
+				errorExit( );
164
+			}
165
+			$file = STORIESPATH."/".$c['uid']."/".$c['chapid'].".txt";
166
+			$log_file = @fopen($file, "r");
167
+			$file_contents = @fread($log_file, filesize($file));
168
+			$story = $file_contents;
169
+			@fclose($log_file);
170
+		}
171
+		else $story = $c['storytext'];
172
+		// The following lines cleans up problems between pre-2.0 stories and 2.0 stories.  If there's html, don't send it through nl2br and then clean up smart quotes.
173
+		$story = format_story($story);
174
+		$tpl->assign("chaptertext", $story);	
175
+			if(!empty($c['endnotes'])) {
176
+				$tpl->newBlock("endnotes");
177
+				$tpl->assign( "endnotes", format_story($c['endnotes']));
178
+				$tpl->gotoBlock("chapterblock");
179
+			}
180
+	}
181
+	$tpl->gotoBlock("_ROOT");
182
+	// Hook for adding content to the printed version of the story.
183
+	$codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'printstory'");
184
+	while($code = dbassoc($codeblocks)) {
185
+		eval($code['code_text']);
186
+	}	
187
+	$tpl->assign("archivedat", _ARCHIVEDAT." <a href=\"$url/viewstory.php?sid=$sid\">$url/viewstory.php?sid=$sid</a>");
188
+	$copyquery = dbquery("SELECT message_text FROM ".TABLEPREFIX."fanfiction_messages WHERE message_name = 'printercopyright' LIMIT 1");
189
+	list($copyright) = dbrow($copyquery);
190
+	$tpl->assign("copyright", $copyright);
191
+}
192
+else if(($displayindex && empty($chapter)) || !empty($_GET['index'])) {
193
+	if(file_exists("$skindir/storyindex.tpl")) $tpl = new TemplatePower( "$skindir/storyindex.tpl" );
194
+	else $tpl = new TemplatePower("default_tpls/storyindex.tpl");
195
+	include("includes/pagesetup.php");
196
+	$stories = $storyinfo;
197
+	// Hook for adding content to only the index of the story.
198
+	$codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'storyindex'");
199
+	while($code = dbassoc($codeblocks)) {
200
+		eval($code['code_text']);
201
+	}
202
+	include("includes/storyblock.php");
203
+	$printicon = "<a href=\"viewstory.php?action=printable&amp;textsize=$textsize&amp;sid=$sid&amp;chapter=all\" target=\"_blank\"><img src='".(isset($printer) ? $printer : "images/print.gif")."' border='0' alt='"._PRINTER."'></a>";
204
+	if($reviewsallowed && (isMEMBER || $anonreviews))
205
+			$reviewslink = "<a href=\"reviews.php?action=add&amp;item=$sid&amp;next=2&amptype=ST\">"._SUBMITREVIEW."</a>";
206
+	$tpl->assign( "reviewslink", $reviewslink );
207
+	if($storyinfo['rr']) {
208
+		$tpl->assign("roundrobin", "[<a href=\"stories.php?action=newchapter&amp;sid=".$sid."\">"._CONTRIBUTE2RR."</a>]");
209
+	}
210
+	$tpl->assign( "printicon", $printicon );
211
+	$tpl->assign( "reviewform", $form);
212
+	$tpl->assign( "output", $output );
213
+	if( $storyinfo['storynotes']) {
214
+		$tpl->newBlock("storynotes");
215
+		$tpl->assign( "storynotes", format_story($storyinfo['storynotes']));
216
+		$tpl->gotoBlock("_ROOT");
217
+	}
218
+	$chapterinfo = dbquery("SELECT chap.*, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX."fanfiction_chapters as chap, "._AUTHORTABLE.") WHERE sid = '$sid' AND chap.uid = "._UIDFIELD." AND chap.validated > 0 ORDER BY inorder");
219
+	$count = 0;
220
+	while($chap = dbassoc($chapterinfo)) {
221
+		$tpl->newBlock("storyindexblock");
222
+		$tpl->assign("chapternumber", $chap['inorder']);
223
+		$tpl->assign("title", "<a href=\"viewstory.php?sid=$sid&amp;chapter=".$chap['inorder']."\">".$chap['title']."</a>");
224
+		$tpl->assign("author", "<a href='viewuser.php?uid=".$chap['uid']."'>".$chap['penname']."</a>");
225
+		$tpl->assign("printicon", "<a href=\"viewstory.php?action=printable&amp;textsize=$textsize&amp;sid=$sid&amp;chapter=".$chap['inorder']."\" target=\"_blank\"><img src='".(isset($printer) ? $printer : "images/print.gif")."' border='0' alt='"._PRINTER."'></a>");
226
+		$tpl->assign("ratingpics", ratingpics($chap['rating']));
227
+		if($reviewsallowed) {
228
+			$tpl->assign("reviews", "<a href=\"reviews.php?type=ST&amp;item=$sid&amp;chapid=".$chap['chapid']."\">"._REVIEWS."</a>");
229
+			$tpl->assign("numreviews", "<a href=\"reviews.php?type=ST&amp;item=$sid&amp;chapid=".$chap['chapid']."\">".$chap['reviews']."</a>");
230
+		}
231
+		if(isADMIN) 
232
+			$tpl->assign("adminoptions", "<div class=\"adminoptions\"><span class='label'>"._ADMINOPTIONS.":</span> <a href=\"stories.php?action=editchapter&amp;sid=$sid&amp;chapid=".$chap['chapid']."&amp;admin=1\">"._EDIT."</a> | <a href=\"stories.php?action=delete&amp;sid=$sid&amp;chapid=".$chap['chapid']."&amp;admin=1\">"._DELETE."</a> </div>");
233
+		$tpl->assign("wordcount", $chap['wordcount']);
234
+		$tpl->assign("chapternotes", format_story($chap['notes']));
235
+		$tpl->assign("count", ($chap['count'] ? $chap['count'] : 0) );
236
+		$tpl->assign("oddeven",  ($count % 2 ? "odd" : "even"));
237
+		$tpl->gotoBlock("_ROOT");
238
+		$count++;
239
+	}
240
+}
241
+else {
242
+	if(file_exists("$skindir/viewstory.tpl")) $tpl = new TemplatePower( "$skindir/viewstory.tpl" );
243
+	else $tpl = new TemplatePower("default_tpls/viewstory.tpl");
244
+	include("includes/pagesetup.php");
245
+	$jumpmenu = "";
246
+	$jumpmenu2 = "";
247
+	if(empty($chapter) || !$chapter) $chapter = 1;
248
+	// get information about the story's chapter(s)
249
+	$chapterinfo = dbquery("SELECT chap.*, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX."fanfiction_chapters as chap, "._AUTHORTABLE.") WHERE sid = '$sid' AND chap.uid = "._UIDFIELD." ORDER BY inorder");
250
+	$chapters = dbnumrows($chapterinfo);
251
+	if($chapters > 1) {
252
+		$printicon = "<img src='".(isset($printer) ? $printer : "images/print.gif")."' border='0' alt='"._PRINTER."'> <a href=\"viewstory.php?action=printable&amp;textsize=$textsize&amp;sid=$sid&amp;chapter=$chapter\" target=\"_blank\">"._CHAPTER."</a> "._OR." <a href=\"viewstory.php?action=printable&amp;textsize=$textsize&amp;sid=$sid&amp;chapter=all\" target=\"_blank\">"._STORY."</a>";
253
+		$jumpmenu .= "<form name=\"jump\" action=\"\">";
254
+		if($chapter > 1) 
255
+			$prev = "<a href=\"viewstory.php?sid=$sid&amp;".($textsize ? "textsize=$textsize&amp;" : "")."chapter=".($chapter-1)."\" class=\"prev\">"._PREVIOUS."</a> ";
256
+		$jumpmenu .= "<select class=\"textbox\" name=\"chapter\" onchange=\"if(document.jump.chapter.selectedIndex.value != $chapter) document.location = 'viewstory.php?sid=$sid&amp;textsize=$textsize&amp;chapter=' + document.jump.chapter.options[document.jump.chapter.selectedIndex].value\">";
257
+		while($chap = dbassoc($chapterinfo)) {
258
+			if($chap['validated']) $jumpmenu .= "<option value='".$chap['inorder']."'".(isset($chapter) && $chap['inorder'] == $chapter ? " selected" : "").">".$chap['inorder'].". ".stripslashes($chap['title'])."</option>";
259
+			if($chap['inorder'] == $chapter) {
260
+				$inorder = $chapter;
261
+				$notes = isset($chap['notes']) ? format_story($chap['notes']) : false;
262
+				$endnotes = isset($chap['endnotes']) ? format_story($chap['endnotes']) : false;
263
+				$chapid = $chap['chapid'];
264
+				$story = stripslashes($chap['storytext']);
265
+				$chapterauthor = $chap['uid'];
266
+				$chapterpenname = $chap['penname'];
267
+				$valid = $chap['validated'];
268
+				$chaptertitle = stripslashes($chap['title']);
269
+			}
270
+		}
271
+		$jumpmenu .= "</select>";
272
+		if($chapter < $chapters) {
273
+			$nextchapter = $chapter + 1;
274
+			$next = "<a href=\"viewstory.php?sid=$sid&amp;textsize=$textsize&amp;chapter=".($chapter+1)."\" class=\"next\">"._NEXT."</a>";
275
+		}
276
+		else {
277
+			$nextchapter = "";
278
+			// Hook for adding content to only the end of the story.
279
+			$codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'storyend'");
280
+			while($code = dbassoc($codeblocks)) {
281
+				eval($code['code_text']);
282
+			}
283
+		}
284
+		$jumpmenu .= "</form>";
285
+	}
286
+	// if the story has only one chapter this is what happens
287
+	else {
288
+		$chapter = dbassoc($chapterinfo);
289
+		$chapterauthor = $chapter['uid'];
290
+		$chapterpenname = $chapter['penname'];
291
+		$chaptertitle = $chapter['title'];
292
+		$chapid = $chapter['chapid'];
293
+		$title = stripslashes($chapter['title']);
294
+		$inorder = $chapter['inorder'];
295
+		$notes = format_story($chapter['notes']);
296
+		$endnotes = format_story($chapter['endnotes']);
297
+		$story = $chapter['storytext'];
298
+		$valid = $chapter['validated'];
299
+		$nextchapter = "";
300
+		$codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'storyend'");
301
+		while($code = dbassoc($codeblocks)) {
302
+			eval($code['code_text']);
303
+		}
304
+		$printicon = "<a href=\"viewstory.php?action=printable&amp;sid=$sid&amp;textsize=$textsize&amp;chapter=1\" target=\"_blank\"><img src='".(isset($printer) ? $priner : "images/print.gif")."' border='0' alt='"._PRINTER."'></a>";
305
+	}
306
+	// if the *CHAPTER* hasn't been validated and the viewer isn't an admin or the author throw them a warning.  
307
+	if(!$valid && !isADMIN && USERUID != $chapterauthor && !in_array($chapterauthor, $storyinfo['coauthors'])) {
308
+		$warning = accessDenied( );
309
+	}
310
+	$stories = $storyinfo;
311
+	$tpl->gotoBlock("_ROOT");
312
+	$jumpmenu2 = ""; 
313
+	include("includes/storyblock.php");
314
+	unset($adminlinks);
315
+	if(isADMIN && uLEVEL < 3) 
316
+		$adminlinks = "<div class=\"adminoptions\"><span class='label'>"._ADMINOPTIONS.":</span> "._EDIT." - <a href=\"stories.php?action=editstory&amp;sid=$sid&amp;admin=1\">"._STORY."</a> "._OR." <a href=\"stories.php?action=editchapter&amp;chapid=$chapid&amp;admin=1\">"._CHAPTER."</a> | "._DELETE." - <a href=\"stories.php?action=delete&amp;sid=$sid&amp;admin=1\">"._STORY."</a> "._OR." <a href=\"stories.php?action=delete&amp;chapid=$chapid&amp;sid=$sid&amp;admin=1\">"._CHAPTER."</a></div>";
317
+	if(isMEMBER && $favorites) {
318
+		$jumpmenu2 .= "<option value=\"user.php?action=favst&amp;add=1&amp;sid=$sid\">"._ADDSTORY2FAVES."</option><option value=\"user.php?action=favau&amp;add=1&amp;author=".$stories['uid'].(count($storyinfo['coauthors']) ? ",".implode(",", array_keys($storyinfo['coauthors'])) : "")."\">"._ADDAUTHOR2FAVES."</option>";
319
+	}
320
+	if($reviewsallowed ) {
321
+		if(isMEMBER || $anonreviews) {
322
+			$reviewslink = "<a href=\"reviews.php?action=add&amp;type=ST&amp;item=$sid&amp;chapid=$chapid&amp;next=$nextchapter\">"._SUBMITREVIEW."</a>";
323
+			$jumpmenu2 .= "<option value=\"reviews.php?action=add&amp;type=ST&amp;item=$sid&amp;chapid=$chapid&amp;next=$nextchapter\">"._SUBMITREVIEW."</option>";
324
+		}
325
+		else $reviewslink = write_message(sprintf(_LOGINTOREVIEW, strtolower($pagelinks['login']['link']), strtolower($pagelinks['register']['link'])));
326
+	}
327
+	$tpl->assign("reportthis", "[<a href=\""._BASEDIR."contact.php?action=report&amp;url=viewstory.php?chapid=$chapid\">"._REPORTTHIS."</a>]");
328
+	$jumpmenu2 .= "<option value=\"contact.php?action=report&amp;url=viewstory.php?chapid=$chapid\">"._REPORTTHIS."</option>";
329
+	if($stories['rr']) {
330
+		$rr = "[<a href=\"stories.php?action=newchapter&amp;sid=".$sid."\">"._CONTRIBUTE2RR."</a>]";
331
+		$jumpmenu2 .= "<option value=\"stories.php?action=newchapter&amp;sid=".$sid."\">"._CONTRIBUTE2RR."</option>";
332
+	}
333
+	if(isset($jumpmenu2)) $jumpmenu2 = "<form name=\"jump2\" action=\"\"><select class=\"textbox\" name=\"jump2\" onchange=\"if(this.selectedIndex.value != 'false') document.location = document.jump2.jump2.options[document.jump2.jump2.selectedIndex].value\"><option value=\"false\">"._OPTIONS."</option>".$jumpmenu2."</select></form>";
334
+	if($reviewsallowed) {
335
+		if(isMEMBER || $anonreviews) {
336
+			$item = $sid;
337
+			$type = "ST";
338
+			include("includes/reviewform.php");
339
+		}
340
+		else $form = write_message(sprintf(_LOGINTOREVIEW, strtolower($pagelinks['login']['link']), strtolower($pagelinks['register']['link'])));
341
+	}
342
+	$textsizer = "<a href=\"viewstory.php?sid=$sid".($inorder ? "&amp;chapter=$inorder" : "")."&amp;textsize=".($textsize - 1)."\">-</a> <strong>". _TEXTSIZE. "</strong> <a href=\"viewstory.php?sid=$sid".($inorder ? "&amp;chapter=$inorder" : "")."&amp;textsize=".($textsize + 1)."\">+</a> ";
343
+	// okay now that we know they can see the story and the chapter add 1 to the story and chapter counts;
344
+	if(empty($viewed) || (is_array($viewed) && !in_array($sid, $viewed))) {
345
+		dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET count = count + 1 WHERE sid = '$sid'  LIMIT 1");
346
+		$viewed[] = $sid;
347
+		$_SESSION['viewed'] = $viewed;
348
+	}
349
+	dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET count = count + 1 WHERE chapid = '$chapid' LIMIT 1");
350
+	// end counters
351
+	// if the text of the chapters is being stored in files we need to get that text here
352
+	if($store == "files") {
353
+		//shouldn't happen, but somehow has on occasion. :(
354
+		if(!$chapterauthor) {
355
+			errorExit(_ERROR);
356
+		}
357
+		$file = STORIESPATH."/$chapterauthor/$chapid.txt";
358
+		$log_file = @fopen($file, "r");
359
+		$file_contents = @fread($log_file, filesize($file));
360
+		$story = $file_contents;
361
+		@fclose($log_file);
362
+	}
363
+	$story = format_story($story);
364
+	if(isset($adminlinks)) $tpl->assign( "adminlinks", $adminlinks );
365
+	$tpl->assign( "printicon", $printicon );
366
+	$tpl->assign( "output", $output );
367
+	if($inorder == 1 && !empty($storyinfo['storynotes'])) {
368
+		$tpl->gotoBlock("_ROOT");
369
+		$tpl->newBlock("storynotes");
370
+		$tpl->assign( "storynotes", stripslashes($storyinfo['storynotes']));
371
+		$tpl->gotoBlock("_ROOT");
372
+	}
373
+	if(!empty($notes)) {
374
+		$tpl->newBlock("notes");
375
+		$tpl->assign( "notes", $notes);
376
+		$tpl->gotoBlock("_ROOT");
377
+	}
378
+	if(!empty($endnotes)) {
379
+		$tpl->newBlock("endnotes");
380
+		$tpl->assign( "endnotes", $endnotes);
381
+		$tpl->gotoBlock("_ROOT");
382
+	}
383
+	$tpl->gotoBlock("_ROOT");
384
+	$tpl->assign("chaptertitle", $chaptertitle);
385
+	$tpl->assign("chapternumber", $inorder);
386
+	$tpl->assign( "story", "<span style=\"font-size: ".(100 + ($textsize * 20))."%;\">$story</span>" );
387
+	$tpl->assign("textsizer", $textsizer);
388
+	if(isset($jumpmenu)) $tpl->assign( "jumpmenu", $jumpmenu);
389
+	if(isset($jumpmenu2)) $tpl->assign( "jumpmenu2", $jumpmenu2);
390
+	$tpl->assign( "roundrobin", $rr );
391
+	$tpl->assign( "reviewform", $form);
392
+	if(isset($addtofaves)) $tpl->assign( "addtofaves", $addtofaves );
393
+	if(isset($next)) $tpl->assign( "next", $next );
394
+	if(isset($prev)) $tpl->assign( "prev", $prev );
395
+
396
+}
397
+// Hook for adding content to view story pages.
398
+$codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'viewstory'");
399
+while($code = dbassoc($codeblocks)) {
400
+	eval($code['code_text']);
401
+}
402
+$tpl->printToScreen();
403
+dbclose( );
404
+
405
+?>
0 406
\ No newline at end of file