PEAK XOOPS - Re: How to display a "Automatic login" message in englishin japanese

Re: How to display a "Automatic login" message

List posts in the topic

normal Re: How to display a "Automatic login" message

msg# 1.1
depth:
1
Previous post - Next post | Parent - Children.1 | Posted on 2004/5/27 13:20
GIJOE  先任軍曹   Posts: 4110
hi efla.

Perhaps, this code is useful for you.

line 163 of include/common.php
	//autologin GIJ
	if(empty($HTTP_SESSION_VARS['xoopsUserId']) && isset($HTTP_COOKIE_VARS['autologin_uname']) && isset($HTTP_COOKIE_VARS['autologin_pass'])) {

		// redirect to Root when query string exists (anti-CSRF)
		if( ! empty( $HTTP_SERVER_VARS['QUERY_STRING'] ) ) {
			redirect_header( XOOPS_URL.'/' , 0 , 'Now, logging in automatically' ) ;
			exit ;
		}

		$myts =& MyTextSanitizer::getInstance();
		$uname = $myts->stripSlashesGPC($HTTP_COOKIE_VARS['autologin_uname']);
		$pass = $myts->stripSlashesGPC($HTTP_COOKIE_VARS['autologin_pass']);
		$myts =& MyTextsanitizer::getInstance();
		$user =& $member_handler->loginUserMd5(addslashes($uname), addslashes($pass));
		$xoops_cookie_path = defined('XOOPS_COOKIE_PATH') ? XOOPS_COOKIE_PATH : preg_replace( '?http://[^/]+(/.*)$?' , "$1" , XOOPS_URL ) ;
		if( $xoops_cookie_path == XOOPS_URL ) $xoops_cookie_path = '/' ;
		if (false != $user && $user->getVar('level') > 0) {
			// update time of last login
			$user->setVar('last_login', time());
			if (!$member_handler->insertUser($user, true)) {
			}
			//$HTTP_SESSION_VARS = array();
			$HTTP_SESSION_VARS['xoopsUserId'] = $user->getVar('uid');
			$HTTP_SESSION_VARS['xoopsUserGroups'] = $user->getGroups();
			// update autologin cookies
			$expire = time() + $xoopsConfig['session_expire'] * 60 ;
			setcookie('autologin_uname', $uname, $expire, $xoops_cookie_path, '', 0);
			setcookie('autologin_pass', $pass, $expire, $xoops_cookie_path, '', 0);
			redirect_header( XOOPS_URL.'/' , 0 , 'Now, logging in automatically' ) ;
			exit ;
		} else {
			setcookie('autologin_uname', '', time() - 3600, $xoops_cookie_path, '', 0);
			setcookie('autologin_pass', '', time() - 3600, $xoops_cookie_path, '', 0);
		}
	}
-------------
6/21 edited) XOOPS_URL to XOOPS_URL.'/' as redirection URL.
Votes:0 Average:0.00

Posts tree

  Advanced search


Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!