uchome登陆机制分析Word下载.docx

上传人:b****5 文档编号:17511508 上传时间:2022-12-06 格式:DOCX 页数:5 大小:16.73KB
下载 相关 举报
uchome登陆机制分析Word下载.docx_第1页
第1页 / 共5页
uchome登陆机制分析Word下载.docx_第2页
第2页 / 共5页
uchome登陆机制分析Word下载.docx_第3页
第3页 / 共5页
uchome登陆机制分析Word下载.docx_第4页
第4页 / 共5页
uchome登陆机制分析Word下载.docx_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

uchome登陆机制分析Word下载.docx

《uchome登陆机制分析Word下载.docx》由会员分享,可在线阅读,更多相关《uchome登陆机制分析Word下载.docx(5页珍藏版)》请在冰豆网上搜索。

uchome登陆机制分析Word下载.docx

@include_onceS_ROOT.'

./uc_client/client.php'

){ 

system_error'

);

$ucresult=uc_user_login($username,$password);

if($ucresult[0]>

0){ 

$passport['

uid'

]=$ucresult[0];

username'

]=$ucresult[1];

email'

]=$ucresult[3];

return$passport;

至此,我们可以发现现在开始和uc_client相关函数关联了.我们进入uc_client文件夹,开始分析,定位至:

uchome_ROOT/uc_client/client.php

/** 

*用户登陆检查 

*@paramstring$username 

用户名/uid 

*@paramstring$password 

密码 

*@paramint$isuid 

是否为uid 

*@paramint$checkques 

是否使用检查安全问答 

*@paramint$questionid 

安全提问 

*@paramstring$answer 

安全提问答案 

*@returnarray(uid/status,username,password,email) 

数组第一项 

:

成功 

-1:

用户不存在,或者被删除 

-2:

密码错 

*/ 

functionuc_user_login($username,$password,$isuid=0,$checkques=0,$questionid='

'

$answer='

$isuid=intval($isuid);

//define('

UC_API_FUNC'

UC_CONNECT=='

mysql'

?

'

uc_api_mysql'

uc_api_post'

$return=call_user_func(UC_API_FUNC,'

user'

login'

array('

=>

$username,'

password'

$password,'

isuid'

$isuid,'

checkques'

$checkques,'

questionid'

$questionid,'

answer'

$answer));

returnUC_CONNECT=='

$return:

uc_unserialize($return);

因为是mysql,故,UC_API_FUNC的值为uc_api_mysql,通过call_user_func()函数,将参数传给uc_api_mysql(),下面进入最关键的函数了:

uchome_ROOT/uc_client/client.php=>

uc_api_mysql()

*MYSQL方式取指定的模块和动作的数据 

*@paramstring$model 

请求的模块 

*@paramstring$action 

请求的动作 

*@paramstring$args 

参数(会加密的方式传送) 

*@returnmix 

functionuc_api_mysql($model,$action,$args=array()){ 

//$model='

$action='

 

//$args=Array([username]=>

test2[password]=>

test[isuid]=>

0[checkques]=>

0[questionid]=>

[answer]=>

) 

global$uc_controls;

if(empty($uc_controls[$model])){ 

//UC_ROOTuc_client/ 

include_onceUC_ROOT.'

./lib/db.class.php'

;

./model/base.php'

include_onceUC_ROOT."

./control/$model.php"

eval("

\$uc_controls['

$model'

]=new{$model}control();

"

//uc_client/control/user.php,usercontrol()类(继承至base基类)实例化 

if($action{0}!

='

_'

$args=uc_addslashes($args,1,TRUE);

$action='

on'

.$action;

//onlogin,usercontrol()中的方法,可以考虑改造此函数以实现预定功能 

$uc_controls[$model]->

input=$args;

//base.php,base基类的方法 

//returnArray([0]=>

3[1]=>

test2[2]=>

test[3]=>

test@[4]=>

0) 

return$uc_controls[$model]->

$action($args);

//返回预定数组,供调用函数分析 

}else{ 

return'

我们看看usercontrol类的onlogin()方法:

uchome_ROOT/uc_client/control/user.php

//notepublic外部接口登陆接口 

functiononlogin(){ 

$this->

init_input();

$isuid=$this->

input('

$username=$this->

$password=$this->

$checkques=$this->

$questionid=$this->

$answer=$this->

if($isuid){ 

$user=$_ENV['

]->

get_user_by_uid($username);

get_user_by_username($username);

//这部分即可改动

$passwordmd5=preg_match('

/^\w{32}$/'

$password)?

$password:

md5($password);

//note用户名不存在 

if(empty($user)){ 

$status=-1;

}elseif($user['

]!

=md5($passwordmd5.$user['

salt'

])){ 

$status=-2;

}elseif($checkques&

&

$user['

secques'

&

=$_ENV['

quescrypt($questionid,$answer)){ 

$status=-3;

$status=$user['

];

$merge=$status!

=-1&

!

$isuid&

$_ENV['

check_mergeuser($username)?

1:

0;

returnarray($status,$user['

],$password,$user['

],$merge);

可以改成如下形式:

//notepublic外部接口登陆接 

functiononlogin($type='

myself'

$type='

if($type=='

) 

echo'

$password:

.$password.'

<

br>

$testmd5=md5('

test'

//假设数据库中保持的所有的密码为test 

// 

print_r($passwordmd5);

print_r($user);

if(emptyempty($user)){ 

=$passwordmd5){ 

$statusz:

.$status.'

die();

}else{ 

至此,我们可以更改uchome默认的认证方式了,如果这里更改了,以后相关的也需要作出更改,这个就留下大家自己去跟踪调试了.

tips:

uchome_ROOT/uc_client/model/user.php下还有一个check_login(),这个函数暂时没有找到调用的地方.

1.function 

check_login($username, 

$password, 

$user) 

2. 

$user 

$this->

3. 

if(empty($user['

])) 

4. 

return 

-1;

5. 

elseif($user['

!

md5(md5($password).$user['

6. 

-2;

7. 

8. 

$user['

9.} 

eclipsePDT还是不错的,可以试试这个IDE.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 高中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1