本文整理汇总了PHP中Func::getRandomCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Func::getRandomCode方法的具体用法?PHP Func::getRandomCode怎么用?PHP Func::getRandomCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Func
的用法示例。
在下文中一共展示了Func::getRandomCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: signUp
//.........这里部分代码省略.........
$data['enterprise_name'] = $enterprise_name;
}
$data['identity'] = $identity = isset($_COOKIE['identity']) ? $_COOKIE['identity'] : null;
$legal_identitys = isset($_COOKIE['legal_identity']) ? $_COOKIE['legal_identity'] : null;
if ($legal_identitys && 'null' != $legal_identitys) {
$data['legal_identity'] = $legal_identitys;
}
$data['legal_name'] = $legal_name = isset($_COOKIE['legal_name']) ? $_COOKIE['legal_name'] : null;
$data['type'] = $type = isset($_POST['type']) ? $_POST['type'] : null;
if (1 == $type) {
if (!$enterprise_name || !$identity || !$legal_identitys || !$legal_name) {
ABase::toJson(1, '注册信息不完整');
}
} else {
if (!$identity || !$legal_name) {
ABase::toJson(1, '注册信息不完整');
}
}
$data['email'] = isset($_COOKIE['email']) ? $_COOKIE['email'] : null;
$data['username_phone'] = $user_phone;
$userid = Users::signUp($data);
if ($userid) {
$rdata['user_id'] = $userid;
$rdata['module_id'] = 2;
$rdata['receiver_name'] = $legal_name;
$rdata['receiver_phone'] = $user_phone;
$rdata['receiver_province'] = isset($_COOKIE['province']) ? $_COOKIE['province'] : 0;
$rdata['receiver_city'] = isset($_COOKIE['city']) ? $_COOKIE['city'] : 0;
$rdata['receiver_county'] = isset($_COOKIE['county']) ? $_COOKIE['county'] : 0;
$rdata['receiver_address'] = isset($_COOKIE['address']) ? $_COOKIE['address'] : null;
$rdata['receiver_postcode'] = isset($_COOKIE['postcode']) ? $_COOKIE['postcode'] : null;
$receiver_address_id = ReceiverAddress::add($rdata);
$user = Users::getData($userid);
$utype = isset($user['type']) ? (int) $user['type'] : 0;
$user_code = isset($user['user_code']) ? $user['user_code'] : '';
$legal_name = isset($user['legal_name']) ? $user['legal_name'] : '';
$enterprise_name = isset($user['enterprise_name']) ? $user['enterprise_name'] : '';
$status = isset($user['status']) ? (int) $user['status'] : 0;
$_SESSION['user'] = $user_phone;
$_SESSION['userid'] = $userid;
$_SESSION['user_code'] = $user_code;
$_SESSION['usertype'] = $utype;
$_SESSION['name'] = $utype ? $enterprise_name : $legal_name;
$_SESSION['userstatus'] = $status;
if (isset($_SESSION['tmp_user'])) {
unset($_SESSION['tmp_user']);
}
if (isset($_SESSION['dxyzm'])) {
unset($_SESSION['dxyzm']);
}
if (isset($_SESSION['signin_token'])) {
unset($_SESSION['signin_token']);
}
if (isset($_SESSION['signin_num'])) {
unset($_SESSION['signin_num']);
}
if (isset($_SESSION['dxyzm_send_num'])) {
unset($_SESSION['dxyzm_send_num']);
}
if ($receiver_address_id) {
Users::update($userid, array('receiver_address_id' => $receiver_address_id));
}
ABase::toJson(0, 'ok');
} else {
ABase::toJson(1, '注册失败,请重试');
}
} else {
ABase::toJson(1, '验证码错误');
}
} else {
$type = isset($_GET['t']) ? (int) $_GET['t'] : 0;
//0:个人,1:企业
$step = isset($_GET['s']) ? (int) $_GET['s'] : 1;
//下一步
if ($step < 1) {
$step = 1;
}
$tmp_user = isset($_SESSION['tmp_user']) ? $_SESSION['tmp_user'] : '';
//保存在输入框的临时信息
$tmp_get_yzm = isset($_SESSION['tmp_get_yzm']) ? (int) $_SESSION['tmp_get_yzm'] : 0;
//重复点击获取验证码按钮刷新后的自动触发
if (isset($_SESSION['tmp_get_yzm'])) {
unset($_SESSION['tmp_get_yzm']);
}
$provinces = Countys::getCountys();
$token = ABase::token();
$signin_token = $_SESSION['signin_token'] = Func::getRandomCode(30);
$user = isset($_SESSION['user']) ? $_SESSION['user'] : null;
Templates::Assign('user', $user);
Templates::Assign('tmp_user', $tmp_user);
Templates::Assign('tmp_get_yzm', $tmp_get_yzm);
Templates::Assign('provinces', $provinces);
Templates::Assign('type', $type);
Templates::Assign('step', $step);
Templates::Assign('token', $token);
Templates::Assign('signin_token', $signin_token);
Templates::Assign('errormsg', $errormsg);
Templates::Display('signup.html');
}
}
示例2: token
static function token($token = '')
{
if (!session_id()) {
session_start();
}
if (!$token) {
$token = $_SESSION['token'] = Func::getRandomCode(20);
return $token;
} else {
$stoken = isset($_SESSION['token']) ? $_SESSION['token'] : '';
if (isset($_SESSION['token'])) {
unset($_SESSION['token']);
}
if ($token === $stoken) {
return true;
}
return false;
}
}