| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,108 @@ |
| 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 |
+if(!defined("_CHARSET")) exit( );
|
|
| 24 |
+ |
|
| 25 |
+if(file_exists(_BASEDIR."modules/challenges/languages/{$language}.php")) include_once(_BASEDIR."modules/challenges/languages/{$language}.php");
|
|
| 26 |
+else include_once(_BASEDIR."modules/challenges/languages/en.php"); |
|
| 27 |
+ |
|
| 28 |
+ $output .= "<div id='pagetitle'>"._CHALLENGES."</div><div class=\"respond\"><a href=\"modules/challenges/challenges.php?action=add\">"._ISSUECHALLENGE."</a></div>".build_alphalinks("browse.php?type=challenges&", $let);
|
|
| 29 |
+ $numrows = 0; |
|
| 30 |
+ $chalquery = array( ); |
|
| 31 |
+ if(!empty($charid)) {
|
|
| 32 |
+ $chars = array( ); |
|
| 33 |
+ foreach($charid as $c) {
|
|
| 34 |
+ $chars[] = "FIND_IN_SET('$c', characters) > 0";
|
|
| 35 |
+ } |
|
| 36 |
+ $chalquery[] = implode(" OR ", $chars);
|
|
| 37 |
+ } |
|
| 38 |
+ if(isset($catid) && count($catid) > 0) {
|
|
| 39 |
+ $categories = array( ); |
|
| 40 |
+ // Get the recursive list. |
|
| 41 |
+ foreach($catid as $cat) {
|
|
| 42 |
+ if($cat == "false" || empty($cat)) continue; |
|
| 43 |
+ $categories = array_merge($categories, recurseCategories($cat)); |
|
| 44 |
+ } |
|
| 45 |
+ // Now format the SQL |
|
| 46 |
+ $cats = array( ); |
|
| 47 |
+ foreach($categories as $cat) {
|
|
| 48 |
+ $cats[] = "FIND_IN_SET($cat, catid) > 0 "; |
|
| 49 |
+ } |
|
| 50 |
+ // Now implode the SQL list |
|
| 51 |
+ if(!empty($cats)) $chalquery[] = "(".implode(" OR ", $cats).")";
|
|
| 52 |
+ } |
|
| 53 |
+ if(isset($authors)) $chalquery[] = "FIND_IN_SET(uid, '".implode(",",$authors)."') > 0";
|
|
| 54 |
+ if(isset($summary)) $chalquery[] = "summary LIKE '%".$summary."%'"; |
|
| 55 |
+ if(isset($title)) $chalquery[] = "summary LIKE '%".$title."%'"; |
|
| 56 |
+ if($let == _OTHER) {
|
|
| 57 |
+ $chalquery[] = "chal.title REGEXP '^[^a-z]'"; |
|
| 58 |
+ } |
|
| 59 |
+ else if(!empty($let)) {
|
|
| 60 |
+ $chalquery[] = "chal.title LIKE '$let%'"; |
|
| 61 |
+ } |
|
| 62 |
+ $chalquery = count($chalquery) > 0 ? " WHERE ".implode(" AND ", $chalquery) : "";
|
|
| 63 |
+ |
|
| 64 |
+ |
|
| 65 |
+ $count = dbquery("SELECT count(chalid) FROM ".TABLEPREFIX."fanfiction_challenges as chal $chalquery");
|
|
| 66 |
+ $query = "SELECT chal.* FROM ".TABLEPREFIX."fanfiction_challenges as chal $chalquery ORDER BY chalid DESC LIMIT $offset, $itemsperpage"; |
|
| 67 |
+ |
|
| 68 |
+ list($numrows) = dbrow($count); |
|
| 69 |
+ if($numrows > 0) {
|
|
| 70 |
+ |
|
| 71 |
+ if(file_exists(_BASEDIR."$skindir/challenges.tpl")) $challenges = new TemplatePower(_BASEDIR."$skindir/challenges.tpl"); |
|
| 72 |
+ else $challenges = new TemplatePower(_BASEDIR."modules/challenges/default_tpls/challenges.tpl"); |
|
| 73 |
+ $challenges->prepare( ); |
|
| 74 |
+ $result = dbquery($query); |
|
| 75 |
+ $count = 0; |
|
| 76 |
+ while($challenge = dbassoc($result)) {
|
|
| 77 |
+ $challenges->newBlock("challenge");
|
|
| 78 |
+ if(isADMIN || (USERUID != 0 && USERUID == $challenge['uid'])) $challenges->assign("adminoptions", "<div class=\"adminoptions\"><span class='label'>".(isADMIN ? _ADMINOPTIONS : _OPTIONS).":</span> [<a href=\"modules/challenges/challenges.php?action=edit&chalid=".$challenge['chalid']."\">"._EDIT."</a>] [<a href=\"modules/challenges/challenges.php?action=delete&chalid=".$challenge['chalid']."\">"._DELETE."</a>]</div>");
|
|
| 79 |
+ $challenges->assign("author", ($challenge['uid'] ? "<a href=\""._BASEDIR."viewuser.php?uid=".$challenge['uid']."\">".$challenge['challenger']."</a>" : $challenge['challenger']));
|
|
| 80 |
+ $challenges->assign("title", "<a href=\"modules/challenges/challenges.php?chalid=".$challenge['chalid']."\">".stripslashes($challenge['title'])."</a>");
|
|
| 81 |
+ $challenges->assign("numresponses", "<a href=\"modules/challenges/challenges.php?chalid=".$challenge['chalid']."\">".$challenge['responses']."</a>");
|
|
| 82 |
+ $challenges->assign("responses", "<a href=\"modules/challenges/challenges.php?chalid=".$challenge['chalid']."\">"._RESPONSES."</a>");
|
|
| 83 |
+ $challenges->assign("summary", stripslashes($challenge['summary']));
|
|
| 84 |
+ $challenges->assign("characters", $challenge['characters'] ? charlist($challenge['characters']) : _NONE);
|
|
| 85 |
+ $challenges->assign("category" , ($challenge['catid'] > 0 ? catlist($challenge['catid']) : _NONE) );
|
|
| 86 |
+ if(isMEMBER) $challenges->assign("respond", "<div class=\"respond\"><a href=\"modules/challenges/challenges.php?action=respond&chalid=".$challenge['chalid']."\">"._RESPOND2CHALLENGE."</a></div>");
|
|
| 87 |
+ $challenges->assign("reportthis", "[<a href=\""._BASEDIR."contact.php?action=report&url=modules/challenges/challenges.php?chalid=".$challenge['chalid']."\">"._REPORTTHIS."</a>]");
|
|
| 88 |
+ $codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'challengeblock'");
|
|
| 89 |
+ while($code = dbassoc($codequery)) {
|
|
| 90 |
+ eval($code['code_text']); |
|
| 91 |
+ } |
|
| 92 |
+ $count++; |
|
| 93 |
+ $challenges->assign("skindir", $skindir);
|
|
| 94 |
+ $challenges->assign("oddeven", ($count % 2 ? "odd" : "even"));
|
|
| 95 |
+ } |
|
| 96 |
+ $tpl->newBlock("listings");
|
|
| 97 |
+ $tpl->assign("pagelinks", $challenges->getOutputContent( ));
|
|
| 98 |
+ $tpl->gotoBlock("_ROOT");
|
|
| 99 |
+ $tpl->newBlock("listings");
|
|
| 100 |
+ if($numrows > $itemsperpage) {
|
|
| 101 |
+ $url = "browse.php?$terms".(!empty($let) ? "&let={$let}" : '')."&";
|
|
| 102 |
+ $tpl->assign("pagelinks", build_pagelinks($url, $numrows, $offset));
|
|
| 103 |
+ } |
|
| 104 |
+ $disablesorts = array("classes", "ratings", "complete", "sorts");
|
|
| 105 |
+ } |
|
| 106 |
+ else $output .= write_message(_NORESULTS); |
|
| 107 |
+ unset($cats, $chars); |
|
| 108 |
+?> |
|
| 0 | 109 |
\ No newline at end of file |