Hmm jeg har et rimeligt stort script som opdatere noget quake2 server status hvært 30 sek!
Men der bliver kaget lidt rundet i det! de bliver gemt under de forkerte kolonner.
hmm i mut script er der 2 functioner i nok ikke kender men her der de!
function db_save($dbname,$array,$arrayver) {
$carray=count($array);
$cver=count($arrayver);
IF (!$carray == $cver){
echo "Code erro plz contact <a href=\\"mailto:doomstone@doomstone.dk\\">doomstone</a> to report the erro";
}else{
$sql = "INSERT INTO";
$sql .= " $dbname ";
$sql .= "(";
$total = count($array)-1;
FOR ($tal=0;$tal <= $total;$tal++){ $sql .= $array[$tal]; IF ($tal == $total){}else { $sql .= ", "; } };
$sql .= ") VALUES (";
FOR ($tal=0;$tal <= $total;$tal++){ $sql .= "'$arrayver[$tal]'"; IF ($tal == $total){}else { $sql .= ", "; } }
$sql .= ")";
mysql_query($sql) or die(mysql_error());
}
}
function db_update($dbname,$id,$array,$arrayver) {
$carray=count($array);
$cver=count($arrayver);
IF (!$carray == $cver){
echo "Code erro plz contact <a href=\\"mailto:doomstone@doomstone.dk\\">doomstone</a> to report the erro";
}else{
$sql = "UPDATE";
$sql .= " $dbname ";
$sql .= "SET ";
$total = count($array)-1;
FOR ($tal=0;$tal <= $total;$tal++){ $sql .= "$array[$tal]='$arrayver[$tal]'"; IF ($tal == $total){}else { $sql .= ", "; } };
$sql .= " WHERE id=$id";
mysql_query($sql) or die(mysql_error());
}
}
Ja nu er vi kommet til mit script
Læg dog mærke til at jeg bruger qplug til at få informationen ud af server.
her der det:
http://193.89.254.15/noechoqplug.classog mit script som udføre det hele!
<?
include("noechoqplug.class");
db_connect();
include("function.inc");
?>
<?
set_time_limit(0);
while (1) { sleep(30); // sætter den til at loppe hvære 30 sek
echo "Updating Servers v 2.1 \\n";
// updatere server status
$foresp = mysql_query("SELECT * FROM botserverlist ORDER BY id") or die (mysql_error());
$ja = mysql_num_rows($foresp);
IF ($ja == 0){ echo "No Servers"; } else {
while($data = mysql_fetch_array($foresp)){
$server = new Q2Plug($data[addr],$data[port],"");
if ($server->Connect()) {
$server->GetData();
$server->Disconnect();
$server->SetVars(array("gamename","features","capturelimit","maxclients","timelimit","dmflags","version"));
$server->ParseData();
$server->serverinfo();
$server->players();
$server->echo_server($data[addr],$data[port],$data[id]);
$serverip[] = $data[addr].":".$data[port].":".$server->hostname;
} // slutter connection
else { echo "Could not connect to ".$server->GetAddr(); }
}} // skutter sql while
// gemmer player info
$antal = count($serverip)-1;
$i="0";
while($i <= $antal){
$explode = explode(":", $serverip[$i]);
$server = new Q2Plug($explode[0],$explode[1],"");
if ($server->Connect()) {
$server->GetData();
$server->Disconnect();
$server->SetVars(array("gamename","features","capturelimit","maxclients","timelimit","dmflags","version"));
$server->ParseData();
$server->serverinfo();
$server->playersave($explode[0],$explode[1],$explode[2]);
} // slutter connection
else { echo "Could not connect to ".$server->GetAddr(); }
//inc $i
$i++;
}
flush();
} // lopning slut!
?>
det er i databasen botserverplayers den fucker rundt i det!
og min tabel botserverlist ser sådan ud!
(tror at det er bedst at u får det i dump format)
CREATE TABLE botserverlist (
id int(11) NOT NULL auto_increment,
addr text NOT NULL,
port text NOT NULL,
hostname text NOT NULL,
map text NOT NULL,
players text NOT NULL,
time text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
#
# Data dump for tabellen `botserverlist`
#
INSERT INTO botserverlist VALUES (1, '210.18.218.27', '29667', 'AQ2: The Next Generation Server (Teamplay)', 'arcadia', '0', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (3, '193.163.220.187', '27234', 'AQ2.DK CW server 1 (TNG)', 'riot', '4', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (4, '193.163.220.187', '27345', 'AQ2.DK CW server 2 (TNG)', 'teamjungle', '0', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (7, '193.163.220.187', '27935', '(=GNU=) Public Server', 'teamjungle', '8', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (6, '193.163.220.187', '27936', '(=GNU=) Clanwar Server 2', 'teamjungle', '4', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (8, '193.163.220.187', '27900', 'SoV - Seals of Vengeance (TNG)', 'cloud', '0', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (9, '194.251.249.71', '27910', 'eDome AQ2 Teamplay #1', 'urban3', '0', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (10, '194.251.249.71', '27920', 'eDome AQ2 Teamplay #2 CTF', 'deepcanyon', '0', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (11, 'clan.q2.edome.net', '27910', 'eDome Quake2 Clan 1', 'riot', '7', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (12, 'clan.q2.edome.net', '27920', 'HAASTAKAAA', 'riot', '4', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (13, 'clan.q2.edome.net', '27930', 'hip', 'cloud', '9', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (14, 'clan.q2.edome.net', '27940', 'eDome Quake2 Clan 4', 'sludge1', '9', '16:22 13/1/2003');
INSERT INTO botserverlist VALUES (15, '193.163.220.187', '27123', 'Public AQ2.DK server (TNG)', 'cliff2', '9', '16:22 13/1/2003');
hmm slut
håber i kan hjælpe!
----------------------
DoomStone@DoomStone.dk[Redigeret d. 12/01-03 22:14:35 af Kasper Søgaard][Redigeret d. 13/01-03 16:43:25 af Kasper Søgaard]