* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBAjax'); /** * Simple AJAX stub: CacheControl * * Flush caches * * @version 0.1.1 * @package WB * @subpackage base */ class WBAjax_CacheControl extends WBAjax { /** * Config * @var WBConfig */ protected $config; /** * Second construcotr * * Called by constructer of super class. * @see include/WB/WBAjax#init() */ protected function init() { } /** * Trigger Event * * @return string zero */ protected function flush() { // check permissions if (!$this->user->isAuthenticated()) { return 0; } if (!$this->user->isInGroup('admin')) { return 0; } $domain = $this->req->get('domain', ''); if (!is_array($domain)) { $domain = explode(',', $domain); } // flush domains $domain = array( 'general', 'template', 'css', 'javascript' ); foreach ($domain as $d) { $this->flushDomain($d); } return 0; } private function flushDomain($domain) { $cmd = 'find %s/var/cache/%s -type f -delete'; $cmd = sprintf($cmd, WBParam::get('wb/dir/base'), $domain); exec($cmd, $out, $ret); // echo $cmd . "\n"; } }