-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
61 lines (47 loc) · 2.09 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* search.php
*
* The script handles caching and output of the search.xml with respective values.
*
* @author Amras Taralom <[email protected]>
* @version 1.0, last modified 2009/10/15
* @package XMLArsenal
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
*
*/
require_once './includes/autoload.inc.php';
require_once './includes/config.inc.php';
require_once './includes/db.inc.php';
require_once './includes/data.inc.php';
require_once './includes/functions.inc.php';
//try using cache
$cachefile = FILECACHEFOLDER. md5("search.xml_".$queryString."_selectedTab_".$_GET['selectedTab']."_lang_".$language) .".cache";
if(USEFILECACHE && file_exists($cachefile) && (filemtime($cachefile) + 60*60*UPDATEINTERVAL > time())){
echo file_get_contents($cachefile)."<!-- cached file. cache valid until ".date('d.m.Y H:i:s',filemtime($cachefile) + 60*60*UPDATEINTERVAL).". -->";
die();
}
$search = new Search($queryString);
if($search->getId() && strlen($queryString) >= 2){
//only display appropriate tabs
$count = $search->getResultCount();
if(!$_GET['selectedTab']){
if($count['characters'] > 0) $_GET['selectedTab'] = 'characters';
else if($count['guilds'] > 0) $_GET['selectedTab'] = 'guilds';
else if($count['arenateams'] > 0) $_GET['selectedTab'] = 'arenateams';
}//if
if($_GET['selectedTab'] == 'arenateams') $xml = fgettemplate('./xml-templates/search-arenateamTab.xml', $search->prepareArenateamTab());
else if($_GET['selectedTab'] == 'guilds') $xml = fgettemplate('./xml-templates/search-guildTab.xml', $search->prepareGuildTab());
else $xml = fgettemplate('./xml-templates/search-characterTab.xml', $search->prepareCharacterTab());
$xml = str_replace(array("\n", "\r", "\t", "\o", "\xOB", " "), '', $xml);
$doc = new DOMDocument('1.0');
$doc->preserveWhiteSpace = false;
$doc->loadXML($xml);
$doc->formatOutput = true;
$xml = $doc->saveXML();
if(USEFILECACHE) file_put_contents($cachefile, $xml);
echo $xml;
}else{
echo fgettemplate('./xml-templates/error404.xml', array('LANGUAGE'=>$language));
}
?>