-
Notifications
You must be signed in to change notification settings - Fork 0
/
character-reputation.php
60 lines (45 loc) · 1.84 KB
/
character-reputation.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
<?php
/**
* character-reputation.php
*
* The script handles caching and output of the character-repuatation.xml with respective values.
*
* @author Amras Taralom <[email protected]>
* @version 1.0, last modified 2010/02/17
* @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("character-reputation.xml_".$charname."_on_".$realmName."_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();
}
//don't display blacklisted chars
if(in_array($charname, $blacklistedChars[$usedRealm])){
echo fgettemplate('./xml-templates/error404.xml', array('LANGUAGE'=>$language));
die();
}
$char = new Character($charname, $usedRealm);
if($char->getId()){
if($DATA["factions"][$char->getRace()] == 0) $xmltmpl = "alliance";
else if($DATA["factions"][$char->getRace()] == 1) $xmltmpl = "horde";
$xml = fgettemplate("./xml-templates/character-sheet-reputation_$xmltmpl.xml", $char->prepareCharacterReputationSheet());
$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/character-sheet-no-such-char.xml');
}
?>