0) { $line = mysql_fetch_object($res); $userid = $line->id; $allow_insert = $line->caninsert; $allowed_allyhistory = $line->allyhistory; $ogame_playerid = $line->ogame_playerid; if (isset($_POST['typ']) && $_POST['typ']=="stats" && isset($_POST['content']) && !empty($_POST['content']) && isset($_POST['who']) && is_numeric($_POST['who']) && isset($_POST['what']) && is_numeric($_POST['what']) && $allow_insert == "true" ) { echo "stats...\n"; // stats $statstext = stripslashes($_POST['content']); $who = (int)$_POST['who']; $what = (int)$_POST['what']; echo "test:\n".$_POST['content']."\n\n"; if ($who == 0) { echo "playerstats...\n"; // Playerstats $newarray = preg_split("/&\w+=/",$statstext); $stats_array['rank'] = explode("|",str_replace(".","",$newarray[1])); $stats_array['playername'] = explode("|",$newarray[2]); $stats_array['pID'] = explode("|",$newarray[3]); $stats_array['alliance'] = explode("|",$newarray[4]); $stats_array['points'] = explode("|",str_replace(".","",$newarray[5])); unset($newarray); // remove empty lines from the toolbar for($i=0; $i < count($stats_array['rank']); $i++) { if (empty($stats_array['rank'][$i])) { array_splice($stats_array['rank'], $i); array_splice($stats_array['playername'], $i); array_splice($stats_array['pID'], $i); array_splice($stats_array['alliance'], $i); array_splice($stats_array['points'], $i); break; } } if (count($stats_array['rank']) > 0) { // allybuffer $alliance_names_2_ids = array(); // determine all alliance IDs $query = "SELECT id, allyname FROM $allytable WHERE allyname IN ("; $run_query = false; foreach ($stats_array['alliance'] as $allyname) { $allyname = trim($allyname); if (!empty($allyname)) { $query .= "'".mysql_real_escape_string($allyname)."', "; $alliance_names_2_ids[strtolower($allyname)] = ""; $run_query = true; } } if ($run_query === true) { $query = substr($query,0,strlen($query)-2).")"; $res = mysql_query($query); if (!$res) { echo $query."\n".mysql_error()."\n"; $content = ob_get_clean(); return_result(622,$content); } while ($line = mysql_fetch_object($res)) { $alliance_names_2_ids[strtolower($line->allyname)] = $line->id; } } // determine all players which are in the database and have an ogame playerid $query = "SELECT id,playername,ogame_playerid FROM $playertable WHERE (ogame_playerid IS NOT NULL OR ogame_playerid != 0) AND ogame_playerid IN ("; for ($i=0; $i < count($stats_array['pID']); $i++) { if ($i < (count($stats_array['pID']) - 1)) { $query .= "'".mysql_real_escape_string($stats_array['pID'][$i])."',"; } else { $query .= "'".mysql_real_escape_string($stats_array['pID'][$i])."'"; } } $query .= ")"; echo $query." \n"; $res = mysql_query($query); echo mysql_num_rows($res)." Entries with ogame playerid found\n"; if (!$res) { echo $query."\n".mysql_error()."\n"; $content = ob_get_clean(); return_result(622,$content); } while ($line = mysql_fetch_object($res)) { echo "name: $line->playername id: $line->ogame_playerid \n"; $player_names_2_ids[strtolower($line->playername)]["id"] = $line->id; $player_names_2_ids[strtolower($line->playername)]["ogame_id"] = $line->ogame_playerid; } // determine the player itself as he might have no ogame playerid at stats (but possibly at the galaxytool) $query = "SELECT id,playername,ogame_playerid FROM $playertable WHERE playername IN ("; $j = 0; for ($i=0; $i < count($stats_array['playername']); $i++) { $stats_array['playername'][$i] = trim($stats_array['playername'][$i]); if ($stats_array['pID'][$i] == 0) { $query .= "'".mysql_real_escape_string($stats_array['playername'][$i])."',"; $j++; } } if ($j > 0) { // remove the , behind the last query part $query = substr($query,0,strlen($query)-1); $query .= ")"; echo $query." \n"; $res = mysql_query($query); echo mysql_num_rows($res)." Entries without ogame playerid found\n"; if (!$res) { echo $query."\n".mysql_error()."\n"; $content = ob_get_clean(); return_result(622,$content); } while ($line = mysql_fetch_object($res)) { $player_names_2_ids[strtolower($line->playername)]["id"] = $line->id; $player_names_2_ids[strtolower($line->playername)]["ogame_id"] = $line->ogame_playerid; } } $query_1 = false; $query_2 = false; switch ($what) { case 0: $query_collection = "INSERT LOW_PRIORITY INTO $playertable (id,user_id,rank,alliance_id,points,last_stats_update,playername,ogame_playerid) VALUES "; $query_collection2 = "INSERT LOW_PRIORITY INTO $playertable (id,user_id,rank,alliance_id,points,last_stats_update,playername) VALUES "; break; case 1: $query_collection = "INSERT LOW_PRIORITY INTO $playertable (id,user_id,frank,alliance_id,fpoints,last_stats_update,playername,ogame_playerid) VALUES "; $query_collection2 = "INSERT LOW_PRIORITY INTO $playertable (id,user_id,frank,alliance_id,fpoints,last_stats_update,playername) VALUES "; break; case 2: $query_collection = "INSERT LOW_PRIORITY INTO $playertable (id,user_id,rrank,alliance_id,rpoints,last_stats_update,playername,ogame_playerid) VALUES "; $query_collection2 = "INSERT LOW_PRIORITY INTO $playertable (id,user_id,rrank,alliance_id,rpoints,last_stats_update,playername) VALUES "; break; } echo "Eintraege: ".count($stats_array)." mit je ".count($stats_array['rank'])."\n"; for ($i=0; $i < count($stats_array['playername']); $i++) { // determine alliance ID $allyname = trim($stats_array['alliance'][$i]); if (empty($alliance_names_2_ids[strtolower($allyname)]) && !empty($allyname)) { // insert Alliance first $query = "INSERT LOW_PRIORITY INTO $allytable (allyname) VALUES ('".mysql_real_escape_string($allyname)."')"; $res = mysql_query($query,$mysqlcon); if (!$res) { echo $query."\n".mysql_error()."\n"; $content = ob_get_clean(); return_result(622,$content); } // set alliance ID $alliance_names_2_ids[strtolower($allyname)] = mysql_insert_id($mysqlcon); } elseif (trim($allyname) == "") { // Allyname is empty $alliance_names_2_ids[""] = 0; } if (empty($stats_array['pID'][$i]) && $ogame_playerid > 0) { $stats_array['pID'][$i] = $ogame_playerid; } // add query data (id,(x)rank,alliance_id,points,last_stats_update,playername,ogame_playerid) if (!empty($stats_array['pID'][$i])) { // ogame playerid known here if (isset($player_names_2_ids[strtolower($stats_array['playername'][$i])]["ogame_id"])) { // database contains that player with ogame playerid //echo "database contains that player with ogame playerid\n"; $query_2 = true; $query_collection2 .= " (".$player_names_2_ids[strtolower($stats_array['playername'][$i])]["id"].", $userid, '".mysql_real_escape_string($stats_array['rank'][$i])."','".mysql_real_escape_string($alliance_names_2_ids[strtolower($allyname)])."','".mysql_real_escape_string($stats_array['points'][$i])."',NOW(),'".mysql_real_escape_string($stats_array['playername'][$i])."'), "; } elseif (isset($player_names_2_ids[strtolower($stats_array['playername'][$i])]["id"])) { // player is included without ogame playerid //echo "player is included without ogame playerid\n"; $query_1 = true; $query_collection .= " (".$player_names_2_ids[strtolower($stats_array['playername'][$i])]["id"].",$userid,'".mysql_real_escape_string($stats_array['rank'][$i])."','".mysql_real_escape_string($alliance_names_2_ids[strtolower($allyname)])."','".mysql_real_escape_string($stats_array['points'][$i])."',NOW(),'".mysql_real_escape_string($stats_array['playername'][$i])."','".intval($stats_array['pID'][$i])."'), "; } else { // player new to database //echo "player new to database\n"; $query_1 = true; $query_collection .= " (NULL,$userid,'".mysql_real_escape_string($stats_array['rank'][$i])."','".mysql_real_escape_string($alliance_names_2_ids[strtolower($allyname)])."','".mysql_real_escape_string($stats_array['points'][$i])."',NOW(),'".mysql_real_escape_string($stats_array['playername'][$i])."','".intval($stats_array['pID'][$i])."'), "; } } else { // ogame playerid unknown (player itself) if (isset($player_names_2_ids[strtolower($stats_array['playername'][$i])]["id"])) { // player already at database //echo "player already at database\n"; $query_2 = true; $query_collection2 .= " (".$player_names_2_ids[strtolower($stats_array['playername'][$i])]["id"].",$userid, '".mysql_real_escape_string($stats_array['rank'][$i])."','".mysql_real_escape_string($alliance_names_2_ids[strtolower($allyname)])."','".mysql_real_escape_string($stats_array['points'][$i])."',NOW(),'".mysql_real_escape_string($stats_array['playername'][$i])."'), "; } else { // player new to database //echo "player new to database\n"; $query_2 = true; $query_collection2 .= " (NULL,$userid,'".mysql_real_escape_string($stats_array['rank'][$i])."','".mysql_real_escape_string($alliance_names_2_ids[strtolower($allyname)])."','".mysql_real_escape_string($stats_array['points'][$i])."',NOW(),'".mysql_real_escape_string($stats_array['playername'][$i])."'), "; } } } // remove last "," at the queries $query_collection = substr($query_collection,0,strlen($query_collection)-2); $query_collection2 = substr($query_collection2,0,strlen($query_collection2)-2); switch ($what) { case 0: $query_collection .= " ON DUPLICATE KEY UPDATE user_id=VALUES(user_id), rank=VALUES(rank), alliance_id=VALUES(alliance_id), points=VALUES(points), last_stats_update=NOW(), playername=VALUES(playername), ogame_playerid=VALUES(ogame_playerid) "; $query_collection2 .= " ON DUPLICATE KEY UPDATE user_id=VALUES(user_id), rank=VALUES(rank), alliance_id=VALUES(alliance_id), points=VALUES(points), last_stats_update=NOW(), playername=VALUES(playername) "; break; case 1: $query_collection .= " ON DUPLICATE KEY UPDATE user_id=VALUES(user_id),frank=VALUES(frank), alliance_id=VALUES(alliance_id), fpoints=VALUES(fpoints), last_stats_update=NOW(), playername=VALUES(playername), ogame_playerid=VALUES(ogame_playerid) "; $query_collection2 .= " ON DUPLICATE KEY UPDATE user_id=VALUES(user_id),frank=VALUES(frank), alliance_id=VALUES(alliance_id), fpoints=VALUES(fpoints), last_stats_update=NOW(), playername=VALUES(playername) "; break; case 2: $query_collection .= " ON DUPLICATE KEY UPDATE user_id=VALUES(user_id),rrank=VALUES(rrank), alliance_id=VALUES(alliance_id), rpoints=VALUES(rpoints), last_stats_update=NOW(), playername=VALUES(playername), ogame_playerid=VALUES(ogame_playerid) "; $query_collection2 .= " ON DUPLICATE KEY UPDATE user_id=VALUES(user_id),rrank=VALUES(rrank), alliance_id=VALUES(alliance_id), rpoints=VALUES(rpoints), last_stats_update=NOW(), playername=VALUES(playername) "; break; } if ($query_1 === true) { echo $query_collection."\n"; $res = mysql_query($query_collection); if (!$res) { echo $query_collection."\n".mysql_error()."\n"; $content = ob_get_clean(); return_result(622,$content); } } if ($query_2 === true) { echo $query_collection2."\n"; $res = mysql_query($query_collection2); if (!$res) { echo $query_collection."\n".mysql_error()."\n"; $content = ob_get_clean(); return_result(622,$content); } } if (!empty($playerhistory)) { // now the alliances has been updated, now update the alliance history $query = "INSERT LOW_PRIORITY INTO $playerhistory (player_id,alliance_id,year,month,day,rank,points,frank,fpoints,rrank,rpoints) SELECT id, alliance_id, DATE_FORMAT(NOW(),'%Y') , DATE_FORMAT(NOW(),'%m') , DATE_FORMAT(NOW(),'%e') , rank, points, frank, fpoints, rrank, rpoints FROM $playertable p WHERE p.last_stats_update > DATE_SUB(CURRENT_TIMESTAMP( ),INTERVAL 5 SECOND) ON DUPLICATE KEY UPDATE $playerhistory.alliance_id=VALUES(alliance_id), $playerhistory.rank=VALUES(rank), $playerhistory.points=VALUES(points), $playerhistory.frank=VALUES(frank), $playerhistory.fpoints=VALUES(fpoints), $playerhistory.rrank=VALUES(rrank), $playerhistory.rpoints=VALUES(rpoints)"; echo $query."\n"; $res = mysql_query($query); if (!$res) { echo $query."\n".mysql_error()."\n"; $content = ob_get_clean(); return_result(622,$content); } } $content = ob_get_clean(); echo "Content:\n"+$content."\n"; return_result(621,$content); } else { // no entries found return_result(622,"No entries found\n"); } } elseif ($who == 1) { echo "allystats...\n"; // Allystats $newarray = preg_split("/&\w+=/",$statstext); $stats_array['rank'] = explode("|",str_replace(".","",$newarray[1])); $stats_array['alliance'] = explode("|",$newarray[2]); $stats_array['member'] = explode("|",$newarray[3]); $stats_array['points'] = explode("|",str_replace(".","",$newarray[4])); unset($newarray); echo "Einträge: ".count($stats_array)." mit je ".count($stats_array['rank'])."\n"; switch ($what) { case 0: $query_collection = "INSERT LOW_PRIORITY INTO $allytable (user_id,rank, points, members, last_update, allyname) VALUES "; $query_end = " ON DUPLICATE KEY UPDATE rank=VALUES(rank), points=VALUES(points), last_update=VALUES(last_update), members=VALUES(members)"; break; case 1: $query_collection = "INSERT LOW_PRIORITY INTO $allytable (user_id,frank, fpoints, members, last_update, allyname) VALUES "; $query_end = " ON DUPLICATE KEY UPDATE frank=VALUES(frank), fpoints=VALUES(fpoints), last_update=NOW(), members=VALUES(members)"; break; case 2: $query_collection = "INSERT LOW_PRIORITY INTO $allytable (user_id,rrank, rpoints, members, last_update, allyname) VALUES "; $query_end = " ON DUPLICATE KEY UPDATE rrank=VALUES(rrank), rpoints=VALUES(rpoints), last_update=NOW(), members=VALUES(members)"; break; } $alliances_added = 0; for ($i=0; $i < count($stats_array['alliance']); $i++) { if (is_numeric($stats_array['rank'][$i])) { $alliances_added++; $query_collection .= "($userid,'".mysql_real_escape_string($stats_array['rank'][$i])."', '".mysql_real_escape_string($stats_array['points'][$i])."', '".mysql_real_escape_string($stats_array['member'][$i])."', NOW(), '".mysql_real_escape_string($stats_array['alliance'][$i])."' ), "; } } if ($alliances_added > 0) { $query_collection = substr($query_collection,0,strlen($query_collection)-2); $query_collection .= $query_end; echo $query_collection."\n"; $res = mysql_query($query_collection); if (!$res) { echo $query."\n".mysql_error()."\n"; $content = ob_get_clean(); return_result(622,$content); } if (!empty($allyhistory)) { // now the alliances has been updated, now update the alliance history $query = "INSERT LOW_PRIORITY INTO $allyhistory (alliance_id,year,month,day,rank,points,frank,fpoints,rrank,rpoints,members) SELECT id, DATE_FORMAT(NOW(),'%Y') , DATE_FORMAT(NOW(),'%m') , DATE_FORMAT(NOW(),'%e') , rank, points, frank, fpoints, rrank, rpoints, members FROM $allytable WHERE $allytable.last_update > DATE_SUB(CURRENT_TIMESTAMP( ),INTERVAL 5 SECOND) ON DUPLICATE KEY UPDATE $allyhistory.rank=VALUES(rank), $allyhistory.points=VALUES(points), $allyhistory.frank=VALUES(frank), $allyhistory.fpoints=VALUES(fpoints), $allyhistory.rrank=VALUES(rrank), $allyhistory.rpoints=VALUES(rpoints), $allyhistory.members=VALUES(members)"; echo $query."\n"; $res = mysql_query($query); if (!$res) { echo $query."\n".mysql_error()."\n"; $content = ob_get_clean(); return_result(622,$content); } } $content = ob_get_clean(); return_result(621,$content); } else { // no entries found return_result(622,"No entries found\n"); } } } elseif (isset($_POST['typ']) && $_POST['typ']=="galaxy" && isset($_POST['content']) && !empty($_POST['content']) && isset($_POST['galaxy']) && is_numeric($_POST['galaxy']) && isset($_POST['system']) && is_numeric($_POST['system']) && $allow_insert == "true" ) { echo "galaxyview...\n"; echo $_POST['content']."\n"; // Galaxy view $galaxy = (int)$_POST['galaxy']; $system = (int)$_POST['system']; $gv_source = str_replace(" "," ",stripslashes($_POST['content'])); $gv_array = explode("\n",$gv_source); $solarstring = $gv_array[0]; unset ($gv_array[1]); unset ($gv_array[0]); $query_collection = "REPLACE LOW_PRIORITY $dbtablename (galaxy,system,planet,moon,moonsize,planetname,last_update,metal,crystal,player_id,user_id) VALUES "; $ogame_playerids = array(); $ogame_playernames = array(); $ogame_allynames = array(); $playername_wo_ogameid = array(); foreach ($gv_array as $gv_row) { $gv_entries = explode("|",$gv_row); if ($gv_entries[8] > 0) { array_push($ogame_playerids ,$gv_entries[8]); // ogame playerid } elseif ($gv_entries[8] == 0 && trim($gv_entries[5]) != "") { array_push($playername_wo_ogameid,trim($gv_entries[5])); // no ogame playerid } if (!empty($gv_entries[5])) array_push($ogame_playernames ,trim($gv_entries[5])); // playername if (!empty($gv_entries[7])) array_push($ogame_allynames ,trim($gv_entries[7])); // allyname } // determine playernames which have ogame_playerid (at DB) $query = "SELECT p.id,playername,ogame_playerid,noob,vacation,banned,inactive,long_inactive,a.allyname FROM $playertable p LEFT JOIN $allytable a ON (p.alliance_id = a.id) WHERE ogame_playerid IN ('".implode("','", $ogame_playerids)."')"; $res = mysql_query($query); if (!$res) { echo $query."\n".mysql_error()."\n"; } $ogame_playernames = array(); while ($line = mysql_fetch_object($res)) { $ogame_playernames[$line->ogame_playerid] = $line->id; $ogame_playernames[strtolower($line->playername)] = $line->id; $ogame_playernames[strtolower($line->playername)] = $line->id; // store current inforation to check if player needs an update $ogame_playerinfo[$line->id]["name"] = $line->playername; $ogame_playerinfo[$line->id]["allyname"] = $line->allyname; $ogame_playerinfo[$line->id]["noob"] = $line->noob; $ogame_playerinfo[$line->id]["vacation"] = $line->vacation; $ogame_playerinfo[$line->id]["banned"] = $line->banned; $ogame_playerinfo[$line->id]["inactive"] = $line->inactive; $ogame_playerinfo[$line->id]["long_inactive"] = $line->long_inactive; } // determine playernames by name (no ogame_playerid) - can happen for own player, but also if at commander view some pics are disabled if (count($playername_wo_ogameid) > 0) { $playername_wo_ogameid = array_unique($playername_wo_ogameid); $query = "SELECT p.id,playername,ogame_playerid,noob,vacation,banned,inactive,long_inactive,a.allyname FROM $playertable p LEFT JOIN $allytable a ON (p.alliance_id = a.id) WHERE playername IN ('".implode("','", $playername_wo_ogameid)."')"; $res = mysql_query($query); if (!$res) { echo $query." ".mysql_error()."\n"; } while ($line = mysql_fetch_object($res)) { $ogame_playernames[strtolower($line->playername)] = $line->id; // store current inforation to check if player needs an update $ogame_playerinfo[$line->id]["name"] = $line->playername; $ogame_playerinfo[$line->id]["allyname"] = $line->allyname; $ogame_playerinfo[$line->id]["noob"] = $line->noob; $ogame_playerinfo[$line->id]["vacation"] = $line->vacation; $ogame_playerinfo[$line->id]["banned"] = $line->banned; $ogame_playerinfo[$line->id]["inactive"] = $line->inactive; $ogame_playerinfo[$line->id]["long_inactive"] = $line->long_inactive; } } unset($playername_wo_ogameid); unset($i); // avoid accidently usage somewhere else // determine allynames if (count($ogame_allynames) > 0) { $query = "SELECT distinct(id),allyname,diplomatic_status FROM $allytable WHERE allyname IN ('".implode("','", $ogame_allynames)."')"; $res = mysql_query($query); if (!$res) { echo $query."\n".mysql_error()."\n"; } while ($line = mysql_fetch_object($res)) { $ogame_allynames[strtolower($line->allyname)]["id"] = $line->id; $ogame_allynames[strtolower($line->allyname)]["diplomatic_status"] = $line->diplomatic_status; } // echo "ID and diplomatic status are read\n"; // echo "starting to loop the gv_array with ".count($gv_array)."entries\n"; } else { $ogame_allynames = array(); } foreach ($gv_array as $gv_row) { $gv_entries = explode("|",$gv_row); // determine moonsize $moon = ($gv_entries[2] > 0) ? "true" : "false"; // "translate" playerstatus to german $playerstatus = $gv_entries[6]; $playerstatus = str_replace("b","g",$playerstatus); // english+french+italian+greek+romanian+japanese banned players $playerstatus = str_replace("v","u",$playerstatus); // english+spanish+dutch+french+italian+greek+romanian+japanese vacation mode $playerstatus = str_replace("o","u",$playerstatus); // balkan vacation mode $playerstatus = str_replace("m","u",$playerstatus); // portugues vacation mode $playerstatus = str_replace("k","g",$playerstatus); // balkan banned players $playerstatus = str_replace("t","u",$playerstatus); // turkish vacation players $playerstatus = str_replace("c","g",$playerstatus); // turkish banned players $playerstatus = str_replace("н","n",$playerstatus); // russian noob players $playerstatus = str_replace("РО","u",$playerstatus); // russian vacation players $playerstatus = str_replace("z","u",$playerstatus); // czech vacation players $playerstatus = str_replace("з","g",$playerstatus); // russian banned players if (strpos($gv_source,"Solsystem") !== false) { $playerstatus = str_replace("f","u",$playerstatus); // danish vacation mode } if (strpos($gv_source,"Teckenförklaring") !== false) { $playerstatus = str_replace("k","n",$playerstatus); // swedish noob players $playerstatus = str_replace("s","u",$playerstatus); // swedish vacation players $playerstatus = str_replace("b","g",$playerstatus); // swedish banned players $playerstatus = str_replace("f","s",$playerstatus); // swedish strong players } // noob players - de,en have "n" if (!preg_match("/Uk\D{1}ad S\D{1}oneczny/",$gv_source)) { // except polish "d" (strong player) $playerstatus = str_replace("d","n",$playerstatus); // french+italian+spanish noob players } $playerstatus = str_replace("z","n",$playerstatus); // dutch+turkey noob players if (preg_match("/Uk\D{1}ad S\D{1}oneczny/",$gv_source) || strpos($gv_source,"Günes Sistemi") !== false) { $playerstatus = str_replace("s","n",$playerstatus); // balkan+polish noob players } if (strpos($gv_source,"Sistema Solar") !== false) { $playerstatus = str_replace("f","n",$playerstatus); // portugues noob players } if (strpos($gv_source,"Sistema solar") !== false) { $playerstatus = str_replace("s","g",$playerstatus); // spanish banned players } if (strpos($gv_source,"Günes Sistemi") !== false) { $playerstatus = str_replace("g","s",$playerstatus); // turkish strong players (otherwise they would get "banned") } $playerstatus = preg_replace('/[^iIugn]/i','', $playerstatus); $playerstatus_noob = (strpos($playerstatus,"n") === false) ? 'false' : 'true'; $playerstatus_vacation = (strpos($playerstatus,"u") === false) ? 'false' : 'true'; $playerstatus_banned = (strpos($playerstatus,"g") === false) ? 'false' : 'true'; $playerstatus_inactive = (strpos($playerstatus,"i") === false) ? 'false' : 'true'; $playerstatus_long_inactive = (strpos($playerstatus,"I") === false) ? 'false' : 'true'; //echo "Spielerstatus: ".$playerstatus_noob.$playerstatus_vacation.$playerstatus_banned.$playerstatus_inactive.$playerstatus_long_inactive."\n"; // insert row into database if ($gv_entries[0] > 0 && $gv_entries[0] < 16) { $query_collection .= " ("; $query_collection .= "'".mysql_real_escape_string($galaxy)."', "; $query_collection .= "'".mysql_real_escape_string($system)."', "; $query_collection .= "'".mysql_real_escape_string($gv_entries[0])."', "; $query_collection .= "'".mysql_real_escape_string($moon)."', "; // moon $query_collection .= "'".mysql_real_escape_string(str_replace(".","",$gv_entries[2]))."', "; // moonsize $query_collection .= "'".mysql_real_escape_string($gv_entries[1])."', "; // planetname $query_collection .= "NOW(), "; // last update $query_collection .= "'".mysql_real_escape_string($gv_entries[3])."', "; // metal $query_collection .= "'".mysql_real_escape_string($gv_entries[4])."', "; // crystal // now add the alliance_id foreign key for the alliance name $alliance_name = trim($gv_entries[7]); if (!isset($ogame_allynames[strtolower($alliance_name)]["id"]) && !empty($alliance_name)) { // insert allyname first and determine the new ID of that alliance $query = "INSERT LOW_PRIORITY INTO $allytable (allyname, last_update) VALUES ('".mysql_real_escape_string($alliance_name)."', NOW())"; $res = mysql_query($query, $mysqlcon); if (!$res) { echo $query."\n".mysql_error()."\n"; } $ogame_allynames[strtolower($alliance_name)]["id"] = mysql_insert_id($mysqlcon); } // now add the player_id foreign key for the playername $player_new_inserted = false; if (empty($gv_entries[5])) { $query_collection .= "'0',"; } elseif (!isset($ogame_playernames[$gv_entries[8]])) { // ogame playerid //echo "no ogame_playerid...\n"; if (!isset($ogame_playernames[strtolower($gv_entries[5])])) { // playername //echo "using playername...\n"; $ally_id = (trim($alliance_name) != "") ? $ogame_allynames[strtolower($alliance_name)]["id"] : 0; // insert playername to the table and determine the new ID of that playername $ogame_playerid_at_query = ($gv_entries[8] == 0) ? "NULL" : "'".mysql_real_escape_string($gv_entries[8])."'"; if (empty($ogame_allynames[strtolower($alliance_name)]["diplomatic_status"])) { $query = "INSERT LOW_PRIORITY INTO $playertable (playername, ogame_playerid, alliance_id, noob,vacation,banned,inactive,long_inactive,diplomatic_status) ". "VALUES ('".mysql_real_escape_string($gv_entries[5])."', $ogame_playerid_at_query, '".$ally_id."', '$playerstatus_noob','$playerstatus_vacation','$playerstatus_banned','$playerstatus_inactive','$playerstatus_long_inactive', 'nothing') "; } else { $query = "INSERT LOW_PRIORITY INTO $playertable (playername, ogame_playerid, alliance_id, noob,vacation,banned,inactive,long_inactive,diplomatic_status) ". "VALUES ('".mysql_real_escape_string($gv_entries[5])."', $ogame_playerid_at_query, '".$ally_id."', '$playerstatus_noob','$playerstatus_vacation','$playerstatus_banned','$playerstatus_inactive','$playerstatus_long_inactive', '".$ogame_allynames[strtolower($alliance_name)]["diplomatic_status"]."')"; } //echo $query."\n"; $res = mysql_query($query,$mysqlcon); if (!$res) { echo $query."\n".mysql_error()."\n"; } $ogame_playernames[strtolower($gv_entries[5])] = mysql_insert_id($mysqlcon); //$ogame_playerinfo[mysql_insert_id($mysqlcon)]["noob"] = ""; //$ogame_playerinfo[mysql_insert_id($mysqlcon)]["vacation"] = ""; //$ogame_playerinfo[mysql_insert_id($mysqlcon)]["banned"] = ""; //$ogame_playerinfo[mysql_insert_id($mysqlcon)]["inactive"] = ""; //$ogame_playerinfo[mysql_insert_id($mysqlcon)]["long_inactive"] = ""; //$ogame_playerinfo[mysql_insert_id($mysqlcon)]["name"] = ""; //$ogame_playerinfo[mysql_insert_id($mysqlcon)]["allyname"] = ""; $query_collection .= "'".mysql_insert_id($mysqlcon)."',"; $galaxytool_playerid = mysql_insert_id($mysqlcon); $player_new_inserted = true; } else { $query_collection .= "'".$ogame_playernames[strtolower($gv_entries[5])]."',"; $galaxytool_playerid = $ogame_playernames[strtolower($gv_entries[5])]; if (!isset($ogame_playerinfo[$galaxytool_playerid]["noob"])) { // the player was inserted before within this galaxyview $player_new_inserted = true; } } } else { //echo "using ogame_playerid...\n"; $query_collection .= "'".$ogame_playernames[$gv_entries[8]]."',"; $galaxytool_playerid = $ogame_playernames[$gv_entries[8]]; } $query_collection .= "'".$userid."'"; // store userid of the player who updated the system $query_collection .= "), "; } // check if playerinformation changed if (!empty($gv_entries[5]) && $player_new_inserted === false && ( $ogame_playerinfo[$galaxytool_playerid]["noob"] != $playerstatus_noob || $ogame_playerinfo[$galaxytool_playerid]["vacation"] != $playerstatus_vacation || $ogame_playerinfo[$galaxytool_playerid]["banned"] != $playerstatus_banned || $ogame_playerinfo[$galaxytool_playerid]["inactive"] != $playerstatus_inactive || $ogame_playerinfo[$galaxytool_playerid]["long_inactive"] != $playerstatus_long_inactive || $ogame_playerinfo[$galaxytool_playerid]["name"] != trim($gv_entries[5]) || $ogame_playerinfo[$galaxytool_playerid]["allyname"] != trim($gv_entries[7]) )) { $ally_id = (trim($alliance_name) != "") ? $ogame_allynames[strtolower($alliance_name)]["id"] : 0; if (isset($gv_entries[8]) && $gv_entries[8] > 0 && $ogame_playerinfo[$galaxytool_playerid]["name"] == trim($gv_entries[5])) { // equal players required - otherwise the ogame_playerid may be assigned to two "different" playernames $player_update_query = "UPDATE LOW_PRIORITY $playertable SET playername='".mysql_real_escape_string($gv_entries[5])."', noob='$playerstatus_noob',vacation='$playerstatus_vacation',banned='$playerstatus_banned',inactive='$playerstatus_inactive',long_inactive='$playerstatus_long_inactive',alliance_id='".$ally_id."', ogame_playerid='".mysql_real_escape_string($gv_entries[8])."' WHERE id='$galaxytool_playerid'"; } else { $player_update_query = "UPDATE LOW_PRIORITY $playertable SET playername='".mysql_real_escape_string($gv_entries[5])."', noob='$playerstatus_noob',vacation='$playerstatus_vacation',banned='$playerstatus_banned',inactive='$playerstatus_inactive',long_inactive='$playerstatus_long_inactive',alliance_id='".$ally_id."' WHERE id='$galaxytool_playerid'"; } echo $player_update_query."\n"; $res = mysql_query($player_update_query); if (!$res) { echo mysql_error()."\n"; echo $player_update_query."gv not updated...\n"; $content = ob_get_clean(); return_result(602,$content); } } } echo "galaxy: ".$galaxy." system: ".$system."\n"; $query_collection = substr($query_collection,0,strlen($query_collection)-2); echo $query_collection."\n"; $res = mysql_query($query_collection); if (!$res) { echo mysql_error()."\n"; echo "gv not updated...\n"; $content = ob_get_clean(); return_result(602,$content); } else { echo "gv updated...\n"; $content = ob_get_clean(); return_result(601,$content); } echo "positions wrong...\n"; $content = ob_get_clean(); return_result(602,$content); } elseif (isset($_POST['typ']) && $_POST['typ']=="reports" && isset($_POST['content']) && !empty($_POST['content']) && $allow_insert == "true" ) { echo "reports...\n"; include_once "spioparser.inc.php"; $parser = new Probeparser($dbusername,$dbpassword,$dbname,$reporttable,$dbtablename,$playertable,$dbhost); $reportstring = str_replace(" "," ",stripslashes($_POST['content'])); $reportstring = str_replace(""," ",$reportstring); $reportstring = str_replace("\n","",$reportstring); $reportstring = str_replace("","\n",$reportstring); if (strpos($reportstring,"Flottbefällhavare") > 0) { // swedish ogame bug $reportstring = preg_replace("/\
"; print_r($parser->error); echo ""; $debug = ob_get_clean(); return_result(612,$debug); } $debug = ob_get_clean(); return_result(611,$debug); } else { echo "nothing found...\n"; $debug = ob_get_clean(); return_result(700,"Nothing done at the galaxytool