Ejemplo n.º 1
0
 function sendVCode()
 {
     $mobile = E_GET("mobile");
     $vcode = randNum(6);
     session_start();
     $_SESSION["vcode"] = $vcode;
     echo "开始向 " . $mobile . " 发送验证码 " . $_SESSION["vcode"] . " ";
 }
Ejemplo n.º 2
0
function randNum($len = 6)
{
    $arr = range(0, 9);
    $i = 0;
    shuffle($arr);
    $ret = "";
    foreach ($arr as $values) {
        $ret = $ret . $values . "";
        $i++;
        if ($i + 1 > $len) {
            break;
        }
    }
    return $ret;
}
echo randNum(6);
function retrieve($url)
{
    preg_match('/\\/([^\\/]+\\.[a-z]+)[^\\/]*$/', $url, $match);
    return $match[1];
}
function dir_path($path)
{
    $path = str_replace('\\', '/', $path);
    if (substr($path, -1) != '/') {
        $path = $path . '/';
    }
    return $path;
}
function dir_list($path, $exts = '', $list = array())
{
Ejemplo n.º 3
0
 public function getCaptcha()
 {
     $phone = I('post.phone');
     $captcha = randNum(4);
     session('captcha', $captcha);
     $re = sendMsg($phone, $captcha, 'resetpwd');
     if ($re) {
         $this->ajaxReturn($re);
     } else {
         $this->ajaxReturn("failed");
     }
 }
Ejemplo n.º 4
0
    echo "Usage:\n";
    echo "\tphp extensions/DataCenter/CLI/Import.php --dummy \n";
    echo "\tImports dummy data into tables, useful for testing.\n";
} else {
    if (isset($options['dummy'])) {
        echo "Importing dummy data into DataCenter tables...\n";
        require_once dirname(dirname(__FILE__)) . '/DataCenter.db.php';
        function randAlphaNum()
        {
            return strtoupper(substr(md5(rand()), 0, 10));
        }
        function randNum()
        {
            return rand(1111111111, 9999999999.0);
        }
        $data = array(array('function' => array('DataCenterDBLocation', 'newFromValues'), 'fields' => array('tense', 'name', 'region', 'latitude', 'longitude'), 'values' => array(array('present', 'PMTPA', 'Tampa, FL', 27.98141, -82.45114100000001), array('present', 'SFO', 'San Francisco, CA', 37.775196, -122.419204))), array('function' => array('DataCenterDBSpace', 'newFromValues'), 'fields' => array('tense', 'name', 'location', 'width', 'height', 'depth', 'power'), 'values' => array(array('present', 'Server Room', 1, 3, 3, 7, 1000), array('present', 'Data Closet', 2, 3, 3, 5, 200))), array('function' => array('DataCenterDBAsset', 'newFromType'), 'parameter' => 'rack', 'fields' => array('tense', 'model', 'location', 'asset', 'serial'), 'values' => array(array('present', 2, 1, randAlphaNum(), randNum()), array('present', 2, 1, randAlphaNum(), randNum()), array('present', 2, 1, randAlphaNum(), randNum()), array('present', 2, 1, randAlphaNum(), randNum()), array('present', 2, 1, randAlphaNum(), randNum()), array('present', 2, 2, randAlphaNum(), randNum()))), array('function' => array('DataCenterDBAsset', 'newFromType'), 'parameter' => 'object', 'fields' => array('tense', 'model', 'location', 'asset', 'serial'), 'values' => array(array('present', 1, 2, randAlphaNum(), randNum()), array('present', 1, 2, randAlphaNum(), randNum()), array('present', 1, 2, randAlphaNum(), randNum()), array('present', 1, 2, randAlphaNum(), randNum()), array('present', 2, 2, randAlphaNum(), randNum()), array('present', 3, 2, randAlphaNum(), randNum()))), array('function' => array('DataCenterDBModel', 'newFromType'), 'parameter' => 'rack', 'fields' => array('manufacturer', 'name', 'kind', 'units'), 'values' => array(array('Rittal', 'TS-42', 'Rack', 42), array('Rittal', 'TS-44', 'Rack', 44), array('Rittal', 'TS-47', 'Rack', 47))), array('function' => array('DataCenterDBModel', 'newFromType'), 'parameter' => 'object', 'fields' => array('manufacturer', 'name', 'kind', 'form_factor', 'units', 'depth', 'power'), 'values' => array(array('Sun', 'Cobalt RaQ XTR', 'Web Server', 'rackunit', 2, 3, 400), array('Cisco', 'Catalyst 2950', 'Switch', 'rackunit', 1, 1, 100), array('APC', 'Smart-UPS 3000VA', 'UPS', 'rackunit', 5, 2, 20))), array('function' => array('DataCenterDBModel', 'newFromType'), 'parameter' => 'port', 'fields' => array('name', 'kind', 'category', 'format'), 'values' => array(array('1000Base-ZX', 'Ethernet', 'network', 'digital'), array('10GBase-CX4', 'Ethernet', 'network', 'digital'), array('10GBase-ER', 'Ethernet', 'network', 'digital'), array('10GBase-Kx', 'Ethernet', 'network', 'digital'), array('10GBase-LR', 'Ethernet', 'network', 'digital'), array('10GBase-LRM', 'Ethernet', 'network', 'digital'), array('10GBase-LX4', 'Ethernet', 'network', 'digital'), array('10GBase-ZR', 'Ethernet', 'network', 'digital'), array('LC/1000Base-LX', 'Ethernet', 'network', 'digital'), array('LC/1000Base-SX', 'Ethernet', 'network', 'digital'), array('LC/100Base-FX', 'Ethernet', 'network', 'digital'), array('LC/100Base-SX', 'Ethernet', 'network', 'digital'), array('LC/10GBase-SR', 'Ethernet', 'network', 'digital'), array('RJ-45/1000Base-T', 'Ethernet', 'network', 'digital'), array('RJ-45/100Base-TX', 'Ethernet', 'network', 'digital'), array('RJ-45/10Base-T', 'Ethernet', 'network', 'digital'), array('SC/1000Base-LX', 'Ethernet', 'network', 'digital'), array('SC/1000Base-SX', 'Ethernet', 'network', 'digital'), array('SC/100Base-FX', 'Ethernet', 'network', 'digital'), array('SC/100Base-SX', 'Ethernet', 'network', 'digital'), array('BNC/10Base2', 'Token Ring', 'network', 'digital'), array('RS-232', 'Serial', 'serial', 'digital'), array('RS-442', 'Serial', 'serial', 'digital'), array('IEC 120v', 'Power', 'power', 'none'), array('IEC 240v', 'Power', 'power', 'none'), array('Type A 120v', 'Power', 'power', 'none'), array('Type B 120v', 'Power', 'power', 'none'), array('Type C 240v', 'Power', 'power', 'none'), array('Type F 240v', 'Power', 'power', 'none'), array('PS2', 'User Input', 'serial', 'digital'), array('USB 1.0', 'USB', 'serial', 'digital'), array('USB 2.0', 'USB', 'serial', 'digital'), array('IEEE 1394a', 'FireWire', 'serial', 'digital'), array('IEEE 1394b', 'FireWire', 'serial', 'digital'), array('IEEE 1394c', 'FireWire', 'serial', 'digital'), array('VGA', 'Video', 'video', 'analog'), array('DVI', 'Video', 'video', 'digital'), array('MiniDVI', 'Video', 'video', 'digital'), array('MicroDVI', 'Video', 'video', 'digital'), array('Optical Audio', 'Audio', 'audio', 'digital'), array('Analog Audio', 'Audio', 'audio', 'analog'), array('Hybrid Audio', 'Audio', 'audio', 'mixed'), array('Other', 'Port', 'other', 'none'))), array('function' => array('DataCenterDBMetaField', 'newFromValues'), 'fields' => array('name', 'format'), 'values' => array(array('WikiMedia Owned', 'boolean'), array('Notes', 'text'), array('Weight (LBS)', 'number'), array('Assigned User', 'string'))), array('function' => array('DataCenterDBMetaValue', 'newFromValues'), 'fields' => array('component_category', 'component_type', 'component_id', 'field', 'value'), 'values' => array(array('facility', 'location', 2, 1, true), array('facility', 'location', 2, 2, 'The best place to be!'))), array('function' => array('DataCenterDBPlan', 'newFromValues'), 'fields' => array('tense', 'space', 'name', 'note'), 'values' => array(array('present', 1, 'PMTA 1.0', 'Current configuration'), array('present', 2, 'SFO 1.0', 'Incomplete but current'), array('future', 1, 'PMTA 1.1', 'Upcoming configuration'))), array('function' => array('DataCenterDBAssetLink', 'newFromValues'), 'fields' => array('name', 'plan', 'tense', 'parent_link', 'asset_type', 'asset_id', 'x', 'y', 'z', 'orientation'), 'values' => array(array('Rack 1A', 1, 'present', null, 'rack', 1, 2, 1, null, 1), array('Rack 1B', 1, 'present', null, 'rack', 2, 2, 2, null, 1), array('Rack 1C', 1, 'present', null, 'rack', 3, 2, 3, null, 1), array('Rack 1D', 1, 'present', null, 'rack', 4, 2, 4, null, 1), array('Rack 1E', 1, 'present', null, 'rack', 5, 2, 5, null, 1), array('Rack 1A', 2, 'present', null, 'rack', 6, 3, 4, null, 1), array('Web Server A', 2, 'present', 6, 'object', 1, null, null, 1, 0), array('Web Server B', 2, 'present', 6, 'object', 2, null, null, 3, 0), array('Web Server C', 2, 'present', 6, 'object', 3, null, null, 5, 0), array('Web Server D', 2, 'present', 6, 'object', 4, null, null, 7, 0), array('Switch', 2, 'present', 6, 'object', 5, null, null, 9, 0), array('UPS', 2, 'present', 6, 'object', 6, null, null, 10, 0))), array('function' => array('DataCenterDBModelLink', 'newFromValues'), 'fields' => array('name', 'quantity', 'parent_type', 'parent_id', 'child_type', 'child_id'), 'values' => array(array('Ethernet', 2, 'object', 1, 'port', 14), array('Ethernet', 24, 'object', 2, 'port', 14), array('Power In', 1, 'object', 3, 'port', 27), array('Power Out', 8, 'object', 3, 'port', 24))), array('function' => array('DataCenterDBMetaFieldLink', 'newFromValues'), 'fields' => array('field', 'component_category', 'component_type'), 'values' => array(array(1, 'facility', 'location'), array(1, 'facility', 'space'), array(1, 'asset', 'rack'), array(1, 'asset', 'object'), array(2, 'facility', 'location'), array(2, 'facility', 'space'), array(2, 'asset', 'rack'), array(2, 'asset', 'object'), array(2, 'model', 'rack'), array(2, 'model', 'object'), array(2, 'model', 'port'), array(3, 'asset', 'object'), array(4, 'asset', 'object'))));
        foreach ($data as $type) {
            // Checks if fields, values and function exist
            if (isset($type['fields']) && isset($type['values']) && isset($type['function'])) {
                $values = array();
                foreach ($type['values'] as $row) {
                    // Correlates data
                    $values = array();
                    if (count($row) == count($type['fields'])) {
                        foreach ($type['fields'] as $index => $field) {
                            $values[$field] = $row[$index];
                        }
                    } else {
                        throw new MWException('Mismatch of fields and values lengths!');
                    }
                    // Checks if call and parameter exist
Ejemplo n.º 5
0
 public function getCaptcha()
 {
     $phone = I('post.phone');
     $captcha = randNum(4);
     session('reg.captcha', $captcha);
     sendMsg($phone, $captcha, 'reg');
 }
Ejemplo n.º 6
0
        return $randNumber;
    }
    for ($i = 0; $i < $numYears; $i++) {
        $year = 2014 - $i;
        $jan = randNum();
        $feb = randNum();
        $march = randNum();
        $april = randNum();
        $may = randNum();
        $june = randNum();
        $july = randNum();
        $august = randNum();
        $september = randNum();
        $october = randNum();
        $november = randNum();
        $december = randNum();
        $total = $jan + $feb + $march + $april + $may + $june + $july + $august + $september + $november + $december;
        ?>
        <tr>
            <td><?php 
        echo $year;
        ?>
</td>
            <td><?php 
        echo $jan;
        ?>
</td>
            <td><?php 
        echo $feb;
        ?>
</td>
Ejemplo n.º 7
0
    $a = rand(0, 1);
    $b = rand(0, 1);
    $c = rand(0, 1);
    $d = rand(0, 1);
    $e = rand(0, 1);
    $f = rand(0, 1);
    $count = $a . $b . $c . $d . $e . $f;
    //得到结果
    if ($a + $b + $c + $d + $e + $f == 4) {
        return $count;
    }
}
$arr = [];
$arrCount = 0;
for ($i = 0; $i < 400; $i++) {
    if (!empty($waitNum = randNum()) && !in_array($waitNum, $arr)) {
        $arr[$arrCount] = $waitNum;
        $arrCount++;
    }
}
var_dump($arr);
//在400次的时候已经不会出错了 在300次的时候偶尔出现一次错误
//方法二 使用数学公式  阶乘
function getNum($a)
{
    if ($a > 1) {
        $sum = $a * getNum($a - 1);
    } else {
        $sum = $a;
        //还必须得有这个 else
    }