"._CHALLENGES."
"._ISSUECHALLENGE."
".build_alphalinks("browse.php?type=challenges&", $let); $numrows = 0; $chalquery = array( ); if(!empty($charid)) { $chars = array( ); foreach($charid as $c) { $chars[] = "FIND_IN_SET('$c', characters) > 0"; } $chalquery[] = implode(" OR ", $chars); } if(isset($catid) && count($catid) > 0) { $categories = array( ); // Get the recursive list. foreach($catid as $cat) { if($cat == "false" || empty($cat)) continue; $categories = array_merge($categories, recurseCategories($cat)); } // Now format the SQL $cats = array( ); foreach($categories as $cat) { $cats[] = "FIND_IN_SET($cat, catid) > 0 "; } // Now implode the SQL list if(!empty($cats)) $chalquery[] = "(".implode(" OR ", $cats).")"; } if(isset($authors)) $chalquery[] = "FIND_IN_SET(uid, '".implode(",",$authors)."') > 0"; if(isset($summary)) $chalquery[] = "summary LIKE '%".$summary."%'"; if(isset($title)) $chalquery[] = "summary LIKE '%".$title."%'"; if($let == _OTHER) { $chalquery[] = "chal.title REGEXP '^[^a-z]'"; } else if(!empty($let)) { $chalquery[] = "chal.title LIKE '$let%'"; } $chalquery = count($chalquery) > 0 ? " WHERE ".implode(" AND ", $chalquery) : ""; $count = dbquery("SELECT count(chalid) FROM ".TABLEPREFIX."fanfiction_challenges as chal $chalquery"); $query = "SELECT chal.* FROM ".TABLEPREFIX."fanfiction_challenges as chal $chalquery ORDER BY chalid DESC LIMIT $offset, $itemsperpage"; list($numrows) = dbrow($count); if($numrows > 0) { if(file_exists(_BASEDIR."$skindir/challenges.tpl")) $challenges = new TemplatePower(_BASEDIR."$skindir/challenges.tpl"); else $challenges = new TemplatePower(_BASEDIR."modules/challenges/default_tpls/challenges.tpl"); $challenges->prepare( ); $result = dbquery($query); $count = 0; while($challenge = dbassoc($result)) { $challenges->newBlock("challenge"); if(isADMIN || (USERUID != 0 && USERUID == $challenge['uid'])) $challenges->assign("adminoptions", "
".(isADMIN ? _ADMINOPTIONS : _OPTIONS).": ["._EDIT."] ["._DELETE."]
"); $challenges->assign("author", ($challenge['uid'] ? "".$challenge['challenger']."" : $challenge['challenger'])); $challenges->assign("title", "".stripslashes($challenge['title']).""); $challenges->assign("numresponses", "".$challenge['responses'].""); $challenges->assign("responses", ""._RESPONSES.""); $challenges->assign("summary", stripslashes($challenge['summary'])); $challenges->assign("characters", $challenge['characters'] ? charlist($challenge['characters']) : _NONE); $challenges->assign("category" , ($challenge['catid'] > 0 ? catlist($challenge['catid']) : _NONE) ); if(isMEMBER) $challenges->assign("respond", "
"._RESPOND2CHALLENGE."
"); $challenges->assign("reportthis", "["._REPORTTHIS."]"); $codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'challengeblock'"); while($code = dbassoc($codequery)) { eval($code['code_text']); } $count++; $challenges->assign("skindir", $skindir); $challenges->assign("oddeven", ($count % 2 ? "odd" : "even")); } $tpl->newBlock("listings"); $tpl->assign("pagelinks", $challenges->getOutputContent( )); $tpl->gotoBlock("_ROOT"); $tpl->newBlock("listings"); if($numrows > $itemsperpage) { $url = "browse.php?$terms".(!empty($let) ? "&let={$let}" : '')."&"; $tpl->assign("pagelinks", build_pagelinks($url, $numrows, $offset)); } $disablesorts = array("classes", "ratings", "complete", "sorts"); } else $output .= write_message(_NORESULTS); unset($cats, $chars); ?>