/** * Check and verify the login was successful * * @return @e void */ public function loginComplete() { /* Fetch sessions API */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/session/api.php', 'session_api'); $publicApi = new $classToLoad($this->registry); //----------------------------------------- // Check form details. //----------------------------------------- $username = ''; $email = ''; //----------------------------------------- // Is this a username or email address? //----------------------------------------- $_type = $this->han_login->emailOrUsername(); switch ($_type) { case 1: $username = $this->request['username']; break; case 2: $email = $this->request['username']; break; case 3: $username = $this->request['username']; $email = $this->request['username']; break; } //----------------------------------------- // Check auth //----------------------------------------- $this->han_login->loginAuthenticate($username, $email, trim($this->request['password'])); //----------------------------------------- // Check return code... //----------------------------------------- $mem = $this->han_login->member_data; if (!$mem['member_id'] or $this->han_login->return_code == 'NO_USER') { $this->_writeToLog($this->request['username'], 'fail'); $this->loginForm($this->lang->words['bad_email_password']); } if ($this->han_login->return_code == 'NO_ACCESS') { $this->_writeToLog($this->request['username'], 'fail'); $this->loginForm($this->lang->words['no_acp_access']); } else { if ($this->han_login->return_code != 'SUCCESS') { $this->_writeToLog($this->request['username'], 'fail'); $this->loginForm($this->lang->words['bad_email_password']); } } //----------------------------------------- // And sort secondary groups... //----------------------------------------- $mem = $this->member->setUpSecondaryGroups($mem); //----------------------------------------- // Check access... //----------------------------------------- if ($mem['g_access_cp'] != 1) { $this->_writeToLog($this->request['username'], 'fail'); $this->loginForm($this->lang->words['no_acp_access']); } else { //----------------------------------------- // Fix up query string... //----------------------------------------- $extra_query = ""; if ($_POST['qstring']) { $extra_query = stripslashes(htmlspecialchars($_POST['qstring'])); $extra_query = str_replace($this->settings['_original_base_url'], "", $extra_query); $extra_query = str_ireplace("?index." . $this->settings['php_ext'], "", $extra_query); $extra_query = ltrim($extra_query, '?'); $extra_query = preg_replace('!adsess=(\\w){32}!', "", $extra_query); $extra_query = str_replace("adsess=x", "", $extra_query); $extra_query = str_replace(array('old_&', 'old_&'), "", $extra_query); $extra_query = preg_replace('!s=(\\w){32}!', "", $extra_query); $extra_query = str_replace("module=login", "", $extra_query); $extra_query = str_replace("do=login-complete", "", $extra_query); $extra_query = str_replace("/admin", "", $extra_query); $extra_query = str_replace('&', '&', $extra_query); $extra_query = preg_replace("#&{1,}#", "&", $extra_query); $extra_query = preg_replace("#messageinabottleacp=(.*?)\$#", "", $extra_query); } //----------------------------------------- // Insert session //----------------------------------------- $sess_id = md5(uniqid(microtime())); $this->DB->delete('core_sys_cp_sessions', 'session_member_id=' . $mem['member_id']); /* Grab user agent */ $uAgent = array(); $this->DB->insert('core_sys_cp_sessions', array('session_id' => $sess_id, 'session_ip_address' => $this->member->ip_address, 'session_member_name' => $mem['members_display_name'], 'session_member_id' => $mem['member_id'], 'session_member_login_key' => $mem['member_login_key'], 'session_location' => 'index', 'session_log_in_time' => time(), 'session_running_time' => time(), 'session_app_data' => serialize($uAgent), 'session_url' => '')); $this->request['adsess'] = $sess_id; /* Log them in public side if not already */ $publicApi->logGuestInAsMember($mem['member_id']); //----------------------------------------- // Redirect... //----------------------------------------- if ($extra_query) { $url = $this->settings['_original_base_url'] . '/' . CP_DIRECTORY . '/index.php?adsess=' . $sess_id . '&' . $extra_query; } else { /* Load main page? */ require_once IPS_ROOT_PATH . 'sources/classes/admin/bookmarks.php'; $bookmarks = new classes_admin_bookmarks(); $bookmarks->setMember($mem['member_id']); $home = $bookmarks->getHomeUrl(); if ($home !== false) { $url = $this->settings['_original_base_url'] . '/' . CP_DIRECTORY . '/index.php?adsess=' . $sess_id . '&' . $home; } else { $url = $this->settings['_original_base_url'] . '/' . CP_DIRECTORY . '/index.php?adsess=' . $sess_id; } } $this->_writeToLog($this->request['username'], 'ok'); ipsRegistry::getClass('output')->global_message = ''; ipsRegistry::getClass('output')->silentRedirect($url); } }
/** * Output the HTML to the browser * * @param bool Return finished output instead of printing * @return @e void */ public function sendOutput($return = false) { $this->_sendOutputSetUp('normal'); //----------------------------------------- // Hang on, is IP.SEO still installed? //----------------------------------------- if (IPSLib::appIsInstalled('ipseo') and !in_array(ipsRegistry::$request['section'], array('upgrade', 'applications'))) { $this->silentRedirect($this->settings['_base_url'] . 'app=core&module=seo&section=upgrade'); } //--------------------------------------- // INIT //----------------------------------------- $clean_module = IPSText::alphanumericalClean(ipsRegistry::$current_module); $navigation = array(); $_seen_nav = array(); $_last_nav = ''; $no_wrapper = FALSE; //----------------------------------------- // Inline pop-up? //----------------------------------------- if (ipsRegistry::$request['_popup']) { $this->printPopupWindow(); exit; } //----------------------------------------- // Debug? //----------------------------------------- if ($this->DB->obj['debug']) { flush(); print "<html><head><title>SQL Debugger</title><body bgcolor='white'><style type='text/css'> TABLE, TD, TR, BODY { font-family: verdana,arial, sans-serif;color:black;font-size:11px }</style>"; print "<h1 align='center'>SQL Total Time: {$this->DB->sql_time} for {$this->DB->query_cnt} queries</h1><br />" . $this->DB->debug_html; print "<br /><div align='center'><strong>Total SQL Time: {$this->DB->sql_time}</div></body></html>"; exit; } //----------------------------------------- // Context sensitive stuff //----------------------------------------- if (!$this->cm_output) { $_file = IPSLib::getAppDir(IPS_APP_COMPONENT) . '/skin_cp/cp_skin_' . $clean_module . '_context_menu.php'; if (is_file($_file)) { $_class = IPSLib::loadLibrary($_file, 'cp_skin_' . $clean_module . '_context_menu', IPS_APP_COMPONENT); $context_menu = new $_class($this->registry); $cm_function_full = ipsRegistry::$request['do'] ? 'context_menu__' . $clean_module . '__' . ipsRegistry::$request['section'] . '__' . ipsRegistry::$request['do'] : 'context_menu__' . $clean_module . '__' . ipsRegistry::$request['section']; $cm_function = 'context_menu__' . $clean_module . '__' . ipsRegistry::$request['section']; $cm_module = 'context_menu__' . $clean_module; if (method_exists($_class, $cm_function_full)) { $this->cm_output = $context_menu->__wrap($context_menu->{$cm_function_full}()); } else { if (method_exists($_class, $cm_function)) { $this->cm_output = $context_menu->__wrap($context_menu->{$cm_function}()); } else { if (method_exists($_class, $cm_module)) { $this->cm_output = $context_menu->__wrap($context_menu->{$cm_module}()); } } } } } /** * Add in bookmarkables */ require_once IPS_ROOT_PATH . 'sources/classes/admin/bookmarks.php'; $bookmarks = new classes_admin_bookmarks(); $_bookmarkData = array('url' => $bookmarks->cleanUrl($this->settings['query_string_safe']), 'can' => $this->_canBookmark ? 'true' : 'false', 'has' => $bookmarks->hasBookmarked($this->settings['query_string_safe']) ? 'true' : 'false', 'jsn' => $bookmarks->asJson()); //----------------------------------------- // Get tab order //----------------------------------------- $applications = ipsRegistry::$applications; $mainTabs = $this->registry->output->getMainTabKeys(); $otherTabs = $this->registry->output->getOtherTabKeys(); $mainTabData = $this->registry->output->getTabDataFromKeys($mainTabs); $otherTabData = $this->registry->output->getTabDataFromKeys($otherTabs); $gbl_sub_menu = $this->_buildGlobalSubMenu(); $html = str_replace('<%CONTENT%>', $this->html_main, $this->global_template->global_main_wrapper(IPS_DOC_CHAR_SET, $this->_css, $gbl_sub_menu, $mainTabData, $otherTabData, $_bookmarkData)); //------------------------------------------------ // Message in a bottle? //------------------------------------------------ $message = ''; if ($this->global_error) { $message = $this->global_template->global_error_message(); } if ($this->global_message) { $message .= $message ? '<br />' . $this->global_template->global_message() : $this->global_template->global_message(); } //----------------------------------------- // Figure out title... //----------------------------------------- $this->html_title = "IP.Board:"; if (ipsRegistry::$current_application) { $this->html_title .= " " . IPSLIb::getAppTitle(ipsRegistry::$current_application); if (ipsRegistry::$current_module) { $this->html_title .= " > " . (isset($this->lang->words['module__' . ipsRegistry::$current_application . '_' . ipsRegistry::$current_module]) ? $this->lang->words['module__' . ipsRegistry::$current_application . '_' . ipsRegistry::$current_module] : ipsRegistry::$modules_by_section[ipsRegistry::$current_application][ipsRegistry::$current_module]['sys_module_title']); } } if (count($this->extra_title)) { $this->html_title .= " > " . implode(' > ', $this->extra_title); } //----------------------------------------- // Got app menu cache? //----------------------------------------- if (!is_array(ipsRegistry::cache()->getCache('app_menu_cache')) or !count(ipsRegistry::cache()->getCache('app_menu_cache'))) { $this->cache->rebuildCache('app_menu_cache', 'global'); } //----------------------------------------- // Other tags... //----------------------------------------- // Can set the second one to none to hide left menu when no context nav is available $html = str_replace("<%DISPLAY_SUB_MENU%>", $this->cm_output ? '' : 'none', $html); $html = str_replace("<%TITLE%>", $this->html_title, $html); $html = str_replace("<%SUBMENU%>", $this->_buildSubMenu(), $html); # Must be called first $html = str_replace("<%MENU%>", $this->_buildMenu(), $html); $html = str_replace("<%SIDEBAR_EXTRA%>", $this->sidebar_extra, $html); $html = str_replace("<%CONTEXT_MENU%>", $this->cm_output, $html); $html = str_replace("<%SECTIONCONTENT%>", $this->html, $html); # This has to be called after the menu has been set so that query_string is set correctly $html = str_replace("<%MSG%>", $message, $html); //----------------------------------------- // Fix up navigation //----------------------------------------- if (count($this->core_nav)) { foreach ($this->core_nav as $data) { if (isset($_seen_nav[$data[1]])) { continue; } else { $_seen_nav[$data[1]] = 1; } $_nav = isset($_last_nav['nav']) ? $_last_nav['nav'] . ' > ' . $data[1] : $data[1]; # Append last nav... $_last_nav = array('url' => $data[0], 'title' => $data[1], 'nav' => $_nav); if ($data[0]) { $navigation[] = "<a href='" . $data[0] . "'>" . $data[1] . "</a>"; } else { $navigation[] = $data[1]; } } } if (count($this->extra_nav)) { foreach ($this->extra_nav as $data) { if (isset($_seen_nav[$data[1]])) { continue; } else { $_seen_nav[$data[1]] = 1; } $_nav = isset($_last_nav['nav']) ? $_last_nav['nav'] . ' > ' . $data[1] : $data[1]; # Append last nav... $_last_nav = array('url' => $data[0], 'title' => $data[1], 'nav' => $_nav); if ($data[0]) { $navigation[] = "<a href='" . $data[0] . "'>" . $data[1] . "</a>"; } else { $navigation[] = $data[1]; } } } //------------------------------------------------ // Navigation? //------------------------------------------------ if (count($navigation) > 0) { $html = str_replace("<%NAV%>", $this->global_template->wrap_nav("<li>" . implode(" > </li><li>", $navigation) . "</li>"), $html); } else { $html = str_replace("<%NAV%>", '', $html); } //----------------------------------------- // Last thing, the nav element... //----------------------------------------- if (isset($_last_nav['title'])) { $html = str_replace("<%PAGE_NAV%>", $_last_nav['title'], $html); } $query_html = ""; //----------------------------------------- // Show SQL queries //----------------------------------------- if (IN_DEV and count($this->DB->obj['cached_queries'])) { $queries = ""; foreach ($this->DB->obj['cached_queries'] as $q) { $queries .= "<div style='padding:6px; border-bottom:1px solid #000'>" . htmlspecialchars($q) . '</div>'; } $query_html .= $this->global_template->global_query_output($queries); /* Included Files */ if (function_exists('get_included_files')) { $__files = get_included_files(); $files = ''; foreach ($__files as $__f) { $files .= "<strong>{$__f}</strong><br />"; } $query_html .= $this->global_template->global_if_output(count($__files), $files); } } //----------------------------------------- // Memory usage //----------------------------------------- if (IPS_MEMORY_DEBUG_MODE and defined('IPS_MEMORY_START') and IN_DEV) { if (is_array(IPSDebug::$memory_debug)) { $memory = ''; $_c = 0; foreach (IPSDebug::$memory_debug as $usage) { $_c++; if ($usage[1] > 500 * 1024) { $_col = "color:#D00000"; } else { if ($usage[1] < 10 * 1024) { $_col = "color:darkgreen"; } else { if ($usage[1] < 100 * 1024) { $_col = "color:darkorange"; } } } $memory .= "<tr><td width='60%' style='{$_col}' align='left'>{$usage[0]}</td><td style='{$_col}' align='left'><strong>" . IPSLib::sizeFormat($usage[1]) . "</strong></td></tr>"; } } $_used = memory_get_usage() - IPS_MEMORY_START; $peak_used = memory_get_peak_usage() - IPS_MEMORY_START; $query_html .= $this->global_template->global_memory_output($memory, IPSLib::sizeFormat($_used), IPSLib::sizeFormat($peak_used)); } $html = str_replace("<%QUERIES%>", $query_html, $html); //----------------------------------------- // Got BODY EXTRA? //----------------------------------------- if ($this->body_extra) { $html = str_replace("<body", "<body " . $this->body_extra, $html); } //----------------------------------------- // Emoticons fix //----------------------------------------- $html = str_replace("<#EMO_DIR#>", 'default', $html); /* Remove any public side hooks */ $html = preg_replace('#<!--hook\\.([^\\>]+?)-->#', '', $html); //----------------------------------------- // Gzip? //----------------------------------------- if (IPB_ACP_USE_GZIP) { $buffer = ""; if (count(ob_list_handlers())) { $buffer = ob_get_contents(); ob_end_clean(); } ob_start('ob_gzhandler'); print $buffer; } @header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); @header("Cache-Control: no-cache, must-revalidate"); @header("Pragma: no-cache"); @header("Content-type: text/html; charset=" . IPS_DOC_CHAR_SET); //----------------------------------------- // OUTPUT //----------------------------------------- if ($return) { $this->_IS_PRINTED = 1; return $html; } print $html; $this->_IS_PRINTED = 1; exit; }