isLogged()) {
$memberData = $this->getData();
if ($memberData['auto_login'] == 'y' && strtotime($memberData['access_code_changed']) < (time() - $this->cookieUpdatePeriod)) {
$this->updateAccessCode($memberData);
}
return false;
}
if (isset($_COOKIE[$this->cookieAccessCodeName])) {
$memberData = $this->DBObj->getMemberByAccessCode($_COOKIE[$this->cookieAccessCodeName]);
if (!is_array($memberData) || empty($memberData) || $memberData['auto_login'] != 'y') {
return false;
}
if (strtotime($memberData['access_code_changed']) < (time() - $this->cookieUpdatePeriod)) {
$this->updateAccessCode($memberData);
}
$this->updateSessionData($memberData);
}
return true;
}
public static function getSessionData($key = null)
{
require_once ('class/Session.php');
$arr = Session::getData(SUPPORTACCOUNT_SESSION_ARR_NAME, SUPPORTACCOUNT_SESSION_ARR_NAME);
if ($key && isset($arr[$key])) return $arr[$key];
return $arr;
}
public static function setSessionData($data, $key = null)
{
require_once ('class/Session.php');
if ($key == null) {
Session::setData(SUPPORTACCOUNT_SESSION_ARR_NAME, SUPPORTACCOUNT_SESSION_ARR_NAME, $data);
} else {
$arr = Session::getData(SUPPORTACCOUNT_SESSION_ARR_NAME, SUPPORTACCOUNT_SESSION_ARR_NAME);
$arr[$key] = $data;
Session::setData(SUPPORTACCOUNT_SESSION_ARR_NAME, SUPPORTACCOUNT_SESSION_ARR_NAME, $arr);
}
return $arr;
}
function login($user, $files = array(), $redirect = true)
{
$member = $this->DBObj->getMemberByEmail($user['member_login']);
if (!is_array($member) || empty($member)) {
return array('member_login' => 'Bad login or password');
}
if (!Member::isActive($member)) {
return array(
'member_login' => 'Your account is not active in our system. ' . '
Please contact us for more information.');
}
$auto_login = $user['auto_login'];
$user = $this->DBObj->DBLogin(array('login' => $user['member_login'], 'password' => $this->DBObj->_encryptPass($user['member_password'])));
if (!empty($user)) {
$this->updateAccessCode($user);
$this->updateSessionData($user);
if ($auto_login == 'y' && $user['auto_login'] != 'y') {
$this->DBObj->setAutoLogin($user['id']);
}
if ($redirect) {
$url = $this->getLogin2();
if ($url == '') {
$url = BASE_URL;
Session::setData($this->ses_arr_name, 'login_to', $url);
}
require_once ('class/HTTP.php');
skHTTP::redirect($url);
}
return true;
} else {
return array('member_login' => 'Bad login or password');
}
}
function logout()
{
require_once ('class/Session.php');
// Logout Support Account
Session::clearData($this->ses_arr_name, $this->ses_arr_name);
setcookie($this->cookieAccessCodeName, '', time() - 3600, '/', $_SERVER['HTTP_HOST'], false);
// Logout Member
Session::clearData(USERAUTH_SESSION_ARR_NAME, USERAUTH_SESSION_ARR_NAME);
setcookie(USERAUTH_ACCESS_CODE_NAME, '', time() - 3600, '/', $_SERVER['HTTP_HOST'], false);
header("Location: " . BASE_URL);
exit();
}
}