+ Error on line 107
return file_put_contents($this->_directory . md5($id) , $expire.serialize($value), LOCK_EX);
<?php
/**
* DooFileCache class file.
*
* @author Leng Sheng Hong <darkredz@gmail.com>
* @link http://www.doophp.com/
* @copyright Copyright © 2009 Leng Sheng Hong
* @license http://www.doophp.com/license
*/
/**
* DooFileCache provides file based caching methods.
*
* @author Leng Sheng Hong <darkredz@gmail.com>
* @version $Id: DooFileCache.php 1000 2009-08-27 19:36:10
* @package doo.cache
* @since 1.1
*/
class DooFileCache {
private $_directory;
/**
* Option to hash the Cache ID into md5 hash string
* @var bool
*/
public $hashing = true;
public function __construct($path='') {
if ( $path=='' ) {
if(isset(Doo::conf()->CACHE_PATH))
$this->_directory = Doo::conf()->CACHE_PATH;
else
$this->_directory = Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . 'cache/';
}else{
$this->_directory = $path;
}
}
/**
* Retrieves a value from cache with an Id.
*
* @param string $id A unique key identifying the cache
* @return mixed The value stored in cache. Return null if no cache found or already expired.
*/
public function get($id) {
if($this->hashing===true)
$cfile = $this->_directory . md5($id);
else
$cfile = $this->_directory . $id;
if (file_exists($cfile)){
$data = file_get_contents($cfile) ;
$expire = substr($data, 0, 10);
if(time() < $expire){
return unserialize(substr($data, 10));
}else{
unlink($cfile);
}
}
}
/**
* Retrieves a value from cache with an Id from different directories
*
* @param string $folder Directory name for the cache files stored
* @param string $id A unique key identifying the cache
* @return mixed The value stored in cache. Return null if no cache found or already expired.
*/
public function getIn($folder, $id) {
if($this->hashing===true)
$cfile = $this->_directory . $folder .'/'. md5($id);
else
$cfile = $this->_directory . $folder .'/'. $id;
if (file_exists($cfile)){
$data = file_get_contents($cfile) ;
$expire = substr($data, 0, 10);
if(time() < $expire){
return unserialize(substr($data, 10));
}else{
unlink($cfile);
}
}
}
/**
* Adds a cache with an unique Id.
*
* @param string $id Unique Id of the cache
* @param mixed $value Cache data value to be stored.
* @param int $expire Duration to determine if the cache is expired. 0 for never expire
* @return bool
*/
public function set($id, $value, $expire=0) {
if($expire===0)
$expire = time()+31536000;
else
$expire = time()+$expire;
if($this->hashing===true)
return
file_put_contents($this->_directory . md5($id) , $expire.serialize($value), LOCK_EX);
return file_put_contents($this->_directory . $id , $expire.serialize($value), LOCK_EX);
}
/**
* Store cache in different directories
*
* @param string $folder Directory name for the cache files to be created and stored
* @param string $id Unique Id of the cache
* @param mixed $value Cache data value to be stored.
* @param int $expire Duration to determine if the cache is expired. 0 for never expire
* @return bool
*/
public function setIn($folder, $id, $value, $expire=0) {
$cfile = $this->_directory.$folder.'/';
if(!file_exists($cfile))
mkdir($cfile);
if($this->hashing===true)
$cfile .= md5($id);
else
$cfile .= $id;
if($expire===0)
$expire = time()+31536000;
else
$expire = time()+$expire;
return file_put_contents($cfile, $expire.serialize($value), LOCK_EX);
}
/**
* Delete a cache file by Id
* @param $id Id of the cache
* @return mixed
*/
public function flush($id) {
if($this->hashing===true)
$cfile = $this->_directory.md5($id);
else
$cfile = $this->_directory.$id;
if (file_exists($cfile)) {
unlink($cfile);
return true;
}
return false;
}
/**
* Deletes all data cache files
* @return bool
*/
public function flushAll() {
$handle = opendir($this->_directory);
while(($file = readdir($handle)) !== false) {
if (is_file($this->_directory . $file))
unlink($this->_directory . $file);
else if (is_dir($this->_directory . $file) && substr($file, 0, 4) == 'mdl_')
$this->flushAllIn($file);
}
return true;
}
/**
* Deletes all data cache in a folder
* @param string $folder
*/
public function flushAllIn($folder){
$cfile = $this->_directory.$folder.'/';
if(file_exists($cfile)){
$handle = opendir($cfile);
while(($file = readdir($handle)) !== false) {
$file = $cfile.$file;
if (is_file($file)){
unlink( $file );
}
}
}
}
/**
* Deletes a data cache in a folder identified by an ID
* @param string $folder
* @param string $id
*/
public function flushIn($folder, $id){
if($this->hashing===true)
$cfile = $this->_directory.$folder.'/'.md5($id);
else
$cfile = $this->_directory.$folder.'/'.$id;
if(file_exists($cfile)){
unlink( $file );
}
}
}
* Stack Trace...
- /home/culipro/domains/culipro.nl/public_html/app/index.php(54) calling run()
- /home/culipro/domains/culipro.nl/dooframework/dooframework/app/DooWebApp.php(34) calling routeTo()
- /home/culipro/domains/culipro.nl/dooframework/dooframework/app/DooWebApp.php(148) calling beforeRun()
- /home/culipro/domains/culipro.nl/protected/controller/ParentPageController.php(391) calling set()
- /home/culipro/domains/culipro.nl/dooframework/dooframework/cache/DooFileCache.php(107) calling file_put_contents()
object(DooConfig)#1 (26) {
["AUTOLOAD"] => array(7) {
[0] => string(5) "class"
[1] => string(5) "model"
[2] => string(10) "controller"
[3] => string(48) "/home/culipro/domains/culipro.nl/protected/class"
[4] => string(48) "/home/culipro/domains/culipro.nl/protected/model"
[5] => string(53) "/home/culipro/domains/culipro.nl/protected/controller"
[6] => string(44) "/home/culipro/domains/culipro.nl/library/Cu/"
}
["SITE_PATH"] => string(1) "/"
["PROTECTED_FOLDER"] => string(43) "/home/culipro/domains/culipro.nl/protected/"
["BASE_PATH"] => string(59) "/home/culipro/domains/culipro.nl/dooframework/dooframework/"
["LOG_PATH"] => string(65) "/home/culipro/domains/culipro.nl/dooframework/dooframework//logs/"
["APP_URL"] => string(22) "http://www.culipro.nl/"
["SUBFOLDER"] => string(1) "/"
["APP_MODE"] => string(4) "prod"
["AUTOROUTE"] => bool(true)
["DEBUG_ENABLED"] => bool(false)
["ERROR_404_DOCUMENT"] => NULL
["ERROR_404_ROUTE"] => string(1) "/"
["CACHE_PATH"] => NULL
["AUTO_VIEW_RENDER_PATH"] => string(13) "/:parentlabel"
["MEMCACHE"] => NULL
["TEMPLATE_ENGINE"] => string(7) "DooView"
["TEMPLATE_SHOW_COMMENT"] => NULL
["TEMPLATE_ALLOW_PHP"] => NULL
["TEMPLATE_COMPILE_ALWAYS"] => NULL
["TEMPLATE_GLOBAL_TAGS"] => array(9) {
[0] => string(5) "upper"
[1] => string(7) "tofloat"
[2] => string(16) "sample_with_args"
[3] => string(5) "debug"
[4] => string(3) "url"
[5] => string(4) "url2"
[6] => string(13) "function_deny"
[7] => string(5) "isset"
[8] => string(5) "empty"
}
["MODULES"] => NULL
["APP_NAMESPACE_ID"] => NULL
["CHMOD_DEFAULT"] => int(511)
["FROM_CLI"] => bool(false)
["culipro"] => array(7) {
["route"] => array(2) {
["homepage"] => array(1) {
[0] => string(14) "deglazenruimte"
}
["errorspages"] => array(1) {
[0] => string(3) "404"
}
}
["system"] => array(4) {
["config-address"] => string(6) "config"
["max-char-tourmessage"] => int(500)
["max-tourpages"] => int(30)
["max-expire-tourguide-days"] => int(1000)
}
["cacheTimeInSec"] => int(1)
["quickcontact-subject"] => string(20) "Culipro contact form"
["quickcontact-email"] => string(15) "info@culipro.nl"
["splitfunctions"] => array(1) {
["pageintro"] => string(14) "[%introsplit%]"
}
["pagesbg_path"] => string(68) "/home/culipro/domains/culipro.nl/public_html/app/global/img/pagebgs/"
}
["indexdir"] => string(48) "/home/culipro/domains/culipro.nl/public_html/app"
}
$_SESSION Variables
array(1) {
[""] => array(2) {
["session_id"] => string(32) "a043d8a624f5d4fc7c81b657bb516ebd"
["tourguide"] => array(1) {
["guid"] => string(36) "bddc43dc-aed6-4097-5585-96deeefd248e"
}
}
}
$_COOKIE Variables
array(1) {
["PHPSESSID"] => string(32) "a043d8a624f5d4fc7c81b657bb516ebd"
}