| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,104 @@ |
| 1 |
+<?php |
|
| 2 |
+// ---------------------------------------------------------------------- |
|
| 3 |
+// Copyright (c) 2007 by Tammy Keefer |
|
| 4 |
+// Based on eFiction 1.1 |
|
| 5 |
+// Copyright (C) 2003 by Rebecca Smallwood. |
|
| 6 |
+// http://efiction.sourceforge.net/ |
|
| 7 |
+// ---------------------------------------------------------------------- |
|
| 8 |
+// LICENSE |
|
| 9 |
+// |
|
| 10 |
+// This program is free software; you can redistribute it and/or |
|
| 11 |
+// modify it under the terms of the GNU General Public License (GPL) |
|
| 12 |
+// as published by the Free Software Foundation; either version 2 |
|
| 13 |
+// of the License, or (at your option) any later version. |
|
| 14 |
+// |
|
| 15 |
+// This program is distributed in the hope that it will be useful, |
|
| 16 |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 17 |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 18 |
+// GNU General Public License for more details. |
|
| 19 |
+// |
|
| 20 |
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html |
|
| 21 |
+// ---------------------------------------------------------------------- |
|
| 22 |
+ |
|
| 23 |
+function genres( ) {
|
|
| 24 |
+ global $allowed_tags; |
|
| 25 |
+ |
|
| 26 |
+ $output .= "<center><h4>"._GENRES."</h4></center>"; |
|
| 27 |
+ if($_GET["delete"]) {
|
|
| 28 |
+ $gid = $_GET["delete"]; |
|
| 29 |
+ if($_GET["confirm"] == "yes") |
|
| 30 |
+ {
|
|
| 31 |
+ $result5 = dbquery("SELECT genre FROM ".TABLEPREFIX."fanfiction_genres WHERE gid = '$gid'") or die(_FATALERROR."Query: SELECT genre FROM ".TABLEPREFIX."fanfiction_genres WHERE gid = '$gid'<br />Error: (".mysql_errno( ).") ".mysql_error( ));
|
|
| 32 |
+ $genres = dbassoc($result5); |
|
| 33 |
+ $newquery5 = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_stories WHERE gid LIKE '%$genres[genre]%'") or die(_FATALERROR."Query: SELECT * FROM ".TABLEPREFIX."fanfiction_stories WHERE gid LIKE '%$genres[genre]%'<br />Error: (".mysql_errno( ).") ".mysql_error( ));
|
|
| 34 |
+ while($genreresult = dbassoc($newquery5)) |
|
| 35 |
+ {
|
|
| 36 |
+ $tok = strtok($genreresult[gid], ", ");// tokenize the old list of names |
|
| 37 |
+ $newString = "";// the new list of good names |
|
| 38 |
+ while($tok) |
|
| 39 |
+ {
|
|
| 40 |
+ if( $tok != $genres[genre] )// oldname is the thing that is going away |
|
| 41 |
+ {
|
|
| 42 |
+ // It's a keeper, so decide if it is first or not for comma-age, then add it in |
|
| 43 |
+ if( $newString != "" ) |
|
| 44 |
+ $newString .= ", "; |
|
| 45 |
+ $newString .= $tok; |
|
| 46 |
+ } |
|
| 47 |
+ $tok = strtok(", "); //advance to the next token
|
|
| 48 |
+ } |
|
| 49 |
+ dbquery("UPDATE ".TABLEPREFIX."fanfiction_stories SET gid = '$newString' WHERE sid = '$genreresult[sid]'") or die(_FATALERROR."Query: UPDATE ".TABLEPREFIX."fanfiction_stories SET gid = '$newString' WHERE sid = '$genreresult[sid]'<br />Error: (".mysql_errno( ).") ".mysql_error( ));
|
|
| 50 |
+ } |
|
| 51 |
+ dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_genres where gid = '$gid'") or die(_FATALERROR."Query: DELETE FROM ".TABLEPREFIX."fanfiction_genres where gid = '$gid'<br />Error: (".mysql_errno( ).") ".mysql_error( ));
|
|
| 52 |
+ $output .= "<center>"._ACTIONSUCCESSFUL."</center>"; |
|
| 53 |
+ } |
|
| 54 |
+ else if ($_GET["confirm"] == "no") |
|
| 55 |
+ {
|
|
| 56 |
+ $output .= "<center>"._ACTIONCANCELLED."</center>"; |
|
| 57 |
+ } |
|
| 58 |
+ else |
|
| 59 |
+ {
|
|
| 60 |
+ $output .= "<center>"._CONFIRMDELETE."<br /><br />"; |
|
| 61 |
+ $output .= "[ <a href=\"admin.php?action=genres&delete=$gid&confirm=yes\">"._YES."</a> | <a href=\"admin.php?action=genres&delete=$gid&confirm=no\">"._NO."</a> ]</center>"; |
|
| 62 |
+ return $output; |
|
| 63 |
+ } |
|
| 64 |
+ } |
|
| 65 |
+ if ($_POST[submit]) {
|
|
| 66 |
+ if($_GET[genre] == "new") dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_genres (genre) VALUES ('".addslashes(stripinput(strip_tags($_POST[genre])))."')") or die(_FATALERROR."<br />Error: (".mysql_errno( ).") ".mysql_error( ));
|
|
| 67 |
+ else dbquery("UPDATE ".TABLEPREFIX."fanfiction_genres set genre = '".addslashes(stripinput(strip_tags($_POST[genre])))."' WHERE gid = '$_GET[genre]'") or die(_FATALERROR."<br />Error: (".mysql_errno( ).") ".mysql_error( ));
|
|
| 68 |
+ $output .= "<center>"._ACTIONSUCCESSFUL."</center>"; |
|
| 69 |
+ } |
|
| 70 |
+ else {
|
|
| 71 |
+ if(isset($_GET[genre])) {
|
|
| 72 |
+ if($_GET[genre] != "new") {
|
|
| 73 |
+ $genrequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_genres WHERE gid = '$_GET[genre]' LIMIT 1") or die(_FATALERROR."<br />Error: (".mysql_errno( ).") ".mysql_error( ));
|
|
| 74 |
+ $genre = dbassoc($genrequery); |
|
| 75 |
+ } |
|
| 76 |
+ $output .= "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"admin.php?action=genres&genre=$_GET[genre]\"> |
|
| 77 |
+ <table align=\"center\"><tr><td colspan=\"2\" align=\"center\"><b>".($_GET[genre] == "new" ? _NEWGENRE : _EDITGENRE)."</b></td></tr> |
|
| 78 |
+ <tr><td>"._GENRE.": <A HREF=\"javascript:pop('docs/adminhints.htm#genres');\">[?]</A></td>
|
|
| 79 |
+ <td><INPUT type=\"text\" class=\"textbox=\" name=\"genre\"".($_GET[genre] != "new" ? "value=\"$genre[genre]\"" : "")."></td></tr> |
|
| 80 |
+ <tr><td colspan=\"2\" align=\"right\"><INPUT type=\"submit\" class=\"button\" value=\""._SUBMIT."\" name=\"submit\"></td></tr></table></form>"; |
|
| 81 |
+ } |
|
| 82 |
+ else {
|
|
| 83 |
+ |
|
| 84 |
+ $result = dbquery("SELECT * from ".TABLEPREFIX."fanfiction_genres");
|
|
| 85 |
+ |
|
| 86 |
+ //List of current genres |
|
| 87 |
+ |
|
| 88 |
+ $output .= "<table class=\"tblborder\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\"> |
|
| 89 |
+ <tr><th colspan=\"2\" align=\"center\">"._GENRES."</th></tr> |
|
| 90 |
+ <tr><td colspan=\"2\" align=\"center\" class=\"tblborder\"><a href=\"admin.php?action=genres&genre=new\">"._ADDGENRE."</a></td></tr>"; |
|
| 91 |
+ while ($genreresults = dbassoc($result)) |
|
| 92 |
+ {
|
|
| 93 |
+ $output .= "<tr><td class=\"tblborder\">$genreresults[genre]"; |
|
| 94 |
+ $output .= "</td><td class=\"tblborder\"><a href=\"admin.php?action=genres&genre=$genreresults[gid]\">"._EDIT."</a> | <a href=\"admin.php?action=genres&delete=$genreresults[gid]\">"._DELETE."</td></tr>"; |
|
| 95 |
+ } |
|
| 96 |
+ $output .= "</table>"; |
|
| 97 |
+ |
|
| 98 |
+ } |
|
| 99 |
+ } |
|
| 100 |
+ return $output; |
|
| 101 |
+} |
|
| 102 |
+// end genres function |
|
| 103 |
+ |
|
| 104 |
+?> |
|
| 0 | 105 |
\ No newline at end of file |