Hi
i was deleting the cache files accidently deleted wrong files, i did manage to locate and replace them, but the site and the admin panel is still showing error 500, on errror log page i see
[31-Mar-2022 19:23:17 Asia/Dili] PHP Parse error: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /home/kunalshah4177/public_html/system/library/cache/file.php on line 4
this is my file.php page
-------------------------------------------------------------
<?php
namespace Opencart\System\Library\Cache;
class File {
private int $expire;
public function __construct(int $expire = 3600) {
$this->expire = $expire;
$files = glob(DIR_CACHE . 'cache.*');
if ($files) {
foreach ($files as $file) {
$filename = basename($file);
$time = substr(strrchr($file, '.'), 1);
if ($time < time()) {
$this->delete(substr($filename, 6, strrpos($filename, '.') - 6));
}
}
}
}
public function get(string $key): array|string|null {
$files = glob(DIR_CACHE . 'cache.' . basename($key) . '.*');
if ($files) {
$handle = fopen($files[0], 'r');
flock($handle, LOCK_SH);
$size = filesize($files[0]);
if ($size > 0) {
$data = fread($handle, $size);
} else {
$data = '';
}
flock($handle, LOCK_UN);
fclose($handle);
return json_decode($data, true);
}
return [];
}
public function set(string $key, array|string|null $value, int $expire = 0): void {
$this->delete($key);
if (!$expire) {
$expire = $this->expire;
}
$file = DIR_CACHE . 'cache.' . basename($key) . '.' . (time() + $expire);
$handle = fopen($file, 'w');
flock($handle, LOCK_EX);
fwrite($handle, json_encode($value));
fflush($handle);
flock($handle, LOCK_UN);
fclose($handle);
}
public function delete(string $key): void {
$files = glob(DIR_CACHE . 'cache.' . basename($key) . '.*');
if ($files) {
foreach ($files as $file) {
if (!@unlink($file)) {
clearstatcache(false, $file);
}
}
}
}
}
-----------------------------------------------------------------------------------------------------------------------
please help
Hey!
It seems you downloaded the files from github.
It seems you downloaded the files from github.
- Look at the opencart version in index.php
- Download this version from the download page
- Replace these files again.
My FREE extensions in marketplace. [ security | flexibility | speedup ]

halfhope wrote: ↑Thu Mar 31, 2022 7:14 pmHey!
It seems you downloaded the files from github.When contacting the forum, indicate the version of the opencart. After the issue is resolved, add [SOLVED] to the beginning of the topic title.
- Look at the opencart version in index.php
- Download this version from the download page
- Replace these files again.
solved
thank you for your help,
Now that the issue has been solved, please add: [SOLVED] at the beginning of the subject line on your first post.albertgracias wrote: ↑Mon Apr 04, 2022 4:48 pm
halfhope wrote: ↑Thu Mar 31, 2022 7:14 pmHey!
It seems you downloaded the files from github.When contacting the forum, indicate the version of the opencart. After the issue is resolved, add [SOLVED] to the beginning of the topic title.
- Look at the opencart version in index.php
- Download this version from the download page
- Replace these files again.
solved
thank you for your help,
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: No registered users and 1 guest