Skip to content

Commit

Permalink
Pre-actions on system controller call, file cache delete function now…
Browse files Browse the repository at this point in the history
… support asterisk (*) as wildcard character, sqlsrv driver bugfix, image class bugfix, url class bugfix
  • Loading branch information
oliveira131 committed Nov 26, 2020
1 parent f16eefd commit a0af7bd
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 144 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ To create a model, put in the models folder a directory and file with the code.

To use a magic request system, you just need to call a `$this->request` method. For sample, to obtain a POST value, use `$this->request->post['field']` to get the post value with security.
For a $_SERVER predefined variables, use `$this->request->server['VALUE']` and `$this->request->get[key]` for $_GET values.

For REST services you can use `$this->request->method` to check if is a POST, GET, PUT, DELETE or other HTTP method. You can use the auxiliary functions to determinate the HTTP method, like `$this->request->isPUT()` to return *true* or *false* for PUT method. Also others methods have your functions, like `$this->request->isPOST()`, `$this->request->isGET()`, `$this->request->isHEAD()`, `$this->request->isCONNECT()`, `$this->request->isOPTIONS()`, `$this->request->isTRACE()`, `$this->request->isPATCH()` or `$this->request->isDELETE()`. All are equivalent to "is" function in request, like this sample: `$this->request->is('PUT')` return true or false for PUT HTTP method.

The advantages to use this requests instead the predefined variables of PHP are more the more security, upgradable and unicode values.

### Sessions
Expand Down
8 changes: 5 additions & 3 deletions system/caches/caches.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,20 @@ public function set($key, $value, $expire = true) {
}

public function delete($key) {
$files = glob($this->dirCache . preg_replace('/[^A-Z0-9\._-]/i', '', $key) . '.cache');
$files = glob($this->dirCache . preg_replace('/[^A-Z0-9\.\*_-]/i', '', $key) . '.cache');

if ($files) {
foreach ($files as $file) {

if (file_exists($file)) {

unlink($file);
return true;

}
}
}

return false;
return (count($files));
}

private function encode($value){
Expand Down
5 changes: 3 additions & 2 deletions system/database/autoload.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

define('DIR_DATABASE', (__DIR__)."/database/");
if(!defined('DIR_DATABASE'))
define('DIR_DATABASE', (__DIR__)."/");

include __DIR__."/library/db.php";
include DIR_DATABASE."/library/db.php";

if(defined('DB_DRIVER')) {
global $db;
Expand Down
8 changes: 4 additions & 4 deletions system/database/database/sqlsrv.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public function __construct($hostname, $username, $password, $database, $port =
}
*/

sqlsrv_query("SET NAMES 'utf8'", $this->link);
sqlsrv_query("SET CHARACTER SET utf8", $this->link);
sqlsrv_query($this->link,"SET NAMES 'utf8'");
sqlsrv_query($this->link, "SET CHARACTER SET utf8");
}

public function query($sql) {
$resource = \sqlsrv_query($sql, $this->link);
$resource = \sqlsrv_query($this->link, $sql);

if ($resource) {
if (is_resource($resource)) {
Expand Down Expand Up @@ -80,7 +80,7 @@ public function countAffected() {
public function getLastId() {
$last_id = false;

$resource = \sqlsrv_query("SELECT @@identity AS id", $this->link);
$resource = \sqlsrv_query($this->link, "SELECT @@identity AS id");

if ($row = \sqlsrv_fetch($resource)) {
$last_id = trim($row[0]);
Expand Down
4 changes: 2 additions & 2 deletions system/database/library/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ final class DB {
private $cachePrefix = "SQL_";

public function __construct($driver, $hostname, $username, $password, $database) {
if (file_exists(DIR_DATABASE . $driver . '.php')) {
require_once(DIR_DATABASE . $driver . '.php');
if (file_exists(DIR_DATABASE .'database/'. $driver . '.php')) {
require_once(DIR_DATABASE .'database/'. $driver . '.php');
} else {
exit('Error: Could not load database file ' . $driver . '!');
}
Expand Down
2 changes: 1 addition & 1 deletion system/engine/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0
1.5.1
22 changes: 11 additions & 11 deletions system/engine/autoload.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

require_once(__DIR__ . '/log.php');
require_once(__DIR__ . '/action.php');
require_once(__DIR__ . '/controller.php');
require_once(__DIR__ . '/front.php');
require_once(__DIR__ . '/loader.php');
require_once(__DIR__ . '/model.php');
require_once(__DIR__ . '/registry.php');
require_once(__DIR__ . '/document.php');
require_once(__DIR__ . '/response.php');
require_once(__DIR__ . '/classes.php');
//require_once(__DIR__ . '/caches.php');
require_once(DIR_SYSTEM . 'engine/log.php');
require_once(DIR_SYSTEM . 'engine/action.php');
require_once(DIR_SYSTEM . 'engine/controller.php');
require_once(DIR_SYSTEM . 'engine/front.php');
require_once(DIR_SYSTEM . 'engine/loader.php');
require_once(DIR_SYSTEM . 'engine/model.php');
require_once(DIR_SYSTEM . 'engine/registry.php');
require_once(DIR_SYSTEM . 'engine/document.php');
require_once(DIR_SYSTEM . 'engine/response.php');
require_once(DIR_SYSTEM . 'engine/classes.php');
//require_once(DIR_SYSTEM . 'engine/caches.php');
2 changes: 1 addition & 1 deletion system/engine/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function getScripts() {
$b[$key] = $value;
}
}
return $b;
return (isset($b)) ? $b : [];
}

public function addFBMeta($property, $content = ''){
Expand Down
Loading

0 comments on commit a0af7bd

Please sign in to comment.