コード例 #1
0
 public function query_num($comCode = false)
 {
     //?type=shunfeng&postid=688624242254&id=1&valicode=&temp=0.5323619142104129
     if ($comCode) {
         $query = '?type=' . $comCode . '&postid=' . $this->number . '&valicode=&temp=' . random_float();
     } else {
         $query = '?type=' . $this->comCode[0] . '&postid=' . $this->number . '&valicode=&temp=' . random_float();
     }
     curl_setopt_array(self::$ch, array(CURLOPT_URL => 'http://www.kuaidi100.com/query' . $query, CURLOPT_POST => 0));
     $response = curl_exec(self::$ch);
     //$response = json_decode($response, true);
     return $response;
 }
コード例 #2
0
ファイル: adaptive_system.php プロジェクト: 0-php/AI
 function Element($action_potential = NULL, $threshold = NULL, $is_input = NULL, $is_output = NULL)
 {
     if ($action_potential == NULL) {
         $action_potential = random_float(0, 1);
     }
     if ($threshold == NULL) {
         $threshold = rand(0, 1);
     }
     if ($is_input == NULL) {
         $is_input = (int) probability($this->genome['percent_of_inputs']);
     }
     if ($is_output == NULL) {
         $is_output = (int) probability($this->genome['percent_of_outputs']);
     }
     return array('potential' => $action_potential, 'threshold' => $threshold, 'is_input' => $is_input, 'is_output' => $is_output);
 }
コード例 #3
0
ファイル: dataPush_server.php プロジェクト: rachmatg/agr
require_once "config.inc.php";
require_once "db.inc.php";
if ($_GET['flag'] == 1) {
    //url:http://localhost/Agr_origin/dataPush_server.php?flag=1&&sensor_id=1&max=100&min=2
    $max = $_GET['max'];
    $min = $_GET['min'];
    $sensor_id = $_GET['sensor_id'];
    //想要 5 到 15(包括 5 和 15)之间的随机数,用 rand(5, 15)。
    //$SQL ="INSERT INTO $table ($str1) VALUES ($str2)";
    function random_float($min, $max)
    {
        return $min + lcg_value() * abs($max - $min);
    }
    //上方函数是为了产生出浮点数
    //sprintf是为了产生2位小数
    $randData = sprintf("%.2f", random_float($min, $max));
    // $randData = rand($min,$max);
    //
    $SQL = "SELECT * FROM device_message WHERE sensor_id = {$sensor_id}";
    // echo $SQL; exit(0);
    //device表   id zone greenhouse_id sensor_id add_mac sensor_type cod_x cod_y time
    //history_message表  id zone greenhouse_id sensor_id add_mac sensor_type cod_x cod_y data time
    $result = mysql_query($SQL) or die("Couldn t execute query." . mysql_error());
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $dataName = "`zone`,`greenhouse_id`,`sensor_id`,`add_mac`,`sensor_type`,`cod_x`,`cod_y`,`data`";
        $sep = "'";
        $dataValue = "{$row['zone']},{$row['greenhouse_id']},{$sensor_id}, {$sep}{$row['add_mac']}{$sep}, {$sep}{$row['sensor_type']}{$sep},{$sep}{$row['cod_x']}{$sep},{$sep}{$row['cod_y']}{$sep},{$sep}{$randData}{$sep}";
        //echo $dataValue; exit(0);
        //$dataValue = "{$row['zone']},{$row['greenhouse_id']}";
        $SQL = "INSERT INTO `history_message` ({$dataName}) VALUES ({$dataValue})";
        $result = mysql_query($SQL) or die("Couldn t execute query." . mysql_error());
コード例 #4
0
ファイル: createaccount_action.php プロジェクト: jboismar/SKM
	<?php 
        $passwd = $_POST['psPassword'];
        $action = $_POST['action'];
        $name = $_POST['name'];
        $dsthost = $_POST['sshhost'];
        $newusr = $name;
        // We create the user
        $GLOBALS['sudousr'] = $GLOBALS['sudousr'];
        $sudoident = $GLOBALS['sudoident'];
        if (!empty($passwd)) {
            function random_float($min, $max)
            {
                return $min + lcg_value() * abs($max - $min);
            }
            $SALT = random_float(10, 20);
            $CRYPTpw = shell_exec("perl -e \"print crypt(\"{$passwd}\",\"{$SALT}\")\"");
            if (!empty($CRYPTpw)) {
                $output = CR_SSHUSER($sudoident, $GLOBALS['sudousr'], $dsthost, $name, $CRYPTpw);
            } else {
                print "ssh connect fail. Internal PW encryption failed. Try to use no special characters.";
                #header("location:sshconnectfail.php?result=pwENCfail");
            }
            if ($output == "OK") {
                $output .= "Creating account successfull";
                $sshtest = TEST_SSHUSER($dsthost, $newusr, $passwd);
                if ("{$sshtest}" != "OK") {
                    $output .= $sshtest;
                    print "{$output}";
                    header("location:sshconnectfail.php?result=testfail");
                } else {
コード例 #5
0
ファイル: randomizer.php プロジェクト: ksm0814/roulette
<?php

$min = 0;
$max = 4;
$val = 0;
function random_float($min, $max)
{
    $val = round($min + lcg_value() * abs($max - $min), 3);
    $bal = round(fmod($val, 0.005), 3);
    $val = $val - $bal;
    echo $val;
}
random_float($min, $max);
コード例 #6
0
ファイル: self-organizing_neurons.php プロジェクト: 0-php/AI
<?php

$inputs = 3;
$hidden = 3;
$outputs = 1;
$inputNeurons = array();
$hiddenNeurons = array();
$outputNeurons = array();
for ($i = 0; $i < $inputs; $i++) {
    $inputNeurons[$i] = random_float(-1, 1);
}
for ($i = 0; $i < $hidden; $i++) {
    $hiddenNeurons[$i] = array('threshold' => random_float(-1, 1));
}
$xor_test = (array) json_decode(file_get_contents('data/xor.json'));
function random_float($min, $max)
{
    return $min + lcg_value() * abs($max - $min);
}