Ejemplo n.º 1
0
 /**
  * 创建应用
  * @access      public
  * @param       array $config
  */
 public static function run()
 {
     self::$appConfig = (require_once 'config.php');
     //初始化
     self::init();
     // 项目开始拓展
     Hook('appBegin');
     $route = self::$appLib['route'];
     //call_user_func_array(array($route, "init"), array(self::$appConfig['route']));
     $route::init(self::$appConfig['route']);
     //设置url的类型
     Hook('appEnd');
 }
Ejemplo n.º 2
0
function Do_Work()
{
    global $settings;
    global $need_reload;
    global $px_Setops;
    global $res_str;
    pluginload();
    $vDir = './farmville-logs';
    if (!file_exists($vDir)) {
        mkdir($vDir);
    }
    $time_limit = 7 * 24 * 60 * 60;
    // number of seconds to 'keep' the log DAYSxHOURSxMINSxSECS
    if ($df = opendir($vDir)) {
        while (false !== ($file = readdir($df))) {
            if ($file != "." && $file != "..") {
                $file1 = $vDir . '/' . $file;
                $last_modified = filemtime($file1);
                if (time() - $last_modified > $time_limit) {
                    unlink($file1);
                }
            }
        }
        closedir($df);
    }
    while (file_exists('notrun_parser.txt') || file_exists('notrun_parser_' . $_SESSION['userId'] . '.txt')) {
        AddLog2("Bot Paused. Next check in 30 seconds.");
        sleep(30);
    }
    parse_neighbors();
    parse_user();
    AddLog2("Beginning Bot Cycle");
    Hook('before_work');
    // Init
    $res = DoInit('full');
    if ($res != 'OK') {
        RaiseError(2);
    } else {
        $res_str = '';
        //for main logs
    }
    Hook('before_load_settings');
    // load settings
    if (!function_exists('LoadSavedSettings')) {
        die("\n\nSettings plugin installed incorrectly no LoadSavedSettings found!\n\n");
    }
    $px_Setopts = LoadSavedSettings();
    $enable_lonlyanimals = $px_Setopts['lonlyanimals'];
    Hook('after_load_settings');
    if ($enable_lonlyanimals) {
        AddLog2("check lonlyanimal");
        Do_Check_Lonlyanimals();
    }
    Hook('flybiplane');
    Hook('before_harvest');
    Hook('harvest');
    Hook('after_harvest');
    Hook('before_harvest_buildings');
    Hook('harvest_buildings');
    Hook('after_harvest_buildings');
    //after building harvest
    Hook('before_harvest_animals');
    //get product from livestock
    Hook('harvest_animals');
    Hook('after_harvest_animals');
    Hook('before_transform_animals');
    Hook('transform_animals');
    Hook('after_transform_animals');
    Hook('before_harvest_trees');
    Hook('harvest_trees');
    Hook('after_harvest_trees');
    Hook('before_hoe');
    Hook('hoe');
    Hook('after_hoe');
    Hook('before_before_planting');
    Hook('before_planting');
    Hook('planting');
    Hook('after_planting');
    Hook('after_work');
    Parser_Check_Images();
    AddLog2("Peak Memory Usaged: " . round(memory_get_peak_usage(true) / 1024 / 1024, 2) . "MB");
    AddLog2("Finished Bot Cycle");
}
            echo friendlydate($weibo["create_time"]);
            ?>
</a> </span>

                                </div>
                                <div class="col-md-8">
                                  <span class="pull-right text-primary" data-weibo-id="<?php 
            echo $weibo["id"];
            ?>
">
                        <?php 
            $weiboCommentTotalCount = $weibo['comment_count'];
            ?>
                        <?php 
            echo Hook('support', array('table' => 'weibo', 'row' => $weibo['id'], 'app' => 'Usercenter', 'uid' => $weibo['uid']));
            echo Hook('repost', array('weiboId' => $weibo['id']));
            ?>
&nbsp;&nbsp;&nbsp;

<span class="text-primary weibo-comment-link cpointer" data-weibo-id="<?php 
            echo $weibo["id"];
            ?>
">
    评论<?php 
            if ($weiboCommentTotalCount) {
                ?>
(<?php 
                echo $weiboCommentTotalCount;
                ?>
)<?php 
            }
                <p>
                    <?php 
echo modC('SUBSCRIB_US', L('_NOT_SET_NOW_'), 'Config');
?>
                </p>
            </div>
            <div class="col-xs-4">
                <h2>
                    <i class="icon-link"></i> <?php 
echo L('_FRIENDLY_LINK_');
?>
                </h2>

                <ul class="friend-link">
                    <?php 
echo Hook('friendLink');
?>
                </ul>

            </div>
        </div>

        <div class="row text-center">
            <hr>

                <h4> <?php 
echo modC('COPY_RIGHT', L('_NOT_SET_NOW_'), 'Config');
?>
</h4>
                <div class="col-xs-12"><?php 
echo L('_RECORD_N_');
Ejemplo n.º 5
0
function DoInit($inittype = '')
{
    $T = time(true);
    $res = 0;
    Hook('before_load_farm');
    $_SESSION['sequence'] = 0;
    // Create Init request
    $amf = CreateRequestAMF('', 'UserService.initUser');
    $amf->_bodys[0]->_value[1][0]['params'][0] = "";
    $amf->_bodys[0]->_value[1][0]['params'][1] = -1;
    $amf->_bodys[0]->_value[1][0]['params'][2] = true;
    $serializer = new AMFSerializer();
    $result = $serializer->serialize($amf);
    // serialize the data
    $answer = Request('', $result);
    $amf2 = new AMFObject($answer);
    $deserializer2 = new AMFDeserializer($amf2->rawData);
    // deserialize the data
    $deserializer2->deserialize($amf2);
    // run the deserializer
    $res = CheckAMF2Response($amf2);
    if ($res == 'OK') {
        // get flashSessionKey
        //$_SESSION['sequence'] = 1;
        //file_put_contents('all.txt', print_r($amf2,true));
        if (isset($amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['session_key'])) {
            $_SESSION['flashSessionKey'] = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['session_key'];
        }
        $_SESSION['servertime'] = $amf2->_bodys[0]->_value['data'][0]['serverTime'];
        // save to file $flashSessionKey, $xp, $energy
        $xp = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['xp'];
        $energy = $amf2->_bodys[0]->_value['data'][0]['data']['energy'];
        $hlXP = Units_GetFarming('higherLevelXp');
        $hlBegin = Units_GetFarming('higherLevelBegin');
        $hlStep = Units_GetFarming('higherLevelStep');
        // get extra info
        $level = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['level'];
        if (isset($hlXP) && $xp >= $hlXP) {
            $level = @$hlBegin + floor(($xp - @$hlXP) / @$hlStep);
        }
        $gold = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['gold'];
        $cash = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['cash'];
        $sizeX = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['world']['sizeX'];
        $sizeY = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['world']['sizeY'];
        $firstname = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['attr']['name'];
        $locale = $amf2->_bodys[0]->_value['data'][0]['data']['locale'];
        $tileset = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['world']['tileSet'];
        $wither = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['witherOn'];
        // save to file $level, $coins, $cash, $sizex, $sizey
        $uSQL = 'INSERT OR REPLACE INTO datastore(userid, storetype, content) values("' . $_SESSION['userId'] . '",
									"playerinfo", "' . implode(';', array($level, $gold, $cash, $sizeX, $sizeY, $firstname, $locale, $tileset, $wither, $xp, $energy, $_SESSION['flashRevision'])) . '");';
        // save world to file
        save_botarray($amf2->_bodys[0]->_value, F('world.txt'));
        //file_put_contents('world.txt', print_r($amf2->_bodys[0]->_value,true));
        // get objects on farm
        $objects = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['world']['objectsArray'];
        //file_put_contents('world.txt', print_r($objects, true));
        // FarmFIX/object split
        $newobjects = serialize($objects);
        $cleanedobjects = str_replace("'", "''", $newobjects);
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t\t'objects', '" . $cleanedobjects . "');";
        // save collection counters to a file
        $nAQ = @$amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['neighborActionQueue']['m_actionQueue'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'nactionqueue', '" . serialize($nAQ) . "');";
        $nAL = @$amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['neighborActionLimits']['m_neighborActionLimits'][date('ymd', $_SESSION['servertime'])];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'nactionlimit', '" . serialize($nAL) . "');";
        $c_count = @$amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['collectionCounters'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'ccount', '" . serialize($c_count) . "');";
        $c_bushel = @$amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['buffs']['BBushel']['crop'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'cbushel', '" . serialize($c_bushel) . "');";
        $c_busheltime = @$amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['buffs']['BBushel']['time'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'cbusheltime', '" . serialize($c_busheltime) . "');";
        $craftstate = @$amf2->_bodys[0]->_value['data'][0]['data']['craftingState'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'craftstate', '" . serialize($craftstate) . "');";
        // save lonelyanimals to a file
        $animallinks = @$amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['lonelyAnimals'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'ralinks', '" . serialize($animallinks) . "');";
        // save license information
        $licenses = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['licenseManager']['licenses'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'licenses', '" . serialize($licenses) . "');";
        $storagedata = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['storageData'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'storagedata', '" . serialize($storagedata) . "');";
        $incraftbox = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['storageData']['-7'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'craftbox', '" . serialize($incraftbox) . "');";
        // save giftbox info for plugins
        $ingiftbox = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['storageData']['-1'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'giftbox', '" . serialize($ingiftbox) . "');";
        foreach ($ingiftbox as $key => $item) {
            $ingiftbox[$key] = isset($item[0]) ? $item[0] : 0;
        }
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'ingiftbox', '" . serialize($ingiftbox) . "');";
        // save consumable info for plugins
        $inconbox = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['storageData']['-6'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'consumebox', '" . serialize($inconbox) . "');";
        foreach ($inconbox as $key => $item) {
            $uInfo = Units_GetUnitByCode($key);
            if (@$uInfo['className'] == 'CSeedPackage') {
                $inseedbox[$key] = isset($item[0]) ? $item[0] : 0;
                unset($inconbox[$key]);
                continue;
            }
            $inconbox[$key] = isset($item[0]) ? $item[0] : 0;
        }
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'inconbox', '" . serialize($inconbox) . "');";
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'inseedbox', '" . serialize($inseedbox) . "');";
        // save storage info for plugins
        $instorage = @$amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['storageData']['-2'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'storagebox', '" . serialize($instorage) . "');";
        foreach ($instorage as $key => $item) {
            $instorage[$key] = $item[0];
        }
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'instorage', '" . serialize($instorage) . "');";
        // save neighbors list
        $neighbors = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['neighbors'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'neighbors', '" . serialize($neighbors) . "');";
        $bsStats = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['breedingState'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'bsstats', '" . serialize($bsStats) . "');";
        $pneighbors = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['pendingNeighbors'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'pneighbors', '" . serialize($pneighbors) . "');";
        // save crop mastery list
        $cropmastery = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['masteryCounters'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'cropmastery', '" . serialize($cropmastery) . "');";
        $cropmasterycnt = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['mastery'];
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'cropmasterycnt', '" . serialize($cropmasterycnt) . "');";
        if (isset($amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['featureCredits']['farm'])) {
            $featurecred = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['featureCredits']['farm'];
        } else {
            $featurecred = $amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['featureCredits'];
        }
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'featurecred', '" . serialize($featurecred) . "');";
        // save ribbon data
        $achievements = @$amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['achCounters'];
        $earned_ribbons = @$amf2->_bodys[0]->_value['data'][0]['data']['userInfo']['player']['achievements'];
        $ribbon_merge = array();
        foreach ($achievements as $name => $data) {
            $ribbon_merge[$name]['count'] = $data;
        }
        if (@count($earned_ribbons) > 0) {
            foreach ($earned_ribbons as $name => $data) {
                $ribbon_merge[$name]['earned'] = $data;
            }
        }
        $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'ach_count', '" . serialize($ribbon_merge) . "');";
        $_SESSION['vDataStoreDB']->exec($uSQL);
        unset($uSQL, $amf2);
        // save_botarray ($array, $filename);
    }
    if ($inittype == 'full') {
        $amf = CreateRequestAMF('', 'UserService.postInit');
        $serializer = new AMFSerializer();
        $result = $serializer->serialize($amf);
        // serialize the data
        $answer = Request('', $result);
        $amf2 = new AMFObject($answer);
        $deserializer2 = new AMFDeserializer($amf2->rawData);
        // deserialize the data
        $deserializer2->deserialize($amf2);
        // run the deserializer
        $res2 = CheckAMF2Response($amf2);
        if ($res2 == 'OK') {
            file_put_contents('world2.txt', print_r($amf2->_bodys[0]->_value, true));
            $availBushels = @$amf2->_bodys[0]->_value['data'][0]['data']['marketView']['marketStalls'];
            $availGoods = @$amf2->_bodys[0]->_value['data'][0]['data']['marketView']['craftedGoods'];
            $bsInfo = @$amf2->_bodys[0]->_value['data'][0]['data']['breedingState'];
            $uSQL = "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'availbushels', '" . serialize($availBushels) . "');";
            $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'availgoods', '" . serialize($availGoods) . "');";
            $uSQL .= "INSERT OR REPLACE INTO datastore(userid, storetype, content) values('" . $_SESSION['userId'] . "',\n\t\t\t\t'bsinfo', '" . serialize($bsInfo) . "');";
            $_SESSION['vDataStoreDB']->exec($uSQL);
            unset($uSQL, $amf2);
        }
        Hook('after_load_farm');
        $res = $res == 'OK' && $res2 == 'OK' ? 'OK' : 'Init: ' . $res . ' - PostInit: ' . $res2;
    }
    $T2 = time();
    $T2 -= $T;
    if ($res == 'OK') {
        AddLog2("Initialization Took: " . $T2 . " Seconds");
    } else {
        AddLog2("Initialization Failed: " . $res);
    }
    return $res;
}