4 $StatsDBHost = "192.168.1.169";
5 $StatsDBUserName = "root";
7 $StatsDBName = "stats";
9 include_once('config.php');
11 error_reporting(E_ERROR | E_PARSE
);
15 $dev_ip="192.168.1.169"; //ip where sql error are displayed
16 $private_network = "/192\.168\.1\./i"; //ip where the cmd=log&msg=dump function works
18 //get the ip of the viewer
21 if (getenv("HTTP_CLIENT_IP"))
23 $ip = getenv("HTTP_CLIENT_IP");
25 elseif(getenv("HTTP_X_FORWARDED_FOR"))
27 $ip = getenv("HTTP_X_FORWARDED_FOR");
31 $ip = getenv("REMOTE_ADDR");
37 // if the player ip is the dev ip then the sql error is explain
38 function die2($debug_str)
40 global $private_network;
41 if ( preg_match($private_network, getIp()) )
51 // Get head or post infos from the query url.
52 // return default if the value has not be found
53 function getPost($value, $default=NULL)
55 if ( isSet( $_GET[$value] ) ) { return $_GET[$value]; }
56 if ( isSet($_POST[$value]) ) { return $_POST[$value]; }
60 //---------------------------------------------------------------------------
62 $cmd = getPost("cmd", "get_patch_url");
65 // get Patch url from the nel database
68 $domain = getPost("domain", "");
73 echo "0:wrong domain";
76 $domainName = getPost("domain");
77 $nelLink = mysqli_connect($DBHost, $DBUserName, $DBPassword) or die2 (__FILE__
. " " .__LINE__
." Can't connect to database host:$DBHost user:$DBUserName");
78 mysqli_select_db ($nelLink, $DBName) or die2 (__FILE__
. " " .__LINE__
." Can't access to the table dbname:$DBName");
80 $domainName = mysqli_real_escape_string($nelLink, $domainName);
81 $query = "SELECT backup_patch_url, patch_urls FROM domain WHERE domain_name='$domainName'";
82 $result = mysqli_query ($nelLink, $query) or die2 (__FILE__
. " " .__LINE__
." Can't execute the query: ".$query);
84 if (mysqli_num_rows($result) != 1)
86 // unrecoverable error, we must giveup
87 $reason = "Can't find domain '".$domainName."' (error code x)";
91 $req = mysqli_fetch_array($result);
93 $backup_patch_url = $req["backup_patch_url"];
94 $patch_urls = $req["patch_urls"];
97 $urls = explode(";", $args);
98 // first display backup url
101 echo 'serverPath="'.$backup_patch_url.'"';
104 // then display default uris
106 $last = count($urls);
107 for (; $first != $last; $first++
)
109 if ($urls[$first] == "")
114 echo "\t<patchURI>$urls[$first]</patchURI>\n";
119 mysqli_close($nelLink);
124 echo "0:Unknown command";