Merge branch '164-crash-on-patching-and-possibly-right-after-login' into 'main/atys...
[ryzomcore.git] / nelns / admin / public_html / update_daily.php
blob1974b36a948aae14f4eeaa536356fc3389a4f027
1 <?php
2 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
3 // Copyright (C) 2010 Winch Gate Property Limited
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Affero General Public License as
7 // published by the Free Software Foundation, either version 3 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Affero General Public License for more details.
15 // You should have received a copy of the GNU Affero General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 if ($REMOTE_ADDR != '195.68.21.194')
19 die();
21 if (!isset($version))
22 die('NO VERSION SET');
24 include('../config.php');
26 //error_reporting(E_NOTICE);
28 // connect to database
29 function connectToDatabase($dbhost, $dbname, $dblogin, $dbpasswd)
31 $connect_id;
32 if (!($connect_id = mysql_connect($dbhost, $dblogin, $dbpasswd)))
33 die("Unable to connect to MySQL server '$dbhost'");
34 if (!mysql_select_db ($dbname, $connect_id))
35 die("Unable to select MySQL database '$dbname'");
36 return array($connect_id, $dbname);
39 function sqldbquery($query, $id)
41 global $queries;
42 // here log queries
43 mysql_select_db($id[1], $id[0]);
44 $res = mysql_query($query, $id[0]);
45 $queries[] = "'$query' on db ".$id[1];
46 return $res;
49 function sqlfetch(&$result)
51 return mysql_fetch_array($result);
54 function sqlaffectedrows($id)
56 return mysql_affected_rows($id[0]);
59 function sqllistfields($table, $id)
61 return mysql_list_fields($id[1], $table, $id[0]);
64 function sqlnumrows($result)
66 return mysql_num_rows($result);
69 function sqlnumfields($result)
71 return mysql_num_fields($result);
74 function sqlfieldname($result, $i)
76 return mysql_field_name($result, $i);
79 function sqlerr($id)
81 return "error ".mysql_errno($id[0]).": ".mysql_error($id[0]);
84 $dbname = "nel";
86 $id = connectToDatabase($dbhost, $dbname, $dblogin, $dbpassword);
88 $shardid = "61";
89 $query = "UPDATE shard SET Version='$version' WHERE ShardId='$shardid'";
90 $result = sqldbquery($query, $id);
92 die ($result ? "[OK]" : "[FAILED]");