From fceaeea30500536877441c0528afda1e4ac20d21 Mon Sep 17 00:00:00 2001 From: "Bruno O. Notario" Date: Wed, 17 Jul 2019 11:48:40 -0300 Subject: [PATCH] Remove unnecessary clearstatcache() calls in cache file module. Remove redundant closing tags. Remove old breadcrumb function. --- controller/common/header.php | 12 +++++----- system/breadcrumb/autoload.php | 37 ------------------------------ system/caches/caches.php | 42 ++++++---------------------------- system/captcha/autoload.php | 1 - system/config/autoload.php | 1 - system/engine/VERSION | 2 +- system/mail/mail.php | 1 - 7 files changed, 14 insertions(+), 82 deletions(-) delete mode 100644 system/breadcrumb/autoload.php diff --git a/controller/common/header.php b/controller/common/header.php index 555caa5..2c9d7a0 100644 --- a/controller/common/header.php +++ b/controller/common/header.php @@ -3,17 +3,17 @@ class ControllerCommonHeader extends Controller { protected function index() { $this->data['title'] = $this->document->getTitle(); - $this->document->addScript('https://code.jquery.com/jquery-3.3.1.min.js'); + $this->document->addScript('https://code.jquery.com/jquery-3.4.1.min.js'); $this->document->addScript('https://code.jquery.com/jquery-migrate-3.0.1.min.js'); - $this->document->addScript('https://use.fontawesome.com/releases/v5.4.1/js/all.js'); - $this->document->addScript('https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js'); - $this->document->addScript('https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js'); + $this->document->addScript('https://use.fontawesome.com/releases/v5.9.0/js/all.js'); + $this->document->addScript('https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js'); + $this->document->addScript('https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js'); - $this->document->addStyle('https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css'); - $this->document->addStyle('https://use.fontawesome.com/releases/v5.6.0/css/all.css'); + $this->document->addStyle('https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css'); + $this->document->addStyle('https://use.fontawesome.com/releases/v5.9.0/css/all.css'); $this->document->addStyle('assets/style.css'); diff --git a/system/breadcrumb/autoload.php b/system/breadcrumb/autoload.php deleted file mode 100644 index 6449fac..0000000 --- a/system/breadcrumb/autoload.php +++ /dev/null @@ -1,37 +0,0 @@ -'; - - $i = 0; - - foreach($l as $montado) { - - $i = $i; - - if($montado == end($l)) { - $bread .= '
  • '.$montado.'
  • '; - } else { - if($l[0] == 'Home' and $l[0] == $montado) { - $montado = ''; - } - $bread .= '
  • '.$montado.'
  • '; - - } $i = $i+1; - } - - $bread .= '
  • Voltar
  • -'; - - return $bread; - -} \ No newline at end of file diff --git a/system/caches/caches.php b/system/caches/caches.php index dcc5c40..f20bdfc 100644 --- a/system/caches/caches.php +++ b/system/caches/caches.php @@ -6,25 +6,10 @@ final class Caches { public function __construct() { if (!file_exists($this->dirCache)) { - mkdir($this->dirCache, 0755, true); + mkdir($this->dirCache, 0760, true); } $this->expire = (defined('CACHE_EXPIRE')) ? CACHE_EXPIRE : 3600; - /*$files = glob($this->dirCache . '*.cache'); - if ($files) { - foreach ($files as $file) { - //$time = substr(strrchr($file, '.'), 1); - $time = substr(strrchr(strstr($file, '.', true), '/'), 1); - //var_dump(substr(strrchr(strstr($file, '.', true), '/'), 1)); - - if ($time < time() and $time !== '0') { - if (file_exists($file)) { - unlink($file); - clearstatcache(); - } - } - } - }*/ } public function verify($key) { @@ -58,8 +43,6 @@ final class Caches { public function set($key, $value, $expire = true) { $this->delete($key); - //$exp = ($expire == true) ? (time() + $this->expire) : 0; - $file = $this->dirCache . preg_replace('/[^A-Z0-9\._-]/i', '', $key) . '.cache'; return file_put_contents($file, $this->encode($value)); @@ -73,10 +56,12 @@ final class Caches { foreach ($files as $file) { if (file_exists($file)) { unlink($file); - clearstatcache(); + return true; } } } + + return false; } private function encode($value){ @@ -102,18 +87,14 @@ final class Caches { $file = ($this->dirCache . preg_replace('/[^A-Z0-9\._-]/i', '', $key) . '.cache'); if (file_exists($file)) { - //var_dump($file); - //$time = substr(strrchr(strstr($files[0], '.', true), '/'), 1); $time = filemtime($file) + $this->expire; - //var_dump(substr(strrchr(strstr($file, '.', true), '/'), 1)); if ($time < time() and $time !== '0') { - //var_dump($file); unlink($file); - clearstatcache(); + return false; } else { @@ -129,18 +110,9 @@ final class Caches { public function deleteAll() { $files = glob($this->dirCache . '*.cache'); - if ($files) { - foreach ($files as $file) { - //$time = substr(strrchr($file, '.'), 1); - //$time = substr(strrchr(strstr($file, '.', true), '/'), 1); - //var_dump(substr(strrchr(strstr($file, '.', true), '/'), 1)); + array_map('unlink', $files); - if (file_exists($file)) { - unlink($file); - clearstatcache(); - } - } - } + unset($files); return true; } diff --git a/system/captcha/autoload.php b/system/captcha/autoload.php index fa3b57f..e6b8d9b 100644 --- a/system/captcha/autoload.php +++ b/system/captcha/autoload.php @@ -221,4 +221,3 @@ class Captcha { imagedestroy($image); } } -?> \ No newline at end of file diff --git a/system/config/autoload.php b/system/config/autoload.php index 26591c6..4f18bdf 100644 --- a/system/config/autoload.php +++ b/system/config/autoload.php @@ -29,4 +29,3 @@ final class Config { } } } -?> \ No newline at end of file diff --git a/system/engine/VERSION b/system/engine/VERSION index e21e727..13175fd 100644 --- a/system/engine/VERSION +++ b/system/engine/VERSION @@ -1 +1 @@ -1.4.0 \ No newline at end of file +1.4.1 \ No newline at end of file diff --git a/system/mail/mail.php b/system/mail/mail.php index b221e87..60d4e93 100644 --- a/system/mail/mail.php +++ b/system/mail/mail.php @@ -411,4 +411,3 @@ final class Mail { } } } -?> \ No newline at end of file