| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,151 @@ |
| 1 |
+<?php |
|
| 2 |
+// ---------------------------------------------------------------------- |
|
| 3 |
+// eFiction 3.0 |
|
| 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 |
+function preview_story($stories) {
|
|
| 28 |
+ global $extendcats, $skindir, $catlist, $charlist, $store, $storiespath, $classlist, $featured, $retired, $rr, $reviewsallowed, $star, $halfstar, $ratingslist, $classtypelist, $dateformat, $recentdays, $current; |
|
| 29 |
+ $count = 0; |
|
| 30 |
+ |
|
| 31 |
+ if(isset($_GET['textsize'])) $textsize = $_GET['textsize']; |
|
| 32 |
+ else $textsize = 0; |
|
| 33 |
+ |
|
| 34 |
+ if(file_exists("./$skindir/viewstory.tpl")) $tpl = new TemplatePower("./$skindir/viewstory.tpl");
|
|
| 35 |
+ else $tpl = new TemplatePower(_BASEDIR."default_tpls/viewstory.tpl"); |
|
| 36 |
+ $tpl->prepare( ); |
|
| 37 |
+ include("includes/storyblock.php");
|
|
| 38 |
+ $adminlinks = "<div class=\"adminoptions\"><span class='label'>"._ADMINOPTIONS.":</span> <a href=\"admin.php?action=validate&sid=$stories[sid]&chapid=$stories[chapid]&validate=yes\">"._VALIDATE."</a> | "._EDIT." - <a href=\"stories.php?action=editstory&sid=$stories[sid]&admin=1\">"._STORY."</a> "._OR." <a href=\"stories.php?action=editchapter&chapid=$stories[chapid]&admin=1\">"._CHAPTER."</a> | "._DELETE." - <a href=\"stories.php?action=delete&sid=$stories[sid]\">"._STORY."</a> "._OR." <a href=\"stories.php?action=delete&chapid=$stories[chapid]&sid=$stories[sid]&admin=1&uid=$stories[uid]\">"._CHAPTER."</a> | <a href=\"javascript:pop('admin.php?action=yesletter&uid=$stories[uid]&chapid=$stories[chapid]', 400, 350, 'yes')\">"._YESLETTER."</a> | <a href=\"javascript:pop('admin.php?action=noletter&uid=$stories[uid]&chapid=$stories[chapid]',400, 350, 'yes')\">"._NOLETTER."</a></div>";
|
|
| 39 |
+ $tpl->assign("adminlinks", $adminlinks);
|
|
| 40 |
+ if($stories['inorder'] == 1 && !empty($stories['storynotes'])) {
|
|
| 41 |
+ $tpl->gotoBlock("_ROOT");
|
|
| 42 |
+ $tpl->newBlock("storynotes");
|
|
| 43 |
+ $tpl->assign( "storynotes", stripslashes($stories['storynotes'])); |
|
| 44 |
+ $tpl->gotoBlock("_ROOT");
|
|
| 45 |
+ } |
|
| 46 |
+ if(!empty($stories['notes'])) {
|
|
| 47 |
+ $tpl->newBlock("notes");
|
|
| 48 |
+ $tpl->assign( "notes", $stories['notes']); |
|
| 49 |
+ $tpl->gotoBlock("_ROOT");
|
|
| 50 |
+ } |
|
| 51 |
+ if(!empty($stories['endnotes'])) {
|
|
| 52 |
+ $tpl->newBlock("endnotes");
|
|
| 53 |
+ $tpl->assign( "endnotes", $stories['endnotes']); |
|
| 54 |
+ $tpl->gotoBlock("_ROOT");
|
|
| 55 |
+ } |
|
| 56 |
+ if($store == "files") |
|
| 57 |
+ {
|
|
| 58 |
+ $file = STORIESPATH."/$stories[uid]/$stories[chapid].txt"; |
|
| 59 |
+ $log_file = fopen($file, "r"); |
|
| 60 |
+ $file_contents = fread($log_file, filesize($file)); |
|
| 61 |
+ $storytext = $file_contents; |
|
| 62 |
+ fclose($log_file); |
|
| 63 |
+ } |
|
| 64 |
+ else if($store == "mysql") |
|
| 65 |
+ {
|
|
| 66 |
+ $storytext = $stories['storytext']; |
|
| 67 |
+ } |
|
| 68 |
+ $storytext = format_story($storytext); |
|
| 69 |
+ $tpl->gotoBlock("_ROOT");
|
|
| 70 |
+ $tpl->assign("chaptertitle", $stories['chaptertitle']);
|
|
| 71 |
+ $tpl->assign("chapternumber", $stories['inorder']);
|
|
| 72 |
+ $tpl->assign( "story", "<span style=\"font-size: ".(100 + ($textsize * 20))."%;\">$storytext</span>" ); |
|
| 73 |
+ return $tpl->getOutputContent( ); |
|
| 74 |
+} |
|
| 75 |
+ |
|
| 76 |
+ $output .= "<div id='pagetitle'>"._VIEWSUBMITTED."</div>"; |
|
| 77 |
+ if(isset($_GET['validate']) && $_GET['validate'] == "yes") {
|
|
| 78 |
+ $storyquery = dbquery("SELECT story.validated, story.catid, story.sid, story.title, story.summary, story.uid, "._PENNAMEFIELD." as penname, chapter.inorder, story.coauthors FROM ".TABLEPREFIX."fanfiction_stories as story, ".TABLEPREFIX."fanfiction_chapters as chapter, "._AUTHORTABLE." WHERE "._UIDFIELD." = story.uid AND chapter.sid = story.sid AND chapter.chapid ='$_GET[chapid]' LIMIT 1");
|
|
| 79 |
+ list($storyvalid, $catid, $sid, $title, $summary, $authoruid, $author, $inorder, $coauthors) = dbrow($storyquery); |
|
| 80 |
+ if(uLEVEL == 1 || (empty($admincats) || sizeof(array_intersect(explode(",", $catid), explode(",", $admincats))))) {
|
|
| 81 |
+ include("includes/emailer.php");
|
|
| 82 |
+ if(!$storyvalid) {
|
|
| 83 |
+ dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET validated = '1', updated = NOW() WHERE sid = '$_GET[sid]'");
|
|
| 84 |
+ foreach(explode(",", $catid) as $cat) {
|
|
| 85 |
+ categoryitems($cat, 1); |
|
| 86 |
+ } |
|
| 87 |
+ $au[] = $authoruid; |
|
| 88 |
+ if($coauthors == 1) {
|
|
| 89 |
+ $au = array(); |
|
| 90 |
+ $coauth = dbquery("SELECT "._PENNAMEFIELD." as penname, co.uid FROM ".TABLEPREFIX."fanfiction_coauthors AS co LEFT JOIN "._AUTHORTABLE." ON co.uid = "._UIDFIELD." WHERE co.sid = '".$_GET['sid']."'");
|
|
| 91 |
+ while($c = dbassoc($coauth)) {
|
|
| 92 |
+ $au[] = $c['uid']; |
|
| 93 |
+ } |
|
| 94 |
+ dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorprefs SET stories = stories + 1 WHERE FIND_IN_SET(uid, '".implode(",", $au)."') > 0");
|
|
| 95 |
+ } |
|
| 96 |
+ dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorprefs SET stories = stories + 1 WHERE uid = '$authoruid'");
|
|
| 97 |
+ $codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'addstory'");
|
|
| 98 |
+ while($code = dbassoc($codequery)) {
|
|
| 99 |
+ eval($code['code_text']); |
|
| 100 |
+ } |
|
| 101 |
+ if($alertson) {
|
|
| 102 |
+ if($au) $cond = " FIND_IN_SET(fav.item, '".implode(",", $au).",$authoruid') > 0";
|
|
| 103 |
+ else $cond = "fav.item = $authoruid"; |
|
| 104 |
+ $subject = _NEWSTORYAT." $sitename"; |
|
| 105 |
+ $mailtext = sprintf(_AUTHORALERTNOTE, $title, $author, $summary, $sid); |
|
| 106 |
+ $favorites = dbquery("SELECT "._UIDFIELD." as uid, "._EMAILFIELD." as email, "._PENNAMEFIELD." as penname, alertson FROM ".TABLEPREFIX."fanfiction_favorites as fav, ".TABLEPREFIX."fanfiction_authorprefs as ap, "._AUTHORTABLE." WHERE $cond AND fav.type = 'AU' AND fav.uid = "._UIDFIELD." AND ap.uid = "._UIDFIELD." AND ap.alertson = '1'");
|
|
| 107 |
+ while($favuser = dbassoc($favorites)) {
|
|
| 108 |
+ sendemail($favuser['penname'], $favuser['email'], $sitename, $siteemail, $subject, $mailtext, "html"); |
|
| 109 |
+ } |
|
| 110 |
+ } |
|
| 111 |
+ if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_VALIDATE_STORY, USERPENNAME, USERUID, $title, $sid, $author, $authoruid))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'VS')");
|
|
| 112 |
+ dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET stories = stories + 1");
|
|
| 113 |
+ } |
|
| 114 |
+ else if($alertson) {
|
|
| 115 |
+ $subject = _STORYALERT; |
|
| 116 |
+ $mailtext = sprintf(_STORYALERTNOTE, $title, $author, $sid, $inorder); |
|
| 117 |
+ $codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'addchapter'");
|
|
| 118 |
+ while($code = dbassoc($codequery)) {
|
|
| 119 |
+ eval($code['code_text']); |
|
| 120 |
+ } |
|
| 121 |
+ $favorites = dbquery("SELECT "._UIDFIELD." as uid, "._EMAILFIELD." as email, "._PENNAMEFIELD." as penname, alertson FROM ".TABLEPREFIX."fanfiction_favorites as fav, ".TABLEPREFIX."fanfiction_authorprefs as ap, "._AUTHORTABLE." WHERE fav.item = '$sid' AND fav.type = 'ST' AND fav.uid = "._UIDFIELD." AND ap.uid = "._UIDFIELD." AND ap.alertson = '1'");
|
|
| 122 |
+ while($favuser = dbassoc($favorites)) {
|
|
| 123 |
+ sendemail($favuser['penname'], $favuser['email'], $sitename, $siteemail, $subject, $mailtext, "html"); |
|
| 124 |
+ } |
|
| 125 |
+ if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_VALIDATE_CHAPTER, USERPENNAME, USERUID, $title, $sid, $author, $authoruid, $inorder))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'VS')");
|
|
| 126 |
+ } |
|
| 127 |
+ dbquery("UPDATE ".TABLEPREFIX."fanfiction_chapters SET validated = '1' WHERE chapid = '$_GET[chapid]'");
|
|
| 128 |
+ dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET updated = NOW( ) WHERE sid = '$sid'");
|
|
| 129 |
+ $count = dbquery("SELECT SUM(wordcount) as totalcount FROM ".TABLEPREFIX."fanfiction_chapters WHERE sid = '$sid' and validated = 1");
|
|
| 130 |
+ list($totalcount) = dbrow($count); |
|
| 131 |
+ if($totalcount) {
|
|
| 132 |
+ dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET wordcount = '$totalcount' WHERE sid = '$sid'");
|
|
| 133 |
+ } |
|
| 134 |
+ list($chapters, $words) = dbrow(dbquery("SELECT COUNT(chapid), SUM(wordcount) FROM ".TABLEPREFIX."fanfiction_chapters WHERE validated = 1"));
|
|
| 135 |
+// list($authors) = dbrow(dbquery("SELECT COUNT(DISTINCT uid) FROM ".TABLEPREFIX."fanfiction_chapters WHERE validated > 0"));
|
|
| 136 |
+ list($authors) = dbrow(dbquery("SELECT COUNT(uid) FROM ".TABLEPREFIX."fanfiction_authorprefs WHERE stories > 0"));
|
|
| 137 |
+ dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats set wordcount = '$words', chapters = '$chapters', authors = '$authors'");
|
|
| 138 |
+ $output .= write_message(_STORYVALIDATED); |
|
| 139 |
+ } |
|
| 140 |
+ else |
|
| 141 |
+ $output .= write_error(_NOTAUTHORIZEDADMIN." "._TRYAGAIN); |
|
| 142 |
+ } |
|
| 143 |
+ else {
|
|
| 144 |
+ if(isNumber($_GET['chapid'])) {
|
|
| 145 |
+ $result = dbquery("SELECT stories.*, stories.title as title, "._PENNAMEFIELD." as penname, UNIX_TIMESTAMP(stories.updated) as updated, UNIX_TIMESTAMP(stories.date) as date, chapter.uid as uid, chapter.inorder, chapter.title as chaptertitle, chapter.storytext, chapter.chapid, chapter.notes, chapter.endnotes FROM "._AUTHORTABLE.", ".TABLEPREFIX."fanfiction_stories as stories, ".TABLEPREFIX."fanfiction_chapters as chapter WHERE chapter.chapid = '$_GET[chapid]' AND chapter.sid = stories.sid AND chapter.uid = "._UIDFIELD);
|
|
| 146 |
+ $stories = dbassoc($result); |
|
| 147 |
+ $output .= preview_story($stories); |
|
| 148 |
+ |
|
| 149 |
+ } |
|
| 150 |
+ } |
|
| 151 |
+?> |
|
| 0 | 152 |
\ No newline at end of file |