/** * Class entry point * * @param object Registry reference * @return @e void [Outputs to screen] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // Load handler... //----------------------------------------- $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login'); $this->han_login = new $classToLoad($this->registry); $this->han_login->init(); $this->registry->getClass('class_localization')->loadLanguageFile(array('public_login'), 'core'); //----------------------------------------- // Show form or process login? //----------------------------------------- if ($this->request['do'] == 'showForm') { $additional_data = $this->han_login->additionalFormHTML(); $replace = false; $data = array(); if (!is_null($additional_data) and is_array($additional_data) and count($additional_data)) { $replace = $additional_data[0]; $data = $additional_data[1]; } $this->returnHtml($this->registry->getClass('output')->getTemplate('global')->loginForm($replace == 'replace' ? true : false, $data)); } else { if ($this->request['do'] == 'authenticateUser') { return $this->_authenticateUser(); } else { return $this->_doLogIn(); } } }
/** * Log the user out * * @access public * @param string Message to show on the form * @return void */ public function loginForm($message = '') { //----------------------------------------- // INIT //----------------------------------------- $message = $message ? $message : $this->member->sessionClass()->getMessage(); //------------------------------------------------------- // Remove all out of date sessions, like a good boy. Woof. //------------------------------------------------------- $cut_off_stamp = time() - 60 * 60 * 2; $this->DB->delete('core_sys_cp_sessions', "session_running_time < {$cut_off_stamp}"); //------------------------------------------------------ // Start form //------------------------------------------------------ $qs = str_replace('&', '&', IPSText::parseCleanValue(urldecode(my_getenv('QUERY_STRING')))); $qs = str_replace('adsess=', 'old_adsess=', $qs); $qs = str_replace('module=menu', '', $qs); $additional_data = $this->han_login->additionalFormHTML(); $replace = false; $data = array(); if (!is_null($additional_data) and is_array($additional_data) and count($additional_data)) { $replace = $additional_data[0]; $data = $additional_data[1]; } ipsRegistry::getClass('output')->html_title = $this->lang->words['ipb_login']; ipsRegistry::getClass('output')->html_main = str_replace('<%CONTENT%>', ipsRegistry::getClass('output')->global_template->log_in_form($qs, $message, $replace == 'replace' ? true : false, $data), ipsRegistry::getClass('output')->global_template->global_main_wrapper_no_furniture()); ipsRegistry::getClass('output')->html_main = str_replace('<%TITLE%>', ipsRegistry::getClass('output')->html_title, ipsRegistry::getClass('output')->html_main); @header("Content-type: text/html"); print ipsRegistry::getClass('output')->html_main; exit; }
/** * Log the user out * * @param string Message to show on the form * @return @e void */ public function loginForm($message = '') { //----------------------------------------- // Hang on, do we need the upgrader? //----------------------------------------- if (!IN_DEV and (!defined('SKIP_UPGRADE_CHECK') or !SKIP_UPGRADE_CHECK)) { require_once IPS_ROOT_PATH . 'setup/sources/base/setup.php'; /*noLibHook*/ foreach (ipsRegistry::$applications as $app_dir => $app) { $_a = ($app_dir == 'forums' or $app_dir == 'members') ? 'core' : $app_dir; $numbers = IPSSetUp::fetchAppVersionNumbers($_a); if ($numbers['latest'][0] and $numbers['latest'][0] > $numbers['current'][0]) { $this->registry->output->silentRedirect($this->settings['base_acp_url'] . '/upgrade/index.php?_acpRedirect=1'); return; } } } //----------------------------------------- // INIT //----------------------------------------- $message = $message ? $message : $this->member->sessionClass()->getMessage(); //------------------------------------------------------- // Remove all out of date sessions, like a good boy. Woof. //------------------------------------------------------- $cut_off_stamp = time() - 60 * 60 * 2; $this->DB->delete('core_sys_cp_sessions', "session_running_time < {$cut_off_stamp}"); //------------------------------------------------------ // Start form //------------------------------------------------------ $qs = str_replace('&', '&', IPSText::parseCleanValue(urldecode(my_getenv('QUERY_STRING')))); $qs = str_replace('adsess=', 'old_adsess=', $qs); $qs = str_replace('module=menu', '', $qs); $additional_data = $this->han_login->additionalFormHTML(); $replace = false; $data = array(); if (!is_null($additional_data) and is_array($additional_data) and count($additional_data)) { $replace = $additional_data[0]; $data = $additional_data[1]; } $uses_name = false; $uses_email = false; foreach (ipsRegistry::cache()->getCache('login_methods') as $method) { $login_methods[$method['login_folder_name']] = $method['login_folder_name']; if ($method['login_user_id'] == 'username' or $method['login_user_id'] == 'either') { $uses_name = true; } if ($method['login_user_id'] == 'email' or $method['login_user_id'] == 'either') { $uses_email = true; } } if ($uses_name and $uses_email) { $this->lang->words['gl_signinname'] = $this->lang->words['enter_name_and_email']; } else { if ($uses_email) { $this->lang->words['gl_signinname'] = $this->lang->words['enter_useremail']; } else { $this->lang->words['gl_signinname'] = $this->lang->words['enter_username']; } } ipsRegistry::getClass('output')->html_title = $this->lang->words['ipb_login']; ipsRegistry::getClass('output')->html_main = ipsRegistry::getClass('output')->global_template->log_in_form($qs, $message, $replace == 'replace' ? true : false, $data); ipsRegistry::getClass('output')->html_main = str_replace('<%TITLE%>', ipsRegistry::getClass('output')->html_title, ipsRegistry::getClass('output')->html_main); @header("Content-type: text/html"); print ipsRegistry::getClass('output')->html_main; exit; }
/** * Show the login form * * @param string Message to show on login form * @return string Login form HTML */ public function loginForm($message = "", $replacement = '') { //----------------------------------------- // INIT //----------------------------------------- $extra_form = ""; $show_form = 1; $template = ''; $serviceClick = trim($this->request['serviceClick']); //----------------------------------------- // Are they banned? //----------------------------------------- if (IPSMember::isBanned('ip', $this->member->ip_address)) { $this->registry->getClass('output')->showError('you_are_banned', 2011, null, null, 403); } if ($message != "") { if ($replacement) { $message = sprintf($this->lang->words[$message], $replacement); } else { $message = $this->lang->words[$message]; } $name = $this->request['UserName'] ? $this->request['UserName'] : $this->request['address']; $message = str_replace("<#NAME#>", "<b>" . $name . "</b>", $message); $template .= $this->registry->getClass('output')->getTemplate('login')->errors($message); } //----------------------------------------- // Using an alternate log in form? //----------------------------------------- $this->han_login->checkLoginUrlRedirect(); /* Did we click a service? */ if ($serviceClick) { switch ($serviceClick) { case 'facebook': $this->registry->getClass('output')->silentRedirect($this->settings['_original_base_url'] . "/interface/facebook/index.php?_reg=1"); break; case 'twitter': $this->registry->getClass('output')->silentRedirect($this->settings['_original_base_url'] . "/interface/twitter/index.php?_reg=1"); break; } } //----------------------------------------- // Extra HTML? //----------------------------------------- $additionalForm = $this->han_login->additionalFormHTML(); if (count($additionalForm[1])) { if ($additionalForm[0] == 'add') { $extra_form = $additionalForm[1]; $show_form = 1; } else { if (is_array($additionalForm[1])) { foreach ($additionalForm[1] as $_form) { $template .= $_form; } } else { $template .= $additionalForm[1]; } $show_form = 0; } } //----------------------------------------- // Continue... //----------------------------------------- if ($show_form) { if ($this->request['referer']) { $http_referrer = $this->request['referer']; } else { /* @link http://community.invisionpower.com/tracker/issue-32302-login-redirect-when-activating */ $_urlPieces = @parse_url($this->settings['board_url']); if (strpos(my_getenv('HTTP_REFERER'), $_urlPieces['host'] ? $_urlPieces['host'] : $this->settings['board_url']) !== false) { $http_referrer = my_getenv('HTTP_REFERER'); } else { $http_referrer = ''; } } $login_methods = false; $uses_name = false; $uses_email = false; foreach ($this->cache->getCache('login_methods') as $method) { $login_methods[$method['login_folder_name']] = $method['login_folder_name']; if ($method['login_user_id'] == 'username' or $method['login_user_id'] == 'either') { $uses_name = true; } if ($method['login_user_id'] == 'email' or $method['login_user_id'] == 'either') { $uses_email = true; } } if ($uses_name and $uses_email) { $this->lang->words['enter_name'] = $this->lang->words['enter_name_and_email']; } else { if ($uses_email) { $this->lang->words['enter_name'] = $this->lang->words['enter_useremail']; } else { $this->lang->words['enter_name'] = $this->lang->words['enter_username']; } } $template .= $this->registry->getClass('output')->getTemplate('login')->showLogInForm($this->lang->words['please_log_in'], htmlentities(urldecode($http_referrer)), $extra_form, $login_methods); } $this->registry->getClass('output')->addNavigation($this->lang->words['log_in'], ''); $this->registry->getClass('output')->setTitle($this->lang->words['log_in'] . ' - ' . ipsRegistry::$settings['board_name']); $this->registry->getClass('output')->addContent($template); $this->registry->getClass('output')->sendOutput(); }
/** * Show the login form * * @access public * @param string Message to show on login form * @return string Login form HTML */ public function loginForm($message = "", $replacement = '') { //----------------------------------------- // INIT //----------------------------------------- $extra_form = ""; $show_form = 1; $template = ''; //----------------------------------------- // Are they banned? //----------------------------------------- if (IPSMember::isBanned('ip', $this->member->ip_address)) { $this->registry->getClass('output')->showError('you_are_banned', 2011); } if ($message != "") { if ($replacement) { $message = sprintf($this->lang->words[$message], $replacement); } else { $message = $this->lang->words[$message]; } $name = $this->request['UserName'] ? $this->request['UserName'] : $this->request['address']; $message = str_replace("<#NAME#>", "<b>" . $name . "</b>", $message); $template .= $this->registry->getClass('output')->getTemplate('login')->errors($message); } //----------------------------------------- // Using an alternate log in form? //----------------------------------------- $this->han_login->checkLoginUrlRedirect(); //----------------------------------------- // Extra HTML? //----------------------------------------- $additionalForm = $this->han_login->additionalFormHTML(); if (count($additionalForm[1])) { if ($additionalForm[0] == 'add') { $extra_form = $additionalForm[1]; $show_form = 1; } else { $template .= $additionalForm[1]; $show_form = 0; } } //----------------------------------------- // Continue... //----------------------------------------- if ($show_form) { if ($this->request['referer']) { $http_referrer = $this->request['referer']; } else { if (!my_getenv('HTTP_REFERER') or stripos(my_getenv('HTTP_REFERER'), $this->settings['board_url']) === false) { // HTTP_REFERER isn't set when force_login is enabled // This method will piece together the base url, and the querystring arguments // This is not anymore secure/insecure than IPB, as IPB will have to process // those arguments whether force_login is enabled or not. $argv = is_array(my_getenv('argv')) && count(my_getenv('argv')) > 0 ? my_getenv('argv') : array(); $http_referrer = $this->settings['base_url'] . @implode("&", $argv); } else { $http_referrer = my_getenv('HTTP_REFERER'); } } $facebookOpts = array(); $login_methods = false; $uses_name = false; $uses_email = false; foreach ($this->cache->getCache('login_methods') as $method) { $login_methods[$method['login_folder_name']] = $method['login_folder_name']; if ($method['login_user_id'] == 'username') { $uses_name = true; } if ($method['login_user_id'] == 'email') { $uses_email = true; } } if ($uses_name and $uses_email) { $this->lang->words['enter_name'] = $this->lang->words['enter_name_and_email']; } else { if ($uses_email) { $this->lang->words['enter_name'] = $this->lang->words['enter_useremail']; } else { $this->lang->words['enter_name'] = $this->lang->words['enter_username']; } } $template .= $this->registry->getClass('output')->getTemplate('login')->showLogInForm($this->lang->words['please_log_in'], htmlentities(urldecode($http_referrer)), $extra_form, $login_methods, $facebookOpts); } /* Work around for bug http://bugs.developers.facebook.com/show_bug.cgi?id=3237 */ if (IPSLib::fbc_enabled()) { $this->_facebook->testConnectSession(); } $this->registry->getClass('output')->addNavigation($this->lang->words['log_in'], ''); $this->registry->getClass('output')->setTitle($this->lang->words['log_in']); $this->registry->getClass('output')->addContent($template); $this->registry->getClass('output')->sendOutput(); }