| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/clients/client2/web11/web/classes/ |
Upload File : |
<?php
class caching {
private $dir = false;
private $time = 5;
public function __construct($time = 5) {
$this->dir = $_SERVER['DOCUMENT_ROOT']."/cache/products/";
$this->time = $time; // Cachetime
}
public function getContent($filename, $xmldata) {
if (file_exists($this->dir.$filename) && (filemtime($this->dir.$filename) > (time() - 60 * $this->time ))) {
$file = file_get_contents($this->dir.$filename);
} else {
$file = json_encode($xmldata);
$this->saveFile($filename, $file);
}
return json_decode($file);
}
public function saveFile($filename, $xmldata){
$filename_dir = $this->dir . $filename;
if ($fp = fopen($filename_dir, 'w+')){
fwrite($fp, $xmldata);
fclose($fp);
return true;
} else return false;
}
}