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


PHP getHash函数代码示例

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


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

示例1: vInsertIntoOwnerLoginTable

function vInsertIntoOwnerLoginTable($SafeFirstName, $SafeLastName, $SafeEmail, $SafePWD)
{
    global $mysqli;
    $UserID = $SafeFirstName . $SafeLastName;
    $iOwnerExists = iCheckIfOwnerEmailExists($SafeEmail);
    #if this is the first claim.
    if ($iOwnerExists == 0) {
        #Obtain a cryption and save it in the DB.
        $salt = salt();
        #Hash a string that is comprised of password and a salt.
        #Save it as a password.  This will create a second level of security.
        $hash = getHash($SafePWD, $salt);
        # The folloing is for email activation of validation.
        $email_code = md5($SafeEmail + microtime());
        if (DEBUG) {
            echo "salt =" . $salt . "<br>";
            echo "SafePWD =" . $SafePWD . "<br>";
            echo "hash =" . $hash . "<br>";
        }
        #user_id is also email address.
        $mysqli->autocommit(FALSE);
        $InsertCommand = "INSERT INTO \r\n                                  login_table ( id, user_id, salt, password, email_address, email_code, type )\r\n\t\t\t\t  values ( NULL, '" . $SafeEmail . "', '" . $salt . "', '" . $hash . "', '" . $SafeEmail . "', '" . $email_code . "', 'O' )";
        $add_post_res = $mysqli->query($InsertCommand);
        # or die($mysqli->error);
        if (!$mysqli->commit()) {
            $mysqli->rollback();
        }
        SendActivateEmailNotice($SafeEmail, $email_code);
        echo "Please activate your email to complete the registration.  Please respond to your email. Thanks.";
    } else {
        /*popup( "You have already registere!", OWNER_LOGIN_PAGE ); */
        echo "You have already registered!";
    }
}
开发者ID:nguaki,项目名称:baboom,代码行数:34,代码来源:owner_register.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new User();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->password = getHash($model->password);
         if (Yii::app()->user->isFranchiseAdmin()) {
             $model->franchise = Yii::app()->user->franchise;
             $model->role_id = 2;
         }
         if (Yii::app()->user->isAdmin()) {
             $franchise = new Franchise();
             $franchise->name = $model->username;
             $franchise->save();
             $model->franchise = $franchise->id;
             $model->role_id = 3;
         }
         if ($model->save()) {
             //                $this->redirect(array('view', 'id' => $model->id));
             $this->redirect(array('user/admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:VishalSuriMcc,项目名称:jaspersiform,代码行数:30,代码来源:UserController_b.php

示例3: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Banner'])) {
         $image = CUploadedFile::getInstance($model, 'image');
         $modelImg = $model->image;
         $model->attributes = $_POST['Banner'];
         if (!$image) {
             $model->image = $modelImg;
         }
         if ($image) {
             $extarr = explode('.', $image->name);
             $ext = end($extarr);
             $imgName = getHash(time());
             $model->image = $imgName . '.' . $ext;
             $PATH = Yii::getPathOfAlias("webroot.productimg") . '/' . $model->image;
         }
         if ($model->save()) {
             if ($image) {
                 $image->saveAs($PATH);
             }
             //                $this->redirect(array('view', 'id' => $model->id));
             $this->redirect(array('banner/admin'));
         }
     }
     $this->render('update', array('model' => $model));
 }
开发者ID:VishalSuriMcc,项目名称:jaspersiform,代码行数:34,代码来源:BannerController.php

示例4: fileNameByRandom

 /**
  * 随机生成文件名
  * @param $ext 文件扩展名
  * @return string
  */
 public static function fileNameByRandom($ext = null)
 {
     if (empty($ext)) {
         $ext = "tmp";
     }
     $randomStr = getHash(rand(1, 30000) . time() . $ext . rand(1, 30000));
     return $randomStr . "." . $ext;
 }
开发者ID:cumtCsdn,项目名称:cumtxa,代码行数:13,代码来源:FileObject.class.php

示例5: getPassword

function getPassword($username, $token)
{
    if (getTokenValid($username, $token)) {
        global $salt;
        $hash = getHash($username);
        $password = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($salt), base64_decode($hash), MCRYPT_MODE_CBC, md5(md5($salt))), "");
        return $password;
    } else {
        return false;
    }
}
开发者ID:CWMCDev,项目名称:Barend,代码行数:11,代码来源:auth.php

示例6: validateHash

function validateHash($password, $hash)
{
    $hashArr = explode(':', $hash);
    switch (count($hashArr)) {
        case 1:
            return getHash($password) === $hash;
        case 2:
            return getHash($hashArr[1] . $password) === $hashArr[0];
    }
    return 'Invalid hash.';
}
开发者ID:HB4daemmon,项目名称:custom,代码行数:11,代码来源:hash.php

示例7: actionLogin

 public function actionLogin()
 {
     $return['sucess'] = false;
     if (isset($params['username']) && isset($params['password'])) {
         $user = User::model()->findByAttributes(array('username' => $params['username'], 'password' => getHash($params['password'])));
         if ($user) {
             $return['sucess'] = true;
             $return['user'] = $user->attributes;
         }
     }
     echo json_encode($return);
 }
开发者ID:VishalSuriMcc,项目名称:jaspersiform,代码行数:12,代码来源:ApiController.php

示例8: login

 public function login($username, $password)
 {
     if (intval(f('SELECT COUNT(1) FROM ' . FAILED_LOGINS_TABLE . ' WHERE UserTable="tblWebUser" AND Username="' . $GLOBALS['DB_WE']->escape($username) . '" AND isValid="true" AND LoginDate >DATE_SUB(NOW(), INTERVAL ' . intval(SECURITY_LIMIT_CUSTOMER_NAME_HOURS) . ' hour)')) >= intval(SECURITY_LIMIT_CUSTOMER_NAME) || intval(f('SELECT COUNT(1) FROM ' . FAILED_LOGINS_TABLE . ' WHERE UserTable="tblWebUser" AND IP="' . $_SERVER['REMOTE_ADDR'] . '" AND LoginDate >DATE_SUB(NOW(), INTERVAL ' . intval(SECURITY_LIMIT_CUSTOMER_IP_HOURS) . ' hour)')) >= intval(SECURITY_LIMIT_CUSTOMER_IP)) {
         logApiRequests('endpoint: ' . $this->request['request'] . '; Login denied for User : ' . $username . '; apiKey : ' . (array_key_exists('apiKey', $this->request) ? $this->request['apiKey'] : 'No API key given') . '; App version : ' . (array_key_exists('appVersion', $this->request) ? $this->request['appVersion'] : 'No App version given') . '; App platform : ' . (array_key_exists('appPlatform', $this->request) ? $this->request['appPlatform'] : 'No App plattform given'));
         throw new Exception('Login denied for user');
     }
     $u = getHash('SELECT * FROM ' . CUSTOMER_TABLE . ' WHERE Password!="" AND LoginDenied=0 AND Username="' . $GLOBALS['DB_WE']->escape($username) . '"', null, MYSQL_ASSOC);
     if (empty($u)) {
         logApiRequests('endpoint: ' . $this->request['request'] . '; Invalid User : ' . $username . '; apiKey : ' . (array_key_exists('apiKey', $this->request) ? $this->request['apiKey'] : 'No API key given') . '; App version : ' . (array_key_exists('appVersion', $this->request) ? $this->request['appVersion'] : 'No App version given') . '; App platform : ' . (array_key_exists('appPlatform', $this->request) ? $this->request['appPlatform'] : 'No App plattform given'));
         throw new Exception('Invalid User');
     }
     return $u && we_customer_customer::comparePassword($u['Password'], $password) ? array('UserIDHash' => $u['App_UserIDHash']) : array('UserIDHash' => false);
 }
开发者ID:andreaswitt,项目名称:CMSwebEdition,代码行数:13,代码来源:user.class.php

示例9: __construct

 /**
  * 构造函数,检查配置是否完成
  */
 protected function __construct()
 {
     SimpleSession::init(null, getHash($_POST['FromUserName']));
     if (!$_SESSION['wechatActivity']) {
         $_SESSION['wechatActivity'] = null;
     }
     if (!$_SESSION['callbackStack']) {
         $_SESSION['callbackStack'] = null;
     }
     $this->activity =& $_SESSION['wechatActivity'];
     $this->callbackStack =& $_SESSION['callbackStack'];
     $this->token = getConfig("wechat", "token");
     $this->appInfo =& getAppInfo();
 }
开发者ID:cumtCsdn,项目名称:cumtxa,代码行数:17,代码来源:WechatRouter.class.php

示例10: iCheckIfOwnerEmailExists

function iCheckIfOwnerEmailExists($SafeEmail, $SafePW, &$ID, &$Email_status, &$Email_code, &$Password_status)
{
    global $mysqli;
    $QueryResultSet = "SELECT count(*) AS row_exists, \r\n                                  salt, \r\n                                  password, \r\n                                  id,\r\n\t\t\t\t  email_active,\r\n\t\t\t\t  email_code,\r\n\t\t\t\t  password_recover\r\n\t\t\t   FROM login_table\r\n\t\t\t   WHERE email_address = '{$SafeEmail}'";
    $objGetResult = $mysqli->query($QueryResultSet);
    if (DEBUG) {
        echo "{$QueryResultSet}<br>";
        var_dump($objGetResult);
    }
    if ($objGetResult) {
        $anArray = $objGetResult->fetch_array(MYSQLI_ASSOC);
        $numof_rows = stripslashes($anArray['row_exists']);
        $salt = stripslashes($anArray['salt']);
        $password = stripslashes($anArray['password']);
        $Password_status = stripslashes($anArray['password_recover']);
        if (DEBUG) {
            echo "Inside<br>";
            echo "numof_rows = {$numof_rows}<br>";
            echo "salt = {$salt}<br>";
            echo "password = {$password}<br>";
        }
        if ($numof_rows == 1) {
            $hash = getHash($SafePW, $salt);
            if (DEBUG) {
                echo "Inside<br>";
                echo "numof_rows = {$numof_rows}<br>";
                echo "salt = {$salt}<br>";
                echo "password = {$password}<br>";
                echo "SafePW = {$SafePW}<br>";
                echo "hash = {$hash}<br>";
            }
            if ($hash == $password) {
                $ID = stripslashes($anArray['id']);
                $Email_status = stripslashes($anArray['email_active']);
                $Email_code = stripslashes($anArray['email_code']);
                if (DEBUG) {
                    echo "email_code" . $Email_code . "<br>";
                }
                $Email_Exists = 1;
            } else {
                $Email_Exists = 0;
            }
        } else {
            $Email_Exists = 0;
        }
        $objGetResult->free_result();
    }
    return $Email_Exists;
}
开发者ID:nguaki,项目名称:baboom,代码行数:49,代码来源:owner_login.php

示例11: loginUser

function loginUser($un, $psw)
{
    $_SESSION['uid'] = $uid = Adapter::getAValue('UID', '`person`', 'name=?', array($un), "s");
    $_SESSION['type'] = Adapter::getAValue('type', '`person`', 'uid=?', array($uid), "i");
    if ($uid == -1) {
        print 1;
        return;
    }
    if (!Adapter::isExists('`person`', 'UID=? AND hash=?', array($uid, getHash($psw)), "is")) {
        print 2;
        return;
    }
    /*login code*/
    $_SESSION['logged'] = 1;
    print 3;
}
开发者ID:Vcnet-Company,项目名称:angularjs-internal,代码行数:16,代码来源:functions.inc.php

示例12: checkUser

 public function checkUser()
 {
     if (isset($_COOKIE['userinfo'])) {
         $string = $_COOKIE['userinfo'];
         $cookieText = explode('||', $string);
         $inputLogin = $cookieText[1];
         $this->user_model->getUserDataByLogin($inputLogin);
         $trueLogin = $this->user_model->getLogin();
         $truePassword = $this->user_model->getPassword();
         $name = $this->user_model->getUserName();
         $userHash = getHash($trueLogin, $truePassword);
         if ($string === $userHash) {
             $userData = array('username' => $name, 'logged_in' => TRUE);
             $this->session->set_userdata($userData);
         } else {
             setcookie('userinfo', '');
         }
     }
 }
开发者ID:nickepoch,项目名称:HW15,代码行数:19,代码来源:login.php

示例13: vInsertIntoClientLoginTable

function vInsertIntoClientLoginTable($SafeFirstName, $SafeLastName, $SafeEmail, $SafePWD)
{
    global $mysqli;
    $UserID = $SafeFirstName . $SafeLastName;
    $iClientExists = iCheckIfClientEmailExists($SafeEmail);
    #if this is the first claim.
    if ($iClientExists == 0) {
        $salt = salt();
        $hash = getHash($SafePWD, $salt);
        $email_code = md5($SafeEmail + microtime());
        #user_id is also email address.
        $mysqli->autocommit(FALSE);
        $InsertCommand = "INSERT INTO client_login_table \r\n                                        ( id, first_name, last_name, email_address, email_code, salt, password )\r\n                                  values \r\n                                  (NULL,'{$SafeFirstName}', '{$SafeLastName}', '{$SafeEmail}', '{$email_code}', '{$salt}', '{$hash}' )";
        $add_post_res = $mysqli->query($InsertCommand) or die($mysqli->error);
        if (!$mysqli->commit()) {
            $mysqli->rollback();
        }
        SendActivateEmailNotice($SafeEmail, $email_code);
        echo "Please activate your email to complete the registration.  Please respond to your email. Thanks.";
    } else {
        /*popup('You have already registered.', "http://" . IP_ADDRESS . "/member/client_login_register.php");*/
        echo "You have already registered";
    }
}
开发者ID:nguaki,项目名称:baboom,代码行数:24,代码来源:member_register.php

示例14: getHash

 * @param array $data Array of transmitted data (see above)
 * @param string $password Your Gateway-Password
 */
function getHash(array $data, $password)
{
    $hash_source = null;
    foreach ($data as $value) {
        $hash_source .= $value . '|';
    }
    $hash_source .= $password;
    $hash_md5 = md5($hash_source);
    return $hash_md5;
}
$databases = array(1);
$data = array('msg_id' => $_POST['messageId'], 'number' => $_POST['responseSender'], 'message' => $_POST['responseMessage'], 'timestamp' => $_POST['responseTimestamp']);
if (getHash($data, SMS_PASSWORD) == $_POST['hash']) {
    // DO something here like sending mail, store in database ...
    $found = false;
    if (!empty($data['msg_id'])) {
        foreach ($databases as $database) {
            $redis->SELECT($database);
            if ($redis->EXISTS("sms:send:{$data['msg_id']}")) {
                $send = $redis->HGETALL("sms:send:{$data['msg_id']}");
                if (is_array($send)) {
                    $found = true;
                    $redis->HMSET("sms:send:{$data['msg_id']}", array('status' => SMS_STATUS_ANSWERED));
                    $redis->HMSET("sms:receive:{$data['msg_id']}", array('returnto' => $send['returnto'], 'sender' => $send['receiver'], 'receiver' => $send['sender'], 'datetime' => $data['timestamp'], 'message' => $data['message']));
                    $redis->SADD("sms:inbound", (string) $data['msg_id']);
                    break;
                } else {
                    $line = trim(date("[d/m @ H:i:s]") . "SMS response Error: " . implode(', ', $data)) . "\n";
开发者ID:rbraband,项目名称:LouCes,代码行数:31,代码来源:sms-response.php

示例15: inputHash

function inputHash()
{
    return '<input type="hidden" name="hash" value="' . getHash() . '">';
}
开发者ID:frycnx,项目名称:jxc,代码行数:4,代码来源:Functions.php


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