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


PHP dss_rand函数代码示例

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


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

示例1: session_reset_keys

/**
* Reset all login keys for the specified user
* Called on password changes
*/
function session_reset_keys($user_id, $user_ip)
{
    global $db, $userdata, $board_config;
    $key_sql = $user_id == $userdata['user_id'] && !empty($userdata['session_key']) ? "AND key_id != '" . md5($userdata['session_key']) . "'" : '';
    $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
		WHERE user_id = ' . (int) $user_id . "\n\t\t\t{$key_sql}";
    if (!$db->sql_query($sql)) {
        message_die(CRITICAL_ERROR, 'Error removing auto-login keys', '', __LINE__, __FILE__, $sql);
    }
    $where_sql = 'session_user_id = ' . (int) $user_id;
    $where_sql .= $user_id == $userdata['user_id'] ? " AND session_id <> '" . $userdata['session_id'] . "'" : '';
    $sql = 'DELETE FROM ' . SESSIONS_TABLE . "\n\t\tWHERE {$where_sql}";
    if (!$db->sql_query($sql)) {
        message_die(CRITICAL_ERROR, 'Error removing user session(s)', '', __LINE__, __FILE__, $sql);
    }
    if (!empty($key_sql)) {
        $auto_login_key = dss_rand() . dss_rand();
        $current_time = time();
        $sql = 'UPDATE ' . SESSIONS_KEYS_TABLE . "\n\t\t\tSET last_ip = '{$user_ip}', key_id = '" . md5($auto_login_key) . "', last_login = {$current_time}\n\t\t\tWHERE key_id = '" . md5($userdata['session_key']) . "'";
        if (!$db->sql_query($sql)) {
            message_die(CRITICAL_ERROR, 'Error updating session key', '', __LINE__, __FILE__, $sql);
        }
        // And now rebuild the cookie
        $sessiondata['userid'] = $user_id;
        $sessiondata['autologinid'] = $auto_login_key;
        $cookiename = $board_config['cookie_name'];
        $cookiepath = $board_config['cookie_path'];
        $cookiedomain = $board_config['cookie_domain'];
        $cookiesecure = $board_config['cookie_secure'];
        setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
        $userdata['session_key'] = $auto_login_key;
        unset($sessiondata);
        unset($auto_login_key);
    }
}
开发者ID:BackupTheBerlios,项目名称:flushcms,代码行数:39,代码来源:sessions.php

示例2: COUNT

        }
        $db->sql_freeresult($result);
        $sql = 'SELECT COUNT(session_id) AS attempts 
			FROM ' . CONFIRM_TABLE . " \n\t\t\tWHERE session_id = '" . $userdata['session_id'] . "'";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not obtain confirm code count', '', __LINE__, __FILE__, $sql);
        }
        if ($row = $db->sql_fetchrow($result)) {
            if ($row['attempts'] > 3) {
                message_die(GENERAL_MESSAGE, $lang['Too_many_registers']);
            }
        }
        $db->sql_freeresult($result);
        // Generate the required confirmation code
        // NB 0 (zero) could get confused with O (the letter) so we make change it
        $code = dss_rand();
        $code = substr(str_replace('0', 'Z', strtoupper(base_convert($code, 16, 35))), 2, 6);
        $confirm_id = md5(uniqid($user_ip));
        $sql = 'INSERT INTO ' . CONFIRM_TABLE . " (confirm_id, session_id, code) \n\t\t\tVALUES ('{$confirm_id}', '" . $userdata['session_id'] . "', '{$code}')";
        if (!$db->sql_query($sql)) {
            message_die(GENERAL_ERROR, 'Could not insert new confirm code information', '', __LINE__, __FILE__, $sql);
        }
        unset($code);
        $confirm_image = '<img src="' . append_sid("profile.{$phpEx}?mode=confirm&amp;id={$confirm_id}") . '" alt="" title="" />';
        $s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />';
        $template->assign_block_vars('switch_confirm', array());
    }
    //
    // Let's do an overall check for settings/versions which would prevent
    // us from doing file uploads....
    //
开发者ID:Nekrofage,项目名称:ForumJdR,代码行数:31,代码来源:usercp_register.php

示例3: make_bbcode_uid

function make_bbcode_uid()
{
    // Unique ID for this message..
    $uid = dss_rand();
    $uid = substr($uid, 0, BBCODE_UID_LEN);
    return $uid;
}
开发者ID:nmpetkov,项目名称:ZphpBB2,代码行数:7,代码来源:bbcode.php

示例4: gen_rand_string

function gen_rand_string($hash)
{
    $rand_str = dss_rand();
    return $hash ? md5($rand_str) : substr($rand_str, 8);
}
开发者ID:bitweaver,项目名称:phpbb,代码行数:5,代码来源:profile.php

示例5: header

} else {
    exit;
}
/**
 * The next part is orginnaly written by ted from mastercode.nl and modified for using in this mod.
 **/
header("content-type:image/png");
header('Cache-control: no-cache, no-store');
$width = 250;
$height = 60;
$img = imagecreatetruecolor($width, $height);
$background = imagecolorallocate($img, color("bg"), color("bg"), color("bg"));
srand(make_seed());
imagefilledrectangle($img, 0, 0, 249, 59, $background);
for ($g = 0; $g < 30; $g++) {
    $t = dss_rand();
    $t = $t[0];
    $ypos = rand(0, $height);
    $xpos = rand(0, $width);
    $kleur = imagecolorallocate($img, color("bgtekst"), color("bgtekst"), color("bgtekst"));
    imagettftext($img, size(), move(), $xpos, $ypos, $kleur, font(), $t);
}
$stukje = $width / (strlen($code) + 3);
for ($j = 0; $j < strlen($code); $j++) {
    $tek = $code[$j];
    $ypos = rand(35, 41);
    $xpos = $stukje * ($j + 1);
    $color2 = imagecolorallocate($img, color("tekst"), color("tekst"), color("tekst"));
    imagettftext($img, size(), move(), $xpos, $ypos, $color2, font(), $tek);
}
imagepng($img);
开发者ID:Nekrofage,项目名称:FJR,代码行数:31,代码来源:usercp_captcha.php

示例6: unique_id

/**
* Return unique id
* @param string $extra additional entropy
*/
function unique_id($extra = 'c')
{
	return dss_rand();
}
开发者ID:ALTUN69,项目名称:icy_phoenix,代码行数:8,代码来源:functions.php

示例7: generateRegisterID

function generateRegisterID()
{
    global $userdata;
    #Generate and delete old confirm ID's from the confirm table based
    #upon inactive sessions
    $sql = 'SELECT session_id FROM sessions';
    $result = mysql_query($sql);
    if (!$result) {
        return "Error";
    }
    $confirm_sql = '';
    $count = 0;
    while ($count < mysql_num_rows($result)) {
        $confirm_sql .= ($confirm_sql != '' ? ', ' : '') . "'" . mysql_result($result, $count, 0) . "'";
        $count++;
    }
    mysql_free_result($result);
    $sql = "DELETE FROM confirm WHERE session_id NOT IN ({$confirm_sql})";
    $result = mysql_query($sql);
    if (!$result) {
        return "Error";
    }
    #
    # Check number of create requests
    #
    $sql = "SELECT COUNT(session_id) AS attempts from confirm WHERE session_id = '" . $userdata['session_id'] . "'";
    $result = mysql_query($sql);
    if (!$result) {
        return "Error";
    }
    if (mysql_result($result, 0, 0) > 3) {
        return "Error";
    }
    mysql_free_result($result);
    // Generate the required confirmation code
    // NB 0 (zero) could get confused with O (the letter) so we make change it
    $code = dss_rand();
    $code = substr(str_replace('0', 'Z', strtoupper(base_convert($code, 16, 35))), 2, 6);
    $confirm_id = md5(uniqid($user_ip));
    $sql = "INSERT INTO confirm (confirm_id, session_id, code) VALUES ('{$confirm_id}', '" . $userdata['session_id'] . "', '{$code}')";
    $result = mysql_query($sql);
    if (!$result) {
        return "Error";
    }
    unset($code);
    return $confirm_id;
}
开发者ID:andrewroth,项目名称:winbolo,代码行数:47,代码来源:forumfunctions.php

示例8: session_begin


//.........这里部分代码省略.........
        }
    } else {
        $login = 0;
    }
    // End PNphpBB2 Module
    //
    // Initial ban check against user id, IP and email address
    //
    preg_match('/(..)(..)(..)(..)/', $user_ip, $user_ip_parts);
    $sql = "SELECT ban_ip, ban_userid, ban_email \n        FROM " . BANLIST_TABLE . " \n        WHERE ban_ip IN ('" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . $user_ip_parts[4] . "', '" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . "ff', '" . $user_ip_parts[1] . $user_ip_parts[2] . "ffff', '" . $user_ip_parts[1] . "ffffff')\n            OR ban_userid = {$user_id}";
    if ($user_id != ANONYMOUS) {
        $sql .= " OR ban_email LIKE '" . str_replace("\\'", "''", $userdata['user_email']) . "' \n            OR ban_email LIKE '" . substr(str_replace("\\'", "''", $userdata['user_email']), strpos(str_replace("\\'", "''", $userdata['user_email']), "@")) . "'";
    }
    if (!($result = $db->sql_query($sql))) {
        message_die(CRITICAL_ERROR, 'Could not obtain ban information', '', __LINE__, __FILE__, $sql);
    }
    if ($ban_info = $db->sql_fetchrow($result)) {
        if ($ban_info['ban_ip'] || $ban_info['ban_userid'] || $ban_info['ban_email']) {
            message_die(CRITICAL_MESSAGE, 'You_been_banned');
        }
    }
    //
    // Create or update the session
    //
    // Begin PNphpBB2 Module
    // -- Remove session_admin
    //	$sql = "UPDATE " . SESSIONS_TABLE . "
    //		SET session_user_id = $user_id, session_start = $current_time, session_time = $current_time, session_page = $page_id, session_logged_in = $login, session_admin = $admin
    //		WHERE session_id = '" . $session_id . "'
    //			AND session_ip = '$user_ip'";
    $sql = "UPDATE " . SESSIONS_TABLE . "\n        SET session_user_id = {$user_id}, session_start = {$current_time}, session_time = {$current_time}, session_page = {$page_id}, session_logged_in = {$login}\n        WHERE session_id = '" . $session_id . "' \n            AND session_ip = '{$user_ip}'";
    // End PNphpBB2 Module
    if (!$db->sql_query($sql) || !$db->sql_affectedrows()) {
        $session_id = md5(dss_rand());
        // Begin PNphpBB2 Module
        // -- Remove session_admin
        //		$sql = "INSERT INTO " . SESSIONS_TABLE . "
        //			(session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in, session_admin)
        //			VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', $page_id, $login, $admin)";
        $sql = "INSERT INTO " . SESSIONS_TABLE . "\n            (session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in)\n            VALUES ('{$session_id}', {$user_id}, {$current_time}, {$current_time}, '{$user_ip}', {$page_id}, {$login})";
        // End PNphpBB2 Module
        if (!$db->sql_query($sql)) {
            message_die(CRITICAL_ERROR, 'Error creating new session', '', __LINE__, __FILE__, $sql);
        }
    }
    if ($user_id != ANONYMOUS) {
        $last_visit = $userdata['user_session_time'] > 0 ? $userdata['user_session_time'] : $current_time;
        // Begin PNphpBB2 Module
        //		if (!$admin)
        //		{
        // End PNphpBB2 Module
        $sql = "UPDATE " . USERS_TABLE . " \n                SET user_session_time = {$current_time}, user_session_page = {$page_id}, user_lastvisit = {$last_visit}\n                WHERE user_id = {$user_id}";
        if (!$db->sql_query($sql)) {
            message_die(CRITICAL_ERROR, 'Error updating last visit time', '', __LINE__, __FILE__, $sql);
        }
        // Begin PNphpBB2 Module
        //		}
        // End PNphpBB2 Module
        $userdata['user_lastvisit'] = $last_visit;
        // Begin PNphpBB2 Module
        /*
                //
                // Regenerate the auto-login key
                //
                if ($enable_autologin)
                {
开发者ID:nmpetkov,项目名称:ZphpBB2,代码行数:67,代码来源:sessions.php


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