class utils {/* */ public static function IsModeCLI() { $sSAPIName = php_sapi_name(); $sCleanName = strtolower(trim($sSAPIName)); if ($sCleanName == ‘cli‘) { return true; } else { return false; } } /* */
使用方法;
if (utils::IsModeCLI()) { $sAuthUser = utils::ReadParam(‘auth_user‘, ‘admin‘, true); $sAuthPwd = utils::ReadParam(‘auth_pwd‘, ‘asset$IT‘, true); if (UserRights::CheckCredentials($sAuthUser, $sAuthPwd)) { UserRights::Login($sAuthUser); // Login & set the user‘s language } else { echo "Access restricted or wrong credentials (‘$sAuthUser‘)"; exit; } } else { $_SESSION[‘login_mode‘] = ‘basic‘; require_once(‘../application/loginwebpage.class.inc.php‘); LoginWebPage::DoLogin(); // Check user rights and prompt if needed $sCSVData = utils::ReadPostedParam(‘csvdata‘); }
时间: 2024-10-10 04:39:10