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,115 @@
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
+if(empty($favorites)) accessDenied( );
27
+
28
+	if(empty($uid)) {
29
+		$uid = USERUID;
30
+		$output .= "<div id='pagetitle'>"._YOURSTATS."</div>";
31
+	}
32
+	$add = isset($_GET['add']) ? $_GET['add'] : false;
33
+	$edit = isset($_GET['edit']) ? $_GET['edit'] : false;
34
+	$delete = isset($_GET['delete']) ? $_GET['delete'] : false;
35
+	if($add) $output .= "<div class='sectionheader'>"._ADDTOFAVORITES."</div>";
36
+	else if($edit) $output .= "<div class='sectionheader'>"._EDITFAVORITES."</div>";
37
+	else $output .= "<div class='sectionheader'>"._FAVORITESTORIES."</div>";
38
+	if(($add || $edit || $delete) && !isMEMBER) accessDenied( );
39
+
40
+	if($delete && isNumber($delete)) {
41
+		$result = dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '".USERUID."' AND item = '$delete' AND type = 'ST' LIMIT 1");
42
+		if($result) $output .= write_message(_ACTIONSUCCESSFUL." "._BACK2ACCT);
43
+		else $output .= write_error(_ERROR);
44
+	}
45
+	if($add && isset($_POST['submit'])) {
46
+		$check = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '".USERUID."' AND item = '$sid' AND type = 'ST' LIMIT 1");
47
+		if(!dbnumrows($check))
48
+			$result = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_favorites(uid, item, type, comments) VALUES ('".USERUID."', '$sid', 'ST', '".escapestring(descript(strip_tags(replace_naughty($_POST['comments']), $allowed_tags)))."')");
49
+		if($result) $output .= write_message(_ACTIONSUCCESSFUL." "._BACK2ACCT);
50
+	}
51
+	if($edit && isset($_POST['submit'])) {
52
+		$result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_favorites SET comments = '".escapestring(descript(strip_tags(replace_naughty($_POST['comments']), $allowed_tags)))."' WHERE uid = '$uid' AND item = '$edit' AND type = 'ST'");
53
+		if($result) $output .= write_message(_ACTIONSUCCESSFUL." "._BACK2ACCT);
54
+		else $output .= write_error(_ERROR);
55
+	}
56
+	if(($add || $edit) && !isset($_POST['submit'])) {
57
+		if($add) {
58
+			$check = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '".USERUID."' AND item = '$sid' AND type = 'ST' LIMIT 1");
59
+			if(dbnumrows($check)) {
60
+				$edit = $sid;
61
+				$add = false;
62
+			}
63
+		}
64
+		if($edit) {
65
+			$query = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '".USERUID."' AND type = 'ST' AND item = '$edit' LIMIT 1");
66
+			$info = dbassoc($query);
67
+		}
68
+		$storyinfo = dbquery(_STORYQUERY." AND sid = '".($edit? $edit : $sid)."'");
69
+		$stories = dbassoc($storyinfo);
70
+		if(!$stories) $output .= write_error(_ERROR);
71
+		else {
72
+			$tpl->newBlock("listings");
73
+			$tpl->newBlock("storyblock");
74
+			include("includes/storyblock.php");
75
+			$tpl->gotoBlock("listings");
76
+			$tpl->assign("pagelinks", "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"user.php?action=favst&amp;".($edit? "edit=$edit" : "add=1")."&amp;sid=".(isset($sid) ? $sid : $edit)."\">\n
77
+				<div style=\"width: 350px; margin: 0 auto; text-align: left;\"><label for=\"comments\">"._COMMENTS.":</label><br />
78
+				<textarea class=\"textbox\" name=\"comments\" id=\"comments\" cols=\"40\" rows=\"5\">".(isset($info['comments']) ? $info['comments'] : "")."</textarea><br />
79
+				<INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\"></div></form>");
80
+			$tpl->gotoBlock("_ROOT");
81
+		}
82
+	}
83
+	else if(!isset($_POST['submit'])) {
84
+		$storyquery = "SELECT stories.*, "._PENNAMEFIELD." as penname, fav.comments as comments,  UNIX_TIMESTAMP(stories.date) as date, UNIX_TIMESTAMP(stories.updated) as updated FROM ".TABLEPREFIX."fanfiction_stories as stories, ".TABLEPREFIX."fanfiction_favorites as fav, "._AUTHORTABLE." WHERE fav.uid = '$uid' AND fav.type = 'ST' AND stories.uid = "._UIDFIELD." AND fav.item = stories.sid "._ORDERBY;
85
+		$countquery = dbquery("SELECT COUNT(item) FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '$uid' AND type = 'ST' GROUP BY uid");
86
+		list($storycount) = dbrow($countquery);
87
+		if($storycount) {
88
+			$list = dbquery($storyquery."  LIMIT $offset, $itemsperpage");
89
+			$tpl->newBlock("listings");
90
+			$count = 0;
91
+			while($stories = dbassoc($list)) { 
92
+				$tpl->newBlock("storyblock");
93
+				include("includes/storyblock.php");
94
+				if(!empty($stories['comments']) || USERUID == $uid || isADMIN) {
95
+				if(file_exists("./$skindir/favcomment.tpl")) $cmt = new TemplatePower( "./$skindir/favcomment.tpl" );
96
+				else $cmt = new TemplatePower( "./default_tpls/favcomment.tpl" );
97
+				$cmt->prepare( );
98
+				$cmt->newBlock("comment");
99
+				$cmt->assign("comment", $stories['comments'] ? "<div class='comments'><span class='label'>"._COMMENTS.": </span>".strip_tags($stories['comments'])."</div>" : "");
100
+				if(USERUID == $uid) 
101
+				$cmt->assign("commentoptions", "<div class='adminoptions'><span class='label'>"._OPTIONS.":</span> <a href=\"user.php?action=favst&amp;edit=".$stories['sid']."\">"._EDIT."</a> | <a href=\"user.php?action=favst&amp;delete=".$stories['sid']."\">"._REMOVEFAV."</a></div>");
102
+				$cmt->assign("oddeven", ($count % 2 ? "odd" : "even"));
103
+				$tpl->assign("comment", $cmt->getOutputContent( ));
104
+				$tpl->gotoBlock( "listings" );
105
+				}
106
+			}	
107
+			if($storycount > $itemsperpage) {
108
+				$tpl->gotoBlock("listings");
109
+				$tpl->assign("pagelinks", build_pagelinks(basename($_SERVER['PHP_SELF'])."?action=favst&amp;uid=$uid&amp;", $storycount, $offset));
110
+			}
111
+		}
112
+		else $output .= write_message(_NORESULTS);
113
+		$tpl->gotoBlock( "_ROOT" );
114
+	}
115
+?>