示例#1
0
function GB_renew_giftbox()
{
    $res = 0;
    //load settings
    DoInit();
    $GB_ingiftbox = unserialize(fBGetDataStore('giftbox'));
    $GB_AllStorages = load_array(GBox_storage);
    if (!$GB_AllStorages) {
        $GB_AllStorages = array();
    }
    $GB_AllStorages['have'] = unserialize(fBGetDataStore('storagedata'));
    if (is_array($GB_AllStorages['have'])) {
        save_array($GB_AllStorages, GBox_storage);
        AddLog2("GiftBox AllStorage update - saved ");
    } else {
        AddLog2("AllStorage ERROR - Not saved ");
    }
    if ($GBox_Settings['Place']) {
        // see if we can store the latest info on farm XY
        $objects = unserialize(fBGetDataStore('objects'));
        save_array($objects, GBox_XY_objects);
        AddLog2("Giftbox Objects - saved ");
        // build the map to find empty spots
        GB_buildEmptyXY();
    }
    // now update the building parts
    GB_BuiltPartBD();
    return $res;
}
示例#2
0
 function fvXML($inittype = '')
 {
     $this->userId = $_SESSION['userId'];
     list(, , , , , , , , , , , $this->flashRevision) = explode(';', fBGetDataStore('playerinfo'));
     //Open Databases
     $this->_fvXMLDBM = new SQLiteDatabase(fvXML_Path . fvXML_Main);
     $this->_fvXMLDBU = new SQLiteDatabase(fvXML_Path . fvXML_Units);
     if (!$this->_fvXMLDBM || !$this->_fvXMLDBU) {
         $this->error = 'fvXML - Database Error';
         return;
     }
     $this->_fvXMLDBM->queryExec('PRAGMA cache_size=20000');
     $this->_fvXMLDBM->queryExec('PRAGMA synchronous=OFF');
     $this->_fvXMLDBM->queryExec('PRAGMA count_changes=OFF');
     $this->_fvXMLDBM->queryExec('PRAGMA journal_mode=MEMORY');
     $this->_fvXMLDBM->queryExec('PRAGMA temp_store=MEMORY');
     $this->_fvXMLDBU->queryExec('PRAGMA cache_size=20000');
     $this->_fvXMLDBU->queryExec('PRAGMA synchronous=OFF');
     $this->_fvXMLDBU->queryExec('PRAGMA count_changes=OFF');
     $this->_fvXMLDBU->queryExec('PRAGMA journal_mode=MEMORY');
     $this->_fvXMLDBU->queryExec('PRAGMA temp_store=MEMORY');
     //Get Settings
     $this->settings = $this->fvGetSettings();
     if ($inittype == 'formload') {
         if (empty($this->settings)) {
             $this->error = 'Please allow fvXML to run a cycle';
         }
         return;
     }
     //Load the world from Z*
     $this->_refreshWorld();
     if ($this->haveWorld === true) {
         if ($this->settings === false) {
             $this->_fvXML_checkDB();
             //Database doesn't exist, create
             $this->_fvUpdateSettings();
             //Insert initial settings
             $this->_fvUpdateUnits();
             //Update the Units file
             $this->error = 'Please allow fvXML to run a cycle to update all settings';
             return;
         }
         if ($this->settings['flashRevision'] != $this->flashRevision) {
             $this->_fvUpdateUnits();
             //Update the Units file
             $this->settings = $this->fvGetSettings();
         }
         if ($this->settings['unitversion'] != $this->flashRevision) {
             $this->_fvUpdateUnits();
             //Update the Units file
         }
         $this->_fvUpdateSettings();
         //Update the settings
         $this->_fvUpdateImages();
         //Update Thumbnails
     }
 }
示例#3
0
function Grifter_loadSettings()
{
    global $Grifter_settings;
    list($level, $gold, $cash, $sizeX, $sizeY, $firstname) = explode(';', fBGetDataStore('playerinfo'));
    $need_save = false;
    $Grifter_settings = load_array(Grifter_settings);
    if ($Grifter_settings['Grifter_version'] != Grifter_version) {
        $Grifter_settings['Grifter_version'] = Grifter_version;
        $Grifter_settings['level'] = 0;
        $Grifter_settings['gold'] = 0;
        $Grifter_settings['sizeX'] = 0;
        $Grifter_settings['sizeY'] = 0;
        $Grifter_settings['giftbox'] = 0;
        $Grifter_Settings['auto'] = false;
        $Grifter_settings['max'] = 0;
        $Grifter_settings['reset'] = false;
        $Grifter_settings['keep'] = false;
        $Grifter_Settings['smaller'] = false;
        $Grifter_Settings['turbo'] = false;
        $Grifter_settings['mansion'] = 0;
        $Grifter_settings['villa'] = 0;
        $Grifter_settings['logcabin'] = 0;
        $Grifter_settings['postoffice'] = 0;
        $Grifter_settings['fruitstand'] = 0;
        $Grifter_settings['schoolhouse'] = 0;
        $Grifter_settings['resttent'] = 0;
        $Grifter_settings['woodpile'] = 0;
        $Grifter_settings['haybale'] = 0;
        $Grifter_settings['engineer'] = 0;
        $Grifter_settings['pheasant'] = 0;
        $Grifter_settings['beltedcow'] = 0;
        $Grifter_settings['goat'] = 0;
        $Grifter_settings['saddleback'] = 0;
        $Grifter_settings['windmill'] = 0;
        $Grifter_settings['cowsilo'] = 0;
        $need_save = true;
    }
    $Grifter_settings['giftbox'] = 0;
    $Grifter_settings['giftbox'] = array_sum(@unserialize(fBGetDataStore('ingiftbox')));
    $Grifter_settings['level'] = $level;
    $Grifter_settings['gold'] = $gold;
    $Grifter_settings['sizeX'] = $sizeX;
    $Grifter_settings['sizeY'] = $sizeY;
    if ($need_save) {
        save_array($Grifter_settings, Grifter_settings);
    }
}
示例#4
0
            unset($overridelist[$item]);
            file_put_contents($_SESSION['base_path'] . F('overrideseed.txt'), serialize($overridelist));
        }
    }
}
if (isset($_POST['defsub'])) {
    //Remove Seed From Default Seedlist
    if (isset($_POST['defaultlist'])) {
        foreach ($_POST['defaultlist'] as $item) {
            unset($defaultlist[$item]);
            file_put_contents($_SESSION['base_path'] . F('defaultseed.txt'), serialize($defaultlist));
        }
    }
}
$mastcnt = unserialize(fBGetDataStore('cropmastery'));
$maststar = unserialize(fBGetDataStore('cropmasterycnt'));
$fvM->settings = $fvM->fvGetSettings();
@($plowcheck = $fvM->settings['plow'] == 1 ? 'CHECKED' : '');
@($plantcheck = $fvM->settings['plant'] == 1 ? 'CHECKED' : '');
@($harvestcheck = $fvM->settings['harvest'] == 1 ? 'CHECKED' : '');
@($planecheck = $fvM->settings['flyplane'] == 1 ? 'CHECKED' : '');
@($autocheck = $fvM->settings['automast'] == 1 ? 'CHECKED' : '');
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" type="text/css" href="css/fvFarmer.css" />
<script type="text/javascript" src="js/fvFarmerCheckBoxes.js"></script>
<script type="text/javascript" src="js/fvFarmer.js"></script>
<script type="text/javascript" src="js/tabber.js"></script>
示例#5
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
 }
示例#6
0
 function fsGetFeature()
 {
     //AddLog2(print_r($this->featurecred,true));
     $fcred = unserialize(fBGetDataStore('featurecred'));
     $featcred = array();
     if (empty($fcred)) {
         return;
     }
     foreach ($fcred as $key => $feature) {
         $uinfo = Units_GetUnitByName(strtolower($key));
         if ($uinfo['type'] == 'building') {
             $featcred['building'][$uinfo['realname']] = $feature;
         }
         if ($uinfo['type'] != 'building' && !empty($uinfo)) {
             $featcred['decoration'][$uinfo['realname']] = $feature;
         }
         if (empty($uinfo)) {
             $featcred['building'][$key] = $feature;
         }
     }
     //AddLog2(print_r($featcred,true));
     return $featcred;
 }
示例#7
0
 function DoWork()
 {
     $grabs = unserialize($this->settings['sharelinks']);
     if (empty($grabs)) {
         return;
     }
     $gbcount = array_sum(unserialize(fBGetDataStore('ingiftbox')));
     $cbcount = array_sum(unserialize(fBGetDataStore('inconbox')));
     $count = 0;
     foreach ($grabs as $fbid => $info) {
         if (@$info['share'] != 1) {
             continue;
         }
         $links = $this->GetLinkTypes($fbid);
         foreach ($links as $cat => $link) {
             if (@$info[$cat] == 1) {
                 continue;
             }
             foreach ($link as $nlink) {
                 if ($gbcount + $cbcount + $count >= 500) {
                     AddLog2('fvLinks: GiftBox/Consumable Box Full');
                     return;
                 }
                 $key = str_replace('&key={*key*}', '', $nlink['rewardLink']);
                 if ($this->fvCheckLink($key) === true) {
                     continue;
                 }
                 $fvSQL = "INSERT OR REPLACE INTO rewardlinks(rewardlinks_link, rewardlinks_timestamp) values('{$key}','" . time() . "')";
                 $this->_fsManagerDBM->queryExec($fvSQL);
                 $answer = $this->_fvLinksGet('http://apps.facebook.com/onthefarm/' . $key);
                 $count++;
                 preg_match_all('/<h3>(.*)<\\/h3>/sim', $answer, $text);
                 if (!empty($answer) && empty($text[1][0])) {
                     AddLog2('fvLinks: Unknown Gift Response');
                     continue;
                 }
                 if ($text[1][0] == "Hey there, farmer! You've claimed all the rewards you can from your friends today.  Try again tomorrow!") {
                     break;
                 }
                 if (!empty($answer)) {
                     AddLog2($text[1][0]);
                 }
                 sleep(3);
             }
         }
     }
 }
示例#8
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);
                 }
             }
         }
     }
 }
示例#9
0
<?
if (!empty($_POST))
{
	$_GET = $_POST;
} else {
	$_POST = $_GET;
}
require_once '../../fB_PluginAPI.php';
include_once('functions.php');
define('sections_Path', '/plugins/Sections/');
define('sections_URL', 'index.php');
define('sections_Version', file_get_contents('Sections.ver'));
define('sections_Version_Date', '');
$objects = @unserialize(fBGetDataStore('objects'));
list($level, $gold, $cash, $sizeX, $sizeY, $firstname, $locale, $tileset, $wither, $xp, $energy, $flashRevision) = explode(';', fBGetDataStore('playerinfo'));

$sections = array();
$sections = load_array('sections.txt');
if ( !(is_array($sections) && count($sections)) ) { $sections = array(); }
$sections = array_merge($sections); // normalize ids

$vSettings = array();
$vSettings = load_array('settings.txt');
if($vSettings['ratio']<1 || $vSettings['ratio']>5) $vSettings['ratio']=3;

if (isset($_POST['vDoExpension'])) {
	foreach ($sections as $vSNum=>$section) {
		$sections[$vSNum]['top_x']=$sections[$vSNum]['top_x']+8;
		$sections[$vSNum]['top_y']=$sections[$vSNum]['top_y']+8;
		$sections[$vSNum]['bot_x']=$sections[$vSNum]['bot_x']+8;
		$sections[$vSNum]['bot_y']=$sections[$vSNum]['bot_y']+8;
示例#10
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);
}
示例#11
0
						<td class="builds" style="vertical-align: top;">
						<div style="overflow-y: scroll; height: 245px;">
						<ul>
						<?php 
$messages = $fsM->fsMessages();
foreach ($messages as $message) {
    echo '<li style="text-indent:-40px; list-style-type: none;">&bull; ' . $message['myworld_message'] . '</li>';
}
?>
						</ul>
						</div>
						</td>
					</tr>
					<tr>
						<?php 
$seedpkgs = unserialize(fBGetDataStore('inseedbox'));
?>
						<td class="builds" style="vertical-align: top; width: 33%;"><font size="2"><b>Seeds:
						</b><?php 
echo array_sum($seedpkgs);
?>
</font></td>
						<td class="builds" style="vertical-align: top; width: 33%;"></td>
						<td class="builds" style="vertical-align: top;"></td>
					</tr>
					<tr>
						<!-- Seeds -->
						<td class="builds" style="vertical-align: top;">
						<div style="overflow-y: scroll; height: 245px;">
						<ul>
							<?php 
示例#12
0
 private function _fvGetLicense($license)
 {
     $licenses = unserialize(fBGetDataStore('licenses'));
     if (empty($licenses)) {
         return false;
     }
     foreach ($licenses as $lic) {
         if ($lic['licensedItem'] == $license) {
             $fvSQL = "SELECT license_duration FROM license WHERE license_code='{$license}'";
             $q = $this->_fvFarmerDBM->query($fvSQL);
             $result = $q->fetchSingle();
             if ($result !== false) {
                 $ltime = $result * (24 * 3600);
                 if ($lic['timeAcquired'] + $ltime > time()) {
                     return true;
                 }
             }
             return false;
         }
     }
     return false;
 }
示例#13
0
function GB_LoadCcount()
{
    return unserialize(fBGetDataStore('ccount'));
}
示例#14
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++;
     }
 }
示例#15
0
 function fvNeighbors($inittype = '')
 {
     list($this->level, $this->gold, $cash, $this->wsizeX, $this->wsizeY, $firstname, $locale, $tileset, $wither, $this->xp, $this->energy) = explode(';', fBGetDataStore('playerinfo'));
     $this->userId = $_SESSION['userId'];
     $this->flashRevision = $_SESSION['flashRevision'];
     $this->error = '';
     $this->haveWorld = false;
     $this->fndebug = false;
     if (!is_numeric($this->userId)) {
         $this->error = "Farmville Bot Not Initialized/User Unknown";
         return;
     }
     //Open Databases
     $this->_fnNeighborsDBM = new SQLiteDatabase(fvNeighbors_Path . PluginF(fvNeighbors_Main));
     if (!$this->_fnNeighborsDBM) {
         $this->error = 'fvNeighbors - Database Error';
         return;
     }
     $this->_fnNeighborsDBM->queryExec('PRAGMA cache_size=20000');
     $this->_fnNeighborsDBM->queryExec('PRAGMA synchronous=OFF');
     $this->_fnNeighborsDBM->queryExec('PRAGMA count_changes=OFF');
     $this->_fnNeighborsDBM->queryExec('PRAGMA journal_mode=MEMORY');
     $this->_fnNeighborsDBM->queryExec('PRAGMA temp_store=MEMORY');
     $this->_fnNeighbors_checkDB();
     //Get Settings
     $this->settings = $this->fnGetSettings();
     if ($inittype == 'formload') {
         if (empty($this->settings)) {
             $this->error = 'Please allow fvNeighbors to run a cycle';
         }
         return;
     }
     if ($this->settings !== false && (!isset($this->settings['version']) || $this->settings['version'] != fvNeighbors_version)) {
         $fbSQL = "DROP TABLE neighborsn;";
         $q = $this->_fnNeighborsDBM->query($fbSQL);
         $this->_fnNeighbors_checkDB();
         //Database doesn't exist, create
         /*$this->_fnUpdateSettings();//Insert initial settings
         		AddLog2('fvNeighbors upgrade finished');*/
     }
     //Load the world from Z*
     $this->_refreshWorld();
     if ($this->haveWorld === true) {
         if ($this->settings === false) {
             $this->_fnNeighbors_checkDB();
             //Database doesn't exist, create
             $this->_fnUpdateSettings();
             //Insert initial settings
             $this->error = 'Please allow fvNeighbors to run a cycle to update all settings';
             return;
         }
         $this->_fnUpdateSettings();
         //Update the settings
         $this->_fnUpdateWorldDB();
         //Update the World
     }
 }
示例#16
0
 function fvManager($inittype = '')
 {
     list($this->level, $this->gold, $this->coin, $this->wsizeX, $this->wsizeY, $firstname, $locale, $tileset, $wither, $xp, $energy, $this->flashRevision) = explode(';', fBGetDataStore('playerinfo'));
     $this->userId = $_SESSION['userId'];
     $this->flashRevision = $_SESSION['flashRevision'];
     $this->xp = $xp;
     $this->energy = $energy;
     $this->error = '';
     $this->haveWorld = false;
     if (!is_numeric($this->userId)) {
         $this->error = "Farmville Bot Not Initialized/User Unknown";
         return;
     }
     //Open Databases
     $this->_fvManagerDBM = new SQLiteDatabase(fvManager_Path . PluginF(fvManager_Main));
     $this->_fvManagerDBW = new SQLiteDatabase(fvManager_Path . PluginF(fvManager_World));
     $this->_fvManagerDBU = new SQLiteDatabase(fvManager_Path . PluginF(fvManager_Units));
     if (!$this->_fvManagerDBM || !$this->_fvManagerDBW || !$this->_fvManagerDBU) {
         $this->error = 'fvManager - Database Error';
         return;
     }
     $this->_fvManagerDBM->queryExec('PRAGMA cache_size=20000');
     $this->_fvManagerDBM->queryExec('PRAGMA synchronous=OFF');
     $this->_fvManagerDBM->queryExec('PRAGMA count_changes=OFF');
     $this->_fvManagerDBM->queryExec('PRAGMA journal_mode=MEMORY');
     $this->_fvManagerDBM->queryExec('PRAGMA temp_store=MEMORY');
     $this->_fvManagerDBW->queryExec('PRAGMA cache_size=20000');
     $this->_fvManagerDBW->queryExec('PRAGMA synchronous=OFF');
     $this->_fvManagerDBW->queryExec('PRAGMA count_changes=OFF');
     $this->_fvManagerDBW->queryExec('PRAGMA journal_mode=MEMORY');
     $this->_fvManagerDBW->queryExec('PRAGMA temp_store=MEMORY');
     $this->_fvManagerDBU->queryExec('PRAGMA cache_size=20000');
     $this->_fvManagerDBU->queryExec('PRAGMA synchronous=OFF');
     $this->_fvManagerDBU->queryExec('PRAGMA count_changes=OFF');
     $this->_fvManagerDBU->queryExec('PRAGMA journal_mode=MEMORY');
     $this->_fvManagerDBU->queryExec('PRAGMA temp_store=MEMORY');
     //Get Settings
     $this->settings = $this->fvGetSettings();
     if ($inittype == 'formload') {
         if (empty($this->settings)) {
             $this->error = 'Please allow fvManager to run a cycle';
         }
         return;
     }
     //Version Upgrade
     if ($this->settings !== false && (!isset($this->settings['version']) || $this->settings['version'] != fvManager_version)) {
         AddLog2('fvManager preparing to upgrade');
         $fwSQL = "DROP TABLE myworld;";
         $q = $this->_fvManagerDBW->query($fwSQL);
         $fgSQL = "DROP TABLE giftbox;";
         $q = $this->_fvManagerDBW->query($fgSQL);
         $fuSQL = "DROP TABLE units;";
         $q = $this->_fvManagerDBU->query($fuSQL);
         $fgSQL = "DROP TABLE fmarket;";
         $q = $this->_fvManagerDBW->query($fgSQL);
         $fbSQL = "DROP TABLE fmbushels;";
         $q = $this->_fvManagerDBW->query($fbSQL);
         $fbSQL = "DROP TABLE work;";
         $q = $this->_fvManagerDBM->query($fbSQL);
         $fbSQL = "DROP TABLE storage;";
         $q = $this->_fvManagerDBW->query($fbSQL);
         $this->_fvManager_checkDB();
         //Database doesn't exist, create
         $this->_fvUpdateSettings();
         //Insert initial settings
         $this->_fvUpdateUnits();
         //Update the Units file
         AddLog2('fvManager upgrade finished');
     }
     //Load the world from Z*
     $this->_refreshWorld();
     if ($this->haveWorld === true) {
         if ($this->settings === false) {
             $this->_fvManager_checkDB();
             //Database doesn't exist, create
             $this->_fvUpdateSettings();
             //Insert initial settings
             $this->_fvImageRev();
             //Update the Image Revision
             $this->_fvUpdateUnits();
             //Update the Units file
             $this->_fvUpdateWorldDB();
             //Update the World
             $this->_findEmpty();
             //$this->_fvCreateMap();//Create World Map
             //$this->_fvGetEmptySpots();//Get Empty Spots
             $this->error = 'Please allow fvManager to run a cycle to update all settings';
             return;
         }
         if ($this->settings['flashRevision'] != $this->flashRevision) {
             $this->_fvImageRev();
             //Update the Image Revision
             $this->_fvUpdateUnits();
             //Update the Units file
             $this->settings = $this->fvGetSettings();
         }
         if ($this->settings['unitversion'] != $this->flashRevision) {
             $this->_fvUpdateUnits();
             //Update the Units file
         }
         $this->_fvUpdateWorldDB();
         //Update the World
         $this->_findEmpty();
         $this->_fvUpdateSettings();
         //Update the settings
         $this->_fvUpdateImages();
         //Update Thumbnails
     }
 }
示例#17
0
function GetNeighbors()
{
    $neighbors = unserialize(fBGetDataStore('neighbors'));
    return $neighbors;
}
示例#18
0
var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
//define universal dsoc top point
var dsoctop=document.all? iebody.scrollTop : pageYOffset;

//if the user is using IE 4+ or Firefox/ NS6+
if (document.all||document.getElementById){
crossobj.style.right=parseInt(dsocleft)+0+"px";
crossobj.style.top=dsoctop+0+"px";
}
}
<?php 
    if (!(isset($_SESSION["browser"]) && $_SESSION["browser"])) {
        echo 'setInterval("positionit()",100);';
    }
    ?>
</script>
		<?php 
}
if (isset($_GET['userId']) && is_numeric($_GET['userId'])) {
    $_SESSION['userId'] = $_GET['userId'];
} else {
    $dUserInfo = fBGetDefUser();
    if (!isset($dUserInfo)) {
        echo '<b>No User Accounts have Ran Yet - Please Allow the Bot to Run</b>';
        exit;
    } else {
        $_SESSION['userId'] = $dUserInfo;
    }
}
list(, , , , , , , , , , , $_SESSION['flashRevision']) = explode(';', fBGetDataStore('playerinfo'));
示例#19
0
function Sections_form()
{
    if (!empty($_POST)) {
        $_POST = $_POST;
    } else {
        $_POST = $_POST;
    }
    require_once '../../fB_PluginAPI.php';
    define('sections_Path', '/plugins/Sections/');
    define('sections_URL', 'index.php');
    define('sections_Version', file_get_contents('Sections.ver'));
    define('sections_Version_Date', '');
    $objects = @unserialize(fBGetDataStore('objects'));
    list($level, $gold, $cash, $sizeX, $sizeY, $firstname, $locale, $tileset, $wither, $xp, $energy, $flashRevision) = explode(';', fBGetDataStore('playerinfo'));
    $sections = array();
    $sections = load_array('sections.txt');
    if (!(is_array($sections) && count($sections))) {
        $sections = array();
    }
    $sections = array_merge($sections);
    // normalize ids
    $vSettings = array();
    $vSettings = load_array('settings.txt');
    if ($vSettings['ratio'] < 1 || $vSettings['ratio'] > 5) {
        $vSettings['ratio'] = 3;
    }
    if (isset($_POST['vDoExpension'])) {
        foreach ($sections as $vSNum => $section) {
            $sections[$vSNum]['top_x'] = $sections[$vSNum]['top_x'] + 8;
            $sections[$vSNum]['top_y'] = $sections[$vSNum]['top_y'] + 8;
            $sections[$vSNum]['bot_x'] = $sections[$vSNum]['bot_x'] + 8;
            $sections[$vSNum]['bot_y'] = $sections[$vSNum]['bot_y'] + 8;
        }
        save_array($sections, 'sections.txt');
    }
    $is_add = isset($_POST['add_sec_form']) && strlen($_POST['add_sec_form']) > 0;
    $is_copy = isset($_POST['copy_sec_form']) && strlen($_POST['copy_sec_form']) > 0;
    $is_edit = isset($_POST['edit_sec_form']) && strlen($_POST['edit_sec_form']) > 0;
    if (isset($_POST['vSave'])) {
        if (isset($_POST['ratio'])) {
            $vSettings['ratio'] = $_POST['ratio'];
        }
        if ($vSettings['ratio'] < 1 || $vSettings['ratio'] > 5) {
            $vSettings['ratio'] = 3;
        }
        $vSettings['map_main'] = isset($_POST['map_main']) ? $_POST['map_main'] : '0';
        $vSettings['map_edit'] = isset($_POST['map_edit']) ? $_POST['map_edit'] : '0';
        $vSettings['map_new'] = isset($_POST['map_new']) ? $_POST['map_new'] : '0';
        if (isset($_POST['tooltip'])) {
            $vSettings['tooltip'] = $_POST['tooltip'];
        }
        save_array($vSettings, 'settings.txt');
    }
    if (isset($_POST['image']) && $_POST['image'] == '1') {
        include 'image.php';
    } elseif (isset($_POST['js']) && $_POST['js'] == '1') {
        include 'wz_tooltip.js';
    } elseif (isset($_POST['js']) && $_POST['js'] == '2') {
        include 'functions.js';
    } elseif (isset($_POST['css']) && $_POST['css'] == '1') {
        include 'main.css';
    } else {
        if (isset($_POST['add_sec']) || isset($_POST['edit_sec'])) {
            foreach ($_POST as $vName => $vValue) {
                if (strpos($vName, 's_a_') !== false && $vValue == '1') {
                    $vAnimArray[] = substr($vName, 4);
                }
                if (strpos($vName, 's_t_') !== false && $vValue == '1') {
                    $vTreeArray[] = substr($vName, 4);
                }
                if (strpos($vName, 's_d_') !== false && $vValue == '1') {
                    $vDecoArray[] = substr($vName, 4);
                }
                if (strpos($vName, 's_b_') !== false && $vValue == '1') {
                    $vBuildingArray[] = substr($vName, 4);
                }
            }
            if (@$_POST['top_x'] < @$_POST['bot_x']) {
                $vTmpX = @$_POST['top_x'];
                @($_POST['top_x'] = @$_POST['bot_x']);
                @($_POST['bot_x'] = $vTmpX);
            }
            if (@$_POST['top_y'] < @$_POST['bot_y']) {
                $vTmpY = @$_POST['top_y'];
                @($_POST['top_y'] = @$_POST['bot_y']);
                @($_POST['bot_y'] = $vTmpY);
            }
        }
        if (isset($_POST['add_sec'])) {
            $sections[] = array('top_x' => @$_POST['top_x'], 'top_y' => @$_POST['top_y'], 'bot_x' => @$_POST['bot_x'], 'bot_y' => @$_POST['bot_y'], 'pat' => @$_POST['pat'], 'seed' => @$_POST['seed'], 'seed2' => @$_POST['seed2'], 'type' => @$_POST['type'], 'anim' => @implode('|', $vAnimArray), 'tree' => @implode('|', $vTreeArray), 'deco' => @implode('|', $vDecoArray), 'building' => @implode('|', $vBuildingArray), 'buyanim' => @$_POST['buyanim'], 'buytree' => @$_POST['buytree'], 'buydeco' => @$_POST['buydeco'], 'active' => @$_POST['active'], 'place' => @$_POST['place'], 'rotate' => @$_POST['rotate'], 'walk' => @$_POST['walk']);
            save_array($sections, 'sections.txt');
        }
        if (isset($_POST['edit_sec'])) {
            $sections[$_POST['num']] = array('top_x' => @$_POST['top_x'], 'top_y' => @$_POST['top_y'], 'bot_x' => @$_POST['bot_x'], 'bot_y' => @$_POST['bot_y'], 'pat' => @$_POST['pat'], 'seed' => @$_POST['seed'], 'seed2' => @$_POST['seed2'], 'type' => @$_POST['type'], 'anim' => @implode('|', $vAnimArray), 'tree' => @implode('|', $vTreeArray), 'deco' => @implode('|', $vDecoArray), 'building' => @implode('|', $vBuildingArray), 'buyanim' => @$_POST['buyanim'], 'buytree' => @$_POST['buytree'], 'buydeco' => @$_POST['buydeco'], 'active' => @$_POST['active'], 'place' => @$_POST['place'], 'rotate' => @$_POST['rotate'], 'walk' => @$_POST['walk']);
            save_array($sections, 'sections.txt');
        }
        if (isset($_POST['vEditActive'])) {
            $sections[$_POST['vEditActive']]['active'] = @$_POST['vActiv'];
            save_array($sections, 'sections.txt');
        }
        if (isset($_POST['vEditPlace'])) {
            $sections[$_POST['vEditPlace']]['place'] = @$_POST['vPlace'];
            save_array($sections, 'sections.txt');
        }
        if (isset($_POST['del_sec'])) {
            $num = @$_POST['num'];
            unset($sections[$num]);
            $sections = array_merge($sections);
            save_array($sections, 'sections.txt');
        }
        ?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css">
<script type="text/javascript" src="functions.js"></script>
</head>
<body>

<script type="text/javascript" src="wz_tooltip.js"></script>
<MAP name='farm'>
<?php 
        $item_loc = array();
        for ($x = 0; $x < $sizeX; $x++) {
            for ($y = 0; $y < $sizeY; $y++) {
                $item_loc[$x][$y] = (object) array('name' => '', 'icon' => '');
            }
        }
        foreach ($objects as $oID => $o) {
            #      $u = $units[$o['itemName']];
            $u = Units_GetUnitByName($o['itemName']);
            if (!isset($u['sizeX'])) {
                $u['sizeX'] = 1;
                $u['sizeY'] = 1;
            }
            if ($o['state'] == 'vertical') {
                $t = $u['sizeX'];
                $u['sizeX'] = $u['sizeY'];
                $u['sizeY'] = $t;
            }
            for ($x = 0; $x < $u['sizeX']; $x++) {
                for ($y = 0; $y < $u['sizeY']; $y++) {
                    $item_loc[$o['position']['x'] + $x][$o['position']['y'] + $y]->name = Sections_GetRealName(Sections_GetValue($u, 'name'), Sections_GetValue($u, 'realname'));
                    $item_loc[$o['position']['x'] + $x][$o['position']['y'] + $y]->icon = Sections_GetValue($u, 'iconurl');
                }
            }
            $vCntItems[$o['itemName']]++;
            foreach ($sections as $vSNum => $section) {
                if ($o['position']['x'] >= $section['bot_x'] && $o['position']['x'] <= $section['top_x'] && $o['position']['y'] >= $section['bot_y'] && $o['position']['y'] <= $section['top_y']) {
                    #          $vSecLoc[$vSNum][(isset($units[$o['itemName']]['realname']) ? $units[$o['itemName']]['realname'] : $units[$o['itemName']]['name']).' ('.$o['itemName'].')']++;
                    $vSecLoc[$vSNum][Units_GetRealnameByName($o['itemName']) . ' (' . $o['itemName'] . ')']++;
                    $vSecItems[$o['itemName']][$vSNum]++;
                    for ($x = 0; $x < $u['sizeX']; $x++) {
                        for ($y = 0; $y < $u['sizeY']; $y++) {
                            $item_loc[$o['position']['x'] + $x][$o['position']['y'] + $y]->snum = $vSNum;
                            $item_loc[$o['position']['x'] + $x][$o['position']['y'] + $y]->stype = $section['type'];
                        }
                    }
                    continue;
                }
            }
        }
        $local_path = "file:///" . str_replace("\\", "/", getcwd()) . '/';
        $remote_path = 'http://static.farmville.com/v' . $flashRevision . '/';
        if ($vSettings['map_main'] == '1' && (isset($_POST['add_sec_form']) || count($sections) == 0) || $vSettings['map_edit'] == '1' && (isset($_POST['edit_sec_form']) || isset($_POST['copy_sec_form'])) || $vSettings['map_new'] == '1' && !(isset($_POST['add_sec_form']) || count($sections) == 0 || isset($_POST['edit_sec_form']) || isset($_POST['copy_sec_form']))) {
            for ($x = 0; $x < $sizeX; $x++) {
                for ($y = 0; $y < $sizeY; $y++) {
                    $vRest = '';
                    if (isset($item_loc[$x][$y]->snum)) {
                        $vAppend = '<br>in Section ' . $item_loc[$x][$y]->snum . ' (' . $item_loc[$x][$y]->stype . ')<br>';
                        $vAppend2 = 'click to edit Section';
                        $vAppend3 = ' onclick=window.location.href="index.php?edit_sec_form=Edit&num=' . $item_loc[$x][$y]->snum . '"';
                    } else {
                        $vAppend = '';
                        $vAppend2 = '';
                        $vAppend3 = '';
                    }
                    if ($vSettings['tooltip'] == 'small') {
                        if (isset($_POST['add_sec_form']) || isset($_POST['edit_sec_form']) || isset($_POST['copy_sec_form']) || count($sections) == 0) {
                            $vRest = " onmouseover=\"Tip('<i>click to set<br><b>'+vTopBot+'</b><br>coordinates</i>', TITLE, '" . $x . " - " . $y . "', DELAY, 1)\" onmouseout=\"UnTip()\" onclick=\"fClick(" . $x . "," . $y . ");this.onmouseover();\"";
                        } else {
                            $vRest = " onmouseover=\"Tip('" . $vAppend2 . "', TITLE, '" . $x . "-" . $y . "', DELAY, 1)\" onmouseout=\"UnTip()\" " . $vAppend3;
                        }
                    }
                    if ($vSettings['tooltip'] == 'full') {
                        $info = $item_loc[$x][$y]->name ? str_replace("'", "\\'", $item_loc[$x][$y]->name) . "<br/><img src=\\'" . (file_exists($item_loc[$x][$y]->icon) ? $local_path : $remote_path) . $item_loc[$x][$y]->icon . "\\' width=100 height=100/>" : "";
                        if (strlen($info) == 0) {
                            $info = 'empty place';
                        }
                        if (isset($_POST['add_sec_form']) || isset($_POST['edit_sec_form']) || isset($_POST['copy_sec_form']) || count($sections) == 0) {
                            $vRest = " onmouseover=\"Tip('" . $info . $vAppend . "<br><i>click to set<br><b>'+vTopBot+'</b><br>coordinates</i>', TITLE, '" . $x . " - " . $y . "', DELAY, 1)\" onmouseout=\"UnTip()\" onclick=\"fClick(" . $x . "," . $y . ");this.onmouseover();\"";
                        } else {
                            $vRest = " onmouseover=\"Tip('" . $info . $vAppend . $vAppend2 . "', TITLE, '" . $x . "-" . $y . "', DELAY, 1)\" onmouseout=\"UnTip()\" " . $vAppend3;
                        }
                    }
                    Sections_Draw_MapThing($x, $y, 1, 1, $vSettings['ratio'], $vRest);
                }
            }
        }
        ?>
	<h1>Sections <?php 
        echo sections_Version;
        ?>
<font size=+1> by
	ralphm2004 <?php 
        echo sections_Version_Date;
        ?>
</font></h1>
	<span onclick="fShowHide('tab_setting')"><small>Show/Hide Settings</small></span>
	<br>
	<table border="0" cellspacing=0 cellpadding=0 width="100%"
		style="display: none" id="tab_setting">
		<tr>
			<td>
			<form action="index.php" method="post">
			<table border="0" cellspacing="0" cellpadding="4">
				<tr valign=top>
					<td><?php 
        echo 'Zoom: <select name="ratio" onchange="this.form.submit();">';
        echo '<option value="1" ' . ($vSettings['ratio'] == '1' ? 'selected' : '') . '>50%</option>';
        echo '<option value="2" ' . ($vSettings['ratio'] == '2' ? 'selected' : '') . '>75%</option>';
        echo '<option value="3" ' . ($vSettings['ratio'] == '3' ? 'selected' : '') . '>100%</option>';
        echo '<option value="4" ' . ($vSettings['ratio'] == '4' ? 'selected' : '') . '>150%</option>';
        echo '<option value="5" ' . ($vSettings['ratio'] == '5' ? 'selected' : '') . '>200%</option>';
        echo '</select>';
        ?>
</td>
					<td>
					<table border="0" cellspacing="0" cellpadding="0">
						<tr valign=top>
							<td>Show Map:</td>
							<td><?php 
        echo '<input type="checkbox" name="map_main" value="1" ' . ($vSettings['map_main'] != 0 ? 'checked ' : '') . '>&nbsp;<small>Main Screen</small><br>';
        echo '<input type="checkbox" name="map_edit" value="1" ' . ($vSettings['map_edit'] != 0 ? 'checked ' : '') . '>&nbsp;<small>Edit Screen</small><br>';
        echo '<input type="checkbox" name="map_new" value="1" ' . ($vSettings['map_new'] != 0 ? 'checked ' : '') . '>&nbsp;<small>New Screen</small><br>';
        ?>
</td>
						</tr>
					</table>
					</td>
					<td>
					<table border="0" cellspacing="0" cellpadding="0">
						<tr valign=top>
							<td>Show Tooltip:</td>
							<td><?php 
        echo '<input type="radio" name="tooltip" value="full" ' . ($vSettings['tooltip'] == 'full' ? 'checked ' : '') . '>&nbsp;<small>Full</small><br>';
        echo '<input type="radio" name="tooltip" value="small" ' . ($vSettings['tooltip'] == 'small' ? 'checked ' : '') . '>&nbsp;<small>Coordinates</small><br>';
        echo '<input type="radio" name="tooltip" value="off" ' . ($vSettings['tooltip'] == 'off' ? 'checked ' : '') . '>&nbsp;<small>Off</small><br>';
        ?>
</td>
						</tr>
					</table>
					</td>
					<td>
					<button type="submit" name="vSave" value="Save"
						onmouseover="this.className='hover';"
						onmouseout="this.className='';">Save</button>
					</td>
				</tr>
			</table>
			</form>
			</td>
		</tr>
	</table>

	<?php 
        if (!function_exists("gd_info")) {
            echo "<font size='+4' color='red'>GD is required to render the farm map image. Please enable it. (See the readme file on how to do this).</font>";
        } else {
            if (isset($_POST['add_sec_form']) || count($sections) == 0) {
                if ($vSettings['map_new'] == '1') {
                    echo "<img src='index.php?image=1" . "&edit_sec_form=" . (isset($_POST['edit_sec_form']) ? $_POST['edit_sec_form'] : '') . "&copy_sec_form=" . (isset($_POST['copy_sec_form']) ? $_POST['copy_sec_form'] : '') . "&num=" . (isset($_POST['num']) ? $_POST['num'] : '') . "' USEMAP='#farm' border=0 style='cursor:crosshair;'/><br/>" . "<small>Hover over the image to see coordinates, click to set top/bottom coordinates</small><br/>\n";
                }
            } elseif (isset($_POST['edit_sec_form']) || isset($_POST['copy_sec_form'])) {
                if ($vSettings['map_edit'] == '1') {
                    echo "<img src='index.php?image=1" . "&edit_sec_form=" . (isset($_POST['edit_sec_form']) ? $_POST['edit_sec_form'] : '') . "&copy_sec_form=" . (isset($_POST['copy_sec_form']) ? $_POST['copy_sec_form'] : '') . "&num=" . (isset($_POST['num']) ? $_POST['num'] : '') . "' USEMAP='#farm' border=0 style='cursor:crosshair;'/><br/>" . "<small>Hover over the image to see coordinates, click to set top/bottom coordinates</small><br/>\n";
                }
            } else {
                if ($vSettings['map_main'] == '1') {
                    echo "<img src='index.php?image=1" . "' USEMAP='#farm' border=0/><br/>" . "<small>Hover over the image to see coordinates</small><br/>\n";
                }
            }
        }
        #    $vSectionUnitsArray=Sections_GetUnits($units,$flashRevision);
        $vSectionUnitsArray = Sections_GetUnits($flashRevision);
        $vSeeds = $vSectionUnitsArray['vSeeds'];
        $vAnimals = $vSectionUnitsArray['vAnimals'];
        $vTrees = $vSectionUnitsArray['vTrees'];
        $vDecorations = $vSectionUnitsArray['vDecorations'];
        $vBuildings = $vSectionUnitsArray['vBuildings'];
        $vBuyAnimals = $vSectionUnitsArray['vBuyAnimals'];
        $vBuyTrees = $vSectionUnitsArray['vBuyTrees'];
        $vBuyDecorations = $vSectionUnitsArray['vBuyDecorations'];
        $vAnimalUnits = $vSectionUnitsArray['vAnimalUnits'];
        $vAll = $vSectionUnitsArray['vAll'];
        if (isset($_POST['add_sec_form']) || isset($_POST['copy_sec_form']) || isset($_POST['edit_sec_form']) || count($sections) == 0) {
            if (isset($_POST['edit_sec_form'])) {
                echo '<h4>Edit section ' . $_POST['num'] . '</h4>';
                $action = 'edit_sec';
                $thissec = $sections[$_POST['num']];
            } elseif (isset($_POST['copy_sec_form'])) {
                echo '<h4>Copy section ' . $_POST['num'] . '</h4>';
                $action = 'add_sec';
                $thissec = $sections[$_POST['num']];
                $_POST['num'] = '';
            } else {
                echo '<h4>Add section</h4>';
                $action = 'add_sec';
                $thissec = array('top_x' => 8, 'top_y' => 8, 'bot_x' => 0, 'bot_y' => 0, 'pat' => 'none', 'seed' => '---', 'seed2' => '---', 'type' => 'seed', 'anim' => '', 'tree' => '', 'deco' => '', 'buyanim' => '', 'buytree' => '', 'buydeco' => '', 'active' => 1, 'place' => '');
            }
            $vGiftboxContent = Sections_GetGiftboxContent();
            echo '<form action="' . sections_URL . '" name=myform>';
            echo '<button type="submit" name="' . $action . '" value="Save" onmouseover="this.className=\'hover\';" onmouseout="this.className=\'\';">Save</button>&nbsp;';
            echo '<button type="submit" name="undo" value="Back" onmouseover="this.className=\'hover\';" onmouseout="this.className=\'\';">Back</button>';
            echo '<input type="hidden" name="num" value="' . @$_POST['num'] . '">';
            echo '<br/><br/>';
            echo '<fieldset class="cream">';
            echo '<small>A Section consists of a square located on the map above. Hover over the map, and find the coordinates of the <b>top</b> and <b>bottom</b> corners of the square you want to define your section in.</small><br/>';
            echo '<span style="width: 50px">Active</span>';
            echo '<input type="checkbox" name="active" value="1" ' . ($thissec['active'] != 0 ? 'checked ' : '') . '>&nbsp;&nbsp; <small>(Switch this Section on/off)</small><br>';
            echo '<span style="width: 50px">Place/Plow</span>';
            echo '<input type="checkbox" name="place" value="1" ' . ($thissec['place'] == 1 ? 'checked ' : '') . '>&nbsp;&nbsp; <small>(Place Items from GiftBox / Plow plot</small><br>';
            echo '<span style="width: 150px">Top corner:</span>';
            echo '<input type="text" name="top_x" id="top_x" value="' . $thissec['top_x'] . '" size=2 />';
            echo '&nbsp;&nbsp;-&nbsp;&nbsp;';
            echo '<input type="text" name="top_y" id="top_y" value="' . $thissec['top_y'] . '" size=2 />';
            echo '<br/>';
            echo '<span style="width: 150px">Bottom corner:</span>';
            echo '<input type="text" name="bot_x" id="bot_x" value="' . $thissec['bot_x'] . '" size=2 />';
            echo '&nbsp;&nbsp;-&nbsp;&nbsp;';
            echo '<input type="text" name="bot_y" id="bot_y" value="' . $thissec['bot_y'] . '" size=2 />';
            echo '<br/>';
            echo '</fieldset>';
            echo '<br/>';
            echo '<fieldset class="cream">';
            echo '<legend>';
            echo '<b>Section Type:</b>&nbsp;';
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'seed') {
                echo '<input onclick="fShowTab(\'tab_seed\')" type=radio value="seed" name="type" ' . (@isset($thissec['type']) && $thissec['type'] == 'seed' ? 'checked' : '') . '>Seed &nbsp;&nbsp;&nbsp;';
            }
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'anim') {
                echo '<input onclick="fShowTab(\'tab_anim\')" type=radio value="anim" name="type" ' . (@isset($thissec['type']) && $thissec['type'] == 'anim' ? 'checked' : '') . '>Animal &nbsp;&nbsp;&nbsp;';
            }
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'tree') {
                echo '<input onclick="fShowTab(\'tab_tree\')" type=radio value="tree" name="type" ' . (@isset($thissec['type']) && $thissec['type'] == 'tree' ? 'checked' : '') . '>Tree &nbsp;&nbsp;&nbsp;';
            }
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'deco') {
                echo '<input onclick="fShowTab(\'tab_deco\')" type=radio value="deco" name="type" ' . (@isset($thissec['type']) && $thissec['type'] == 'deco' ? 'checked' : '') . '>Decoration &nbsp;&nbsp;&nbsp;';
            }
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'building') {
                echo '<input onclick="fShowTab(\'tab_building\')" type=radio value="building" name="type" ' . (@isset($thissec['type']) && $thissec['type'] == 'building' ? 'checked' : '') . '>Buildings &nbsp;&nbsp;&nbsp;';
            }
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'buyanim') {
                echo '<input onclick="fShowTab(\'tab_buyanim\')" type=radio value="buyanim" name="type" ' . (@isset($thissec['type']) && $thissec['type'] == 'buyanim' ? 'checked' : '') . '>Buy Animal &nbsp;&nbsp;&nbsp;';
            }
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'buytree') {
                echo '<input onclick="fShowTab(\'tab_buytree\')" type=radio value="buytree" name="type" ' . (@isset($thissec['type']) && $thissec['type'] == 'buytree' ? 'checked' : '') . '>Buy Tree &nbsp;&nbsp;&nbsp;';
            }
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'buydeco') {
                echo '<input onclick="fShowTab(\'tab_buydeco\')" type=radio value="buydeco" name="type" ' . (@isset($thissec['type']) && $thissec['type'] == 'buydeco' ? 'checked' : '') . '>Buy Decoration &nbsp;&nbsp;&nbsp;';
            }
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'dontmove') {
                echo '<input onclick="fShowTab(\'tab_dontmove\')" type=radio value="dontmove" name="type" ' . (@isset($thissec['type']) && $thissec['type'] == 'dontmove' ? 'checked' : '') . '>Don\'t Move &nbsp;&nbsp;&nbsp;';
            }
            echo '</legend>';
            echo '<br>';
            ######################################## seed
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'seed') {
                echo '<table id="tab_seed" border="0" cellspacing=0 cellpadding=0 width="100%" style="display: ' . (@isset($thissec['type']) && $thissec['type'] == 'seed' ? 'block' : 'none') . '">';
                echo '<tr><td>';
                echo '<span style="width: 150px">Pattern:</span>';
                echo '<select name="pat" id="pat">';
                echo '<option value="none" ' . ($thissec['pat'] == 'none' ? 'selected' : '') . '>None (just use first seed)</option>';
                echo '<option value="checkerboard" ' . ($thissec['pat'] == 'checkerboard' ? 'selected' : '') . '>Checkerboard</option>';
                echo '<option value="striped-row" ' . ($thissec['pat'] == 'striped-row' ? 'selected' : '') . '>Striped (north to south)</option>';
                echo '<option value="striped-col" ' . ($thissec['pat'] == 'striped-col' ? 'selected' : '') . '>Striped (east to west)</option>';
                echo '<option value="squared1" ' . ($thissec['pat'] == 'squared1' ? 'selected' : '') . '>Squared variant 1</option>';
                echo '<option value="squared2" ' . ($thissec['pat'] == 'squared2' ? 'selected' : '') . '>Squared variant 2</option>';
                echo '<option value="corner-n" ' . ($thissec['pat'] == 'corner-n' ? 'selected' : '') . '>Corner (north) </option>';
                echo '<option value="corner-e" ' . ($thissec['pat'] == 'corner-e' ? 'selected' : '') . '>Corner (east)</option>';
                echo '<option value="corner-s" ' . ($thissec['pat'] == 'corner-s' ? 'selected' : '') . '>Corner (south)</option>';
                echo '<option value="corner-w" ' . ($thissec['pat'] == 'corner-w' ? 'selected' : '') . '>Corner (west)</option>';
                echo '</select><br/>';
                echo '<span style="width: 150px">First Seed:</span>';
                echo '<select name="seed" id="seed">';
                echo '<option ' . ($thissec['seed'] == '---' || $thissec['seed'] == '' ? 'selected ' : '') . 'value="---">please select</option>';
                echo '<option ' . ($thissec['seed'] == 'just_plow' ? 'selected ' : '') . 'value="just_plow">place/plow plot, dont seed it</option>';
                foreach ($vSeeds as $vName => $vRealName) {
                    echo '<option ' . ($thissec['seed'] == htmlentities($vName) ? 'selected ' : '') . 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '<option>---- Seeder-Glitch ----</option>';
                foreach ($vAll as $vName => $vRealName) {
                    echo '<option ' . ($thissec['seed'] == htmlentities($vName) ? 'selected ' : '') . 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '</select><br/>';
                echo '<span style="width: 150px">Second Seed:</span>';
                echo '<select name="seed2" id="seed2">';
                echo '<option ' . ($thissec2['seed'] == '---' || $thissec2['seed'] == '' ? 'selected ' : '') . 'value="---">please select</option>';
                foreach ($vSeeds as $vName => $vRealName) {
                    echo '<option ' . ($thissec['seed2'] == htmlentities($vName) ? 'selected ' : '') . 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '</select> ';
                echo '(Used when pattern not none)<br/>';
                echo '</td></tr>';
                echo '</table>';
            }
            ######################################## anim
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'anim') {
                echo '<script>';
                echo 'function fCheckUncheckAnimUnit(vUnit,vCheck){', "\n";
                foreach ($vAnimalUnits as $vUnitName => $vArray) {
                    echo 'if(vUnit=="', $vUnitName, '" || vUnit=="all") {', "\n";
                    foreach ($vArray as $vName => $Tmp) {
                        echo 'document.forms["myform"].elements["s_a_' . htmlentities($vName) . '"].checked=vCheck;', "\n";
                    }
                    echo '}', "\n";
                }
                echo 'document.forms["myform"].elements["vCheckAllAnimal"].value="---"', "\n";
                echo 'document.forms["myform"].elements["vUnCheckAllAnimal"].value="---"', "\n";
                echo '}', "\n";
                echo '</script>', "\n";
                echo '<table id="tab_anim" border="0" cellspacing=0 cellpadding=0 width="100%" style="display: ';
                echo (@isset($thissec['type']) && $thissec['type'] == 'anim' ? 'block' : 'none') . '">';
                echo '<tr><td>';
                echo '<table border="0" cellspacing="1" cellpadding="0" class="cream2"><tr valign=top><td>';
                echo 'Walk:&nbsp;';
                echo '</td><td>';
                echo '<input type="radio" name="walk" value="nothing" ', @isset($thissec['walk']) && $thissec['walk'] == 'nothing' || $thissec['walk'] == '' ? 'checked' : '', '>&nbsp;dont change<br>';
                echo '<input type="radio" name="walk" value="walk" ', @isset($thissec['walk']) && $thissec['walk'] == 'walk' ? 'checked' : '', '>&nbsp;allow animals to walk<br>';
                echo '<input type="radio" name="walk" value="stay" ', @isset($thissec['walk']) && $thissec['walk'] == 'stay' ? 'checked' : '', '>&nbsp;forbid animals to walk<br>';
                echo '</td><td>&nbsp;&nbsp;&nbsp;</td><td>';
                echo 'Rotate:&nbsp;';
                echo '</td><td>';
                echo '<input type="radio" name="rotate" value="nothing" ', @isset($thissec['rotate']) && $thissec['rotate'] == 'nothing' || $thissec['rotate'] == '' ? 'checked' : '', '>&nbsp;dont change<br>';
                echo '<table border="0" cellspacing="0" cellpadding="0" class="cream2">
      <tr>
        <td align="right">top-left&nbsp;<input type="radio" name="rotate" value="3" ', @isset($thissec['rotate']) && $thissec['rotate'] == '3' ? 'checked' : '', '></td>
        <td><input type="radio" name="rotate" value="2" ', @isset($thissec['rotate']) && $thissec['rotate'] == '2' ? 'checked' : '', '>&nbsp;top-right</td>
      </tr>
      <tr>
        <td align="right">bottom-left&nbsp;<input type="radio" name="rotate" value="0" ', @isset($thissec['rotate']) && $thissec['rotate'] == '0' ? 'checked' : '', '></td>
        <td><input type="radio" name="rotate" value="1" ', @isset($thissec['rotate']) && $thissec['rotate'] == '1' ? 'checked' : '', '>&nbsp;bottom-right</td>
      </tr>
    </table>';
                echo '</td></tr></table><br>';
                echo '&nbsp;Select: <select name="vCheckAllAnimal" onchange="fCheckUncheckAnimUnit(this.value,true)"><option value="---">please select</option><option value="all">all animals</option>', "\n";
                foreach ($vAnimalUnits as $vUnitName => $vTmp) {
                    echo '<option value="', $vUnitName, '">', $vUnitName, '</option>', "\n";
                }
                echo '</select>', "\n";
                echo '&nbsp;UnSelect: <select name="vUnCheckAllAnimal" onchange="fCheckUncheckAnimUnit(this.value,false)"><option value="---">please select</option><option value="all">all animals</option>', "\n";
                foreach ($vAnimalUnits as $vUnitName => $vTmp) {
                    echo '<option value="', $vUnitName, '">', $vUnitName, '</option>', "\n";
                }
                echo '</select>', "\n";
                echo '<br>';
                echo '<table class="cream" border="0" cellspacing="0" cellpadding="0">';
                echo '<tr bgcolor=white>';
                echo '<th></th><th>RealName</th><th>Name</th><th>In Giftbox</th><th>In Sections</th><th>On the Farm</th>';
                echo '</tr>';
                $vArray = explode('|', $thissec['anim']);
                foreach ($vAnimals as $vName => $vRealName) {
                    echo '<tr bgcolor=white valign=top>';
                    echo '<td>';
                    echo '<input type="checkbox" name="s_a_', htmlentities($vName), '" value="1" ';
                    echo in_array(htmlentities($vName), $vArray) ? 'checked ' : '', '>';
                    echo '</td><td>', $vRealName, '</td><td>', $vName, '</td>';
                    echo '<td>';
                    $vCntGB = 0;
                    foreach ($vGiftboxContent['animal'] as $vItem) {
                        if ($vItem['name'] == $vName) {
                            $vCntGB++;
                        }
                    }
                    if ($vCntGB > 0) {
                        echo '<nobr>', $vCntGB, 'x in GiftBox&nbsp;&nbsp;</nobr> ';
                    }
                    echo '</td>';
                    echo '<td>';
                    $vCntInSections = 0;
                    foreach ($vSecItems[$vName] as $vSecNum => $count) {
                        echo '<nobr>', $count, 'x in S.', $vSecNum, '&nbsp;&nbsp;</nobr> ';
                        $vCntInSections += $count;
                    }
                    echo '</td>';
                    echo '<td>';
                    $vCntWorld = $vCntItems[$vName];
                    if ($vCntWorld > 0) {
                        echo '<nobr>', $vCntWorld, 'x on Farm';
                        if ($vCntInSections != $vCntWorld && $vCntInSections > 0) {
                            echo ' / ', $vCntWorld - $vCntInSections, 'x not in Sections';
                        }
                        echo '</nobr>';
                    }
                    echo '</td>';
                    echo '</tr>';
                }
                echo '</table>';
                echo '</td></tr>';
                echo '</table>';
            }
            ######################################## tree
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'tree') {
                echo '<script>';
                echo 'function fCheckUncheckTree(vCheck){', "\n";
                foreach ($vTrees as $vName => $vRealName) {
                    echo 'document.forms["myform"].elements["s_t_' . htmlentities($vName) . '"].checked=vCheck;', "\n";
                }
                echo '}', "\n";
                echo '</script>';
                echo '<table id="tab_tree" border="0" cellspacing=0 cellpadding=0 width="100%" style="display: ';
                echo (@isset($thissec['type']) && $thissec['type'] == 'tree' ? 'block' : 'none') . '">';
                echo '<tr><td>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:fCheckUncheckTree(true)">Select All</a>';
                echo '&nbsp; <a href="javascript:fCheckUncheckTree(false)">UnSelect All</a><br>';
                echo '<table class="cream" border="0" cellspacing="0" cellpadding="0">';
                echo '<tr bgcolor=white>';
                echo '<th></th><th>RealName</th><th>Name</th><th>In Giftbox</th><th>In Sections</th><th>On the Farm</th>';
                echo '</tr>';
                $vArray = explode('|', $thissec['tree']);
                foreach ($vTrees as $vName => $vRealName) {
                    echo '<tr bgcolor=white valign=top>';
                    echo '<td>';
                    echo '<input type="checkbox" name="s_t_', htmlentities($vName), '" value="1" ';
                    echo in_array(htmlentities($vName), $vArray) ? 'checked ' : '', '>';
                    echo '</td><td>', $vRealName, '</td><td>', $vName, '</td>';
                    echo '<td>';
                    $vCntGB = 0;
                    foreach ($vGiftboxContent['tree'] as $vItem) {
                        if ($vItem['name'] == $vName) {
                            $vCntGB++;
                        }
                    }
                    if ($vCntGB > 0) {
                        echo '<nobr>', $vCntGB, 'x in GiftBox&nbsp;&nbsp;</nobr> ';
                    }
                    echo '</td>';
                    echo '<td>';
                    $vCntInSections = 0;
                    foreach ($vSecItems[$vName] as $vSecNum => $count) {
                        echo '<nobr>', $count, 'x in S.', $vSecNum, '&nbsp;&nbsp;</nobr> ';
                        $vCntInSections += $count;
                    }
                    echo '</td>';
                    echo '<td>';
                    $vCntWorld = $vCntItems[$vName];
                    if ($vCntWorld > 0) {
                        echo '<nobr>', $vCntWorld, 'x on Farm';
                        if ($vCntInSections != $vCntWorld && $vCntInSections > 0) {
                            echo ' / ', $vCntWorld - $vCntInSections, 'x not in Sections';
                        }
                        echo '</nobr>';
                    }
                    echo '</td>';
                    echo '</tr>';
                }
                echo '</table>';
                echo '</td></tr>';
                echo '</table>';
            }
            ######################################## deco
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'deco') {
                $vEggNewNameArray[] = 'egg_white';
                $vEggOldNameArray[] = 'mysteryeggwhite';
                $vEggNewNameArray[] = 'egg_brown';
                $vEggOldNameArray[] = 'mysteryeggbrown';
                $vEggNewNameArray[] = 'egg_black';
                $vEggOldNameArray[] = 'mysteryeggblack';
                $vEggNewNameArray[] = 'egg_gold';
                $vEggOldNameArray[] = 'mysteryegggold';
                $vEggNewNameArray[] = 'egg_cornish';
                $vEggOldNameArray[] = 'mysteryeggcornish';
                $vEggNewNameArray[] = 'egg_rhodered';
                $vEggOldNameArray[] = 'mysteryeggrhodered';
                $vEggNewNameArray[] = 'egg_scotsgrey';
                $vEggOldNameArray[] = 'mysteryeggscotsgrey';
                echo '<script>';
                echo 'function fCheckUncheckDeco(vCheck){', "\n";
                foreach ($vDecorations as $vName => $vRealName) {
                    echo 'document.forms["myform"].elements["s_d_' . htmlentities($vName) . '"].checked=vCheck;', "\n";
                }
                echo '}', "\n";
                echo '</script>';
                echo '<table id="tab_deco" border="0" cellspacing=0 cellpadding=0 width="100%" style="display: ';
                echo (@isset($thissec['type']) && $thissec['type'] == 'deco' ? 'block' : 'none') . '">';
                echo '<tr><td>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:fCheckUncheckDeco(true)">Select All</a>';
                echo '&nbsp; <a href="javascript:fCheckUncheckDeco(false)">UnSelect All</a><br>';
                echo '<table class="cream" border="0" cellspacing="0" cellpadding="0">';
                echo '<tr bgcolor=white>';
                echo '<th></th><th>RealName</th><th>Name</th><th>In Giftbox</th><th>In Sections</th><th>On the Farm</th>';
                echo '</tr>';
                $vArray = explode('|', $thissec['deco']);
                foreach ($vDecorations as $vName => $vRealName) {
                    echo '<tr bgcolor=white valign=top>';
                    echo '<td>';
                    echo '<input type="checkbox" name="s_d_', htmlentities($vName), '" value="1" ';
                    echo in_array(htmlentities($vName), $vArray) ? 'checked ' : '', '>';
                    echo '</td><td>', $vRealName, '</td><td>', $vName, '</td>';
                    echo '<td>';
                    $vCntGB = 0;
                    foreach ($vGiftboxContent['decoration'] as $vItem) {
                        if (str_replace($vEggOldNameArray, $vEggNewNameArray, $vItem['name']) == $vName) {
                            $vCntGB++;
                        }
                    }
                    if ($vCntGB > 0) {
                        echo '<nobr>', $vCntGB, 'x in GiftBox&nbsp;&nbsp;</nobr> ';
                    }
                    echo '</td>';
                    echo '<td>';
                    $vCntInSections = 0;
                    if (strpos($vName, 'egg_') !== false) {
                        foreach ($vSecItems[str_replace($vEggNewNameArray, $vEggOldNameArray, $vName)] as $vSecNum => $count) {
                            echo '<nobr>', $count, 'x in S.', $vSecNum, '&nbsp;&nbsp;</nobr> ';
                            $vCntInSections += $count;
                        }
                        $vCntWorld = $vCntItems[str_replace($vEggNewNameArray, $vEggOldNameArray, $vName)];
                    } else {
                        foreach ($vSecItems[$vName] as $vSecNum => $count) {
                            echo '<nobr>', $count, 'x in S.', $vSecNum, '&nbsp;&nbsp;</nobr> ';
                            $vCntInSections += $count;
                        }
                        $vCntWorld = $vCntItems[$vName];
                    }
                    echo '</td>';
                    echo '<td>';
                    if ($vCntWorld > 0) {
                        echo '<nobr>', $vCntWorld, 'x on Farm';
                        if ($vCntInSections != $vCntWorld && $vCntInSections > 0) {
                            echo ' / ', $vCntWorld - $vCntInSections, 'x not in Sections';
                        }
                        echo '</nobr>';
                    }
                    echo '</td>';
                    echo '</tr>';
                }
                echo '</table>';
                echo '</td></tr>';
                echo '</table>';
            }
            ######################################## building
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'building') {
                echo '<script>';
                echo 'function fCheckUncheckBuilding(vCheck){', "\n";
                foreach ($vBuildings as $vName => $vRealName) {
                    echo 'document.forms["myform"].elements["s_d_' . htmlentities($vName) . '"].checked=vCheck;', "\n";
                }
                echo '}', "\n";
                echo '</script>';
                echo '<table id="tab_building" border="0" cellspacing=0 cellpadding=0 width="100%" style="display: ';
                echo (@isset($thissec['type']) && $thissec['type'] == 'building' ? 'block' : 'none') . '">';
                echo '<tr><td>';
                echo '&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:fCheckUncheckBuilding(true)">Select All</a>';
                echo '&nbsp; <a href="javascript:fCheckUncheckBuilding(false)">UnSelect All</a><br>';
                echo '<table class="cream" border="0" cellspacing="0" cellpadding="0">';
                echo '<tr bgcolor=white>';
                echo '<th></th><th>RealName</th><th>Name</th><th>In Giftbox</th><th>In Sections</th><th>On the Farm</th>';
                echo '</tr>';
                $vArray = explode('|', $thissec['building']);
                foreach ($vBuildings as $vName => $vRealName) {
                    echo '<tr bgcolor=white valign=top>';
                    echo '<td>';
                    echo '<input type="checkbox" name="s_b_', htmlentities($vName), '" value="1" ';
                    echo in_array(htmlentities($vName), $vArray) ? 'checked ' : '', '>';
                    echo '</td><td>', $vRealName, '</td><td>', $vName, '</td>';
                    echo '<td>';
                    $vCntGB = 0;
                    foreach ($vGiftboxContent['building'] as $vItem) {
                        if ($vItem['name'] == $vName) {
                            $vCntGB++;
                        }
                    }
                    if ($vCntGB > 0) {
                        echo '<nobr>', $vCntGB, 'x in GiftBox&nbsp;&nbsp;</nobr> ';
                    }
                    echo '</td>';
                    echo '<td>';
                    $vCntInSections = 0;
                    foreach ($vSecItems[$vName] as $vSecNum => $count) {
                        echo '<nobr>', $count, 'x in S.', $vSecNum, '&nbsp;&nbsp;</nobr> ';
                        $vCntInSections += $count;
                    }
                    $vCntWorld = $vCntItems[$vName];
                    echo '</td>';
                    echo '<td>';
                    if ($vCntWorld > 0) {
                        echo '<nobr>', $vCntWorld, 'x on Farm';
                        if ($vCntInSections != $vCntWorld && $vCntInSections > 0) {
                            echo ' / ', $vCntWorld - $vCntInSections, 'x not in Sections';
                        }
                        echo '</nobr>';
                    }
                    echo '</td>';
                    echo '</tr>';
                }
                echo '</table>';
                echo '</td></tr>';
                echo '</table>';
            }
            ######################################## buyanim
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'buyanim') {
                echo '<table id="tab_buyanim" border="0" cellspacing=0 cellpadding=0 width="100%" style="display: ' . (@isset($thissec['type']) && $thissec['type'] == 'buyanim' ? 'block' : 'none') . '">';
                echo '<tr><td>';
                echo '<select name="buyanim" id="buyanim">';
                echo '<option ', $thissec['buyanim'] == '---' || $thissec['buyanim'] == '' ? 'selected ' : '', 'value="---">please select</option>';
                echo '<option style="background-color:#dddddd" value="">==== Buyable, Coins ===</option>';
                foreach ($vBuyAnimals['coins'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buyanim'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '<option style="background-color:#dddddd" value="">==== Buyable, Cash ===</option>';
                foreach ($vBuyAnimals['cash'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buyanim'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '<option style="background-color:#dddddd" value="">==== Not Buyable, Coins ===</option>';
                foreach ($vBuyAnimals['nocoins'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buyanim'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '<option style="background-color:#dddddd" value="">==== Not Buyable, Cash ===</option>';
                foreach ($vBuyAnimals['nocash'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buyanim'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '</select>';
                echo '</td></tr>';
                echo '</table>';
            }
            ######################################## buytree
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'buytree') {
                echo '<table id="tab_buytree" border="0" cellspacing=0 cellpadding=0 width="100%" style="display: ' . (@isset($thissec['type']) && $thissec['type'] == 'buytree' ? 'block' : 'none') . '">';
                echo '<tr><td>';
                echo '<select name="buytree" id="buytree">';
                echo '<option ', $thissec['buytree'] == '---' || $thissec['buytree'] == '' ? 'selected ' : '', 'value="---">please select</option>';
                echo '<option style="background-color:#dddddd" value="">==== Buyable, Coins ===</option>';
                foreach ($vBuyTrees['coins'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buytree'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '<option style="background-color:#dddddd" value="">==== Buyable, Cash ===</option>';
                foreach ($vBuyTrees['cash'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buytree'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '<option style="background-color:#dddddd" value="">==== Not Buyable, Coins ===</option>';
                foreach ($vBuyTrees['nocoins'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buytree'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '<option style="background-color:#dddddd" value="">==== Not Buyable, Cash ===</option>';
                foreach ($vBuyTrees['nocash'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buytree'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '</select>';
                echo '</td></tr>';
                echo '</table>';
            }
            ######################################## buydeco
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'buydeco') {
                echo '<table id="tab_buydeco" border="0" cellspacing=0 cellpadding=0 width="100%" style="display: ' . (@isset($thissec['type']) && $thissec['type'] == 'buydeco' ? 'block' : 'none') . '">';
                echo '<tr><td>';
                echo '<select name="buydeco" id="buydeco">';
                echo '<option ', $thissec['buydeco'] == '---' || $thissec['buydeco'] == '' ? 'selected ' : '', 'value="---">please select</option>';
                echo '<option style="background-color:#dddddd" value="">==== Buyable, Coins ===</option>';
                foreach ($vBuyDecorations['coins'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buydeco'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '<option style="background-color:#dddddd" value="">==== Buyable, Cash ===</option>';
                foreach ($vBuyDecorations['cash'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buydeco'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '<option style="background-color:#dddddd" value="">==== Not Buyable, Coins ===</option>';
                foreach ($vBuyDecorations['nocoins'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buydeco'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '<option style="background-color:#dddddd" value="">==== Not Buyable, Cash ===</option>';
                foreach ($vBuyDecorations['nocash'] as $vName => $vRealName) {
                    echo '<option ', $thissec['buydeco'] == htmlentities($vName) ? 'selected ' : '', 'value="' . htmlentities($vName) . '">' . htmlentities($vRealName . ' (' . $vName . ')') . '</option>';
                }
                echo '</select>';
                echo '</td></tr>';
                echo '</table>';
            }
            ######################################## dontmove
            if (!isset($_POST['edit_sec_form']) || $thissec['type'] == 'dontmove') {
                echo '<table id="tab_dontmove" border="0" cellspacing=0 cellpadding=0 width="100%" style="display: ' . (@isset($thissec['type']) && $thissec['type'] == 'dontmove' ? 'block' : 'none') . '">';
                echo '<tr><td>';
                echo '</td></tr>';
                echo '</table>';
            }
            echo '</fieldset><br/>';
            echo '<button type="submit" name="' . $action . '" value = "Save" onmouseover="this.className=\'hover\';" onmouseout="this.className=\'\';">Save</button>&nbsp;';
            echo '<button type="submit" name="undo" value="Back" onmouseover="this.className=\'hover\';" onmouseout="this.className=\'\';">Back</button>';
            echo '</form>';
        } else {
            echo '<table border="0" cellspacing="7" cellpadding="0"><tr valign=center>';
            echo '<td><big><b>Sections</b></big></td>';
            echo '<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>';
            echo '<form action="index.php" method="post">';
            echo '<td>';
            echo '<button type="submit" name="add_sec_form" value="Add section" onmouseover="this.className=\'hover\';" onmouseout="this.className=\'\';">Add section</button>';
            echo '</td>';
            echo '</form>';
            echo '<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>';
            echo '<form action="index.php" method="post">';
            echo '<input type="hidden" name="vDoExpension" value="on">';
            echo '<td>';
            echo '<button onclick="javascript:if(confirm(\'*REALLY* UPGRADED FARM? All Sections get move 8x8 Spots\')){this.form.submit()}" type="button" name="farm_expension" value="Farm Expension" onmouseover="this.className=\'hover\';" onmouseout="this.className=\'\';">Farm Expension</button>';
            echo '</td>';
            echo '</form>';
            echo '</tr></table>';
            echo '<table class="cream" border="0" cellspacing="0" cellpadding="0">';
            echo '<tr bgcolor=white>';
            echo '<th colspan=4>Number</th><th>&nbsp;Active&nbsp;</th><th>&nbsp;Place&nbsp;<br>&nbsp;Plow&nbsp;</th><th colspan=3>Top</th><th>&nbsp;</th><th colspan=3>Bottom</th><th>&nbsp;</th><th colspan=2>Details</th><th colspan=2>Content</th>';
            echo '</tr>';
            foreach ($sections as $num => $section) {
                echo '<tr bgcolor=white valign=top class="sec' . $num . '">';
                echo '<td align=left>' . $num . '</td>';
                echo '<td>';
                echo '<form action="index.php" methd="post">';
                echo '<input type="hidden" name="num" value="' . $num . '">';
                echo '<button type="submit" name="edit_sec_form" value="Edit" title="Edit" onmouseover="this.className=\'hover\';" onmouseout="this.className=\'\';">Edit</button>';
                echo '</td>';
                echo '</form>';
                echo '<form action="index.php" method="post"><td>';
                echo '<input type="hidden" name="num" value="' . $num . '">';
                echo '<button type="submit" name="copy_sec_form" value="Copy" title="Copy" onmouseover="this.className=\'hover\';" onmouseout="this.className=\'\';">Copy</button>';
                echo '</td></form>';
                echo '<form action="index.php" method="post"><td>';
                echo '<input type="hidden" name="num" value="' . $num . '">';
                echo '<button type="submit" name="del_sec" value="Del" title="Delete" onmouseover="this.className=\'hover\';" onmouseout="this.className=\'\';">Delete</button>';
                echo '</td></form>';
                echo '<td>';
                echo '&nbsp;&nbsp;&nbsp;';
                echo '<input onclick="self.location.href=\'index.php?vEditActive=' . $num . '&vActiv=' . ($section['active'] != 0 ? '0' : '1') . '\'" type="checkbox" name="active" value="1" ' . ($section['active'] != 0 ? 'checked ' : '') . '>';
                echo '</td>';
                echo '<td>';
                echo '&nbsp;&nbsp;';
                if ($section['type'] == 'anim' || $section['type'] == 'tree' || $section['type'] == 'deco' || $section['type'] == 'building' || $section['type'] == 'seed') {
                    echo '<input onclick="self.location.href=\'main.php?vEditPlace=' . $num . '&vPlace=' . ($section['place'] != 0 ? '0' : '1') . '\'"  type="checkbox" name="place" value="1" ' . ($section['place'] == 1 ? 'checked ' : '') . '>';
                }
                echo '</td>';
                echo '<td align="right">' . $section['top_x'] . '</td>';
                echo '<td>-</td>';
                echo '<td align="right">' . $section['top_y'] . '</td>';
                echo '<td>&nbsp;&nbsp;</td>';
                echo '<td align="right">' . $section['bot_x'] . '</td>';
                echo '<td>-</td>';
                echo '<td align="right">' . $section['bot_y'] . '</td>';
                echo '<td>&nbsp;&nbsp;</td>';
                echo '<td>' . $section['type'] . '</td>';
                echo '<td>';
                if ($section['type'] == 'seed') {
                    echo ' pattern ' . $section['pat'] . ": ";
                    echo Sections_GetValue($vSeeds, $section['seed']) . ' (' . $section['seed'] . ')';
                    echo $section['pat'] != 'none' ? '/' . Sections_GetValue($vSeeds, $section['seed2']) . ' (' . $section['seed2'] . ')' : '';
                } elseif ($section['type'] == 'anim') {
                    foreach (explode('|', $section['anim']) as $vAnimal) {
                        echo '<nobr>' . $vAnimals[$vAnimal] . ' (' . $vAnimal . ')&nbsp;&nbsp;&nbsp;</nobr> ';
                    }
                    if ($section['walk'] == 'walk') {
                        echo 'walk&nbsp;&nbsp;&nbsp; ';
                    }
                    if ($section['walk'] == 'stay') {
                        echo 'stay&nbsp;&nbsp;&nbsp; ';
                    }
                    if ($section['rotate'] == '0') {
                        echo '<nobr>bottom-left&nbsp;&nbsp;&nbsp;</nobr> ';
                    }
                    if ($section['rotate'] == '1') {
                        echo '<nobr>bottom-right&nbsp;&nbsp;&nbsp;</nobr> ';
                    }
                    if ($section['rotate'] == '2') {
                        echo '<nobr>top-right&nbsp;&nbsp;&nbsp;</nobr> ';
                    }
                    if ($section['rotate'] == '3') {
                        echo '<nobr>top-left&nbsp;&nbsp;&nbsp;</nobr> ';
                    }
                } elseif ($section['type'] == 'tree') {
                    foreach (explode('|', $section['tree']) as $vTree) {
                        echo '<nobr>' . (isset($vTrees[$vTree]) ? $vTrees[$vTree] . ' (' . $vTree . ')' : $vTree) . '&nbsp;&nbsp;&nbsp;</nobr> ';
                    }
                } elseif ($section['type'] == 'deco') {
                    foreach (explode('|', $section['deco']) as $vDeco) {
                        echo '<nobr>' . $vDecorations[$vDeco] . ' (' . $vDeco . ')&nbsp;&nbsp;&nbsp;</nobr> ';
                    }
                } elseif ($section['type'] == 'building') {
                    foreach (explode('|', $section['building']) as $Building) {
                        echo '<nobr>' . $vBuildings[$Building] . ' (' . $Building . ')&nbsp;&nbsp;&nbsp;</nobr> ';
                    }
                } elseif ($section['type'] == 'buyanim') {
                    echo $vAnimals[$section['buyanim']] . ' (' . $section['buyanim'] . ')';
                } elseif ($section['type'] == 'buytree') {
                    echo $vTrees[$section['buytree']] . ' (' . $section['buytree'] . ')';
                } elseif ($section['type'] == 'buydeco') {
                    echo $vDecorations[$section['buydeco']] . ' (' . $section['buydeco'] . ')';
                }
                echo '</td>';
                echo '<td>';
                foreach ($vSecLoc[$num] as $itemName => $count) {
                    echo '<nobr>', $count, 'x ' . $itemName . '</nobr> ';
                }
                echo '</td>';
                echo '</tr>';
            }
            echo '</table><br/>';
        }
        echo "</body></html>";
    }
}
示例#20
0
function Sections_plant_sections()
{
    global $need_reload;
    $enable_seed = true;
    echo "Sections v", sections_Version, " >> plant_sections\r\n";
    $sections = load_array('sections.txt');
    if (!(is_array($sections) && count($sections))) {
        return;
    }
    #return;  // uncomment to disable for debug purposes
    if ($need_reload) {
        $res = DoInit();
        //reload farm
        $need_reload = false;
    }
    #  $units = @unserialize(file_get_contents(F('units.txt')));
    $objects = @unserialize(fBGetDataStore('objects'));
    list($level, $gold, $cash, $sizeX, $sizeY, $firstname, $locale, $tileset, $wither, $xp, $energy, $flashRevision) = explode(';', fBGetDataStore('playerinfo'));
    // Build matrix so we can know which locations are empty
    $location_empty = array();
    for ($x = 0; $x < $sizeX; $x++) {
        for ($y = 0; $y < $sizeY; $y++) {
            $location_empty[$x][$y] = true;
        }
    }
    foreach ($objects as $o) {
        #    $u = $units[$o['itemName']];
        $u = Units_GetUnitByName($o['itemName']);
        if (!isset($u['sizeX'])) {
            $u['sizeX'] = 1;
            $u['sizeY'] = 1;
        }
        if ($o['state'] == 'vertical') {
            $t = $u['sizeX'];
            $u['sizeX'] = $u['sizeY'];
            $u['sizeY'] = $t;
        }
        for ($x = 0; $x < $u['sizeX']; $x++) {
            for ($y = 0; $y < $u['sizeY']; $y++) {
                $location_empty[$o['position']['x'] + $x][$o['position']['y'] + $y] = false;
            }
        }
    }
    foreach ($sections as $section) {
        if ($section['active'] == '1' && $section['place'] == '1' && $section['type'] == 'seed') {
            $u['sizeX'] = 4;
            $u['sizeY'] = 4;
            while ($newpos = Sections_Find_Free_Location_Buy($section, $u, $location_empty)) {
                unset($vPlot);
                $vPlot['itemName'] = null;
                $vPlot['isProduceItem'] = false;
                $vPlot['isBigPlot'] = false;
                $vPlot['direction'] = 0;
                $vPlot['plantTime'] = 'NaN';
                $vPlot['deleted'] = false;
                $vPlot['isJumbo'] = false;
                $vPlot['state'] = 'plowed';
                $vPlot['tempId'] = -1;
                $vPlot['id'] = 0;
                $vPlot['className'] = 'Plot';
                $vPlot['position']['z'] = 0;
                $vPlot['position']['x'] = (int) $newpos['x'];
                $vPlot['position']['y'] = (int) $newpos['y'];
                $tractor_plots[] = $vPlot;
                for ($x = 0; $x < $u['sizeX']; $x++) {
                    for ($y = 0; $y < $u['sizeY']; $y++) {
                        $location_empty[$newpos['x'] + $x][$newpos['y'] + $y] = false;
                    }
                }
            }
        }
    }
    if (isset($tractor_plots) && count($tractor_plots) > 0) {
        $result = Do_Farm_Work_Plots($tractor_plots, 'tractor');
        $need_reload = $need_reload || $result;
    }
    // Below mostly copied from parser.php with adaptions
    if ($need_reload) {
        $res = DoInit();
        //reload farm
        $need_reload = false;
    }
    if ($enable_seed) {
        $plots = GetObjects('Plot');
        //Find empty plots
        $plowed_plots = array();
        foreach ($plots as $plowed_key => $plot) {
            if ($plot['state'] == 'plowed') {
                $plowed_plots[] = $plot;
            }
        }
        $seed_plots = array();
        foreach ($plowed_plots as $plot) {
            $itemName = "";
            $px = floor($plot['position']['x'] / 4);
            $py = floor($plot['position']['y'] / 4);
            $npx = $plot['position']['x'];
            $npy = $plot['position']['y'];
            foreach ($sections as $section) {
                if ($section['active'] == '1' && $section['type'] == 'seed' && $section['seed'] != 'just_plow' && $section['seed'] != '---' && $npx >= $section['bot_x'] && $npx <= $section['top_x'] && $npy >= $section['bot_y'] && $npy <= $section['top_y']) {
                    // found the section
                    switch ($section['pat']) {
                        case 'checkerboard':
                            $itemName = ($px + $py) % 2 == 1 ? $section['seed'] : $section['seed2'];
                            break;
                        case 'striped-row':
                            $itemName = $py % 2 == 1 ? $section['seed'] : $section['seed2'];
                            break;
                        case 'striped-col':
                            $itemName = $px % 2 == 1 ? $section['seed'] : $section['seed2'];
                            break;
                        case 'squared1':
                            $itemName = $px % 2 == 1 || $py % 2 == 1 ? $section['seed'] : $section['seed2'];
                            break;
                        case 'squared2':
                            $itemName = $px % 2 == 1 || $py % 2 == 1 ? $section['seed'] : $section['seed2'];
                            break;
                        case 'corner-w':
                            $itemName = $px % 2 == 1 && $px >= $py || $py % 2 == 1 && $py >= $px ? $section['seed'] : $section['seed2'];
                            break;
                        case 'corner-e':
                            $itemName = $px % 2 == 1 && $px <= $py || $py % 2 == 1 && $py <= $px ? $section['seed'] : $section['seed2'];
                            break;
                        case 'corner-n':
                            $sz_x = floor(($section['top_x'] - $section['bot_x']) / 4);
                            $itemName = $px % 2 == 1 && $sz_x - $px <= $py || $py % 2 == 1 && $py <= $sz_x - $px ? $section['seed'] : $section['seed2'];
                            break;
                        case 'corner-s':
                            $sz_x = floor(($section['top_x'] - $section['bot_x']) / 4);
                            $itemName = $px % 2 == 1 && $sz_x - $px >= $py || $py % 2 == 1 && $py <= $sz_x - $px ? $section['seed'] : $section['seed2'];
                            break;
                        default:
                            $itemName = $section['seed'];
                    }
                }
            }
            if (strlen($itemName) > 0) {
                $plot['itemName'] = $itemName;
                $seed_plots[] = $plot;
                #      } else {
                #        echo GetPlotName($plot) . " not in a section.";
            }
        }
        if (count($seed_plots) > 0) {
            Do_Farm_Work_Plots($seed_plots, 'place');
            //plant crops
        }
        unset($seed_plots, $plowed_plots);
    }
}
示例#21
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);
}
示例#22
0
function SM_showFarmStats()
{
    list($level, $gold, $cash, $sizeX, $sizeY, $firstname) = explode(';', fBGetDataStore('playerinfo'));
    $xm = $sizeX - 1;
    $ym = $sizeY - 1;
    $farm = array();
    $farm = TB_buildFarmArray();
    $cPlots = 0;
    $cFree = 0;
    for ($x = 0; $x <= $xm; $x++) {
        for ($y = 0; $y <= $ym; $y++) {
            if ($farm[$x][$y]) {
                $cFree++;
            }
            $cPlots++;
        }
    }
    echo '<table style="border:none" width="100%">';
    echo '<tr>';
    echo '<td colspan="4">';
    echo 'Your farm: ' . $sizeX . ' x ' . $sizeY . '  -  ' . round($cFree / $cPlots * 100) . '% is free';
    echo '</td>';
    echo '</tr>';
    echo '</table>';
}