/** * 初始化 * */ public function init() { $this->set('currentUrl', Request::currentUrl()); $this->set('refererUrl', Request::refererUrl()); $this->set('controller', Router::getController()); $this->set('action', Router::getAction()); $this->set('get', Request::getGet()); $this->set('post', Request::getPost()); }
/** * 记录 * * @return boolean */ public static function write($param = array()) { if (!self::checkLog()) { return false; } $logFile = self::getLogFileName(); $param = http_build_query($param); $log = sprintf("[%s][IMP_LOG]\t%s\t%s\t%s\t%f\t%s\t%s", date("Y-m-d H:i:s"), microtime(true) - $_Sys['beginTime'], Imp::app()->instance('router')->getController(), Imp::app()->instance('router')->getAction(), Request::currentUrl(), $param); file_put_contents($logFile, $log, FILE_APPEND); }
/** * * @return boolean */ public static function log() { global $_Sys; if (!self::checkLog()) { return false; } $logFile = self::_getLogFileName(); $endTime = microtime(true); $log = sprintf("[%s][SUCCESS][Time:%f] Url %s", date("Y-m-d H:i:s"), $endTime - $_Sys['beginTime'], Request::currentUrl()); $fp = @fopen($logFile, "ab+"); @fwrite($fp, $log . "\r\n"); @fclose($fp); }
/** * forces SSL request * * @see core/components/SecurityComponent::secureRequired() */ public function forceSSL() { $secured = "https://" . $this->request->currentUrl(); Redirector::to($secured); }
function imp_error_handler($error, $error_string, $filename, $line, $symbols) { $error_no_arr = array(1 => 'ERROR', 2 => 'WARNING', 4 => 'PARSE', 8 => 'NOTICE', 16 => 'CORE_ERROR', 32 => 'CORE_WARNING', 64 => 'COMPILE_ERROR', 128 => 'COMPILE_WARNING', 256 => 'USER_ERROR', 512 => 'USER_WARNING', 1024 => 'USER_NOTICE', 2047 => 'ALL', 2048 => 'STRICT'); if (in_array($error, array_keys($error_no_arr))) { $time = date("Y-m-d H:i:s"); $msg = sprintf("[%s][%s] Url %s %s at file %s(%s)", $time, $error_no_arr[$error], Request::currentUrl(), $error_string, $filename, $line); } }
/** * the current url * * @return string */ public static function getCurrentUrl() { return Request::currentUrl(); }