本文整理汇总了PHP中random_gen函数的典型用法代码示例。如果您正苦于以下问题:PHP random_gen函数的具体用法?PHP random_gen怎么用?PHP random_gen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了random_gen函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cmpHashes
function cmpHashes($rounds)
{
$isReversible = false;
$i = 0;
while ($i < $rounds && !$isReversible) {
$i++;
$str = random_gen(32);
$output = hash('md5', $str);
if ($output == $str) {
$isReversible = true;
/* Email Settings */
$to = "elliott.kember@gmail.com";
$subject = "A reversible Hash was found!";
$body = "The reversible Hash is: " . $str;
/* Send email if revsersible hash was found */
mail($to, $subject, $body, "From:Experiment@elliottkember.com<The Kember Identity>");
}
}
return 'None of ' . $rounds . ' hashes were reversible!';
}
示例2: addVideoLecture
function addVideoLecture($name, $format, $examyear, $start, $end, $creator)
{
$conn = getConnection();
do {
$temp_url = md5($name . random_gen(10) . getCurrentInstituteID1());
$query = "SELECT * FROM video WHERE url LIKE '" . $temp_url . "'";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
if ($rows == 0) {
$tempflag = false;
} else {
$tempflag = true;
}
} while ($tempflag);
$url = $temp_url . '.' . $format;
$query = "INSERT INTO video(name ,url,examyear,activeflag ,createdby , start_date, end_date, lastupdated) VALUES('" . $name . "' ,'" . $url . "' ,'" . $examyear . "' , 1 , " . $creator . ", '" . $start . "', '" . $end . "',NOW())";
$result = mysql_query($query);
if ($result) {
$temp = array(true, mysql_insert_id());
} else {
$temp = array(false, mysql_error());
}
return $temp;
}
示例3: random_gen
<?
session_start();
$page_title = ""; // PAGE TITLE FOR THIS PAGE - IF BLANK USE DEFAULT TITLE
$meta_keywords = ""; // KEYWORD METATAGS FOR THIS PAGE - IF BLANK USE DEFAULT
$meta_description = ""; // DESCRIPTION METATAGS FOR THIS PAGE - IF BLANK USE DEFAULT
include( "database.php" );
include( "functions.php" );
include( "config_public.php" );
// VISITOR ID
if(!$_SESSION['visitor_id']){
session_register("visitor_id");
$_SESSION['visitor_id'] = random_gen(16,"");
}
//UNSET ANY IMAGE VIEWING
unset($_SESSION['pub_gid']);
unset($_SESSION['pub_pid']);
?>
<html>
<head>
<? print($head); ?>
<center>
<table cellpadding="0" cellspacing="0"><tr><td valign="top">
<table cellpadding="0" cellspacing="0" width="765" class="main_table" style="border: 5px solid #<? echo $border_color; ?>;">
<? include("header.php"); ?>
<tr>
<td class="left_nav_header"><? echo $misc_photocat; ?></td>
示例4: random_gen
$_SESSION['form_phone1'] = $_POST['phone'];
session_register("form_address11");
$_SESSION['form_address11'] = $_POST['address1'];
session_register("form_address21");
$_SESSION['form_address21'] = $_POST['address2'];
session_register("form_city1");
$_SESSION['form_city1'] = $_POST['city'];
session_register("form_state1");
$_SESSION['form_state1'] = $_POST['state'];
session_register("form_zip1");
$_SESSION['form_zip1'] = $_POST['zip'];
session_register("form_note1");
$_SESSION['form_note1'] = $_POST['note'];
$item = $_SESSION['visitor_id'];
$order_num = random_gen(10,"");
$savings = $coupon;
$member_id = $_SESSION['sub_member'];
if($_POST['type'] == "sub"){
$total = $_SESSION['ses_total'];
$grand_total = $total;
$bypass = 1;
}
if($bypass != 1){
$coupon_result = mysql_query("SELECT type,code,used FROM coupon where id = '$coupon_id'", $db);
$coupon_rows = mysql_num_rows($coupon_result);
$coupon = mysql_fetch_object($coupon_result);
if($coupon_rows > 0){
$used = $coupon->used + 1;
示例5: session_start
<?php
session_start();
require_once 'includes/login.php';
require_once 'includes/functions.php';
require_once 'includes/auth.php';
include_once 'includes/header.php';
echo "<br><br>";
$sorted_books = [];
$books = random_gen(1, 6, 5);
#multidimensional array with book information
$books = handleArticles($books);
#Handles issues with articles as first words in title. Returns an array of titles.
sort($books, SORT_NATURAL | SORT_FLAG_CASE);
#sorts the array by title of book
foreach ($books as $key => $val) {
array_push($sorted_books, $val);
}
$answer_array = array($sorted_books[1], $sorted_books[3]);
#an array of answer choices
shuffle($answer_array);
#shuffles answer choices so the are not necessarily displayed in their sorted order
echo "<br><p>In your hands:<br>" . $answer_array[0] . "<br>" . $answer_array[1] . "</p><br>";
#Gives the options for the puzzle
echo '<form action="level_two_final.php" method="post"><fieldset style="width:50%"><legend>YMI</legend>';
echo '<div style="position: relative; background: url(images/spine.png); width:500px; height: 53px; line-height:53px;"><p style="text-align: center;">' . $sorted_books[0] . '</p></div>';
echo '<div style="position: relative; background: url(images/spine.png); width:500px; height: 53px; line-height:53px;"><p style="text-align: center;">';
echo '<select name="question_one"><option value="' . $answer_array[0] . '">' . $answer_array[0] . '</option>';
echo '<option value="' . $answer_array[1] . '">' . $answer_array[1] . '</option></select></p></div>';
echo '<div style="position: relative; background: url(images/spine.png); width:500px; height: 53px; line-height:53px;"><p style="text-align: center;">' . $sorted_books[2] . '</p></div>';
echo '<div style="position: relative; background: url(images/spine.png); width:500px; height: 53px; line-height:53px;"><p style="text-align: center;">';
示例6: uploadNotes
function uploadNotes($picture)
{
$conn = getConnection();
$attachmentstring = "";
$save_path = "../includes/notes/";
$save_path1 = "includes/notes/";
$filename = basename($picture[1]);
$file_ext = substr($filename, strripos($filename, '.'));
$file_basename = substr($filename, 0, strripos($filename, '.'));
$file_name = $file_basename;
$file_basename = md5($file_basename . random_gen(10));
$file_basename = $file_basename . rand();
$filename = $file_basename . $file_ext;
$target_path = $save_path . $filename;
$url = $save_path1 . $filename;
move_uploaded_file($picture[0], $target_path);
$attachmentstring .= $url;
return $attachmentstring;
}
示例7: dbSetTempPW
function dbSetTempPW($email, &$tempPW)
{
// check to make sure the user is in the user table
$query = "SELECT resident_id FROM user WHERE user_name = '{$email}'";
if ($this->debug) {
echo "EXECUTING QUERY: {$query}<br>";
}
$result = $this->conn->query($query);
if ($this->conn->errno) {
printf("Select resident from user table failed: %s\n", $this->conn->error);
$this->errmsg = $this->conn->connect_error;
return false;
}
$row = $result->fetch_row();
$userid = $row[0];
$result->close();
// check to make sure a record was found
if ($userid == 0) {
$this->errmsg = "This user name does not exist, please try again";
return false;
}
// create a temporary password
$tempPW = random_gen(8);
if ($this->debug) {
echo "TEMPORARY PASSWORD = {$tempPW}<br>";
}
$encpw = md5($tempPW);
$query = "UPDATE user set user_password_text = '{$encpw}', " . "user_temp_password_ind = 'Y' where resident_id = '{$userid}'";
if ($this->debug) {
echo "EXECUTING QUERY: {$query}<br>";
}
$result = $this->conn->query($query);
if ($this->conn->errno) {
printf("Update user table failed: %s\n", $this->conn->error);
$this->errmsg = $this->conn->connect_error;
return false;
} else {
return true;
}
}
示例8: mysql_query
$pg_result = mysql_query("SELECT * FROM photo_galleries where id = '" . $_GET['item_id'] . "'", $db);
$pg = mysql_fetch_object($pg_result);
echo "<form name=\"data_form\" action=\"" . $actions_page . "?pmode=save_edit\" method=\"post\" ENCTYPE=\"multipart/form-data\">";
echo "<input type=\"hidden\" value=\"" . $pg->id . "\" name=\"item_id\">";
echo "<input type=\"hidden\" value=\"mgr.php?nav=" . $_GET['nav'] . "&message=saved&item_id=" . $_GET['item_id'] . "\" name=\"return\">";
}
?>
<input type="hidden" value="<? echo $reference; ?>" name="reference" readonly>
<input type="hidden" value="<? echo $file_path; ?>" name="file_path" readonly>
<input type="hidden" value="<? echo $image_path; ?>" name="image_path" readonly>
<input type="hidden" value="<? echo $_GET['lang']; ?>" name="language" readonly>
<?
if($pg->rdmcode){
$rdmcode = $pg->rdmcode;
} else {
$rdmcode = random_gen(8, "");
}
?>
<input type="hidden" value="<? echo $rdmcode; ?>" name="rdmcode">
<tr>
<td bgcolor="#3C6ABB" align="center" style="padding: 3px; border-bottom: 1px solid #355894;">
<table cellpadding="0" cellspacing="0" width="95%">
<tr>
<td nowrap><font face="arial" color="#ffffff" style="font-size: 11;"><b> <? if($item_id == "new"){ ?>ADD A NEW LISTING<? } else { ?>EDIT THIS LISTING<? } ?></b></font></td>
</tr>
</table>
</td>
</tr>
<tr>
示例9: random_gen
<?php
// A Kember Identity Hash script by George Hickman, improved upon by Alan Geleynse
function random_gen($length)
{
$characters = '0123456789abcdef';
$str = '';
for ($i = 0; $i < $length; $i++) {
$str .= substr($characters, mt_rand() % strlen($characters), 1);
}
return $str;
}
$isReversible = false;
$i = 0;
while (!$isReversible) {
$str = random_gen(32);
$i++;
if ($i == 100000) {
echo $str;
echo "\n";
$i = 0;
}
$output = hash('md5', $str);
if ($output == $str) {
$isReversible = true;
echo 'Hurrah ' . $str . ' is a reversible md5 hash. Profit!';
}
}
示例10: mysql_query
<?PHP
session_start();
$page_title = ""; // PAGE TITLE FOR THIS PAGE - IF BLANK USE DEFAULT TITLE
$meta_keywords = ""; // KEYWORD METATAGS FOR THIS PAGE - IF BLANK USE DEFAULT
$meta_description = ""; // DESCRIPTION METATAGS FOR THIS PAGE - IF BLANK USE DEFAULT
include( "database.php" );
include( "functions.php" );
include( "config_public.php" );
$photo_result = mysql_query("SELECT id FROM uploaded_images where reference = 'photo_package' and reference_id = '$pid' order by id desc", $db);
$photo = mysql_fetch_object($photo_result);
session_register("mail_id");
$_SESSION['mail_id'] = random_gen(16,"");
if($_GET['message'] == "sent"){
echo $email_photo_successfully;
exit;
} else {
echo $email_emailphoto;
?>
<form name="emailphoto" method="post" action="public_actions.php?pmode=email_photo&pid=<? echo $pid; ?>">
<? if($setting->show_watermark_thumb == 1){ ?>
<img src="thumb_mark.php?i=<? echo $photo->id; ?>" class="photo"><br>
<? } else { ?>
<img src="image.php?src=<? echo $photo->id; ?>" class="photo"><br>
<? } ?>
<input type="hidden" value="<?php echo $_SESSION['mail_id']; ?>" name="reg" />
<input type="hidden" value="<?php echo selfurl(); ?>" name="return" />
示例11: addNewBatchesForTest
function addNewBatchesForTest($testID, $batches, $creatorID)
{
$conn = getConnection();
$testObj = getTest($testID);
$type = $testObj->getType();
$indentifier = $testObj->getIndentifier();
if ($type == 0) {
// Convert to common type
$type = 1;
$indentifier = random_gen(20);
$testObj->setType($type);
$testObj->setIndentifier($indentifier);
$result = $testObj->update();
}
for ($i = 0; $i < count($batches); $i++) {
$query = "INSERT INTO `test` (`ID`, `name`, `maximum`, `topic`, `datetest`, `activeflag`, `batchID`, `subjectID`, `datecreated`, `createdby`, `lastupdated`, `type`, `indentifier`, `quiztype`, `quizmodule`, `correctmark`, `wrongmark`,`typeID`) VALUES (NULL, '" . $testObj->getName() . "', '" . $testObj->getMaximum() . "', '" . $testObj->getTopic() . "', '" . $testObj->datecreated . "', '" . $testObj->getActiveFlag() . "', '" . $batches[$i] . "', '" . $testObj->getSubjectID() . "', NOW(), '" . $creatorID . "', CURRENT_TIMESTAMP , '" . $type . "', '" . $indentifier . "', '" . $testObj->getQuizType() . "', '" . $testObj->getQuizModuleID() . "', '" . $testObj->getCorrectMark() . "', '" . $testObj->getWrongMark() . "', '" . $testObj->getTypeID() . "' )";
$result = mysql_query($query, $conn);
$newID = mysql_insert_id();
if ($testObj->getQuizType() != 0) {
addQuestionsForNewSimilarTest($testID, $newID);
}
}
}