当前位置: 首页>>代码示例>>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;未经允许,请勿转载。