function getServerName($array1, $array2) { $adjective = getRandom($array1); $noun = getRandom($array2); $name = "{$adjective} {$noun}"; return $name; }
function pageController() { $nounArray = ['Tree', 'Bear', 'Wolf', 'Pedro', 'Pidgeon', 'Dog', 'Flower', 'Bull', 'Fox', 'Horse']; $adjectiveArray = ['Happy', 'Flaming', 'Flying', 'Screaming', 'Dancing', 'Soggy', 'Kicking', 'Running', 'Flailing', 'Many']; $data = []; $data['name'] = makeName(getRandom($nounArray, $adjectiveArray)); return $data; }
public function sendCaptcha($mobile) { $rep = array(); $captcha = getRandom(6, 1); $_SESSION['captcha'][$mobile] = $captcha; $msg = '您好,您的验证码是' . $captcha; $sms = new L_SMS($mobile, $msg); $code = $sms->send(); if ($code == 0) { $rep['code'] = 1; $rep['error'] = '验证码已发送'; } else { $rep['code'] = 0; $rep['error'] = '验证码发送失败'; } return $rep; }
/** * 字符串加密 * @param string $txt 要加密的字符串 * @param string $key 自定义key字符串,加密时用到 * @return string $string 加密后的字符串 */ function encrypt($txt, $key = 'aJq0q3Yezx-6HdHC8yFEORjlWTgyUHzRzdSgpa4m') { $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_."; $ikey = "6acb9732b4a4eb64c01f07f6e80a078f"; $nh1 = rand(0, 64); $nh2 = rand(0, 64); $nh3 = rand(0, 64); $ch1 = $chars[$nh1]; $ch2 = $chars[$nh2]; $ch3 = $chars[$nh3]; $nhnum = $nh1 + $nh2 + $nh3; $knum = 0; $i = 0; while (isset($key[$i])) { $knum += ord($key[$i++]); } $mdKey = substr(md5(md5(md5($key . $ch1) . $ch2 . $ikey) . $ch3), $nhnum % 8, $knum % 8 + 16); $txt = base64_encode($txt); $txt = str_replace(array('+', '/', '='), array('-', '_', '.'), $txt); $tmp = ''; $j = 0; $k = 0; $tlen = strlen($txt); $klen = strlen($mdKey); for ($i = 0; $i < $tlen; $i++) { $k = $k == $klen ? 0 : $k; $j = ($nhnum + strpos($chars, $txt[$i]) + ord($mdKey[$k++])) % 64; $tmp .= $chars[$j]; } $tmplen = strlen($tmp); $tmp = substr_replace($tmp, $ch3, $nh2 % ++$tmplen, 0); $tmp = substr_replace($tmp, $ch2, $nh1 % ++$tmplen, 0); $tmp = substr_replace($tmp, $ch1, $knum % ++$tmplen, 0); // add $tmp = getRandom(5, 5) . $tmp . getRandom(8, 5); $tmp = strrev($tmp); return $tmp; }
public function qrcodeAction() { $value = $this->get('value', FALSE); if ($value) { Yaf_Loader::import('L_Qrcode.class.php'); $savePath .= APP_PATH . '/public/qrcode'; if (!file_exists($savePath)) { Helper::import('File'); createRDir($savePath); } $err = 'L'; $size = '10'; // 有 LOGO 的话去掉下一行的注释, 并作为构造函数的第五个参数传入 //$logo = APP_PATH.'/asset/logo.jpg'; Helper::import('String'); $file = getRandom(6, 1) . '.png'; $qr = $savePath . '/' . $file; $Qrcode = new L_Qrcode($value, $qr, $err, $size); $Qrcode->createQr(); $buffer['qrCode'] = '/qrcode/' . $file; } $this->getView()->assign($buffer); }
{ $str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $key = ""; for ($i = 0; $i < $param; $i++) { $key .= $str[mt_rand(0, 32)]; //生成php随机数 } return $key; } $ranstr1 = getRandom(150); $ranstr2 = getRandom(400); $str1 = str_replace('http://t.cn/', '', $str1); ?> <div align="center"><div class="htmleaf-container"><div class="wrapper form-success"><tr><td><form action="str.php" method="post"><p align="right">中文 | <a href="en/">English</a></p><p align="center">长链接生成器v2.2</p>生成成功!<a href="<?php echo $str1; ?> " target="_blank">原网址</a>的长链接为:<br><p><input type="text" name="content" id="fe_text" placeholder="输入网址~" value="http://<?php echo getRandom(63); ?> .biubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiu.com/<?php $strcount = strlen($str1); for ($x = 0; $x < $strcount; $x++) { $ranstr1[$x * 4 + 4] = $str1[$x]; } $ranstr1[2] = $strcount; $final = $ranstr1 . $ranstr2; $final = base64_encode($final); $final = str_replace('=', '', $final); echo $final; ?> " size="82"> <button id="d_clip_button" class="button grey large" data-clipboard-target="fe_text"><b>copy~</b></button><br><a href="index.html">再生成一个长链接</a></p><p align="right">by <a href="http://www.chenxublog.com/" target="_blank">晨旭</a></p></form></td></tr><ul class="bg-bubbles"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul></div></div></div><script src="jquery-2.1.1.min.js" type="text/javascript"></script><script>$("#login-button").click(function(e){e.preventDefault(),$("form").fadeOut(500),$(".wrapper").addClass("form-success")});</script><script type="text/javascript" src="ZeroClipboard.min.js"></script><script type="text/javascript">var clip=new ZeroClipboard(document.getElementById("d_clip_button"),{moviePath:"ZeroClipboard.swf"});clip.on("complete",function(){alert("复制成功~")});</script><script type="text/javascript" src="http://v3.jiathis.com/code_mini/jiathis_r.js?type=left&move=0&btn=l1.gif" charset="utf-8"></script><tr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><div class="ds-thread" data-thread-key="1" data-title="长链接生成器" data-url="http://biubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiubiu.com/index.html"></div><script type="text/javascript">var duoshuoQuery={short_name:"biubiubiubiubiubiu"};!function(){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src=("https:"==document.location.protocol?"https:":"http:")+"//static.duoshuo.com/embed.js",t.charset="UTF-8",(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(t)}();</script></tr></body></html></html>
public function ceshi() { function getRandom($array, $rate) { $rate = explode(':', $rate); $sum = 0; $left = 0; $right = 0; foreach ($rate as $value) { $sum += $value * 10; } $temp = rand(0, $sum); foreach ($rate as $key => $value) { $right += $value * 10; if ($left <= $temp && $temp < $right) { return $array[$key]; } $left += $value * 10; } } /*$array = array(0,1,2,3); $rate = '2:1:3:5'; $a=$b=$c=$d=0; for($i=0;$i<1100;$i++){ if(getRandom($array,$rate)==0){ $a++; } if(getRandom($array,$rate)==1){ $b++; } if(getRandom($array,$rate)==2){ $c++; } if(getRandom($array,$rate)==3){ $d++; } } echo $a; echo "\n"; echo $b; echo "\n"; echo $c; echo "\n"; echo $d; echo "\n";*/ $array = array(1, 0); $rate = '9:1'; $a = $b = 0; for ($i = 0; $i < 1000; $i++) { if (getRandom($array, $rate)) { $a++; } if (!getRandom($array, $rate)) { $b++; } } echo $a; echo "\n"; echo $b; }
}*/ } //echo "<br>Manager ID Selection "; while ($ifmid) { $mid = getRandom(5, 16); $ifmid = search($mid, "mid", "manager"); //echo "<br><br>Manager ID : ".$mid; /* if($ifmcode) { echo "<br> Manager ID".$mid." already present!!"; } else { echo "<br> Manager ID ".$mid." available!!"; }*/ } //echo "<br>Password Selection "; $pass = "******"; $pass = getRandom(6, 16); //echo "<br><br>Password : "******"<br>username validation"; if (!(strlen($uname) >= 6) && strlen($uname) < 15) { $uFlag = 1; $flag = 0; } for ($i = 0; $i < strlen($uname); $i++) { if (!(ctype_alnum($uname[$i]) || $uname[$i] != '_')) { $uFlag = 1; $flag = 0; } }
function performDraw() { global $maxBingoInt; global $chosenNumbers; global $sheetSize; global $bingoSheets; global $bingoedCount; global $maxBingoHit; global $freeSpace; global $totalDrawResults; $randNum = getRandom($maxBingoInt) + 1; while (in_array($randNum, $chosenNumbers)) { $randNum = getRandom($maxBingoInt) + 1; } $chosenNumbers[] = $randNum; if (count($chosenNumbers) >= $sheetSize) { $tempIdStore = array(); for ($i = 0; $i < count($bingoSheets); $i++) { $res = checkBingo($bingoSheets[$i]); if ($res) { $tempIdStore[] = $i; } } if (count($tempIdStore) > 0) { $bingoedCount += count($tempIdStore); $tempIdStore = array_reverse($tempIdStore); for ($j = 0; $j < count($tempIdStore); $j++) { array_splice($bingoSheets, $tempIdStore[$j], 1); } } } if (count($bingoSheets) > 0 && $bingoedCount < $maxBingoHit) { performDraw(); } else { $totalDrawResults[] = count($chosenNumbers) - ($freeSpace ? 1 : 0); outputEcho('Completed'); } }
<body> <link href="main.css" rel="stylesheet"> <div class="header"></div> <?php //echo (rand()%16); RANDOM FUNCTION if ($flag == 0) { $ifmcode = 1; $ifmid = 1; //MANAGER CODE SELECTION while ($ifmcode) { $scode = getRandom(10, 16); $ifmcode = search($scode, "scode", "station"); } echo "<br />Station Code: " . $scode; while ($ifmid) { $sid = getRandom(5, 16); $ifmid = search($sid, "sid", "manager"); } //VALIDATION //---------- //STATION NAME VALIDATION $nFlag = 0; if (strlen($sname) > 30 || strlen($sname) < 2) { $flag = 1; $nFlag = 1; } if (!ctype_alpha($sname[0])) { $flag = 1; $nFlag = 1; } for ($i = 1; $i < strlen($sname); $i++) {
return isset($_POST['userid']); } ///////////////////////////////////////////////////////////////登录 function login() { $str4 = "<li class=\"login\"><a href=\"login.html\">登录</a></li>"; if (isloged()) { $userid = $_POST['userid']; $str4 = "<li class=\"login\"><a href=\"javascript:logout()\">退出</a></li>"; $str4 = $str4 . "<li class=\"login\"><a id=\"userid\" href=\"#\">{$userid}</a></li>"; } return $str4; } ////////////////////////////////////////////////////////////////////////////////////////////////////// //$recommend=recommend(); $randombook = getRandom(); $login = login(); $mostRatedBooks = getRateMost(); $rateRecord = getRateRecord(); $str1 = <<<HTMLSTR <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>图书推荐系统</title> \t <head> <link rel="shortcut icon" href="images/favicon.ico" > <link href="./css/frame.css" charset="UTF-8" type="text/css" rel="stylesheet"/> <script src="js/jquery-1.11.3.min.js"></script> <script language="JavaScript" src="js/js.js">
fclose($fp); echo "Failed <a href=\"javascript:window.open('" . $DATABASE_SCRIPT_DIR . $DS_LOGS_DIR . $logFile . "');\">view log</a> or <a href=\"javascript:resetForm();\">add another</a>"; exit; } for ($l = 0; $l < $trackLength; $l++) { $trackAddedTime = mt_rand($albumAddedTime, time(null)); if ($trackLength == 1) { $trackInfo = getTrackInfo($trackList->tracks->track); } else { $trackInfo = getTrackInfo($trackList->tracks->track[$l]); } if (trackExist($dbHandle, $albumId, addslashes($trackInfo['name']), $trackInfo['duration'])) { fprintf($fp, "DUP track, skipping track\n"); $warning++; } else { $sql[0] = "INSERT INTO track_list (album_id, track_name, duration, time_added) VALUES ('" . $albumId . "', '" . addslashes($trackInfo['name']) . "', '" . $trackInfo['duration'] . "', '" . getRandom() . "')"; $sql[1] = "SELECT * FROM track_list WHERE album_id='" . $albumId . "' AND `track_name`='" . addslashes($trackInfo['name']) . "' AND duration='" . $trackInfo['duration'] . "'"; if (!insertQuery($dbHandle, $sql)) { fprintf($fp, "Unable to insert track into database\n"); fclose($fp); echo "Failed <a href=\"javascript:window.open('" . $DATABASE_SCRIPT_DIR . $DS_LOGS_DIR . $logFile . "');\">view log</a>"; exit; } if (!trackExist($dbHandle, $albumId, addslashes($trackInfo['name']), $trackInfo['duration'])) { fprintf($fp, "Unable to get track from database\n"); fclose($fp); echo "Failed <a href=\"javascript:window.open('" . $DATABASE_SCRIPT_DIR . $DS_LOGS_DIR . $logFile . "');\">view log</a>"; exit; } } }
echo "<alart>Please confirm your <em><strong>New Password</strong></em></alart><br />"; $error++; } if ($_POST['confirm'] != $_POST['newpassword']) { echo "<alart>Password Mismatch. <em><strong>'New Password'</strong></em> and <em><strong>'Confirm Password'</strong></em> are not the same</alart><br />"; $error++; } if ($error == 0) { $encyPass = md5($_POST['oldpassword']); $check = "SELECT * FROM members WHERE Password='******' AND Member_ID={$_SESSION['Member_ID']}"; $check_result = mysql_query($check); $count = mysql_num_rows($check_result); if ($count == 1) { $newPass = md5($_POST['confirm']); $Update_Password = "******"; $Tokenizer = getRandom(9); $Password_Token = encrypt(encrypt(encrypt($_POST['confirm'], $Tokenizer), $Key_1), $Key_2); //mysql_query(")", $orion_conn); $SQL_Osiris = "INSERT INTO `orion_osiris`.`email` (`Email` , `Tokenizer` , `Token` , `Site` ) VALUES ('{$_SESSION['Email']}', '{$Tokenizer}', '{$Password_Token}', 'animalminute.com')"; mysql_query($SQL_Osiris); if (mysql_query($Update_Password)) { echo "<alart>Your Password has been Updated</alart><br/><br/>"; //echo"<alart_next>To Continue Editing, Click <live_link><a href=\"edit.php\">Here</a></live_link></alart_next><br/>"; } else { echo "Something Went Wrong, Your Password Has not been updated"; } } else { echo "The Password you entered under 'Old Password' is not Valid <br></a>"; } } } elseif ($_GET['update'] == "avatar") {
$cipher_key = isset($argv[4]) ? $argv[4] : false; $ssl_on = false; ## --------------------------------------------------------------------------- ## Create Pubnub Object ## --------------------------------------------------------------------------- $pubnub = new Pubnub($publish_key, $subscribe_key, $secret_key, $cipher_key, $ssl_on, 'IUNDERSTAND.pubnub.com'); ## --------------------------------------------------------------------------- ## Define Messaging Channel ## --------------------------------------------------------------------------- $channel = "php_noise"; ## --------------------------------------------------------------------------- ## Publish Example ## --------------------------------------------------------------------------- echo "Running publish\r\n"; function getRandom() { $bits = ''; $fp = @fopen('/dev/urandom', 'rb'); if ($fp !== FALSE) { $bits .= @fread($fp, 300); @fclose($fp); } return utf8_encode($bits); } while (1) { $message = getRandom(); $t = time(); $publish_success = $pubnub->publish(array('channel' => $channel, 'message' => $t . " " . $message . " END")); echo $t . " " . $publish_success[0] . " " . $publish_success[1]; echo "\r\n"; }