Fix checkRpItemsPosition
[ryzomcore.git] / web / public_php / login / client_install.php
blobdb93f8caae3f7b7436ab30d3bb4ee7ab26aceb2b
1 <?php
3 // LOG database
4 $StatsDBHost = "192.168.1.169";
5 $StatsDBUserName = "root";
6 $StatsDBPassword = "";
7 $StatsDBName = "stats";
9 include_once('config.php');
11 error_reporting(E_ERROR | E_PARSE);
13 // global var
14 $link = NULL;
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
19 function getIp()
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");
29 else
31 $ip = getenv("REMOTE_ADDR");
33 return $ip;
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()) )
43 die($debug_str);
45 else
47 die("GENERIC_ERROR");
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]; }
57 return $default;
60 //---------------------------------------------------------------------------
62 $cmd = getPost("cmd", "get_patch_url");
63 switch ($cmd)
65 // get Patch url from the nel database
67 case "get_patch_url":
68 $domain = getPost("domain", "");
71 if ($domain == "")
73 echo "0:wrong domain";
74 die2();
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)";
88 $res = false;
91 $req = mysqli_fetch_array($result);
93 $backup_patch_url = $req["backup_patch_url"];
94 $patch_urls = $req["patch_urls"];
96 $args = $patch_urls;
97 $urls = explode(";", $args);
98 // first display backup url
99 echo "<version ";
101 echo 'serverPath="'.$backup_patch_url.'"';
102 echo ">\n";
104 // then display default uris
105 $first = 0;
106 $last = count($urls);
107 for (; $first != $last; $first++)
109 if ($urls[$first] == "")
112 else
114 echo "\t<patchURI>$urls[$first]</patchURI>\n";
117 echo "</version>\n";
119 mysqli_close($nelLink);
120 unset($nelLink);
121 break;
123 default:
124 echo "0:Unknown command";
125 die2();