博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Discuz! X2.5(PHP) 集合 CAS 单点登录

Posted on 2013-03-26 23:28  蜗牛57  阅读(3819)  评论(2编辑  收藏  举报

  首先在自己的主机搭载CAS认证系统,前人的blog把步骤写的已经很详细了,不做赘述,可以参考下面的三篇文章:

  http://www.cnblogs.com/arix04/archive/2009/08/06/1540103.html

  http://blog.csdn.net/id19870510/article/details/5653177

  http://www.kafeitu.me/sso/2010/11/05/sso-cas-full-course.html

 

  然后搭载Discuz! X2.5 平台,这个比较简单,我用的是wamp集成服务器,直接next、next...就可以了。

  之后配置PHP的CAS,先下载客户端: http://downloads.jasig.org/cas-clients/php/ 我下载的是1.3.1,然后将解压后的CAS文件夹和CAS.php复制到

  你所对应的工程下,不过可以先建立一个案例测试一下。先建立了一个casPHP工程文件,将两个文件copy过去后,新建了一个example.php 作为登录客户端,代码如下:

  

View Code
 1 <?php
 2 //
 3 // phpCAS simple client
 4 //
 5  
 6 // import phpCAS lib
 7 include_once('CAS.php');//注意这个
 8  
 9 phpCAS::setDebug();
10  
11 // initialize phpCAS
12 phpCAS::client(CAS_VERSION_2_0,'www.woniu.com',8443,'cas');
13  
14 // no SSL validation for the CAS server
15 phpCAS::setNoCasServerValidation();
16  
17 // force CAS authentication
18 phpCAS::forceAuthentication();
19  
20 // at this step, the user has been authenticated by the CAS server
21 // and the user's login name can be read with phpCAS::getUser().
22  
23 // logout if desired
24 if (isset($_REQUEST['logout'])) {
25          phpCAS::logout();
26 }
27  
28 // for this test, simply print that the authentication was successfull
29 ?>
30 <html>
31   <head>
32     <title>phpCAS simple client</title>
33     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
34   </head>
35   <body>
36     <h1>Successfull Authentication!</h1>
37     <p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
38     <p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
39      //用来测试的java客户端
40          <p><a href="http://localhost:8080/Temp/servlet/helloworld">去java客户端测试</a></p>        
41     <p><a href="?logout=">Logout</a></p>
42   </body>
43 </html>

  

  访问 http://localhost/casPHP/example.php

  

也许你会看到类似这样的错误提示:

Fatal error: Call to undefined function curl_init() in D:\javasoft\PHP\wamp\www\CAS\Request\CurlRequest.php   on line 64它说curl_init()

这个方法没被定义。

 

 

  

;extension=php_curl.dll前面的分号去掉就可以了。至此,PHP的CAS就配置好了。

  Discuz! X2.5中操作也差不多。首先将CAS文件和CAS.php拷贝过去。我的工程名为Discuz2.5,所以拷贝到Discuz2.5目录下。

  然后要做的就是修改工程中的三个文件,由于我对PHP也不是很熟悉,所以这里就直接给出代码,请自行修改。如果有懂PHP的欢迎对其作出补充完善。

 

   

 

  首先是修改文件 Discuz2.5\upload\source\class\class_member.php ,可以直接替换

 

 

  

View Code
  1 <?php
  2 
  3 /**
  4  *      [Discuz!] (C)2001-2099 Comsenz Inc.
  5  *      This is NOT a freeware, use is subject to license terms
  6  *
  7  *      $Id: class_member.php 30465 2012-05-30 04:10:03Z zhengqingpeng $
  8  */
  9 
 10 if(!defined('IN_DISCUZ')) {
 11     exit('Access Denied');
 12 }
 13 
 14 class logging_ctl {
 15 
 16     function logging_ctl() {
 17         require_once libfile('function/misc');
 18         loaducenter();
 19     }
 20 
 21     function logging_more($questionexist) {
 22         global $_G;
 23         if(empty($_GET['lssubmit'])) {
 24             return;
 25         }
 26         $auth = authcode($_GET['username']."\t".$_GET['password']."\t".($questionexist ? 1 : 0), 'ENCODE');
 27         $js = '<script type="text/javascript">showWindow(\'login\', \'member.php?mod=logging&action=login&auth='.rawurlencode($auth).'&referer='.rawurlencode(dreferer()).(!empty($_GET['cookietime']) ? '&cookietime=1' : '').'\')</script>';
 28         showmessage('location_login', '', array('type' => 1), array('extrajs' => $js));
 29     }
 30 
 31     function on_login() {
 32         global $_G;
 33         if($_G['uid']) {
 34             $referer = dreferer();
 35             $ucsynlogin = $this->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
 36             $param = array('username' => $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['member']['uid']);
 37             showmessage('login_succeed', $referer ? $referer : './', $param, array('showdialog' => 1, 'locationtime' => true, 'extrajs' => $ucsynlogin));
 38         }
 39 
 40         $from_connect = $this->setting['connect']['allow'] && !empty($_GET['from']) ? 1 : 0;
 41         $seccodecheck = $from_connect ? false : $this->setting['seccodestatus'] & 2;
 42         $seccodestatus = !empty($_GET['lssubmit']) ? false : $seccodecheck;
 43         $invite = getinvite();
 44 
 45         if(1==2) {
 46 
 47             $auth = '';
 48             $username = !empty($_G['cookie']['loginuser']) ? dhtmlspecialchars($_G['cookie']['loginuser']) : '';
 49 
 50             if(!empty($_GET['auth'])) {
 51                 list($username, $password, $questionexist) = explode("\t", authcode($_GET['auth'], 'DECODE'));
 52                 $username = dhtmlspecialchars($username);
 53                 if($username && $password) {
 54                     $auth = dhtmlspecialchars($_GET['auth']);
 55                 } else {
 56                     $auth = '';
 57                 }
 58             }
 59 
 60             $cookietimecheck = !empty($_G['cookie']['cookietime']) || !empty($_GET['cookietime']) ? 'checked="checked"' : '';
 61 
 62             if($seccodecheck) {
 63                 $seccode = random(6, 1) + $seccode{0} * 1000000;
 64             }
 65 
 66             if($this->extrafile && file_exists($this->extrafile)) {
 67                 require_once $this->extrafile;
 68             }
 69 
 70             $navtitle = lang('core', 'title_login');
 71             include template($this->template);
 72 
 73         } else {
 74 
 75             if(!empty($_GET['auth'])) {
 76                 list($_GET['username'], $_GET['password']) = daddslashes(explode("\t", authcode($_GET['auth'], 'DECODE')));
 77             }
 78 
 79              
 80             if($_GET['fastloginfield']) {
 81                 $_GET['loginfield'] = $_GET['fastloginfield'];
 82             }
 83             $_G['uid'] = $_G['member']['uid'] = 0;
 84             $_G['username'] = $_G['member']['username'] = $_G['member']['password'] = '';
 85             
 86             //================================================
 87 define('CAS_ENABLE', true);
 88 define('CAS_SERVER_HOSTNAME', "www.woniu.com");
 89 define('CAS_SERVER_PORT', 8443);
 90 define('CAS_SERVER_APP_NAME', "cas");
 91 
 92  
 93 require_once  './CAS.php';
 94 require_once  './CAS/Client.php';
 95 require_once  './CAS/Proxychain/AllowedList.php';
 96 require_once  './CAs/Request/RequestInterface.php';
 97 require_once  './CAs/Request/AbstractRequest.php';
 98 require_once  './CAS/Request/CurlRequest.php';
 99 
100 
101 
102  
103 phpCAS::client(CAS_VERSION_2_0, CAS_SERVER_HOSTNAME, CAS_SERVER_PORT, CAS_SERVER_APP_NAME);
104 //不使用SSL服务校验
105 phpCAS::setNoCasServerValidation();
106 phpCAS::handleLogoutRequests();  
107 phpCAS::forceAuthentication();
108 
109     
110 $auth1 = phpCAS::checkAuthentication();
111 $cas='';
112 
113 
114 if($auth1){
115 $cas = phpCAS::getUser();
116 
117 }else{
118     showmessage('尚未登录,<a href="#" onclick="return gocas();">前去登录</a>');
119 }
120 
121 
122              $_GET['username']=$cas;
123             // $_GET['password']=$username;
124             $result = userlogin($_GET['username'], $_GET['password'], $_GET['questionid'], $_GET['answer'], $this->setting['autoidselect'] ? 'auto' : $_GET['loginfield'], $_G['clientip']);
125             $uid = $result['ucresult']['uid'];
126 
127             if(!empty($_GET['lssubmit']) && ($result['ucresult']['uid'] == -3 || $seccodecheck && $result['status'] > 0)) {
128                 $_GET['username'] = $result['ucresult']['username'];
129                 $this->logging_more($result['ucresult']['uid'] == -3);
130             }
131 
132             if($result['status'] == -1) {
133                 if(!$this->setting['fastactivation']) {
134                     $auth = authcode($result['ucresult']['username']."\t".FORMHASH, 'ENCODE');
135                     showmessage('location_activation', 'member.php?mod='.$this->setting['regname'].'&action=activation&auth='.rawurlencode($auth).'&referer='.rawurlencode(dreferer()), array(), array('location' => true));
136                 } else {
137                     $init_arr = explode(',', $this->setting['initcredits']);
138                     $groupid = $this->setting['regverify'] ? 8 : $this->setting['newusergroupid'];
139 
140                     C::t('common_member')->insert($uid, $result['ucresult']['username'], md5(random(10)), $result['ucresult']['email'], $_G['clientip'], $groupid, $init_arr);
141                     $result['member'] = getuserbyuid($uid);
142                     $result['status'] = 1;
143                 }
144             }
145 
146             if($result['status'] > 0) {
147 
148                 if($this->extrafile && file_exists($this->extrafile)) {
149                     require_once $this->extrafile;
150                 }
151 
152                 setloginstatus($result['member'], $_GET['cookietime'] ? 2592000 : 0);
153                 checkfollowfeed();
154 
155                 C::t('common_member_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'lastvisit' =>TIMESTAMP, 'lastactivity' => TIMESTAMP));
156                 $ucsynlogin = $this->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
157 
158                 if($invite['id']) {
159                     $result = C::t('common_invite')->count_by_uid_fuid($invite['uid'], $uid);
160                     if(!$result) {
161                         C::t('common_invite')->update($invite['id'], array('fuid'=>$uid, 'fusername'=>$_G['username']));
162                         updatestat('invite');
163                     } else {
164                         $invite = array();
165                     }
166                 }
167                 if($invite['uid']) {
168                     require_once libfile('function/friend');
169                     friend_make($invite['uid'], $invite['username'], false);
170                     dsetcookie('invite_auth', '');
171                     if($invite['appid']) {
172                         updatestat('appinvite');
173                     }
174                 }
175 
176                 $param = array(
177                     'username' => $result['ucresult']['username'],
178                     'usergroup' => $_G['group']['grouptitle'],
179                     'uid' => $_G['member']['uid'],
180                     'groupid' => $_G['groupid'],
181                     'syn' => $ucsynlogin ? 1 : 0
182                 );
183 
184                 $extra = array(
185                     'showdialog' => true,
186                     'locationtime' => true,
187                     'extrajs' => $ucsynlogin
188                 );
189 
190                 $loginmessage = $_G['groupid'] == 8 ? 'login_succeed_inactive_member' : 'login_succeed';
191 
192                 $location = $invite || $_G['groupid'] == 8 ? 'home.php?mod=space&do=home' : dreferer();
193                 if(empty($_GET['handlekey']) || !empty($_GET['lssubmit'])) {
194                     if(defined('IN_MOBILE')) {
195                         showmessage('location_login_succeed_mobile', $location, array('username' => $result['ucresult']['username']), array('location' => true));
196                     } else {
197                         if(!empty($_GET['lssubmit'])) {
198                             if(!$ucsynlogin) {
199                                 $extra['location'] = true;
200                             }
201                             showmessage($loginmessage, $location, $param, $extra);
202                         } else {
203                             $href = str_replace("'", "\'", $location);
204                             showmessage('location_login_succeed', $location, array(),
205                                 array(
206                                     'showid' => 'succeedmessage',
207                                     'extrajs' => '<script type="text/javascript">'.
208                                         'setTimeout("window.location.href =\''.$href.'\';", 3000);'.
209                                         '$(\'succeedmessage_href\').href = \''.$href.'\';'.
210                                         '$(\'main_message\').style.display = \'none\';'.
211                                         '$(\'main_succeed\').style.display = \'\';'.
212                                         '$(\'succeedlocation\').innerHTML = \''.lang('message', $loginmessage, $param).'\';</script>'.$ucsynlogin,
213                                     'striptags' => false,
214                                     'showdialog' => true
215                                 )
216                             );
217                         }
218                     }
219                 } else {
220                     showmessage($loginmessage, $location, $param, $extra);
221                 }
222             } else {
223                 $password = preg_replace("/^(.{".round(strlen($_GET['password']) / 4)."})(.+?)(.{".round(strlen($_GET['password']) / 6)."})$/s", "\\1***\\3", $_GET['password']);
224                 $errorlog = dhtmlspecialchars(
225                     TIMESTAMP."\t".
226                     ($result['ucresult']['username'] ? $result['ucresult']['username'] : $_GET['username'])."\t".
227                     $password."\t".
228                     "Ques #".intval($_GET['questionid'])."\t".
229                     $_G['clientip']);
230                 writelog('illegallog', $errorlog);
231                 loginfailed($_GET['username']);
232                 $fmsg = $result['ucresult']['uid'] == '-3' ? (empty($_GET['questionid']) || $answer == '' ? 'login_question_empty' : 'login_question_invalid') : 'login_invalid';
233                 if($_G['member_loginperm'] > 1) {
234                     showmessage($fmsg, '', array('loginperm' => $_G['member_loginperm'] - 1));
235                 } elseif($_G['member_loginperm'] == -1) {
236                     showmessage('login_password_invalid');
237                 } else {
238                     showmessage('login_strike');
239                 }
240             }
241 
242         }
243 
244     }
245 
246     function on_logout() {
247         global $_G;
248 
249         $ucsynlogout = $this->setting['allowsynlogin'] ? uc_user_synlogout() : '';
250 
251         if($_GET['formhash'] != $_G['formhash']) {
252             showmessage('logout_succeed', dreferer(), array('formhash' => FORMHASH, 'ucsynlogout' => $ucsynlogout));
253         }
254 
255         clearcookies();
256         $_G['groupid'] = $_G['member']['groupid'] = 7;
257         $_G['uid'] = $_G['member']['uid'] = 0;
258         $_G['username'] = $_G['member']['username'] = $_G['member']['password'] = '';
259         $_G['setting']['styleid'] = $this->setting['styleid'];
260         
261         //================================================
262 define('CAS_ENABLE', true);
263 define('CAS_SERVER_HOSTNAME', "www.woniu.com");
264 define('CAS_SERVER_PORT', 8443);
265 define('CAS_SERVER_APP_NAME', "cas");
266 
267  
268 require_once  './CAS.php';
269 require_once  './CAS/Client.php';
270 require_once  './CAS/ProxyChain/AllowedList.php';
271 require_once  './CAs/Request/RequestInterface.php';
272 require_once  './CAs/Request/AbstractRequest.php';
273 require_once  './CAS/Request/CurlRequest.php';
274 
275 
276  
277 phpCAS::client(CAS_VERSION_2_0, CAS_SERVER_HOSTNAME, CAS_SERVER_PORT, CAS_SERVER_APP_NAME);
278 
279  
280 $param=array("service"=>"http://localhost");
281 
282  phpCAS::logout($param);
283 
284 
285         showmessage('logout_succeed', dreferer(), array('formhash' => FORMHASH, 'ucsynlogout' => $ucsynlogout));
286     }
287 
288 }
289 
290 class register_ctl {
291 
292     var $showregisterform = 1;
293 
294     function register_ctl() {
295         global $_G;
296         if($_G['setting']['bbclosed']) {
297             if(($_GET['action'] != 'activation' && !$_GET['activationauth']) || !$_G['setting']['closedallowactivation'] ) {
298                 showmessage('register_disable', NULL, array(), array('login' => 1));
299             }
300         }
301 
302         loadcache(array('modreasons', 'stamptypeid', 'fields_required', 'fields_optional', 'fields_register', 'ipctrl'));
303         require_once libfile('function/misc');
304         require_once libfile('function/profile');
305         if(!function_exists('sendmail')) {
306             include libfile('function/mail');
307         }
308         loaducenter();
309     }
310 
311     function on_register() {
312         global $_G;
313 
314         $_GET['username'] = $_GET[''.$this->setting['reginput']['username']];
315         $_GET['password'] = $_GET[''.$this->setting['reginput']['password']];
316         $_GET['password2'] = $_GET[''.$this->setting['reginput']['password2']];
317         $_GET['email'] = $_GET[''.$this->setting['reginput']['email']];
318 
319         if($_G['uid']) {
320             $ucsynlogin = $this->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
321             $url_forward = dreferer();
322             if(strpos($url_forward, $this->setting['regname']) !== false) {
323                 $url_forward = 'forum.php';
324             }
325             showmessage('login_succeed', $url_forward ? $url_forward : './', array('username' => $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid']), array('extrajs' => $ucsynlogin));
326         } elseif(!$this->setting['regclosed'] && (!$this->setting['regstatus'] || !$this->setting['ucactivation'])) {
327             if($_GET['action'] == 'activation' || $_GET['activationauth']) {
328                 if(!$this->setting['ucactivation'] && !$this->setting['closedallowactivation']) {
329                     showmessage('register_disable_activation');
330                 }
331             } elseif(!$this->setting['regstatus']) {
332                 showmessage(!$this->setting['regclosemessage'] ? 'register_disable' : str_replace(array("\r", "\n"), '', $this->setting['regclosemessage']));
333             }
334         }
335 
336         $bbrules = & $this->setting['bbrules'];
337         $bbrulesforce = & $this->setting['bbrulesforce'];
338         $bbrulestxt = & $this->setting['bbrulestxt'];
339         $welcomemsg = & $this->setting['welcomemsg'];
340         $welcomemsgtitle = & $this->setting['welcomemsgtitle'];
341         $welcomemsgtxt = & $this->setting['welcomemsgtxt'];
342         $regname = $this->setting['regname'];
343 
344         if($this->setting['regverify']) {
345             if($this->setting['areaverifywhite']) {
346                 $location = $whitearea = '';
347                 $location = trim(convertip($_G['clientip'], "./"));
348                 if($location) {
349                     $whitearea = preg_quote(trim($this->setting['areaverifywhite']), '/');
350                     $whitearea = str_replace(array("\\*"), array('.*'), $whitearea);
351                     $whitearea = '.*'.$whitearea.'.*';
352                     $whitearea = '/^('.str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea).')$/i';
353                     if(@preg_match($whitearea, $location)) {
354                         $this->setting['regverify'] = 0;
355                     }
356                 }
357             }
358 
359             if($_G['cache']['ipctrl']['ipverifywhite']) {
360                 foreach(explode("\n", $_G['cache']['ipctrl']['ipverifywhite']) as $ctrlip) {
361                     if(preg_match("/^(".preg_quote(($ctrlip = trim($ctrlip)), '/').")/", $_G['clientip'])) {
362                         $this->setting['regverify'] = 0;
363                         break;
364                     }
365                 }
366             }
367         }
368 
369         $invitestatus = false;
370         if($this->setting['regstatus'] == 2) {
371             if($this->setting['inviteconfig']['inviteareawhite']) {
372                 $location = $whitearea = '';
373                 $location = trim(convertip($_G['clientip'], "./"));
374                 if($location) {
375                     $whitearea = preg_quote(trim($this->setting['inviteconfig']['inviteareawhite']), '/');
376                     $whitearea = str_replace(array("\\*"), array('.*'), $whitearea);
377                     $whitearea = '.*'.$whitearea.'.*';
378                     $whitearea = '/^('.str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea).')$/i';
379                     if(@preg_match($whitearea, $location)) {
380                         $invitestatus = true;
381                     }
382                 }
383             }
384 
385             if($this->setting['inviteconfig']['inviteipwhite']) {
386                 foreach(explode("\n", $this->setting['inviteconfig']['inviteipwhite']) as $ctrlip) {
387                     if(preg_match("/^(".preg_quote(($ctrlip = trim($ctrlip)), '/').")/", $_G['clientip'])) {
388                         $invitestatus = true;
389                         break;
390                     }
391                 }
392             }
393         }
394 
395         $groupinfo = array();
396         if($this->setting['regverify']) {
397             $groupinfo['groupid'] = 8;
398         } else {
399             $groupinfo['groupid'] = $this->setting['newusergroupid'];
400         }
401 
402         $seccodecheck = $this->setting['seccodestatus'] & 1;
403         $secqaacheck = $this->setting['secqaa']['status'] & 1;
404         $fromuid = !empty($_G['cookie']['promotion']) && $this->setting['creditspolicy']['promotion_register'] ? intval($_G['cookie']['promotion']) : 0;
405         $username = isset($_GET['username']) ? $_GET['username'] : '';
406         $bbrulehash = $bbrules ? substr(md5(FORMHASH), 0, 8) : '';
407         $auth = $_GET['auth'];
408 
409         if(!$invitestatus) {
410             $invite = getinvite();
411         }
412         $sendurl = $this->setting['sendregisterurl'] ? true : false;
413         if($sendurl) {
414             if(!empty($_GET['hash'])) {
415                 $hash = explode("\t", authcode($_GET['hash'], 'DECODE', $_G['config']['security']['authkey']));
416                 if(is_array($hash) && isemail($hash[0]) && TIMESTAMP - $hash[1] < 259200) {
417                     $sendurl = false;
418                 }
419             }
420         }
421 
422         if(!submitcheck('regsubmit', 0, $seccodecheck, $secqaacheck)) {
423 
424             if(!$sendurl) {
425                 if($_GET['action'] == 'activation') {
426                     $auth = explode("\t", authcode($auth, 'DECODE'));
427                     if(FORMHASH != $auth[1]) {
428                         showmessage('register_activation_invalid', 'member.php?mod=logging&action=login');
429                     }
430                     $username = $auth[0];
431                     $activationauth = authcode("$auth[0]\t".FORMHASH, 'ENCODE');
432                 }
433 
434                 if($fromuid) {
435                     $member = getuserbyuid($fromuid);
436                     if(!empty($member)) {
437                         $fromuser = dhtmlspecialchars($member['username']);
438                     } else {
439                         dsetcookie('promotion');
440                     }
441                 }
442 
443                 $bbrulestxt = nl2br("\n$bbrulestxt\n\n");
444                 if($_GET['action'] == 'activation') {
445                     $auth = dhtmlspecialchars($auth);
446                 }
447 
448                 if($seccodecheck) {
449                     $seccode = random(6, 1);
450                 }
451 
452                 $username = dhtmlspecialchars($username);
453 
454                 $htmls = $settings = array();
455                 foreach($_G['cache']['fields_register'] as $field) {
456                     $fieldid = $field['fieldid'];
457                     $html = profile_setting($fieldid, array(), false, false, true);
458                     if($html) {
459                         $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid];
460                         $htmls[$fieldid] = $html;
461                     }
462                 }
463 
464                 $navtitle = $this->setting['reglinkname'];
465 
466                 if($this->extrafile && file_exists($this->extrafile)) {
467                     require_once $this->extrafile;
468                 }
469             }
470             $dreferer = dreferer();
471 
472             include template($this->template);
473 
474         } else {
475 
476             if($sendurl) {
477                 checkemail($_GET['email']);
478                 $hashstr = urlencode(authcode("$_GET[email]\t$_G[timestamp]", 'ENCODE', $_G['config']['security']['authkey']));
479                 $registerurl = "{$_G[siteurl]}member.php?mod=".$this->setting['regname']."&amp;hash={$hashstr}&amp;email={$_GET[email]}";
480                 $email_register_message = lang('email', 'email_register_message', array(
481                     'bbname' => $this->setting['bbname'],
482                     'siteurl' => $_G['siteurl'],
483                     'url' => $registerurl
484                 ));
485                 if(!sendmail("$_GET[email] <$_GET[email]>", lang('email', 'email_register_subject'), $email_register_message)) {
486                     runlog('sendmail', "$_GET[email] sendmail failed.");
487                 }
488                 showmessage('register_email_send_succeed', dreferer(), array('bbname' => $this->setting['bbname']), array('showdialog' => true, 'msgtype' => 3, 'closetime' => 10));
489             }
490             $emailstatus = 0;
491             if($this->setting['sendregisterurl'] && !$sendurl) {
492                 $_GET['email'] = strtolower($hash[0]);
493                 $this->setting['regverify'] = $this->setting['regverify'] == 1 ? 0 : $this->setting['regverify'];
494                 if(!$this->setting['regverify']) {
495                     $groupinfo['groupid'] = $this->setting['newusergroupid'];
496                 }
497                 $emailstatus = 1;
498             }
499 
500             if($this->setting['regstatus'] == 2 && empty($invite) && !$invitestatus) {
501                 showmessage('not_open_registration_invite');
502             }
503 
504             if($bbrules && $bbrulehash != $_POST['agreebbrule']) {
505                 showmessage('register_rules_agree');
506             }
507 
508             $activation = array();
509             if(isset($_GET['activationauth'])) {
510                 $activationauth = explode("\t", authcode($_GET['activationauth'], 'DECODE'));
511                 if($activationauth[1] == FORMHASH && !($activation = uc_get_user($activationauth[0]))) {
512                     showmessage('register_activation_invalid', 'member.php?mod=logging&action=login');
513                 }
514             }
515 
516             if(!$activation) {
517                 $usernamelen = dstrlen($username);
518                 if($usernamelen < 3) {
519                     showmessage('profile_username_tooshort');
520                 } elseif($usernamelen > 15) {
521                     showmessage('profile_username_toolong');
522                 }
523                 if(uc_get_user(addslashes($username)) && !C::t('common_member')->fetch_uid_by_username($username) && !C::t('common_member_archive')->fetch_uid_by_username($username)) {
524                     if($_G['inajax']) {
525                         showmessage('profile_username_duplicate');
526                     } else {
527                         showmessage('register_activation_message', 'member.php?mod=logging&action=login', array('username' => $username));
528                     }
529                 }
530                 if($this->setting['pwlength']) {
531                     if(strlen($_GET['password']) < $this->setting['pwlength']) {
532                         showmessage('profile_password_tooshort', '', array('pwlength' => $this->setting['pwlength']));
533                     }
534                 }
535                 if($this->setting['strongpw']) {
536                     $strongpw_str = array();
537                     if(in_array(1, $this->setting['strongpw']) && !preg_match("/\d+/", $_GET['password'])) {
538                         $strongpw_str[] = lang('member/template', 'strongpw_1');
539                     }
540                     if(in_array(2, $this->setting['strongpw']) && !preg_match("/[a-z]+/", $_GET['password'])) {
541                         $strongpw_str[] = lang('member/template', 'strongpw_2');
542                     }
543                     if(in_array(3, $this->setting['strongpw']) && !preg_match("/[A-Z]+/", $_GET['password'])) {
544                         $strongpw_str[] = lang('member/template', 'strongpw_3');
545                     }
546                     if(in_array(4, $this->setting['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $_GET['password'])) {
547                         $strongpw_str[] = lang('member/template', 'strongpw_4');
548                     }
549                     if($strongpw_str) {
550                         showmessage(lang('member/template', 'password_weak').implode(',', $strongpw_str));
551                     }
552                 }
553                 $email = strtolower(trim($_GET['email']));
554                 if(empty($this->setting['ignorepassword'])) {
555                     if($_GET['password'] !== $_GET['password2']) {
556                         showmessage('profile_passwd_notmatch');
557                     }
558 
559                     if(!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) {
560                         showmessage('profile_passwd_illegal');
561                     }
562                     $password = $_GET['password'];
563                 } else {
564                     $password = md5(random(10));
565                 }
566             }
567 
568             $censorexp = '/^('.str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(($this->setting['censoruser'] = trim($this->setting['censoruser'])), '/')).')$/i';
569 
570             if($this->setting['censoruser'] && @preg_match($censorexp, $username)) {
571                 showmessage('profile_username_protect');
572             }
573 
574             if($this->setting['regverify'] == 2 && !trim($_GET['regmessage'])) {
575                 showmessage('profile_required_info_invalid');
576             }
577 
578             if($_G['cache']['ipctrl']['ipregctrl']) {
579                 foreach(explode("\n", $_G['cache']['ipctrl']['ipregctrl']) as $ctrlip) {
580                     if(preg_match("/^(".preg_quote(($ctrlip = trim($ctrlip)), '/').")/", $_G['clientip'])) {
581                         $ctrlip = $ctrlip.'%';
582                         $this->setting['regctrl'] = $this->setting['ipregctrltime'];
583                         break;
584                     } else {
585                         $ctrlip = $_G['clientip'];
586                     }
587                 }
588             } else {
589                 $ctrlip = $_G['clientip'];
590             }
591 
592             if($this->setting['regctrl']) {
593                 if(C::t('common_regip')->count_by_ip_dateline($ctrlip, $_G['timestamp']-$this->setting['regctrl']*3600)) {
594                     showmessage('register_ctrl', NULL, array('regctrl' => $this->setting['regctrl']));
595                 }
596             }
597 
598             $setregip = null;
599             if($this->setting['regfloodctrl']) {
600                 $regip = C::t('common_regip')->fetch_by_ip_dateline($_G['clientip'], $_G['timestamp']-86400);
601                 if($regip) {
602                     if($regip['count'] >= $this->setting['regfloodctrl']) {
603                         showmessage('register_flood_ctrl', NULL, array('regfloodctrl' => $this->setting['regfloodctrl']));
604                     } else {
605                         $setregip = 1;
606                     }
607                 } else {
608                     $setregip = 2;
609                 }
610             }
611 
612             $profile = $verifyarr = array();
613             foreach($_G['cache']['fields_register'] as $field) {
614                 if(defined('IN_MOBILE')) {
615                     break;
616                 }
617                 $field_key = $field['fieldid'];
618                 $field_val = $_GET[''.$field_key];
619                 if($field['formtype'] == 'file' && !empty($_FILES[$field_key]) && $_FILES[$field_key]['error'] == 0) {
620                     $field_val = true;
621                 }
622 
623                 if(!profile_check($field_key, $field_val)) {
624                     $showid = !in_array($field['fieldid'], array('birthyear', 'birthmonth')) ? $field['fieldid'] : 'birthday';
625                     showmessage($field['title'].lang('message', 'profile_illegal'), '', array(), array(
626                         'showid' => 'chk_'.$showid,
627                         'extrajs' => $field['title'].lang('message', 'profile_illegal').($field['formtype'] == 'text' ? '<script type="text/javascript">'.
628                             '$(\'registerform\').'.$field['fieldid'].'.className = \'px er\';'.
629                             '$(\'registerform\').'.$field['fieldid'].'.onblur = function () { if(this.value != \'\') {this.className = \'px\';$(\'chk_'.$showid.'\').innerHTML = \'\';}}'.
630                             '</script>' : '')
631                     ));
632                 }
633                 if($field['needverify']) {
634                     $verifyarr[$field_key] = $field_val;
635                 } else {
636                     $profile[$field_key] = $field_val;
637                 }
638             }
639 
640             if(!$activation) {
641                 $uid = uc_user_register(addslashes($username), $password, $email, $questionid, $answer, $_G['clientip']);
642 
643                 if($uid <= 0) {
644                     if($uid == -1) {
645                         showmessage('profile_username_illegal');
646                     } elseif($uid == -2) {
647                         showmessage('profile_username_protect');
648                     } elseif($uid == -3) {
649                         showmessage('profile_username_duplicate');
650                     } elseif($uid == -4) {
651                         showmessage('profile_email_illegal');
652                     } elseif($uid == -5) {
653                         showmessage('profile_email_domain_illegal');
654                     } elseif($uid == -6) {
655                         showmessage('profile_email_duplicate');
656                     } else {
657                         showmessage('undefined_action');
658                     }
659                 }
660             } else {
661                 list($uid, $username, $email) = $activation;
662             }
663             $_G['username'] = $username;
664             if(getuserbyuid($uid, 1)) {
665                 if(!$activation) {
666                     uc_user_delete($uid);
667                 }
668                 showmessage('profile_uid_duplicate', '', array('uid' => $uid));
669             }
670 
671             $password = md5(random(10));
672             $secques = $questionid > 0 ? random(8) : '';
673 
674             if(isset($_POST['birthmonth']) && isset($_POST['birthday'])) {
675                 $profile['constellation'] = get_constellation($_POST['birthmonth'], $_POST['birthday']);
676             }
677             if(isset($_POST['birthyear'])) {
678                 $profile['zodiac'] = get_zodiac($_POST['birthyear']);
679             }
680 
681             if($_FILES) {
682                 $upload = new discuz_upload();
683 
684                 foreach($_FILES as $key => $file) {
685                     $field_key = 'field_'.$key;
686                     if(!empty($_G['cache']['fields_register'][$field_key]) && $_G['cache']['fields_register'][$field_key]['formtype'] == 'file') {
687 
688                         $upload->init($file, 'profile');
689                         $attach = $upload->attach;
690 
691                         if(!$upload->error()) {
692                             $upload->save();
693 
694                             if(!$upload->get_image_info($attach['target'])) {
695                                 @unlink($attach['target']);
696                                 continue;
697                             }
698 
699                             $attach['attachment'] = dhtmlspecialchars(trim($attach['attachment']));
700                             if($_G['cache']['fields_register'][$field_key]['needverify']) {
701                                 $verifyarr[$key] = $attach['attachment'];
702                             } else {
703                                 $profile[$key] = $attach['attachment'];
704                             }
705                         }
706                     }
707                 }
708             }
709 
710             if($setregip !== null) {
711                 if($setregip == 1) {
712                     C::t('common_regip')->update_count_by_ip($_G['clientip']);
713                 } else {
714                     C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => 1, 'dateline' => $_G['timestamp']));
715                 }
716             }
717 
718             if($invite && $this->setting['inviteconfig']['invitegroupid']) {
719                 $groupinfo['groupid'] = $this->setting['inviteconfig']['invitegroupid'];
720             }
721 
722             $init_arr = array('credits' => explode(',', $this->setting['initcredits']), 'profile'=>$profile, 'emailstatus' => $emailstatus);
723 
724             C::t('common_member')->insert($uid, $username, $password, $email, $_G['clientip'], $groupinfo['groupid'], $init_arr);
725             if($emailstatus) {
726                 updatecreditbyaction('realemail', $uid);
727             }
728             if($verifyarr) {
729                 $setverify = array(
730                     'uid' => $uid,
731                     'username' => $username,
732                     'verifytype' => '0',
733                     'field' => serialize($verifyarr),
734                     'dateline' => TIMESTAMP,
735                 );
736                 C::t('common_member_verify_info')->insert($setverify);
737                 C::t('common_member_verify')->insert(array('uid' => $uid));
738             }
739 
740             require_once libfile('cache/userstats', 'function');
741             build_cache_userstats();
742 
743             if($this->extrafile && file_exists($this->extrafile)) {
744                 require_once $this->extrafile;
745             }
746 
747             if($this->setting['regctrl'] || $this->setting['regfloodctrl']) {
748                 C::t('common_regip')->delete_by_dateline($_G['timestamp']-($this->setting['regctrl'] > 72 ? $this->setting['regctrl'] : 72)*3600);
749                 if($this->setting['regctrl']) {
750                     C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => -1, 'dateline' => $_G['timestamp']));
751                 }
752             }
753 
754             $regmessage = dhtmlspecialchars($_GET['regmessage']);
755             if($this->setting['regverify'] == 2) {
756                 C::t('common_member_validate')->insert(array(
757                     'uid' => $uid,
758                     'submitdate' => $_G['timestamp'],
759                     'moddate' => 0,
760                     'admin' => '',
761                     'submittimes' => 1,
762                     'status' => 0,
763                     'message' => $regmessage,
764                     'remark' => '',
765                 ), false, true);
766                 manage_addnotify('verifyuser');
767             }
768 
769             setloginstatus(array(
770                 'uid' => $uid,
771                 'username' => $_G['username'],
772                 'password' => $password,
773                 'groupid' => $groupinfo['groupid'],
774             ), 0);
775             include_once libfile('function/stat');
776             updatestat('register');
777 
778             if($invite['id']) {
779                 $result = C::t('common_invite')->count_by_uid_fuid($invite['uid'], $uid);
780                 if(!$result) {
781                     C::t('common_invite')->update($invite['id'], array('fuid'=>$uid, 'fusername'=>$_G['username'], 'regdateline' => $_G['timestamp'], 'status' => 2));
782                     updatestat('invite');
783                 } else {
784                     $invite = array();
785                 }
786             }
787             if($invite['uid']) {
788                 if($this->setting['inviteconfig']['inviteaddcredit']) {
789                     updatemembercount($uid, array($this->setting['inviteconfig']['inviterewardcredit'] => $this->setting['inviteconfig']['inviteaddcredit']));
790                 }
791                 if($this->setting['inviteconfig']['invitedaddcredit']) {
792                     updatemembercount($invite['uid'], array($this->setting['inviteconfig']['inviterewardcredit'] => $this->setting['inviteconfig']['invitedaddcredit']));
793                 }
794                 require_once libfile('function/friend');
795                 friend_make($invite['uid'], $invite['username'], false);
796                 notification_add($invite['uid'], 'friend', 'invite_friend', array('actor' => '<a href="home.php?mod=space&uid='.$invite['uid'].'" target="_blank">'.$invite['username'].'</a>'), 1);
797 
798                 space_merge($invite, 'field_home');
799                 if(!empty($invite['privacy']['feed']['invite'])) {
800                     require_once libfile('function/feed');
801                     $tite_data = array('username' => '<a href="home.php?mod=space&uid='.$_G['uid'].'">'.$_G['username'].'</a>');
802                     feed_add('friend', 'feed_invite', $tite_data, '', array(), '', array(), array(), '', '', '', 0, 0, '', $invite['uid'], $invite['username']);
803                 }
804                 if($invite['appid']) {
805                     updatestat('appinvite');
806                 }
807             }
808 
809             if($welcomemsg && !empty($welcomemsgtxt)) {
810                 $welcomemsgtitle = replacesitevar($welcomemsgtitle);
811                 $welcomemsgtxt = replacesitevar($welcomemsgtxt);
812                 if($welcomemsg == 1) {
813                     $welcomemsgtxt = nl2br(str_replace(':', '&#58;', $welcomemsgtxt));
814                     notification_add($uid, 'system', $welcomemsgtxt, array('from_id' => 0, 'from_idtype' => 'welcomemsg'), 1);
815                 } elseif($welcomemsg == 2) {
816                     sendmail_cron($email, $welcomemsgtitle, $welcomemsgtxt);
817                 } elseif($welcomemsg == 3) {
818                     sendmail_cron($email, $welcomemsgtitle, $welcomemsgtxt);
819                     $welcomemsgtxt = nl2br(str_replace(':', '&#58;', $welcomemsgtxt));
820                     notification_add($uid, 'system', $welcomemsgtxt, array('from_id' => 0, 'from_idtype' => 'welcomemsg'), 1);
821                 }
822             }
823 
824             if($fromuid) {
825                 updatecreditbyaction('promotion_register', $fromuid);
826                 dsetcookie('promotion', '');
827             }
828             dsetcookie('loginuser', '');
829             dsetcookie('activationauth', '');
830             dsetcookie('invite_auth', '');
831 
832             $url_forward = dreferer();
833             $refreshtime = 3000;
834             switch($this->setting['regverify']) {
835                 case 1:
836                     $idstring = random(6);
837                     $authstr = $this->setting['regverify'] == 1 ? "$_G[timestamp]\t2\t$idstring" : '';
838                     C::t('common_member_field_forum')->update($_G['uid'], array('authstr' => $authstr));
839                     $verifyurl = "{$_G[siteurl]}member.php?mod=activate&amp;uid={$_G[uid]}&amp;id=$idstring";
840                     $email_verify_message = lang('email', 'email_verify_message', array(
841                         'username' => $_G['member']['username'],
842                         'bbname' => $this->setting['bbname'],
843                         'siteurl' => $_G['siteurl'],
844                         'url' => $verifyurl
845                     ));
846                     if(!sendmail("$username <$email>", lang('email', 'email_verify_subject'), $email_verify_message)) {
847                         runlog('sendmail', "$email sendmail failed.");
848                     }
849                     $message = 'register_email_verify';
850                     $locationmessage = 'register_email_verify_location';
851                     $refreshtime = 10000;
852                     break;
853                 case 2:
854                     $message = 'register_manual_verify';
855                     $locationmessage = 'register_manual_verify_location';
856                     break;
857                 default:
858                     $message = 'register_succeed';
859                     $locationmessage = 'register_succeed_location';
860                     break;
861             }
862             $param = array('bbname' => $this->setting['bbname'], 'username' => $_G['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid']);
863             if(strpos($url_forward, $this->setting['regname']) !== false || strpos($url_forward, 'buyinvitecode') !== false) {
864                 $url_forward = 'forum.php';
865             }
866             $href = str_replace("'", "\'", $url_forward);
867             $extra = array(
868                 'showid' => 'succeedmessage',
869                 'extrajs' => '<script type="text/javascript">'.
870                     'setTimeout("window.location.href =\''.$href.'\';", '.$refreshtime.');'.
871                     '$(\'succeedmessage_href\').href = \''.$href.'\';'.
872                     '$(\'main_message\').style.display = \'none\';'.
873                     '$(\'main_succeed\').style.display = \'\';'.
874                     '$(\'succeedlocation\').innerHTML = \''.lang('message', $locationmessage).'\';'.
875                 '</script>',
876                 'striptags' => false,
877             );
878             showmessage($message, $url_forward, $param, $extra);
879         }
880     }
881 
882 }
883 
884 class crime_action_ctl {
885 
886     var $actions = array('all', 'crime_delpost', 'crime_warnpost', 'crime_banpost', 'crime_banspeak', 'crime_banvisit', 'crime_banstatus', 'crime_avatar', 'crime_sightml', 'crime_customstatus');
887 
888     function crime_action_ctl() {}
889 
890     function &instance() {
891         static $object;
892         if(empty($object)) {
893             $object = new crime_action_ctl();
894         }
895         return $object;
896     }
897 
898     function recordaction($uid, $action, $reason) {
899         global $_G;
900 
901         $uid = intval($uid);
902         $key = array_search($action, $this->actions);
903         if($key === FALSE) {
904             return false;
905         }
906         $insert = array(
907             'uid' => $uid,
908             'operatorid' => $_G['uid'],
909             'operator' => $_G['username'],
910             'action' => $key,
911             'reason' => $reason,
912             'dateline' => $_G['timestamp']
913         );
914         C::t('common_member_crime')->insert($insert);
915         return true;
916     }
917 
918     function getactionlist($uid) {
919         $uid = intval($uid);
920         $clist = array();
921         foreach(C::t('common_member_crime')->fetch_all_by_uid($uid) as $c) {
922             $c['action'] = $this->actions[$c['action']];
923             $clist[] = $c;
924         }
925         return $clist;
926     }
927 
928     function getcount($uid, $action) {
929         $uid = intval($uid);
930         $key = array_search($action, $this->actions);
931         if($key === FALSE) {
932             return 0;
933         }
934         return C::t('common_member_crime')->count_by_uid_action($uid, $key);
935     }
936 
937     function search($action, $username, $operator, $startime, $endtime, $reason, $start, $limit) {
938         $action = intval($action);
939         $operator = daddslashes(trim($operator));
940         $starttime = $starttime ? strtotime($starttime) : 0;
941         $endtime = $endtime ? (strtotime($endtime) + 3600 * 24) : 0;
942         $reason = daddslashes(trim($reason));
943         $start = intval($start);
944         $limit = intval($limit);
945 
946         if(!empty($username)) {
947             $uid = C::t('common_member')->fetch_uid_by_username($username);
948             $wheresql[] = "uid='$uid'";
949         }
950 
951         if($action) {
952             $wheresql[] = "action='$action'";
953         }
954         if($operator) {
955             $wheresql[] = "operator='$operator'";
956         }
957         if($starttime) {
958             $wheresql[] = "dateline>='$starttime'";
959         }
960         if($endtime) {
961             $wheresql[] = "dateline<='$endtime'";
962         }
963         if($reason) {
964             $wheresql[] = "reason LIKE '%$reason%'";
965         }
966 
967         if($wheresql) {
968             $wheresql = 'WHERE '.implode(' AND ', $wheresql);
969         } else {
970             $wheresql = '';
971         }
972         $clist = array();
973         $count = C::t('common_member_crime')->count_by_where($wheresql);
974 
975         if($count) {
976             $uids = array();
977             foreach(C::t('common_member_crime')->fetch_all_by_where($wheresql, $start, $limit) as $crime) {
978                 $crime['action'] = $this->actions[$crime['action']];
979                 $clist[] = $crime;
980                 $uids[$crime['uid']] = $crime['uid'];
981             }
982             $members = C::t('common_member')->fetch_all($uids, false, 0);
983             foreach($clist as $key => $crime) {
984                 $crime['username'] = $members[$crime['uid']]['username'];
985                 $clist[$key] = $crime;
986             }
987         }
988         return array($count, $clist);
989     }
990 }
991 ?>

   基本的已经更改完毕,你只要直接查找‘cas’ ,将cas服务器个相关信息更改就可以了。

  然后是修改 Discuz2.5\uc_client\control\user.php 

  

View Code
  1 <?php
  2 
  3 /*
  4     [UCenter] (C)2001-2099 Comsenz Inc.
  5     This is NOT a freeware, use is subject to license terms
  6 
  7     $Id: user.php 1082 2011-04-07 06:42:14Z svn_project_zhangjie $
  8 */
  9 
 10 !defined('IN_UC') && exit('Access Denied');
 11 
 12 define('UC_USER_CHECK_USERNAME_FAILED', -1);
 13 define('UC_USER_USERNAME_BADWORD', -2);
 14 define('UC_USER_USERNAME_EXISTS', -3);
 15 define('UC_USER_EMAIL_FORMAT_ILLEGAL', -4);
 16 define('UC_USER_EMAIL_ACCESS_ILLEGAL', -5);
 17 define('UC_USER_EMAIL_EXISTS', -6);
 18 
 19 class usercontrol extends base {
 20 
 21 
 22     function __construct() {
 23         $this->usercontrol();
 24     }
 25 
 26     function usercontrol() {
 27         parent::__construct();
 28         $this->load('user');
 29         $this->app = $this->cache['apps'][UC_APPID];
 30     }
 31 
 32     // -1 未开启
 33     function onsynlogin() {
 34         $this->init_input();
 35         $uid = $this->input('uid');
 36         if($this->app['synlogin']) {
 37             if($this->user = $_ENV['user']->get_user_by_uid($uid)) {
 38                 $synstr = '';
 39                 foreach($this->cache['apps'] as $appid => $app) {
 40                     if($app['synlogin'] && $app['appid'] != $this->app['appid']) {
 41                         $synstr .= '<script type="text/javascript" src="'.$app['url'].'/api/uc.php?time='.$this->time.'&code='.urlencode($this->authcode('action=synlogin&username='.$this->user['username'].'&uid='.$this->user['uid'].'&password='.$this->user['password']."&time=".$this->time, 'ENCODE', $app['authkey'])).'"></script>';
 42                     }
 43                 }
 44                 return $synstr;
 45             }
 46         }
 47         return '';
 48     }
 49 
 50     function onsynlogout() {
 51         $this->init_input();
 52         if($this->app['synlogin']) {
 53             $synstr = '';
 54             foreach($this->cache['apps'] as $appid => $app) {
 55                 if($app['synlogin'] && $app['appid'] != $this->app['appid']) {
 56                     $synstr .= '<script type="text/javascript" src="'.$app['url'].'/api/uc.php?time='.$this->time.'&code='.urlencode($this->authcode('action=synlogout&time='.$this->time, 'ENCODE', $app['authkey'])).'"></script>';
 57                 }
 58             }
 59             return $synstr;
 60         }
 61         return '';
 62     }
 63 
 64     function onregister() {
 65         $this->init_input();
 66         $username = $this->input('username');
 67         $password =  $this->input('password');
 68         $email = $this->input('email');
 69         $questionid = $this->input('questionid');
 70         $answer = $this->input('answer');
 71         $regip = $this->input('regip');
 72 
 73         if(($status = $this->_check_username($username)) < 0) {
 74             return $status;
 75         }
 76         if(($status = $this->_check_email($email)) < 0) {
 77             return $status;
 78         }
 79         $uid = $_ENV['user']->add_user($username, $password, $email, 0, $questionid, $answer, $regip);
 80         return $uid;
 81     }
 82 
 83     function onedit() {
 84         $this->init_input();
 85         $username = $this->input('username');
 86         $oldpw = $this->input('oldpw');
 87         $newpw = $this->input('newpw');
 88         $email = $this->input('email');
 89         $ignoreoldpw = $this->input('ignoreoldpw');
 90         $questionid = $this->input('questionid');
 91         $answer = $this->input('answer');
 92 
 93         if(!$ignoreoldpw && $email && ($status = $this->_check_email($email, $username)) < 0) {
 94             return $status;
 95         }
 96         $status = $_ENV['user']->edit_user($username, $oldpw, $newpw, $email, $ignoreoldpw, $questionid, $answer);
 97 
 98         if($newpw && $status > 0) {
 99             $this->load('note');
100             $_ENV['note']->add('updatepw', 'username='.urlencode($username).'&password=');
101             $_ENV['note']->send();
102         }
103         return $status;
104     }
105 
106     function onlogin() {
107         $this->init_input();
108         $isuid = $this->input('isuid');
109         $username = $this->input('username');
110         $password = $this->input('password');
111         $checkques = $this->input('checkques');
112         $questionid = $this->input('questionid');
113         $answer = $this->input('answer');
114         if($isuid == 1) {
115             $user = $_ENV['user']->get_user_by_uid($username);
116         } elseif($isuid == 2) {
117             $user = $_ENV['user']->get_user_by_email($username);
118         } else {
119             $user = $_ENV['user']->get_user_by_username($username);
120         }
121         
122 //$user = $_ENV['user']->get_user_by_username($username);
123         
124         if(empty($user)) {
125             $status = -1;
126         } else {
127             $status = $user['uid'];
128         }
129         $merge = $status != -1 && !$isuid && $_ENV['user']->check_mergeuser($username) ? 1 : 0;
130         return array($status, $user['username'], $password, $user['email'], $merge);
131     }
132 
133     function oncheck_email() {
134         $this->init_input();
135         $email = $this->input('email');
136         return $this->_check_email($email);
137     }
138 
139     function oncheck_username() {
140         $this->init_input();
141         $username = $this->input('username');
142         if(($status = $this->_check_username($username)) < 0) {
143             return $status;
144         } else {
145             return 1;
146         }
147     }
148 
149     function onget_user() {
150         $this->init_input();
151         $username = $this->input('username');
152         if(!$this->input('isuid')) {
153             $status = $_ENV['user']->get_user_by_username($username);
154         } else {
155             $status = $_ENV['user']->get_user_by_uid($username);
156         }
157         if($status) {
158             return array($status['uid'],$status['username'],$status['email']);
159         } else {
160             return 0;
161         }
162     }
163 
164 
165     function ongetprotected() {
166         $protectedmembers = $this->db->fetch_all("SELECT uid,username FROM ".UC_DBTABLEPRE."protectedmembers GROUP BY username");
167         return $protectedmembers;
168     }
169 
170     function ondelete() {
171         $this->init_input();
172         $uid = $this->input('uid');
173         return $_ENV['user']->delete_user($uid);
174     }
175 
176     function onaddprotected() {
177         $this->init_input();
178         $username = $this->input('username');
179         $admin = $this->input('admin');
180         $appid = $this->app['appid'];
181         $usernames = (array)$username;
182         foreach($usernames as $username) {
183             $user = $_ENV['user']->get_user_by_username($username);
184             $uid = $user['uid'];
185             $this->db->query("REPLACE INTO ".UC_DBTABLEPRE."protectedmembers SET uid='$uid', username='$username', appid='$appid', dateline='{$this->time}', admin='$admin'", 'SILENT');
186         }
187         return $this->db->errno() ? -1 : 1;
188     }
189 
190     function ondeleteprotected() {
191         $this->init_input();
192         $username = $this->input('username');
193         $appid = $this->app['appid'];
194         $usernames = (array)$username;
195         foreach($usernames as $username) {
196             $this->db->query("DELETE FROM ".UC_DBTABLEPRE."protectedmembers WHERE username='$username' AND appid='$appid'");
197         }
198         return $this->db->errno() ? -1 : 1;
199     }
200 
201     function onmerge() {
202         $this->init_input();
203         $oldusername = $this->input('oldusername');
204         $newusername = $this->input('newusername');
205         $uid = $this->input('uid');
206         $password = $this->input('password');
207         $email = $this->input('email');
208         if(($status = $this->_check_username($newusername)) < 0) {
209             return $status;
210         }
211         $uid = $_ENV['user']->add_user($newusername, $password, $email, $uid);
212         $this->db->query("DELETE FROM ".UC_DBTABLEPRE."mergemembers WHERE appid='".$this->app['appid']."' AND username='$oldusername'");
213         return $uid;
214     }
215 
216     function onmerge_remove() {
217         $this->init_input();
218         $username = $this->input('username');
219         $this->db->query("DELETE FROM ".UC_DBTABLEPRE."mergemembers WHERE appid='".$this->app['appid']."' AND username='$username'");
220         return NULL;
221     }
222 
223     function _check_username($username) {
224         $username = addslashes(trim(stripslashes($username)));
225         if(!$_ENV['user']->check_username($username)) {
226             return UC_USER_CHECK_USERNAME_FAILED;
227         } elseif(!$_ENV['user']->check_usernamecensor($username)) {
228             return UC_USER_USERNAME_BADWORD;
229         } elseif($_ENV['user']->check_usernameexists($username)) {
230             return UC_USER_USERNAME_EXISTS;
231         }
232         return 1;
233     }
234 
235     function _check_email($email, $username = '') {
236         if(empty($this->settings)) {
237             $this->settings = $this->cache('settings');
238         }
239         if(!$_ENV['user']->check_emailformat($email)) {
240             return UC_USER_EMAIL_FORMAT_ILLEGAL;
241         } elseif(!$_ENV['user']->check_emailaccess($email)) {
242             return UC_USER_EMAIL_ACCESS_ILLEGAL;
243         } elseif(!$this->settings['doublee'] && $_ENV['user']->check_emailexists($email, $username)) {
244             return UC_USER_EMAIL_EXISTS;
245         } else {
246             return 1;
247         }
248     }
249 
250     function onuploadavatar() {
251     }
252 
253     function onrectavatar() {
254     }
255     function flashdata_decode($s) {
256     }
257 }
258 
259 ?>

  然后下面改的就是登录部分了,我将之前的‘登录’和‘注册’修改成了‘一键登录’和‘注册’,代码如下,可以根据自己的情况修改

  

View Code
 1 <?php
 2 if(!defined('IN_DISCUZ')) exit('Access Denied'); if(CURMODULE != 'logging') { 
 3 ?>
 4 <script src="<?php echo $_G['setting']['jspath'];?>logging.js?<?php echo VERHASH;?>" type="text/javascript"></script>
 5 <form method="post" autocomplete="off" id="lsform" action="member.php?mod=logging&amp;action=login&amp;loginsubmit=yes&amp;infloat=yes&amp;lssubmit=yes" onsubmit="<?php if($_G['setting']['pwdsafety']) { ?>pwmd5('ls_password');<?php } ?>return lsSubmit();">
 6 <div class="fastlg cl">
 7 <span id="return_ls" style="display:none"></span>
 8 <div class="y pns">
 9 <table cellspacing="0" cellpadding="0">
10 <tr>
11 <?php 
12     if(!$_G['setting']['autoidselect']) { 
13 ?>
14 <td>
15 
16 <script type="text/javascript">simulateSelect('ls_fastloginfield')</script>
17 </td>
18 <td></td>
19 <?php 
20     } else { 
21 ?>
22 <td><label for="ls_username">帐号</label></td>
23 <td><input type="text" name="username" id="ls_username" class="px vm xg1" <?php if($_G['setting']['autoidselect']) { ?> value="UID/用户名/Email" onfocus="if(this.value == 'UID/用户名/Email'){this.value = '';this.className = 'px vm';}" onblur="if(this.value == ''){this.value = 'UID/用户名/Email';this.className = 'px vm xg1';}"<?php } ?> tabindex="901" /></td>
24 <?php 
25     } 
26 ?>
27 <td class="fastlg_l"> </td>
28 <td></td>
29 </tr>
30 <tr>
31 <td></td>
32 <td></td>
33 <td class="fastlg_l"><button type="submit" class="pn vm" tabindex="904" style="width: 75px;"><em>一键登录</em></button></td>
34 <td>&nbsp;<a href="member.php?mod=<?php echo $_G['setting']['regname'];?>" class="xi2 xw1"><?php echo $_G['setting']['reglinkname'];?></a></td>
35 </tr>
36 </table>
37 <input type="hidden" name="quickforward" value="yes" />
38 <input type="hidden" name="handlekey" value="ls" />
39 </div>
40 <?php 
41     if(!empty($_G['setting']['pluginhooks']['global_login_extra'])) echo $_G['setting']['pluginhooks']['global_login_extra'];
42 ?>
43 </div>
44 </form>
45 
46 <?php 
47     if($_G['setting']['pwdsafety']) { 
48 ?>
49 <script src="<?php echo $_G['setting']['jspath'];?>md5.js?<?php echo VERHASH;?>" type="text/javascript" reload="1"></script>
50 <?php 
51 
52     }
53 }
54 
55 ?>

 

  至此,就差不多完成了。