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); }
function Giftbox() { AddLog2('GiftBox: Start'); $T = time(true); // begin SQL setup $this->GBDBuser_init("Hook"); $this->GB_renew_giftbox_SQL(); // end SQL setup // Get the settings $GBSQL = "SELECT _val,_set FROM gamesettings"; $result = $this->_GBUser->query($GBSQL); if ($result->numRows() > 0) { $GB_results = $result->fetchAll(); foreach ($GB_results as $GB_result) { $this->GB_Setting[$GB_result['_set']] = $GB_result['_val']; } } // import default actions? $this->GB_AutoActionFile(); // if place is on, than let's update the locations to find empty locations if ($this->GB_Setting['DoPlace']) { $this->GBCreateMap(); } AddLog2('GiftBox: Detecting Building Parts'); $this->GB_DetectBuildingParts4(); $this->GB_BuildingParts4(); if ($this->GB_Setting['RunPlugin']) { //check the cellar for storage. if ($this->GB_Setting['DoStorage']) { $this->GB_checkCellar(); } // check this amount of items in giftbox. $result1 = $this->_GBUser->query("SELECT SUM(_amount) FROM giftbox"); if ($result1->numRows() > 0) { $GB_total_in_giftbox = $result1->fetchSingle(); } else { $GB_total_in_giftbox = 0; } AddLog2("GiftBox: Items Counted - " . $GB_total_in_giftbox); global $GB_tempid; if ($GB_tempid == "") { $GB_tempid = 63000; } //get the collection info. $GBccount = array(); $GBccount = GB_LoadCcount(); $GB_changed = false; //true when we did action. $MAP_ObjectArray = array(); $Map_all_items = array(); $MapXY = array(); $EmptyXY = array(); if ($this->GB_Setting['DoFeetPet']) { AddLog2("GiftBox: Detecting Pet(s)"); $GB_Pets = $this->GB_FindPetsSQL(); $found = count(array_keys($GB_Pets)); AddLog2("GiftBox: Found {$found} Pet(s)"); if ($found > 0) { foreach ($GB_Pets as $GB_Petfeed) { if ($GB_Petfeed['isRunAway'] == 1) { AddLog2('GiftBox: ' . $GB_Petfeed['petName'] . ' Has Ran Away'); } else { $FeedWhat = $GB_Petfeed['FeedWhat']; $FeedName = $GB_Petfeed['petName']; AddLog2('GiftBox: ' . $FeedName . ' Needs: ' . $FeedWhat . ' ' . nicetime($GB_Petfeed['feedtime'])); } } } } // DoFeetPet // load the totstorage. $GBSQL = "SELECT * FROM totstorage "; $query = $this->_GBUser->query($GBSQL); $totstorages = $query->fetchAll(); if (!is_array($totstorages)) { $totstorages = array(); } // load the giftbox... $GBSQL = "SELECT * FROM giftbox "; $query = $this->_GBUser->query($GBSQL); $giftboxs = $query->fetchAll(); foreach ($giftboxs as $giftbox) { $GB_ItemCode = $giftbox["_itemcode"]; $GB_ItemAmount = $giftbox["_amount"]; // if items = 0 then skip this item. if ($GB_ItemAmount < 1) { continue; } $place_on_farm = ''; $place_in_build = ''; $place_in_amount = ''; $place_in_max = ''; $place_in_special = ''; $target = ''; $selling = ''; $keep = 0; $construction = ''; $collection = ''; $consume = ''; // Let's check if there is action for this item. $GBSQL = "SELECT * FROM action WHERE _code = '" . $GB_ItemCode . "'"; $query = $this->_GBUser->query($GBSQL); $action = $query->fetchAll(); if (!empty($action)) { // so there is action. $place_on_farm = $action['0']['_place_on_farm']; $place_in_build = $action['0']['_place_in_build']; $place_in_amount = $action['0']['_place_in_amount']; $place_in_max = $action['0']['_place_in_max']; $place_in_special = $action['0']['_place_in_special']; $target = $action['0']['_target']; $selling = $action['0']['_selling']; $construction = $action['0']['_construction']; $keep = $action['0']['_keep']; $collection = $action['0']['_collection']; $consume = $action['0']['_consume']; } // prepare Unit settings $GBSQL = "SELECT * FROM units WHERE _code = '" . $GB_ItemCode . "' "; $query = $this->_GBMain->query($GBSQL); $Unit = $query->fetchAll(); // Get the realname $Unit['0']['realname'] = $this->GB_get_friendlyName($Unit['0']['_name']); // check if we need to feed pet $FeedNowCheck = false; $PetFeedFound = ""; if ($GB_ItemCode == "0O") { $FeedNowCheck = true; $PetFeedFound = "Puppy Kibble "; } if ($GB_ItemCode == "0z") { $FeedNowCheck = true; $PetFeedFound = "Dog Treat "; } if ($FeedNowCheck == true && $this->GB_Setting['DoFeetPet']) { AddLog('GiftBox: ' . $GB_ItemAmount . " " . $PetFeedFound . " Found - Checking If Needed"); if ($GB_ItemAmount > 0) { // loop all pets foreach ($GB_Pets as $GB_Petfeed) { if ($GB_Petfeed['isRunAway'] == 1) { AddLog2('GiftBox: ' . $GB_Petfeed['petName'] . ' Has Ran Away - Cannot Feed'); } else { $FeedWhat = $GB_Petfeed['FeedWhat']; $FeedName = $GB_Petfeed['petName']; $FeedNow = true; if ($FeedWhat == "kibble" && $GB_ItemCode == "0z") { AddLog2("GiftBox: This Puppy Does Not Need Dog Treats.."); $FeedNow = false; } if ($FeedWhat == "treat" && $GB_ItemCode == "0O") { AddLog2("GiftBox: This Dog Does Not Need Kibble.."); $FeedNow = false; } if ($FeedNow == true) { $UnixNow = time(); if ($UnixNow > $GB_Petfeed['feedtime']) { // need feed now $FeedWhat = $GB_Petfeed['FeedWhat']; $result = GB_consumePet($GB_Petfeed['id'], "consume_" . $FeedWhat); AddLog2("GiftBox: Feeding " . $GB_Petfeed['petName'] . " " . $FeedWhat . '- ' . $result); if ($result == "OK") { AddLog2("GiftBox: Kibble Has Been Fed"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, "Pet feed", $GB_ItemAmount, "Pet Feed"); //GB_Stat($GB_ItemCode, "Kibble feed", 0, 0, $GB_ItemAmount,0 ); } else { $giftboxs = array(); break; } } else { AddLog2($GB_Petfeed['petName'] . ' Needs to be Fed ' . nicetime($GB_Petfeed['feedtime'])); } } } } } } // End pet feet. // check target settings global. if ($target != 0) { $Target = $this->GBSQLGetObjByID($target); $TotItems = 0; $TargetItemHave = 0; // map the content of the target and find the total items have if (is_array($Target['contents'])) { // count the contents foreach ($Target['contents'] as $content) { $TotItems = $TotItems + $content['numItem']; $TargetCont[$content['itemCode']] = $content['numItem']; if ($GB_ItemCode == $content['itemCode']) { $TargetItemHave = $content['numItem']; } } } // end contents // now check if the item is in totstorage. $featureCreditsName = 'N'; if ($Target['itemName'] == 'valentinesbox') { $featureCreditsName = 'valentine'; } if ($Target['itemName'] == 'potofgold') { $featureCreditsName = 'potOfGold'; } if ($Target['itemName'] == 'easterbasket') { $featureCreditsName = 'easterBasket'; } if ($Target['itemName'] == 'wedding') { $featureCreditsName = 'tuscanWedding'; } if ($Target['itemName'] == 'beehive_finished') { $featureCreditsName = 'beehive'; } if ($Target['itemName'] == 'hatchstorage') { $featureCreditsName = 'InventoryCellar'; } //added if ($featureCreditsName != 'N') { $GBSQL = "SELECT * FROM totstorage WHERE _storagecode = '" . $featureCreditsName . "' AND _itemcode = 'current'"; $query = $this->_GBUser->query($GBSQL); if ($query->numRows() > 0) { $totstorage = $query->fetchAll(); $TotItems = $totstorages['0']['_amount']; } } // Get target unit details. $GBSQL = "SELECT * FROM units WHERE _name = '" . $Target['itemName'] . "' "; $result = $this->_GBMain->query($GBSQL); $TargetUnit = $result->fetchAll(); // check capacity of target $TargetCapacity = 0; if (!array_key_exists('isFullyBuilt', $Target)) { $Target['isFullyBuilt'] = "N"; } if ($Target['isFullyBuilt'] == "1") { $TargetCapacity = $TargetUnit['0']['_capacity']; if (array_key_exists('expansionLevel', $Target)) { $level = $Target['expansionLevel']; if ($level > 1) { $GBSQL = "SELECT _capacity FROM unitbuilding WHERE _level = '" . $level . "' AND _buildingcode = '" . $TargetUnit['0']['_code'] . "' "; $result = $this->_GBMain->query($GBSQL); $TargetCapacity = $result->fetchSingle(); } } else { $level = 0; } } // end fully build // check if building is in construction $TargetIsConstruction = 'N'; if ($Target['state'] == 'construction') { $TargetIsConstruction = 'Y'; } else { // check if it is a horsestable if ($Target['itemName'] == 'horsestablewhite') { // check if horse stable has expansionParts if (count(array_keys($Target['expansionParts'])) > 0) { // yes, we have expansionParts $TargetIsConstruction = 'Y'; } if ($TargetItemHave > 0) { // yes, we have expansionParts $TargetIsConstruction = 'Y'; } } } } // End check target //check if we can store this item. if ($this->GB_Setting['DoStorage']) { $Able2Store = GB_CanWeStore($Unit['0']); if ($this->GB_Setting['StorageLocation'] == 'N') { $Able2Store = 'N'; } else { if ($this->GB_Setting['StorageUsed'] >= $this->GB_Setting['StorageCapacity']) { // storage is full. $Able2Store = 'N'; AddLog2("GiftBox: Storage is Full?"); } } if ($this->GB_Setting['DoStorage'] && $Able2Store == 'Y' && $GB_ItemAmount > 0) { // check content of storage AddLog2("GiftBox: Entering Storage Routine For: " . $Unit['0']['realname']); $cellars = unserialize($this->GB_Setting['StorageContent2']); $AmountInCellar = 0; if (array_key_exists($GB_ItemCode, $cellars)) { $AmountInCellar = $cellars[$GB_ItemCode]; } AddLog2("GiftBox: Store " . $GB_ItemAmount . " " . $Unit['0']['realname'] . '?'); if ($this->GB_Setting['DoStorage1'] && $AmountInCellar < 1) { $Amount2Store = 1; AddLog2("GiftBox: Store " . $Amount2Store . " " . $Unit['0']['realname']); } else { AddLog2("GiftBox: Store " . $Unit['0']['realname'] . " Already in Storage"); } if ($Amount2Store > 0) { $result = GB_StoreCel($Unit['0'], $Amount2Store); if ($result == "OK") { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - Added"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Fuel added"); $GB_ItemAmount = $GB_ItemAmount - $Amount2Store; } else { $giftboxs = array(); break; } } else { AddLog2("GiftBox: No Need to Store This Item."); } } // end stor } // check if we can use the item to store into a building if ($place_in_build != 0 && $target != 0 && $this->GB_Setting['DoPlaceBuild'] && $GB_ItemAmount > 0) { //$place_in_max AddLog2('GiftBox ' . $Target['itemName'] . ' - Capacity: ' . $TargetCapacity . ' - Have: ' . $TotItems); $finished = false; if ($TotItems >= $TargetCapacity) { // The building is full lets skip this item. AddLog2("GiftBox: This Building is Full - Skipping"); $finished = true; } while (!$finished) { $result = GB_storeItem($Unit['0'], $Target); if ($result == "OK") { $GB_changed = true; //update the amount. AddLog2('GiftBox: Placed in Building ' . $Unit['0']['_name'] . ' - Total in Building: ' . $TotItems); $this->GB_SQL_updAction("_place_in_build", $GB_ItemCode, $place_in_build - $GB_ItemAmount); //$field, $code, $val //update stats. $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Into building"); $TotItems++; $GB_ItemAmount--; } else { $finished = true; $giftboxs = array(); break; } if ($TotItems >= $TargetCapacity) { $finished = true; } if ($GB_ItemAmount < 1) { $finished = true; } } // not full } //end place in build // check if we have to place construction in a building // construction = # or Y 0 = not construction if ($construction == 'Y' && $this->GB_Setting['DoConstr'] && $GB_ItemAmount > 0) { $go = $GB_ItemAmount; $used = 0; while ($go > 0) { AddLog2('GiftBox: Construction Part ' . $Unit['0']['_name'] . ' Found ' . $go); $GBSQL = "SELECT * FROM BuildingParts WHERE _itemCode = " . $this->Qs($GB_ItemCode) . " AND _action ='construction' AND _ObjHave < 10 LIMIT " . $go; $query = $this->_GBUser->query($GBSQL); if ($query->numRows() > 0) { $BuildingParts = $query->fetchAll(); foreach ($BuildingParts as $BuildingPart) { // 1 or more targets found $Target = $this->GBSQLGetObjByID($BuildingPart['_ObjId']); AddLog2('GiftBox: Part: ' . $BuildingPart['_itemName'] . ' For ' . $BuildingPart['_UnitBuildName'] . " - Contains: " . $BuildingPart['_ObjHave'] . " - Adding 1"); $result = GB_storeItem($Unit['0'], $Target); if ($result == "OK") { $GB_changed = true; $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Construction"); //update the amount have $have = $BuildingPart['_ObjHave'] + 1; $GBSQL = "UPDATE BuildingParts SET _ObjHave=" . $this->Qs($have) . " WHERE _UnitBuildName = " . $this->Qs($BuildingPart['_UnitBuildName']) . " AND _itemCode = " . $this->Qs($GB_ItemCode); $query = $this->_GBUser->query($GBSQL); $go--; $used++; } else { $go = 0; $giftboxs = array(); break; } } } else { //skip there are no target buildings AddLog2('GiftBox: Construction Part Not Needed. (' . $GB_ItemCode . ')'); $go = 0; } } // while $GB_ItemAmount > 1 $GB_ItemAmount = $GB_ItemAmount - $used; } // constructions // check if we have Special to handle if ($place_in_special != 0 && $target != 0 && $this->GB_Setting['DoSpecials'] && $GB_ItemAmount > 0) { AddLog2('GiftBox: Special ' . $TargetUnit['0']['_name'] . " For " . $Target['itemName']); // for specials there is no max. $result = GB_storeItem2($Unit['0'], $Target, $GB_ItemAmount); if ($result == "OK") { //GB_SpecialThisUpdate($GB_ItemCode, $GB_ItemAmount); $GB_changed = true; $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Special"); $GB_ItemAmount = 0; } else { $giftboxs = array(); break; } } // check if we have collection if ($collection == 'Y' && $this->GB_Setting['DoColl'] && $GB_ItemAmount > 0) { $Amount_in_Collection = GB_GetColInfo($GB_ItemCode, $GBccount); // Check if we have less than 10 if ($Amount_in_Collection < 10 && $GB_ItemAmount > 0) { if ($Amount_in_Collection + $GB_ItemAmount <= 10) { $Amount_to_add = $GB_ItemAmount; } else { $Amount_to_add = 10 - $Amount_in_Collection; } AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['_name'] . " - Have " . $Amount_in_Collection . " Will Add " . $Amount_to_add . " To Collection"); $result = GB_DoColAdd($Unit['0']['_name'], $GB_ItemCode, $Amount_to_add); if ($result == "OK") { AddLog2($Amount_to_add . " " . $Unit['0']['_name'] . " Added To Collection"); $GB_changed = true; $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Added collection"); $Amount_in_Collection = $Amount_in_Collection + $Amount_to_add; $GB_ItemAmount = $GB_ItemAmount - $Amount_to_add; } else { $giftboxs = array(); break; } } // end < 10 if ($Amount_in_Collection >= 10 && $GB_ItemAmount > 0) { //we have already 10 if ($this->GB_Setting['DoCollSell']) { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['_name'] . " - Have " . $Amount_in_Collection . " Will Sell Now"); $result = GB_DoSellCol($Unit['0'], $GB_ItemAmount); if ($result == "OK") { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Sold"); $GB_changed = true; $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Sold collection"); } else { $giftboxs = array(); break; } } else { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $ObjD['realname'] . " - Have " . $Amount_in_Collection . " Selling Disabled"); } // end do_sell } // end more 10. } // end collection // Place on farm if ($place_on_farm == 'Y' && $this->GB_Setting['DoPlace'] && $GB_ItemAmount > 0) { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - Place on Farm"); $GB_Where = "Decoration"; if ($Unit['0']['_type'] == "animal") { $GB_Where = "Animal"; } if ($Unit['0']['_type'] == "tree") { $GB_Where = "Tree"; } //check if there is place on the farm. $GB_Free_place = $this->TEmptyXY3($GB_Where, "ALL"); if ($GB_Free_place < $GB_ItemAmount) { AddLog2("****** Error *****"); AddLog2("GiftBox: There is no room on you farm left."); AddLog2("GiftBox: To place: " . $GB_ItemAmount . " " . $Unit['0']['realname']); AddLog2("****** Error *****"); } else { $result = GB_PlaceM3($Unit['0'], $GB_ItemAmount, $GB_Where); if ($result == "OK") { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Placed"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Placed"); $GB_ItemAmount = 0; } else { $giftboxs = array(); break; } } } // end place if ($Unit['0']['_type'] == 'fuel' && $this->GB_Setting['DoFuel'] && $GB_ItemAmount > 0) { // selling fuel enabled >> GB_BuyFuel($ObjD , $GB_amount) $result = GB_BuyFuel($Unit['0'], $GB_ItemAmount); AddLog2("GiftBox " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Fuel found - " . $result); if ($result == "OK") { AddLog2("GiftBox " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Added"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Fuel added"); $GB_ItemAmount = 0; } else { $giftboxs = array(); break; } } // end fuel // consumable if ($consume == 'Y' && $GB_ItemAmount > 0) { $GBAction_Amount = $GB_ItemAmount - $keep; if ($GBAction_Amount >= 1) { $result = GB_consume($Unit['0'], $GBAction_Amount); AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Consume - Leave in GiftBox: " . $keep . ' - ' . $result); $need_reload = true; if ($result == "OK") { AddLog2("GiftBox: " . $GBAction_Amount . " " . $Unit['0']['realname'] . " Consumed"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GBAction_Amount, "Consume"); $GB_ItemAmount = 0; } else { DoInit(); $giftboxs = array(); break; } } else { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - Keep in Giftbox: " . $keep); } } // end consumable // DoVehicle if ($this->GB_Setting['DoVehicle'] && $GB_ItemCode == "dS" && $GB_ItemAmount > 0) { $GBAction_Amount = $GB_ItemAmount - $keep; $vehicle = $this->GB_garage('hook'); $AmountOfRuns = $vehicle['0']['vehicle']; AddLog2("GiftBox: Have " . $GB_ItemAmount . " Vehicle Parts - " . $vehicle['0']['vehicle'] . " Vehicles Need Parts"); while ($AmountOfRuns >= 1 && $GBAction_Amount > 1) { $needpart = $vehicle[$AmountOfRuns]['need']; AddLog2("Giftbox: Vehicle " . $vehicle[$AmountOfRuns]['itemCode'] . " Needs " . $needpart . " Parts"); while ($needpart >= 1 && $GBAction_Amount > 1) { $result = GB_DoGarage($vehicle[$AmountOfRuns], $vehicle['0']['id']); if ($result == "OK") { $vehicle[$AmountOfRuns]['numParts'] = $vehicle[$AmountOfRuns]['numParts'] + 1; $needpart--; AddLog2("GiftBox: 1 " . $Unit['0']['realname'] . " Added, Need " . $needpart . ' More'); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GBAction_Amount, "Added"); $GBAction_Amount--; $GB_ItemAmount--; } else { $giftboxs = array(); break; } } $AmountOfRuns--; } } // end DoVehicle // check if we can open this. $GB_OpenArray = unserialize($this->GB_Setting['OpenItems']); if (in_array($GB_ItemCode, $GB_OpenArray)) { $GB_OpenThis = 'Y'; } else { $GB_OpenThis = 'N'; } if ($this->GB_Setting['DoMystery'] && $GB_ItemAmount > 0 && $GB_OpenThis == 'Y') { $GBAction_Amount = $GB_ItemAmount - $keep; if ($GBAction_Amount >= 1) { $result = GB_OpenGift($Unit['0'], $GBAction_Amount); AddLog2("GiftBox: Open " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - " . $result); $need_reload = true; if ($result == "OK") { AddLog2("GiftBox: Opened " . $GBAction_Amount . " " . $Unit['0']['realname'] . " - Done"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GBAction_Amount, "Opened"); $GB_ItemAmount = 0; } else { $giftboxs = array(); break; } } else { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - Keep in GiftBox: " . $keep); } } // end open if ($selling == 'Y' && $this->GB_Setting['DoSelling'] && $GB_ItemAmount > 0) { $GBAction_Amount = $GB_ItemAmount - $keep; if ($GBAction_Amount >= 1) { $result = GB_DoSellCol($Unit['0'], $GBAction_Amount); AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Will be Sold - Leave in GiftBox: " . $keep . ' - ' . $result); $need_reload = true; if ($result == "OK") { AddLog2("GiftBox: " . $GBAction_Amount . " " . $Unit['0']['realname'] . " Sold"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GBAction_Amount, "Sold"); $GB_ItemAmount = 0; } else { $giftboxs = array(); break; } } else { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - Keep in GiftBox: " . $keep); } } // end Do_SellList } //end foreach giftbox // after giftbox, see the collection trade in. if ($this->GB_Setting['DoCollTrade']) { // now look to complete collections. AddLog2("Collection trade in set to: " . $this->GB_Setting['DoCollKeep']); $GB_CollCompete_res = GB_CollCompete(); // get the information while (list($GB_CollCode, $amount) = each($GB_CollCompete_res)) { AddLog2("Collection Info: [" . $GB_CollCode . "] has" . $amount . " completed"); $GB_Tradein_amount = $amount - $this->GB_Setting['DoCollKeep']; if ($GB_Tradein_amount > 0) { $GB_TradeIn_res = GB_TradeIn($GB_CollCode, $GB_Tradein_amount); AddLog2("Collection Trade In: [" . $GB_CollCode . "] " . $GB_Tradein_amount . " Time(s)"); $this->GB_Stat3($GB_CollCode, "Collection", $GB_Tradein_amount, "Trade in"); $GB_changed = true; } } } // end complete collection } else { AddLog2("Skipping GiftBox..."); } if ($GB_changed) { $res = $this->GB_renew_giftbox_SQL(); // update giftbox. so it shows correctly in the screen. } else { $T2 = time(); $T2 -= $T; AddLog2("Giftbox: Finished in " . $T2 . " Seconds"); } }
function fusionne($afus) { global $l; $i = 0; $maxStamp = 0; $minStamp = mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")); //demain foreach ($afus as $a) { $d = $a["lastcome"]; $a["stamp"] = mktime($d[11] . $d[12], $d[14] . $d[15], $d[17] . $d[18], $d[5] . $d[6], $d[8] . $d[9], $d[0] . $d[1] . $d[2] . $d[3]); //echo "stamp:".$a["stamp"]."== mktime($d[11]$d[12],$d[14]$d[15],$d[17]$d[18],$d[5]$d[6],$d[8]$d[9],$d[0]$d[1]$d[2]$d[3]);<br>"; if ($maxStamp < $a["stamp"]) { $maxStamp = $a["stamp"]; $maxInd = $i; } if ($minStamp > $a["stamp"]) { $minStamp = $a["stamp"]; $minInd = $i; } $i++; } if ($afus[$minInd]["deviceid"] != "") { $okLock = true; foreach ($afus as $a) { if (!($okLock = $okLock && lock($a["id"]))) { break; } else { $locked[] = $a["id"]; } } if ($okLock) { //TRACE_DELETED if (mysqli_num_rows(mysql2_query_secure("SELECT * FROM config WHERE IVALUE>0 AND NAME='TRACE_DELETED'", $_SESSION['OCS']["readServer"]))) { foreach ($afus as $a) { if ($afus[$maxInd]["deviceid"] == $a["deviceid"]) { continue; } $sql = "insert into deleted_equiv(DELETED,EQUIVALENT) values('%s','%s')"; $arg = array($a["deviceid"], $afus[$maxInd]["deviceid"]); mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg); } } //KEEP OLD QUALITY,FIDELITY AND CHECKSUM $sql = "SELECT CHECKSUM,QUALITY,FIDELITY FROM hardware WHERE ID='%s'"; $persistent_req = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $afus[$minInd]["id"]); $reqDelAccount = "DELETE FROM accountinfo WHERE hardware_id='%s'"; mysql2_query_secure($reqDelAccount, $_SESSION['OCS']["writeServer"], $afus[$maxInd]["id"]); msg_success($l->g(190) . " " . $afus[$maxInd]["deviceid"] . " " . $l->g(191)); $keep = array("accountinfo", "devices", "groups_cache"); foreach ($keep as $tableToBeKept) { $reqRecupAccount = "UPDATE %s SET hardware_id='%s' WHERE hardware_id='%s'"; $argRecupAccount = array($tableToBeKept, $afus[$maxInd]["id"], $afus[$minInd]["id"]); mysql2_query_secure($reqRecupAccount, $_SESSION['OCS']["writeServer"], $argRecupAccount); } msg_success($l->g(190) . " " . $afus[$minInd]["deviceid"] . " " . $l->g(206) . " " . $afus[$maxInd]["deviceid"]); $i = 0; foreach ($afus as $a) { if ($i != $maxInd) { deleteDid($a["id"], false, false, false); $lesDel .= $a["deviceid"] . "/"; } $i++; } //RESTORE PERSISTENT VALUES $persistent_values = mysqli_fetch_row($persistent_req); $sql = "UPDATE hardware SET QUALITY=%s,FIDELITY=%s,CHECKSUM=CHECKSUM|%s WHERE id='%s'"; $arg = array($persistent_values[1], $persistent_values[2], $persistent_values[0], $afus[$maxInd]["id"]); mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"], $arg); } else { errlock(); } foreach ($locked as $a) { unlock($a); } } $lesDel .= " => " . $afus[$maxInd]["deviceid"]; AddLog("FUSION", $lesDel); }
$tab_typ_champ[0]['INPUT_TYPE'] = 2; $tab_name[0] = $l->g(1014) . ":"; $tab_typ_champ[0]['RELOAD'] = "CHANGE"; if ($protectedPost['MODE'] == 5 and $list_mode[$protectedPost['MODE']] == 'FUSER') { $tab_typ_champ[1]['DEFAULT_VALUE'] = $protectedPost['FUSER']; $tab_typ_champ[1]['INPUT_NAME'] = "FUSER"; $tab_typ_champ[1]['INPUT_TYPE'] = 0; $tab_name[1] = $l->g(926) . " "; } tab_modif_values($tab_name, $tab_typ_champ, '', array('title' => $l->g(1015))); if (isset($protectedPost['Reset_modif'])) { reloadform_closeme('', true); } //passage en mode if (isset($protectedPost['Valid_modif']) and $protectedPost["MODE"] != "") { AddLog("MODE", $list_mode[$protectedPost["MODE"]]); if ($protectedPost["MODE"] == 1) { unset($_SESSION['OCS']['DEBUG'], $_SESSION['OCS']['MODE_LANGUAGE'], $_SESSION['OCS']["usecache"]); } elseif ($protectedPost["MODE"] == 2) { unset($_SESSION['OCS']['MODE_LANGUAGE']); $_SESSION['OCS']['DEBUG'] = "ON"; } elseif ($protectedPost["MODE"] == 3) { unset($_SESSION['OCS']['DEBUG']); $_SESSION['OCS']['MODE_LANGUAGE'] = "ON"; } elseif ($protectedPost["MODE"] == 4) { $_SESSION['OCS']['MODE_LANGUAGE'] = "ON"; $_SESSION['OCS']['DEBUG'] = "ON"; } elseif ($protectedPost["MODE"] == 5) { if (!isset($_SESSION['OCS']['TRUE_USER'])) { $true_user = $_SESSION['OCS']['loggeduser']; $list_page_profil = $_SESSION['OCS']['profile']->getPages();
private function _fvFarmWork($items, $action = 'harvest') { $count = count($items); if ($count > 0) { $i = 0; $amf = ''; foreach ($items as $plot) { if ($action == 'harvest') { $pUnit = Units_GetUnitByName($plot['itemName'], true); $Seed = $plot['itemName']; $LastSeed = $Seed; if ($this->currbushel != $pUnit['bushelItemCode']) { $this->_fvDoBushels($pUnit['bushelItemCode']); } } $amf = CreateMultAMFRequest($amf, $i, $action, 'WorldService.performAction'); $amf->_bodys[0]->_value[1][$i]['params'][1] = $plot; $amf->_bodys[0]->_value[1][$i]['params'][2] = array(); $amf->_bodys[0]->_value[1][$i]['params'][2][0]['energyCost'] = 0; $prealname = trim(Units_GetRealnameByName($plot['itemName'])); if (@(!$plotsstring)) { $plotsstring = $prealname . " " . $plot['position']['x'] . '-' . $plot['position']['y']; } else { $plotsstring = $plotsstring . ", " . $prealname . " " . $plot['position']['x'] . '-' . $plot['position']['y']; } if (@(!$OKstring)) { $OKstring = ucfirst($action) . " " . $prealname . " " . $plot['position']['x'] . '-' . $plot['position']['y']; } else { $OKstring = $OKstring . "\r\n" . ucfirst($action) . " " . $plot['itemName'] . " " . $plot['position']['x'] . '-' . $plot['position']['y']; } $i++; if ($i == $this->botspeed || $i >= $count) { $count -= $i; $i = 0; AddLog2('fvFarmer: ' . ucfirst($action) . " " . $plotsstring); $res = RequestAMF($amf, true); $amf2 = $res['amf2']; $amf = ''; if ($res['res'] === 'OK') { AddLog2("fvFarmer Result: " . $res['res']); foreach ($amf2->_bodys[0]->_value['data'][0]['data'] as $result) { if (isset($result['data']['foundBushel'])) { $crop = $result['data']['foundBushel']['bushelCode']; $cUnit = Units_GetUnitByCode($crop, true); AddLog2('fvFarmer: Found Bushel ' . $cUnit['realname']); if ($result['data']['foundBushel']['bushelAddedToStall'] == 1) { $this->fmBushels[] = $crop; } } } } else { if ($res['res']) { AddLog("fvFarmer Error: " . $res['res'] . " on {$OKstring}"); if (intval($res['res']) == 29 || intval($res['res']) == 28) { DoInit(); } } } unset($plotsstring, $OKstring); } } } }
$pass = CleanPass(isset($_POST["pass"]) ? $_POST["pass"] : NULL); $valckAccess = ""; AddLog("Cargando login/pass '{$login}/{$pass}'"); $user = true; if ($login and $pass) { $id = identificacionUsuarioValidoMd5($login, md5($pass)); if ($id) { RegistrarUsuarioLogueado($id); AddLog("Se loguea id'{$id}'"); AddLog("Se redirigie a xulmenu..."); session_write_close(); header("Location: xulentrar.php?modo=login-local"); exit; } else { $fail = "Nombre ('{$login}') o password ('{$pass}') incorrectas: {$_motivoFallo}"; AddLog("Falla identificacion."); } } break; } StartXul("Login gPOS"); ?> <box flex="1" style="background-image: url(img/gpos_bg_login.jpg); background-repeat:no-repeat; background-color:#2F6496;"> <spacer flex="1" /> <vbox > <spacer flex="1" /> <spacer flex="1" /> <vbox style="width: 425px; height: 180px; background-image: url(img/gpos_login_back.png); background-repeat:no-repeat; "> <vbox >