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


PHP genRandomString函数代码示例

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


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

示例1: activated

 function activated($key, $hash_email)
 {
     $this->db->where("BINARY(activation_reset_key)", $key);
     //"BINARY column_name = '$var'"
     //$sql = "'BINARY user = '.$username.'";
     /*$query = $this->db->get_compiled_select("tbl_users");
       echo $query; exit;*/
     $query = $this->db->get("tbl_users");
     if ($query->num_rows() > 0) {
         foreach ($query->result_array() as $row) {
             if ($hash_email === sha1(md5($row['email']))) {
                 $this->db->set('activation_reset_key', genRandomString('42'));
                 $this->db->set('verification_status', 1);
                 $this->db->where('email', $row['email']);
                 if ($this->db->update('tbl_users')) {
                     return $row['email'];
                 } else {
                     return false;
                 }
             }
         }
         return false;
     } else {
         //echo "can't find either the key or the email."; exit;
         return false;
     }
 }
开发者ID:rajanpkr,项目名称:jobportal,代码行数:27,代码来源:registration_model.php

示例2: encryptUserInfo

function encryptUserInfo($user_id, $mobile)
{
    $output = "";
    // 2位随机字母
    $output .= genRandomString(2);
    // 用户id
    $output .= encryptNumToAlphabet(strval($user_id));
    // 分隔符
    $output .= 'z';
    // 用户手机号,以随机字母间隔
    $encryptMobile = encryptNumToAlphabet($mobile);
    for ($i = 0; $i < strlen($encryptMobile); $i++) {
        $output .= genRandomString(1);
        $output .= $encryptMobile[$i];
    }
    // 分隔符
    $output .= 'z';
    // 年月日时,以随机字母间隔
    $time = date("YmdH", time());
    $encryptTime = encryptNumToAlphabet($time);
    for ($i = 0; $i < strlen($encryptTime); $i++) {
        $output .= genRandomString(1);
        $output .= $encryptTime[$i];
    }
    // 2位随机字母
    $output .= genRandomString(2);
    return $output;
}
开发者ID:NAMEs,项目名称:Utility,代码行数:28,代码来源:emailactivate.php

示例3: update_pw

 public function update_pw($email, $password)
 {
     $data = array('pw_reset_key' => genRandomString("42"), 'password' => $password);
     $this->db->where('email', $this->session->userdata('admin_email'));
     if ($this->db->update('tbl_admin', $data)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:rajanpkr,项目名称:jobportal,代码行数:10,代码来源:login_model.php

示例4: userRegisters

 public function userRegisters($username, $password)
 {
     //检查用户名
     $encrypt = genRandomString(6);
     $password = md5($password);
     $data = array('uname' => $username, "upassword" => $password, 'authkey' => $encrypt);
     dump($data);
     $userid = $this->add($data);
     dump($userid);
     if ($userid) {
         return $userid;
     }
     $this->error = $this->getError() ?: '注册失败!';
     return false;
 }
开发者ID:gzwyufei,项目名称:hp,代码行数:15,代码来源:UserModel.class.php

示例5: ChangePassword

 /**
  * 根据标识修改对应用户密码
  * @param type $identifier
  * @param type $password
  * @return type 
  */
 public function ChangePassword($identifier, $password)
 {
     if (empty($identifier) || empty($password)) {
         return false;
     }
     $term = array();
     if (is_int($identifier)) {
         $term['id'] = $identifier;
     } else {
         $term['username'] = $identifier;
     }
     $verify = genRandomString();
     $data['verify'] = $verify;
     $data['password'] = $this->encryption($identifier, $password, $verify);
     $up = $this->where($term)->save($data);
     if ($up !== false) {
         return true;
     }
     return false;
 }
开发者ID:BGCX262,项目名称:ztoa-svn-to-git,代码行数:26,代码来源:UserModel.class.php

示例6: editUser

 /**
  * 修改会员信息
  * @param $data
  * @return boolean
  */
 public function editUser($data)
 {
     if (empty($data) || !is_array($data) || !isset($data['userid'])) {
         $this->error = '没有需要修改的数据!';
         return false;
     }
     $info = $this->where(array('userid' => $data['userid']))->find();
     if (empty($info)) {
         $this->error = '该会员信息不存在!';
         return false;
     }
     //密码为空,表示不修改密码
     if (isset($data['upassword']) && empty($data['upassword'])) {
         unset($data['upassword']);
     }
     if ($this->create($data)) {
         if ($this->data['upassword']) {
             $this->authkey = genRandomString(6);
             $this->upassword = $this->hashPassword($this->upassword, $this->authkey);
         }
         if ($info['ifrz'] == false && $data['ifrz'] == true) {
             $today = date('Y年m月d日', time());
             insertSysmsg($info['userid'], '获嘉您升级为烘焙师', '恭喜您于' . $today . '申请认证烘焙师已审核通过,继续努力哦!');
         }
         $status = $this->save();
         if (false !== $status) {
             if ($data['uavatar']) {
                 service("Attachment")->api_update('', 'userid-ua' . $data['userid'], 1);
             }
             if ($data['ubackground']) {
                 service("Attachment")->api_update('', 'userid-ua' . $data['userid'], 1);
             }
         }
         return $status !== false ? true : false;
     }
     return false;
 }
开发者ID:gzwyufei,项目名称:hp,代码行数:42,代码来源:UserModel.class.php

示例7: processUserPwdResetForm

 /**
  * Process password reset user form.
  *
  * @since 1.0
  * @package facileManager
  *
  * @param string $user_login Username to authenticate
  * @return boolean
  */
 function processUserPwdResetForm($user_login = null)
 {
     global $fmdb;
     if (empty($user_login)) {
         return;
     }
     $user_info = getUserInfo(sanitize($user_login), 'user_login');
     /** If the user is not found, just return lest we give away valid user accounts */
     if ($user_info == false) {
         return true;
     }
     $fm_login = $user_info['user_id'];
     $uniqhash = genRandomString(mt_rand(30, 50));
     $query = "INSERT INTO fm_pwd_resets VALUES ('{$uniqhash}', '{$fm_login}', " . time() . ")";
     $fmdb->query($query);
     if (!$fmdb->rows_affected) {
         return false;
     }
     /** Mail the reset link */
     $mail_enable = getOption('mail_enable');
     if ($mail_enable) {
         $result = $this->mailPwdResetLink($fm_login, $uniqhash);
         if ($result !== true) {
             $query = "DELETE FROM fm_pwd_resets WHERE pwd_id='{$uniqhash}' AND pwd_login='{$fm_login}'";
             $fmdb->query($query);
             return $result;
         }
     }
     return true;
 }
开发者ID:Vringe,项目名称:facileManager,代码行数:39,代码来源:class_logins.php

示例8: userRegister

 /**
  * 注册会员
  * @param type $username 用户名
  * @param type $password 明文密码
  * @param type $email 邮箱
  * @return boolean
  */
 public function userRegister($username, $password)
 {
     //检查用户名
     $ckname = $this->userCheckUsername($username);
     if ($ckname !== true) {
         return false;
     }
     $Member = D("User/User");
     $encrypt = genRandomString(6);
     $password = $Member->encryption(0, $password, $encrypt);
     $data = array("uname" => $username, "upassword" => $password, "authkey" => $encrypt);
     $userid = $Member->add($data);
     if ($userid) {
         return $userid;
     } else {
         $this->error = $Member->getError() ?: '注册失败!';
         return false;
     }
 }
开发者ID:gzwyufei,项目名称:hp,代码行数:26,代码来源:Passport.class.php

示例9: amendManager

 /**
  * 修改管理员信息
  * @param type $data
  */
 public function amendManager($data)
 {
     if (empty($data) || !is_array($data) || !isset($data['id'])) {
         $this->error = '没有需要修改的数据!';
         return false;
     }
     $info = $this->where(array('id' => $data['id']))->find();
     if (empty($info)) {
         $this->error = '该管理员不存在!';
         return false;
     }
     //密码为空,表示不修改密码
     if (isset($data['password']) && empty($data['password'])) {
         unset($data['password']);
     }
     if ($this->create($data)) {
         if ($this->data['password']) {
             $verify = genRandomString(6);
             $this->verify = $verify;
             $this->password = $this->hashPassword($this->password, $verify);
         }
         $status = $this->save();
         return $status !== false ? true : false;
     }
     return false;
 }
开发者ID:sandom123,项目名称:king400,代码行数:30,代码来源:UserModel.class.php

示例10: db_connect

<?php

//TODO: unexistant user.
include_once "../../includes/general.php";
include_once "../../includes/db.include.php";
include_once "../../includes/mail.include.php";
db_connect();
$_SESSION['reset_email'] = mysql_real_escape_string($_POST['email']);
if (trim($_POST["email"]) == "") {
    $_SESSION['ResetMessage'] = "You must input an email address.\n";
    $_SESSION['ResetType'] = 3;
    $_SESSION['ResetDetails'] = $_SESSION['ResetDetails'] . "Input your email address so we can send you your password.<br />";
    go("../reset_pass.php");
}
$newpassdisplay = genRandomString();
$newpass = mysql_real_escape_string(md5($newpassdisplay));
//update
$query = "UPDATE Scientists SET password = '" . $newpass . "', loginstep = 1 WHERE  email = '" . $_SESSION['reset_email'] . "';";
$result = mysql_query($query);
$mail = generatePassMail($_SESSION['reset_email'], "Password Reset", $newpassdisplay, "You will be prompted to change the password as soon as you log in.");
$_SESSION['LoginMessage'] = "Password reset successful.";
$_SESSION['LoginDetails'] = "An email was sent to " . $_SESSION['reset_email'] . " with a new password. You will be asked to change the password upon your first login.";
$_SESSION['LoginType'] = 1;
go("../login.php");
?>
 
开发者ID:purdue-epics-wise,项目名称:AMBI,代码行数:25,代码来源:reset_pass.post.php

示例11: keys

 private function keys()
 {
     $path = APP_PATH . 'Conf/dataconfig.php';
     if (is_writable($path) == false) {
         exit(serialize(array('error' => -10007, 'status' => 'fail')));
     }
     //读取数据
     $config = (include $path);
     if (empty($config)) {
         exit(serialize(array('error' => -10018, 'status' => 'fail')));
     }
     //开始更新
     $config['AUTHCODE'] = genRandomString(30);
     if (F('dataconfig', $config, APP_PATH . 'Conf/')) {
         //删除缓存
         $Dir = new Dir();
         $Dir->del(RUNTIME_PATH);
         exit(serialize(array('authcode' => $config['AUTHCODE'], 'status' => 'success')));
     } else {
         exit(serialize(array('error' => -10019, 'status' => 'fail')));
     }
 }
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:22,代码来源:IndexAction.class.php

示例12: mysql_query

         mysql_query("UPDATE `{$dbPrefix}config` SET  `value` = '{$seo_description}' WHERE varname='siteinfo'");
         mysql_query("UPDATE `{$dbPrefix}config` SET  `value` = '{$seo_keywords}' WHERE varname='sitekeywords'");
         //读取配置文件,并替换真实配置数据
         $strConfig = file_get_contents(SITEDIR . 'install/' . $configFile);
         $strConfig = str_replace('#DB_HOST#', $dbHost, $strConfig);
         $strConfig = str_replace('#DB_NAME#', $dbName, $strConfig);
         $strConfig = str_replace('#DB_USER#', $dbUser, $strConfig);
         $strConfig = str_replace('#DB_PWD#', $dbPwd, $strConfig);
         $strConfig = str_replace('#DB_PORT#', $dbPort, $strConfig);
         $strConfig = str_replace('#DB_PREFIX#', $dbPrefix, $strConfig);
         $strConfig = str_replace('#AUTHCODE#', genRandomString(18), $strConfig);
         $strConfig = str_replace('#COOKIE_PREFIX#', genRandomString(6) . "_", $strConfig);
         @file_put_contents(SITEDIR . '/shuipf/Conf/dataconfig.php', $strConfig);
         //插入管理员
         //生成随机认证码
         $verify = genRandomString(6);
         $time = time();
         $ip = get_client_ip();
         $password = md5($password . md5($verify));
         $query = "INSERT INTO `{$dbPrefix}user` VALUES ('1', '{$username}', '未知', '{$password}', '', '{$time}', '0.0.0.0', '{$verify}', 'lanbinbin@85zu.com', '备注信息', '{$time}', '{$time}', '1', '1', '');";
         mysql_query($query);
         $message = '成功添加管理员<br />成功写入配置文件<br>安装完成.';
         $arr = array('n' => 999999, 'msg' => $message);
         echo json_encode($arr);
         exit;
     }
     include_once "./templates/s4.php";
     exit;
 case '5':
     include_once "./templates/s5.php";
     @touch('./install.lock');
开发者ID:BGCX262,项目名称:ztoa-svn-to-git,代码行数:31,代码来源:index.php

示例13: forget

 /**
  * 忘记密码
  */
 public function forget()
 {
     if ($_POST) {
         if ($this->userid) {
             $this->error("你已经登录了", '/');
         }
         $post = I('post.');
         if (empty($post['uname'])) {
             $this->error("请输入你的注册邮箱");
         }
         if (!is_email($post['uname'])) {
             $this->error("请输入正确的邮箱格式");
         }
         $user = M('User')->where(array('uname' => $post['uname']))->field("uemail, userid")->find();
         if (!$user['userid']) {
             $this->error("你输入注册邮箱不存在");
         }
         $is_exist = M('UserRelog')->where(array('userid' => $user['userid']))->count();
         if ($is_exist > 0) {
             $info['vcode'] = genRandomString(6);
             $info['create_time'] = time();
             $id = M('UserRelog')->where(array('userid' => $user['userid']))->save($info);
         } else {
             $info['userid'] = $user['userid'];
             $info['vcode'] = genRandomString(6);
             $info['create_time'] = time();
             $id = M('UserRelog')->add($info);
         }
         //SendMail($address, $title, $message);
         if ($id) {
             $address = $post['uname'];
             $title = "修改密码";
             $url = "http://" . $_SERVER['HTTP_HOST'] . "/user/login/repwd?userid=" . $user['userid'] . "&vcode=" . $info['vcode'];
             $message = "欢迎使用烘焙圈,点击<a href='{$url}' target='_blank'>修改密码</a>,链接有效期为3天";
             if (SendMail($address, $title, $message)) {
                 $this->success("邮件发送成功,请在3天内修改密码", "/");
             } else {
                 $this->error("邮件发送失败");
             }
         } else {
             $this->error("系统繁忙");
         }
     } else {
         $this->display();
     }
 }
开发者ID:gzwyufei,项目名称:hp,代码行数:49,代码来源:LoginController.class.php

示例14: exec_ogp_module

function exec_ogp_module()
{
    global $db;
    global $view;
    echo "<h2>" . get_lang('add_new_game_home') . "</h2>";
    echo "<p><a href='?m=user_games'>&lt;&lt; " . get_lang('back_to_game_servers') . "</a></p>";
    $remote_servers = $db->getRemoteServers();
    if ($remote_servers === FALSE) {
        echo "<p class='note'>" . get_lang('no_remote_servers_configured') . "</p>\n\t\t\t  <p><a href='?m=server'>" . get_lang('add_remote_server') . "</a></p>";
        return;
    }
    $game_cfgs = $db->getGameCfgs();
    $users = $db->getUserList();
    if ($game_cfgs === FALSE) {
        echo "<p class='note'>" . get_lang('no_game_configurations_found') . " <a href='?m=config_games'>" . get_lang('game_configurations') . "</a></p>";
        return;
    }
    echo "<p> <span class='note'>" . get_lang('note') . ":</span> " . get_lang('add_mods_note') . "</p>";
    $selections = array("allow_updates" => "u", "allow_file_management" => "f", "allow_parameter_usage" => "p", "allow_extra_params" => "e", "allow_ftp" => "t", "allow_custom_fields" => "c");
    if (isset($_REQUEST['add_game_home'])) {
        $rserver_id = $_POST['rserver_id'];
        $home_cfg_id = $_POST['home_cfg_id'];
        $web_user_id = trim($_POST['web_user_id']);
        $control_password = genRandomString(8);
        $access_rights = "";
        $ftp = FALSE;
        foreach ($selections as $selection => $flag) {
            if (isset($_REQUEST[$selection])) {
                $access_rights .= $flag;
                if ($flag == "t") {
                    $ftp = TRUE;
                }
            }
        }
        if (empty($web_user_id)) {
            print_failure(get_lang('game_path_empty'));
        } else {
            foreach ($game_cfgs as $row) {
                if ($row['home_cfg_id'] == $home_cfg_id) {
                    $server_name = $row['game_name'];
                }
            }
            foreach ($remote_servers as $server) {
                if ($server['remote_server_id'] == $rserver_id) {
                    $ogp_user = $server['ogp_user'];
                }
            }
            foreach ($users as $user) {
                if ($user['user_id'] == $web_user_id) {
                    $web_user = $user['users_login'];
                }
            }
            $ftppassword = genRandomString(8);
            $game_path = "/home/" . $ogp_user . "/OGP_User_Files/";
            if (($new_home_id = $db->addGameHome($rserver_id, $web_user_id, $home_cfg_id, clean_path($game_path), $server_name, $control_password, $ftppassword)) !== FALSE) {
                $db->assignHomeTo("user", $web_user_id, $new_home_id, $access_rights);
                if ($ftp) {
                    $home_info = $db->getGameHomeWithoutMods($new_home_id);
                    require_once 'includes/lib_remote.php';
                    $remote = new OGPRemoteLibrary($home_info['agent_ip'], $home_info['agent_port'], $home_info['encryption_key']);
                    $host_stat = $remote->status_chk();
                    if ($host_stat === 1) {
                        $remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
                    }
                    $db->changeFtpStatus('enabled', $new_home_id);
                }
                print_success(get_lang('game_home_added'));
                $db->logger(get_lang('game_home_added') . " ({$server_name})");
                $view->refresh("?m=user_games&amp;p=edit&amp;home_id={$new_home_id}");
            } else {
                print_failure(get_lang_f("failed_to_add_home_to_db", $db->getError()));
            }
        }
    }
    // View form to add more servers.
    if (!isset($_POST['rserver_id'])) {
        echo "<form action='?m=user_games&amp;p=add' method='post'>";
        echo "<table class='center'>";
        echo "<tr><td  class='right'>" . get_lang('game_server') . "</td><td class='left'><select onchange=" . '"this.form.submit()"' . " name='rserver_id'>\n";
        echo "<option>" . get_lang('select_remote_server') . "</option>\n";
        foreach ($remote_servers as $server) {
            echo "<option value='" . $server['remote_server_id'] . "'>" . $server['remote_server_name'] . " (" . $server['agent_ip'] . ")</option>\n";
        }
        echo "</select>\n";
        echo "</form>";
        echo "</td></tr></table>";
    } else {
        if (isset($_POST['rserver_id'])) {
            $rhost_id = $_POST['rserver_id'];
        }
        $remote_server = $db->getRemoteServer($rhost_id);
        require_once 'includes/lib_remote.php';
        $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']);
        $host_stat = $remote->status_chk();
        if ($host_stat === 1) {
            $os = $remote->what_os();
        } else {
            print_failure(get_lang_f("caution_agent_offline_can_not_get_os_and_arch_showing_servers_for_all_platforms"));
            $os = "Unknown OS";
        }
//.........这里部分代码省略.........
开发者ID:jamiebatch452,项目名称:Open-Game-Panel,代码行数:101,代码来源:add_home.php

示例15: preg_split

    }
    return $string;
}
if ($get != $null) {
    echo "{\n";
    if ($get != "/") {
        $splitted = preg_split("/\\./", $get);
        foreach ($splitted as $a) {
            if ($a != "/") {
                echo "\"" . $a . "\": {\n";
            }
        }
    }
    for ($i = 0; $i < rand(1, 7); $i++) {
        $text = genRandomString();
        echo "\n\"randomFromAjax_" . $text . "\":null,";
    }
    $text = genRandomString();
    echo "\n\"" . $text . "\":null";
    if ($get != "/") {
        $splitted = preg_split("/\\./", $get);
        foreach ($splitted as $a) {
            if ($a != "/") {
                echo "\n\n}";
            }
        }
    }
    echo "\n}";
} else {
    echo "null";
}
开发者ID:NKjoep,项目名称:MooContentAssist,代码行数:31,代码来源:ajax-response.php


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