"; else if($warninglevel[1] && empty($_SESSION[SITEKEY."_ageconsent"]) && !$ageconsent) $warning = _AGECHECK."
".$rating['warningtext'].""; else if($warninglevel[2] && empty($_SESSION[SITEKEY."_warned"][$storyinfo['rid']])) { $warning = $rating['warningtext']."
"._CONTINUE.""; } // if the above checks came back with a warning, output an error page. if(!empty($warning)) { $current = "storyerror"; // load our template files to set up the page. if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" ); else $tpl = new TemplatePower("default_tpls/default.tpl"); include("includes/pagesetup.php"); $tpl->assign("output", "
".$title."
".write_error($warning)); $tpl->printToScreen( ); dbclose( ); exit( ); } // End $reviews = ""; $numreviews = ""; $reviewslink = ""; $form = ""; $rr = ""; if($action == "printable") { $settingsresults = dbquery("SELECT store, storiespath FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".SITEKEY."'"); list($store, $storiespath) = dbrow($settingsresults); if(file_exists("$skindir/printstory.tpl")) $tpl = new TemplatePower( "$skindir/printstory.tpl" ); else $tpl = new TemplatePower("default_tpls/printstory.tpl"); include("includes/pagesetup.php"); $tpl->assign("title", stripslashes($storyinfo['title'])); $tpl->assign("author", author_link($storyinfo)); if(empty($chapter)) $chapter = "all"; // shouldn't happen but just in case $stories = $storyinfo; include("includes/storyblock.php"); unset($stories); if($chapter == "all") { if($storyinfo['storynotes']) { $tpl->newBlock("storynotes"); $tpl->assign( "storynotes", format_story($storyinfo['storynotes'])); $tpl->gotoBlock("_ROOT"); } $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"); while($c = dbassoc($chapterinfo)) { $tpl->newBlock("storyindexblock"); $tpl->assign("chapternumber", $c['inorder']); $tpl->assign("title", "".$c['title'].""); $tpl->assign("author", $c['penname']); $tpl->gotoBlock("_ROOT"); $tpl->newBlock("chapterblock"); $tpl->assign("chaptertitle", "".$c['title']); $tpl->assign("chapterauthor", $c['penname']); if(!empty($c['notes'])) { $tpl->newBlock("notes"); $tpl->assign( "notes", format_story($c['notes'])); $tpl->gotoBlock("chapterblock"); } if($store == "files") { //shouldn't happen, but somehow has on occasion. :( if(!$c['uid']) { errorExit( ); } $file = STORIESPATH."/".$c['uid']."/".$c['chapid'].".txt"; $log_file = @fopen($file, "r"); $file_contents = @fread($log_file, filesize($file)); $story = $file_contents; @fclose($log_file); } else $story = $c['storytext']; // 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. $story = format_story($story); $tpl->assign("chaptertext", $story); $tpl->assign("back2top", ""._BACK2INDEX.""); if(!empty($c['endnotes'])) { $tpl->newBlock("endnotes"); $tpl->assign( "endnotes", format_story($c['endnotes'])); $tpl->gotoBlock("chapterblock"); } } } else { $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"); $c = dbassoc($chapterinfo); // if the *CHAPTER* hasn't been validated and the viewer isn't an admin or the author throw them a warning. if(empty($c['validated']) && !isADMIN && USERUID != $c['uid'] && !in_array(USERUID, $stories['coauthors'])) { $warning = write_error(_ACCESSDENIED); $tpl->assign("archivedat", $warning); $tpl->printToScreen( ); dbclose( ); exit( ); } if($c['inorder'] == 1 && !empty($storyinfo['storynotes'])) { $tpl->newBlock("storynotes"); $tpl->assign( "storynotes", format_story($storyinfo['storynotes'])); $tpl->gotoBlock("_ROOT"); } $tpl->newBlock("chapterblock"); $tpl->assign("chaptertitle", $c['title']); $tpl->assign("chapternumber", $c['inorder']); $tpl->assign("chapterauthor", $c['penname']); if(!empty($c['notes'])) { $tpl->newBlock("notes"); $tpl->assign( "notes", format_story($c['notes'])); $tpl->gotoBlock("chapterblock"); } //shouldn't happen, but somehow has on occasion. :( if($store == "files") { if(!$c['uid']) { errorExit( ); } $file = STORIESPATH."/".$c['uid']."/".$c['chapid'].".txt"; $log_file = @fopen($file, "r"); $file_contents = @fread($log_file, filesize($file)); $story = $file_contents; @fclose($log_file); } else $story = $c['storytext']; // 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. $story = format_story($story); $tpl->assign("chaptertext", $story); if(!empty($c['endnotes'])) { $tpl->newBlock("endnotes"); $tpl->assign( "endnotes", format_story($c['endnotes'])); $tpl->gotoBlock("chapterblock"); } } $tpl->gotoBlock("_ROOT"); // Hook for adding content to the printed version of the story. $codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'printstory'"); while($code = dbassoc($codeblocks)) { eval($code['code_text']); } $tpl->assign("archivedat", _ARCHIVEDAT." $url/viewstory.php?sid=$sid"); $copyquery = dbquery("SELECT message_text FROM ".TABLEPREFIX."fanfiction_messages WHERE message_name = 'printercopyright' LIMIT 1"); list($copyright) = dbrow($copyquery); $tpl->assign("copyright", $copyright); } else if(($displayindex && empty($chapter)) || !empty($_GET['index'])) { if(file_exists("$skindir/storyindex.tpl")) $tpl = new TemplatePower( "$skindir/storyindex.tpl" ); else $tpl = new TemplatePower("default_tpls/storyindex.tpl"); include("includes/pagesetup.php"); $stories = $storyinfo; // Hook for adding content to only the index of the story. $codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'storyindex'"); while($code = dbassoc($codeblocks)) { eval($code['code_text']); } include("includes/storyblock.php"); $printicon = ""._PRINTER.""; if($reviewsallowed && (isMEMBER || $anonreviews)) $reviewslink = ""._SUBMITREVIEW.""; $tpl->assign( "reviewslink", $reviewslink ); if($storyinfo['rr']) { $tpl->assign("roundrobin", "["._CONTRIBUTE2RR."]"); } $tpl->assign( "printicon", $printicon ); $tpl->assign( "reviewform", $form); $tpl->assign( "output", $output ); if( $storyinfo['storynotes']) { $tpl->newBlock("storynotes"); $tpl->assign( "storynotes", format_story($storyinfo['storynotes'])); $tpl->gotoBlock("_ROOT"); } $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"); $count = 0; while($chap = dbassoc($chapterinfo)) { $tpl->newBlock("storyindexblock"); $tpl->assign("chapternumber", $chap['inorder']); $tpl->assign("title", "".$chap['title'].""); $tpl->assign("author", "".$chap['penname'].""); $tpl->assign("printicon", ""._PRINTER.""); $tpl->assign("ratingpics", ratingpics($chap['rating'])); if($reviewsallowed) { $tpl->assign("reviews", ""._REVIEWS.""); $tpl->assign("numreviews", "".$chap['reviews'].""); } if(isADMIN) $tpl->assign("adminoptions", "
"._ADMINOPTIONS.": "._EDIT." | "._DELETE."
"); $tpl->assign("wordcount", $chap['wordcount']); $tpl->assign("chapternotes", format_story($chap['notes'])); $tpl->assign("count", ($chap['count'] ? $chap['count'] : 0) ); $tpl->assign("oddeven", ($count % 2 ? "odd" : "even")); $tpl->gotoBlock("_ROOT"); $count++; } } else { if(file_exists("$skindir/viewstory.tpl")) $tpl = new TemplatePower( "$skindir/viewstory.tpl" ); else $tpl = new TemplatePower("default_tpls/viewstory.tpl"); include("includes/pagesetup.php"); $jumpmenu = ""; $jumpmenu2 = ""; if(empty($chapter) || !$chapter) $chapter = 1; // get information about the story's chapter(s) $chapterinfo = dbquery("SELECT chap.*, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX."fanfiction_chapters as chap, "._AUTHORTABLE.") WHERE sid = '$sid' AND chap.uid = "._UIDFIELD." ORDER BY inorder"); $chapters = dbnumrows($chapterinfo); if($chapters > 1) { $printicon = ""._PRINTER." "._CHAPTER." "._OR." "._STORY.""; $jumpmenu .= "
"; if($chapter > 1) $prev = ""._PREVIOUS." "; $jumpmenu .= ""; if($chapter < $chapters) { $nextchapter = $chapter + 1; $next = ""._NEXT.""; } else { $nextchapter = ""; // Hook for adding content to only the end of the story. $codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'storyend'"); while($code = dbassoc($codeblocks)) { eval($code['code_text']); } } $jumpmenu .= "
"; } // if the story has only one chapter this is what happens else { $chapter = dbassoc($chapterinfo); $chapterauthor = $chapter['uid']; $chapterpenname = $chapter['penname']; $chaptertitle = $chapter['title']; $chapid = $chapter['chapid']; $title = stripslashes($chapter['title']); $inorder = $chapter['inorder']; $notes = format_story($chapter['notes']); $endnotes = format_story($chapter['endnotes']); $story = $chapter['storytext']; $valid = $chapter['validated']; $nextchapter = ""; $codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'storyend'"); while($code = dbassoc($codeblocks)) { eval($code['code_text']); } $printicon = ""._PRINTER.""; } // if the *CHAPTER* hasn't been validated and the viewer isn't an admin or the author throw them a warning. if(!$valid && !isADMIN && USERUID != $chapterauthor && !in_array($chapterauthor, $storyinfo['coauthors'])) { $warning = accessDenied( ); } $stories = $storyinfo; $tpl->gotoBlock("_ROOT"); $jumpmenu2 = ""; include("includes/storyblock.php"); unset($adminlinks); if(isADMIN && uLEVEL < 3) $adminlinks = "
"._ADMINOPTIONS.": "._EDIT." - "._STORY." "._OR." "._CHAPTER." | "._DELETE." - "._STORY." "._OR." "._CHAPTER."
"; if(isMEMBER && $favorites) { $jumpmenu2 .= ""; } if($reviewsallowed ) { if(isMEMBER || $anonreviews) { $reviewslink = ""._SUBMITREVIEW.""; $jumpmenu2 .= ""; } else $reviewslink = write_message(sprintf(_LOGINTOREVIEW, strtolower($pagelinks['login']['link']), strtolower($pagelinks['register']['link']))); } $tpl->assign("reportthis", "["._REPORTTHIS."]"); $jumpmenu2 .= ""; if($stories['rr']) { $rr = "["._CONTRIBUTE2RR."]"; $jumpmenu2 .= ""; } if(isset($jumpmenu2)) $jumpmenu2 = "
"; if($reviewsallowed) { if(isMEMBER || $anonreviews) { $item = $sid; $type = "ST"; include("includes/reviewform.php"); } else $form = write_message(sprintf(_LOGINTOREVIEW, strtolower($pagelinks['login']['link']), strtolower($pagelinks['register']['link']))); } $textsizer = "- ". _TEXTSIZE. " + "; // okay now that we know they can see the story and the chapter add 1 to the story and chapter counts; if(empty($viewed) || (is_array($viewed) && !in_array($sid, $viewed))) { dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET count = count + 1 WHERE sid = '$sid' LIMIT 1"); $viewed[] = $sid; $_SESSION['viewed'] = $viewed; } dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET count = count + 1 WHERE chapid = '$chapid' LIMIT 1"); // end counters // if the text of the chapters is being stored in files we need to get that text here if($store == "files") { //shouldn't happen, but somehow has on occasion. :( if(!$chapterauthor) { errorExit(_ERROR); } $file = STORIESPATH."/$chapterauthor/$chapid.txt"; $log_file = @fopen($file, "r"); $file_contents = @fread($log_file, filesize($file)); $story = $file_contents; @fclose($log_file); } $story = format_story($story); if(isset($adminlinks)) $tpl->assign( "adminlinks", $adminlinks ); $tpl->assign( "printicon", $printicon ); $tpl->assign( "output", $output ); if($inorder == 1 && !empty($storyinfo['storynotes'])) { $tpl->gotoBlock("_ROOT"); $tpl->newBlock("storynotes"); $tpl->assign( "storynotes", stripslashes($storyinfo['storynotes'])); $tpl->gotoBlock("_ROOT"); } if(!empty($notes)) { $tpl->newBlock("notes"); $tpl->assign( "notes", $notes); $tpl->gotoBlock("_ROOT"); } if(!empty($endnotes)) { $tpl->newBlock("endnotes"); $tpl->assign( "endnotes", $endnotes); $tpl->gotoBlock("_ROOT"); } $tpl->gotoBlock("_ROOT"); $tpl->assign("chaptertitle", $chaptertitle); $tpl->assign("chapternumber", $inorder); $tpl->assign( "story", "$story" ); $tpl->assign("textsizer", $textsizer); if(isset($jumpmenu)) $tpl->assign( "jumpmenu", $jumpmenu); if(isset($jumpmenu2)) $tpl->assign( "jumpmenu2", $jumpmenu2); $tpl->assign( "roundrobin", $rr ); $tpl->assign( "reviewform", $form); if(isset($addtofaves)) $tpl->assign( "addtofaves", $addtofaves ); if(isset($next)) $tpl->assign( "next", $next ); if(isset($prev)) $tpl->assign( "prev", $prev ); } // Hook for adding content to view story pages. $codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'viewstory'"); while($code = dbassoc($codeblocks)) { eval($code['code_text']); } $tpl->printToScreen(); dbclose( ); ?>