diff --git a/.gitignore b/.gitignore index ef139ce..b4821ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ config/config.php prototypes/ admin/ +cache/localhost # PhpStorm .idea/ diff --git a/api/status.php b/api/status.php index 85e6c65..d283a84 100644 --- a/api/status.php +++ b/api/status.php @@ -4,26 +4,17 @@ header('Content-Type: application/json'); set_error_handler("exception_error_handler", E_ALL); require_once __DIR__ . "/../include/tsutils.php"; -require_once __DIR__ . "/../lib/phpfastcache/autoload.php"; +require_once __DIR__ . "/../include/cacheutils.class.php"; date_default_timezone_set($config["general"]["timezone"]); -use phpFastCache\Util; -use phpFastCache\CacheManager; +$cacheutils = new CacheUtils('serverstatus'); -Util\Languages::setEncoding("UTF-8"); -$cache = CacheManager::Files(); - -$serverstatus = $cache->get('serverstatus'); - -// $cache->clean(); - -if (is_null($serverstatus)) { - $serverstatus = getResult(); - $cache->set('serverstatus', $serverstatus, 10); +if($cacheutils->isExpired()) { + $cacheutils->setValue(getResult(), 10); } -die ($serverstatus); +die ($cacheutils->getValue()); // ********* // METHODS diff --git a/bans.php b/bans.php index f7054e0..d3fb33c 100644 --- a/bans.php +++ b/bans.php @@ -2,23 +2,15 @@ $bansPage = true; require_once __DIR__ . "/include/header.php"; require_once __DIR__ . "/include/tsutils.php"; -require_once __DIR__ . "/lib/phpfastcache/autoload.php"; +require_once __DIR__ . "/include/cacheutils.class.php"; +$cacheutils = new CacheUtils('banlist'); -use phpFastCache\Util; -use phpFastCache\CacheManager; - -Util\Languages::setEncoding("UTF-8"); -$cache = CacheManager::Files(); - -$banlist = $cache->get('banlist'); - -// $cache->clean(); - -if (is_null($banlist)) { - $banlist = array(getBanlist(), date('d-m-Y H:i:s')); - $cache->set('banlist', $banlist, 600); +if($cacheutils->isExpired()) { + $cacheutils->setValue([getBanlist(), date('d-m-Y H:i:s')], 300); } + +$banlist = $cacheutils->getValue(); ?>
- ts-website v 1.3.7 — © Wruczek 2016 - 2017 + ts-website v 1.4.0 — © Wruczek 2016 - 2017
diff --git a/include/modulecheck.php b/include/modulecheck.php index 5b806d8..c0c4ffb 100644 --- a/include/modulecheck.php +++ b/include/modulecheck.php @@ -14,7 +14,8 @@ if (!isPHPVersionSupported()) { $text = '
You are using old, unsupported PHP version.
Your PHP version: ' . phpversion() . ', required PHP version: 5.5.0.
Please update your PHP installation and try again.
'; - die(showError($title, $text)); + showError($title, $text); + die(); } if (!function_exists("utf8_encode")) { @@ -24,18 +25,15 @@ if (!function_exists("utf8_encode")) {For PHP 7.0 (recommended), install this package: sudo apt-get install php-xml php7.0-xml and restart apache. Otherwise, installation instructions can be found on Google ;)
If you are using Web Hosting service, please contact the Hosting support for instruction on enabling needed packages.
'; - die(showError($title, $text)); + showError($title, $text); + die(); } -try { - require_once __DIR__ . "/../lib/phpfastcache/autoload.php"; - \phpFastCache\CacheManager::Files(); -} catch (\phpFastCache\Exceptions\phpFastCacheDriverException $e) { - $title = 'Directory is not writable'; - - $text = 'Please make sure that the whole website directory including subdirectories is fully writable.
'; - - die(showError($title, $text)); +if(!is_writable(__DIR__ . '/../cache')) { + $title = 'Cache directory is not writable'; + $text = 'Please make sure that the cache directory is fully writable.
Please go into the directory config and rename config.template.php to config.php.
Edit the new file and tweak it to suite your needs.
'; - die(showError($title, $text)); + showError($title, $text); + die(); } @@ -90,7 +89,7 @@ function showError($title, $text) { ?>"; - print_r($value); - echo ""; - */ - } - - public function _hit($index, $step = 1) - { - $instance = $this->config[ 'instance' ]; - $current = isset(CacheManager::$hit[ $instance ][ 'data' ][ $index ]) ? CacheManager::$hit[ $instance ][ 'data' ][ $index ] : 0; - CacheManager::$hit[ $instance ][ 'data' ][ $index ] = $current + ($step); - } - -} \ No newline at end of file diff --git a/lib/phpfastcache/phpFastCache/Core/DriverInterface.php b/lib/phpfastcache/phpFastCache/Core/DriverInterface.php deleted file mode 100644 index 1724374..0000000 --- a/lib/phpfastcache/phpFastCache/Core/DriverInterface.php +++ /dev/null @@ -1,86 +0,0 @@ - http://www.phpfastcache.com - * @author Georges.L (Geolim4)
'; - print_r($something); - echo ''; - var_dump($something); - } else { - echo $something; - } - echo "\r\n