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