本文整理汇总了PHP中make_seed函数的典型用法代码示例。如果您正苦于以下问题:PHP make_seed函数的具体用法?PHP make_seed怎么用?PHP make_seed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_seed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
public function generate($f3)
{
require_once '***/libs/htmlpurifier/library/HTMLPurifier.auto.php';
$purifier = new HTMLPurifier();
make_seed();
$models = array('cv2/lm_lstm_epoch50.00_0.5080.t7', 'cv/lm_lstm_epoch46.00_0.7940.t7');
$rnx = array_rand($models, 1);
$model = $models[$rnx];
$seed = round(rand());
$cmd = 'cd ***/char-rnn && th ***/char-rnn/sample.lua -verbose 0 -temperature 0.8 -gpuid -1 -seed ' . $seed . ' -length 2048 -primetext "<poem><html><head><meta charset=\\"utf-8\\"><style>body{background-color:#000;color:#0c0;}</style></head><body>" /home/drakh/klingon-poetry/' . $model;
$postVars = array('cmd' => $cmd);
$options = array('method' => 'POST', 'content' => http_build_query($postVars));
$r = \Web::instance()->request('http://127.0.0.1:1337', $options);
$clean_html = $purifier->purify($r['body']);
$poem = nl2br(trim($clean_html));
$db_data = array('seed' => $seed, 'model' => $model, 'poem' => $poem);
$data_to_save = json_encode($db_data, JSON_UNESCAPED_UNICODE);
$this->model->poem = $data_to_save;
$this->model->written_date = date('d.m.Y H:i:s');
$this->model->save();
$id = $this->model->id_poem;
$postVars = array('id' => $id);
$options = array('method' => 'POST', 'content' => http_build_query($postVars));
$r = \Web::instance()->request('http://127.0.0.1:1338', $options);
$f3->reroute('/poem/' . $id);
}
示例2: cleanup
/**
* This function will clean up old data in the database that is not
* needed according to user defined settings.
*
* Deletes entries in the database tables dstore, thatstack, thatstackindex
* and if set also conversationlog.
*
* @uses make_seed()
*
* @return void nothing, deletes database entires
*/
function cleanup()
{
if (RANDOMCHANCECLEAN == -1 || MINUTESTOKEEPDATA == -1) {
return;
}
mt_srand(make_seed());
$randval = mt_rand(1, RANDOMCHANCECLEAN);
if ($randval == RANDOMCHANCECLEAN) {
if (MINUTESTOKEEPDATA != -1) {
$clean_dstore = "delete from dstore where enteredtime < date_add(now(), interval - " . MINUTESTOKEEPDATA . " minute)";
$clean_thatstack = "delete from thatstack where enteredtime < date_add(now(), interval - " . MINUTESTOKEEPDATA . " minute)";
$clean_thatindex = "delete from thatindex where enteredtime < date_add(now(), interval - " . MINUTESTOKEEPDATA . " minute)";
$selectcode = mysql_query($clean_dstore);
if ($selectcode) {
}
$selectcode = mysql_query($clean_thatstack);
if ($selectcode) {
}
$selectcode = mysql_query($clean_thatindex);
if ($selectcode) {
}
}
if (MINUTESTOKEEPCHATLOG != -1) {
$clean_convlog = "delete from conversationlog where enteredtime < date_add(now(), interval - " . MINUTESTOKEEPCHATLOG . " minute) and " . whichbots();
$selectcode = mysql_query($clean_convlog);
if ($selectcode) {
}
}
}
}
示例3: make_password
function make_password($password_length){
srand(make_seed());
$alfa = "!@123!@4567!@890qwer!@tyuiopa@!sdfghjkl@!zxcvbn@!mQWERTYUIO@!PASDFGH@!JKLZXCVBNM!@";
$token = "";
for($i = 0; $i < $password_length; $i ++) {
$token .= $alfa[rand(0, strlen($alfa))];
}
return $token;
}
示例4: generatePass
function generatePass()
{
// Generate random password
srand(make_seed());
$alfa = "23456789qwertyuiopasdfghjkzxcvbnmQWERTYUIPASDFGHJKLZXCVBNM";
$password = "";
for ($i = 0; $i < 7; $i++) {
$password .= $alfa[rand(0, strlen($alfa) - 1)];
}
return $password;
}
示例5: gen_rnd_string
function gen_rnd_string()
{
$alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
// 1 and I removed
$myreturn = '';
mt_srand(make_seed());
for ($i = 0; $i < $this->chars; ++$i) {
$myreturn .= $alphabet[mt_rand(0, 31)];
}
return $myreturn;
}
示例6: promocode_generate
function promocode_generate($ini = 0)
{
# --------------------------------------------------------
$p1 = 0;
$p2 = 0;
$p3 = 0;
$c = 0;
mt_srand(make_seed());
$c = intval(mt_rand(1000000000, mt_getrandmax())) + 1 . (intval(mt_rand(1000000000, mt_getrandmax())) + 1) . (intval(mt_rand(1000000000, mt_getrandmax())) + 1);
$p1 = substr($c, 0, 5);
$p2 = substr($c, 7, 5);
$p3 = substr($c, 8, 3);
// print promocode_dv($p1). $p1. promocode_dv($p1.$p2). $p2. promocode_dv($p2) . $p3 ." ";
return substr(promocode_dv($p1) . $p1 . promocode_dv($p1 . $p2) . $p2 . promocode_dv($p2) . $p3, 0, 5);
}
示例7: add
function add()
{
if (!isset($_POST["message"])) {
// there is no message , return
return;
}
//write message into a file
mt_srand(make_seed());
$randval = mt_rand(1, 50);
$file = fopen("./message/" . $randval . ".txt", "w");
fwrite($file, $_POST["message"]);
fclose($file);
html_div(100, 10, "#ffffff", 20);
echo "Success, your message ID is " . $randval;
html_div_end();
}
示例8: randomString
function randomString($len)
{
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (double) $sec + (double) $usec * 100000;
}
srand(make_seed());
//Der String $possible enth�lt alle Zeichen, die verwendet werden sollen
$possible = "ABCDEFGHJKLMNPRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789";
$str = "";
while (strlen($str) < $len) {
$str .= substr($possible, rand() % strlen($possible), 1);
}
return $str;
}
示例9: getUnID
function getUnID($length)
{
$toRet = "";
$symbols = array();
for ($i = 0; $i < 26; $i++) {
$symbols[] = chr(97 + $i);
}
for ($i = 0; $i < 10; $i++) {
$symbols[] = chr(48 + $i);
}
srand(make_seed());
for ($i = 0; $i < $length; $i++) {
$toRet .= $symbols[rand(0, 35)];
}
return $toRet;
}
示例10: gen_new_pwd
function gen_new_pwd()
{
$password_length = 9;
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (double) $sec + (double) $usec * 100000;
}
srand(make_seed());
$alfa = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
$token = "";
for ($i = 0; $i < $password_length; $i++) {
$token .= $alfa[rand(0, strlen($alfa) - 1)];
}
return $token;
}
示例11: check_obval
function check_obval($tree)
{
global $char;
$rand = obval_chance($tree);
mt_srand(make_seed());
$ch = mt_rand(0, 100);
if ($ch <= $rand) {
//обвал
craft_DelFunc($char['user_id']);
myquery("DELETE FROM craft_build_rab WHERE user_id=" . $char['user_id'] . "");
myquery("UPDATE craft_build_stonemason SET klin=0,state=0,user_id=0,end_time=0,chance=0,reserve_time=0,reserve_user_id=0 WHERE id=" . $tree['id'] . "");
set_craft_delay($char['user_id'], 1);
echo '<b>Произошел обвал! Работа прекращена!</b><br><br>';
return 1;
} else {
myquery("UPDATE craft_build_stonemason SET chance=chance+5 WHERE id=" . $tree['id'] . "");
}
return 0;
}
示例12: generate_code
function generate_code($length = 7)
{
global $wovels, $wovelsnoy, $consonants, $start, $mid, $end, $freqs;
for ($i = 0; $i < $length; $i++) {
if ($i == 0) {
$chars = $wovelsnoy . $consonants;
} elseif ($i == 1) {
$chars = wcdispatch($result[$i - 1], $start);
} elseif (in_array($result[$i - 1], mbStringToArray($wovels)) && in_array($result[$i - 2], mbStringToArray($wovels))) {
$chars = $consonants;
} elseif (in_array($result[$i - 1], mbStringToArray($consonants)) && in_array($result[$i - 2], mbStringToArray($consonants))) {
$chars = checkharmony($result[$i - 1]);
} elseif ($i == $length - 1) {
$chars = wcdispatch($result[$i - 1], $end);
} else {
$chars = wcdispatch($result[$i - 1], $mid);
}
$charset = mbStringToArray($chars);
$sum = 0;
foreach ($charset as $char) {
$sum += $freqs[$char];
}
$xfq = array();
$bsum = 0;
foreach ($charset as $char) {
$balanced = $freqs[$char] / $sum;
$bsum += $balanced;
$xfq[(string) $bsum] = $char;
}
$roll = frand();
foreach ($xfq as $freq => $letter) {
if ($roll < $freq) {
$result[$i] = $letter;
$roll = 2;
}
}
}
mt_srand(make_seed());
$array_mix = preg_split('//', mb_strtoupper(implode("", $result)), -1, PREG_SPLIT_NO_EMPTY);
return implode("", $array_mix);
}
示例13: make_rand
public function make_rand()
{
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (double) $sec + (double) $usec * 100000;
}
$m = M('User');
$where['username'] = 'rand';
$arrc = $m->where($where)->find();
if ($arrc) {
$data['id'] = $arrc['id'];
$data['reg_time'] = time();
srand(make_seed());
$data['password'] = rand(1000, 9999);
$succ = $m->save($data);
if ($succ) {
$this->redirect('Admin/index');
}
} else {
}
}
示例14: init_srand
function init_srand($seed = '')
{
static $wascalled = FALSE;
if (!$wascalled) {
$seed = $seed === '' ? make_seed() : $seed;
srand($seed);
$wascalled = TRUE;
}
}
示例15: sortrandom
function sortrandom()
{
$result = db_execquery('SELECT id from ' . TBL_PLAYLIST_LIST . ' WHERE listid = ' . $this->listid . ' ORDER BY ID ASC');
srand(make_seed());
while ($row = db_fetch_row($result)) {
db_execquery('UPDATE ' . TBL_PLAYLIST_LIST . ' SET seq = ' . getrand() . ' WHERE id = ' . $row[0], true);
}
$this->rewriteseq();
}