diff --git a/index.php b/index.php index a20535c..c79858e 100644 --- a/index.php +++ b/index.php @@ -4,6 +4,7 @@ error_reporting(-1); // Set the default paths +define('BASE_PATH', __DIR__); define('SYS_PATH', __DIR__.'/sys/'); define('MOD_PATH', __DIR__.'/modules/'); define('APP_PATH', __DIR__.'/app/'); diff --git a/sys/common.php b/sys/common.php index 4c6ad3a..5a9a55b 100644 --- a/sys/common.php +++ b/sys/common.php @@ -4,6 +4,34 @@ * File including common framework-wide functions */ +/** + * Function to run on script shutdown + * -used to catch most fatal errors, and + * display them cleanly + */ +function shutdown() +{ + // Catch the last error + $error = error_get_last(); + + // types of errors that are fatal + $fatal = array(E_ERROR, E_PARSE, E_RECOVERABLE_ERROR); + + // Display pretty error page + if(in_array($error['type'], $fatal)) + { + $file = str_replace(BASE_PATH, "", $error['file']); + + $err_msg = <<Fatal Error: +{$error['message']}

+File: {$file}

+Line: {$error['line']} +TXT; + show_error($err_msg); + } +} + /** * Function to search through the tree to find the necessary file * @@ -56,7 +84,11 @@ function on_error($severity, $message, $filepath, $line, $context) E_USER_NOTICE => 'User Notice', E_STRICT => 'Strict Error' ); - + + //Make it prettier + $message = highlight_string($message, TRUE); + $filepath = str_replace(BASE_PATH, "", $filepath); + $severity = (isset($levels[$severity])) ? $levels[$severity] : $severity; // Contain the content for buffering @@ -72,7 +104,7 @@ function on_error($severity, $message, $filepath, $line, $context) // -------------------------------------------------------------------------- /** - * Custom exception handler + * Custom exception handlererror_get_last */ function on_exception($exception) { @@ -350,6 +382,7 @@ function do_curl($url, $options=array()) // -------------------------------------------------------------------------- //Set error handlers +register_shutdown_function('shutdown'); set_error_handler('on_error'); set_exception_handler('on_exception'); @@ -362,4 +395,4 @@ require_once('db.php'); //Route to the appropriate function route(); -// End of common.php \ No newline at end of file +// End of common.php diff --git a/sys/db.php b/sys/db.php index 7d82d67..79c48f0 100644 --- a/sys/db.php +++ b/sys/db.php @@ -129,7 +129,14 @@ class db extends PDO { return self::get_instance($db); } + function start_transaction() + { + } + function end_transaction() + { + + } } // End of db.php diff --git a/sys/page.php b/sys/page.php index b4a5674..96dfa48 100644 --- a/sys/page.php +++ b/sys/page.php @@ -154,20 +154,6 @@ class Page // -------------------------------------------------------------------------- - /** - * Set an individual js file in header - * @param string $js - * @param bool $domain - * @return Page - */ - public function set_head_js($js, $domain = TRUE) - { - $this->head_js .= $this->script_tag($js, $domain); - return $this; - } - - // -------------------------------------------------------------------------- - /** * Sets a minified css group * @param string $group @@ -202,19 +188,6 @@ class Page // -------------------------------------------------------------------------- - /** - * Sets js in footer; multiple files are combined and minified. - * @param array $args - * @return Page - */ - public function set_foot_js($js, $domain) - { - $this->foot_js .= $this->script_tag($js, $domain); - return $this; - } - - // -------------------------------------------------------------------------- - /** * Sets html title string * @param string $title @@ -298,20 +271,6 @@ class Page // -------------------------------------------------------------------------- - /** - * Sets uncompressed js file in footer - * @param string $name - * @param bool $domain - * @return Page - */ - public function set_foot_js_tag($name, $domain = TRUE) - { - $this->foot_js .= $this->script_tag($name, $domain); - return $this; - } - - // -------------------------------------------------------------------------- - /** * Sets a custom tag in the header * @param string $tag @@ -490,7 +449,13 @@ class Page } // -------------------------------------------------------------------------- - + + /** + * Private helper function to generate meta tags + * + * @param array $params + * @return string + */ private function _meta($params) { $string = "