当前位置: 首页>>代码示例>>PHP>>正文


PHP encrypt_password函数代码示例

本文整理汇总了PHP中encrypt_password函数的典型用法代码示例。如果您正苦于以下问题:PHP encrypt_password函数的具体用法?PHP encrypt_password怎么用?PHP encrypt_password使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了encrypt_password函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login_authenticate

 function login_authenticate()
 {
     $username = $this->input->post('username');
     $password = $this->input->post('password');
     $uri_segment = $this->input->post('uri_segment');
     log_message('error', __METHOD__);
     $result = $this->login_model->login_authenticate($username, encrypt_password($password), $uri_segment);
     if (count($result) > 0 && $result['id'] != '') {
         $this->session->set_userdata('user_id', $result['id']);
         $this->session->set_userdata('user_email', $result['email']);
         $this->session->set_userdata('username', $result['username']);
         $this->session->set_userdata('role_id', $result['role_id']);
         $this->session->set_userdata('link', base_url() . $uri_segment . '/');
         $status = 'y';
         $login_session = array('session_id' => $this->session->userdata('session_id'), 'login_ip' => $this->input->ip_address(), 'login_time' => current_timestamp_database(), 'login_client' => $this->input->user_agent(), 'user_id' => $result['id']);
         $this->login_model->session_details($login_session);
         $remember_me = $this->input->post('remember_me') ? TRUE : FALSE;
         if ($remember_me) {
             // set sess_expire_on_close to 0 or FALSE when remember me is checked.
             log_message('error', __METHOD__ . 'remember me called status' . $remember_me);
             $this->session->sess_expire_on_close = 'false';
         }
     } else {
         $status = 'n';
     }
     echo json_encode(array('status' => $status, 'uri_segment' => $uri_segment));
 }
开发者ID:nandumayani,项目名称:jewelstreet2,代码行数:27,代码来源:login.php

示例2: login

function login($username, $password)
{
    global $pdo;
    if (isset($_SESSION['userid']) && $username == $_SESSION['userid']) {
        return TRUE;
    }
    if ($pdo == null) {
        open_database();
    }
    $stmt = $pdo->prepare("SELECT * FROM users WHERE login=?");
    if (!$stmt->execute(array($username))) {
        die('Invalid query : [' . error_database() . ']' . $pdo->errorInfo());
    }
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $stmt->closeCursor();
    if (!isset($row['salt'])) {
        return FALSE;
    }
    $digest = encrypt_password($password, $row['salt']);
    if ($digest == $row['crypted_password']) {
        $_SESSION['userid'] = $row['id'];
        $_SESSION['username'] = $row['name'];
        $_SESSION['useraccess'] = $row['access_level'];
        $_SESSION['userpageaccess'] = $row['page_access_level'];
        return TRUE;
    } else {
        return FALSE;
    }
}
开发者ID:haiyangzhang798,项目名称:pecan,代码行数:29,代码来源:common.php

示例3: save

 /**
  * Save the new password
  *
  * @access public
  */
 public function save()
 {
     //load model
     $this->load->model('account_model');
     //get the post data
     $current_password = trim($this->input->post('password_current'));
     $new_password = trim($this->input->post('password_new'));
     $confirmation_password = trim($this->input->post('password_confirmation'));
     //validate the current password and the new password
     if (empty($current_password) || strlen($current_password) < config('ACCOUNT_PASSWORD')) {
         $this->message_stack->add('account_password', sprintf(lang('field_customer_password_current_error'), config('ACCOUNT_PASSWORD')));
     } elseif (empty($new_password) || strlen($new_password) < config('ACCOUNT_PASSWORD')) {
         $this->message_stack->add('account_password', sprintf(lang('field_customer_password_new_error'), config('ACCOUNT_PASSWORD')));
     } elseif (empty($confirmation_password) || $new_password != $confirmation_password) {
         $this->message_stack->add('account_password', lang('field_customer_password_new_mismatch_with_confirmation_error'));
     }
     //if the validation is successful, update the password
     if ($this->message_stack->size('account_password') === 0) {
         if ($this->account_model->check_account($this->customer->get_email_address(), $current_password)) {
             $data['customers_password'] = encrypt_password($new_password);
             if ($this->account_model->save($data, $this->customer->get_id())) {
                 $this->message_stack->add_session('account', lang('success_password_updated'), 'success');
                 redirect(site_url('account'));
             } else {
                 $this->message_stack->add('account_password', lang('error_database'));
             }
         }
     }
     //Setup view
     $this->template->build('account/account_password');
 }
开发者ID:colonia,项目名称:tomatocart-v2,代码行数:36,代码来源:password.php

示例4: new_user

function new_user($firstName, $lastName, $email, $password, $userType)
{
    $salt = generate_salt();
    $encPassword = encrypt_password($password, $salt);
    $user = create_user_object($firstName, $lastName, $email, $encPassword, $salt, $userType);
    save_user_object($user);
    return $user;
}
开发者ID:JXHZY,项目名称:webDeveloper,代码行数:8,代码来源:data_service.php

示例5: create_user_account

function create_user_account($username, $password)
{
    $conn = get_conn();
    $username = mysql_fix_string($conn, $username);
    $password = mysql_fix_string($conn, $password);
    $password = encrypt_password($password);
    $query = "insert into ajx_org_users values('{$username}', '{$password}', null)";
    get_result($conn, $query);
    $conn->close();
}
开发者ID:alexanderpugh,项目名称:Ajax-Organiser,代码行数:10,代码来源:sql-functions.php

示例6: save

 public function save($id = false)
 {
     if ($this->perm->can_create == 'y') {
         if ($_POST) {
             $data = new User($id);
             //	ตรวจสอบชื่อ username ซ้ำ
             if (@$_POST["username"]) {
                 $chk = new User();
                 if ($id) {
                     $chk->where("id !=", $id);
                 }
                 $chk->where("username", strip_tags(trim($_POST["username"])))->get();
                 if ($chk->id) {
                     redirect("admin/settings/users");
                 }
             }
             //	ตรวจสอบชื่อ email ซ้ำ
             if (@$_POST["email"]) {
                 $chk = new User();
                 if ($id) {
                     $chk->where("id !=", $id);
                 }
                 $chk->where("email", strip_tags(trim($_POST["email"])))->get();
                 if ($chk->id) {
                     //	redirect("admin/settings/users");
                 }
             }
             //	Username
             //	$data->username = strip_tags(trim($_POST["username"]));
             if (!empty($_POST["password"])) {
                 $data->password = encrypt_password(strip_tags(trim($_POST["password"])));
             }
             $data->titulation = strip_tags($_POST["titulation"]);
             $data->firstname = strip_tags($_POST["firstname"]);
             $data->lastname = strip_tags($_POST["lastname"]);
             $data->email = strip_tags($_POST["email"]);
             $data->tel = strip_tags($_POST["tel"]);
             $data->org_id = $_POST['org_id'];
             $data->position = strip_tags($_POST['position']);
             $data->user_type_id = $_POST['user_type_id'];
             $data->username = strip_tags($_POST['username']);
             $data->status = !empty($_POST['status']) ? '1' : '0';
             if ($_POST['id'] == '') {
                 $data->created_by = $this->current_user->id;
             } else {
                 $data->updated_by = $this->current_user->id;
             }
             $data->save();
             $action = $_POST['id'] > 0 ? 'UPDATE' : 'CREATE';
             save_logs($this->menu_id, $action, @$data->id, $action . ' ' . $data->firstname . ' ' . $data->lastname . ' User Detail');
         }
     }
     redirect("admin/settings/users");
 }
开发者ID:ultraauchz,项目名称:conference,代码行数:54,代码来源:users.php

示例7: verify_account

function verify_account($dirty_username, $dirty_password, $dirty_activation_code)
{
    $username = escape($dirty_username);
    $password = escape($dirty_password);
    $code = escape($dirty_activation_code);
    $validateUsrMsg = validate_username($username);
    if ($validateUsrMsg != "valid-username") {
        return;
    }
    $validatePwdMsg = validate_password($password);
    if ($validatePwdMsg != "valid-password") {
        return;
    }
    $account_id = account_id_from_code($code);
    $sql1 = "SELECT * FROM account_signup WHERE code='{$code}'";
    $result = query($sql1);
    if (mysqli_num_rows($result) == 1) {
        $row = mysqli_fetch_assoc($result);
        $date_requested = $row["date_requested"];
        $expires = $date_requested + 86400;
        if (time() > $expires) {
            echo "validation-expired";
            return;
        }
        $encrypted_password = encrypt_password($password);
        $sql2 = "UPDATE account_head SET status='logged-out' WHERE account={$account_id};";
        query($sql2);
        if (user_has_status($account_id, 'logged-out') == false) {
            echo 'verify-error';
            return;
        }
        $sql3 = "INSERT INTO account_credentials (account, username, password)";
        $sql3 .= " VALUES ({$account_id}, '{$username}', '{$encrypted_password}');";
        query($sql3);
        if (user_has_credentials($account_id, $username, $encrypted_password) == false) {
            echo 'verify-error';
            return;
        }
        $sql4 = "DELETE FROM account_signup WHERE account={$account_id};";
        query($sql4);
        if (user_has_signup_pending($account_id)) {
            echo 'verify-error';
            return;
        }
        echo "verify-success";
        return;
    }
    echo 'verify-error';
}
开发者ID:andrewdownie,项目名称:projectportfolio.io,代码行数:49,代码来源:verify_account.php

示例8: login

 function login($username, $password)
 {
     $CI =& get_instance();
     $foo = new User();
     //echo $password;
     //echo encrypt_password($password);
     $foo->where("username", $username)->where("password", encrypt_password($password))->where("status", 1)->get(1);
     if ($foo->id) {
         $CI->session->set_userdata("id", $foo->id);
         $CI->session->set_userdata("user_type_id", $foo->user_type_id);
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:ultraauchz,项目名称:asean_cultural_mapping,代码行数:15,代码来源:authen_helper.php

示例9: auto_create_user

 function auto_create_user($login)
 {
     if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) {
         $user_id = $this->find_user_by_login($login);
         if (!$user_id) {
             $login = db_escape_string($login);
             $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
             $pwd_hash = encrypt_password($password, $salt, true);
             $query = "INSERT INTO ttrss_users\n\t\t\t\t\t\t(login,access_level,last_login,created,pwd_hash,salt)\n\t\t\t\t\t\tVALUES ('{$login}', 0, null, NOW(), '{$pwd_hash}','{$salt}')";
             db_query($this->link, $query);
             return $this->find_user_by_login($login);
         } else {
             return $user_id;
         }
     }
     return $this->find_user_by_login($login);
 }
开发者ID:bohoo,项目名称:tiny_tiny_rss-openshift-quickstart-1,代码行数:17,代码来源:base.php

示例10: changepassword

 function changepassword()
 {
     $old_pw = $_POST["old_password"];
     $new_pw = $_POST["new_password"];
     $con_pw = $_POST["confirm_password"];
     if ($old_pw == "") {
         print "ERROR: " . __("Old password cannot be blank.");
         return;
     }
     if ($new_pw == "") {
         print "ERROR: " . __("New password cannot be blank.");
         return;
     }
     if ($new_pw != $con_pw) {
         print "ERROR: " . __("Entered passwords do not match.");
         return;
     }
     $result = db_query($this->link, "SELECT salt FROM ttrss_users WHERE\n\t\t\tid = " . $_SESSION['uid']);
     $salt = db_fetch_result($result, 0, "salt");
     if (!$salt) {
         $old_pw_hash1 = encrypt_password($old_pw);
         $old_pw_hash2 = encrypt_password($old_pw, $_SESSION["name"]);
         $query = "SELECT id FROM ttrss_users WHERE\n\t\t\t\tid = " . $_SESSION['uid'] . " AND (pwd_hash = '{$old_pw_hash1}' OR\n\t\t\t\tpwd_hash = '{$old_pw_hash2}')";
     } else {
         $old_pw_hash = encrypt_password($old_pw, $salt, true);
         $query = "SELECT id FROM ttrss_users WHERE\n\t\t\t\tid = " . $_SESSION['uid'] . " AND pwd_hash = '{$old_pw_hash}'";
     }
     $result = db_query($this->link, $query);
     if (db_num_rows($result) == 1) {
         $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
         $new_pw_hash = encrypt_password($new_pw, $new_salt, true);
         db_query($this->link, "UPDATE ttrss_users SET\n\t\t\t\tpwd_hash = '{$new_pw_hash}', salt = '{$new_salt}'\n\t\t\t\t\tWHERE id = " . $_SESSION['uid']);
         $_SESSION["pwd_hash"] = $new_pw_hash;
         print __("Password has been changed.");
     } else {
         print "ERROR: " . __('Old password is incorrect.');
     }
 }
开发者ID:4iji,项目名称:Tiny-Tiny-RSS,代码行数:38,代码来源:pref_prefs.php

示例11: __construct

 function __construct()
 {
     //encryption
     require_once "encryption.php";
     if (isset($_GET['logout']) && $_GET['logout']) {
         $_SESSION['logged'] = FALSE;
         session_destroy();
     }
     $data['invalidEmailPass'] = "<br />";
     //Authentication logic
     if (isset($_POST['login'])) {
         //store form email and pass
         $email = $_POST['email'];
         $enc_password = encrypt_password($_POST['password']);
         $usersObj = new Users_model();
         if ($usersObj->login($email, $enc_password)) {
             $_SESSION['logged'] = TRUE;
             $_SESSION['email'] = $email;
             // $_SESSION['name'] = 'Alin';
             header('Location: http://188.166.119.187/workspace/ilear/MVC/part4/index.php?page=admin');
         } else {
             $data['invalidEmailPass'] = "Invalid email and/or password!";
         }
     }
     // $data['condition'] = (isset($_SESSION['logged']) && $_SESSION['logged'] ===  TRUE);
     // $data['logged'] = "You are logged in!";
     // // $data['unlogged'] = "";
     $data['logged'] = isset($_SESSION['logged']) && $_SESSION['logged'] === TRUE ? "You are logged in!" : "";
     // $data['logged'] = "You are logged in!";
     $data['title'] = "LoginPage";
     // $data['mailSent'] = "Note that only phone number is optional!";
     $this->render('views/top.php', $data);
     $this->render('views/menu.php', $data);
     $this->render('views/login.php', $data);
     $this->render('views/bottom.php', $data);
 }
开发者ID:rai1,项目名称:my-work,代码行数:36,代码来源:login.php

示例12: while

Phone No,
Comments
*/
$cur = config::get_config_item("currency");
$row = 1;
if (($handle = fopen("../../David_People.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        foreach ($data as $key => $val) {
            #  $data[$key] = utf8_encode($data[$key]);
        }
        $person = new person();
        $person->currency = $cur;
        $person->set_value("username", $data[0]);
        $person->set_value("firstName", $data[1]);
        $person->set_value("surname", $data[2]);
        $person->set_value("password", encrypt_password($data[3]));
        $person->set_value("emailAddress", $data[4]);
        $person->set_value("phoneNo1", $data[5]);
        $person->set_value("comments", $data[6]);
        $person->set_value("perms", "employee");
        $person->set_value("personActive", 1);
        $person->set_value("personModifiedUser", $current_user->get_id());
        $person->save();
        $x++;
        echo "<br>here: " . $person->get_id() . $data[0];
        if ($x > 4) {
            //die();
        }
    }
    fclose($handle);
}
开发者ID:cjbayliss,项目名称:alloc,代码行数:31,代码来源:csv_people.php

示例13: resetUserPassword

 static function resetUserPassword($uid, $show_password)
 {
     $result = db_query("SELECT login,email\n\t\t\t\tFROM ttrss_users WHERE id = '{$uid}'");
     $login = db_fetch_result($result, 0, "login");
     $email = db_fetch_result($result, 0, "email");
     $salt = db_fetch_result($result, 0, "salt");
     $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
     $tmp_user_pwd = make_password(8);
     $pwd_hash = encrypt_password($tmp_user_pwd, $new_salt, true);
     db_query("UPDATE ttrss_users SET pwd_hash = '{$pwd_hash}', salt = '{$new_salt}', otp_enabled = false\n\t\t\t\tWHERE id = '{$uid}'");
     if ($show_password) {
         print T_sprintf("Changed password of user <b>%s</b> to <b>%s</b>", $login, $tmp_user_pwd);
     } else {
         print_notice(T_sprintf("Sending new password of user <b>%s</b> to <b>%s</b>", $login, $email));
     }
     require_once 'classes/ttrssmailer.php';
     if ($email) {
         require_once "lib/MiniTemplator.class.php";
         $tpl = new MiniTemplator();
         $tpl->readTemplateFromFile("templates/resetpass_template.txt");
         $tpl->setVariable('LOGIN', $login);
         $tpl->setVariable('NEWPASS', $tmp_user_pwd);
         $tpl->addBlock('message');
         $message = "";
         $tpl->generateOutputToString($message);
         $mail = new ttrssMailer();
         $rc = $mail->quickMail($email, $login, __("[tt-rss] Password change notification"), $message, false);
         if (!$rc) {
             print_error($mail->ErrorInfo);
         }
     }
 }
开发者ID:zamentur,项目名称:ttrss_ynh,代码行数:32,代码来源:users.php

示例14: trim

 $test = trim(db_escape_string($_REQUEST["turing_test"]));
 if (!$login || !$email || !$test) {
     print_error(__("Your registration information is incomplete."));
     print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t</form>";
     return;
 }
 if ($test == "four" || $test == "4") {
     $result = db_query("SELECT id FROM ttrss_users WHERE\n\t\t\t\tlogin = '{$login}'");
     $is_registered = db_num_rows($result) > 0;
     if ($is_registered) {
         print_error(__('Sorry, this username is already taken.'));
         print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t</form>";
     } else {
         $password = make_password();
         $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
         $pwd_hash = encrypt_password($password, $salt, true);
         db_query("INSERT INTO ttrss_users\n\t\t\t\t\t(login,pwd_hash,access_level,last_login, email, created, salt)\n\t\t\t\t\tVALUES ('{$login}', '{$pwd_hash}', 0, null, '{$email}', NOW(), '{$salt}')");
         $result = db_query("SELECT id FROM ttrss_users WHERE\n\t\t\t\t\tlogin = '{$login}' AND pwd_hash = '{$pwd_hash}'");
         if (db_num_rows($result) != 1) {
             print_error(__('Registration failed.'));
             print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t</form>";
         } else {
             $new_uid = db_fetch_result($result, 0, "id");
             initialize_user($new_uid);
             $reg_text = "Hi!\n" . "\n" . "You are receiving this message, because you (or somebody else) have opened\n" . "an account at Tiny Tiny RSS.\n" . "\n" . "Your login information is as follows:\n" . "\n" . "Login: {$login}\n" . "Password: {$password}\n" . "\n" . "Don't forget to login at least once to your new account, otherwise\n" . "it will be deleted in 24 hours.\n" . "\n" . "If that wasn't you, just ignore this message. Thanks.";
             $mail = new ttrssMailer();
             $mail->IsHTML(false);
             $rc = $mail->quickMail($email, "", "Registration information for Tiny Tiny RSS", $reg_text, false);
             if (!$rc) {
                 print_error($mail->ErrorInfo);
             }
开发者ID:adrianpietka,项目名称:bfrss,代码行数:31,代码来源:register.php

示例15: db_prepare_input

         $password2 = db_prepare_input($_POST['Password2']);
         $resetcode_sent = true;
         if (empty($session_email) || empty($session_account_number)) {
             tep_redirect(get_href_link(PAGE_RESET_PASSWORD, '', 'SSL'));
         }
         $sql = "SELECT user_id, firstname, lastname,security_question,account_number FROM " . _TABLE_USERS . " WHERE (email='" . $session_email . "') and (account_number='" . $session_account_number . "')";
         $account = db_fetch_array(db_query($sql));
         $user_id = $account['user_id'];
         $ok = false;
         if ($validator->validateEqual('Password', $password, $password2, _ERROR_PASSWORD)) {
         }
         if ($validator->validateMinLength('Password Length', $password, 6, _ERROR_PASSWORD_MIN_LENGTH)) {
         }
         if (count($validator->errors) == 0) {
             $ok = true;
             $q = db_query("UPDATE  users SET  password =  '" . encrypt_password($password) . "' WHERE user_id = {$user_id}");
             $_html_main_content = $smarty->fetch('home/reset_password_success.html');
         } else {
             //	postAssign($smarty);
             $smarty->assign('validerrors', $validator->errors);
             //--------Add by donghp 27/03/2012- ----------------------------------
             $sql = "SELECT user_id, firstname, lastname,security_question,account_number FROM " . _TABLE_USERS . " WHERE (email='" . $email . "')";
             $account = db_fetch_array(db_query($sql));
             $smarty->assign('email', $email);
             $smarty->assign('account_number', $account['account_number']);
             // $smarty->assign('message_err',$message_err);
             $_html_main_content = $smarty->fetch('home/reset_password03.html');
         }
         $resetcode_sent = true;
     }
 }
开发者ID:rongandat,项目名称:e-global-cya,代码行数:31,代码来源:reset_password.php


注:本文中的encrypt_password函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。