Exemplo n.º 1
0
function fvTools_doWork()
{
    AddLog2('fvTools: Beginning Work');
    $fvM = new fvTools();
    unset($fvM);
    AddLog2('fvTools: Finished Work');
}
Exemplo n.º 2
0
function GB_CollCompete()
{
    $GB_CollectionList = GB_GetCollectionList();
    if (!$GB_CollectionList) {
        AddLog2("collectable_info.txt not found.. ");
        return false;
    }
    $GB_CollCompl = 0;
    $GBccount = array();
    $GBccount = GB_LoadCcount();
    if (!$GBccount) {
        AddLog2("ccount.txt not found.. ");
        return false;
    }
    $res = array();
    foreach ($GB_CollectionList as $value) {
        // walk all collections
        $GB_amount_Coll = count($value['collectable']);
        $i = 0;
        $GB_ThisCollCompl = 0;
        $GB_ThisCollVal = array();
        while ($i < $GB_amount_Coll) {
            // each collection
            //$ObjD = GB_GetUnitInfo($value['collectable'][$i], "code", $GB_units);
            $Amount_in_Collection = GB_GetColInfo($value['collectable'][$i], $GBccount);
            $GB_ThisCollVal[] = $Amount_in_Collection;
            $i++;
        }
        $GB_ThisCollCompl = min($GB_ThisCollVal);
        $res[$value['code']] = $GB_ThisCollCompl;
    }
    return $res;
    //return total completed array can be empty.
}
Exemplo n.º 3
0
function fvManager_doWork()
{
    AddLog2('fvManager initializing');
    $fvM = new fvManager();
    if ($fvM->error != '') {
        unset($fvM);
        return;
    }
    AddLog2('fvManager initialized');
    $fvM->fvSellAll();
    $results = $fvM->fvGetWork('2');
    if (empty($results) || count($results) <= 0) {
        unset($fvM);
        AddLog2('fvManager had no work to do');
        return;
    } else {
        AddLog2('fvManager preparing to buy/sell items');
        foreach ($results as $item) {
            switch ($item['work_action']) {
                case 'craftbuy':
                case 'buy':
                    $result = $fvM->fvBuyItem($item);
                    break;
                default:
                    $result = $fvM->fvSell($item);
            }
        }
        unset($fvM);
        AddLog2('fvManager has finished buying/selling items');
    }
}
Exemplo n.º 4
0
function FarmStats_doWork()
{
    $fvM = new FarmStats();
    if ($fvM->error != '') {
        unset($fvM);
        AddLog2($fvM->error);
        return;
    }
    unset($fvM);
}
Exemplo n.º 5
0
function Grifter_run()
{
    global $Grifter_settings;
    Grifter_loadSettings();
    Grifter_autofill();
    AddLog2('Grifter v' . Grifter_version);
    $farm = null;
    $farm = Grifter_Grift($farm);
    save_array($Grifter_settings, Grifter_settings);
}
Exemplo n.º 6
0
function fvNeighbors_doWork()
{
    AddLog2('fvNeighbors initializing');
    $fvM = new fvNeighbors();
    if ($fvM->error != '') {
        AddLog2($fvM->error);
        unset($fvM);
        return;
    }
    AddLog2('fvNeighbors initialized');
    unset($fvM);
}
Exemplo n.º 7
0
 private function _fvBuyGoods()
 {
     $amfcount = 0;
     $amf = '';
     $tmpArray = array();
     $iguser = load_array('ignores.txt');
     $usedUserIds = array();
     while ($this->cBagsConsumed < $this->cDailyPurch) {
         foreach ($this->availGoods as $aGoods) {
             $uid = number_format($aGoods['uid'], 0, '', '');
             if (fBGetNeighborRealName($uid) === false) {
                 continue;
             }
             if (isset($iguser[$uid])) {
                 continue;
             }
             if (@$this->cConsumed[$uid] >= $this->cDailyBags) {
                 if ($this->settings['debug'] == 1) {
                     AddLog2("Buy from " . $uid . " result: Maximum Goods Consumed");
                 }
                 continue;
             }
             foreach ($aGoods['in'] as $aInvent) {
                 if (isset($usedUserIds[$uid])) {
                     break;
                 }
                 $code = $aInvent['ic'];
                 $cost = $aInvent['pr'];
                 $amf = $this->_fvCreateMultAMFRequest($amf, $amfcount, '', 'CraftingService.onBuyCraftedGoods');
                 $amf->_bodys[0]->_value[1][$amfcount]['params'][0][0]['itemCode'] = trim($code);
                 $amf->_bodys[0]->_value[1][$amfcount]['params'][0][0]['priceOffered'] = $cost;
                 $amf->_bodys[0]->_value[1][$amfcount]['params'][0][0]['sellingUserId'] = trim($uid);
                 $tmpArray[$amfcount]['uid'] = $uid;
                 $tmpArray[$amfcount]['code'] = $code;
                 $amf2 = $this->_fvAMFSend($amf);
                 $amf = '';
                 $amfcount = 0;
                 if ($amf2 === false) {
                     continue;
                 }
                 foreach ($amf2->_bodys[0]->_value['data'] as $key => $returned) {
                     $resp2 = $returned['data']['buyResponse']['buyResults'][0]['code'];
                     if ($resp2 == 1 || $resp2 == 2 || $resp2 == 12) {
                         $iguser = load_array('ignores.txt');
                         $iguser[$tmpArray[$key]['uid']] = $tmpArray[$key]['uid'];
                         save_array($iguser, 'ignores.txt');
                     }
                     if ($resp2 == 0) {
                         $item = $this->fvGetUnits($tmpArray[$key]['code']);
                         AddLog2("Buy " . $item['units_realname'] . " from " . $tmpArray[$key]['uid'] . " result: " . $this->zErrCGoods[$resp2]);
                         $usedUserIds[$uid] = 1;
                         $this->cBagsConsumed++;
                         break;
                     } else {
                         if ($this->settings['debug'] == 1) {
                             AddLog2("Buy from {$uid} result: " . $this->zErrCGoods[$resp2]);
                         }
                     }
                 }
             }
         }
         break;
     }
     if ($amf != '') {
         $amf2 = $this->_fvAMFSend($amf);
         if ($amf2 !== false) {
             foreach ($amf2->_bodys[0]->_value['data'] as $key => $returned) {
                 $resp2 = $returned['data']['buyResponse']['code'];
                 if ($resp2 == 1 || $resp2 == 2 || $resp2 == 12) {
                     $iguser = load_array('ignores.txt');
                     $iguser[$tmpArray[$key]['uid']] = $tmpArray[$key]['uid'];
                     save_array($iguser, 'ignores.txt');
                 }
                 if ($resp2 == 0) {
                     $item = $this->fvGetUnits($tmpArray[$key]['code']);
                     AddLog2("Buy " . $item['units_realname'] . " from " . $tmpArray[$key]['uid'] . " result: " . $this->zErrCGoods[$resp2]);
                 } else {
                     if ($this->settings['debug'] == 1) {
                         AddLog2("Buy from " . $tmpArray[$key]['uid'] . " result: " . $this->zErrCGoods[$resp2]);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
function TB_run_storagemanager($getFarm = null)
{
    global $TB_settings;
    global $AM_settings;
    //########################################################################
    // storagemanager functions
    //########################################################################
    echo "StorageManager\r\n";
    $farm = $getFarm;
    if (isset($TB_settings['SM_action']['sell']) || isset($TB_settings['SM_action']['place'])) {
        if (count($TB_settings['SM_action']['sell']) > 0) {
            SM_sell();
        }
        if (count($TB_settings['SM_action']['place']) > 0) {
            if (!isset($farm)) {
                AddLog2('TB - reloding farm');
                DoInit();
                $farm = TB_buildFarmArray();
            }
            $re = SM_place($farm);
            if (is_array($re)) {
                $farm = $re;
            }
        }
        $TB_settings['TB_needReload'] = true;
    }
    return $farm;
}
Exemplo n.º 9
0
 private function _fvDoGreenhouse()
 {
     $bsInfo = unserialize(fBGetDataStore('bsinfo'));
     $greenhouses = GetObjectsByName('greenhousebuildable_finished');
     if (empty($greenhouses)) {
         return;
     }
     $trayscnt = $bsInfo[0]['upgradeUnlockedTrays'];
     $totaltrays = $trayscnt[$greenhouses[0]['expansionLevel']];
     $bsStats = unserialize(fBGetDataStore('bsstats'));
     $fthybrids = unserialize($this->fvGetSettings('fthybrids'));
     $genealogy = $bsInfo[0]['genealogy'];
     foreach ($genealogy as $gene) {
         foreach ($gene['ingredient'] as $key => $ingred) {
             $gene['ingredient'][$key]['quantity'] = $ingred['quantity'] * 50;
         }
         $recipes[$gene['itemCode']] = $gene['ingredient'];
     }
     $alltrays = $bsStats['breedingFeatures']['farm']['greenhousebuildable_finished']['trays'];
     //Harvest Trays
     foreach ($alltrays as $key => $tray) {
         if (count($tray['helpingFriendIds']) >= 3 || $_SESSION['servertime'] >= $tray['startTime'] + $bsInfo[0]['breedingDuration']) {
             $amf = CreateRequestAMF('', 'BreedingService.finishBreedingProject');
             $amf->_bodys[0]->_value[1][0]['params'][0] = 'greenhousebuildable_finished';
             $amf->_bodys[0]->_value[1][0]['params'][1] = $key;
             $res = RequestAMF($amf);
             AddLog2('fvTools: Collecting Seeds From Tray ' . ($key + 1) . ': ' . $res);
             if ($res = 'OK') {
                 unset($alltrays[$key]);
             }
         }
     }
     //Start New Trays
     if (empty($fthybrids)) {
         return;
     }
     $traycnt = 0;
     for ($x = count($alltrays); $x < $totaltrays; $x++) {
         $traycode = $fthybrids['tray_' . $x];
         $seedname = Units_GetRealnameByCode($traycode);
         $amf = CreateRequestAMF('', 'BreedingService.beginNewBreedingProject');
         $amf->_bodys[0]->_value[1][0]['params'][0] = 'greenhousebuildable_finished';
         $amf->_bodys[0]->_value[1][0]['params'][1] = $traycnt;
         $amf->_bodys[0]->_value[1][0]['params'][2] = $recipes[$traycode];
         $res = RequestAMF($amf);
         AddLog2('fvTools: Starting ' . $seedname . ' in Tray ' . ($traycnt + 1) . ': ' . $res);
         $traycnt++;
     }
 }
Exemplo n.º 10
0
 private function _fvUpdateUnits()
 {
     error_reporting(E_ERROR | E_WARNING | E_NOTICE);
     ini_set('display_errors', true);
     $doc = file_get_contents('./farmville-xml/' . $this->flashRevision . '_items.xml');
     if (!$doc) {
         AddLog2('Unable to get items.xml');
     }
     $doc3 = file_get_contents('./farmville-xml/' . $this->flashRevision . '_gameSettings.xml');
     if (!$doc3) {
         AddLog2('Unable to get gameSettings.xml');
     }
     $doc4 = file_get_contents('./farmville-xml/' . $this->flashRevision . '_StorageConfig.xml');
     if (!$doc4) {
         AddLog2('Unable to get StorageConfig.xml');
     }
     $doc2 = file_get_contents('./farmville-xml/' . $this->flashRevision . '_crafting.xml');
     if (!$doc2) {
         AddLog2('Unable to get crafting.xml');
     }
     if (!$doc || !$doc2 || !$doc3 || !$doc4) {
         return;
     }
     AddLog2('fvXML is updating units');
     //$newimgs = load_array('newimages.txt');
     $fvSQL = "DELETE FROM units";
     $this->_fvXMLDBU->queryExec($fvSQL);
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($doc);
     $items = $xmlDoc->getElementsByTagName("item");
     $iCount = $items->length;
     AddLog2("Adding {$iCount} items to units database");
     $mfvSQL = '';
     $this->_fvXMLDBU->queryExec('BEGIN;');
     foreach ($items as $item) {
         $data = array();
         $classname = @$item->getAttribute('className');
         $ls = @$item->getElementsByTagName('limitedStart');
         //limitedStart
         $lstart = @$ls->item(0)->nodeValue;
         $le = @$item->getElementsByTagName('limitedEnd');
         //limitedEnd
         $lend = @$le->item(0)->nodeValue;
         $lmt = @$item->getElementsByTagName('limit');
         //limit
         $fn = @$item->getElementsByTagName('finishedName');
         //finishedName
         $ca = @$item->getElementsByTagName('capacity');
         //capacity
         $rl = @$item->getElementsByTagName('requiredLevel');
         //requiredLevel
         $cash = @$item->getElementsByTagName('cash');
         //cash
         $cost = @$item->getElementsByTagName('cost');
         //cost
         $sizeX = @$item->getElementsByTagName('sizeX');
         //sizeX
         $sizeY = @$item->getElementsByTagName('sizeY');
         //sizeY
         $growTime = @$item->getElementsByTagName('growTime');
         $plantXp = @$item->getElementsByTagName('plantXp');
         $coinYield = @$item->getElementsByTagName('coinYield');
         $data['code'] = @$item->getAttribute('code');
         $data['canplace'] = @$item->getAttribute('placeable');
         $data['iphoneonly'] = @$item->getAttribute('iphoneonly');
         $data['mastery'] = @$item->getAttribute('mastery');
         $data['license'] = @$item->getAttribute('license');
         $data['name'] = @$item->getAttribute('name');
         $data['type'] = @$item->getAttribute('type');
         $data['buyable'] = @$item->getAttribute('buyable');
         $data['subtype'] = @$item->getAttribute('subtype');
         $data['giftable'] = @$item->getAttribute('giftable');
         $data['market'] = @$item->getAttribute('market');
         $data['classname'] = empty($classname) ? ucfirst($data['type']) : $classname;
         $data['limitedstart'] = !empty($lstart) ? strtotime($lstart) : '';
         $data['limitedend'] = !empty($lend) ? strtotime($lend) : '';
         $data['limit'] = @$lmt->item(0)->nodeValue;
         $data['finishedName'] = @$fn->item(0)->nodeValue;
         $data['capacity'] = @$ca->item(0)->nodeValue;
         $data['requiredLevel'] = @$rl->item(0)->nodeValue;
         $data['cash'] = @$cash->item(0)->nodeValue;
         $data['cost'] = @$cost->item(0)->nodeValue;
         $data['sizeX'] = @$sizeX->item(0)->nodeValue;
         $data['sizeY'] = @$sizeY->item(0)->nodeValue;
         $data['growTime'] = @$growTime->item(0)->nodeValue;
         $data['plantXp'] = @$plantXp->item(0)->nodeValue;
         $data['coinYield'] = @$coinYield->item(0)->nodeValue;
         $upgrades = @$item->getElementsByTagName('upgrade');
         //upgrade
         $up = array();
         foreach ($upgrades as $upgrade) {
             $level = @$upgrade->getAttribute('level');
             $capacity = @$upgrade->getAttribute('capacity');
             $up[$level] = @$capacity;
         }
         $data['upgrade'] = serialize(@$up);
         $requirements = @$item->getElementsByTagName('requirements');
         //upgrade
         $require = array();
         foreach ($requirements as $rq) {
             $rqs = @$rq->getElementsByTagName('requirement');
             $rname = $rqs->item(0)->getAttribute('name');
             $rlevel = $rqs->item(0)->getAttribute('level');
             $require[$rname] = @$rlevel;
         }
         $data['requirements'] = serialize(@$require);
         $imgs = @$item->getElementsByTagName('image');
         foreach ($imgs as $img) {
             $itype = $img->getAttribute('name');
             if ($itype == 'built_rotatable' || $data['classname'] == 'RotateableDecoration') {
                 $data['canrotate'] = 'true';
             }
             if ($itype == 'icon') {
                 $data['iconurl'] = @$img->getAttribute('url');
             }
         }
         $data['canrotate'] = @$data['canrotate'] == 'true' ? 1 : 0;
         $data['canplace'] = @$data['canplace'] == 'true' ? 1 : 0;
         $data['canplace'] = (@$data['type'] == 'building' || @$data['type'] == 'decoration') && !is_numeric(@$data['canplace']) ? 1 : @$data['canplace'];
         $data['iphoneonly'] = @$data['iphoneonly'] == 'true' ? 1 : 0;
         $data['buyable'] = @$data['buyable'] == 'true' ? 1 : 0;
         $data['mastery'] = @$data['mastery'] == 'true' ? 1 : 0;
         $data['giftable'] = @$data['giftable'] == 'true' ? 1 : 0;
         if (!empty($data['code'])) {
             $realname = Units_GetRealnameByName($data['name']);
             $realname = str_replace("'", "''", $realname);
             $mfvSQL = " INSERT OR REPLACE INTO units(";
             $mfvSQL .= "units_name, units_type, units_code, units_buyable, ";
             $mfvSQL .= "units_class, units_iconurl, units_subtype, ";
             $mfvSQL .= "units_requiredLevel, units_sizeX, units_sizeY, ";
             $mfvSQL .= "units_market, units_cash, units_limitedstart, units_limitedend, ";
             $mfvSQL .= "units_cost, units_canplace, units_canrotate, units_capacity, units_finishedName, ";
             $mfvSQL .= "units_limit, units_iphoneonly, units_realname, units_upgrade, units_license, ";
             $mfvSQL .= "units_requirements, units_coinYield, units_growTime, units_plantXp, units_mastery, units_giftable) ";
             $mfvSQL .= "values('";
             $mfvSQL .= $data['name'] . "','" . $data['type'] . "','" . $data['code'] . "','";
             $mfvSQL .= $data['buyable'] . "','" . $data['classname'] . "','" . @$data['iconurl'] . "','";
             $mfvSQL .= $data['subtype'] . "','" . $data['requiredLevel'] . "','";
             $mfvSQL .= $data['sizeX'] . "','" . $data['sizeY'] . "','" . $data['market'] . "','";
             $mfvSQL .= $data['cash'] . "','" . $data['limitedstart'] . "','" . $data['limitedend'] . "','";
             $mfvSQL .= $data['cost'] . "','" . $data['canplace'] . "','" . $data['canrotate'] . "','";
             $mfvSQL .= $data['capacity'] . "','" . $data['finishedName'] . "','" . $data['limit'] . "','";
             $mfvSQL .= $data['iphoneonly'] . "','" . $realname . "','" . $data['upgrade'] . "','";
             $mfvSQL .= $data['license'] . "','" . $data['requirements'] . "','" . $data['coinYield'] . "','";
             $mfvSQL .= $data['growTime'] . "','" . $data['plantXp'] . "','" . $data['mastery'] . "','" . $data['giftable'] . "');";
             $this->_fvXMLDBU->queryExec($mfvSQL, $error);
             if (!empty($error)) {
                 AddLog2($error);
                 echo $mfvSQL . "\n";
             }
         }
     }
     $this->_fvXMLDBU->queryExec('COMMIT;', $error);
     if (!empty($error)) {
         AddLog2($error);
     }
     unset($xmlDoc);
     //Storage Information
     $xmlDoc = new DOMDocument();
     $xmlDoc->loadXML($doc4);
     $invent = $xmlDoc->getElementsByTagName('StorageEntity');
     $this->_fvXMLDBU->queryExec('BEGIN;');
     foreach ($invent as $inv) {
         $name = $inv->getAttribute('name');
         if ($name != 'Inventory') {
             continue;
         }
         $aClass = $inv->getElementsByTagName('allowedClass');
         foreach ($aClass as $aC) {
             $storeClass = $aC->getAttribute('type');
             $mfvSQL = " UPDATE OR IGNORE units ";
             $mfvSQL .= "SET units_canstore = '1'";
             $mfvSQL .= " WHERE units_class LIKE '%" . trim($storeClass) . "%' AND units_subtype <>'animal_pens'";
             $mfvSQL .= " AND units_subtype <> 'crafting' AND units_subtype <> 'storage'";
             $this->_fvXMLDBU->queryExec($mfvSQL, $error);
             if (!empty($error)) {
                 AddLog2($error);
                 echo $mfvSQL . "\n";
             }
         }
         $dClass = $inv->getElementsByTagName('nonStorableClass');
         foreach ($dClass as $dC) {
             $nonstoreClass = $dC->nodeValue;
             $mfvSQL = " UPDATE OR IGNORE units ";
             $mfvSQL .= "SET units_canstore = '0'";
             $mfvSQL .= " WHERE units_class LIKE '%" . trim($nonstoreClass) . "%';";
             $this->_fvXMLDBU->queryExec($mfvSQL, $error);
             if (!empty($error)) {
                 AddLog2($error);
                 echo $mfvSQL . "\n";
             }
         }
     }
     $this->_fvXMLDBU->queryExec('COMMIT;', $error);
     if (!empty($error)) {
         AddLog2($error);
     }
     unset($xmlDoc);
     $xmlDoc = new DOMDocument();
     //Crafting Recipe's
     $xmlDoc->loadXML($doc2);
     $items = $xmlDoc->getElementsByTagName("CraftingRecipe");
     $this->_fvXMLDBU->queryExec('BEGIN;');
     foreach ($items as $item) {
         $id = $item->getAttribute('id');
         $ingredients = $item->getElementsByTagName('Ingredient');
         $ing = array();
         foreach ($ingredients as $ingredient) {
             $in = $ingredient->getAttribute('itemCode');
             $qty = $ingredient->getAttribute('quantityRequired');
             $ing[$in] = $qty;
         }
         $ings = serialize($ing);
         $fU_SQL = "UPDATE OR IGNORE units SET units_ingredients = '" . $ings . "' WHERE units_code = '" . $id . "'";
         $this->_fvXMLDBU->queryExec($fU_SQL, $error);
         if (!empty($error)) {
             AddLog2($error);
             echo $fU_SQL . "\n";
         }
         unset($ing);
     }
     $this->_fvXMLDBU->queryExec('COMMIT;', $error);
     if (!empty($error)) {
         AddLog2($error);
     }
     $items = @$xmlDoc->getElementsByTagName("craftSkill");
     $this->_fvXMLDBU->queryExec('BEGIN;');
     foreach ($items as $item) {
         $id = $item->getAttribute('id');
         $buildings = @$item->getElementsByTagName('cottageBuilding');
         $building = @$buildings->item(0)->getAttribute('name');
         $fU_SQL = "UPDATE OR IGNORE units SET units_craftSkill = '" . $id . "' WHERE units_name = '" . $building . "'";
         $this->_fvXMLDBU->queryExec($fU_SQL, $error);
         if (!empty($error)) {
             AddLog2($error);
             echo $fU_SQL . "\n";
         }
         unset($ing);
     }
     $this->_fvXMLDBU->queryExec('COMMIT;', $error);
     if (!empty($error)) {
         AddLog2($error);
     }
     //Check Units Count
     $fvSQL = 'SELECT COUNT(*) AS ucount FROM units';
     $q = $this->_fvXMLDBU->query($fvSQL);
     $ucount = $q->fetchAll(SQLITE_ASSOC);
     if ($ucount[0]['ucount'] >= $iCount - 200) {
         AddLog2("Added {$iCount} items to units database");
     } else {
         AddLog2("Failed Adding Units - Report to RadicalLinux");
         return;
     }
     AddLog2('fvXML has finished updating units');
     $fvSQL = "INSERT OR REPLACE INTO settings(settings_name,settings_value) values('unitversion','" . $this->flashRevision . "')";
     $this->_fvXMLDBM->queryExec($fvSQL);
     unset($xmlDoc);
 }
Exemplo n.º 11
0
 function TEmptyXYSQL($loc, $amount)
 {
     $cont = true;
     $counter = 0;
     if (!in_array($loc, array("Animal", "Tree", "Decoration"))) {
         $cont = false;
     }
     if (!in_array($amount, array("ALL", "ONE"))) {
         $cont = false;
     }
     //$GB_Setting['userid']
     $minX = $this->GB_Setting[$loc . 'X1'];
     $minY = $this->GB_Setting[$loc . 'Y1'];
     $maxX = $this->GB_Setting[$loc . 'X2'];
     $maxY = $this->GB_Setting[$loc . 'Y2'];
     if ($cont) {
         @(list($level, $gold, $cash, $FarmSizeX, $FarmSizeY) = explode(';', fBGetDataStore('playerinfo')));
         if ($FarmSizeX == '' || $FarmSizeY == '') {
             $GB_place_items = "No";
             return;
         } else {
             $GB_place_items = "OK";
         }
         if (file_exists($_SESSION['base_path'] . "plugins/GiftBox/" . $this->GB_Setting['userid'] . "_" . GBox_XY_map)) {
             $MapXY = load_array(GBox_XY_map);
         } else {
             AddLog2("GB_XY_map.txt not found");
             return "Not indexed yet.";
         }
         $Map_pos_x = $minX;
         while ($Map_pos_x < $maxX) {
             $Map_pos_y = $minY;
             while ($Map_pos_y < $maxY) {
                 if (!array_key_exists($Map_pos_x . "-" . $Map_pos_y, $MapXY)) {
                     // empty position found
                     $EmptyXY['x'] = $Map_pos_x;
                     $EmptyXY['y'] = $Map_pos_y;
                     if ($amount == "ONE") {
                         $MapXY[$Map_pos_x . "-" . $Map_pos_y] = "temp_Giftbox";
                         save_array($MapXY, GBox_XY_map);
                         return $EmptyXY;
                     } else {
                         $counter++;
                     }
                 }
                 $Map_pos_y++;
             }
             $Map_pos_x++;
         }
         if ($amount == "ONE") {
             return "fail";
         }
         return $counter;
     } else {
         return "fail";
     }
     // paramter wrong
 }
Exemplo n.º 12
0
function GetUnitList()
{
    $vDir = 'farmville-xml';
    if (!file_exists($vDir)) {
        mkdir($vDir);
    }
    $time_limit = 7 * 24 * 60 * 60;
    // number of seconds to 'keep' the log DAYSxHOURSxMINSxSECS
    if ($df = opendir($vDir)) {
        while (false !== ($file = readdir($df))) {
            if ($file != "." && $file != "..") {
                $file1 = $vDir . '/' . $file;
                $last_modified = filemtime($file1);
                if (time() - $last_modified > $time_limit) {
                    unlink($file1);
                }
            }
        }
        closedir($df);
    }
    $vDir = 'farmville-sqlite';
    if (!file_exists($vDir)) {
        mkdir($vDir);
    }
    $time_limit = 7 * 24 * 60 * 60;
    // number of seconds to 'keep' the log DAYSxHOURSxMINSxSECS
    if ($df = opendir($vDir)) {
        while (false !== ($file = readdir($df))) {
            if ($file != "." && $file != "..") {
                $file1 = $vDir . '/' . $file;
                $last_modified = filemtime($file1);
                if (time() - $last_modified > $time_limit) {
                    unlink($file1);
                }
            }
        }
        closedir($df);
    }
    $sqlite_update = 0;
    //if 1 we are going to download new xml from server
    // check settings table
    if (@$_SESSION['vDataStoreDB']->querySingle('SELECT * FROM settings limit 1') === false) {
        $vSQL = 'CREATE TABLE
              settings (
                settings_name CHAR(25) PRIMARY KEY,
                settings_value CHAR(25)
              )';
        $_SESSION['vDataStoreDB']->exec($vSQL);
    }
    // check datastore table
    if (@$_SESSION['vDataStoreDB']->querySingle('SELECT * FROM datastore limit 1') === false) {
        $vSQL = 'CREATE TABLE
              datastore (
                userid CHAR(25),
                storetype CHAR(25),
                content BLOB,
                PRIMARY KEY (userid, storetype)
              )';
        $_SESSION['vDataStoreDB']->exec($vSQL);
    }
    // check datastore table
    if (@$_SESSION['vRewardStoreDB']->querySingle('SELECT * FROM rewardstore limit 1') === false) {
        $vSQL = 'CREATE TABLE
              rewardstore (
                userid CHAR(25),
                storetype CHAR(25),
                content BLOB,
                PRIMARY KEY (userid, storetype)
              )';
        $_SESSION['vRewardStoreDB']->exec($vSQL);
    }
    // check userids table
    if (@$_SESSION['vDataStoreDB']->querySingle('SELECT * FROM userids limit 1') === false) {
        $vSQL = 'CREATE TABLE
              userids (
                userid CHAR(25) PRIMARY KEY,
                username CHAR(25)
              )';
        $_SESSION['vDataStoreDB']->exec($vSQL);
    }
    if (@$_SESSION['vDataStoreDB']->querySingle('SELECT * FROM neighbors limit 1') === false) {
        $vSQL = 'CREATE TABLE
              neighbors (
                neighborid CHAR(25) PRIMARY KEY,
                fullname CHAR(50),
                profilepic TEXT
              )';
        $_SESSION['vDataStoreDB']->exec($vSQL);
    }
    // check units table
    if (@$_SESSION['vDataDB']->querySingle('SELECT * FROM units limit 1') === false) {
        $vSQL = 'CREATE TABLE
              units (
                name CHAR(25),
                field CHAR(25),
                content CHAR(250)
              )';
        $_SESSION['vDataDB']->exec($vSQL);
        $_SESSION['vDataDB']->exec('CREATE INDEX units_idx_1 ON units(name,field)');
        $_SESSION['vDataDB']->exec('CREATE INDEX units_idx_2 ON units(field,content)');
        $sqlite_update = 1;
    }
    // check achievements table
    if (@$_SESSION['vDataDB']->querySingle('SELECT * FROM achievements limit 1') === false) {
        $vSQL = 'CREATE TABLE
              achievements (
                name CHAR(25),
                field CHAR(25),
                content CHAR(250)
              )';
        $_SESSION['vDataDB']->exec($vSQL);
        $_SESSION['vDataDB']->exec('CREATE INDEX achievements_idx_1 ON achievements(name,field)');
        $_SESSION['vDataDB']->exec('CREATE INDEX achievements_idx_2 ON achievements(field,content)');
        $sqlite_update = 1;
    }
    // check collectables table
    if (@$_SESSION['vDataDB']->querySingle('SELECT * FROM collectables limit 1') === false) {
        $vSQL = 'CREATE TABLE
              collectables (

                name CHAR(25),
                field CHAR(25),
                content CHAR(250)
              )';
        $_SESSION['vDataDB']->exec($vSQL);
        $_SESSION['vDataDB']->exec('CREATE INDEX collectables_idx_1 ON collectables(name,field)');
        $_SESSION['vDataDB']->exec('CREATE INDEX collectables_idx_2 ON collectables(field,content)');
        $sqlite_update = 1;
    }
    // check storage table
    if (@$_SESSION['vDataDB']->query('SELECT * FROM storage limit 1') === false) {
        $vSQL = 'CREATE TABLE
              storage (
                name CHAR(25),
                field CHAR(25),
                content CHAR(250)
              )';
        $_SESSION['vDataDB']->exec($vSQL);
        $_SESSION['vDataDB']->exec('CREATE INDEX storage_idx_1 ON storage(name,field)');
        $_SESSION['vDataDB']->exec('CREATE INDEX storage_idx_2 ON storage(field,content)');
        $sqlite_update = 1;
    }
    // check crafting table
    if (@$_SESSION['vDataDB']->query('SELECT * FROM crafting limit 1') === false) {
        $vSQL = 'CREATE TABLE
              crafting (
                name CHAR(25),
                field CHAR(25),
                content CHAR(250)
              )';
        $_SESSION['vDataDB']->query($vSQL);
        $_SESSION['vDataDB']->query('CREATE INDEX crafting_idx_1 ON crafting(name,field)');
        $_SESSION['vDataDB']->query('CREATE INDEX crafting_idx_2 ON crafting(field,content)');
        $sqlite_update = 1;
    }
    // check quests table
    if (@$_SESSION['vDataDB']->query('SELECT * FROM quests limit 1') === false) {
        $vSQL = 'CREATE TABLE
              quests (
                name CHAR(25),
                field CHAR(50),
                content CHAR(250)
              )';
        $_SESSION['vDataDB']->query($vSQL);
        $_SESSION['vDataDB']->query('CREATE INDEX quests_idx_1 ON quests(name,field)');
        $_SESSION['vDataDB']->query('CREATE INDEX quests_idx_2 ON quests(field,content)');
        $sqlite_update = 1;
    }
    // Force download when key files are missing
    if (!file_exists('units.txt')) {
        $sqlite_update = 1;
    }
    if (!file_exists('collectable_info.txt')) {
        $sqlite_update = 1;
    }
    if (!file_exists('achievement_info.txt')) {
        $sqlite_update = 1;
    }
    $flashVars = parse_flashvars();
    $vGameSetting = 'farmville-xml/' . $_SESSION['flashRevision'] . '_gameSettings.xml';
    if (!file_exists($vGameSetting)) {
        $xml_units = '';
        if (!$xml_units) {
            AddLog2($flashVars['game_config_url']);
            AddLog2('DL: v' . $_SESSION['flashRevision'] . ' settings file.');
            //$geturl = 'http://static-facebook.farmville.com/v' . $_SESSION['flashRevision'] . '/gameSettings.xml.gz';
            $geturl = $flashVars['game_config_url'];
            $xml_units = gzuncompress(proxy_GET($geturl));
        }
        if (!$xml_units) {
            AddLog2('Couldn\'t find a settings xml...');
        } else {
            AddLog2('Download completed.');
            file_put_contents($vGameSetting, $xml_units);
            $sqlite_update = 1;
        }
        unset($xml_units);
    }
    $vItemsSetting = 'farmville-xml/' . $_SESSION['flashRevision'] . '_items.xml';
    if (!file_exists($vItemsSetting)) {
        $xml_items = '';
        if (!$xml_items) {
            AddLog2($flashVars['items_url']);
            AddLog2('DL: v' . $_SESSION['flashRevision'] . ' items xml.');
            //$geturl = 'http://static-facebook.farmville.com/v' . $_SESSION['flashRevision'] . '/items.xml.gz';
            $geturl = $flashVars['items_url'];
            $xml_items = gzuncompress(proxy_GET($geturl));
        }
        if (!$xml_items) {
            AddLog2('Couldn\'t find a items xml...');
        } else {
            AddLog2('Download completed.');
            file_put_contents($vItemsSetting, $xml_items);
            $sqlite_update = 1;
        }
        unset($xml_items);
    }
    $vStorageConfig = 'farmville-xml/' . $_SESSION['flashRevision'] . '_StorageConfig.xml';
    if (!file_exists($vStorageConfig)) {
        $xml_storage = '';
        AddLog2('DL: v' . $_SESSION['flashRevision'] . ' storageconfig xml');
        if (isset($flashVars['xml_url']) && !empty($flashVars['xml_url'])) {
            $geturl = $flashVars['xml_url'] . 'StorageConfig.xml.gz';
        } else {
            $geturl = $flashVars['app_url'] . 'v' . $_SESSION['flashRevision'] . '/StorageConfig.xml.gz';
        }
        $xml_storage = gzuncompress(proxy_GET($geturl));
        if (!$xml_storage) {
            AddLog2('Couldn\'t find a storageconfig xml...');
        } else {
            AddLog2('Download completed.');
            file_put_contents($vStorageConfig, $xml_storage);
            $sqlite_update = 1;
        }
        unset($xml_storage);
    }
    $vQuestsConfig = 'farmville-xml/' . $_SESSION['flashRevision'] . '_Quests.xml';
    if (!file_exists($vQuestsConfig)) {
        $xml_quests = '';
        $geturl = $flashVars['social_quest_url'];
        AddLog2('DL: v' . $_SESSION['flashRevision'] . ' quests xml');
        //$geturl = 'http://static-facebook.farmville.com/v' . $_SESSION['flashRevision'] . '/quests.xml';
        $xml_quests = gzuncompress(proxy_GET($geturl));
        if (!$xml_quests) {
            AddLog2('Couldn\'t find a quests xml...');
        } else {
            AddLog2('Download completed.');
            file_put_contents($vQuestsConfig, $xml_quests);
            $sqlite_update = 1;
        }
        unset($xml_quests);
    }
    $vCraftingConfig = 'farmville-xml/' . $_SESSION['flashRevision'] . '_Crafting.xml';
    if (!file_exists($vCraftingConfig)) {
        $xml_crafting = '';
        AddLog2('DL: v' . $_SESSION['flashRevision'] . ' crafting xml');
        if (isset($flashVars['xml_url']) && !empty($flashVars['xml_url'])) {
            $geturl = $flashVars['xml_url'] . 'crafting.xml.gz';
        } else {
            $geturl = $flashVars['app_url'] . 'v' . $_SESSION['flashRevision'] . '/crafting.xml.gz';
        }
        $xml_crafting = gzuncompress(proxy_GET($geturl));
        if (!$xml_crafting) {
            AddLog2('Couldn\'t find a crafting xml...');
        } else {
            AddLog2('Download completed.');
            file_put_contents($vCraftingConfig, $xml_crafting);
            $sqlite_update = 1;
        }
        unset($xml_crafting);
    }
    if ($sqlite_update == 1) {
        $_SESSION['vDataDB']->exec('BEGIN TRANSACTION');
        $_SESSION['vDataDB']->exec('delete from units');
        $_SESSION['vDataDB']->exec('delete from achievements');
        $_SESSION['vDataDB']->exec('delete from collectables');
        $_SESSION['vDataDB']->exec('delete from storage');
        $_SESSION['vDataDB']->exec('delete from crafting');
        $_SESSION['vDataDB']->exec('delete from quests');
        $_SESSION['vDataDB']->exec('COMMIT TRANSACTION');
        $_SESSION['vDataDB']->exec('vacuum');
        $_SESSION['vDataDB']->exec('BEGIN TRANSACTION');
        $xmlDoc = simplexml_load_file($vItemsSetting);
        $itemsarray = objectsIntoArray($xmlDoc);
        //file_put_contents('testarray.txt', print_r($array,true));
        foreach ($itemsarray['items']['item'] as $item) {
            $itemName = $item['@attributes']['name'];
            foreach ($item as $key => $field) {
                if ($key == '@attributes') {
                    foreach ($field as $key1 => $attr) {
                        $_SESSION['vDataDB']->exec('insert into units(name,field,content) values("' . $itemName . '","' . $key1 . '","' . $attr . '");');
                    }
                    continue;
                }
                if ($key == 'image') {
                    foreach ($field as $key1 => $attr) {
                        if ($attr['name'] == 'icon') {
                            $_SESSION['vDataDB']->exec('insert into units(name,field,content) values("' . $itemName . '","iconurl","' . $attr['url'] . '");');
                            break;
                        }
                        if ($attr['@attributes']['name'] == 'icon') {
                            $_SESSION['vDataDB']->exec('insert into units(name,field,content) values("' . $itemName . '","iconurl","' . $attr['@attributes']['url'] . '");');
                            break;
                        }
                    }
                    continue;
                }
                if ($key == 'masteryLevel') {
                    foreach ($field as $key1 => $attr) {
                        if (isset($attr['@attributes']['gift'])) {
                            $_SESSION['vDataDB']->exec('insert into units(name,field,content) values("' . $itemName . '","masterymax","' . $attr['@attributes']['count'] . '");');
                            break;
                        }
                        if (isset($attr['gift'])) {
                            $_SESSION['vDataDB']->exec('insert into units(name,field,content) values("' . $itemName . '","masterymax","' . $attr['count'] . '");');
                            break;
                        }
                    }
                    continue;
                }
                if (is_array($field)) {
                    $_SESSION['vDataDB']->exec("insert into units(name,field,content) values('" . $itemName . "','" . $key . "','" . serialize($field) . "');");
                } else {
                    $_SESSION['vDataDB']->exec('insert into units(name,field,content) values("' . $itemName . '","' . $key . '","' . $field . '");');
                }
            }
        }
        $xmlDoc = simplexml_load_file($vGameSetting);
        foreach ($xmlDoc->farming as $vItem) {
            foreach ($vItem->attributes() as $vField => $vContent) {
                $_SESSION['vDataDB']->exec('insert into units(name,field,content) values("_farming","' . $vField . '","' . $vContent . '");');
            }
        }
        foreach ($xmlDoc->collections->collection as $vItem) {
            $vItemName = (string) $vItem['name'];
            if (strlen($vItemName) > 0) {
                foreach ($vItem->attributes() as $vField => $vContent) {
                    $_SESSION['vDataDB']->exec('insert into collectables(name,field,content) values("' . $vItemName . '","' . $vField . '","' . $vContent . '");');
                }
                foreach ($vItem->children() as $vSubName => $vSubElement) {
                    if ($vSubName == 'collectable') {
                        $_SESSION['vDataDB']->query('insert into collectables(name,field,content) values("' . $vItemName . '","collectable","' . $vSubElement['code'] . '");');
                        if (isset($vSubElement['chance'])) {
                            $_SESSION['vDataDB']->exec('insert into collectables(name,field,content) values("' . $vSubElement['code'] . '","chance","' . $vSubElement['chance'] . '");');
                        }
                        if (isset($vSubElement['rarity'])) {
                            $_SESSION['vDataDB']->exec('insert into collectables(name,field,content) values("' . $vSubElement['code'] . '","rarity","' . $vSubElement['rarity'] . '");');
                        }
                        if (isset($vSubElement['source'])) {
                            $_SESSION['vDataDB']->exec('insert into collectables(name,field,content) values("' . $vSubElement['code'] . '","source","' . $vSubElement['source'] . '");');
                        }
                        if (isset($vSubElement['numneeded'])) {
                            $_SESSION['vDataDB']->exec('insert into collectables(name,field,content) values("' . $vSubElement['code'] . '","numneeded","' . $vSubElement['numneeded'] . '");');
                        }
                    }
                    if ($vSubName == 'tradeInReward') {
                        if (isset($vSubElement['xp'])) {
                            $_SESSION['vDataDB']->exec('insert into collectables(name,field,content) values("' . $vItemName . '","tradeInReward_xp","' . $vSubElement['xp'] . '");');
                        }
                        if (isset($vSubElement['coins'])) {
                            $_SESSION['vDataDB']->exec('insert into collectables(name,field,content) values("' . $vItemName . '","tradeInReward_coins","' . $vSubElement['coins'] . '");');
                        }
                        if (isset($vSubElement['gift'])) {
                            $_SESSION['vDataDB']->exec('insert into collectables(name,field,content) values("' . $vItemName . '","tradeInReward_gift","' . $vSubElement['gift'] . '");');
                        }
                    }
                }
            }
        }
        foreach ($xmlDoc->achievements->achievement as $vItem) {
            $vItemName = (string) $vItem['name'];
            $_SESSION['vDataDB']->exec('insert into units(name,field,content) values("' . $vItemName . '","type","achieve");');
            if (strlen($vItemName) > 0) {
                foreach ($vItem->attributes() as $vField => $vContent) {
                    $_SESSION['vDataDB']->exec('insert into achievements(name,field,content) values("' . $vItemName . '","' . $vField . '","' . $vContent . '");');
                    $_SESSION['vDataDB']->exec('insert into units(name,field,content) values("' . $vItemName . '","' . $vField . '","' . $vContent . '");');
                }
                foreach ($vItem->children() as $vSubName => $vSubElement) {
                    if ($vSubName == 'image') {
                        if ($vSubElement['name'] == 'icon_48') {
                            $_SESSION['vDataDB']->exec('insert into achievements(name,field,content) values("' . $vItemName . '","iconurl","' . $vSubElement['url'] . '");');
                            $_SESSION['vDataDB']->exec('insert into units(name,field,content) values("' . $vItemName . '","iconurl","' . $vSubElement['url'] . '");');
                        }
                    } elseif ($vSubName = 'level') {
                        $_SESSION['vDataDB']->exec('insert into achievements(name,field,content) values("' . $vItemName . '","count","' . $vSubElement['count'] . '");');
                        $_SESSION['vDataDB']->exec('insert into achievements(name,field,content) values("' . $vItemName . '","xp","' . $vSubElement['xp'] . '");');
                        $_SESSION['vDataDB']->exec('insert into achievements(name,field,content) values("' . $vItemName . '","coins","' . $vSubElement['coins'] . '");');
                    }
                }
            }
        }
        unset($xmlDoc);
        //$xmlDoc = simplexml_load_file($vStorageConfig);
        $XML_string = file_get_contents($vStorageConfig);
        $obj = new xml2array($XML_string);
        $itemsarray = $obj->getResult();
        foreach ($itemsarray['storage']['StorageBuilding'] as $item) {
            $itemName = $item['name'];
            unset($item['metadata'], $item['#comment']);
            foreach ($item as $key => $value) {
                if (is_array($value) && count($value) == 1) {
                    $_SESSION['vDataDB']->exec('insert into storage(name,field,content) values("' . $itemName . '","' . $key . '","' . implode('', $value) . '");');
                } elseif (is_string($value)) {
                    $_SESSION['vDataDB']->exec('insert into storage(name,field,content) values("' . $itemName . '","' . $key . '","' . $value . '");');
                } else {
                    $_SESSION['vDataDB']->exec("insert into storage(name,field,content) values('" . $itemName . "','" . $key . "','" . serialize($value) . "');");
                }
            }
        }
        foreach ($itemsarray['storage']['FeatureCreditStorage'] as $item) {
            $itemName = $item['name'];
            unset($item['metadata'], $item['#comment']);
            foreach ($item as $key => $value) {
                if (is_array($value) && count($value) == 1) {
                    $_SESSION['vDataDB']->exec('insert into storage(name,field,content) values("' . $itemName . '","' . $key . '","' . implode('', $value) . '");');
                } elseif (is_string($value)) {
                    $_SESSION['vDataDB']->exec('insert into storage(name,field,content) values("' . $itemName . '","' . $key . '","' . $value . '");');
                } else {
                    $_SESSION['vDataDB']->exec("insert into storage(name,field,content) values('" . $itemName . "','" . $key . "','" . serialize($value) . "');");
                }
            }
        }
        $xmlDoc = simplexml_load_file($vCraftingConfig);
        foreach ($xmlDoc->recipes->CraftingRecipe as $vRecipe) {
            $vRecipeID = (string) $vRecipe['id'];
            if (strlen($vRecipeID) > 0) {
                $vRecipeName = '';
                foreach ($vRecipe->attributes() as $vField => $vContent) {
                    $_SESSION['vDataDB']->query('insert into crafting(name,field,content) values("' . $vRecipeID . '","' . $vField . '","' . $vContent . '");');
                }
                foreach ($vRecipe->children() as $vSubName => $vSubElement) {
                    if ($vSubName == 'name') {
                        $vRecipeName = (string) $vSubElement;
                    }
                    if ($vSubName == 'image') {
                        if ($vSubElement['name'] == 'icon') {
                            $_SESSION['vDataDB']->exec('insert into crafting(name,field,content) values("' . $vRecipeID . '","iconurl","' . $vSubElement['url'] . '");');
                        }
                    } elseif ($vSubName == 'Reward') {
                        foreach ($vSubElement->children() as $vSubSubName => $vSubSubElement) {
                            foreach ($vSubSubElement->attributes() as $vField => $vContent) {
                                $_SESSION['vDataDB']->exec('insert into crafting(name,field,content) values("' . $vRecipeID . '","reward_' . $vSubSubName . '_' . $vField . '","' . (string) $vContent . '");');
                            }
                        }
                    } elseif ($vSubName == 'Ingredients') {
                        foreach ($vSubElement->children() as $vSubSubName => $vSubSubElement) {
                            $_SESSION['vDataDB']->exec('insert into crafting(name,field,content) values("' . $vRecipeID . '","Ingredient_itemCode","' . $vSubSubElement['itemCode'] . '");');
                            $_SESSION['vDataDB']->exec('insert into crafting(name,field,content) values("' . $vRecipeID . '","Ingredient_quantityRequired_' . $vSubSubElement['itemCode'] . '","' . $vSubSubElement['quantityRequired'] . '");');
                        }
                    } else {
                        $_SESSION['vDataDB']->exec('insert into crafting(name,field,content) values("' . $vRecipeID . '","' . $vSubName . '","' . (string) $vSubElement . '");');
                    }
                }
                if (strlen($vRecipeName) > 0) {
                    $_SESSION['vDataDB']->exec('update crafting set name="' . $vRecipeName . '" where name="' . $vRecipeID . '"');
                }
            }
        }
        unset($xmlDoc);
        $xmlDoc = simplexml_load_file($vQuestsConfig);
        foreach ($xmlDoc->quest as $vQuest) {
            $vQuestID = (string) $vQuest['id'];
            if (strlen($vQuestID) > 0) {
                foreach ($vQuest->attributes() as $vField => $vContent) {
                    $_SESSION['vDataDB']->exec('insert into quests(name,field,content) values("' . $vQuestID . '","' . $vField . '","' . $vContent . '");');
                }
                foreach ($vQuest->children() as $vSubName => $vSubElement) {
                    if ($vSubName == 'text') {
                        foreach ($vSubElement->attributes() as $vField => $vContent) {
                            $_SESSION['vDataDB']->exec('insert into quests(name,field,content) values("' . $vQuestID . '","' . $vField . '","' . (string) $vContent . '");');
                        }
                    } elseif ($vSubName == 'icon') {
                        $_SESSION['vDataDB']->exec('insert into quests(name,field,content) values("' . $vQuestID . '","iconurl","' . $vSubElement['url'] . '");');
                    } elseif ($vSubName == 'questGiverImage') {
                        $_SESSION['vDataDB']->exec('insert into quests(name,field,content) values("' . $vQuestID . '","questGiverImage","' . $vSubElement['url'] . '");');
                    } elseif ($vSubName == 'completionRequirements') {
                        $vCompleteName = $vSubElement['name'];
                        $_SESSION['vDataDB']->exec('insert into quests(name,field,content) values("' . $vQuestID . '","completionRequirements_' . $vCompleteName . '","' . $vCompleteName . '");');
                        $_SESSION['vDataDB']->exec('insert into quests(name,field,content) values("' . $vQuestID . '","completionRequirements_' . $vCompleteName . '_timeLimit","' . $vSubElement['timeLimit'] . '");');
                        foreach ($vSubElement->children() as $vSubSubName => $vSubSubElement) {
                            if ($vSubSubName == 'requirement') {
                                $_SESSION['vDataDB']->exec('insert into quests(name,field,content) values("' . $vQuestID . '","completionRequirements_' . $vCompleteName . '_' . (string) $vSubSubElement['action'] . '_' . (string) $vSubSubElement['type'] . '","' . (string) $vSubSubElement['many'] . '");');
                            }
                            if ($vSubSubName == 'reward') {
                                $_SESSION['vDataDB']->exec('insert into quests(name,field,content) values("' . $vQuestID . '","completionRequirements_' . $vCompleteName . '_reward_coins","' . (string) $vSubSubElement['coins'] . '");');
                                $_SESSION['vDataDB']->exec('insert into quests(name,field,content) values("' . $vQuestID . '","completionRequirements_' . $vCompleteName . '_reward_experience","' . (string) $vSubSubElement['experience'] . '");');
                            }
                        }
                    } else {
                        $_SESSION['vDataDB']->exec('insert into quests(name,field,content) values("' . $vQuestID . '","' . $vSubName . '","' . (string) $vSubElement . '");');
                    }
                }
            }
        }
        unset($xmlDoc);
        $_SESSION['vDataDB']->query('COMMIT TRANSACTION');
        $vCollectable = array();
        // create collectable_info.txt
        $vSQL = 'select * from collectables where field="code"';
        $vResult = $_SESSION['vDataDB']->query($vSQL);
        while ($vRow = $vResult->fetchArray(SQLITE3_ASSOC)) {
            $vCollectable[$vRow['content']]['name'] = $vRow['name'];
            $vCollectable[$vRow['content']]['code'] = $vRow['content'];
            $vSQL2 = 'select content from collectables where name="' . $vRow['name'] . '" and field="tradeInReward_xp"';
            $vCollectable[$vRow['content']]['tradeInReward'] = $_SESSION['vDataDB']->querySingle($vSQL2);
            $vSQL2 = 'select content from collectables where name="' . $vRow['name'] . '" and field="realname"';
            $vCollectable[$vRow['content']]['realname'] = $_SESSION['vDataDB']->querySingle($vSQL2);
            $vSQL2 = 'select content from collectables where name="' . $vRow['name'] . '" and field="collectable"';
            $vResult2 = $_SESSION['vDataDB']->query($vSQL2);
            while ($vRow2 = $vResult2->fetchArray(SQLITE3_ASSOC)) {
                $vCollectable[$vRow['content']]['collectable'][] = $vRow2['content'];
            }
        }
        file_put_contents('collectable_info.txt', serialize($vCollectable));
        unset($vCollectable);
        $vAchievements = array();
        $vSQL = 'select * from achievements where field="code"';
        $vResult = $_SESSION['vDataDB']->query($vSQL);
        while ($vRow = $vResult->fetchArray(SQLITE3_ASSOC)) {
            $vAchievements[$vRow['content']]['name'] = $vRow['name'];
            $vAchievements[$vRow['content']]['code'] = $vRow['content'];
            $vSQL2 = 'select content from achievements where name="' . $vRow['name'] . '" and field="iconurl"';
            $vAchievements[$vRow['content']]['iconurl'] = $_SESSION['vDataDB']->querySingle($vSQL2);
            $vSQL2 = 'select content from achievements where name="' . $vRow['name'] . '" and field="realname"';
            $vAchievements[$vRow['content']]['realname'] = $_SESSION['vDataDB']->querySingle($vSQL2);
            $vSQL2 = 'select content from achievements where name="' . $vRow['name'] . '" and field="desc"';
            $vAchievements[$vRow['content']]['desc'] = $_SESSION['vDataDB']->querySingle($vSQL2);
            $vSQL2 = 'select content from achievements where name="' . $vRow['name'] . '" and field="count" order by field';
            $vResult2 = $_SESSION['vDataDB']->query($vSQL2);
            while ($vRow2 = $vResult2->fetchArray(SQLITE3_ASSOC)) {
                $vAchievements[$vRow['content']]['level'][] = $vRow2['content'];
            }
        }
        file_put_contents('achievement_info.txt', serialize($vAchievements));
        unset($vAchievements);
        file_put_contents('units.txt', serialize(Units_GetAll()));
        file_put_contents('sqlite_check.txt', $_SESSION['flashRevision']);
    }
    EchoData('OK');
}
Exemplo n.º 13
0
 function _fvPlantQuests($plots)
 {
     if (empty($plots)) {
         return;
     }
     sort($plots);
     $quest = @$this->settings['coop'];
     if (empty($quest)) {
         return;
     }
     AddLog2("Planting for Crafts");
     $questinfo = Quests_GetByCode($quest);
     $qkeys = array_keys($questinfo);
     foreach ($qkeys as $qkey) {
         if (stripos($qkey, 'completionRequirements_bronze_seed_') !== false) {
             $qseed = str_replace('completionRequirements_bronze_seed_', '', $qkey);
             $qseeds[$qseed] = $questinfo[$qkey];
         }
     }
     $seedcnt = array_sum($qseeds);
     $seed_plots = array();
     $emptyplots = count($plots);
     $i = 0;
     foreach ($qseeds as $seed => $cnt) {
         if (empty($plots)) {
             break;
         }
         $seedpercent = ceil($emptyplots * ($cnt / $seedcnt));
         $seedpercent = $seedpercent < 1 ? 1 : $seedpercent;
         for ($x = 0; $x < $seedpercent; $x++) {
             if (empty($plots)) {
                 break 2;
             }
             $plots[$i]['itemName'] = $seed;
             $seed_plots[] = $plots[$i];
             unset($plots[$i]);
             $i++;
         }
     }
     if (count($seed_plots) > 0) {
         $this->_fvPlotWork($seed_plots, 'place');
     }
 }
Exemplo n.º 14
0
 private function _acceptGifts()
 {
     $giftReqs = $this->_getGifts();
     $gBCount = count(unserialize(fBGetDataStore('ingiftbox')));
     $cBCount = count(unserialize(fBGetDataStore('inconbox')));
     AddLog2('fBGifts: ' . count($giftReqs) . ' Gifts On Gift Page');
     $giftSettings = unserialize($this->settings['giftopts']);
     if (is_array($giftReqs)) {
         if (count($giftReqs) > 0) {
             $count = 0;
             foreach ($giftReqs as $key => $data) {
                 if (!isset($giftSettings[$data['app_id'] . '_accept'])) {
                     continue;
                 }
                 if ($gBCount + $cBCount >= 500 && $data['app_id'] == '102452128776') {
                     AddLog2('fBGifts: Giftbox or Consumable Box Full, Skipping Farmville Gift');
                     continue;
                 } elseif ($data['app_id'] == '102452128776') {
                     $gBCount++;
                 }
                 $count++;
                 $accepted = 0;
                 $returned = 0;
                 //Remove Link From Gifts Page
                 $discard = $this->_fBGiftsPost("http://www.facebook.com/ajax/reqs.php?__a=1", $data['post_data']);
                 //file_put_contents('debug/data.txt', print_r($data,true), FILE_APPEND);
                 //Submit the link to goto the page
                 $giftAction = $this->_fBGiftsGet($data['action_url']);
                 //file_put_contents('debug/data.txt', $giftAction, FILE_APPEND);
                 if (!empty($giftAction)) {
                     $accepted = 1;
                     AddLog2("[{$count}] fBGifts: Accept Gift From " . $data['app_name'] . ' - Success');
                 } else {
                     $accepted = 9;
                     AddLog2("[{$count}] fBGifts: Accept Gift From " . $data['app_name'] . ' - Failed');
                 }
                 if (isset($giftSettings[$data['app_id'] . '_return']) && $accepted == 1) {
                     preg_match_all('/class="fb_protected_wrapper"><form(.*?)<\\/div>/ims', $giftAction, $forms);
                     foreach ($forms[0] as $key => $form) {
                         if (stripos($form, "thank you") !== false || stripos($form, 'send to') !== false || stripos($form, 'é€') !== false) {
                             $postdata = array();
                             $arr1 = '';
                             $arr2 = '';
                             preg_match_all('/.*action="([^"]*)".*/ims', $form, $acts);
                             preg_match_all('/.*giftRecipient=([^&]*).*type="([^"]*)".*content="([^"]*)".*id="([^"]*)".*post_form_id=([^&]*).*/ims', $form, $fields);
                             preg_match('/content="([^"]*)"/sim', $form, $content);
                             //AddLog2(print_r($content,true));
                             $form = html_entity_decode($form);
                             preg_match_all('/PlatformInvite.*\\{(.*)\\}/sim', $form, $newfields);
                             $newdata = str_replace('"', '', $newfields[1][0]);
                             $arr1 = explode(',', $newdata);
                             foreach ($arr1 as $tmpdata) {
                                 $tmp = explode(':', $tmpdata);
                                 $arr2[$tmp[0]] = $tmp[1];
                             }
                             $postdata['app_id'] = $data['app_id'];
                             $postdata['to_ids[0]'] = $arr2['prefill'];
                             $postdata['request_type'] = urlencode($arr2['request_type']);
                             $postdata['invite'] = $arr2['invite'];
                             $postdata['content'] = urlencode($content[1]);
                             $postdata['preview'] = 'true';
                             $postdata['is_multi'] = $arr2['is_multi'];
                             $postdata['is_in_canvas'] = $arr2['is_in_canvas'];
                             $postdata['form_id'] = $arr2['request_form'];
                             $postdata['prefill'] = 'true';
                             $postdata['message'] = '';
                             $postdata['donot_send'] = 'false';
                             $postdata['include_ci'] = $arr2['include_ci'];
                             $postdata['__d'] = 1;
                             $postdata['post_form_id'] = $fields[5][0];
                             $postdata['fb_dtsg'] = $data['fb_dtsg'];
                             $postdata['lsd'] = null;
                             $postdata['post_form_id_source'] = 'AsyncRequest';
                             $discard = $this->_fBGiftsPost("http://apps.facebook.com/fbml/ajax/prompt_send.php?__a=1", $postdata);
                             //file_put_contents('debug/discard.txt', $discard, FILE_APPEND);
                             //unset($postdata['request_type']);
                             //$postdata['&request_type'] = urlencode($arr2['request_type']);
                             $postdata['preview'] = 'false';
                             $retGift = $this->_fBGiftsPost("http://apps.facebook.com/fbml/ajax/prompt_send.php?__a=1", $postdata);
                             //AddLog2($acts[1][0]);
                             $retGift2 = $this->_fBGiftsPost(html_entity_decode($acts[1][0]), array());
                             if (stripos(strip_tags($retGift), '"error":0')) {
                                 $returned = 1;
                                 AddLog2("[{$count}] fBGifts: Returned Gift From " . $data['app_name'] . ' - Success');
                             } else {
                                 $returned = 9;
                                 AddLog2("[{$count}] fBGifts: Returned Gift From " . $data['app_name'] . ' - Failed');
                             }
                             //file_put_contents('debug/postdata.txt', print_r($postdata,true), FILE_APPEND);
                             //file_put_contents('debug/formdata.txt', print_r($form,true), FILE_APPEND);
                             //file_put_contents('debug/giftaction.txt', $giftAction, FILE_APPEND);
                             //file_put_contents('debug/returngift.txt', $retGift, FILE_APPEND);
                             //file_put_contents('debug/returngift2.txt', $retGift2, FILE_APPEND);
                             //sleep(500);
                             break;
                         }
                     }
                 }
                 $data['gift_text'] = str_replace("'", "''", @$data['gift_text']);
                 $fvSQL = "INSERT INTO giftlog(giftlog_timestamp, giftlog_appname, giftlog_text, giftlog_link, giftlog_accept, giftlog_return) " . "values('" . time() . "','" . $data['app_name'] . "','" . $data['gift_text'] . "','" . $data['action_url'] . "','{$accepted}', '{$returned}')";
                 $this->_fBGiftsDBM->queryExec($fvSQL, $error);
                 if (!empty($error)) {
                     AddLog2($error . " " . $fvSQL);
                 }
             }
         }
     }
 }
Exemplo n.º 15
0
 private function _fvLinksGet($url = '')
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, 45);
     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SearchToolbar 1.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)');
     curl_setopt($ch, CURLOPT_COOKIE, $this->_fvLinksGetCookie());
     curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Language: en-US', 'Pragma: no-cache'));
     if ($_SESSION['use_proxy']) {
         curl_setopt($ch, CURLOPT_PROXY, trim($_SESSION['proxy_settings'][0]));
         curl_setopt($ch, CURLOPT_PROXYPORT, intval($_SESSION['proxy_settings'][1]));
         if (isset($_SESSION['proxy_settings'][2]) && isset($_SESSION['proxy_settings'][3])) {
             // is set proxy user and password
             $authorization = trim($_SESSION['proxy_settings'][2]) . ':' . trim($_SESSION['proxy_settings'][3]);
             curl_setopt($ch, CURLOPT_PROXYUSERPWD, $authorization);
             curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
         }
     }
     $response = curl_exec($ch);
     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if ($httpCode == 404) {
         AddLog2("fvLinks: Error 404/Page Not Found");
         return;
     }
     if ($httpCode == 500) {
         AddLog2("fvLinks: Error 500/Internal Server Error");
         return;
     }
     if (empty($response)) {
         AddLog2("fvLinks: Empty Response Returned");
         return;
     }
     curl_close($ch);
     return $response;
 }
Exemplo n.º 16
0
function GB_AMF_Error($res)
{
    AddLog2("GiftBox Oops.. that was wrong.. : {$res}");
    return;
}
Exemplo n.º 17
0
function fBSettings_init()
{
    if (FB_PARSER_VER != FB_SETTINGS_VER) {
        AddLog2("******ERROR: faceBot's updated settings version (" . FB_SETTINGS_VER . ") doesn't match parser version (" . FB_PARSER_VER . ")******");
    }
}
Exemplo n.º 18
0
function Parser_SQlite_Connect($vDBFile)
{
    $vDB = new SQLite3($vDBFile);
    if (!$vDB) {
        AddLog2('Parser SQlite Error: cant open ' . $vDBFile);
        return false;
    }
    $vDB->exec('PRAGMA cache_size=20000');
    $vDB->exec('PRAGMA synchronous=OFF');
    $vDB->exec('PRAGMA count_changes=OFF');
    $vDB->exec('PRAGMA journal_mode=MEMORY');
    $vDB->exec('PRAGMA temp_store=MEMORY');
    $vDB->busyTimeout(10000);
    return $vDB;
}
Exemplo n.º 19
0
function create_image2()
{
    $GBC = new GBsql();
    $GBC->GB_getSQLsetting();
    $GBSQL = "SELECT * from locations ";
    $result = $GBC->_GBUser->query($GBSQL);
    $locs = $result->fetchAll();
    @(list($level, $gold, $cash, $FarmSizeX, $FarmSizeY) = explode(';', fBGetDataStore('playerinfo')));
    if ($FarmSizeX == '' || $FarmSizeY == '') {
        $GB_place_items = "No";
        return;
    } else {
        $GB_place_items = "OK";
    }
    $maxX = $FarmSizeX * 4;
    $maxX = $maxX + 3;
    $maxY = $FarmSizeY * 4;
    $maxY = $maxY + 3;
    $im = @imagecreate($maxX, $maxY) or AddLog2("Cannot Initialize new GD image stream");
    $background_color = imagecolorallocate($im, 255, 255, 255);
    // yellow
    $red = imagecolorallocate($im, 255, 0, 0);
    // red
    $green = imagecolorallocate($im, 0, 255, 0);
    $blue = imagecolorallocate($im, 0, 0, 255);
    // blue
    $white = imagecolorallocate($im, 255, 255, 255);
    $yellow = imagecolorallocate($im, 255, 255, 0);
    $black = imagecolorallocate($im, 0, 0, 0);
    $purple = ImageColorAllocate($im, 153, 51, 255);
    //purple
    $pink = ImageColorAllocate($im, 255, 0, 128);
    //pink
    $grey = ImageColorAllocate($im, 192, 192, 192);
    //grey
    $brown = ImageColorAllocate($im, 51, 0, 0);
    $loc = "Animal";
    $style = array($white, $white, $white, $blue, $blue, $blue);
    ImageSetStyle($im, $style);
    $X1 = $GBC->GB_Setting[$loc . 'X1'] * 4;
    $Y1 = $maxY - $GBC->GB_Setting[$loc . 'Y1'] * 4;
    $X2 = $GBC->GB_Setting[$loc . 'X2'] * 4;
    $Y2 = $maxY - $GBC->GB_Setting[$loc . 'Y2'] * 4;
    imagefilledrectangle($im, $X1, $Y1, $X2, $Y2, IMG_COLOR_STYLED);
    $loc = "Tree";
    $style = array($white, $white, $white, $yellow, $yellow, $yellow);
    ImageSetStyle($im, $style);
    $X1 = $GBC->GB_Setting[$loc . 'X1'] * 4;
    $Y1 = $maxY - $GBC->GB_Setting[$loc . 'Y1'] * 4;
    $X2 = $GBC->GB_Setting[$loc . 'X2'] * 4;
    $Y2 = $maxY - $GBC->GB_Setting[$loc . 'Y2'] * 4;
    imagefilledrectangle($im, $X1, $Y1, $X2, $Y2, IMG_COLOR_STYLED);
    $loc = "Decoration";
    $style = array($white, $white, $white, $black, $black, $black);
    ImageSetStyle($im, $style);
    $X1 = $GBC->GB_Setting[$loc . 'X1'] * 4;
    $Y1 = $maxY - $GBC->GB_Setting[$loc . 'Y1'] * 4;
    $X2 = $GBC->GB_Setting[$loc . 'X2'] * 4;
    $Y2 = $maxY - $GBC->GB_Setting[$loc . 'Y2'] * 4;
    imagefilledrectangle($im, $X1, $Y1, $X2, $Y2, IMG_COLOR_STYLED);
    foreach ($locs as $loc) {
        $GB_fill = $red;
        if (strpos($loc['_what'], 'E') !== false) {
            $GB_fill = $green;
        }
        if (strpos($loc['_what'], 'Decoration') !== false) {
            $GB_fill = $black;
        }
        if (strpos($loc['_what'], 'Animal') !== false) {
            $GB_fill = $purple;
        }
        if (strpos($loc['_what'], 'Building') !== false) {
            $GB_fill = $pink;
        }
        if (strpos($loc['_what'], 'Plot') !== false) {
            $GB_fill = $brown;
        }
        $Map_PXI = $loc['_X'] * 4;
        $Map_PYI = $loc['_Y'] * 4;
        $Map_PYI = $maxY - $Map_PYI;
        imagefilledrectangle($im, $Map_PXI, $Map_PYI, $Map_PXI + 1, $Map_PYI + 1, $GB_fill);
    }
    $GB_map_image = $_SESSION['userId'] . "_FarmMap3.png";
    imagepng($im, $GB_map_image);
    imagedestroy($im);
}
Exemplo n.º 20
0
function CheckAMF2Response($amf2)
{
    if (@$amf2->_bodys[0]->_value['errorType'] != 0) {
        if ($amf2->_bodys[0]->_value['errorData'] == "There is a new version of the farm game released") {
            AddLog2('FV UPDATE: New Version of FV Released');
            AddLog2('Work Will Restart in 15 Seconds');
            @unlink('sqlite_check.txt');
            die;
        } else {
            if ($amf2->_bodys[0]->_value['errorData'] == "token value failed") {
                AddLog2('FV FUBAR: Game Opened in Another Browser');
                AddLog2('Work Will Restart in 15 Seconds');
                die;
            } else {
                if ($amf2->_bodys[0]->_value['errorData'] == "token too old") {
                    AddLog2('FV FUBAR: Your Session Has Expired');
                    AddLog2('Work Will Restart in 15 Seconds');
                    die;
                } else {
                    if ($amf2->_bodys[0]->_value['errorType'] == 29) {
                        AddLog2('FV FUBAR: Server Sequence Was Reset');
                        $_SESSION['sequence'] = 0;
                    } else {
                        $res = "Error: " . $amf2->_bodys[0]->_value['errorType'] . " " . $amf2->_bodys[0]->_value['errorData'];
                        DoInit();
                    }
                }
            }
        }
    } else {
        if (!isset($amf2->_bodys[0]->_value['data'][0])) {
            $res = "BAD AMF REPLY (OOS?)";
        } else {
            if (isset($amf2->_bodys[0]->_value['data'][0]['data']) && $amf2->_bodys[0]->_value['data'][0]['data'] == 'success') {
                $res = 'OK';
            } else {
                if (isset($amf2->_bodys[0]->_value['data'][0]['data']) && $amf2->_bodys[0]->_value['data'][0]['data'] == '6uccess') {
                    $res = 'OK';
                } else {
                    if (isset($amf2->_bodys[0]->_value['data'][0]['errorType']) && $amf2->_bodys[0]->_value['data'][0]['errorType'] != 0) {
                        $res = $amf2->_bodys[0]->_value['data'][0]['errorType'] . " " . $amf2->_bodys[0]->_value['data'][0]['errorData'] . ' ' . $amf2->_bodys[0]->_value['data'][0]['data']['error'];
                    } else {
                        if (isset($amf2->_bodys[0]->_value['data'][0]['data']['error']) && strlen($amf2->_bodys[0]->_value['data'][0]['data']['error']) > 0) {
                            $res = $amf2->_bodys[0]->_value['data'][0]['data']['error'];
                        } else {
                            $res = 'OK';
                        }
                    }
                }
            }
        }
    }
    return $res;
}
Exemplo n.º 21
0
 function _fnCancelNeighbor($neighborid)
 {
     $url = 'http://apps.facebook.com/onthefarm/neighbors.php?zyUid=' . $this->userId . '&zySnuid=' . $this->userId . '&zySnid=1&zySig=' . $this->_token;
     $contents = 'action=cancelRequest&uid=' . $neighborid;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $contents);
     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SearchToolbar 1.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)');
     curl_setopt($ch, CURLOPT_COOKIE, $this->_fnGetCookie());
     curl_setopt($ch, CURLOPT_ENCODING, '');
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Language: en-US', 'Pragma: no-cache'));
     if ($_SESSION['use_proxy']) {
         curl_setopt($ch, CURLOPT_PROXY, trim($_SESSION['proxy_settings'][0]));
         curl_setopt($ch, CURLOPT_PROXYPORT, intval($_SESSION['proxy_settings'][1]));
         if (isset($_SESSION['proxy_settings'][2]) && isset($_SESSION['proxy_settings'][3])) {
             // is set proxy user and password
             $authorization = trim($_SESSION['proxy_settings'][2]) . ':' . trim($_SESSION['proxy_settings'][3]);
             curl_setopt($ch, CURLOPT_PROXYUSERPWD, $authorization);
             curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
         }
     }
     $response = curl_exec($ch);
     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if ($httpCode == 404) {
         AddLog2("fvNeighbors - Cancel: Error 404/Page Not Found");
         return;
     }
     if ($httpCode == 500) {
         AddLog2("fvNeighbors - Cancel: Error 500/Internal Server Error");
         return;
     }
     if (empty($response)) {
         AddLog2("fvNeighbors - Cancel: Empty Response Returned");
         return;
     }
     if ($httpCode == 200) {
         $fvSQL = "DELETE FROM neighbors WHERE neighbors_fbid='" . $neighborid . "'";
         $q = $this->_fnNeighborsDBM->query($fvSQL);
         AddLog2('fvNeighbors - Action: Cancel - NeighborID: ' . $neighborid . ' - OK');
     }
     curl_close($ch);
     //AddLog2($request);
     //echo $vHTTPResponse;
 }
Exemplo n.º 22
0
function Sections_WalkRotate_Speed()
{
    global $vAnnounceWalkRotateArray;
    $px_Setopts = LoadSavedSettings();
    if (!@$px_Setopts['bot_speed'] || @$px_Setopts['bot_speed'] > 50 || @$px_Setopts['bot_speed'] < 1) {
        $vSpeed = 1;
    } else {
        $vSpeed = $px_Setopts['bot_speed'];
    }
    $vCntMoves = count($vAnnounceWalkRotateArray);
    $vRunMainLoop = ceil($vCntMoves / $vSpeed);
    for ($vI = 0; $vI < $vRunMainLoop; $vI++) {
        $need_reload = false;
        $res = 0;
        $amf = new AMFObject("");
        $amf->_bodys[0] = new MessageBody();
        $amf->_bodys[0]->targetURI = 'FlashService.dispatchBatch';
        $amf->_bodys[0]->responseURI = '/1/onStatus';
        $amf->_bodys[0]->responseIndex = '/1';
        $amf->_bodys[0]->_value[0] = GetAMFHeaders();
        unset($vMSG);
        $vNumAction = 0;
        for ($vJ = $vI * $vSpeed; $vJ < $vI * $vSpeed + $vSpeed && $vJ < $vCntMoves; $vJ++) {
            $o = $vAnnounceWalkRotateArray[$vJ]['o'];
            $vWalk = $vAnnounceWalkRotateArray[$vJ]['vWalk'];
            $vRotate = $vAnnounceWalkRotateArray[$vJ]['vRotate'];
            $amf->_bodys[0]->_value[1][$vNumAction]['params'] = array();
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][0] = 'move';
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][1] = $o;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2] = array();
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['canWander'] = $vWalk;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['state'] = $o['state'];
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['direction'] = $vRotate;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['x'] = $o['position']['x'];
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['y'] = $o['position']['y'];
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['z'] = $o['position']['z'];
            $amf->_bodys[0]->_value[1][$vNumAction]['sequence'] = GetSequense();
            $amf->_bodys[0]->_value[1][$vNumAction]['functionName'] = 'WorldService.performAction';
            $vNumAction++;
            $vMSG[] = $o['position']['x'] . '/' . $o['position']['y'];
        }
        $amf->_bodys[0]->_value[2] = 0;
        AddLog2("Sections: Speed_WalkRotate on " . implode(' ', $vMSG));
        $res = RequestAMF($amf);
        AddLog2("Sections: result {$res}");
        if ($res === 'OK') {
            $need_reload = true;
        }
    }
    return $need_reload;
}
Exemplo n.º 23
0
function fvTools_form()
{
    global $this_plugin;
    AddLog2(print_r($_POST, true));
    $fvM = new fvTools('formload');
    if (empty($fvM->settings)) {
        echo 'Database is not initialized yet, please allow bot to run a cycle';
        return;
    }
    if (!empty($fvM->error) && $fvM->haveWorld !== false) {
        echo $fvM->error;
        return;
    }
    if (@$_GET['submit'] == 'Save Settings') {
        $fvM->fvDoSettings();
    }
    $fvM->settings = $fvM->fvGetSettings();
    $Bot_path = getcwd();
    global $fvTools_ImagePath;
    $fvTools_ImagePath = str_replace("/", "\\", $Bot_path);
    $mast = unserialize($fvM->settings['mastery']);
    $mastcnt = unserialize($fvM->settings['masterycnt']);
    if (file_exists(F('seed.txt'))) {
        // fix infinite loop when no file exists
        $seed_list = explode(';', trim(file_get_contents(F('seed.txt'))));
    }
    ?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/plugins/fvTools/css/index.css" />
<script type="text/javascript" src="/plugins/fvTools/js/fvTools.js"></script>
<script type="text/javascript" src="/plugins/fvTools/js/tabber.js"></script>
<script type="text/javascript" src="/plugins/fvTools/js/lib/prototype.js"></script>
<script type="text/javascript" src="/plugins/fvTools/js/src/scriptaculous.js"></script>

<script type="text/javascript">
function showhide(id){
if (document.getElementById){
obj = document.getElementById(id);
if (obj.style.display == "none"){
obj.style.display = "";
} else {
obj.style.display = "none";
}
}
}
</script> 
</head>
<body>
<?php 
    define('REQ_VER_PARSER', '218');
    if (!PX_VER_PARSER || PX_VER_PARSER < REQ_VER_PARSER) {
        echo "<br><br><span style=\"text-align:center;color:red\">**** ERROR: fvTools v" . fvTools_version . " Requires parser version v" . REQ_VER_PARSER . " or higher ****</span><br>";
        return;
    }
    ?>
<h1>fvTools V<?php 
    echo fvTools_version;
    ?>
</h1>
<p><a href="#" onclick="showhide('settings');">Show/Hide Settings</a></p>
<div id="settings" style="display: none;">
<form id="settings" method="get">
<?php 
    $showxmlchk = $fvM->settings['showxml'] == 1 ? 'checked' : '';
    ?>
<small>
<input type="checkbox" name="showxml" value="showxml" <?php 
    echo $showxmlchk;
    ?>
 />Show XML Tab<br />
<input type="submit" name="submit" value="Save Settings" />
</small>
</form>
</div>
<div class="tabber" id="t">
	<!--Seeding Tab-->
	<div class="tabbertab">
		<h2>Seed List</h2>
		<?php 
    $seeds = $fvM->fvSeedUnits();
    ?>
		<b>Drag and Drop List Items to Sort.</b>
		<table border=0>
		<tr>
		<td>
        <ul id="seeds_list" style="list-style-type : none; margin : 0;">
            <?php 
    foreach ($seed_list as $key => $seedname) {
        ?>
                <li id="seed_<?php 
        echo $key;
        ?>
" style="border : 1px solid #000; cursor : move; margin : 2px 0 2px 0; padding : 3px; background : #f7f7f7; border : #ccc; width : 400px;"><?php 
        echo $seedname;
        ?>
</li>
            <?php 
    }
    ?>
        </ul>
        </td>
        <td>
		<div id="deleteArea">
			<big>Drag Here to Delete.</big>
		</div>
		</td>
		</tr>
		</table>
		<input type="submit" value="Save" onClick="new Ajax.Request('main.php', { method: 'post', parameters: Sortable.serialize('seeds_list'), 
								onSuccess: function(transport){
		      					var response = transport.responseText || 'no response text';
	      						alert('Success! \n\n' + response);
	    						},
								onFailure: function(){ alert('Something went wrong...');}});">      
        <script type="text/javascript">
            Sortable.create('seeds_list', {
            	tag:'li',
				constraint: false,
				dropOnEmpty: true,
				containment: ['seeds_list','deleteArea']
				});
				Droppables.add('deleteArea', {
				containment: ['seeds_list','deleteArea'],
				onDrop: deleteItem
				});
				function deleteItem(draggable,deleteArea) {
					draggable.parentNode.removeChild(draggable);
					deleteArea.appendChild(draggable);
					deleteArea.removeChild(draggable);
			}            
        </script>
    </div>
	<?php 
    if ($fvM->settings['showxml'] == 1) {
        ?>
	<!--XML Items Tab-->
	<div class="tabbertab">
		<h2>XML Items</h2>
		<?php 
        $buyable = $fvM->fvBuyableUnits();
        ?>
		<div class="tabber" id="t3">
			<?php 
        foreach ($buyable as $key => $item) {
            ?>
			<!-- XML Items Subtabs -->
			<div class="tabbertab">
				<h3><?php 
            echo ucfirst($item['units_type']);
            ?>
</h3>
				<table border="1">
					<tr>
						<td align="center"><b>Image</b></td>
						<td align="center"><b>Real Name</b></td>
						<td align="center"><b>Code</b></td>
						<td align="center"><b>Name</b></td>
						<td align="center"><b>Classname</b></td>
						<td align="center"><b>Start Date</b></td>
						<td align="center"><b>End Date</b></td>
						<td align="center"><b>Size</b></td>
						<td align="center"><b>Giftable</b></td>
						<td align="center"><b>Placeable</b></td>
						<td align="center"><b>Iphone</b></td>
						<td align="center"><b>Currency</b></td>
						<td align="center"><b>Cost</b></td>
					</tr>
					<?php 
            $items = $fvM->fvBuyableUnits($item['units_type']);
            foreach ($items as $itms) {
                $iconurl = 'file:///' . $fvTools_ImagePath . '/' . $itms['units_iconurl'] . ".40x40.jpeg";
                if ($itms['units_limit'] > 0) {
                    $itms['units_realname'] = $itms['units_realname'] . ' (Limit ' . $itms['units_limit'] . ')';
                }
                ?>
					<tr>
						<td><img src="<?php 
                echo $iconurl;
                ?>
" height="40" width="40" /></td>
						<td><?php 
                echo $itms['units_realname'];
                ?>
</td>
						<td align="center"><?php 
                echo $itms['units_code'];
                ?>
</td>
						<td align="center"><?php 
                echo $itms['units_name'];
                ?>
</td>
						<td align="center"><?php 
                echo $itms['units_class'];
                ?>
</td>
						<td align="center"><?php 
                echo date("m/d/y", $itms['units_limitedstart']);
                ?>
&nbsp;</td>
						<td align="center"><?php 
                echo date("m/d/y", $itms['units_limitedend']);
                ?>
&nbsp;</td>
						<td align="center"><?php 
                echo $itms['units_sizeX'] . 'x' . $itms['units_sizeY'];
                ?>
</td>
						<td align="center"><?php 
                echo $itms['units_giftable'];
                ?>
</td>
						<td align="center"><?php 
                echo $itms['units_canplace'];
                ?>
</td>
						<td align="center"><?php 
                echo $itms['units_iphoneonly'];
                ?>
</td>
						<td align="center"><?php 
                echo ucfirst($itms['units_market']);
                ?>
</td>
						<td align="center"><?php 
                echo number_format($itms['units_cost']);
                ?>
</td>
					</tr>
					<?php 
            }
            ?>
				</table>
			</div>
		<?php 
        }
        ?>
		</div>
	</div>
	<?php 
    }
    ?>
</div>
</body>
</html>

<?php 
    unset($fvM);
}
Exemplo n.º 24
0
 function fsGetGoods()
 {
     $fwSQL = "SELECT myworld_itemCode FROM myworld WHERE myworld_className = 'CraftingCottageBuilding'";
     $q = $this->_fsManagerDBW->query($fwSQL);
     $bresults = $q->fetchAll(SQLITE_ASSOC);
     foreach ($bresults as $bresult) {
         $fuSQL = "SELECT units_craftskill FROM units WHERE units_code = '" . $bresult['myworld_itemCode'] . "'";
         $r = $this->_fsManagerDBU->query($fuSQL);
         $csresults = $r->fetchAll(SQLITE_ASSOC);
         $craftskill[] = $csresults[0]['units_craftskill'];
     }
     $cs = implode("','", $craftskill);
     AddLog2('Craftskills: ' . $cs);
     $fuSQL = "SELECT * FROM units WHERE units_subtype IN('{$cs}')";
     $q = $this->_fsManagerDBU->query($fuSQL);
     $iresults = $q->fetchAll(SQLITE_ASSOC);
     return $iresults;
 }
Exemplo n.º 25
0
function AM_farmGold_moveAnimalsToBuilding($building, $getLeft, $getFarm, $getIDs, $getNames, $getPositions)
{
    global $TB_settings;
    global $AM_settings;
    if ($getLeft == 0) {
        return;
    }
    $i = 0;
    $farm = array();
    $farm = $getFarm;
    $left = $getLeft;
    $index = 0;
    while ($left > 0) {
        if (empty($getNames[$index])) {
            continue;
        }
        $amf = CreateMultAMFRequest($amf, $i, 'store', 'WorldService.performAction');
        $amf->_bodys[0]->_value[1][$i]['params'][1]['id'] = $building['id'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['contents'][0]['num'] = $index;
        //$amf->_bodys[0]->_value[1][$i]['params'][1]['contents'][0]['item']	= '';
        $amf->_bodys[0]->_value[1][$i]['params'][1]['itemName'] = $building['itemName'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['direction'] = 0;
        $amf->_bodys[0]->_value[1][$i]['params'][1]['buildTime'] = 0;
        $amf->_bodys[0]->_value[1][$i]['params'][1]['className'] = $building['className'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['position']['x'] = $building['position']['x'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['position']['y'] = $building['position']['y'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['position']['z'] = 0;
        $amf->_bodys[0]->_value[1][$i]['params'][1]['deleted'] = false;
        $amf->_bodys[0]->_value[1][$i]['params'][1]['state'] = $building['state'];
        $amf->_bodys[0]->_value[1][$i]['params'][1]['tempId'] = 'NaN';
        //$amf->_bodys[0]->_value[1][$i]['params'][1]['plantTime']          		= $time;
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['resource'] = $getIDs[$index];
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['cameFromLocation'] = 0;
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['storedItemCode'] = TB_GetCodeByName($getNames[$index]);
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['storedClassName'] = 'animal';
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['isGift'] = false;
        $amf->_bodys[0]->_value[1][$i]['params'][2][0]['storedItemName'] = $getNames[$index];
        $farm[$getPositions[$index]['x']][$getPositions[$index]['y']] = true;
        $farm[$getPositions[$index]['x'] + 1][$getPositions[$index]['y']] = true;
        $farm[$getPositions[$index]['x']][$getPositions[$index]['y'] + 1] = true;
        $farm[$getPositions[$index]['x'] + 1][$getPositions[$index]['y'] + 1] = true;
        $i++;
        $left--;
        $index++;
        if ($i >= $TB_settings['TB_speedAction']) {
            $res = RequestAMF($amf);
            if ($res == 'OK') {
                AddLog2('-> ' . $res . ' ' . $left . ' left');
                $i = 0;
            } else {
                AddLog2("ERROR - {$res}");
                return false;
            }
        }
    }
    if ($i > 0) {
        $res = RequestAMF($amf);
        if ($res == 'OK') {
            AddLog2('-> ' . $res);
            return $farm;
        } else {
            AddLog2("ERROR - {$res}");
            return false;
        }
    } else {
        return $farm;
    }
}
Exemplo n.º 26
0
function Grifter_TurboSell($name, $x)
{
    Addlog2('selling ' . $name . ' : ' . $x . ' times');
    $vSpeed = 8;
    $Code = Units_GetCodeByName($name);
    unset($GLOBALS['amfphp']['encoding']);
    $vRunMainLoop = ceil($x / $vSpeed);
    for ($vI = 0; $vI < $vRunMainLoop; $vI++) {
        $vNumAction = 0;
        for ($vJ = $vI * $vSpeed; $vJ < $vI * $vSpeed + $vSpeed && $vJ < $x; $vJ++) {
            @($amf = CreateMultAMFRequest($amf, $vNumAction, '', 'UserService.sellStoredItem'));
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][0]['code'] = $Code;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][1] = false;
            $amf->_bodys[0]->_value[1][$vNumAction]['params'][2] = -1;
            $vNumAction++;
        }
        $res = RequestAMF($amf);
        if ($res == 'OK') {
            Addlog2(" result {$res}");
        } else {
            AddLog2("GiftBox: Error - " . $res);
            return $res;
        }
    }
    return $res;
}
Exemplo n.º 27
0
function Do_Farm_Work_Plots($plots, $action = "harvest")
{
    global $vCnt63000;
    list(, , , , , , , , , , $fuel) = explode(';', fBGetDataStore('playerinfo'));
    if (@strlen($vCnt63000) == 0) {
        $vCnt63000 = 63000;
    }
    $px_Setopts = LoadSavedSettings();
    if (!@$px_Setopts['bot_speed'] || @$px_Setopts['bot_speed'] < 1) {
        $px_Setopts['bot_speed'] = 1;
    }
    if (@$px_Setopts['bot_speed'] > PARSER_MAX_SPEED) {
        $px_Setopts['bot_speed'] = PARSER_MAX_SPEED;
    }
    $vMaxEquip = 16;
    if (@(!$fuel) || @$fuel < 0) {
        $fuel = 0;
    }
    if ($fuel == 0 && $action == 'tractor') {
        return;
    }
    if ($fuel == 0) {
        Do_Farm_Work($plots, $action);
        return;
    }
    while (count($plots) > 0) {
        $amf = new AMFObject("");
        $amf->_bodys[0] = new MessageBody();
        $amf->_bodys[0]->targetURI = 'FlashService.dispatchBatch';
        $amf->_bodys[0]->responseURI = '/1/onStatus';
        $amf->_bodys[0]->responseIndex = '/1';
        $amf->_bodys[0]->_value[0] = GetAMFHeaders();
        $amf->_bodys[0]->_value[2] = 0;
        $vCntSpeed = 0;
        while (count($plots) > 0 && $vCntSpeed < $px_Setopts['bot_speed'] && $fuel > 0) {
            $amf->_bodys[0]->_value[1][$vCntSpeed]['sequence'] = GetSequense();
            $amf->_bodys[0]->_value[1][$vCntSpeed]['functionName'] = "EquipmentWorldService.onUseEquipment";
            if ($action == 'tractor') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][0] = 'plow';
            } else {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][0] = $action;
            }
            $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['id'] = -1;
            if ($action == 'harvest') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['key'] = 'V1:32';
            }
            # fully expanded harvester
            if ($action == 'tractor' || $action == 'plow') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['key'] = 'T1:32';
            }
            # fully expanded tractor
            if ($action == 'place') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['key'] = 'S1:32';
            }
            # fully expanded seeder
            $vCntEquip = 0;
            $vSeed = '';
            $vLastSeed = '';
            while (count($plots) > 0 && $vCntEquip < $vMaxEquip && $fuel > 0) {
                $vPlot = array_pop($plots);
                if ($action == 'place') {
                    $vSeed = $vPlot['itemName'];
                    if ($vLastSeed == '') {
                        $vLastSeed = $vSeed;
                    } elseif ($vLastSeed != $vSeed) {
                        array_push($plots, $vPlot);
                        break;
                    }
                }
                if (@(!$plotsstring)) {
                    $plotsstring = $vPlot['itemName'] . " " . GetPlotName($vPlot);
                } else {
                    $plotsstring = $plotsstring . ", " . $vPlot['itemName'] . " " . GetPlotName($vPlot);
                }
                if (@(!$OKstring)) {
                    $OKstring = $action . " " . $vPlot['itemName'] . " on plot " . GetPlotName($vPlot);
                } else {
                    $OKstring = $OKstring . "\r\n" . $action . " " . $vPlot['itemName'] . " on plot " . GetPlotName($vPlot);
                }
                $fuel--;
                if ($action == 'tractor') {
                    $vCnt63000++;
                    $vPlot['id'] = $vCnt63000;
                    $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][2][$vCntEquip] = $vPlot;
                } else {
                    $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][2][$vCntEquip]['id'] = $vPlot['id'];
                }
                $vCntEquip++;
            }
            if ($action == 'tractor' || $action == 'harvest' || $action == 'plow') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][3] = 'plowed';
            }
            if ($action == 'place') {
                $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][3] = $vSeed;
            }
            $vCntSpeed++;
        }
        AddLog2($action . " " . $plotsstring);
        $res = RequestAMF($amf);
        AddLog2("result {$res}");
        unset($amf->_bodys[0]->_value[1]);
        if ($res === 'OK') {
            AddLog($OKstring);
            $need_reload = true;
        } else {
            if ($res) {
                AddLog("Error: {$res} on " . $OKstring);
                if (intval($res) == 29 || strpos($res, 'BAD AMF') !== false) {
                    // Server sequence was reset
                    DoInit();
                }
            }
        }
        unset($plotsstring, $OKstring);
    }
    $px_Setopts = LoadSavedSettings();
    if ($action == 'plow' || $action == 'tractor') {
        $px_Setopts['fuel_plow'] = $fuel;
    }
    if ($action == 'place') {
        $px_Setopts['fuel_place'] = $fuel;
    }
    if ($action == 'harvest') {
        $px_Setopts['fuel_harvest'] = $fuel;
    }
    SaveSettings($px_Setopts);
}
Exemplo n.º 28
0
function TB_sendRequest($amf)
{
    //start parser
    $serializer = new AMFSerializer();
    $result = $serializer->serialize($amf);
    // serialize the data
    $answer = Request('', $result);
    $amf2 = new AMFObject($answer);
    $deserializer2 = new AMFDeserializer($amf2->rawData);
    // deserialize the data
    $deserializer2->deserialize($amf2);
    // run the deserializer
    if (@$amf2->_bodys[0]->_value['errorType'] != 0) {
        if ($amf2->_bodys[0]->_value['errorData'] == "There is a new version of the farm game released") {
            AddLog2("New version of the game released");
            echo "\n*****\nGame version out of date\n*****\n";
            echo "\n Restarting Bot in 15 seconds. \n";
            sleep(15);
            touch('need_restart.txt');
            //creating this file will cause the game to restart
        } else {
            if ($amf2->_bodys[0]->_value['errorData'] == "token value failed") {
                AddLog2("Error: token value failed");
                AddLog2("You opened the game in another browser");
                AddLog2("Restart the game or wait for forced restart");
                echo "\n*****\nError: token value failed\nThis error is caused by opening the game in another browser\nRestart the bot or wait 15 seconds for forced restart.\n*****\n";
                sleep(15);
                touch('need_restart.txt');
            } else {
                if ($amf2->_bodys[0]->_value['errorData'] == "token too old") {
                    AddLog2("Error: token too old");
                    AddLog2("The session expired");
                    AddLog2("Restart the game or wait for forced restart");
                    echo "\n*****\nError: token too old\nThe session has expired\nRestart the bot or wait 15 seconds for forced restart.\n*****\n";
                    sleep(15);
                    touch('need_restart.txt');
                    //creating this file will cause the game to restart
                } else {
                    echo "\n*****\nError: \n" . $amf2->_bodys[0]->_value['errorType'] . " " . $amf2->_bodys[0]->_value['errorData'] . "\n";
                    $res = "Error: " . $amf2->_bodys[0]->_value['errorType'] . " " . $amf2->_bodys[0]->_value['errorData'];
                }
            }
        }
    } else {
        if (!isset($amf2->_bodys[0]->_value['data'][0])) {
            echo "\n*****\nError:\n BAD AMF REPLY - Possible Server problem or farm badly out of sync\n*****\n";
            $res = "BAD AMF REPLY (OOS?)";
        } else {
            if (isset($amf2->_bodys[0]->_value['data'][0]['errorType']) && $amf2->_bodys[0]->_value['data'][0]['errorType'] == 0) {
                $res = 'OK';
            } else {
                if (isset($amf2->_bodys[0]->_value['data'][0])) {
                    $res = $amf2->_bodys[0]->_value['data'][0]['errorType'] . " " . $amf2->_bodys[0]->_value['data'][0]['errorData'];
                }
            }
        }
    }
    //end parser
    $return['amf2'] = $amf2;
    $return['res'] = $res;
    return $return;
}