Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions system/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}

Expand Down
9 changes: 9 additions & 0 deletions system/pip.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,6 +30,7 @@ function pip()

// Get our controller file
$path = APP_DIR . 'controllers/' . $controller . '.php';

if(file_exists($path)){
require_once($path);
} else {
Expand All @@ -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;
Expand Down