%PDF- %PDF-
Direktori : /www/old2/_music/ingress/ |
Current File : /www/old2/_music/ingress/hackanalyze.php |
<?php function getPlayerLevel($ap, $imaginary = false) { if($ap < 10000) return 1; if($ap < 30000) return 2; if($ap < 70000) return 3; if($ap < 150000) return 4; if($ap < 300000) return 5; if($ap < 600000) return 6; if($ap < 1200000) return 7; if(!$imaginary) return 8; if($ap < 2400000) return 8; if($ap < 4800000) return 9; if($ap < 9600000) return 10; if($ap < 19200000) return 11; if($ap < 38400000) return 12; } function getPortalLevel($resonatorLevels) { $lvl = 0; foreach($resonatorLevels as $res) { $lvl += $res; } return $lvl / 8; } die; header("Content-Type: text/plain"); ini_set('mongo.native_long', 1); exec("ls /var/www/hacks/decompressed/*.txt", $files); foreach($files as $file) { $txt = file_get_contents($file); $data = json_decode($txt); preg_match("/.*?_([0-9]*)_.*/", $file, $match); $stime = $match[1]; if($data->rpcResult->error == null) { $hack = new stdClass(); $hack->serverTime = $stime; $hack->ingressTime = ($data->rpcResult->gameBasket->inventory[0][1]); $hack->playerGuid = $data->rpcResult->gameBasket->playerEntity[0]; $hack->playerSide = $data->rpcResult->gameBasket->playerEntity[2]->controllingTeam->team; $hack->playerLevel = getPlayerlevel($data->rpcResult->gameBasket->playerEntity[2]->playerPersonal->ap); $hack->playerImaginaryLevel = getPlayerlevel($data->rpcResult->gameBasket->playerEntity[2]->playerPersonal->ap, true); $hack->playerApGain = 0; if(count($data->rpcResult->gameBasket->apGains) > 0) { foreach($data->rpcResult->gameBasket->apGains as $apg) { $hack->playerApGain += $apg->apGainAmount; } } $hack->portalSide = $data->portalTeam->team; $hack->decimalPortalLevel = getPortalLevel($data->portal->resonatorLevels); $hack->portalLevel = floor($hack->decimalPortalLevel); $hack->items = array(); foreach($data->rpcResult->gameBasket->inventory as $item) { $it = new stdClass(); if(isset($item[2]->resourceWithLevels)) { $it->item = $item[2]->resourceWithLevels->resourceType; $it->level = $item[2]->resourceWithLevels->level; } elseif(isset($item[2]->modResource)) { $it->item = $item[2]->modResource->resourceType; $it->rarity = $item[2]->modResource->rarity; } elseif(isset($item[2]->resource)) { $it->item = $item[2]->resource->resourceType; $it->rarity = $item[2]->resource->rarity; } else { $fname = uniqid("unknown_hack_".$stime); $txt = json_encode($data, JSON_PRETTY_PRINT); file_put_contents("/var/www/hacks/decompressed/$fname.txt", $txt); } $hack->items[] = $it; } $m = new MongoClient(); $db = $m->selectDB("ingress"); $col = $db->selectCollection("hacks"); $col->insert($hack); var_dump($hack->ingressTime); } } ?>