當前位置: 首頁>>代碼示例>>PHP>>正文


PHP base::randomString方法代碼示例

本文整理匯總了PHP中base::randomString方法的典型用法代碼示例。如果您正苦於以下問題:PHP base::randomString方法的具體用法?PHP base::randomString怎麽用?PHP base::randomString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在base的用法示例。


在下文中一共展示了base::randomString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: session_hash

function session_hash(database $database, base $base, $username)
{
    //generate new hash
    $session_hash = $base->randomString(35);
    //update old hash to new one (after checking the hahs doesn't exist)
    $database->processQuery("SELECT * FROM `users` WHERE `cookie` = ?", array($session_hash), false);
    if ($database->getRowCount() == 0) {
        $database->processQuery("UPDATE `users` SET `cookie` = ? WHERE `username` = ? LIMIT 1", array($session_hash, $username), false);
        return $session_hash;
    } else {
        session_hash();
    }
}
開發者ID:Vubot,項目名稱:RuneScapeCommunityScript,代碼行數:13,代碼來源:login.php

示例2: foreach

            }
            if (preg_match('#[^a-zA-Z0-9$ ]#', $answer)) {
                $errors[] = 'Question #' . $i . ' contains illegal characters.';
            }
        }
        if (count($errors) >= 1) {
            //back button
            ?>
 <center><input type="button" value="Back" onclick="goBack()" /></center> <?php 
            //display errors
            foreach ($errors as $error) {
                echo $error . '<br/>';
            }
        } else {
            //generate a tracking ID
            $rand_hash = $base->randomString(11);
            $tracking_id = substr($rand_hash, 0, 3) . '-' . substr($rand_hash, 4, 3) . '-' . substr($rand_hash, 7, 3);
            //create the recovery request
            $database->processQuery("INSERT INTO `tracking` VALUES (null, ?, ?, NOW(), ?, ?, 0, ?, ?, ?, ?, ?, ?)", array($user->getIdByName($_POST['username']), $_SERVER['REMOTE_ADDR'], time(), $tracking_id, $answers[0], $answers[1], $answers[2], $answers[3], $answers[4], $answers[5]), false);
            ?>
                                            <fieldset class="question">
                                                <legend>Success!</legend>
                                                You have successfully submitted a recovery request to the Asgarniax team. Within 24 hours, your request will be reviewed. To get the status of the administrator's review, 
                                                you can track the recovery by the tracking ID given to you below. <b>Write the tracking ID down so you don't forget.</b>
                                            </fieldset>
                                            <br/>
                                            <br/>
                                            <b>Tracking ID: <?php 
            echo $tracking_id;
            ?>
</b>
開發者ID:Vubot,項目名稱:RuneScapeCommunityScript,代碼行數:31,代碼來源:recover.php


注:本文中的base::randomString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。