/** * Creates a new Error. * * @param string $message * @param Error|null $error */ protected function __construct($message, Error $error = null) { if (null != $error) { $message = $error->message() . ' -> ' . $message; } $this->message = $message; }
public function connect($config = array()) { $this->config = $config; if (strstr($this->config['driver'], '->')) { $subdrivers = explode('->', $this->config['driver']); $this->select_driver = $subdrivers[1]; } if (empty($this->select_driver)) { $this->select_driver = 'mysql'; } if (!in_array($this->select_driver, $this->pdo_subdrivers)) { die(Error::message('Database', 'driverError', $this->select_driver)); } $this->connect = $this->_sub_drivers($this->config['user'], $this->config['password']); // Mysql için karakterseti sorguları if ($this->select_driver === 'mysql') { if (!empty($this->config['charset'])) { $this->connect->exec("SET NAMES '" . $this->config['charset'] . "'"); } if (!empty($this->config['charset'])) { $this->connect->exec('SET CHARACTER SET ' . $this->config['charset']); } if (!empty($this->config['collation'])) { $this->connect->exec("SET COLLATION_CONNECTION = '" . $this->config['collation'] . "'"); } } }
public function run($functionName = '', $functionRun = '') { $datas = Structure::datas(); $parameters = $datas['parameters']; $isFile = $datas['isFile']; $function = $datas['function']; if (file_exists($isFile)) { if ($functionName === $function) { if (is_callable($functionRun)) { if (APP_TYPE === 'local') { set_error_handler('Exceptions::table'); } call_user_func_array($functionRun, $parameters); if (APP_TYPE === 'local') { restore_error_handler(); } } else { // Sayfa bilgisine erişilemezse hata bildir. if (!Config::get('Route', 'show404')) { // Hatayı ekrana yazdır. echo Error::message('Error', 'callUserFuncArrayError', $functionRun); // Hatayı rapor et. report('Error', getMessage('Error', 'callUserFuncArrayError'), 'SystemCallUserFuncArrayError'); // Çalışmayı durdur. return false; } else { redirect(Config::get('Route', 'show404')); } } } } }
public function render($includeFile) { if (file_exists($includeFile)) { foreach ($this->templateParams as $param => $value) { ${$param} = $value; } include_once $includeFile; } else { Error::message('Template não encontrado.'); } }
public function output() { $template = Loader::find('template', true); if (!file_exists($template)) { return Error::message(404, 'Oh No!', 'We can\'t seem to locate the template file. Please try visiting the <a href="/">home page</a>.'); } ob_start(); include $template; $this->output = ob_get_contents(); ob_end_clean(); return $this->output; }
public function run($functionName = '', $functionRun = '', $route = array()) { if (!empty($this->route)) { $route = $this->route; } if (is_array($route) && !empty($route)) { Config::set('Route', 'changeUri', $route); } $datas = Structure::data(); $parameters = $datas['parameters']; $isFile = $datas['file']; $function = $datas['function']; if (($functionName === 'construct' || $functionName === 'destruct') && is_callable($functionRun)) { call_user_func_array($functionRun, $parameters); } if (file_exists($isFile)) { if (strtolower($function) === 'index' && strtolower($functionName) === 'main') { $function = 'main'; } if ($functionName === $function) { if (is_callable($functionRun)) { call_user_func_array($functionRun, $parameters); } else { // Sayfa bilgisine erişilemezse hata bildir. if (!Config::get('Route', 'show404')) { // Hatayı rapor et. report('Error', lang('Error', 'callUserFuncArrayError'), 'SystemCallUserFuncArrayError'); // Hatayı ekrana yazdır. die(Error::message('Error', 'callUserFuncArrayError', $functionRun)); } else { redirect(Config::get('Route', 'show404')); } } } } }
/** * 错误信息 * @author wave */ function error() { Error::message(); exit; }
public static function display($tmpl = null) { if ($tmpl == null) { $tmpl = 'default'; } $pathang = pathang::getInstance('pathang'); $snippet = $pathang->get('snippet'); $file = $file = 'snippets' . DS . $snippet . DS . 'tmpl' . DS . $tmpl . '.php'; if (file_exists($file)) { require_once $file; } else { Error::message("Snippet {$snippet} template file {$tmpl} not found"); } }
/** * Generate error message and quit script execution * * Alias for message(), but with added die() function call. * * @param string $code HTTP Status Code * @param string $title Error Title * @param string $message Error Message * @return string $output * @author Jay Williams */ static function quit($code = 404, $title = '', $message = '') { return die(Error::message($code, $title, $message)); }
public function errval($errno = 0) { if (!isPhpVersion('5.5.0')) { die(Error::message('Error', 'invalidVersion', array('%' => 'curl_version', '#' => '5.5.0'))); } if (!is_numeric($errno)) { return Error::set('Error', 'numericParameter', '1.(errno)'); } return curl_strerror($errno); }
public static function data() { //------------------------------------------------------------------------------------------------ // Page //------------------------------------------------------------------------------------------------ // // @var string // //------------------------------------------------------------------------------------------------ $page = ''; //------------------------------------------------------------------------------------------------ // Function //------------------------------------------------------------------------------------------------ // // @var string // //------------------------------------------------------------------------------------------------ $function = 'index'; //------------------------------------------------------------------------------------------------ // Parameters //------------------------------------------------------------------------------------------------ // // @var array // //------------------------------------------------------------------------------------------------ $parameters = array(); //------------------------------------------------------------------------------------------------ // Segments //------------------------------------------------------------------------------------------------ // // @var string // //------------------------------------------------------------------------------------------------ $segments = ''; //------------------------------------------------------------------------------------------------ // Is File //------------------------------------------------------------------------------------------------ // // @var string // //------------------------------------------------------------------------------------------------ $isFile = ''; //------------------------------------------------------------------------------------------------ // Request Uri //------------------------------------------------------------------------------------------------ // // @var string // //------------------------------------------------------------------------------------------------ $requestUri = requestUri(); //------------------------------------------------------------------------------------------------ // $_GET kontrolü yapılarak temel URL bilgisi elde ediliyor. //------------------------------------------------------------------------------------------------ $url = explode('?', $requestUri); //------------------------------------------------------------------------------------------------ // Temel URL adresi / karakteri ile bölümlere ayrılıyor. //------------------------------------------------------------------------------------------------ $segments = explode('/', $url[0]); //------------------------------------------------------------------------------------------------ // Controller/Sayfa: Controller/ dizini içinde çalıştırılacak dosya adı. //------------------------------------------------------------------------------------------------ if (isset($segments[0])) { $page = $segments[0]; $isFile = restorationPath(CONTROLLERS_DIR . suffix($page, '.php')); // Kontrolcüler Controllers/ dizini içinde // farklı bir dizinde yer alıyorsa bu bölüm // ile o kontrolcülere erişim sağlanıyor. if (!is_file($isFile)) { $if = ''; $nsegments = $segments; for ($i = 0; $i < count($segments); $i++) { $if .= $segments[$i] . '/'; $ifTrim = rtrim($if, '/'); $isF = restorationPath(CONTROLLERS_DIR . suffix($ifTrim, '.php')); if (is_file($isF)) { $page = divide($ifTrim, '/', -1); $isFile = $isF; $segments = $nsegments; break; } array_shift($nsegments); } } unset($segments[0]); $pageControl = strtolower($page); // Bir Controller/ dosyası index kelimesi ile isimlendirilemez! if ($pageControl === 'index' || $pageControl === 'main') { // Hatayı rapor et. report('Error', lang('Error', 'controllerNameError', $pageControl), 'ControllerNameError'); // Hatayı ekrana yazdır. die(Error::message('Error', 'controllerNameError', $pageControl)); } } //------------------------------------------------------------------------------------------------ // Restore Modu //------------------------------------------------------------------------------------------------ if (APPMODE === 'restoration') { Restoration::mode(); } //------------------------------------------------------------------------------------------------ // Fonksiyon: Çalıştırılacak dosyaya ait yöntem adı. //------------------------------------------------------------------------------------------------ if (isset($segments[1])) { $function = $segments[1]; unset($segments[1]); } //------------------------------------------------------------------------------------------------ // Parametreler: Çalıştırılacak yönteme gönderilecek parametreler. //------------------------------------------------------------------------------------------------ if (isset($segments[2])) { $parameters = $segments; } //------------------------------------------------------------------------------------------------ // Return Array //------------------------------------------------------------------------------------------------ // // @key array $parameters // @key string $page // @key string $file // @key string $function // //------------------------------------------------------------------------------------------------ return array('parameters' => $parameters, 'page' => $page, 'file' => $isFile, 'function' => $function); }
/** * Sets up the error class with data from the thrown error. * * @access public * @static * @final * @param object $e The exception that was thrown */ public static final function setupError($e) { // call hook Hook::call('Error.setupError.before', array(&$e)); if (is_object($e)) { self::$message = $e->getMessage(); self::$code = $e->getCode(); self::$file = $e->getFile(); self::$line = $e->getLine(); self::$trace = $e->getTrace(); self::$params = $e->getParams(); self::$triggered = true; } // call hook Hook::call('Error.setupError.after'); }
public static function run() { $datas = self::datas(); $parameters = $datas['parameters']; $page = $datas['page']; $isFile = $datas['isFile']; $function = $datas['function']; // TAMPONLAMA BAŞLATILIYOR... if (Config::get('Cache', 'obGzhandler') && substr_count(server('acceptEncoding'), 'gzip')) { ob_start('ob_gzhandler'); } else { ob_start(); } // ---------------------------------------------------------------------- // BAŞLIK BİLGİLERİ DÜZENLENİYOR... headers(Config::get('Headers', 'settings')); // ---------------------------------------------------------------------- // SAYFA KONTROLÜ YAPILIYOR... // ------------------------------------------------------------------------------- // Sayfa bilgisine erişilmişse sayfa dahil edilir. // ------------------------------------------------------------------------------- if (file_exists($isFile)) { // ------------------------------------------------------------------------------- // Tadilat modu açıksa bu ayarlar geçerli olacaktır. // ------------------------------------------------------------------------------- if (Config::get('Repair', 'mode') === true) { Repair::mode(); } // ------------------------------------------------------------------------------- // Sayfa dahil ediliyor. // ------------------------------------------------------------------------------- require_once $isFile; // ------------------------------------------------------------------------------- // Sayfaya ait controller nesnesi oluşturuluyor. // ------------------------------------------------------------------------------- if (class_exists($page, false)) { $var = new $page(); // ------------------------------------------------------------------------------- // Sınıf ve yöntem bilgileri geçerli ise sayfayı çalıştır. // ------------------------------------------------------------------------------- if (is_callable(array($var, $function))) { if (APP_TYPE === 'local') { set_error_handler('Exceptions::table'); } call_user_func_array(array($var, $function), $parameters); if (APP_TYPE === 'local') { restore_error_handler(); } } else { // Sayfa bilgisine erişilemezse hata bildir. if (!Config::get('Route', 'show404')) { // Hatayı ekrana yazdır. echo Error::message('Error', 'callUserFuncArrayError', $function); // Hatayı rapor et. report('Error', getMessage('Error', 'callUserFuncArrayError'), 'SystemCallUserFuncArrayError'); // Çalışmayı durdur. return false; } else { redirect(Config::get('Route', 'show404')); } } } } else { // Sayfa bilgisine erişilemezse hata bildir. if (Config::get('Route', 'show404')) { redirect(Config::get('Route', 'show404')); } else { // Hatayı ekrana yazdır. echo Error::message('Error', 'notIsFileError', $isFile); // Hatayı rapor et. report('Error', getMessage('Error', 'notIsFileError'), 'SystemNotIsFileError'); // Çalışmayı durdur. return false; } } // ---------------------------------------------------------------------- // TAMPONLAMA KAPATILIYOR... ob_end_flush(); // ---------------------------------------------------------------------- }
} } //---------------------------------------------------------------------------------------------------- // El ile Yüklenen Fonksiyonlar //---------------------------------------------------------------------------------------------------- if (!empty($starting['handload'])) { Import::handload($starting['handload']); } //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- // Composer Autoload İşlemi //---------------------------------------------------------------------------------------------------- $composer = Config::get('Composer', 'autoload'); if ($composer === true) { //------------------------------------------------------------------------------------------------ // Varsayılan Yol: vendor/autoload.php //------------------------------------------------------------------------------------------------ $path = 'vendor/autoload.php'; if (file_exists($path)) { require_once $path; } else { report('Error', lang('Error', 'fileNotFound', $path), 'AutoloadComposer'); die(Error::message('Error', 'fileNotFound', $path)); } } elseif (is_file($composer)) { require_once $composer; } elseif (!empty($composer)) { report('Error', lang('Error', 'fileNotFound', $composer), 'AutoloadComposer'); die(Error::message('Error', 'fileNotFound', $composer)); } //----------------------------------------------------------------------------------------------------
public static function run() { /* Page Değişkeni * * Controller/page.php bilgisini * tutması çin oluşturulmuştur. */ $page = ''; /* Function Değişkeni * * Page/Function bilgisini * tutaması için oluşturulmuştur. */ $function = 'index'; /* Parameters Dizi Değişkeni * * Url adresindeki parametre bilgilerini * tutması için oluşturulmuştur. */ $parameters = array(); /* Segments Değişkeni * * Url adresinin parametre bölümlerini * tutması için oluşturulmuştur. */ $segments = ''; /* Is Fıle Değişkeni * * Girilen Url adresinin geçerli bir. * sayfa olma durumun kontrol etmesi için oluşturulmuştur. */ $isFile = ''; /* Request Uri Değişkeni * * Ziyaretçi URL adresini * tutması için oluşturulmuştur. */ $requestUri = requestUri(); // ------------------------------------------------------------------------------- // $_GET kontrolü yapılarak temel URL bilgisi elde ediliyor. // ------------------------------------------------------------------------------- $url = explode('?', $requestUri); // ------------------------------------------------------------------------------- // Temel URL adresi / karakteri ile bölümlere ayrılıyor. // ------------------------------------------------------------------------------- $segments = explode('/', $url[0]); // ------------------------------------------------------------------------------- // Controller/Sayfa: Controller/ dizini içinde çalıştırılacak dosya adı. // ------------------------------------------------------------------------------- if (isset($segments[0])) { $page = $segments[0]; $isFile = CONTROLLERS_DIR . suffix($page, '.php'); unset($segments[0]); // Bir Controller/ dosyası index kelimesi ile isimlendirilemez! if (strtolower($page) === 'index') { // Hatayı ekrana yazdır. echo Error::message('Error', 'controllerNameError', $page); // Hatayı rapor et. report('Error', getMessage('Error', 'controllerNameError'), 'ControllerNameError'); // Çalışmayı durdur. return false; } } // ------------------------------------------------------------------------------- // Fonksiyon: Çalıştırılacak dosyaya ait yöntem adı. // ------------------------------------------------------------------------------- if (isset($segments[1])) { $function = $segments[1]; unset($segments[1]); } // ------------------------------------------------------------------------------- // Parametreler: Çalıştırılacak yönteme gönderilecek parametreler. // ------------------------------------------------------------------------------- if (isset($segments[2])) { $parameters = $segments; } // ---------------------------------------------------------------------- // TAMPONLAMA BAŞLATILIYOR... if (Config::get('Cache', 'obGzhandler') && substr_count(server('acceptEncoding'), 'gzip')) { ob_start('ob_gzhandler'); } else { ob_start(); } // ---------------------------------------------------------------------- // BAŞLIK BİLGİLERİ DÜZENLENİYOR... headers(Config::get('Headers', 'settings')); // ---------------------------------------------------------------------- // SAYFA KONTROLÜ YAPILIYOR... // ------------------------------------------------------------------------------- // Sayfa bilgisine erişilmişse sayfa dahil edilir. // ------------------------------------------------------------------------------- if (file_exists($isFile)) { // ------------------------------------------------------------------------------- // Tadilat modu açıksa bu ayarlar geçerli olacaktır. // ------------------------------------------------------------------------------- if (Config::get('Repair', 'mode')) { Repair::mode(); } // ------------------------------------------------------------------------------- // Sayfa dahil ediliyor. // ------------------------------------------------------------------------------- require_once $isFile; // ------------------------------------------------------------------------------- // Sayfaya ait controller nesnesi oluşturuluyor. // ------------------------------------------------------------------------------- $var = new $page(); // ------------------------------------------------------------------------------- // Sınıf ve yöntem bilgileri geçerli ise sayfayı çalıştır. // ------------------------------------------------------------------------------- if (is_callable(array($var, $function))) { if (APP_TYPE === 'local') { set_error_handler('Exceptions::table'); } call_user_func_array(array($var, $function), $parameters); if (APP_TYPE === 'local') { restore_error_handler(); } } else { // Sayfa bilgisine erişilemezse hata bildir. if (!Config::get('Route', 'show404')) { // Hatayı ekrana yazdır. echo Error::message('Error', 'callUserFuncArrayError', $function); // Hatayı rapor et. report('Error', getMessage('Error', 'callUserFuncArrayError'), 'SystemCallUserFuncArrayError'); // Çalışmayı durdur. return false; } else { redirect(Config::get('Route', 'show404')); } } } else { // Sayfa bilgisine erişilemezse hata bildir. if (Config::get('Route', 'show404')) { redirect(Config::get('Route', 'show404')); } else { // Hatayı ekrana yazdır. echo Error::message('Error', 'notIsFileError', $isFile); // Hatayı rapor et. report('Error', getMessage('Error', 'notIsFileError'), 'SystemNotIsFileError'); // Çalışmayı durdur. return false; } } // ---------------------------------------------------------------------- // TAMPONLAMA KAPATILIYOR... ob_end_flush(); // ---------------------------------------------------------------------- }
} else { // Hatayı rapor et. report('Error', lang('Error', 'callUserFuncArrayError', $function), 'SystemCallUserFuncArrayError'); // Hatayı ekrana yazdır. die(Error::message('Error', 'callUserFuncArrayError', $function)); } } } } else { if (Config::get('Route', 'show404')) { redirect(Config::get('Route', 'show404')); } else { // Hatayı rapor et. report('Error', lang('Error', 'notIsFileError', $isFile), 'SystemNotIsFileError'); // Hatayı ekrana yazdır. die(Error::message('Error', 'notIsFileError', $isFile)); } } //---------------------------------------------------------------------------------------------------- // Ob End Flush //---------------------------------------------------------------------------------------------------- // // Tampon kapatılıyor. // //---------------------------------------------------------------------------------------------------- ob_end_flush(); //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- // Restore Error Handler //---------------------------------------------------------------------------------------------------- //