本文整理汇总了PHP中random_key函数的典型用法代码示例。如果您正苦于以下问题:PHP random_key函数的具体用法?PHP random_key怎么用?PHP random_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了random_key函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_config_file
public static function generate_config_file($db_type, $db_host, $db_name, $db_username, $db_password, $db_prefix = '', $cookie_name = false, $cookie_seed = false)
{
if ($cookie_name === false) {
$cookie_name = 'luna_cookie_' . random_key(6, false, true);
}
if ($cookie_seed === false) {
$cookie_seed = random_key(16, false, true);
}
return '<?php' . "\n\n" . '$db_type = \'' . $db_type . "';\n" . '$db_host = \'' . $db_host . "';\n" . '$db_name = \'' . addslashes($db_name) . "';\n" . '$db_username = \'' . addslashes($db_username) . "';\n" . '$db_password = \'' . addslashes($db_password) . "';\n" . '$db_prefix = \'' . addslashes($db_prefix) . "';\n" . '$p_connect = false;' . "\n\n" . '$cookie_name = ' . "'" . $cookie_name . "';\n" . '$cookie_domain = ' . "'';\n" . '$cookie_path = ' . "'/';\n" . '$cookie_secure = 0;' . "\n" . '$cookie_seed = \'' . $cookie_seed . "';\n\ndefine('PUN', 1);\n";
}
示例2: hash_password
function hash_password($password, $salt = null)
{
$rice = "";
if (trim($salt) != "") {
$rice = trim($salt);
} else {
$rice = random_key(SALT_LEN);
}
$hash = hash("sha256", $password . $rice);
$hash .= $rice;
return $hash;
}
示例3: set_new_key
public function set_new_key()
{
//now we're going to set the random key
$this->random_key = random_key(20);
//before we can set that random key to the object
//we NEED to make sure it doesn't exist
while (Reset_Password::is_random_key_being_used($this->random_key)) {
//while this key does it exist, keep looping through and generating new
//random keys until it already exists
$this->random_key = random_key(20);
}
}
示例4: get_new_password
function get_new_password()
{
global $settings;
if ($settings['admin_username'] == $_REQUEST['user'] && $settings['admin_password'] == $_REQUEST['old_pw']) {
$new_password = random_key(8, true);
$query = array('UPDATE' => 'settings', 'SET' => 'value="' . openld_hash($new_password) . '"', 'WHERE' => 'title="admin_password"');
($hook = get_hook('admin_login_get_password_settings_sql')) ? eval($hook) : null;
$db->query_build($query);
generate_settings_cache();
echo NEW_PASSWORD . ":" . $new_password;
} else {
error("Invalid password request");
}
}
示例5: send
private function send($send_parameters)
{
global $con;
$to = $send_parameters["to"];
$from = $_SESSION["userid"];
$msg = $send_parameters["msg"];
$subj = $send_parameters["subject"];
$convoid = $send_parameters["thread"];
if (isset($to) && isset($msg) && isset($subj)) {
if (!isset($convoid)) {
$convoid = random_key(256);
}
$send_array = array("thread" => $convoid, "sender" => $from, "receiver" => $to, "subject" => $subj, "msg" => $msg, "date" => date("Y-m-d H:i:s"));
addRow($con, "msg", $send_array);
return 200;
} else {
return 401;
}
}
示例6: function
gid: <?php
echo $game_id;
?>
},
beforeSend: beforeSend || function(){}
}).done(function(res){
if (callback) {
callback(res);
}
});
}
var cipheredTerms = <?php
$output = "[";
foreach ($terms_res as $i) {
$key = random_key(max(strlen($i["term"]), strlen($i["def"])));
$term = encode($i["term"], $key);
$def = encode($i["def"], $key);
$output .= "['{$term}','{$def}','{$i['id']}','{$key}'],";
}
$output = substr($output, 0, -1);
$output .= "]";
echo $output;
?>
;
</script>
</head>
示例7: random_pass
function random_pass($len)
{
return random_key($len, true);
}
示例8: _e
?>
<span class="help-block"><?php
_e('Password and confirmation for SMTP server, only when required', 'luna');
?>
</span></label>
<div class="col-sm-9">
<div class="checkbox">
<label>
<input type="checkbox" name="form[smtp_change_pass]" id="form_smtp_change_pass" value="1" />
<?php
_e('Check this if you want to change or delete the currently stored password.', 'luna');
?>
</label>
</div>
<?php
$smtp_pass = !empty($luna_config['o_smtp_pass']) ? random_key(luna_strlen($luna_config['o_smtp_pass']), true) : '';
?>
<div class="row">
<div class="col-sm-6">
<input class="form-control" type="password" name="form[smtp_pass1]" maxlength="50" value="<?php
echo $smtp_pass;
?>
" />
</div>
<div class="col-sm-6">
<input class="form-control" type="password" name="form[smtp_pass2]" maxlength="50" value="<?php
echo $smtp_pass;
?>
" />
</div>
</div>
示例9: implode
$mail_message = 'User \'' . $forum_user['username'] . '\' changed to an e-mail address that also belongs to: ' . implode(', ', $dupe_list) . "\n\n" . 'User profile: ' . forum_link($forum_url['user'], $id) . "\n\n" . '-- ' . "\n" . 'Forum Mailer' . "\n" . '(Do not reply to this message)';
forum_mail($forum_config['o_mailing_list'], $mail_subject, $mail_message);
}
}
}
// Did everything go according to plan?
if (empty($errors)) {
if ($forum_config['o_regs_verify'] != '1') {
// We have no confirmed e-mail so we change e-mail right now
$query = array('UPDATE' => 'users', 'SET' => 'email=\'' . $forum_db->escape($new_email) . '\'', 'WHERE' => 'id=' . $id);
($hook = get_hook('pf_change_email_key_qr_update_email')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
redirect(forum_link($forum_url['profile_about'], $id), $lang_profile['E-mail updated redirect']);
}
// We have a confirmed e-mail so we going to send an activation link
$new_email_key = random_key(8, true);
// Save new e-mail and activation key
$query = array('UPDATE' => 'users', 'SET' => 'activate_string=\'' . $forum_db->escape($new_email) . '\', activate_key=\'' . $new_email_key . '\'', 'WHERE' => 'id=' . $id);
($hook = get_hook('pf_change_email_normal_qr_update_email_activation')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
// Load the "activate e-mail" template
$mail_tpl = forum_trim(file_get_contents(FORUM_ROOT . 'lang/' . $forum_user['language'] . '/mail_templates/activate_email.tpl'));
// The first row contains the subject
$first_crlf = strpos($mail_tpl, "\n");
$mail_subject = forum_trim(substr($mail_tpl, 8, $first_crlf - 8));
$mail_message = forum_trim(substr($mail_tpl, $first_crlf));
$mail_message = str_replace('<username>', $forum_user['username'], $mail_message);
$mail_message = str_replace('<base_url>', $base_url . '/', $mail_message);
$mail_message = str_replace('<activation_url>', str_replace('&', '&', forum_link($forum_url['change_email_key'], array($id, $new_email_key))), $mail_message);
$mail_message = str_replace('<board_mailer>', sprintf($lang_common['Forum mailer'], $forum_config['o_board_title']), $mail_message);
($hook = get_hook('pf_change_email_normal_pre_activation_email_sent')) ? eval($hook) : null;
示例10: user_register
private function user_register($profile, $prev_url)
{
global $forum_config, $lang_fancy_login_loginza, $forum_user, $forum_db, $forum_url;
// Load the profile language file
if (!isset($lang_profile)) {
require FORUM_ROOT . 'lang/' . $forum_user['language'] . '/profile.php';
}
// We allowed register new users?
if ($forum_config['o_regs_allow'] == '0') {
message($lang_profile['No new regs']);
}
// Check that someone from this IP didn't register a user within the last hour (DoS prevention)
$query = array('SELECT' => 'COUNT(u.id)', 'FROM' => 'users AS u', 'WHERE' => 'u.registration_ip=\'' . $forum_db->escape(get_remote_address()) . '\' AND u.registered>' . (time() - 3600));
($hook = get_hook('rg_register_qr_check_register_flood')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
if ($forum_db->result($result) > 0) {
message($lang_profile['Registration flood']);
}
// Get user info from Loginza Profile
$username = $this->get_username_for_new_user($profile);
$loginza_identity = isset($profile->identity) ? forum_trim($profile->identity) : FALSE;
$lup = new LoginzaUserProfile($profile);
$email = $lup->get_email();
if (!$username) {
message($lang_fancy_login_loginza['Error empty username']);
}
if (!$loginza_identity) {
message($lang_fancy_login_loginza['Error empty identity']);
}
// Check e-mail address
$banned_email = FALSE;
$dupe_list = array();
if ($email) {
$error = $this->check_email($email, $banned_email, $dupe_list);
if (TRUE !== $error) {
message($error);
}
}
// Clean old unverified registrators - delete older than 72 hours
$query = array('DELETE' => 'users', 'WHERE' => 'group_id=' . FORUM_UNVERIFIED . ' AND activate_key IS NOT NULL AND registered < ' . (time() - 259200));
($hook = get_hook('rg_register_qr_delete_unverified')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
($hook = get_hook('rg_register_end_validation')) ? eval($hook) : null;
// User default info
$language = $forum_config['o_default_lang'];
$password = random_key(12, TRUE);
$salt = random_key(12);
$password_hash = forum_hash($password, $salt);
$initial_group_id = $forum_config['o_regs_verify'] == '0' ? $forum_config['o_default_user_group'] : FORUM_UNVERIFIED;
// Timezone & DST
$this->get_timezone_and_dst($timezone, $dst);
// Insert the new user into the database.
// We do this now to get the last inserted id for later use.
$user_info = array('username' => $username, 'group_id' => $initial_group_id, 'salt' => $salt, 'password' => $password, 'password_hash' => $password_hash, 'email' => $email, 'email_setting' => $forum_config['o_default_email_setting'], 'timezone' => $timezone, 'dst' => $dst, 'language' => $forum_config['o_default_lang'], 'style' => $forum_config['o_default_style'], 'registered' => time(), 'registration_ip' => get_remote_address(), 'activate_key' => $forum_config['o_regs_verify'] == '1' ? '\'' . random_key(8, TRUE) . '\'' : 'NULL', 'require_verification' => $forum_config['o_regs_verify'] == '1', 'notify_admins' => $forum_config['o_regs_report'] == '1', 'loginza_profile' => $profile, 'loginza_return_url' => $prev_url, 'loginza_banned_email' => $banned_email, 'loginza_dupe_list' => $dupe_list);
($hook = get_hook('rg_register_pre_add_user')) ? eval($hook) : null;
// If we dont have email — save userdata to session and show form
if (!$email) {
if (!isset($_SESSION)) {
session_start();
}
$session_id = 'fancy_login_loginza_' . random_key(12, TRUE, TRUE);
$_SESSION[$session_id] = $user_info;
$this->form_end_reg($session_id);
} else {
if ($forum_config['o_regs_verify'] == '1' && $forum_config['o_fancy_login_loginza_trust_openid_emails'] == '1') {
// Skip activate email from OpenID
$user_info['activate_key'] = 'NULL';
$user_info['require_verification'] = FALSE;
$user_info['group_id'] = $forum_config['o_default_user_group'];
}
$this->register($user_info);
}
}
示例11: send_password
function send_password()
{
// Variable errors
$errors = array();
$sended = false;
// Load the modules
$this->load->library('email');
$this->load->helper('email');
// Type text or html emails
$config['mailtype'] = 'html';
$this->email->initialize($config);
if (!isset($_POST['universe'])) {
$errors[] = $this->lang->line('error_universe');
}
if (!isset($_POST['email']) or !valid_email($_POST['email'])) {
$errors[] = $this->lang->line('error_email2');
}
if (!in_array($_POST['universe'], $this->config->item('uni_array'))) {
$errors[] = $this->lang->line('error_world');
}
if (count($errors) == 0) {
$user_query = $this->db->get_where($_POST['universe'] . '_users', array('email' => $_POST['email']));
if ($user_query->num_rows == 0) {
$errors[] = $this->lang->line('error_email3');
} else {
$user = $user_query->row();
$password = $key = random_key(8);
$this->db->set('password', md5($password));
$this->db->where(array('id' => $user->id));
$this->db->update($_POST['universe'] . '_users');
// Send an email
$message = '
<html>
<body>
<p>' . $this->lang->line('register_email_text_1') . ' ' . $user->login . ',<br>
<br>' . $this->lang->line('password_email_text_1') . ' (' . $_POST['universe'] . '):<br>
<br>' . $password . '<br>
<br>' . $this->lang->line('password_email_text_2') . ' <a href="' . $this->config->item('base_url') . '" target="_blank">' . $this->config->item('base_url') . '</a><br>
<br>' . $this->lang->line('register_email_text_6') . ',<br>' . $this->lang->line('register_email_text_7') . '</p>
</body>
</html>';
$this->email->from($this->config->item('email_from'), 'ZZJHONS');
$this->email->to($_POST['email']);
$this->email->subject($this->lang->line('password_email_text_1') . '!');
$this->email->message($message);
$this->email->send();
$sended = true;
}
}
$this->session->set_flashdata(array('errors' => $errors));
$this->session->set_flashdata(array('sended' => $sended));
$this->load->view('main_index_4', array('page' => 'password', 'errors' => $errors, 'sended' => $sended));
}
示例12: mktime
}
</script>
<?php
include "../../include/config.php";
include "../../include/db.php";
include "../../include/poa_rca.php";
include "../../include/mail_helper.php";
include "../../include/mail.php";
include "../../include/css/default.css";
$authenticated = $_REQUEST['authenticated'];
$ticket_id = $_REQUEST['ticket_id'];
$request_date = mktime();
$requested_by = $_REQUEST['requested_by'];
$approval_by = $_REQUEST["approver"];
$approval_key = random_key();
$base_url = "http://";
if ($HTTPS == 1) {
$base_url = "https://";
}
$base_url .= $_SERVER["SERVER_NAME"] . "/" . $INSTALL_HOME . "eztickets/scp";
if ($authenticated == 1) {
$sql = "insert into isost_ticket_approval (ticket_id,request_date,requested_by,approval_status,approval_by,approval_date,approval_comments,approval_key)";
$sql .= " values('{$ticket_id}','{$request_date}','{$requested_by}','PENDING','{$approval_by}','','','{$approval_key}')";
$result = mysql_query($sql);
$sql = "update isost_ticket set pending_approval=1 where ticket_id='{$ticket_id}'";
$result = mysql_query($sql);
$title = "Ticket Pending Approval";
$note = "Ticket is pending external approval from " . $approval_name . " requested by " . $requested_by;
$sql = "insert into isost_ticket_note(ticket_id,staff_id,source,title,note,created)";
$sql .= " values('{$ticket_id}','0','system','{$title}','{$note}',NOW())";
示例13: save
public function save()
{
// Security stuffs
$this->Security_model->log('election creation', 3);
// None of these fields must be empty. If it occurs, there is an IHM problem and the procedure
// should be aborted.
$profile = array('election' => array('admin_name' => '', 'admin_surname' => '', 'admin_email' => '', 'admin_password' => '', 'business' => '', 'winners' => '', 'title' => '', 'page' => '', 'start' => '', 'end' => ''), 'candidates' => array(), 'electors' => array());
// No need to specify 'true' in the second argument as it is also configured in the config file,
// but as it is a very important verification, it's better to force it here...
$data = $this->input->post(null, true);
$keys = array_keys($profile['election']);
foreach ($data as $key => $value) {
if ($key == 'start' or $key == 'end') {
//$dt = DateTime::createFromFormat( 'd/m/Y', $value );
$dt = DateTime::createFromFormat('Y/m/d H:i', $value);
if ($dt) {
$profile['election'][$key] = $dt->format(DateTime::ISO8601);
} else {
die('Date error.');
}
} elseif ($key == 'page') {
$profile['election']['page'] = $value;
// the same as below, without strip_tags()
} elseif (in_array($key, $keys)) {
$profile['election'][$key] = strip_tags($value);
} elseif (substr($key, 0, 9) == 'candidate') {
$profile['candidates'][] = strip_tags($value);
} elseif (in_array(substr($key, 0, 4), array('name', 'surn', 'emai'))) {
$col = preg_replace('/[0-9]/s', '', $key);
$row = preg_replace('/[^0-9]/s', '', $key);
$profile['electors'][$row][$col] = strip_tags($value);
} elseif (substr($key, 0, 5) == 'valid') {
// We have to ignore explicitly this field, otherwise we trigger
// an 'unexpected data' error (see bellow)
} else {
die_error('unexpected data.');
}
}
// Adding public user ID
//
// $key_list is used to prevent the generation of two identical keys.
//
$key_list = array();
foreach ($profile['electors'] as &$e) {
$key = random_key();
while (in_array($key, $key_list)) {
$key = random_key();
}
$key_list[] = $key;
$e['public_id'] = $key;
}
// post treatment validation
foreach ($profile as $value) {
if ($value == '' or is_array($value) && count($value) == 0) {
die_error('missing data.');
}
}
// generate a password for the admin
// It will be sent to the admin with its confirmation mail.
// In the database, only the md5 is saved for security reasons.
$password = random_key();
$profile['election']['admin_password'] = md5($password);
// Ok, so let's record it
$this->load->model('Election_model');
$this->load->model('Candidate_model');
$this->load->model('Elector_model');
$fk = $this->Election_model->save($profile['election']);
$this->Candidate_model->save($profile['candidates'], $fk);
$this->Elector_model->save($profile['electors'], $fk);
// warn the admin
$this->lang->load('el_mail');
$response = sendmail(array('subject' => 'Congratulations ! Elections are on rails now', 'message' => $this->load->view('email/creation', array('data' => $profile['election'], 'password' => $password), true), 'toName' => $profile['election']['admin_name'] . ' ' . $profile['election']['admin_surname'], 'toEmail' => $profile['election']['admin_email']));
if ($response !== true) {
die_error($response);
}
// warn the electors
foreach ($profile['electors'] as $elector) {
$mail = array('subject' => $profile['election']['title'], 'message' => $this->load->view('email/invitation', array('message' => $profile['election']['page'], 'public_id' => $elector['public_id'], 'start' => $profile['election']['start'], 'end' => $profile['election']['end']), true), 'fromName' => 'Election Libre', 'fromEmail' => $profile['election']['admin_email'], 'fromBusiness' => $profile['election']['business'], 'toName' => $elector['name'] . ' ' . $elector['surname'], 'toEmail' => $elector['email']);
$response = sendmail($mail);
if ($response !== true) {
die_error($response);
}
}
die(lang('manage_success'));
}
示例14: random_key
?>
</span>
</td>
</tr>
<tr>
<th scope="row"><?php
echo $lang_admin_options['SMTP password label'];
?>
</th>
<td>
<label><input type="checkbox" name="form_smtp_change_pass" value="1" /> <?php
echo $lang_admin_options['SMTP change password help'];
?>
</label>
<?php
$smtp_pass = !empty($feather_config['o_smtp_pass']) ? random_key(feather_strlen($feather_config['o_smtp_pass']), true) : '';
?>
<input type="password" name="form_smtp_pass1" size="25" maxlength="50" value="<?php
echo $smtp_pass;
?>
" />
<input type="password" name="form_smtp_pass2" size="25" maxlength="50" value="<?php
echo $smtp_pass;
?>
" />
<span><?php
echo $lang_admin_options['SMTP password help'];
?>
</span>
</td>
</tr>
示例15: trim
* Last Updated: 6/5/2014
* Signature: Tyler Nickerson
* Copyright 2014 eDart
*
* [Do not remove this header. One MUST be included at the start of every page/script]
*
*/
include_once $_SERVER["DOC_ROOT"] . "/scripts/php/core.php";
//Include core functionality
$complete = false;
//Boolean denoting whether the form has been submitted
//If the form has been submitted...
if (isset($_POST["forgotbox"])) {
$to = trim($_POST["forgotbox"]);
//Get the email address to send it to
$rand = random_key(64);
//Get a random password to reset to
$fname = "eDart";
//Default user first name
$lname = "User";
//Default user last name
$found = false;
//Boolean as to whether this user exists
//Connect to MySQL
$con = mysqli_connect(host(), username(), password(), mainDb());
//Try to find the user by email (not possible via the API)
$que = mysqli_query($con, "SELECT * FROM `usr` WHERE `email`='" . mysqli_real_escape_string($con, $to) . "'");
//Loop through the results
while ($row = mysqli_fetch_array($que)) {
//If we found them...
$fname = $row["fname"];