public function __construct() { $this->root = '/var/www/dealschrome/' . Yii::app()->theme->baseUrl . '/imagecache'; chdir($this->root); $storingtime = 86400 * 7; $foldername = round(time() / $storingtime); if (!file_exists($foldername)) { // remove all old cache Filehelper::cleandir(getcwd()); // create a cache for today Filehelper::mkdir($foldername); } $this->savepath = $foldername; }