当前位置:编程学习 > php >>

php中实现自动注册自动登录验证代码

 代码如下 复制代码

$urls = parse_url($db_bbsurl);
$domain = $urls['host'];
include_once (R_P .'require/admvclient.php');
$adm_oem= new Cnzz_Adm_Oem();
//判断config文件是否存在用户密码
pwCache::getData(D_P . "data/bbscache/adm_config.php");//用户名密码 配置文件
if (isset($adm_user) && isset($adm_pwd)) {
$request = array("adm_user"=>$adm_user,"adm_pwd"=>$adm_pwd,'cms'=>'pw');
$token = $adm_oem->get_appkey_once($request);
if ($token<0){
if($token==-1){
adminmsg('传递参数为空或传递参数非数字');
}else if($token==-2){
adminmsg('传递参数password错误');
}
}else{
$apikey = $token['adm_key'];
}
}else{
$Key = md5($domain.'KclGiq7H');
$request = array('cms'=>'pw','domain'=>$domain,'key'=>$Key);
$token = $adm_oem->reg_user_once($request);
if ($token<0){//异常
if($token==-1){
adminmsg('key有误');
} else if($token==-2){
adminmsg('域名长度有误(1~64)');
} elseif($token==-3){
adminmsg('域名输入有误(比如输入汉字)');
} elseif($token==-4){
adminmsg('域名插入数据库有误');
} elseif($token==-5){
adminmsg('IP用户调用页面超过阀值,阀值暂定为10');
}
} elseif (is_array($token) && isset($token)){
$adm_user = $token['adm_user'];
$adm_pwd = $token['adm_pwd'];
$apikey = $token['adm_key'];
pwCache::setData(D_P.'data/bbscache/adm_config.php',"<?phprn$adm_user=".$adm_user.";rn$adm_pwd=".$adm_pwd."rn?>");
}
}
补充:Php教程,Php高级应用 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,