function getusername($tmp_username) { global $db, $db_prefix; $sql = "select * from {$db_prefix}users where username='******' "; $result = $db->get_one($sql); if (!empty($result)) { $name = getrand(); getusername($name); } else { return $tmp_username; } }
if (g("passReg", "") != g("repassReg", "")) { panic("Some var is emtpy or pass != repass after javascript test"); } if (strlen($password) < 5) { panic("Pass is shorter than 5 chars after javascript test"); } $r = redisLink(); if ($r->get("username:{$username}:id")) { panic("Username already in use"); } # Everything is ok, Register the user! $userid = $r->incr("global:nextUserId"); $r->set("username:{$username}:id", $userid); $r->set("uid:{$userid}:username", $username); $r->set("uid:{$userid}:hashpass", bcrypt_hash($password)); $r->set("uid:{$userid}:email", $email); $r->set("uid:{$userid}:regtime", time()); $r->set("uid:{$userid}:excludemyvisits", '0'); $authsecret = getrand(); $r->set("uid:{$userid}:auth", $authsecret); $r->set("auth:{$authsecret}", $userid); # Manage a Set with all the users, may be userful in the future $r->sadd("global:users", $userid); # User registered! Login this guy $now = time() + 3600 * 24 * 365; setCookie("secret", $authsecret, $now, "/"); setCookie("secret", $authsecret, $now, "/", Config("domain")); setCookie("secret", $authsecret, $now, "/", "." . Config("domain")); # Send the email sendMail("welcome.txt", Config("emailreg"), $email, "%password%", $password, "%username%", $username); header("Location: /success.html.php");
function flashhtml_enqueue() { global $setctl, $phpenv, $u_cookieid, $u_id, $cfg; kprintheader('', 0, 'createPlayer();'); $playlist = $setctl->get('streamurl') . $phpenv['streamlocation']; $playlist .= '?templist=' . $u_id . '&c=' . $u_cookieid . '&file=' . lzero(getrand(1, 999999), 6) . '.xml'; $playlist = urlencode($playlist); $width = $cfg['jw_window_x'] - 20; $height = $cfg['jw_window_y'] - 20; $imgheight = round($height / 2); $link = $cfg['jw_urls']['swf']; ?> <script type="text/javascript" src="<?php echo $cfg['jw_urls']['js']; ?> "></script> <script type="text/javascript"> <!-- var xmlhttp; var xmlDoc; function loadXMLDoc(theFile) { xmlhttp=null; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp != null) { xmlhttp.onreadystatechange = loaded; xmlhttp.open("GET",theFile,true); xmlhttp.send(null); } else { alert('Sorry, your browser can\'t handle this script'); return; } } function checkReadyState(obj) { if(obj.readyState == 4) { if(obj.status == 200) { return true; } else { alert("Problem retrieving XML data"); } } } function loaded() { if(checkReadyState(xmlhttp)) { xmlDoc=xmlhttp.responseXML.documentElement; showTags('track'); } } function showTags(theTag) { function getTag(tag) { var tmp=''; xx=x[i].getElementsByTagName(tag); try { tmp=xx[0].firstChild.data; } catch(er) { tmp=''; } return(tmp); } var xx; var x; var txt; x = xmlDoc.getElementsByTagName(theTag); for (i=0; i<x.length; i++) { addItem('mpl',{file: decodeURIComponent(getTag("location")), image: decodeURIComponent(getTag("image")), title: getTag("title"), author: getTag("creator")}); } } function createPlayer() { var s1 = new SWFObject('<?php echo $link; ?> ','mpl','<?php echo $width; ?> ','<?php echo $height; ?> ','8'); s1.addParam("allowfullscreen", "true"); s1.addParam('allowscriptaccess','always'); s1.addVariable('height',<?php echo $height; ?> ); s1.addVariable('width',<?php echo $width; ?> ); s1.addVariable('displayheight',<?php echo $imgheight; ?> ); s1.addVariable("enablejs", "true"); s1.addVariable("javascriptid", "kPlayer"); s1.addVariable('searchbar','false'); s1.addVariable('autostart','true'); s1.addVariable('repeat','list'); s1.addVariable('shuffle','false'); s1.addVariable('file','<?php echo $playlist; ?> '); s1.write('player1'); } function thisMovie(swf) { if(navigator.appName.indexOf("Microsoft") != -1) { return window[swf]; } else { return document[swf]; } } function loadFile(swf,obj) { thisMovie(swf).loadFile(obj); } function addItem(swf, obj, idx) { thisMovie(swf).addItem(obj, idx); } --> </script> <p id="player1"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p> <?php kprintend(); }
<?php include "retwis.php"; if (!isLoggedIn()) { header("Location: index.php"); exit; } $r = redisLink(); $newauthsecret = getrand(); $userid = $User['id']; $oldauthsecret = $r->hget("user:{$userid}", "auth"); $r->hset("user:{$userid}", "auth", $newauthsecret); $r->hset("auths", $newauthsecret, $userid); $r->hdel("auths", $oldauthsecret); header("Location: index.php");
function do_a_run($count, &$error_rate) { // generate the +1 / -1 dividing line from 2 random points $p1x = getrand(); $p1y = getrand(); $p2x = getrand(); $p2y = getrand(); $slope = ($p2y - $p1y) / ($p2x - $p1x); $intercept = $p1y - $slope * $p1x; // initial the weight array $w = array(0, 0, 0); // build the sample data point array $data = array(); for ($i = 0; $i < $count; $i++) { $data[$i] = array(); // element 0 is always 1 $data[$i][0] = 1; $x1 = getrand(); $real_y = getrand(); $calc_y = $slope * $x1 + $intercept; if ($real_y > $calc_y) { $result = 1; } else { $result = -1; } // stuff the values of the X1, X2 (real_y) and the +1/-1 result $data[$i][1] = $x1; $data[$i][2] = $real_y; $data[$i][3] = $result; } // At first, I was too lazy to add code to pick random mislocated points. // just started at element 0 and and looked for the first missed point for ($loop = 0; $loop < 30000; $loop++) { for ($i = 0; $i < $count; $i++) { $real_result = $data[$i][3]; // calculate our predicted result $calc_result = 0; for ($j = 0; $j <= 2; $j++) { $calc_result += $w[$j] * $data[$i][$j]; } // if we didn't match sign, adjust weight and start over if (sign($calc_result) != $real_result) { for ($j = 0; $j <= 2; $j++) { $w[$j] += $real_result * $data[$i][$j]; } break; } } // if we got all the way through without finding a mismatch, then we are done if ($i == $count) { break; } } //echo "iterations to converge $loop\n"; // TRY RANDOM POINTS. SEE how we agree $test_count = 10000; $error_count = 0; for ($num = 0; $num < $test_count; $num++) { // new random point $x1 = getrand(); $real_y = getrand(); $calc_y = $slope * $x1 + $intercept; if ($real_y > $calc_y) { $result = 1; } else { $result = -1; } $calc_result = $w[0] + $x1 * $w[1] + $real_y * $w[2]; $sign_calc_result = sign($calc_result); if ($sign_calc_result != $result) { $error_count++; } } $error_rate = $error_count / $test_count; //echo "ERROR RATE $error_rate\n"; return $loop; }
/** * setGameId * sets a new unique gameid * @param userid * @return gameid **/ function setGameId($uid) { $redis = new Predis\Client(); $game_id = getrand(); $redis->set("uid:{$uid}:gameid", $game_id); //set this game as the latest $redis->set("uid:{$uid}:latest", $game_id); return $game_id; }
<?php function getrand() { $str = null; $strl = "QWERTYUIOPASDFGHJKLZXCVBNM123456789qwertyuiopasdfghjklzxcvbnm"; $max = strlen($strl) - 1; for ($i = 0; $i <= 15; $i++) { $str .= $strl[rand(0, $max)]; } return $str; } $dblink = mysql_connect("localhost", "root", "") or die("you lose"); mysql_select_db("talk"); for ($i = 1; $i <= 200; $i++) { $binggan = getrand(); $send = "insert into cookie(binggan)\n\t VALUES('{$binggan}')"; $rs = mysql_query($send); if ($rs) { echo "ok"; } else { echo "false"; } } mysql_close($dblink);