Start Conversion


Click here to start the conversion from !


Attention: Tables vwar , vwar_opponents, vwar_scores, vwar_screen will be deleted!


 Error


Please copy to !


query("DELETE FROM vwar".$n.""); $vwardb->query("DELETE FROM vwar".$n."_opponents"); $vwardb->query("DELETE FROM vwar".$n."_scores"); $vwardb->query("DELETE FROM vwar".$n."_screen"); $oppnames[] = ""; $fp = fopen($vwar_root . "convert/" . SOURCE_STORAGEFILE, "r"); while (!FEOF($fp)) { $warstring[] = fgets ($fp, 9192); } for ($i = 0; $i < count($warstring); $i++) { $details = split("\|\|", $warstring[$i]); $warid = $details[0]; if ($warid > 0) { // get gametypeid and if not exists gametype already then create it $result = $vwardb->query_first("SELECT gametypeid FROM vwar".$n."_gametype WHERE gametypename = '$details[14]'"); $gametypeid = $result['gametypeid']; $vwardb->free_result($result); if (!$gametypeid) { $result = $vwardb->query_first("SELECT COUNT(gametypeid) AS numgametypes FROM vwar".$n."_gametype WHERE gametypename = '$details[14]'"); $num = $result['numgametypes']; $vwardb->free_result($result); if ($num == 0) { $vwardb->query("INSERT INTO vwar".$n."_gametype (gametypename) VALUES ('$details[14]')"); $gametypeid = $vwardb->insert_id(); } } // get matchtypeid and if not exists matchtype already then create it $result = $vwardb->query_first("SELECT matchtypeid FROM vwar".$n."_matchtype WHERE matchtypename = '$details[12]'"); $matchtypeid = $result['matchtypeid']; $vwardb->free_result($result); if (!$matchtypeid) { $result = $vwardb->query_first("SELECT COUNT(matchtypeid) AS nummatchtypes FROM vwar".$n."_matchtype WHERE matchtypename = '$details[12]'"); $num = $result['nummatchtypes']; $vwardb->free_result($result); if ($num == 0) { $vwardb->query("INSERT INTO vwar".$n."_matchtype (matchtypename) VALUES ('$details[12]')"); $matchtypeid = $vwardb->insert_id(); } } // get details out of the array $report = str_replace("
","\n", $details[13]); $wardate = mktime( 0, 0, 0, $details[3], $details[4], $details[2]); $oppnameshort = $details[7]; $oppname = $details[6]; $opphomepage = $details[8]; $ownplayers = $details[9]; $opplayers = $details[10]; if (in_array($oppname, $oppnames) == false) { $vwardb->query(" INSERT INTO vwar".$n."_opponents VALUES ( NULL, '".addslashes($oppnameshort)."', '".addslashes($oppname)."', '', '', '', '', '', '', '', '', '".$opphomepage."', '', '0') "); } $result = $vwardb->query_first("SELECT oppid FROM vwar".$n."_opponents WHERE oppname = '".addslashes($oppname)."'"); $oppid = $result['oppid']; $vwardb->free_result($result); $vwardb->query("UPDATE vwar".$n." SET oppid='".$oppid."' WHERE warid = '$warid'"); $oppnames[] = $oppname; $vwardb->query(" INSERT INTO vwar".$n." (warid,gameid,gametypeid,matchtypeid,oppid,ownplayers,opplayers,report,status,dateline ) VALUES ( '$warid', '', '$gametypeid', '$matchtypeid', '$oppid', '".addslashes($ownplayers)."', '".addslashes($opplayers)."', '".addslashes($report)."', '1', '$wardate') "); $locations = $details[11]; $locations = split(";;;",$locations); for ($x = 0; $x < count($locations); $x++) { $scorearray = split(";;", $locations[$x]); $result = $vwardb->query_first("SELECT locationid FROM vwar".$n."_locations WHERE locationname = '$scorearray[0]'"); $locationid = $result['locationid']; $vwardb->free_result($result); if(!$locationid) { $result = $vwardb->query_first("SELECT COUNT(locationid) AS numlocations FROM vwar".$n."_locations WHERE locationname = '$scorearray[0]'"); $num = $result['numlocations']; $vwardb->free_result($result); if ($num == 0) { $vwardb->query("INSERT INTO vwar".$n."_locations (locationname,gameid) VALUES ('$scorearray[0]','1')"); $locationid = $vwardb->insert_id(); } } $oldfile = $vwar_root . "/images/screen/" . $warid . $scorearray[0] . $scorearray[3] . ".jpg"; if (@file_exists($oldfile)) { $vwardb->query(" INSERT INTO vwar".$n."_screen (locationid,warid,filename) VALUES ('$locationid','$warid','".$warid.$scorearray[0].$scorearray[3]."') "); $screenid = $vwardb->insert_id(); $vwardb->query(" INSERT INTO vwar".$n."_scores (warid,screenid,locationid,ownscore,oppscore) VALUES ('$warid','$screenid','$locationid','$scorearray[1]','$scorearray[2]') "); $scoreid = $vwardb->insert_id(); $new_filename = $warid . "-" . $locationid . "_" . $scoreid . ".jpg"; $vwardb->query(" UPDATE vwar".$n."_screen SET filename = '$new_filename', scoreid = '".$scoreid."' WHERE screenid = '".$screenid."' "); } else { $vwardb->query(" INSERT INTO vwar".$n."_scores (warid, locationid, ownscore, oppscore) VALUES ('$warid', '$locationid', '$scorearray[1]', '$scorearray[2]') "); } } } } // close file pointer fclose($fp); // the right gameid's will be set here ! // function is experimental, but worked fine so far $games_arr = array( "UT" => "Unreal Tournament", "CS" => "Counterstrike", "Q3" => "Quake 3" ); while (list($game_short, $game_long) = each($games_arr)) { $result = $vwardb->query_first("SELECT gameid, gameicon FROM vwar".$n."_games WHERE gamename = '".$game_long."'"); if ($result['gameid']) { $gameid[$game_short] = $result['gameid']; } else { $vwardb->query("INSERT INTO vwar".$n."_games (gameid, gamename, gamenameshort, gameicon, deleted) VALUES ( '', '".$game_long."', '".$game_short."', '', '0') "); $gameid[$game_short] = $vwardb->insert_id(); } if(@file_exists($vwar_root . "images/gameicons/" . $gameicon) && $result['gameicon'] == "") { $gameicon = strtolower($game_short) . ".gif"; $vwardb->query("UPDATE vwar".$n."_games SET gameicon = '$gameicon' WHERE gameid = '".$gameid[$game_short]."'"); } } $result = $vwardb->query("SELECT warid FROM vwar".$n.""); while ($row = $vwardb->fetch_array($result)) { $result2 = $vwardb->query(" SELECT locationname FROM vwar".$n."_locations, vwar".$n."_scores WHERE vwar".$n."_scores.locationid = vwar".$n."_locations.locationid AND vwar".$n."_scores.warid = $row[warid] "); while ($location = $vwardb->fetch_array($result2)) { // check for Q3 if (stristr($location['locationname'], "q3") || stristr($location['locationname'], "cpm") || stristr($location['locationname'], "ra3")) { $vwardb->query(" UPDATE vwar".$n."_locations SET gameid = '".$gameid['Q3']."' WHERE locationname = '".$location['locationname']."' AND NOT gameid = '".$gameid['Q3']."' "); $vwardb->query("UPDATE vwar".$n." SET gameid = '".$gameid['Q3']."' WHERE warid = '".$row['warid']."'"); } // check for CS if (stristr($location['locationname'], "cs_") || stristr($location['locationname'],"de_") || stristr($location['locationname'], "CS-")) { $vwardb->query(" UPDATE vwar".$n."_locations SET gameid = '".$gameid['CS']."' WHERE locationname = '".$location['locationname']."' AND NOT gameid = '".$gameid['CS']."' "); $vwardb->query("UPDATE vwar".$n." SET gameid = '".$gameid['CS']."' WHERE warid = '".$row['warid']."'"); } // check for UT if (stristr($location['locationname'], "dm-") || stristr($location['locationname'],"ctf-") || stristr($location['locationname'], "dom-") || stristr($location['locationname'], "as-")) { $vwardb->query(" UPDATE vwar".$n."_locations SET gameid = '".$gameid['UT']."' WHERE locationname = '".$location['locationname']."' AND NOT gameid = '".$gameid['UT']."' "); $vwardb->query("UPDATE vwar".$n." SET gameid = '".$gameid['UT']."' WHERE warid = '".$row['warid']."'"); } } } if ($vwarlanguage == "") { $vwarlanguage = "english"; } // update countrys include($vwar_root . "includes/language/" . $vwarlanguage . ".inc.php"); $result = $vwardb->query("SELECT oppid, opphomepage FROM vwar".$n."_opponents"); while ($row = $vwardb->fetch_array($result)) { $homepage = split("[.]",$row['opphomepage']); $homepage = split("[/]",$homepage[2]); $country = $homepage[0]; if (in_array($country, array_keys($country_array))) { $count++; $vwardb->query("UPDATE vwar".$n."_opponents SET oppcountry = '".$country."' WHERE oppid = '".$row['oppid']."'"); } } $vwardb->free_result($result); printHeader("Virtual War Conversion from ".SOURCE_SCRIPTNAME, 2); ?>
 End of conversion from


Conversion ended successfully!

Delete now!

Click here to go to your Virtual War!