diff --git a/app/errors/error_general.php b/app/errors/error_general.php
new file mode 100644
index 0000000..43947d1
--- /dev/null
+++ b/app/errors/error_general.php
@@ -0,0 +1,28 @@
+
+
+
+ Error
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/welcome/controllers/welcome.php b/modules/welcome/controllers/welcome.php
index 247f0fe..9601cbe 100644
--- a/modules/welcome/controllers/welcome.php
+++ b/modules/welcome/controllers/welcome.php
@@ -23,5 +23,4 @@ class Welcome extends MM_Controller {
$this->output->set_output($output);
}
-
}
\ No newline at end of file
diff --git a/sys/common.php b/sys/common.php
index b556d39..4c6ad3a 100644
--- a/sys/common.php
+++ b/sys/common.php
@@ -113,15 +113,40 @@ function on_exception($exception)
echo $msg;
}
+// --------------------------------------------------------------------------
+
+/**
+ * General 404 function
+ */
function show_404()
{
@header('HTTP/1.1 404 Not Found', TRUE, 404);
die('404 Not Found
');
}
-function show_error()
-{
+// --------------------------------------------------------------------------
+/**
+ * Fatal Error page function
+ *
+ * @param string $message
+ * @param int $status_code
+ */
+function show_error($message, $status_code=null)
+{
+ if( ! is_null($status_code))
+ {
+ @header("HTTP/1.1 {$status_code}", TRUE, (int)$status_code);
+ }
+
+ // Contain the content for buffering
+ ob_start();
+
+ include(APP_PATH.'/errors/error_general.php');
+
+ $buffer = ob_get_contents();
+ ob_end_clean();
+ die($buffer);
}
// --------------------------------------------------------------------------
@@ -170,7 +195,7 @@ function controller_methods($controller)
*/
function route()
{
- $pi = $_SERVER['PATH_INFO'];
+ $pi = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : null;
// Load the routes config file
$routes = require_once(APP_PATH.'config/routes.php');
@@ -259,11 +284,7 @@ function route()
{
$class = new $controller;
- //echo "Found class";
-
- call_user_func(array($class, $func));
-
- return;
+ return call_user_func(array($class, $func));
}
// Function doesn't exist...404
@@ -290,6 +311,44 @@ function site_url($segment)
// --------------------------------------------------------------------------
+/**
+ * Wrapper function to simplify using curl
+ *
+ * @param string $url
+ * @param array $options
+ * @return mixed
+ */
+function do_curl($url, $options=array())
+{
+ $cookie = tempnam ("/tmp", "CURLCOOKIE");
+ $ch = curl_init($url);
+
+ //Use the user's User Agent and Cookies
+ $opts= array(
+ CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
+ CURLOPT_COOKIEJAR => $cookie,
+ CURLOPT_FOLLOWLOCATION => TRUE,
+ CURLOPT_ENCODING => "",
+ CURLOPT_RETURNTRANSFER => TRUE,
+ CURLOPT_AUTOREFERER => TRUE,
+ CURLOPT_SSL_VERIFYPEER => FALSE,
+ CURLOPT_CONNECTTIMEOUT => 10,
+ CURLOPT_TIMEOUT => 10,
+ CURLOPT_MAXREDIRS => 10,
+ CURLOPT_PROTOCOLS => array(CURLPROTO_HTTP,CURLPROTO_HTTPS)
+ );
+
+ //Set default options
+ curl_setopt_array($ch, $opts);
+
+ //Set additional options
+ curl_setopt_array($ch, $options);
+
+ return curl_exec($ch);
+}
+
+// --------------------------------------------------------------------------
+
//Set error handlers
set_error_handler('on_error');
set_exception_handler('on_exception');
@@ -303,4 +362,4 @@ require_once('db.php');
//Route to the appropriate function
route();
-// End of common.php
+// End of common.php
\ No newline at end of file
diff --git a/sys/miniMVC.php b/sys/miniMVC.php
index cd039a2..4cbc524 100644
--- a/sys/miniMVC.php
+++ b/sys/miniMVC.php
@@ -142,6 +142,53 @@ class miniMVC{
{
return self::get_instance();
}
+
+ /**
+ * Method to load classes into the singleton
+ *
+ * @param string $name
+ */
+ function load_class($name)
+ {
+ $path = APP_PATH . "classes/{$name}.php";
+ $class = "{$name}";
+
+ if(class_exists($class, FALSE))
+ {
+ if ( ! isset($this->$name))
+ {
+ $this->$name = new $class;
+ return;
+ }
+ }
+
+ if(is_file($path))
+ {
+ require_once($path);
+
+ if(class_exists($class, FALSE))
+ {
+ if ( ! isset($this->$name))
+ {
+ $this->$name = new $class;
+ return;
+ }
+ }
+ }
+ }
+
+ /**
+ * Convenience function to remove an object from the singleton
+ *
+ * @param string $name
+ */
+ function unload($name)
+ {
+ if(isset($this->$name))
+ {
+ unset($this->$name);
+ }
+ }
}
// --------------------------------------------------------------------------