本文整理汇总了PHP中create_hash函数的典型用法代码示例。如果您正苦于以下问题:PHP create_hash函数的具体用法?PHP create_hash怎么用?PHP create_hash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_hash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute($requests)
{
$tail = $GLOBALS['KTAI_URL_TAIL'];
$u = $GLOBALS['KTAI_C_MEMBER_ID'];
// --- リクエスト変数
$ktai_address = $requests['ktai_address'];
// ----------
$ktai_address = str_replace('"', '', $ktai_address);
//--- 権限チェック
//必要なし?
//---
if (!db_common_is_mailaddress($ktai_address)) {
// メールアドレスを入力してください
$p = array('msg' => 12);
openpne_redirect('ktai', 'page_h_regist_address', $p);
}
if (!is_ktai_mail_address($ktai_address)) {
// 携帯メールアドレス以外は指定できません
$p = array('msg' => 16);
openpne_redirect('ktai', 'page_h_regist_address', $p);
}
if (db_member_is_sns_join4mail_address($ktai_address)) {
// このメールアドレスはすでに登録されています
$p = array('msg' => 17);
openpne_redirect('ktai', 'page_h_regist_address', $p);
}
db_member_delete_c_member_ktai_pre4id($ktai_address);
db_member_delete_c_ktai_address_pre4ktai_address($ktai_address);
$session = create_hash();
db_member_insert_c_ktai_address_pre($u, $session, $ktai_address);
//function cache削除
cache_drop_c_member_profile($u);
do_mail_sns_change_ktai_mail_send($u, $session, $ktai_address);
openpne_redirect('ktai', 'page_o_send_mail_end');
}
示例2: forget_password_attempt
public function forget_password_attempt()
{
$email = $_POST['email'];
$this->load->model('user_model');
$user = $this->user_model->checkEmailFP($email);
if ($user) {
include OTHERS . "PasswordHash.php";
$new_password = $this->_get_random_string(10);
$salt = $this->_get_random_string(16);
$hashed_password = create_hash($new_password . $salt);
$update = array('password' => $hashed_password, 'salt' => $salt);
if ($this->user_model->updateUserFP($update, $user->id)) {
$this->load->model('email_model');
$this->email_model->forgetPasswordSendEmail($user, $new_password);
$this->session->set_flashdata("message", "<div class='alert alert-success'><i class='fa fa-check'></i> The new password is sent to your email!</div>");
header("Location: " . base_url() . 'pages/forget_password');
} else {
$this->session->set_flashdata("message", "<div class='alert alert-danger'><i class='fa fa-exclamation'></i> Generating new password failed, please try again later.</div>");
header("Location: " . base_url() . 'pages/forget_password');
}
} else {
$this->session->set_flashdata("message", "<div class='alert alert-danger'><i class='fa fa-exclamation'></i> The email you entered was not found.</div>");
header("Location: " . base_url() . 'pages/forget_password');
}
}
示例3: database_add_user
function database_add_user($username, $password, $picture, $phone)
{
global $mysqli;
// Sanitize the variables you passed in
$username = sanitize_input($username);
$password = sanitize_input($password);
// NOTE: Add another variable to be sanitized here:
$phone = sanitize_input($phone);
// Hash the password so that it is not stored in the database as plain text
$password = create_hash($password);
// Process the picture for putting it in the database
$picture = process_picture($picture);
// NOTE: modify this query to also include the newfield
// Insert the new user into the database
$q1 = "INSERT INTO users (username, password, picture, phone)";
$q2 = "VALUES ('{$username}','{$password}','{$picture}', '{$phone}')";
$q = $q1 . $q2;
$userID = 0;
if (isUsernameTaken($username) == false) {
// Add the user to the database
mysqli_query($mysqli, $q);
// Set this userID as logged in
$userID = mysqli_insert_id($mysqli);
set_user_logged_in($userID, $password);
}
return $userID;
}
示例4: create
public function create()
{
if ($_POST) {
$customer = Stripe_Customer::create(array('email' => $_POST['email']));
foreach ($_POST as $key => $value) {
$_POST[$key] = urldecode($value);
}
include OTHERS . "PasswordHash.php";
$new_password = $_POST['password'];
$salt = $this->_get_random_string(16);
$hashed_password = create_hash($new_password . $salt);
$stateSplit = explode(' - ', $_POST['state']);
$key = $this->_get_random_string(50);
$user = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'password' => $hashed_password, 'salt' => $salt, 'phone' => $_POST['phone'], 'email' => $_POST['email'], 'country' => $_POST['country'], 'state' => $stateSplit[1], 'state_abbr' => $stateSplit[0], 'confirmation_key' => $key, 'stripe_customer_id' => $customer->id);
if (isset($_POST['reg_plan_id'])) {
$user['stripe_reg_plan_id'] = $_POST['reg_plan_id'];
} else {
$this->load->model('settings_model');
$general = transformArrayToKeyValue($this->settings_model->get(array('category' => 'general')));
$this->load->model('package_model');
$package = $this->package_model->getPackage($general['trial_period_package']->v);
$user['stripe_reg_plan_id'] = $package->stripe_plan_id;
}
if ($this->user_model->add($user)) {
echo "OK";
}
} else {
$this->index();
}
}
示例5: execute
function execute($requests)
{
//<PCKTAI
if (OPENPNE_AUTH_MODE == 'slavepne' || !(OPENPNE_REGIST_FROM & OPENPNE_REGIST_FROM_PC)) {
client_redirect_login();
}
//>
$sid = $requests['sid'];
$ktai_address = $requests['ktai_address'];
$ktai_address = str_replace('"', '', $ktai_address);
if (!db_member_is_active_sid($sid)) {
$p = array('msg_code' => 'invalid_url');
openpne_redirect('pc', 'page_o_tologin', $p);
}
//携帯メールアドレスチェック
if (!db_common_is_mailaddress($ktai_address)) {
$msg = "メールアドレスを正しく入力してください";
} elseif (db_member_is_sns_join4mail_address($ktai_address)) {
$msg = "そのメールアドレスは既に登録済みです";
} elseif (!is_ktai_mail_address($ktai_address)) {
$msg = "携帯メールアドレスを入力してください";
}
if (!empty($msg)) {
$p = array('msg' => $msg, 'sid' => $sid, 'ktai_address' => $ktai_address);
openpne_redirect('pc', 'page_o_regist_ktai_address', $p);
}
$pre = db_member_c_member_pre4sid($sid);
$ktai_session = create_hash();
// c_member_pre にデータ挿入
$c_member_pre_secure = array('ktai_session' => $ktai_session, 'ktai_address' => $ktai_address);
db_member_update_c_member_pre_secure($pre['c_member_pre_id'], array_merge($pre, $c_member_pre_secure), true);
do_mail_sns_regist_ktai_id_mail_send_pre($ktai_session, $ktai_address);
openpne_redirect('pc', 'page_o_regist_ktai_address_end', array('c_member_pre_id' => $pre['c_member_pre_id']));
}
示例6: submit
public function submit()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// TODO validate data
if ($_POST['password'] !== $_POST['passwordrepeat']) {
Flash::set('error_message', 'Your passwords did not match!');
} elseif (!preg_match("#[0-9]+#", $_POST['password'])) {
// should contain at least 1 number
Flash::set('error_message', 'Your password should contain at least 1 number');
} elseif (!preg_match("#[A-Z]+#", $_POST['password'])) {
// should contain at least 1 capital letter
Flash::set('error_message', 'Your password should contain at least an uppercase letter');
} elseif (!preg_match("#[a-z]+#", $_POST['password'])) {
// should contain at least 1 lowercase letter
Flash::set('error_message', 'Your password should contain at least a lowercase letter');
} else {
// TODO submit data
Real_Estate::create(['name' => $_POST['name'], 'password' => create_hash($_POST['password']), 'address' => $_POST['address'], 'email' => $_POST['email'], 'phone' => $_POST['phone'], 'photo' => null]);
Flash::set('success_message', 'Your company account has been created!');
$this->redirect('/');
return;
}
$this->redirect('/realest/signup');
} else {
$this->send404();
}
}
示例7: protectView
/**
* add a password to protect the view
* @param string $url
* @param string $password
* @return boolean true, if password was added
* @return error message if exception catched during PDO
*/
function protectView($url, $password, $pdo)
{
require 'password_hash.php';
$hash = create_hash($password);
if (!isSaved($url)) {
try {
$stmt = $pdo->prepare("INSERT INTO note(id,content,pwdView,pwdEdit) VALUES(:url,:content,:pwdView,:pwdEdit)");
$stmt->bindValue(':url', $url, PDO::PARAM_STR);
$stmt->bindValue(':content', null);
$stmt->bindValue(':pwdView', $hash, PDO::PARAM_STR);
$stmt->bindValue(':pwdEdit', null);
$stmt->execute();
return True;
} catch (PDOException $e) {
throw $e;
}
} else {
try {
$stmt = $pdo->prepare("UPDATE note SET pwdView = :pwdView WHERE id = :url");
$stmt->bindValue(':url', $url, PDO::PARAM_STR);
$stmt->bindValue(':pwdView', $hash, PDO::PARAM_STR);
$stmt->execute();
return True;
} catch (PDOException $e) {
throw $e;
}
}
}
示例8: addUser
/**
* 新增用户
* @author JunhaoHo
*/
public function addUser()
{
if (IS_POST) {
//防止#jQuery.load()的AJAX误判,不要用IS_AJAX判断
$username = I('username', null);
//用户名
$email = I('email', null);
//邮件地址
$gender = I('gender', null);
//性别
$groupid = I('groupid', null);
//用户组id
$password = "password";
//默认密码
$salted_hash = create_hash($password);
$regtime = time();
$avatar = $gender . '_default.png';
$data = array('username' => $username, 'email' => $email, 'gender' => $gender, 'groupid' => $groupid, 'salted_hash' => $salted_hash, 'regtime' => $regtime, 'avatar' => $avatar);
$uid = D('Member')->addUser($data);
if ($uid) {
$result['code'] = self::ADD_USER_SUCCESS_CODE;
} else {
$result['code'] = self::ADD_USER_FAILED_CODE;
$error = D('Member')->getDbError();
$str = "Duplicate entry '{$username}' for key 'username'";
$error = substr($error, 0, strpos($error, "[ SQL语句 ]"));
$error = strpos($error, $str) ? '已存在相同用户名!' : $error;
$result['error'] = $error;
}
$this->ajaxReturn($result);
}
$this->display();
}
示例9: execute
function execute($requests)
{
//<PCKTAI
if (!OPENPNE_ENABLE_KTAI) {
openpne_redirect('pc', 'page_h_home');
}
//>
$u = $GLOBALS['AUTH']->uid();
// --- リクエスト変数
$ktai_address = $requests['ktai_address'];
// ----------
$ktai_address = str_replace('"', '', $ktai_address);
if (!is_ktai_mail_address($ktai_address)) {
$msg = "携帯メールアドレスを記入してください";
$p = array('msg' => $msg);
openpne_redirect('pc', 'page_h_config_ktai', $p);
}
// 登録済みメールアドレスかどうかチェックする
if (($c_member_id = db_member_c_member_id4ktai_address2($ktai_address)) && $c_member_id != $u) {
$msg = "入力されたメールアドレスは既に登録されています";
$p = array('msg' => $msg);
openpne_redirect('pc', 'page_h_config_ktai', $p);
}
db_member_delete_c_member_ktai_pre4ktai_address($ktai_address);
db_member_delete_c_ktai_address_pre4ktai_address($ktai_address);
$session = create_hash();
db_member_insert_c_ktai_address_pre($u, $session, $ktai_address);
do_mail_sns_change_ktai_mail_send($u, $session, $ktai_address);
openpne_redirect('pc', 'page_h_config_ktai_end');
}
示例10: createUserAndGetPassword
public static function createUserAndGetPassword($ps_username, $ps_password)
{
// We don't create users in external databases, we assume they're already there
// We will create a password hash that is compatible with the CaUsers authentication adapter though
// That way users could, in theory, turn off external db authentication later. The hash will not be used
// for authentication in this adapter though.
return create_hash($ps_password);
}
示例11: execute
function execute($requests)
{
//外部認証の場合はリダイレクト
check_action4pne_slave(false);
// --- リクエスト変数
$pc_address = $requests['pc_address'];
$q_id = $requests['c_password_query_id'];
$q_answer = $requests['c_password_query_answer'];
// ----------
if (OPENPNE_USE_CAPTCHA) {
@session_start();
if (empty($_SESSION['captcha_keystring']) || $_SESSION['captcha_keystring'] !== $requests['captcha']) {
unset($_SESSION['captcha_keystring']);
$p = array('msg' => "確認キーワードが誤っています");
openpne_redirect('pc', 'page_o_password_query', $p);
}
unset($_SESSION['captcha_keystring']);
}
if (!$pc_address) {
$p = array('msg' => 'メールアドレスを入力してください');
openpne_redirect('pc', 'page_o_password_query', $p);
}
if (!db_common_is_mailaddress($pc_address)) {
$p = array('msg' => 'メールアドレスの形式が正しくありません');
openpne_redirect('pc', 'page_o_password_query', $p);
}
if (IS_PASSWORD_QUERY_ANSWER) {
if (!$q_id) {
$p = array('msg' => '秘密の質問を選択してください');
openpne_redirect('pc', 'page_o_password_query', $p);
}
if (!$q_answer) {
$p = array('msg' => '秘密の質問の答えを入力してください');
openpne_redirect('pc', 'page_o_password_query', $p);
}
}
//--- 権限チェック
if (IS_PASSWORD_QUERY_ANSWER) {
$c_member_id = db_member_is_password_query_complete($pc_address, $q_id, $q_answer);
$msg = '正しい値を入力してください';
if (!$c_member_id) {
$p = array('msg' => $msg);
openpne_redirect('pc', 'page_o_password_query', $p);
}
} else {
$c_member_id = db_member_c_member_id4pc_address($pc_address);
if (!$c_member_id) {
openpne_redirect('pc', 'page_o_password_query_end');
}
}
//---
// パスワード再発行用のハッシュをDBに登録し再設定用のメールを送信
$session = create_hash();
db_member_update_c_member_config($c_member_id, 'password_reset_sid', $session);
db_member_update_c_member_config($c_member_id, 'password_reset_sid_time', time());
do_password_reset_query_mail_send($c_member_id, $pc_address, $session);
openpne_redirect('pc', 'page_o_password_query_end');
}
示例12: check_hash
function check_hash($pre_shared_key, $password) {
$str1 = $_GET["HashDigest"];
$hashcode = create_hash($pre_shared_key, $password);
if ($hashcode == $str1) {
return "HASH PASSED";
} else {
return "HASH FAILED";
}
}
示例13: registerAccount
public function registerAccount($username, $password, $email)
{
$hash = create_hash($password);
$stmt = $this->dbh->prepare('INSERT INTO accounts (username, password, email) VALUES(?, ?, ?)');
$stmt->bindParam(1, $username);
$stmt->bindParam(2, $hash);
$stmt->bindParam(3, $email);
$stmt->execute();
}
示例14: changePassword
public function changePassword()
{
include OTHERS . "PasswordHash.php";
$new_password = $_POST['newPassword'];
$this->load->library('custom_library');
$salt = $this->custom_library->get_random_string(16);
$hashed_password = create_hash($new_password . $salt);
$update = array('password' => $hashed_password, 'salt' => $salt);
$this->load->model('user_model');
echo $this->user_model->update($update, $_POST['id']);
}
示例15: db_api_update_token
function db_api_update_token($c_member_id)
{
$token = create_hash();
$data = array('token' => $token);
$where = array('c_member_id' => intval($c_member_id));
db_update('c_api_member', $data, $where);
if (!db_affected_rows()) {
db_api_insert_token($c_member_id, $token);
}
return $token;
}