discuz二次开发:使用ucenter示例,开发属于自己的网站登录接口

2013-05-13 05:40 阅读 894 次 评论关闭

<?php
header("Content-Type: text/html; charset=gb2312");
include './config.inc.php';
include './uc_client/client.php';
include './include/db_mysql.class.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);

foreach(array('_COOKIE', '_POST', '_GET') as $_request) {
foreach($$_request as $_key => $_value) {
$_key{0} != '_' && $$_key = daddslashes($_value);
}
}

function daddslashes($string, $force = 0) {
!defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
if(!MAGIC_QUOTES_GPC || $force) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = daddslashes($val, $force);
}
} else {
$string = addslashes($string);
}
}
return $string;
}

if (isset($function)){
if($function=='login'){
user_login($loginId,$password);
}

}

function user_login($loginId,$password){
global $db,$tablepre;
$r=$db->fetch_first("select * from pre_ucenter_members where username='$loginId'");
echo "userid:".$r['uid'];
if($r['username'] ==$loginId){
$cmd5 = md5((md5($password).$r['salt']));
if($r['password'] == $cmd5){
$ucsynlogin = uc_user_synlogin($r['uid']);
if($ucsynlogin ==''){
echo '登录不成功';
}else{
echo '登录成功';
}
}
}

}

?>

更多discuz二次开发的教程:

版权声明:本文著作权归原作者所有,欢迎分享本文,谢谢支持!
转载请注明:discuz二次开发:使用ucenter示例,开发属于自己的网站登录接口 | 猎微网

评论已关闭!