当前位置: 首页>>代码示例>>PHP>>正文


PHP getRandomString函数代码示例

本文整理汇总了PHP中getRandomString函数的典型用法代码示例。如果您正苦于以下问题:PHP getRandomString函数的具体用法?PHP getRandomString怎么用?PHP getRandomString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getRandomString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getHash

function getHash($password, $salt = false)
{
    if (is_integer($salt)) {
        $salt = getRandomString($salt);
    }
    return $salt === false ? md5($password) : md5($salt . $password) . ':' . $salt;
}
开发者ID:HB4daemmon,项目名称:custom,代码行数:7,代码来源:hash.php

示例2: newUserId

 function newUserId()
 {
     $name = getRandomString();
     $sql = sprintf('INSERT INTO users SET name="%s", created=NOW(), modified=NOW()', r($name));
     mysql_query($sql) or die(mysql_error());
     $user_id = mysql_insert_id();
     return $user_id;
 }
开发者ID:nigohiroki,项目名称:webichi,代码行数:8,代码来源:item_model.php

示例3: createTestUser

    public function createTestUser()
    {
        $id = $this->insert('
insert into users
  (user_name, b_sex, email, passwd, dt_reg, msg)
values
  (?, ?, ?, ?, UNIX_TIMESTAMP(), ?)', array('', rand(SEX_BOY, SEX_GIRL), '@mail.ru', md5('1'), getRandomString(100, true, 10)));
        $this->update('update users set user_name=?, email=? where id_user=?', array("user{$id}", "{$id}@mail.ru", $id));
        return $id;
    }
开发者ID:ilivanoff,项目名称:www,代码行数:10,代码来源:TESTBean.php

示例4: getRandomImageForPos

function getRandomImageForPos($panelsDir, $pos)
{
    $fullPosName = posAbbrToFull($pos);
    $filename = "";
    $fileListDir = "filelists/";
    if ($fullPosName != "") {
        $serializedPaths = file_get_contents($fileListDir . $fullPosName . "Paths.txt");
        $allFiles = unserialize($serializedPaths);
        $filename = getRandomString($allFiles);
    }
    return $filename;
}
开发者ID:aag,项目名称:dinoremix,代码行数:12,代码来源:utils.php

示例5: user_login

 static function user_login($IN, $db)
 {
     $db->query("SELECT password_hash, id FROM user WHERE BINARY name = ? AND deleted_at IS NULL", $IN['username']);
     if ($row = $db->fetch()) {
         if (password_verify($IN['password'], $row['password_hash'])) {
             $_SESSION['authorized'] = $row['id'];
             $session_token = getRandomString(16);
             $db->query("UPDATE user\n                            SET session_token=?\n                            WHERE id=?;", $session_token, $row['id']);
             $return = array("token" => $session_token, "id" => $row['id']);
             API::respond(true, $return);
         }
     }
     API::respond(false, "Username or password was incorrect");
 }
开发者ID:anton-christensen,项目名称:p2_software,代码行数:14,代码来源:index.php

示例6: show

 public function show()
 {
     global $USER, $PLANET, $resource, $pricelist, $reslist, $LNG;
     $targetGalaxy = HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
     $targetSystem = HTTP::_GP('system', (int) $PLANET['system']);
     $targetPlanet = HTTP::_GP('planet', (int) $PLANET['planet']);
     $targetType = HTTP::_GP('type', (int) $PLANET['planet_type']);
     $mission = HTTP::_GP('target_mission', 0);
     $Fleet = array();
     $FleetRoom = 0;
     $allyInfo = $GLOBALS['DATABASE']->query("SELECT FleetCapa FROM `uni1_alliance` WHERE id = " . $USER['ally_id'] . ";");
     $allyInfo = $GLOBALS['DATABASE']->fetch_array($allyInfo);
     $listorder = array(210, 212, 202, 203, 204, 205, 229, 209, 206, 207, 208, 217, 215, 213, 211, 220, 224, 219, 223, 225, 226, 214, 216, 230, 227, 228, 222, 218, 221);
     foreach ($listorder as $id => $ShipID) {
         $amount = max(0, round(HTTP::_GP('ship' . $ShipID, 0.0, 0.0)));
         if ($amount < 1 || $ShipID == 212) {
             continue;
         }
         $Fleet[$ShipID] = $amount;
         $FleetRoom += $pricelist[$ShipID]['capacity'] * $amount;
         $FleetRoom += $FleetRoom / 100 * getbonusOneBis(1207, $USER['academy_1207']) + $FleetRoom / 100 * $allyInfo['FleetCapa'];
     }
     foreach ($Fleet as $Ship => $Count) {
         if ($Count > $PLANET[$resource[$Ship]]) {
             $this->printMessage($LNG['fl_not_all_ship_avalible']);
         }
     }
     $FleetRoom *= 1 + $USER['factor']['ShipStorage'];
     if (empty($Fleet)) {
         FleetFunctions::GotoFleetPage();
     }
     $FleetData = array('fleetroom' => floattostring($FleetRoom), 'gamespeed' => FleetFunctions::GetGameSpeedFactor(), 'fleetspeedfactor' => max(0, 1 + $USER['factor']['FlyTime']), 'planet' => array('galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type']), 'maxspeed' => FleetFunctions::GetFleetMaxSpeed($Fleet, $USER), 'ships' => FleetFunctions::GetFleetShipInfo($Fleet, $USER), 'fleetMinDuration' => MIN_FLEET_TIME);
     $token = getRandomString();
     $_SESSION['fleet'][$token] = array('time' => TIMESTAMP, 'fleet' => $Fleet, 'fleetRoom' => $FleetRoom);
     $shortcutList = $this->GetUserShotcut();
     $colonyList = $this->GetColonyList();
     $ACSList = $this->GetAvalibleACS();
     if (!empty($shortcutList)) {
         $shortcutAmount = max(array_keys($shortcutList));
     } else {
         $shortcutAmount = 0;
     }
     $this->tplObj->loadscript('flotten.js');
     $this->tplObj->execscript('updateVars();FleetTime();window.setInterval("FleetTime()", 1000);');
     $this->tplObj->assign_vars(array('token' => $token, 'mission' => $mission, 'shortcutList' => $shortcutList, 'shortcutMax' => $shortcutAmount, 'colonyList' => $colonyList, 'ACSList' => $ACSList, 'galaxy' => $targetGalaxy, 'system' => $targetSystem, 'planet' => $targetPlanet, 'type' => $targetType, 'speedSelect' => FleetFunctions::$allowedSpeed, 'typeSelect' => array(1 => $LNG['type_planet'][1], 2 => $LNG['type_planet'][2], 3 => $LNG['type_planet'][3], 4 => $LNG['type_planet'][4]), 'fleetdata' => $FleetData));
     $this->display('page.fleetStep1.default.tpl');
 }
开发者ID:Decoder1978,项目名称:Xterium,代码行数:47,代码来源:class.ShowFleetStep1Page.php

示例7: generateRandomString

function generateRandomString($length = 32)
{
    try {
        $string = random_bytes($length);
        $randomString = bin2hex($string);
    } catch (TypeError $e) {
        // Well, it's an integer, so this IS unexpected.    //die("An unexpected error has occurred");
        $randomString = getRandomString($length);
    } catch (Error $e) {
        // This is also unexpected because 32 is a reasonable integer.    //die("An unexpected error has occurred");
        $randomString = getRandomString($length);
    } catch (Exception $e) {
        // If you get this message, the CSPRNG failed hard.     //die("Could not generate a random string. Is our OS secure?");
        $randomString = getRandomString($length);
    }
    return substr($randomString, 0, $length);
}
开发者ID:amin-alizadeh,项目名称:WordVive,代码行数:17,代码来源:login.php

示例8: verifyImage

function verifyImage($type = 1, $length = 4, $pixel = 30, $line = 0, $sess_name = "verify")
{
    session_start();
    Header("Content-type: image/PNG");
    //Header("Content-type: image/GIF");
    //创建画布
    $width = 80;
    $height = 30;
    $image = imagecreatetruecolor($width, $height);
    $white = imagecolorallocate($image, 255, 255, 255);
    $black = imagecolorallocate($image, 0, 0, 0);
    imagefilledrectangle($image, 1, 1, $width - 2, $height - 2, $white);
    $chars = getRandomString($type, $length);
    $_SESSION[$sess_name] = $chars;
    $fontfiles = array("msyh.ttc", "msyhl.ttc", "msyhbd.ttc");
    for ($i = 0; $i < $length; $i++) {
        $size = mt_rand(14, 18);
        $angle = mt_rand(-15, 15);
        $x = 5 + $i * $size;
        //echo $x;
        $y = mt_rand(20, 26);
        $fontfile = "../fonts/" . $fontfiles[mt_rand(0, count($fontfiles) - 1)];
        $color = imagecolorallocate($image, mt_rand(50, 90), mt_rand(80, 200), mt_rand(90, 180));
        $text = substr($chars, $i, 1);
        imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $text);
    }
    if ($pixel) {
        for ($i = 0; $i < 50; $i++) {
            imagesetpixel($image, mt_rand(0, $width - 1), mt_rand(0, $height - 1), $black);
        }
    }
    if ($line) {
        for ($i = 1; $i < $line; $i++) {
            $color = imagecolorallocate($image, mt_rand(50, 90), mt_rand(80, 200), mt_rand(90, 180));
            imageline($image, mt_rand(0, $width - 1), mt_rand(0, $height - 1), mt_rand(0, $width - 1), mt_rand(0, $height - 1), $color);
        }
    }
    //echo $chars;
    ImagePNG($image);
    //ImageGIF($image);
    ImageDestroy($image);
}
开发者ID:lucas1111,项目名称:shop,代码行数:42,代码来源:image.func.php

示例9: SetTrackingCookie

function SetTrackingCookie($len = 32)
{
    $MAX_ITER = 5;
    $iter = 0;
    $conn = mysqlConnectDB("webtracking");
    //connect to database webtracking
    while ($iter < $MAX_ITER) {
        $token = getRandomString($len);
        if (saveTokenInDB($conn, $token)) {
            //expires in 30 minutes. The length of random string is 32.
            // Need to set domain = NULL as chrome prevents creration of cookie for localhost.
            setcookie("token", $token, time() + 30 * 60, "/webtracking", NULL, false, true);
            break;
        }
        $iter++;
    }
    if ($iter == $MAX_ITER) {
        die("Some Error occured try again!");
    }
}
开发者ID:tapananand,项目名称:trackingDemo,代码行数:20,代码来源:utility.php

示例10: show

 public function show()
 {
     global $USER, $PLANET, $pricelist, $reslist, $LNG;
     $targetGalaxy = HTTP::_GP('galaxy', (int) $PLANET['galaxy']);
     $targetSystem = HTTP::_GP('system', (int) $PLANET['system']);
     $targetPlanet = HTTP::_GP('planet', (int) $PLANET['planet']);
     $targetType = HTTP::_GP('type', (int) $PLANET['planet_type']);
     $mission = HTTP::_GP('target_mission', 0);
     $Fleet = array();
     $FleetRoom = 0;
     foreach ($reslist['fleet'] as $id => $ShipID) {
         $amount = max(0, round(HTTP::_GP('ship' . $ShipID, 0.0, 0.0)));
         if ($amount < 1 || $ShipID == 212) {
             continue;
         }
         $Fleet[$ShipID] = $amount;
         $FleetRoom += $pricelist[$ShipID]['capacity'] * $amount;
     }
     $FleetRoom *= 1 + $USER['factor']['ShipStorage'];
     if (empty($Fleet)) {
         FleetFunctions::GotoFleetPage();
     }
     $FleetData = array('fleetroom' => floatToString($FleetRoom), 'gamespeed' => FleetFunctions::GetGameSpeedFactor(), 'fleetspeedfactor' => max(0, 1 + $USER['factor']['FlyTime']), 'planet' => array('galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type']), 'maxspeed' => FleetFunctions::GetFleetMaxSpeed($Fleet, $USER), 'ships' => FleetFunctions::GetFleetShipInfo($Fleet, $USER), 'fleetMinDuration' => MIN_FLEET_TIME);
     $token = getRandomString();
     $_SESSION['fleet'][$token] = array('time' => TIMESTAMP, 'fleet' => $Fleet, 'fleetRoom' => $FleetRoom);
     $shortcutList = $this->GetUserShotcut();
     $colonyList = $this->GetColonyList();
     $ACSList = $this->GetAvalibleACS();
     if (!empty($shortcutList)) {
         $shortcutAmount = max(array_keys($shortcutList));
     } else {
         $shortcutAmount = 0;
     }
     $this->tplObj->loadscript('flotten.js');
     $this->tplObj->execscript('updateVars();FleetTime();window.setInterval("FleetTime()", 1000);');
     $this->assign(array('token' => $token, 'mission' => $mission, 'shortcutList' => $shortcutList, 'shortcutMax' => $shortcutAmount, 'colonyList' => $colonyList, 'ACSList' => $ACSList, 'galaxy' => $targetGalaxy, 'system' => $targetSystem, 'planet' => $targetPlanet, 'type' => $targetType, 'speedSelect' => FleetFunctions::$allowedSpeed, 'typeSelect' => array(1 => $LNG['type_planet'][1], 2 => $LNG['type_planet'][2], 3 => $LNG['type_planet'][3]), 'fleetdata' => $FleetData));
     $this->display('page.fleetStep1.default.tpl');
 }
开发者ID:tatarysh,项目名称:2Moons,代码行数:38,代码来源:ShowFleetStep1Page.class.php

示例11: getRandomString

<?php

/**
 *  2Moons
 *  Copyright (C) 2012 Jan Kröpke
 *
 * For the full copyright and license information, please view the LICENSE
 *
 * @package 2Moons
 * @author Jan Kröpke <info@2moons.cc>
 * @copyright 2012 Jan Kröpke <info@2moons.cc>
 * @licence MIT
 * @version 1.7.2 (2013-03-18)
 * @info $Id$
 * @link http://2moons.cc/
 */
$token = getRandomString();
$db = Database::get();
$fleetResult = $db->update("UPDATE %%FLEETS_EVENT%% SET `lock` = :token WHERE `lock` IS NULL AND `time` <= :time;", array(':time' => TIMESTAMP, ':token' => $token));
if ($db->rowCount() !== 0) {
    require 'includes/classes/class.FlyingFleetHandler.php';
    $fleetObj = new FlyingFleetHandler();
    $fleetObj->setToken($token);
    $fleetObj->run();
    $db->update("UPDATE %%FLEETS_EVENT%% SET `lock` = NULL WHERE `lock` = :token;", array(':token' => $token));
}
开发者ID:tatarysh,项目名称:2Moons,代码行数:26,代码来源:FleetHandler.php

示例12: mysql_real_escape_string

    $seprator = "|";
    $message = "User Added";
    $uname = mysql_real_escape_string($_POST['uname']);
    $password = mysql_real_escape_string($_POST['upassword']);
    $mdpass = md5($password);
    $fname = mysql_real_escape_string($_POST['fname']);
    $lname = mysql_real_escape_string($_POST['lname']);
    $designation = mysql_real_escape_string($_POST['designation']);
    $organisation = mysql_real_escape_string($_POST['organisation']);
    $uemail = mysql_real_escape_string($_POST['uemail']);
    $user_ip = $_SERVER['REMOTE_ADDR'];
    function getRandomString($length)
    {
        $validCharacters = "1080nordiff00123456vikas09084abcdefghijklmnopqrstuvwxyz";
        $validCharNumber = strlen($validCharacters);
        $result = "";
        for ($i = 0; $i < $length; $i++) {
            $index = mt_rand(0, $validCharNumber - 1);
            $result .= $validCharacters[$index];
        }
        return $result;
    }
    $activation_code = getRandomString(50);
    $finalreg = $registration->UserRegister($uname, $mdpass, $fname, $lname, $designation, $organisation, $uemail, $user_ip, $activation_code);
}
?>
</div>
	</div>
</section>
<?php 
require $get_footer;
开发者ID:jobayerccj,项目名称:hamad-mayo,代码行数:31,代码来源:index+not+used.php

示例13: insertDeclaration

 public function insertDeclaration()
 {
     $curDate = getCurDateStamp();
     $d_code = getRandomString(10);
     $data = array('d_code' => $d_code, 'd_msg' => stripslashes($this->input->post('declaration_msg')), 'd_status' => $this->input->post('declaration_status'), 'created_at' => $curDate);
     $data['d_status'] = is_null($data['d_status']) ? 0 : 1;
     if (!is_null($data['d_msg']) && $data['d_msg'] !== "") {
         //Transfering data to Model
         $this->declaration_model->insert_declaration($data);
         $data['d_successful'] = 'Data Inserted Successfully';
     }
     //Loading View
     $this->dailyDeclarations();
 }
开发者ID:rccghmp,项目名称:efollowup,代码行数:14,代码来源:controlcentre.php

示例14: install

function install($adminPassword, $email, $timezoneOffset)
{
    global $Language;
    $stdOut = array();
    $timezone = timezone_name_from_abbr("", $timezoneOffset, 0);
    date_default_timezone_set($timezone);
    $currentDate = Date::current(DB_DATE_FORMAT);
    // ============================================================================
    // Create directories
    // ============================================================================
    // 7=read,write,execute | 5=read,execute
    $dirpermissions = 0755;
    $firstPostSlug = 'first-post';
    if (!mkdir(PATH_POSTS . $firstPostSlug, $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_POSTS . $firstPostSlug;
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PAGES . 'error', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PAGES . 'error';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'pages', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'pages';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'simplemde', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'simplemde';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_PLUGINS_DATABASES . 'tags', $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . 'tags';
        error_log($errorText, 0);
    }
    if (!mkdir(PATH_UPLOADS, $dirpermissions, true)) {
        $errorText = 'Error when trying to created the directory=>' . PATH_UPLOADS;
        error_log($errorText, 0);
    }
    // ============================================================================
    // Create files
    // ============================================================================
    $dataHead = "<?php defined('BLUDIT') or die('Bludit CMS.'); ?>" . PHP_EOL;
    // File pages.php
    $data = array('error' => array('description' => 'Error page', 'username' => 'admin', 'tags' => array(), 'status' => 'published', 'date' => $currentDate, 'position' => 0));
    file_put_contents(PATH_DATABASES . 'pages.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File posts.php
    $data = array($firstPostSlug => array('description' => 'Welcome to Bludit', 'username' => 'admin', 'status' => 'published', 'tags' => array('bludit' => 'Bludit', 'cms' => 'CMS', 'flat-files' => 'Flat files'), 'allowComments' => 'false', 'date' => $currentDate));
    file_put_contents(PATH_DATABASES . 'posts.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File site.php
    $data = array('title' => 'Bludit', 'slogan' => 'cms', 'description' => '', 'footer' => Date::current('Y'), 'language' => $Language->getCurrentLocale(), 'locale' => $Language->getCurrentLocale(), 'timezone' => $timezone, 'theme' => 'pure', 'adminTheme' => 'default', 'homepage' => '', 'postsperpage' => '6', 'uriPost' => '/post/', 'uriPage' => '/', 'uriTag' => '/tag/', 'url' => 'http://' . DOMAIN . HTML_PATH_ROOT, 'cliMode' => 'true', 'emailFrom' => 'no-reply@' . DOMAIN);
    file_put_contents(PATH_DATABASES . 'site.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    $salt = getRandomString();
    $passwordHash = sha1($adminPassword . $salt);
    // File users.php
    $data = array('admin' => array('firstName' => '', 'lastName' => '', 'twitter' => '', 'role' => 'admin', 'password' => $passwordHash, 'salt' => $salt, 'email' => $email, 'registered' => $currentDate));
    file_put_contents(PATH_DATABASES . 'users.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File security.php
    $data = array('minutesBlocked' => 5, 'numberFailuresAllowed' => 10, 'blackList' => array());
    file_put_contents(PATH_DATABASES . 'security.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
    // File tags.php
    file_put_contents(PATH_DATABASES . 'tags.php', $dataHead . json_encode(array('postsIndex' => array('bludit' => array('name' => 'Bludit', 'posts' => array('first-post')), 'cms' => array('name' => 'CMS', 'posts' => array('first-post')), 'flat-files' => array('name' => 'Flat files', 'posts' => array('first-post'))), 'pagesIndex' => array()), JSON_PRETTY_PRINT), LOCK_EX);
    // PLUGINS
    // File plugins/pages/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'pages' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'homeLink' => true, 'label' => $Language->get('Pages')), JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/simplemde/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'simplemde' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'tabSize' => 4, 'toolbar' => '&quot;bold&quot;, &quot;italic&quot;, &quot;heading&quot;, &quot;|&quot;, &quot;quote&quot;, &quot;unordered-list&quot;, &quot;|&quot;, &quot;link&quot;, &quot;image&quot;, &quot;code&quot;, &quot;horizontal-rule&quot;, &quot;|&quot;, &quot;preview&quot;, &quot;side-by-side&quot;, &quot;fullscreen&quot;, &quot;guide&quot;'), JSON_PRETTY_PRINT), LOCK_EX);
    // File plugins/tags/db.php
    file_put_contents(PATH_PLUGINS_DATABASES . 'tags' . DS . 'db.php', $dataHead . json_encode(array('position' => 0, 'label' => $Language->get('Tags')), JSON_PRETTY_PRINT), LOCK_EX);
    // File index.txt for error page
    $data = 'Title: ' . $Language->get('Error') . '
	Content: ' . $Language->get('The page has not been found');
    file_put_contents(PATH_PAGES . 'error' . DS . 'index.txt', $data, LOCK_EX);
    // File index.txt for welcome post
    $data = 'Title: ' . $Language->get('First post') . '
Content:

## ' . $Language->get('Congratulations you have successfully installed your Bludit') . '

### ' . $Language->get('Whats next') . '
- ' . $Language->get('Manage your Bludit from the admin panel') . '
- ' . $Language->get('Follow Bludit on') . ' [Twitter](https://twitter.com/bludit) / [Facebook](https://www.facebook.com/pages/Bludit/239255789455913) / [Google+](https://plus.google.com/+Bluditcms)
- ' . $Language->get('Visit the support forum') . '
- ' . $Language->get('Read the documentation for more information') . '
- ' . $Language->get('Share with your friends and enjoy');
    file_put_contents(PATH_POSTS . $firstPostSlug . DS . 'index.txt', $data, LOCK_EX);
    return true;
}
开发者ID:veshinak,项目名称:bludit,代码行数:86,代码来源:install.php

示例15: sendExpo

 function sendExpo()
 {
     global $LNG, $ProdGrid, $resource, $reslist, $CONF, $pricelist, $USER, $PLANET;
     $Type_search = HTTP::_GP('type_fouille', '');
     $Popu = array();
     $endtime = 0;
     if ($Type_search == 1) {
         $endtime = rand(7200, 9000);
     } elseif ($Type_search == 2) {
         $endtime = rand(14400, 16200);
     } elseif ($Type_search == 3) {
         $endtime = rand(21600, 23400);
     }
     foreach ($reslist['population'] as $id => $popID) {
         $amount = max(0, round(HTTP::_GP('population' . $popID, 0.0, 0.0)));
         if ($amount < 1) {
             continue;
         }
         $Popu[$popID] = $amount;
     }
     //if (empty($Popu))
     //FleetFunctions::GotoFleetPage();
     $token = getRandomString();
     $_SESSION['population'][$token] = array('time' => TIMESTAMP, 'population' => $Popu);
     $fleetArray = $_SESSION['population'][$token]['population'];
     foreach ($fleetArray as $Ship => $Count) {
         if ($Count > $PLANET[$resource[$Ship]]) {
             $this->printMessage('<span class="rouge">' . $LNG['ls_explora_27'] . '</span>');
         }
     }
     foreach ($fleetArray as $ShipID => $ShipCount) {
         $fleetData[] = $ShipID . ',' . floattostring($ShipCount);
         $planetQuery[] = $resource[$ShipID] . " = " . $resource[$ShipID] . " - " . floattostring($ShipCount);
         $PLANET[$resource[$ShipID]] -= floattostring($ShipCount);
     }
     $SQL = "LOCK TABLE uni1_explorations WRITE, " . USERS . " WRITE, " . PLANETS . " WRITE;\n\t\t\t\t   UPDATE " . PLANETS . " SET " . implode(", ", $planetQuery) . " WHERE id = " . $PLANET['id'] . ";\n\t\t\t\t   UPDATE " . USERS . " SET max_explore = max_explore + 1 WHERE id = " . $USER['id'] . ";\n\t\t\t\t   INSERT INTO uni1_explorations SET\n\t\t\t\t   userID              = " . $USER['id'] . ",\n\t\t\t\t   state              = '1',\n\t\t\t\t   type_of_search              = " . $Type_search . ",\n\t\t\t\t   start_planet_name              = '" . $PLANET['name'] . "',\n\t\t\t\t   start_system              = " . $PLANET['system'] . ",\n\t\t\t\t   start_planet              = " . $PLANET['planet'] . ",\n\t\t\t\t   end_planet_name              = '" . $PLANET['name'] . "',\n\t\t\t\t   start_time              = " . TIMESTAMP . ",\n\t\t\t\t   emd_time              = " . (TIMESTAMP + $endtime) . ",\n\t\t\t\t   population_array              = '" . implode(';', $fleetData) . "',\n\t\t\t\t   ships_array              = '" . implode(';', $fleetData) . "';\n\t\t\t\t   SET @explorationID = LAST_INSERT_ID();\n\t\t\t\t   UNLOCK TABLES;";
     $GLOBALS['DATABASE']->multi_query($SQL);
     $this->printMessage('<span class="vert">' . $LNG['ls_explora_26'] . '</span>', true, array('game.php?page=Explorations', 3));
     $this->tplObj->assign_vars(array());
     $this->display('page.explorations.busy.tpl');
 }
开发者ID:fuding,项目名称:Antaris,代码行数:41,代码来源:class.ShowExplorationsPage.php


注:本文中的getRandomString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。