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,128 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// eFiction 3.2
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
+	$output .= "<div class='sectionheader'>"._FAVORITEAUTHORS."</div>";
33
+	
34
+	$add = !empty($_GET['add']) ? $_GET['add'] : "";
35
+	$delete = isset($_GET['delete']) && isNumber($_GET['delete']) ? $_GET['delete'] : false;
36
+	$edit = isset($_GET['edit']) && isNumber($_GET['edit']) ? $_GET['edit'] : false;
37
+	$author = explode(",", $add);
38
+	$author = array_filter($author, "isNumber");
39
+	if(($add || $edit || $delete) && !isMEMBER) accessDenied( );
40
+
41
+	if(isMEMBER && $uid == USERUID) {
42
+		if($delete) {
43
+			$result = dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '".USERUID."' AND item = '$delete' AND type = 'AU' LIMIT 1");
44
+			if($result) $output .= write_message(_ACTIONSUCCESSFUL." "._BACK2ACCT);
45
+			else $output .= write_error(_ERROR);
46
+		}
47
+		if($add && isset($_POST['submit'])) {
48
+			$comment = escapestring(descript(strip_tags(replace_naughty($_POST['comments']), $allowed_tags)));
49
+			foreach($author AS $a) {
50
+				$result = dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_favorites(uid, item, type, comments) VALUES('".USERUID."', '$a', 'AU', '$comment') ON DUPLICATE KEY UPDATE comments = '$comment'");
51
+			}
52
+			if($result) $output .= write_message(_ACTIONSUCCESSFUL." "._BACK2ACCT);
53
+			else $output .= write_error(_ERROR);
54
+		}
55
+		if($edit && isset($_POST['submit'])) {
56
+			$result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_favorites SET comments = '".escapestring(descript(strip_tags(replace_naughty($_POST['comments']), $allowed_tags)))."' WHERE uid = '".USERUID."' AND item = '$edit' AND type = 'AU'");
57
+			if($result) $output .= write_message(_ACTIONSUCCESSFUL." "._BACK2ACCT);
58
+			else $output .= write_error(_ERROR);
59
+		}
60
+		if(($add || $edit) && !isset($_POST['submit'])) {
61
+			if($add) {
62
+				$check = dbquery("SELECT item FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '".USERUID."' AND ".findclause("item", $author)." AND type = 'AU'");
63
+				if(dbnumrows($check)) {
64
+					while($c = dbassoc($check)) {
65
+						$edit[] = $c['item'];
66
+					}
67
+					$edit = array_diff($author, $edit);
68
+				}
69
+				else {
70
+					$pQuery = dbquery("SELECT "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE." WHERE ".findclause(_UIDFIELD, $author));
71
+					while($pRes = dbassoc($pQuery)) {
72
+						$pennames[] = $pRes['penname'];
73
+					}
74
+					$pennames = implode(", ", $pennames);
75
+				}
76
+				$output = "<div class='sectionheader'>"._ADDTOFAVORITES.": ".$pennames."</div>";
77
+			}
78
+			if($edit) {
79
+				$pQuery = dbquery("SELECT fav.*, "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE." LEFT JOIN ".TABLEPREFIX."fanfiction_favorites as fav ON fav.item = "._UIDFIELD." AND fav.type = 'AU' AND fav.uid = '".USERUID."' WHERE "._UIDFIELD." = '$edit' LIMIT 1");
80
+				if(dbnumrows($pQuery)) {
81
+					$info = dbassoc($pQuery);
82
+					$pennames = $info['penname'];
83
+					$output .= "<div class='sectionheader'>"._EDITFAVORITES.": ".$pennames."</div>";
84
+				}
85
+				else {
86
+					$author = array($edit);
87
+					$pQuery = dbquery("SELECT "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE." WHERE ".findclause(_UIDFIELD, $author));
88
+					while($pRes = dbassoc($pQuery)) {
89
+						$pennames[] = $pRes['penname'];
90
+					}
91
+					$pennames = implode(", ", $pennames);
92
+					$output .= "<div class='sectionheader'>"._ADDTOFAVORITES.": ".$pennames."</div>";
93
+				}
94
+			}
95
+			$author = implode(",", $author);
96
+			$output .= "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"user.php?action=favau&amp;".( $add ? "add=$author" : "edit=$edit")."\">\n
97
+				<div style=\"width: 350px; margin: 0 auto; text-align: left;\"><label for=\"comments\">"._COMMENTS.":</label><br />
98
+				<textarea class=\"textbox\" name=\"comments\" id=\"comments\" cols=\"40\" rows=\"5\">".(isset($info['comments']) ? $info['comments'] : "")."</textarea><br />
99
+				<INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\"></div></form>";
100
+		}
101
+	}
102
+	if(!$add && !$edit) {
103
+		$query = "SELECT "._UIDFIELD." as uid, "._PENNAMEFIELD." as penname, fav.comments as comments FROM ".TABLEPREFIX."fanfiction_favorites as fav, "._AUTHORTABLE." WHERE fav.uid = '$uid' AND fav.type = 'AU' AND fav.item = "._UIDFIELD." ORDER BY "._PENNAMEFIELD;
104
+		$countquery = dbquery("SELECT COUNT(item) FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '$uid' AND type = 'AU' GROUP BY uid");
105
+		list($count) = dbrow($countquery);
106
+		$x = 1;
107
+		if($count) {
108
+				$list = dbquery($query."  LIMIT $offset, $itemsperpage");
109
+				while($author = dbassoc($list)) { 
110
+					$output .= "<span class='label'>$x.</span> <a href=\"viewuser.php?uid=".$author['uid']."\">".$author['penname']."</a><br />";
111
+					if(file_exists("./$skindir/favcomment.tpl")) $cmt = new TemplatePower( "./$skindir/favcomment.tpl" );
112
+					else $cmt = new TemplatePower( "./default_tpls/favcomment.tpl" );
113
+					$cmt->prepare( );
114
+					$cmt->newBlock("comment");
115
+					$cmt->assign("comment", format_story($author['comments']));
116
+					if(USERUID == $uid) 
117
+					$cmt->assign("commentoptions", "<div class='adminoptions'><span class='label'>"._OPTIONS.":</span> <a href=\"user.php?action=favau&amp;edit=".$author['uid']."\">"._EDIT."</a> | <a href=\"user.php?action=favau&amp;delete=".$author['uid']."\">"._REMOVEFAV."</a></div>");
118
+					$cmt->assign("oddeven", ($x % 2 ? "odd" : "even"));
119
+					$output .= $cmt->getOutputContent( );
120
+					$x++;
121
+				}
122
+			if($count > $itemsperpage) $output .= build_pagelinks("viewuser.php?action=favau&amp;uid=$uid&amp;", $count, $offset);
123
+		}
124
+		else $output .= write_message(_NORESULTS);
125
+	}
126
+	$tpl->assign("output", $output);
127
+	$tpl->gotoBlock( "_ROOT" );
128
+?>