嘿嘿,我的独立博客对应的地址:http://imzc.net/show-102-1.html
第一步:
定位到source/do_login.php,找到如下函数:
PHP代码
-
- if(!$passport = getpassport($username, $password)) {
- showmessage('login_failure_please_re_login', 'do.php?ac='.$_SCONFIG['login_action']);
- }
上示函数便是登陆的第一步处理函数,再次定位:
source/function_common.php,找到如下函数:
PHP代码
-
- function getpassport($username, $password) {
- global $_SGLOBAL, $_SC;
-
- $passport = array();
- if(!@include_once S_ROOT.'./uc_client/client.php') {
- showmessage('system_error');
- }
-
- $ucresult = uc_user_login($username, $password);
- if($ucresult[0] > 0) {
- $passport['uid'] = $ucresult[0];
- $passport['username'] = $ucresult[1];
- $passport['email'] = $ucresult[3];
- }
- return $passport;
- }
至此,我们可以发现现在开始和uc_client相关函数关联了.我们进入uc_client文件夹,开始分析,定位至:uc_client/client.php
PHP代码
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function uc_user_login($username, $password, $isuid = 0, $checkques = 0, $questionid = '', $answer = '') {
- $isuid = intval($isuid);
-
- $return = call_user_func(UC_API_FUNC, 'user', 'login', array('username'=>$username, 'password'=>$password, 'isuid'=>$isuid, 'checkques'=>$checkques, 'questionid'=>$questionid, 'answer'=>$answer));
- return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
- }
因为是mysql,故,call_user_func()函数,将参数传给
uc_client/client.php =>
PHP代码
-
-
-
-
-
-
-
-
-
- function uc_api_mysql($model, $action, $args=array()) {
-
-
- global $uc_controls;
- if(empty($uc_controls[$model])) {
-
- include_once UC_ROOT.'./lib/db.class.php';
- include_once UC_ROOT.'./model/base.php';
- include_once UC_ROOT."./control/$model.php";
- eval("\$uc_controls['$model'] = new {$model}control();");
-
- }
- if($action{0} != '_') {
- $args = uc_addslashes($args, 1, TRUE);
- $action = 'on'.$action;
- $uc_controls[$model]->input = $args;
-
-
- return $uc_controls[$model]->$action($args);
- } else {
- return '';
- }
- }
我们看看
PHP代码
-
- function onlogin() {
- $this->init_input();
- $isuid = $this->input('isuid');
- $username = $this->input('username');
- $password = $this->input('password');
- $checkques = $this->input('checkques');
- $questionid = $this->input('questionid');
- $answer = $this->input('answer');
- if($isuid) {
- $user = $_ENV['user']->get_user_by_uid($username);
- } else {
- $user = $_ENV['user']->get_user_by_username($username);
- }
- //这部分即可改动
- $passwordmd5 = preg_match('/^\w{32}$/', $password) ? $password : md5($password);
-
- if(empty($user)) {
- $status = -1;
- } elseif($user['password'] != md5($passwordmd5.$user['salt'])) {
- $status = -2;
- } elseif($checkques && $user['secques'] != '' && $user['secques'] != $_ENV['user']->quescrypt($questionid, $answer)) {
- $status = -3;
- } else {
- $status = $user['uid'];
- }
- $merge = $status != -1 && !$isuid && $_ENV['user']->check_mergeuser($username) ? 1 : 0;
- return array($status, $user['username'], $password, $user['email'], $merge);
- }
可以改成如下形式:
PHP代码
-
- function onlogin($type='myself') {
- $this->init_input();
- $isuid = $this->input('isuid');
- $username = $this->input('username');
- $password = $this->input('password');
- $checkques = $this->input('checkques');
- $questionid = $this->input('questionid');
- $answer = $this->input('answer');
- if($isuid) {
- $user = $_ENV['user']->get_user_by_uid($username);
- } else {
- $user = $_ENV['user']->get_user_by_username($username);
- }
-
- $passwordmd5 = preg_match('/^\w{32}$/', $password) ? $password : md5($password);
-
- $type='myself';
- if($type=='myself')
- {
- echo '$password:'.$password.'<br>';
- $testmd5 = md5('test');
-
-
-
-
- if(emptyempty($user)) {
- $status = -1;
- } elseif($user['password'] != $passwordmd5) {
- $status = -2;
- } elseif($checkques && $user['secques'] != '' && $user['secques'] != $_ENV['user']->quescrypt($questionid, $answer)) {
- $status = -3;
- } else {
- $status = $user['uid'];
- }
-
-
- }else{
- if(emptyempty($user)) {
- $status = -1;
- } elseif($user['password'] != md5($passwordmd5.$user['salt'])) {
- $status = -2;
- } elseif($checkques && $user['secques'] != '' && $user['secques'] != $_ENV['user']->quescrypt($questionid, $answer)) {
- $status = -3;
- } else {
- $status = $user['uid'];
- }
- }
- $merge = $status != -1 && !$isuid && $_ENV['user']->check_mergeuser($username) ? 1 : 0;
- return array($status, $user['username'], $password, $user['email'], $merge);
- }
PHP代码
- function check_login($username, $password, &$user) {
- $user = $this->get_user_by_username($username);
- if(empty($user['username'])) {
- return -1;
- } elseif($user['password'] != md5(md5($password).$user['salt'])) {
- return -2;
- }
- return $user['uid'];
- }
且行且珍惜...
作者资料:
O(∩_∩)O川zc
我的主页 个人资料
我的闪存 与我联系