diff --git a/system/model.php b/system/model.php index 04503ca..ce3ed57 100644 --- a/system/model.php +++ b/system/model.php @@ -8,19 +8,22 @@ public function __construct() { global $config; - $this->connection = mysql_pconnect($config['db_host'], $config['db_username'], $config['db_password']) or die('MySQL Error: '. mysql_error()); - mysql_select_db($config['db_name'], $this->connection); + $this->connection = new mysqli($config["db_host"],$config["db_username"],$config["db_password"],$config["db_name"]); + } public function escapeString($string) { - return mysql_real_escape_string($string); + return mysqli_real_escape_string($this->connection,$string); } public function escapeArray($array) { - array_walk_recursive($array, create_function('&$v', '$v = mysql_real_escape_string($v);')); - return $array; + $clean = []; + foreach ($array as $key => $value) { + $clean[$key] = mysqli_real_escape_string($this->connection,$value); + } + return $clean; } public function to_bool($val) @@ -45,17 +48,14 @@ public function to_datetime($val) public function query($qry) { - $result = mysql_query($qry) or die('MySQL Error: '. mysql_error()); - $resultObjects = array(); - - while($row = mysql_fetch_object($result)) $resultObjects[] = $row; + $result = $this->connection->query($qry) or die('MySQL Error: '. mysqli_error($this->connection)); - return $resultObjects; + return $result; } public function execute($qry) { - $exec = mysql_query($qry) or die('MySQL Error: '. mysql_error()); + $exec = mysqli_query($qry) or die('MySQL Error: '. mysqli_error($this->connection)); return $exec; } diff --git a/system/pip.php b/system/pip.php index c69195c..0e4e0ea 100644 --- a/system/pip.php +++ b/system/pip.php @@ -11,6 +11,11 @@ function pip() // Get request url and script url $request_url = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : ''; + + $temp = (strpos($_SERVER["REQUEST_URI"], "?")) ? strpos($_SERVER["REQUEST_URI"],"?") : strlen($_SERVER["REQUEST_URI"]); + + $request_url = substr($_SERVER['REQUEST_URI'],0,$temp); + $script_url = (isset($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : ''; // Get our url path and trim the / of the left and the right @@ -25,6 +30,7 @@ function pip() // Get our controller file $path = APP_DIR . 'controllers/' . $controller . '.php'; + if(file_exists($path)){ require_once($path); } else { @@ -33,11 +39,14 @@ function pip() } // Check the action exists + if(!method_exists($controller, $action)){ $controller = $config['error_controller']; require_once(APP_DIR . 'controllers/' . $controller . '.php'); $action = 'index'; } + + // Create object and call method $obj = new $controller;