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


PHP create_randomstr函数代码示例

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


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

示例1: addadmin

 public function addadmin()
 {
     $this->data['title'] = "AddAdmin";
     $this->load->view('mzsj/com_header', $this->data);
     if (isset($_POST['dosubmit']) && $this->form_validation->run('admin_rules')) {
         // 取得所有数据,并给密码加密
         $insertData = $this->input->post('info[]');
         $insertData['password'] = md5(md5($insertData['password'] . $insertData['encrypt']));
         $res = $this->admin_model->insertOne($insertData);
         if ($res) {
             // addlog
             $this->addlog('adminid = ' . $res);
             // update admincache
             $this->load->library('updatecache');
             $this->updatecache->admincache();
             $this->msg('AddAdmin Success!', 'mzsj/admin/index');
         } else {
             $this->msg('AddAdmin Error!', uri_string());
         }
     } else {
         $data['encrypt'] = create_randomstr();
         $data['rolelist'] = $this->cache->get('rolecache');
         $this->load->view('mzsj/admin_addadmin', $data);
     }
     $this->load->view('mzsj/com_footer');
 }
开发者ID:freedomlizhigang,项目名称:CIDemo,代码行数:26,代码来源:Admin.php

示例2: password

 /**
  * 对用户的密码进行加密
  * @param $password
  * @param $encrypt //传入加密串,在修改密码时做认证
  * @return array/password
  */
 function password($password, $encrypt = '')
 {
     $pwd = array();
     $pwd['encrypt'] = $encrypt ? $encrypt : create_randomstr();
     $pwd['password'] = md5(md5(trim($password)) . $pwd['encrypt']);
     return $encrypt ? $pwd['password'] : $pwd;
 }
开发者ID:u0mo5,项目名称:app,代码行数:13,代码来源:Safe.php

示例3: info

 /**
  * 修改个人信息
  */
 public function info()
 {
     if (isset($_POST['dosubmit'])) {
         $info = I('post.info');
         if ($info['password'] == "") {
             // 不修改密码
             unset($info['password']);
             unset($info['pwdconfirm']);
         } else {
             if (trim($info['password']) != trim($info['pwdconfirm'])) {
                 $this->error("两次密码不一致");
                 exit;
             }
             unset($info['pwdconfirm']);
             $info['encrypt'] = create_randomstr();
             $info['password'] = password($info['password'], $info['encrypt']);
         }
         if (M('admin')->save($info)) {
             $this->success('更新成功');
         } else {
             $this->error('更新失败');
         }
     } else {
         $where['userid'] = session('userid');
         $data = M("admin")->where($where)->find();
         $this->assign("data", $data);
         //角色列表
         $rolelist = M("admin_role")->select();
         $this->assign("rolelist", $rolelist);
         //-----End
         $this->assign('data', $data);
         $this->display();
     }
 }
开发者ID:mracale,项目名称:myframe,代码行数:37,代码来源:IndexController.class.php

示例4: register

 /**
  * 用户注册
  * @param string $username 	用户名
  * @param string $password 	密码
  * @param string $email		email
  * @return int {-1:用户名已经存在 ;-2:email已存在;-4:用户名禁止注册;-5:邮箱禁止注册;-6:uc注册失败;int(uid):成功}
  */
 public function register()
 {
     $this->random = isset($this->data['random']) && !empty($this->data['random']) ? $this->data['random'] : create_randomstr(6);
     $this->password = isset($this->data['password']) ? create_password($this->data['password'], $this->random) : '';
     $this->email = isset($this->data['email']) ? $this->data['email'] : '';
     $this->type = isset($this->appid) ? 'app' : 'connect';
     $this->regip = isset($this->data['regip']) ? $this->data['regip'] : '';
     $this->appid = isset($this->appid) ? $this->appid : '';
     $this->appname = $this->applist[$this->appid]['name'];
     $checkname = $this->checkname(1);
     if ($checkname == -1) {
         exit('-1');
     } elseif ($checkname == -4) {
         exit('-4');
     }
     $checkemail = $this->checkemail(1);
     //UCenter会员注册
     $ucuserid = 0;
     if ($this->config['ucuse']) {
         pc_base::load_config('uc_config');
         require_once PHPCMS_PATH . 'api/uc_client/client.php';
         $uid = uc_user_register($this->username, $this->data['password'], $this->email, $this->random);
         if (is_numeric($uid)) {
             switch ($uid) {
                 case '-3':
                     exit('-1');
                     break;
                 case '-6':
                     exit('-2');
                     break;
                 case '-2':
                     exit('-4');
                     break;
                 case '-5':
                     exit('-5');
                     break;
                 case '-1':
                     exit('-4');
                     break;
                 case '-4':
                     exit('-5');
                     break;
                 default:
                     $ucuserid = $uid;
                     break;
             }
         } else {
             exit('-6');
         }
     }
     $data = array('username' => $this->username, 'password' => $this->password, 'email' => $this->email, 'regip' => $this->regip, 'regdate' => SYS_TIME, 'lastdate' => SYS_TIME, 'appname' => $this->appname, 'type' => $this->type, 'random' => $this->random, 'ucuserid' => $ucuserid);
     $uid = $this->db->insert($data, 1);
     /*插入消息队列*/
     $noticedata = $data;
     $noticedata['uid'] = $uid;
     messagequeue::add('member_add', $noticedata);
     exit("{$uid}");
     //exit($uid) 不可以If status is an integer, that value will also be used as the exit status.
 }
开发者ID:cfhb,项目名称:MIS,代码行数:66,代码来源:index.php

示例5: create_password

/**
 * 
 * @param $password ├▄┬в
 * @param $random ╦Т╗Щ╩§
 */
function create_password($password = '', $random = '')
{
    if (empty($random)) {
        $array['random'] = create_randomstr();
        $array['password'] = md5(md5($password) . $array['random']);
        return $array;
    }
    return md5(md5($password) . $random);
}
开发者ID:ahmatjan,项目名称:huluphp,代码行数:14,代码来源:global.func.php

示例6: register

 public function register()
 {
     $this->_session_start();
     //获取用户siteid
     $siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
     //定义站点id常量
     if (!defined('SITEID')) {
         define('SITEID', $siteid);
     }
     //加载用户模块配置
     $member_setting = getcache('member_setting');
     if (!$member_setting['allowregister']) {
         showmessage(L('deny_register'), 'index.php?m=member&c=index&a=login');
     }
     //加载短信模块配置
     $sms_setting_arr = getcache('sms', 'sms');
     $sms_setting = $sms_setting_arr[$siteid];
     header("Cache-control: private");
     if (isset($_POST['dosubmit'])) {
         if ($member_setting['enablcodecheck'] == '1') {
             //开启验证码
             if (empty($_SESSION['connectid']) && $_SESSION['code'] != strtolower($_POST['code']) && $_POST['code'] !== NULL || empty($_SESSION['code'])) {
                 showmessage(L('code_error'));
             } else {
                 $_SESSION['code'] = '';
             }
         }
         $userinfo = array();
         $userinfo['encrypt'] = create_randomstr(6);
         $userinfo['username'] = isset($_POST['username']) && is_username($_POST['username']) ? $_POST['username'] : exit('0');
         $userinfo['nickname'] = isset($_POST['nickname']) && is_username($_POST['nickname']) ? $_POST['nickname'] : '';
         $userinfo['email'] = isset($_POST['email']) && is_email($_POST['email']) ? $_POST['email'] : exit('0');
         $userinfo['password'] = isset($_POST['password']) && is_badword($_POST['password']) == false ? $_POST['password'] : exit('0');
         $userinfo['email'] = isset($_POST['email']) && is_email($_POST['email']) ? $_POST['email'] : exit('0');
         $userinfo['modelid'] = isset($_POST['modelid']) ? intval($_POST['modelid']) : 10;
         $userinfo['regip'] = ip();
         $userinfo['point'] = $member_setting['defualtpoint'] ? $member_setting['defualtpoint'] : 0;
         $userinfo['amount'] = $member_setting['defualtamount'] ? $member_setting['defualtamount'] : 0;
         $userinfo['regdate'] = $userinfo['lastdate'] = SYS_TIME;
         $userinfo['siteid'] = $siteid;
         $userinfo['connectid'] = isset($_SESSION['connectid']) ? $_SESSION['connectid'] : '';
         $userinfo['from'] = isset($_SESSION['from']) ? $_SESSION['from'] : '';
         //手机强制验证
         if ($member_setting[mobile_checktype] == '1') {
             //取用户手机号
             $mobile_verify = $_POST['mobile_verify'] ? intval($_POST['mobile_verify']) : '';
             if ($mobile_verify == '') {
                 showmessage('请提供正确的手机验证码!', HTTP_REFERER);
             }
             $sms_report_db = pc_base::load_model('sms_report_model');
             $posttime = SYS_TIME - 360;
             $where = "`id_code`='{$mobile_verify}' AND `posttime`>'{$posttime}'";
             $r = $sms_report_db->get_one($where, '*', 'id DESC');
             if (!empty($r)) {
                 $userinfo['mobile'] = $r['mobile'];
             } else {
                 showmessage('未检测到正确的手机号码!', HTTP_REFERER);
             }
         } elseif ($member_setting[mobile_checktype] == '2') {
             //获取验证码,直接通过POST,取mobile值
             $userinfo['mobile'] = isset($_POST['mobile']) ? $_POST['mobile'] : '';
         }
         if ($userinfo['mobile'] != "") {
             if (!preg_match('/^1([0-9]{9})/', $userinfo['mobile'])) {
                 showmessage('请提供正确的手机号码!', HTTP_REFERER);
             }
         }
         unset($_SESSION['connectid'], $_SESSION['from']);
         if ($member_setting['enablemailcheck']) {
             //是否需要邮件验证
             $userinfo['groupid'] = 7;
         } elseif ($member_setting['registerverify']) {
             //是否需要管理员审核
             $modelinfo_str = $userinfo['modelinfo'] = isset($_POST['info']) ? array2string(array_map("safe_replace", new_html_special_chars($_POST['info']))) : '';
             $this->verify_db = pc_base::load_model('member_verify_model');
             unset($userinfo['lastdate'], $userinfo['connectid'], $userinfo['from']);
             $userinfo['modelinfo'] = $modelinfo_str;
             $this->verify_db->insert($userinfo);
             showmessage(L('operation_success'), 'index.php?m=member&c=index&a=register&t=3');
         } else {
             //查看当前模型是否开启了短信验证功能
             $model_field_cache = getcache('model_field_' . $userinfo['modelid'], 'model');
             if (isset($model_field_cache['mobile']) && $model_field_cache['mobile']['disabled'] == 0) {
                 $mobile = $_POST['info']['mobile'];
                 if (!preg_match('/^1([0-9]{10})/', $mobile)) {
                     showmessage(L('input_right_mobile'));
                 }
                 $sms_report_db = pc_base::load_model('sms_report_model');
                 $posttime = SYS_TIME - 300;
                 $where = "`mobile`='{$mobile}' AND `posttime`>'{$posttime}'";
                 $r = $sms_report_db->get_one($where);
                 if (!$r || $r['id_code'] != $_POST['mobile_verify']) {
                     showmessage(L('error_sms_code'));
                 }
             }
             $userinfo['groupid'] = $this->_get_usergroup_bypoint($userinfo['point']);
         }
         if (pc_base::load_config('system', 'phpsso')) {
             $this->_init_phpsso();
             $status = $this->client->ps_member_register($userinfo['username'], $userinfo['password'], $userinfo['email'], $userinfo['regip'], $userinfo['encrypt']);
//.........这里部分代码省略.........
开发者ID:boylzj,项目名称:omguitar,代码行数:101,代码来源:index.php

示例7: admin_save

 public function admin_save()
 {
     $post = $this->input->post(NULL, TRUE);
     $update['nickname'] = $post['nickname'];
     $update['email'] = $post['email'];
     $update['tel'] = $post['tel'];
     $update['roleid'] = $post['roleid'];
     $update['addtime'] = date('Y-m-d H:i:s');
     if ($post['password']) {
         $update['password'] = md5($post['password']);
     }
     if ($id = $post['id']) {
         $this->db->where('id', $id)->update('admin', $update);
         $json = array('status' => 'success', 'msg' => '编辑管理员成功!', 'url' => ADMINURL . 'user/admin');
     } else {
         $update['username'] = $post['username'] ? $post['username'] : $this->_check_form('username');
         $update['encrypt'] = create_randomstr(6);
         if (empty($update['password'])) {
             $this->_check_form('password');
         }
         if ($query = $this->db->where(array('username' => $update['username']))->get('admin')->row_array()) {
             echo json_encode(array('status' => 'error', 'msg' => '【' . lang('username') . '】已存在!'));
             exit;
         }
         $this->db->insert('admin', $update);
         $json = array('status' => 'success', 'msg' => '新建管理员成功!', 'url' => ADMINURL . 'user/admin');
     }
     echo json_encode($json);
 }
开发者ID:tatfan,项目名称:fb_backend,代码行数:29,代码来源:ajax.php

示例8: editMy

 public function editMy()
 {
     //修改我的密码等
     $userid = $_SESSION['userid'];
     $M = M('admin');
     $password_edit = '';
     if ($_POST['password']) {
         $r = $M->get_one(array('userid' => $userid), 'password,encrypt');
         if (password($_POST['oldpassword'], $r['encrypt']) !== $r['password']) {
             $this->jsonResult(array('errno' => 1, 'errstr' => '旧密码错误'));
         }
         $data['encrypt'] = create_randomstr(6);
         $data['password'] = password($_POST['password'], $data['encrypt']);
         $password_edit = '111';
         //修改过密码
     }
     $data['email'] = $_POST['email'];
     $r = $M->update($data, array('userid' => $userid));
     if ($r !== false) {
         $this->jsonResult(array('errno' => 0, 'password_edit' => $password_edit));
     } else {
         $this->jsonResult(array('errno' => 1, 'errstr' => '修改失败'));
     }
 }
开发者ID:zhouzhouxs,项目名称:Progect,代码行数:24,代码来源:action.php

示例9: register

	public function register() {
		$this->_session_start();
		//加载用户模块配置
		$member_setting = getcache('member_setting');
		if(!$member_setting['allowregister']) {
			showmessage(L('deny_register'), 'index.php?m=member&c=index&a=login');
		}
		
		//获取用户siteid
		$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
		//定义站点id常量
		if (!defined('SITEID')) {
		   define('SITEID', $siteid);
		}
		
		header("Cache-control: private");
		if(isset($_POST['dosubmit'])) {
			if (empty($_SESSION['connectid']) && $_SESSION['code'] != strtolower($_POST['code'])) {
				showmessage(L('code_error'));
			}
			$userinfo = array();
			$userinfo['encrypt'] = create_randomstr(6);

			$userinfo['username'] = (isset($_POST['username']) && is_username($_POST['username'])) ? $_POST['username'] : exit('0');
			$userinfo['nickname'] = (isset($_POST['nickname']) && is_username($_POST['nickname'])) ? $_POST['nickname'] : '';
			
			$userinfo['email'] = (isset($_POST['email']) && is_email($_POST['email'])) ? $_POST['email'] : exit('0');
			$userinfo['password'] = isset($_POST['password']) ? $_POST['password'] : exit('0');
			
			$userinfo['email'] = (isset($_POST['email']) && is_email($_POST['email'])) ? $_POST['email'] : exit('0');

			$userinfo['modelid'] = isset($_POST['modelid']) ? intval($_POST['modelid']) : 10;
			$userinfo['regip'] = ip();
			$userinfo['point'] = $member_setting['defualtpoint'] ? $member_setting['defualtpoint'] : 0;
			$userinfo['amount'] = $member_setting['defualtamount'] ? $member_setting['defualtamount'] : 0;
			$userinfo['regdate'] = $userinfo['lastdate'] = SYS_TIME;
			$userinfo['siteid'] = $siteid;
			$userinfo['connectid'] = isset($_SESSION['connectid']) ? $_SESSION['connectid'] : '';
			$userinfo['from'] = isset($_SESSION['from']) ? $_SESSION['from'] : '';
			unset($_SESSION['connectid'], $_SESSION['from']);
			
			if($member_setting['enablemailcheck']) {	//是否需要邮件验证
				$userinfo['groupid'] = 7;
			} elseif($member_setting['registerverify']) {	//是否需要管理员审核
				$userinfo['modelinfo'] = isset($_POST['info']) ? array2string($_POST['info']) : '';
				$this->verify_db = pc_base::load_model('member_verify_model');
				unset($userinfo['lastdate'],$userinfo['connectid'],$userinfo['from']);
				$this->verify_db->insert($userinfo);
				showmessage(L('operation_success'), 'index.php?m=member&c=index&a=register&t=3');
			} else {
				$userinfo['groupid'] = $this->_get_usergroup_bypoint($userinfo['point']);
			}
			
			if(pc_base::load_config('system', 'phpsso')) {
				$this->_init_phpsso();
				$status = $this->client->ps_member_register($userinfo['username'], $userinfo['password'], $userinfo['email'], $userinfo['regip'], $userinfo['encrypt']);
				if($status > 0) {
					$userinfo['phpssouid'] = $status;
					//传入phpsso为明文密码,加密后存入phpcms_v9
					$userinfo['password'] = password($userinfo['password'], $userinfo['encrypt']);
					$userid = $this->db->insert($userinfo, 1);
					if($member_setting['choosemodel']) {	//如果开启选择模型
						//通过模型获取会员信息					
						require_once CACHE_MODEL_PATH.'member_input.class.php';
				        require_once CACHE_MODEL_PATH.'member_update.class.php';
						$member_input = new member_input($userinfo['modelid']);
						$user_model_info = $member_input->get($_POST['info']);
						$user_model_info['userid'] = $userid;
	
						//插入会员模型数据
						$this->db->set_model($userinfo['modelid']);
						$this->db->insert($user_model_info);
					}
					
					if($userid > 0) {
						//执行登陆操作
						if(!$cookietime) $get_cookietime = param::get_cookie('cookietime');
						$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
						$cookietime = $_cookietime ? TIME + $_cookietime : 0;
						
						if($userinfo['groupid'] == 7) {
							param::set_cookie('_username', $userinfo['username'], $cookietime);
							param::set_cookie('email', $userinfo['email'], $cookietime);							
						} else {
							$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
							$phpcms_auth = sys_auth($userid."\t".$userinfo['password'], 'ENCODE', $phpcms_auth_key);
							
							param::set_cookie('auth', $phpcms_auth, $cookietime);
							param::set_cookie('_userid', $userid, $cookietime);
							param::set_cookie('_username', $userinfo['username'], $cookietime);
							param::set_cookie('_nickname', $userinfo['nickname'], $cookietime);
							param::set_cookie('_groupid', $userinfo['groupid'], $cookietime);
							param::set_cookie('cookietime', $_cookietime, $cookietime);
						}
					}
					//如果需要邮箱认证
					if($member_setting['enablemailcheck']) {
						pc_base::load_sys_func('mail');
						$phpcms_auth_key = md5(pc_base::load_config('system', 'auth_key').$this->http_user_agent);
						$code = sys_auth($userid.'|'.md5($phpcms_auth_key), 'ENCODE', $phpcms_auth_key);
//.........这里部分代码省略.........
开发者ID:hxzyzz,项目名称:ddc,代码行数:101,代码来源:index.php


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