summaryrefslogtreecommitdiff
path: root/html/import
diff options
context:
space:
mode:
Diffstat (limited to 'html/import')
-rwxr-xr-xhtml/import/import_ass.php34
-rwxr-xr-xhtml/import/import_bt.php46
-rwxr-xr-xhtml/import/import_ctf.php43
-rwxr-xr-xhtml/import/import_dom.php19
-rwxr-xr-xhtml/import/import_jailbreak.php22
-rwxr-xr-xhtml/import/import_killsmatrix.php22
-rwxr-xr-xhtml/import/import_lms.php46
-rwxr-xr-xhtml/import/import_pcleanup.php256
-rwxr-xr-xhtml/import/import_playerstuff.php182
-rwxr-xr-xhtml/import/import_ranking.php127
-rwxr-xr-xhtml/import/import_tdm.php2
-rwxr-xr-xhtml/import/import_weapons.php209
-rwxr-xr-xhtml/import/index.htm0
13 files changed, 1008 insertions, 0 deletions
diff --git a/html/import/import_ass.php b/html/import/import_ass.php
new file mode 100755
index 0000000..9539bc5
--- /dev/null
+++ b/html/import/import_ass.php
@@ -0,0 +1,34 @@
+<?php
+// Who did the objectives
+ $r_assobj = small_query("SELECT count(id) AS assobjcount FROM uts_temp_$uid WHERE col1 = 'assault_obj' AND col2 = $playerid");
+ $assobjcount = $r_assobj[assobjcount];
+ $upd_assobj = "UPDATE uts_player SET ass_obj = $assobjcount WHERE id = $playerecordid";
+ mysql_query($upd_assobj) or die(mysql_error());
+
+// Get assault game code (unique code give for the 2 games played)
+
+ $r_asscode = small_query("SELECT col2 FROM uts_temp_$uid WHERE col1 = 'assault_gamecode' LIMIT 0,1");
+ $asscode = $r_asscode[col2];
+ $updateasscode = "UPDATE uts_match SET assaultid = '$asscode' WHERE id = $matchid";
+ mysql_query($updateasscode) or die(mysql_error());
+
+// Get Which Teams Attacking
+
+ $r_assteam = small_query("SELECT col2 FROM uts_temp_$uid WHERE col1 = 'assault_attacker' LIMIT 0,1");
+ $assteam = $r_assteam[col2];
+ $updateassteam = "UPDATE uts_match SET ass_att = $assteam WHERE id = $matchid;";
+ mysql_query($updateassteam) or die(mysql_error());
+
+// Did they do it?
+
+ $sql_asswin = "SELECT col0 FROM uts_temp_$uid WHERE col1 = 'game_end' AND col2 = 'Assault succeeded!' LIMIT 0,1";
+ $q_asswin = mysql_query($sql_asswin) or die(mysql_error());
+ $asswin = 0;
+
+ while ($r_asswin = mysql_fetch_array($q_asswin)) {
+ IF ($r_asswin[col0] != NULL ) { $asswin = 1; }
+ }
+
+ $updateasswin = "UPDATE uts_match SET ass_win = $asswin WHERE id = $matchid;";
+ mysql_query($updateasswin) or die(mysql_error());
+?>
diff --git a/html/import/import_bt.php b/html/import/import_bt.php
new file mode 100755
index 0000000..fe6a480
--- /dev/null
+++ b/html/import/import_bt.php
@@ -0,0 +1,46 @@
+<?php
+// get the caps, captimes and store them in the events database
+ $sql_capbt = "SELECT col0, col1, col2, col3, col4 FROM uts_temp_$uid WHERE (col1 = 'cap' OR col1 = 'btcap') AND col2 = $playerid";
+ $q_capbt = mysql_query($sql_capbt);
+
+ $cap_speed = 0;
+ $cap_time = 0;
+ $cap_gametime = 0;
+ $flag_capture = 0;
+
+ while ($r_capbt = mysql_fetch_array($q_capbt)) {
+ if ($cap_speed == 0 || $r_capbt['col3'] > $cap_speed) {
+ $cap_speed = $r_capbt['col3'];
+ $col0 = $r_capbt['col0']; // time
+ $col1 = $r_capbt['col1']; // cap
+ $col2 = $r_capbt['col2']; // playerid
+ $col3 = $r_capbt['col3']; // speed in 2000 - seconds (old system) or 600000 - hundreds of seconds (new system)
+ $col4 = $r_capbt['col4']; // date in seconds since epoch
+ }
+ $flag_capture++;
+ }
+
+ if ($cap_speed != 0) {
+ # use col2 to store the rank, col3 to store the captime in seconds and col4 to store the date of the record
+ $col2 = small_count("SELECT DISTINCT col2 FROM uts_temp_$uid WHERE col1 = 'cap' AND col3 > $col3") + 1;
+ if ($col1 == "btcap") {
+ $col3 = ceil(600000 - $col3) / 100;
+ }
+ else if ($col1 == "cap") {
+ $col3 = ceil((2000 - $col3-1)*100/1.1) / 100;
+ $col1 = "btcap";
+ }
+ $col3 = sprintf("%01.2f", $col3);
+ $sql_eventsbt = "INSERT INTO uts_events
+ (matchid, playerid, col0, col1, col2, col3, col4) VALUES
+ ($matchid, $playerid, '$col0', '$col1', '$col2', '$col3', '$col4')";
+ mysql_query($sql_eventsbt) or die (mysql_error());
+ }
+
+ if ($flag_capture > 0) {
+ $sql_playerflags = " UPDATE uts_player
+ SET flag_capture = $flag_capture
+ WHERE id = $playerecordid";
+ mysql_query($sql_playerflags) or die(mysql_error());
+ }
+?>
diff --git a/html/import/import_ctf.php b/html/import/import_ctf.php
new file mode 100755
index 0000000..206cbb0
--- /dev/null
+++ b/html/import/import_ctf.php
@@ -0,0 +1,43 @@
+<?php
+// Get Player Flag Events Count
+ $sql_playerctf = "SELECT col1, COUNT(col1) AS flag_count FROM uts_temp_$uid WHERE (col1 LIKE 'flag_%' OR col1 = 'cover' OR col1 = 'seal') AND col2 = $playerid GROUP BY col1";
+ $q_playerctf = mysql_query($sql_playerctf);
+
+ $flag_taken = 0;
+ $flag_dropped = 0;
+ $flag_return = 0;
+ $flag_capture = 0;
+ $flag_cover = 0;
+ $flag_seal = 0;
+ $flag_assist = 0;
+ $flag_kill = 0;
+ $flag_pickedup = 0;
+
+ while ($r_playerctf = mysql_fetch_array($q_playerctf)) {
+
+ // Cycle through events and see what the player got
+
+ IF ($r_playerctf[col1] == "flag_taken") { $flag_taken = $r_playerctf[flag_count]; }
+ IF ($r_playerctf[col1] == "flag_dropped") { $flag_dropped = $r_playerctf[flag_count]; }
+ IF ($r_playerctf[col1] == "flag_returned") { $flag_return = $r_playerctf[flag_count]; }
+ IF ($r_playerctf[col1] == "flag_captured") { $flag_capture = $r_playerctf[flag_count]; }
+ IF ($r_playerctf[col1] == "flag_cover" or $r_playerctf[col1] == "Flag_cover" or $r_playerctf[col1] == "cover") { $flag_cover = $r_playerctf[flag_count]; }
+ IF ($r_playerctf[col1] == "flag_seal" or $r_playerctf[col1] == "Flag_seal" or $r_playerctf[col1] == "seal") { $flag_seal = $r_playerctf[flag_count]; }
+ IF ($r_playerctf[col1] == "flag_assist" or $r_playerctf[col1] == "Flag_assist") { $flag_assist = $r_playerctf[flag_count]; }
+ IF ($r_playerctf[col1] == "flag_kill" or $r_playerctf[col1] == "Flag_kill") { $flag_kill = $r_playerctf[flag_count]; }
+ IF ($r_playerctf[col1] == "flag_pickedup" or $r_playerctf[col1] == "flag_pickedup") { $flag_pickedup = $r_playerctf[flag_count]; }
+ }
+
+ $sql_playerflags = " UPDATE uts_player
+ SET flag_taken = $flag_taken,
+ flag_dropped = $flag_dropped,
+ flag_return = $flag_return,
+ flag_capture = $flag_capture,
+ flag_cover = $flag_cover,
+ flag_seal = $flag_seal,
+ flag_assist = $flag_assist,
+ flag_kill = $flag_kill,
+ flag_pickedup = $flag_pickedup
+ WHERE id = $playerecordid";
+ mysql_query($sql_playerflags) or die(mysql_error());
+?>
diff --git a/html/import/import_dom.php b/html/import/import_dom.php
new file mode 100755
index 0000000..91106ac
--- /dev/null
+++ b/html/import/import_dom.php
@@ -0,0 +1,19 @@
+<?php
+// Get dom player scores
+ $sql_domplayer = "SELECT col3 FROM uts_temp_$uid WHERE col1 = 'dom_playerscore_update' AND col2 = $playerid ORDER BY id DESC LIMIT 0,1";
+ $q_domplayer = mysql_query($sql_domplayer) or die(mysql_error());
+ $r_domplayer = mysql_fetch_array($q_domplayer);
+ $domplayer = $r_domplayer[col3];
+ if (empty($domplayer)) {
+ $domplayer = 0;
+ }
+ $updatedomplayer = "UPDATE uts_player SET ass_obj = $domplayer WHERE id = $playerecordid";
+ mysql_query($updatedomplayer) or die("Error idom1:" . mysql_error());
+
+// Who did the control points
+ $r_domcp = small_query("SELECT count(id) AS domcpcount FROM uts_temp_$uid WHERE col1 = 'controlpoint_capture' AND col3 = $playerid");
+ $domcpcount = $r_domcp[domcpcount];
+ $upd_domcp = "UPDATE uts_player SET dom_cp = $domcpcount WHERE id = $playerecordid";
+ mysql_query($upd_domcp) or die("Error idom2:" . mysql_error());
+
+?> \ No newline at end of file
diff --git a/html/import/import_jailbreak.php b/html/import/import_jailbreak.php
new file mode 100755
index 0000000..6d6e0da
--- /dev/null
+++ b/html/import/import_jailbreak.php
@@ -0,0 +1,22 @@
+<?php
+// Get team releases
+ $q_releases = small_query("SELECT COUNT(*) AS releases FROM uts_temp_$uid WHERE col1 = 'team_released' AND col3 = $playerid");
+ $r_releases = $q_releases['releases'];
+
+// Get the real suicide count
+// (Jail releases should not be counted as suicides)
+ $q_suicides = small_query("SELECT COUNT(*) AS suicides FROM uts_temp_$uid WHERE col1 = 'suicide' AND col2 = $playerid and col4 <> 'RedeemerDeath' and col4 <> 'JailRelease'");
+ $r_suicides = $q_suicides['suicides'];
+
+ $r_frags = $r_kills - $r_suicides;
+ $r_efficiency = get_dp(($r_kills / ($r_kills + $r_deaths + $r_suicides + $r_teamkills)) * 100);
+
+
+ mysql_query(" UPDATE uts_player
+ SET ass_obj = '$r_releases',
+ suicides = '$r_suicides',
+ frags = '$r_frags',
+ eff = '$r_efficiency'
+ WHERE id = $playerecordid;") or die(mysql_error());
+
+?> \ No newline at end of file
diff --git a/html/import/import_killsmatrix.php b/html/import/import_killsmatrix.php
new file mode 100755
index 0000000..433a659
--- /dev/null
+++ b/html/import/import_killsmatrix.php
@@ -0,0 +1,22 @@
+<?php
+ $sql_killmatrix = "SELECT col2 AS killer,
+ col4 AS killed,
+ COUNT(*) AS kills
+ FROM uts_temp_$uid
+ WHERE col1 = 'kill'
+ OR col1 = 'teamkill'
+ GROUP BY col2, col4";
+
+ $q_killmatrix = mysql_query($sql_killmatrix) or die(mysql_error());
+ while ($r_killmatrix = mysql_fetch_array($q_killmatrix)) {
+
+ $sql = " INSERT
+ INTO uts_killsmatrix
+ SET matchid = '$matchid',
+ killer = '". $r_killmatrix['killer'] ."',
+ victim = '". $r_killmatrix['killed'] ."',
+ kills = '". $r_killmatrix['kills'] ."';";
+ mysql_query($sql) or die(mysql_error());
+
+ }
+?>
diff --git a/html/import/import_lms.php b/html/import/import_lms.php
new file mode 100755
index 0000000..eb3ebd7
--- /dev/null
+++ b/html/import/import_lms.php
@@ -0,0 +1,46 @@
+<?php
+// get the caps, captimes and store them in the events database
+ $ttl = 0;
+ if ($qc_deaths[col4] + $q_suicides[col4] == $qm_gameinfofl[col3]) {
+ // echo " get out time ";
+ $outtime = small_query("SELECT col0, col1, col2 FROM uts_temp_$uid WHERE (col1 = 'kill' AND col4 = $playerid) or (col1 = 'suicide' AND col2 = $playerid) ORDER BY CONVERT(col0, UNSIGNED INTEGER) DESC LIMIT 0,1");
+ $col0 = $outtime[col0];
+ $col1 = 'out';
+ $col2 = intval($outtime[col0] - $gamestart); //time
+ $col3 = $outtime[col2]; // killer
+ $col4 = "";
+
+ $sql_eventslms = "INSERT INTO uts_events
+ (matchid, playerid, col0, col1, col2, col3, col4) VALUES
+ ($matchid, $playerid, '$col0', '$col1', '$col2', '$col3', '$col4')";
+ mysql_query($sql_eventslms) or die (mysql_error());
+
+ // Fix ttl
+ $ttl = ($outtime[col0] - $gamestart) / ($qc_deaths[col4] + $q_suicides[col4]);
+
+ mysql_query("UPDATE uts_player SET ttl = $ttl WHERE id = $playerecordid") or die(mysql_error());
+ }
+ else {
+ $disconnect = small_query("SELECT col0 FROM uts_temp_$uid WHERE col1 = 'player' AND col2 = 'Disconnect' AND col3 = $playerid");
+ if ((!empty($disconnect[col0])) and (intval($disconnect[col0]) < intval($gameend))) {
+ // echo " get out time ";
+ $outtime = $player_left - $gamestart;
+ $q_out = mysql_query($sql_out);
+ $col0 = $disconnect[col0];
+ $col1 = 'out';
+ $col2 = intval($disconnect[col0] - $gamestart); //time
+ $col3 = "Disconnect";
+ $col4 = "";
+
+ $sql_eventslms = "INSERT INTO uts_events
+ (matchid, playerid, col0, col1, col2, col3, col4) VALUES
+ ($matchid, $playerid, '$col0', '$col1', '$col2', '$col3', '$col4')";
+ mysql_query($sql_eventslms) or die (mysql_error());
+
+ // Update ttl and set score to 0
+ $ttl = ($disconnect[col0] - $gamestart) / ($qc_deaths[col4] + $q_suicides[col4]);
+
+ mysql_query("UPDATE uts_player SET ttl = $ttl, gamescore = 0 WHERE id = $playerecordid") or die(mysql_error());
+ }
+ }
+?>
diff --git a/html/import/import_pcleanup.php b/html/import/import_pcleanup.php
new file mode 100755
index 0000000..3e1be8a
--- /dev/null
+++ b/html/import/import_pcleanup.php
@@ -0,0 +1,256 @@
+<?php
+$sql_tgame = small_query("SELECT teamgame FROM uts_match WHERE id = $matchid");
+IF($sql_tgame == "True") {
+ $rem_srecord = "DELETE FROM uts_player WHERE matchid = $matchid AND team > 3";
+ mysql_query($rem_srecord);
+}
+
+$cleaned = false;
+// Get list of players
+$sql_pname = "SELECT pid, name FROM uts_player, uts_pinfo AS pi WHERE matchid = $matchid AND pid = pi.id";
+$q_pname = mysql_query($sql_pname);
+while ($r_pname = mysql_fetch_array($q_pname)) {
+ $playername = addslashes($r_pname[name]);
+ $pid = $r_pname['pid'];
+
+
+ // Check if player has more than 1 record
+ $q_ids = mysql_query("SELECT playerid FROM uts_player WHERE pid = '$pid' AND matchid = $matchid");
+
+ IF (mysql_num_rows($q_ids) > 1) {
+ $numrecords = mysql_num_rows($q_ids);
+ echo $r_pname[name] .' ';
+ // get all the ids this player had
+ $playerids = array();
+ while ($r_ids = mysql_fetch_array($q_ids)) {
+ $playerids[] = $r_ids['playerid'];
+ }
+
+ $r_newplayerid = small_query("SELECT (MAX(playerid) + 1) AS newplayerid FROM uts_player WHERE matchid = $matchid");
+ $newplayerid = $r_newplayerid['newplayerid'];
+
+ // Fix the events table
+ foreach ($playerids as $i => $oldplayerid) {
+ mysql_query("UPDATE uts_events SET playerid = $newplayerid WHERE playerid = $oldplayerid AND matchid = $matchid");
+ }
+
+ // Fix matchcount in ranking table
+ // mysql_query("UPDATE uts_rank SET matches = matches - ". ($numrecords - 1) ." WHERE pid = '$pid' AND gid = '$gid'") or die(mysql_error());
+
+ // ***********************
+ // UPDATE THE KILLS MATRIX
+ $sql_kmupdate = " SELECT victim,
+ SUM(kills) AS kills
+ FROM uts_killsmatrix
+ WHERE matchid = $matchid
+ AND killer IN (". implode(",", $playerids) .")
+ GROUP BY victim;";
+
+ $q_kmupdate = mysql_query($sql_kmupdate);
+ while ($r_kmupdate = mysql_fetch_array($q_kmupdate)) {
+ mysql_query(" INSERT
+ INTO uts_killsmatrix
+ SET matchid = $matchid,
+ killer = $newplayerid,
+ victim = ${r_kmupdate['victim']},
+ kills = ${r_kmupdate['kills']};");
+ }
+
+ $sql_kmupdate = " SELECT killer,
+ SUM(kills) AS kills
+ FROM uts_killsmatrix
+ WHERE matchid = $matchid
+ AND victim IN (". implode(",", $playerids) .")
+ GROUP BY killer;";
+
+ $q_kmupdate = mysql_query($sql_kmupdate);
+ while ($r_kmupdate = mysql_fetch_array($q_kmupdate)) {
+ mysql_query(" INSERT
+ INTO uts_killsmatrix
+ SET matchid = $matchid,
+ killer = ${r_kmupdate['killer']},
+ victim = $newplayerid,
+ kills = ${r_kmupdate['kills']};");
+ }
+
+ mysql_query(" DELETE
+ FROM uts_killsmatrix
+ WHERE matchid = $matchid
+ AND (killer IN (". implode(",", $playerids) .")
+ OR victim IN (". implode(",", $playerids) ."));");
+
+
+ // FINISHED UPDATING THE KILLS MATRiX
+ // **********************************
+
+
+ // Get non summed information
+
+ $r_truepinfo1 = small_query("SELECT insta, pid, team, isabot, country, ip, gid FROM uts_player WHERE pid = '$pid' AND matchid = $matchid LIMIT 0,1");
+ // fix rejoin as spec
+ if ($r_treupinfo1['team'] == 255) {
+ $r_trueteam = small_query("SELECT team FROM uts_player WHERE pid = '$pid' AND matchid = $matchid AND team != 255 LIMIT 0,1");
+ if ($r_trueteam['team'] < 255) {
+ $r_truepinfo1['team'] = $r_trueteam['team'];
+ }
+ }
+
+ // Group Player Stuff so we only have 1 player record per match
+ if ($gamename == "Bunny Track") {
+ // In bunnytrack the gamescore is 2000 - fastest time in seconds so use MAX gamescore rather then SUM
+ $r_truepinfo2 = small_query("SELECT
+ SUM(gametime) AS gametime,
+ MAX(gamescore) AS gamescore,
+ AVG(lowping) AS lowping,
+ AVG(highping) AS highping,
+ AVG(avgping) AS avgping,
+ SUM(frags) AS frags,
+ SUM(deaths) AS deaths,
+ SUM(kills) AS kills,
+ SUM(suicides) AS suicides,
+ SUM(teamkills) AS teamkills,
+ AVG(eff) AS eff,
+ AVG(accuracy) AS accuracy,
+ AVG(ttl) AS ttl,
+ SUM(flag_taken) AS flag_taken,
+ SUM(flag_pickedup) AS flag_pickedup,
+ SUM(flag_dropped) AS flag_dropped,
+ SUM(flag_return) AS flag_return,
+ SUM(flag_capture) AS flag_capture,
+ SUM(flag_cover) AS flag_cover,
+ SUM(flag_seal) AS flag_seal,
+ SUM(flag_assist) AS flag_assist,
+ SUM(flag_kill) AS flag_kill,
+ SUM(dom_cp) AS dom_cp,
+ SUM(ass_obj) AS ass_obj,
+ SUM(spree_double) AS spree_double,
+ SUM(spree_triple) AS spree_triple,
+ SUM(spree_multi) AS spree_multi,
+ SUM(spree_mega) AS spree_mega,
+ SUM(spree_ultra) AS spree_ultra,
+ SUM(spree_monster) AS spree_monster,
+ SUM(spree_kill) AS spree_kill,
+ SUM(spree_rampage) AS spree_rampage,
+ SUM(spree_dom) AS spree_dom,
+ SUM(spree_uns) AS spree_uns,
+ SUM(spree_god) AS spree_god,
+ SUM(pu_pads) AS pu_pads,
+ SUM(pu_armour) AS pu_armour,
+ SUM(pu_keg) AS pu_keg,
+ SUM(pu_invis) AS pu_invis,
+ SUM(pu_belt) AS pu_belt,
+ SUM(pu_amp) AS pu_amp,
+ SUM(rank) AS rank
+ FROM uts_player WHERE matchid = $matchid AND pid = '$pid'");
+ }
+ else {
+ $r_truepinfo2 = small_query("SELECT
+ SUM(gametime) AS gametime,
+ SUM(gamescore) AS gamescore,
+ AVG(lowping) AS lowping,
+ AVG(highping) AS highping,
+ AVG(avgping) AS avgping,
+ SUM(frags) AS frags,
+ SUM(deaths) AS deaths,
+ SUM(kills) AS kills,
+ SUM(suicides) AS suicides,
+ SUM(teamkills) AS teamkills,
+ AVG(eff) AS eff,
+ AVG(accuracy) AS accuracy,
+ AVG(ttl) AS ttl,
+ SUM(flag_taken) AS flag_taken,
+ SUM(flag_pickedup) AS flag_pickedup,
+ SUM(flag_dropped) AS flag_dropped,
+ SUM(flag_return) AS flag_return,
+ SUM(flag_capture) AS flag_capture,
+ SUM(flag_cover) AS flag_cover,
+ SUM(flag_seal) AS flag_seal,
+ SUM(flag_assist) AS flag_assist,
+ SUM(flag_kill) AS flag_kill,
+ SUM(dom_cp) AS dom_cp,
+ SUM(ass_obj) AS ass_obj,
+ SUM(spree_double) AS spree_double,
+ SUM(spree_triple) AS spree_triple,
+ SUM(spree_multi) AS spree_multi,
+ SUM(spree_mega) AS spree_mega,
+ SUM(spree_ultra) AS spree_ultra,
+ SUM(spree_monster) AS spree_monster,
+ SUM(spree_kill) AS spree_kill,
+ SUM(spree_rampage) AS spree_rampage,
+ SUM(spree_dom) AS spree_dom,
+ SUM(spree_uns) AS spree_uns,
+ SUM(spree_god) AS spree_god,
+ SUM(pu_pads) AS pu_pads,
+ SUM(pu_armour) AS pu_armour,
+ SUM(pu_keg) AS pu_keg,
+ SUM(pu_invis) AS pu_invis,
+ SUM(pu_belt) AS pu_belt,
+ SUM(pu_amp) AS pu_amp,
+ SUM(rank) AS rank
+ FROM uts_player WHERE matchid = $matchid AND pid = '$pid'");
+ }
+
+ // Remove all of this player's records
+ $rem_precord = "DELETE FROM uts_player WHERE matchid = $matchid AND pid = '$pid'";
+ mysql_query($rem_precord);
+
+ // Add this new record to match
+ $upd_precord = " INSERT
+ INTO uts_player
+ SET matchid = $matchid,
+ insta = '$r_truepinfo1[insta]',
+ playerid = '$newplayerid',
+ pid = '$pid',
+ team = '$r_truepinfo1[team]',
+ isabot = '$r_truepinfo1[isabot]',
+ country = '$r_truepinfo1[country]',
+ ip = '$r_truepinfo1[ip]',
+ gid = '$r_truepinfo1[gid]',
+ gametime = '$r_truepinfo2[gametime]',
+ gamescore = '$r_truepinfo2[gamescore]',
+ lowping = '".(int)$r_truepinfo2[lowping]."',
+ highping = '".(int)$r_truepinfo2[highping]."',
+ avgping = '".(int)$r_truepinfo2[avgping]."',
+ frags = '$r_truepinfo2[frags]',
+ deaths = '$r_truepinfo2[deaths]',
+ kills = '$r_truepinfo2[kills]',
+ suicides = '$r_truepinfo2[suicides]',
+ teamkills = '$r_truepinfo2[teamkills]',
+ eff = '$r_truepinfo2[eff]',
+ accuracy = '$r_truepinfo2[accuracy]',
+ ttl = '$r_truepinfo2[ttl]',
+ flag_taken = '$r_truepinfo2[flag_taken]',
+ flag_dropped = '$r_truepinfo2[flag_dropped]',
+ flag_return = '$r_truepinfo2[flag_return]',
+ flag_capture = '$r_truepinfo2[flag_capture]',
+ flag_cover = '$r_truepinfo2[flag_cover]',
+ flag_seal = '$r_truepinfo2[flag_seal]',
+ flag_assist = '$r_truepinfo2[flag_assist]',
+ flag_kill = '$r_truepinfo2[flag_kill]',
+ flag_pickedup = '$r_truepinfo2[flag_pickedup]',
+ dom_cp = '$r_truepinfo2[dom_cp]',
+ ass_obj = '$r_truepinfo2[ass_obj]',
+ spree_double = '$r_truepinfo2[spree_double]',
+ spree_triple = '$r_truepinfo2[spree_triple]',
+ spree_multi = '$r_truepinfo2[spree_multi]',
+ spree_mega = '$r_truepinfo2[spree_mega]',
+ spree_ultra = '$r_truepinfo2[spree_ultra]',
+ spree_monster = '$r_truepinfo2[spree_monster]',
+ spree_kill = '$r_truepinfo2[spree_kill]',
+ spree_rampage = '$r_truepinfo2[spree_rampage]',
+ spree_dom = '$r_truepinfo2[spree_dom]',
+ spree_uns = '$r_truepinfo2[spree_uns]',
+ spree_god = '$r_truepinfo2[spree_god]',
+ pu_pads = '$r_truepinfo2[pu_pads]',
+ pu_armour = '$r_truepinfo2[pu_armour]',
+ pu_keg = '$r_truepinfo2[pu_keg]',
+ pu_invis = '$r_truepinfo2[pu_invis]',
+ pu_belt = '$r_truepinfo2[pu_belt]',
+ pu_amp = '$r_truepinfo2[pu_amp]',
+ rank = '$r_truepinfo2[rank]';";
+ mysql_query($upd_precord) or die(mysql_error());
+ $cleaned = true;
+ }
+}
+if ($cleaned and $html) echo "<br />";
+?> \ No newline at end of file
diff --git a/html/import/import_playerstuff.php b/html/import/import_playerstuff.php
new file mode 100755
index 0000000..73714e4
--- /dev/null
+++ b/html/import/import_playerstuff.php
@@ -0,0 +1,182 @@
+<?php
+ include_once("includes/geoip.inc");
+ $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
+
+ // Get the unique ID of this player.
+ // Create a new one if he has none yet.
+ $r_pid = small_query("SELECT id, country, banned FROM uts_pinfo WHERE name = '$playername'");
+ if ($r_pid) {
+ $pid = $r_pid['id'];
+ $pid_country = $r_pid['country'];
+ $playerbanned = ($r_pid['banned'] == 'Y') ? true : false;
+ } else {
+ mysql_query("INSERT INTO uts_pinfo SET name = '$playername'") or die(mysql_error());
+ $pid = mysql_insert_id();
+ $pid_country = false;
+ $playerbanned = false;
+ }
+ $playerid2pid[$playerid] = $pid;
+
+ // Do we import banned players?
+ if ($playerbanned and $import_ban_type == 2) return;
+
+
+ // Did the player do first blood?
+ IF($playerid == $firstblood) {
+ $upd_firstblood = "UPDATE uts_match SET firstblood = '$pid' WHERE id = $matchid";
+ mysql_query($upd_firstblood) or die(mysql_error());
+ }
+
+ // Get player's IP
+ $q_playerip = small_query("SELECT INET_ATON(col4) AS ip FROM uts_temp_$uid WHERE col1 = 'player' AND col2 = 'IP' and col3 = '$playerid' ORDER BY id ASC LIMIT 0,1");
+ $playerip = ($q_playerip) ? $q_playerip['ip'] : 0;
+ if (empty($playerip)) $playerip = 0;
+
+ // Map the IP to a country
+ $playercountry = strtolower(geoip_country_code_by_addr($gi,long2ip($playerip)));
+
+ if ($playercountry != $pid_country)
+ {
+ mysql_query("UPDATE uts_pinfo SET country = '$playercountry' WHERE id = '$pid'") or die(mysql_error());
+ }
+
+
+ // Get Sprees
+ $q_spree_dbl = small_count("SELECT id FROM uts_temp_$uid WHERE col1 = 'spree' AND col2 = 'spree_dbl' AND col3 = '$playerid'");
+ $q_spree_mult = small_count("SELECT id FROM uts_temp_$uid WHERE col1 = 'spree' AND col2 = 'spree_mult' AND col3 = '$playerid'");
+ $q_spree_ult = small_count("SELECT id FROM uts_temp_$uid WHERE col1 = 'spree' AND col2 = 'spree_ult' AND col3 = '$playerid'");
+ $q_spree_mon = small_count("SELECT id FROM uts_temp_$uid WHERE col1 = 'spree' AND col2 = 'spree_mon' AND col3 = '$playerid'");
+
+ $q_spree_kill = small_count("SELECT id FROM uts_temp_$uid WHERE col1 = 'spree' AND col2 = 'spree_kill' AND col3 = '$playerid'");
+ $q_spree_rampage = small_count("SELECT id FROM uts_temp_$uid WHERE col1 = 'spree' AND col2 = 'spree_rampage' AND col3 = '$playerid'");
+ $q_spree_dom = small_count("SELECT id FROM uts_temp_$uid WHERE col1 = 'spree' AND col2 = 'spree_dom' AND col3 = '$playerid'");
+ $q_spree_uns = small_count("SELECT id FROM uts_temp_$uid WHERE col1 = 'spree' AND col2 = 'spree_uns' AND col3 = '$playerid'");
+ $q_spree_god = small_count("SELECT id FROM uts_temp_$uid WHERE col1 = 'spree' AND col2 = 'spree_god' AND col3 = '$playerid'");
+
+
+ // Get Count of Pickups
+ $sql_player7 = "SELECT col2, COUNT(col2) AS pu_count FROM uts_temp_$uid WHERE col1 = 'item_get' AND col3 = $playerid GROUP BY col2";
+ $q_player7 = mysql_query($sql_player7);
+
+ $pu_pads = 0;
+ $pu_armour = 0;
+ $pu_keg = 0;
+ $pu_belt = 0;
+ $pu_amp = 0;
+ $pu_invis = 0;
+
+ while ($r_player7 = mysql_fetch_array($q_player7)) {
+ // Cycle through pickups and see what the player got
+ IF ($r_player7[col2] == "Thigh Pads") { $pu_pads = $r_player7[pu_count]; }
+ IF ($r_player7[col2] == "Body Armor") { $pu_armour = $r_player7[pu_count]; }
+ IF ($r_player7[col2] == "Super Health Pack") { $pu_keg = $r_player7[pu_count]; }
+ IF ($r_player7[col2] == "ShieldBelt") { $pu_belt = $r_player7[pu_count]; }
+ IF ($r_player7[col2] == "Damage Amplifier") { $pu_amp = $r_player7[pu_count]; }
+ IF ($r_player7[col2] == "Invisibility") { $pu_invis = $r_player7[pu_count]; }
+ }
+
+ // Get ping information
+ $r_player9 = small_query("SELECT MIN(col4 * 1) AS lowping, MAX(col4 * 1) AS highping, AVG(col4 * 1) AS avgping FROM uts_temp_$uid WHERE col1 = 'Player' AND col2 = 'Ping' AND col3 = $playerid AND col4 > 0");
+ $lowping = $r_player9[lowping];
+ $highping = $r_player9[highping];
+ $avgping = (int)$r_player9[avgping];
+
+ // People who join at the end error the import, this stops it
+ IF ($lowping == NULL) { $lowping = 0; }
+ IF ($highping == NULL) { $highping = 0; }
+ IF ($avgping == NULL) { $avgping = 0; }
+
+ // Get accuracy, ttl etc
+ $r_acc = 0;
+ $r_deaths = 0;
+ $r_efficiency = 0;
+ $r_frags = 0;
+ $r_kills = 0;
+ $r_teamkills = 0;
+ $r_suicides = 0;
+ $r_tos = 0;
+ $r_ttl = 0;
+
+ $q_acc = small_query("SELECT col4 FROM uts_temp_$uid WHERE col1 = 'stat_player' AND col2 = 'accuracy' AND col3 = $playerid");
+ $q_deaths = small_query("SELECT col4 FROM uts_temp_$uid WHERE col1 = 'stat_player' AND col2 = 'deaths' AND col3 = $playerid");
+ $q_kills = small_query("SELECT col4 FROM uts_temp_$uid WHERE col1 = 'stat_player' AND col2 = 'kills' AND col3 = $playerid");
+ $q_teamkills = small_query("SELECT col4 FROM uts_temp_$uid WHERE col1 = 'stat_player' AND col2 = 'teamkills' AND col3 = $playerid");
+ $q_efficiency = small_query("SELECT col4 FROM uts_temp_$uid WHERE col1 = 'stat_player' AND col2 = 'efficiency' AND col3 = $playerid");
+ $q_suicides = small_query("SELECT col4 FROM uts_temp_$uid WHERE col1 = 'stat_player' AND col2 = 'suicides' AND col3 = $playerid");
+ $q_tos = small_query("SELECT col4 FROM uts_temp_$uid WHERE col1 = 'stat_player' AND col2 = 'time_on_server' AND col3 = $playerid");
+ $q_ttl = small_query("SELECT col4 FROM uts_temp_$uid WHERE col1 = 'stat_player' AND col2 = 'ttl' AND col3 = $playerid");
+ $q_score = small_query("SELECT col4 FROM uts_temp_$uid WHERE col1 = 'stat_player' AND col2 = 'score' AND col3 = $playerid");
+
+ IF ($teamgame == "True") {
+ $r_kills = $q_kills[col4];
+ $r_teamkills = $q_teamkills[col4];
+ }
+ IF ($teamgame == "False") {
+ $r_kills = $q_kills[col4] + $q_teamkills[col4];
+ $r_teamkills = 0;
+ }
+
+ $r_acc = get_dp($q_acc[col4]);
+ $r_efficiency = get_dp($q_efficiency[col4]);
+ $r_deaths = $q_deaths[col4];
+ $r_suicides = $q_suicides[col4];
+ $r_frags = $r_kills-$r_suicides-$r_teamkills;
+
+ $r_tos = get_dp($q_tos[col4]);
+ // time on server can't be longer then the server game time!
+ if ($r_tos > $servergametime) {
+ $r_tos = get_dp($servergametime);
+ }
+ $r_ttl = get_dp($q_ttl[col4]);
+ $r_score = $q_score[col4];
+
+ // Generate player record
+ $sql_playerid = " INSERT
+ INTO uts_player
+ SET matchid = '$matchid',
+ playerid = '$playerid',
+ pid = '$pid',
+ team = '$playerteam',
+ gid = '$gid',
+ insta = '$gameinsta',
+ country = '$playercountry',
+ ip = '$playerip',
+
+
+ spree_double = '$q_spree_dbl',
+ spree_multi = '$q_spree_mult',
+ spree_ultra = '$q_spree_ult',
+ spree_monster = '$q_spree_mon',
+ spree_kill = '$q_spree_kill',
+ spree_rampage = '$q_spree_rampage',
+ spree_dom = '$q_spree_dom',
+ spree_uns = '$q_spree_uns',
+ spree_god = '$q_spree_god',
+
+ pu_pads = '$pu_pads',
+ pu_armour = '$pu_armour',
+ pu_keg = '$pu_keg',
+ pu_belt = '$pu_belt',
+ pu_amp = '$pu_amp',
+ pu_invis = '$pu_invis',
+
+ lowping = '$lowping',
+ highping = '$highping',
+ avgping = '$avgping',
+
+ accuracy = '$r_acc',
+ frags = '$r_frags',
+ deaths = '$r_deaths',
+ kills = '$r_kills',
+ suicides = '$r_suicides',
+ teamkills = '$r_teamkills',
+ eff = '$r_efficiency',
+ gametime = '$r_tos',
+ ttl = '$r_ttl',
+ gamescore= '$r_score'";
+
+ $q_playerid = mysql_query($sql_playerid) or die(mysql_error());
+ $playerecordid = mysql_insert_id();
+
+
+?>
diff --git a/html/import/import_ranking.php b/html/import/import_ranking.php
new file mode 100755
index 0000000..9ad18a2
--- /dev/null
+++ b/html/import/import_ranking.php
@@ -0,0 +1,127 @@
+<?php
+ if ($playerbanned) return;
+// Get sums of different events
+
+ // Work out all possible ranking scores
+ $r_cnt = small_query("SELECT
+ SUM(frags*0.5) AS frags, SUM(deaths*0.25) AS deaths, SUM(suicides*0.25) AS suicides, SUM(teamkills*2) AS teamkills,
+ SUM(flag_taken*1) AS flag_taken, SUM(flag_pickedup*1) AS flag_pickedup, SUM(flag_return*1) AS flag_return, SUM(flag_capture*10) AS flag_capture, SUM(flag_cover*3) AS flag_cover,
+ SUM(flag_seal*2) AS flag_seal, SUM(flag_assist*5) AS flag_assist, SUM(flag_kill*2) AS flag_kill,
+ SUM(dom_cp*10) AS dom_cp, SUM(ass_obj*10) AS ass_obj,
+ SUM(spree_double*1) AS spree_double, SUM(spree_multi*1) AS spree_multi, SUM(spree_ultra*1) AS spree_ultra, SUM(spree_monster*2) AS spree_monster,
+ SUM(spree_kill*1) AS spree_kill, SUM(spree_rampage*1) AS spree_rampage, SUM(spree_dom*1.5) AS spree_dom, SUM(spree_uns*2) AS spree_uns, SUM(spree_god*3) AS spree_god,
+ SUM(gametime) AS gametime
+ FROM uts_player WHERE pid = $pid and gid = $gid and matchid <= $matchid");
+
+ // Work out per game ranking amounts
+ $rank_ctf = $r_cnt[flag_taken]+$r_cnt[flag_pickedup]+$r_cnt[flag_return]+$r_cnt[flag_capture]+$r_cnt[flag_cover]+$r_cnt[flag_seal]+$r_cnt[flag_assist]+$r_cnt[flag_kill];
+ $rank_ass = $r_cnt[ass_obj];
+ $rank_dom = $r_cnt[com_cp];
+ $rank_jb = $r_cnt[ass_obj] * 0.15;
+ $rank_bt = $r_cnt[flag_capture];
+ $rank_fpos = $r_cnt[frags]+$r_cnt[spree_double]+$r_cnt[spree_multi]+$r_cnt[spree_ultra]+$r_cnt[spree_monster]+$r_cnt[spree_kill]+$r_cnt[spree_rampage]+$r_cnt[spree_dom]+$r_cnt[spree_uns]+$r_cnt[spree_god];
+ $rank_fneg = $r_cnt[deaths]+$r_cnt[suicides]+$r_cnt[teamkills];
+ $r_gametime = ceil($r_cnt[gametime]/60);
+
+
+ // Select rank record
+ $r_rankp = small_query("SELECT id, time, rank, matches FROM uts_rank WHERE pid = '$pid' AND gid = '$gid'");
+ $rank_id = $r_rankp[id];
+ $rank_gametime = $r_rankp[time];
+ $rank_crank = $r_rankp[rank];
+ $rank_matches = $r_rankp[matches];
+
+ // Work out initial rank dependant on game, if no game known use DM ranking
+ IF ($gamename == "Assault" || $gamename == "Assault (insta)") {
+ $rank_nrank = $rank_ass+$rank_fpos-$rank_fneg;
+ } elseIF ($gamename == "Capture the Flag" || $gamename == "Capture the Flag (insta)") {
+ $rank_nrank = $rank_ctf+$rank_fpos-$rank_fneg;
+ } elseIF ($gamename == "Domination" || $gamename == "Domination (insta)") {
+ $rank_nrank = $rank_dom+$rank_fpos-$rank_fneg;
+ } elseIF ($gamename == "JailBreak" || $gamename == "JailBreak (insta)") {
+ $rank_nrank = $rank_jb+$rank_fpos-$rank_fneg;
+ } elseIF ($gamename == "Bunny Track") {
+ // The complain about the old system which was based on captures/time only was that noobs
+ // would vote easy maps only and therefore get many caps/hour. This mean much points for the
+ // noobs and fewer for the good players. The new ranking would be based on the fastest captime.
+ $rank_bt = 0;
+ $sql_btmaprank = "SELECT e.col2 AS no, COUNT(e.col2) AS count FROM uts_events AS e, uts_player AS p WHERE p.pid = $pid AND p.gid = $gid AND p.playerid = e.playerid AND e.matchid = p.matchid AND e.matchid <= $matchid AND e.col2 > 0 AND e.col2 <= 5 GROUP BY e.col2";
+ $q_btmaprank = mysql_query($sql_btmaprank) or die ("Can't retrieve \$q_btmaprank: ". mysql_error());
+ while($r_btmaprank = mysql_fetch_assoc($q_btmaprank)) {
+ IF ($r_btmaprank[no] == 1) {
+ $rank_bt += $r_btmaprank[count] * 10;
+ } elseIF ($r_btmaprank[no] == 2) {
+ $rank_bt += $r_btmaprank[count] * 8;
+ } elseIF ($r_btmaprank[no] == 3) {
+ $rank_bt += $r_btmaprank[count] * 6;
+ } elseIF ($r_btmaprank[no] == 4) {
+ $rank_bt += $r_btmaprank[count] * 4;
+ } elseIF ($r_btmaprank[no] == 5) {
+ $rank_bt += $r_btmaprank[count] * 2;
+ }
+ // if ($dbg) echo "| pid: $r_btmaprank[no]*$r_btmaprank[count] => $rank_bt<br>";
+ }
+
+ $rank_nrank = $rank_bt;
+ } else {
+ $rank_nrank = $rank_fpos-$rank_fneg;
+ }
+
+ // Average the rank over game minutes
+ if ($r_gametime == 0) {
+ // some bug occured, ignore
+ if ($dbg) echo "Skip ranking. " ;
+
+ return;
+ }
+
+ $rank_nrank = ($rank_nrank/$r_gametime) * 600;
+ if ($dbg) echo "Points: $rank_nrank<br>Time: $r_gametime<br>";
+
+ // Add rank gametime to previous amount
+ $rank_gametime = $r_gametime;
+
+ // Reduce ranking if player hasnt played that much
+ IF ($rank_gametime < 10) return;
+
+ IF ($rank_gametime < 50) {
+ $rank_nrank = $rank_nrank*.25;
+ }
+
+ IF ($rank_gametime >= 50 && $rank_gametime < 100) {
+ $rank_nrank = $rank_nrank*.50;
+ }
+
+ IF ($rank_gametime >= 100 && $rank_gametime < 200) {
+ $rank_nrank = $rank_nrank*.70;
+ }
+
+ IF ($rank_gametime >= 200 && $rank_gametime < 300) {
+ $rank_nrank = $rank_nrank*.85;
+ }
+
+ if ($dbg) echo "Reduced: $rank_nrank<br>";
+
+ // Add new rank record if one does not exist
+ IF($rank_id == NULL) {
+ mysql_query("INSERT INTO uts_rank SET time = '$r_gametime', pid = '$pid', gid = '$gid', rank = '0', matches = '0';") or die(mysql_error());
+ $rank_id = mysql_insert_id();
+ $rank_gametime = 0;
+ $rank_crank = 0;
+ $rank_matches = 0;
+ }
+
+ // Add number of matches played
+ $rank_matches = $rank_matches+1;
+
+ // Work out effective rank given
+ $eff_rank = $rank_nrank-$rank_crank;
+
+ // if ($dbg) echo "", intval($rank_crank), "-", intval($rank_nrank). "-", $rank_matches, " ";
+
+ // Add effective rank points given to uts_player record
+ mysql_query("UPDATE uts_player SET rank = $eff_rank WHERE id = $playerecordid") or die(mysql_error());
+
+ // Update the rank
+ mysql_query("UPDATE uts_rank SET time = '$rank_gametime', rank = '$rank_nrank', prevrank = '$rank_crank', matches = '$rank_matches' WHERE id = $rank_id;") or die(mysql_error());
+?>
diff --git a/html/import/import_tdm.php b/html/import/import_tdm.php
new file mode 100755
index 0000000..6595072
--- /dev/null
+++ b/html/import/import_tdm.php
@@ -0,0 +1,2 @@
+<?php
+?>
diff --git a/html/import/import_weapons.php b/html/import/import_weapons.php
new file mode 100755
index 0000000..5d59a3f
--- /dev/null
+++ b/html/import/import_weapons.php
@@ -0,0 +1,209 @@
+<?php
+
+// Read all available weapons, we'll need them later
+if (!isset($weaponnames)) {
+ $sql_weaponnames = "SELECT id, name FROM uts_weapons";
+ $q_weaponnames = mysql_query($sql_weaponnames);
+ while ($r_weaponnames = mysql_fetch_array($q_weaponnames)) {
+ $weaponnames[$r_weaponnames['name']] = $r_weaponnames['id'];
+ }
+}
+
+
+// Get all kills by weapon
+$sql_weapons = " SELECT col2 AS player,
+ col3 AS weaponname,
+ COUNT(*) AS kills
+ FROM uts_temp_$uid
+ WHERE col1 = 'kill'
+ OR col1 = 'teamkill'
+ GROUP BY weaponname, player";
+
+$q_weapons = mysql_query($sql_weapons) or die(mysql_error());
+$weapons = array();
+while ($r_weapons = mysql_fetch_array($q_weapons)) {
+
+ // Get the wepon's id or assign a new one
+ if (empty($r_weapons['weaponname'])) continue;
+ if (isset($weaponnames[$r_weapons['weaponname']])) {
+ $weaponid = $weaponnames[$r_weapons['weaponname']];
+ } else {
+ mysql_query("INSERT INTO uts_weapons SET name = '". addslashes($r_weapons['weaponname']) ."'") or die(mysql_error());
+ $weaponid = mysql_insert_id();
+ $weaponnames[$r_weapons['weaponname']] = $weaponid;
+ }
+
+ // Get the unique pid of this player
+ if (!isset($playerid2pid[$r_weapons['player']])) {
+ continue;
+ } else {
+ $pid = $playerid2pid[$r_weapons['player']];
+ }
+
+ $weapons[$pid][$weaponid] = array(
+ 'weap_kills' => $r_weapons['kills'],
+ 'weap_shotcount' => 0,
+ 'weap_hitcount' => 0,
+ 'weap_damagegiven' => 0,
+ 'weap_accuracy' => 0
+ );
+
+
+}
+
+
+// Get the weapon statistics
+$sql_weapons = " SELECT col1 AS type,
+ col2 AS weaponname,
+ col3 AS player,
+ col4 AS value
+ FROM uts_temp_$uid
+ WHERE col1 LIKE 'weap_%'";
+
+$q_weapons = mysql_query($sql_weapons) or die(mysql_error());
+while ($r_weapons = mysql_fetch_array($q_weapons)) {
+ // Get the wepon's id or assign a new one
+ if (empty($r_weapons['weaponname'])) continue;
+ if (isset($weaponnames[$r_weapons['weaponname']])) {
+ $weaponid = $weaponnames[$r_weapons['weaponname']];
+ } else {
+ mysql_query("INSERT INTO uts_weapons SET name = '". addslashes($r_weapons['weaponname']) ."'") or die(mysql_error());
+ $weaponid = mysql_insert_id();
+ $weaponnames[$r_weapons['weaponname']] = $weaponid;
+ }
+
+ // Get the unique pid of this player
+ if (!isset($playerid2pid[$r_weapons['player']])) {
+// Happens if we're ignoring bots or banned players
+ continue;
+ } else {
+ $pid = $playerid2pid[$r_weapons['player']];
+ }
+
+ if (!isset($weapons[$pid][$weaponid]['weap_kills'])) {
+ $weapons[$pid][$weaponid] = array(
+ 'weap_kills' => 0,
+ 'weap_shotcount' => 0,
+ 'weap_hitcount' => 0,
+ 'weap_damagegiven' => 0,
+ 'weap_accuracy' => 0
+ );
+ }
+
+ $weapons[$pid][$weaponid][$r_weapons['type']] = $r_weapons['value'];
+}
+
+
+// Finally write the weapon statistics for this match
+$s_weapons = array();
+foreach($weapons as $playerid => $weapon) {
+ foreach($weapon as $weaponid => $infos) {
+ if ($infos['weap_kills'] == 0 and $infos['weap_shotcount'] == 0) continue;
+ mysql_query(" INSERT
+ INTO uts_weaponstats
+ SET matchid = '$matchid',
+ pid = '$playerid',
+ weapon = '$weaponid',
+ kills = '${infos['weap_kills']}',
+ shots = '${infos['weap_shotcount']}',
+ hits= '${infos['weap_hitcount']}',
+ damage = '${infos['weap_damagegiven']}',
+ acc = '". round($infos['weap_accuracy'], 2) ."';") or die(mysql_error());
+
+ // Summarize totals for this match
+ if (!isset($s_weapons[$weaponid]['weap_kills'])) {
+ $s_weapons[$weaponid]['weap_kills'] = $infos['weap_kills'];
+ $s_weapons[$weaponid]['weap_shotcount'] = $infos['weap_shotcount'];
+ $s_weapons[$weaponid]['weap_hitcount'] = $infos['weap_hitcount'];
+ $s_weapons[$weaponid]['weap_damagegiven'] = $infos['weap_damagegiven'];
+ $s_weapons[$weaponid]['weap_accuracy'] = $infos['weap_accuracy'];
+ } else {
+ $s_weapons[$weaponid]['weap_kills'] += $infos['weap_kills'];
+ $s_weapons[$weaponid]['weap_shotcount'] += $infos['weap_shotcount'];
+ $s_weapons[$weaponid]['weap_hitcount'] += $infos['weap_hitcount'];
+ $s_weapons[$weaponid]['weap_damagegiven'] += $infos['weap_damagegiven'];
+ $s_weapons[$weaponid]['weap_accuracy'] = ($s_weapons[$weaponid]['weap_accuracy'] + $infos['weap_accuracy']) / 2;
+ }
+ }
+}
+
+
+// Update the player's weapon statistics (matchid 0);
+foreach($weapons as $playerid => $weapon) {
+ foreach($weapon as $weaponid => $infos) {
+ if ($infos['weap_kills'] == 0 and $infos['weap_shotcount'] == 0) continue;
+ // Check whether a record for this player and weapon already
+ // exists
+ $r_pstat = small_query(" SELECT pid
+ FROM uts_weaponstats
+ WHERE matchid = '0'
+ AND pid = '$playerid'
+ AND weapon = '$weaponid'");
+ // No -> create
+ if (!$r_pstat) {
+ mysql_query(" INSERT
+ INTO uts_weaponstats
+ SET matchid = '0',
+ pid = '$playerid',
+ weapon = '$weaponid',
+ kills = '${infos['weap_kills']}',
+ shots = '${infos['weap_shotcount']}',
+ hits= '${infos['weap_hitcount']}',
+ damage = '${infos['weap_damagegiven']}',
+ acc = '". round($infos['weap_accuracy'], 2) ."';") or die(mysql_error());
+ // Yes -> update
+ } else {
+ mysql_query(" UPDATE uts_weaponstats
+ SET weapon = '$weaponid',
+ kills = kills + '${infos['weap_kills']}',
+ shots = shots + '${infos['weap_shotcount']}',
+ hits = hits + '${infos['weap_hitcount']}',
+ damage = damage + '${infos['weap_damagegiven']}',
+ acc = (acc + '". round($infos['weap_accuracy'], 2) ."') / 2
+ WHERE matchid = '0'
+ AND pid = '$playerid'
+ AND weapon = '$weaponid';") or die(mysql_error());
+ }
+ }
+}
+
+// Update the global weapon statistics (matchid 0, playerid 0 );
+foreach($s_weapons as $weaponid => $infos) {
+ if ($infos['weap_kills'] == 0 and $infos['weap_shotcount'] == 0) continue;
+ // Check whether the global record for this weapon already exists
+ $r_pstat = small_query(" SELECT pid
+ FROM uts_weaponstats
+ WHERE matchid = '0'
+ AND pid = '0'
+ AND weapon = '$weaponid'");
+ // No -> create
+ if (!$r_pstat) {
+ mysql_query(" INSERT
+ INTO uts_weaponstats
+ SET matchid = '0',
+ pid = '0',
+ weapon = '$weaponid',
+ kills = '${infos['weap_kills']}',
+ shots = '${infos['weap_shotcount']}',
+ hits= '${infos['weap_hitcount']}',
+ damage = '${infos['weap_damagegiven']}',
+ acc = '". round($infos['weap_accuracy'], 2) ."';") or die(mysql_error());
+ // Yes -> update
+ } else {
+ mysql_query(" UPDATE uts_weaponstats
+ SET weapon = '$weaponid',
+ kills = kills + '${infos['weap_kills']}',
+ shots = shots + '${infos['weap_shotcount']}',
+ hits = hits + '${infos['weap_hitcount']}',
+ damage = damage + '${infos['weap_damagegiven']}',
+ acc = (acc + '". round($infos['weap_accuracy'], 2) ."') / 2
+ WHERE matchid = '0'
+ AND pid = '0'
+ AND weapon = '$weaponid';") or die(mysql_error());
+ }
+}
+
+
+
+
+?> \ No newline at end of file
diff --git a/html/import/index.htm b/html/import/index.htm
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/html/import/index.htm