Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,66 @@
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
+if(empty($type) || $type != "challenges") { // If you're already browsing challenges no sense putting them in the other results.
28
+$chalquery = array( );
29
+if(isset($charid)) {
30
+	if(!is_array($charid)) $charid = array($charid);
31
+	if(count($charid) > 0) {
32
+		foreach($charid as $c) {
33
+			$chars[] = "FIND_IN_SET('$c', characters) > 0";
34
+		}
35
+		$chalquery[] = implode(" OR ", $chars);
36
+	}
37
+}
38
+if(is_array($catid) && count($catid) > 0) {
39
+	$categories = array( );
40
+	// Get the recursive list.
41
+	foreach($catid as $cat) {
42
+		if($cat == "false" || empty($cat) || $cat == -1) 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($searchterm) {
54
+	if($searchtype == "title") $chalquery[] = "title LIKE '%$searchterm%'";
55
+	if($searchtype == "summary") $chalquery[] = "summary LIKE '%$searchterm%'";
56
+}
57
+if(count($chalquery) > 0) {
58
+	$chalquery = "WHERE ".implode(" AND ", $chalquery);
59
+	$query = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_challenges $chalquery");
60
+	$challenges = dbnumrows($query);
61
+
62
+	if($challenges > 0) $otherresults[] = "<a href='browse.php?type=challenges&amp;$terms'>$challenges "._CHALLENGES."</a>";
63
+}
64
+	unset($where, $query, $chars, $cats);
65
+}
66
+?>
0 67
\ No newline at end of file