_destroySubDirsFrom(constant('WWW_PATH') . '/' . App_Application_Document_Obj::DOCUMENT_ACCESS_PATH); $this->_destroySubDirsFrom(constant('BASE_PATH') . '/tmp/' . App_Application_Document_AdminObj::DOCUMENT_ADMIN_ACCESS_PATH); exit; } protected function _destroySubDirsFrom($path) { foreach (scandir($path) as $dir) { if ($dir != '..' && $dir != '.' && $dir != '.htaccess' && $dir != '.htaccess_dev' && !$this->sessionExists($dir)) { $this->_destroyDir($path . '/' . $dir); } } } protected function _destroyDir($dir) { if (!is_dir($dir) || is_link($dir)) { return unlink($dir); } foreach (scandir($dir) as $file) { if ($file == '.' || $file == '..' || $file == '.htaccess') { continue; } if (!$this->_destroyDir($dir . DIRECTORY_SEPARATOR . $file)) { chmod($dir . DIRECTORY_SEPARATOR . $file, 0777); if (!$this->_destroyDir($dir . DIRECTORY_SEPARATOR . $file)) { return false; } }; } return rmdir($dir); } public function sessionExists($sessionId) { $file = $this->getSessionSavePath() . '/sess_' . $sessionId; return file_exists($file); } public function getSessionSavePath() { if (null === $this->_sessionSavePath) { $this->_sessionSavePath = session_save_path(); if (empty($this->_sessionSavePath)) { $this->_sessionSavePath = sys_get_temp_dir(); } } return $this->_sessionSavePath; } }