/** * A static method to display a login screen * * @static * * @param string $sMessage * @param string $sessionID * @param bool $inlineLogin */ function displayLogin($sMessage = '', $sessionID = 0, $inLineLogin = false) { global $strUsername, $strPassword, $strLogin, $strWelcomeTo, $strEnterUsername, $strNoAdminInteface, $strForgotPassword; $aConf = $GLOBALS['_MAX']['CONF']; $aPref = $GLOBALS['_MAX']['PREF']; @header('Cache-Control: max-age=0, no-cache, proxy-revalidate, must-revalidate'); if (!$inLineLogin) { phpAds_PageHeader(phpAds_Login); } // Check environment settings $oSystemMgr = new OA_Environment_Manager(); $aSysInfo = $oSystemMgr->checkSystem(); foreach ($aSysInfo as $env => $vals) { $errDetails = ''; if (is_array($vals['error']) && !empty($vals['error'])) { if ($env == 'PERMS') { // Just note that some file/folders are unwritable and that more information can be found in the debug.log OA_Admin_UI::queueMessage('Error: File permission errors detected.<br />These <em>may</em> impact the accurate delivery of your ads,<br />See the debug.log file for the list of unwritable files', 'global', 'error', 0); } else { foreach ($vals['error'] as $key => $val) { $errDetails .= '<li>' . htmlspecialchars($key) . ' => ' . htmlspecialchars($val) . '</li>'; } phpAds_Die(' Error: ' . $err, $errDetails); } } } $oTpl = new OA_Admin_Template('login.html'); $appName = !empty($aConf['ui']['applicationName']) ? $aConf['ui']['applicationName'] : PRODUCT_NAME; $oTpl->assign('uiEnabled', $aConf['ui']['enabled']); $oTpl->assign('sessionID', $sessionID); $oTpl->assign('appName', $appName); $oTpl->assign('message', $sMessage); $oTpl->display(); phpAds_PageFooter(); exit; }
/** * A static method to display a login screen * * @static * * @param string $sMessage * @param string $sessionID * @param bool $inlineLogin */ function displayLogin($sMessage = '', $sessionID = 0, $inLineLogin = false) { global $strUsername, $strPassword, $strLogin, $strWelcomeTo, $strEnterUsername, $strNoAdminInteface, $strForgotPassword; $aConf = $GLOBALS['_MAX']['CONF']; $aPref = $GLOBALS['_MAX']['PREF']; header('Cache-Control: max-age=0, no-cache, proxy-revalidate, must-revalidate'); if (!$inLineLogin) { phpAds_PageHeader(phpAds_Login); } // Check environment settings $oSystemMgr = new OA_Environment_Manager(); $aSysInfo = $oSystemMgr->checkSystem(); foreach ($aSysInfo as $env => $vals) { $errDetails = ''; if (is_array($vals['error'])) { $errDetails = '<ul>'; if ($env == 'PERMS') { foreach ($vals['actual'] as $key => $val) { if ($val['error']) { $errDetails .= '<li>' . htmlspecialchars($val['file']) . ' ' . htmlspecialchars($val['result']) . '</li>'; } } } else { foreach ($vals['actual'] as $key => $val) { $errDetails .= '<li>' . htmlspecialchars($key) . ' => ' . htmlspecialchars($val) . '</li>'; } } $errDetails .= '</ul>'; foreach ($vals['error'] as $key => $err) { phpAds_Die(' Error: ' . $err, $errDetails); } } } $oTpl = new OA_Admin_Template('login.html'); // we build the URL of the current page to use a redirect URL after login // this code should work on all server configurations hence why it is a bit complicated // inspired by http://dev.piwik.org/svn/trunk/core/Url.php getCurrentUrl() $url = ''; if (!empty($_SERVER['PATH_INFO'])) { $url = $_SERVER['PATH_INFO']; } else { if (!empty($_SERVER['REQUEST_URI'])) { if (($pos = strpos($_SERVER['REQUEST_URI'], "?")) !== false) { $url = substr($_SERVER['REQUEST_URI'], 0, $pos); } else { $url = $_SERVER['REQUEST_URI']; } } } if (empty($url)) { $url = $_SERVER['SCRIPT_NAME']; } if (!empty($_SERVER['QUERY_STRING'])) { $url .= '?' . $_SERVER['QUERY_STRING']; } if (!empty($url)) { // remove any extra slashes that would confuse the browser (see OX-5234) $url = '/' . ltrim($url, '/'); } $appName = !empty($aConf['ui']['applicationName']) ? $aConf['ui']['applicationName'] : MAX_PRODUCT_NAME; $oTpl->assign('uiEnabled', $aConf['ui']['enabled']); $oTpl->assign('formAction', $url); $oTpl->assign('sessionID', $sessionID); $oTpl->assign('appName', $appName); $oTpl->assign('message', $sMessage); $oTpl->display(); phpAds_PageFooter(); exit; }