X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=Asset.php;h=92e43cbba844120cd4a1481d8489fcd7caa342bf;hp=2a621929c0a3aa81bbc329d0a8be405b1932e67a;hb=refs%2Fheads%2Fwip_alan_T5884_add_photo_to_report;hpb=938df0f8371d4ff13e812f865cb2544e425cbe91 diff --git a/Asset.php b/Asset.php index 2a621929..92e43cbb 100644 --- a/Asset.php +++ b/Asset.php @@ -36,7 +36,6 @@ class Pman_Core_Asset extends Pman { function get($s='', $opts = Array()) { - $this->sessionState(0); $bits = explode('/', $s); @@ -50,13 +49,9 @@ class Pman_Core_Asset extends Pman { $ui = posix_getpwuid(posix_geteuid()); $ff = HTML_FlexyFramework::get(); - $compile = session_save_path() . '/' . - $ui['name'] . '-' . $ff->project . '-' . $ff->version . '-'. $bits[0] . 'compile'; - - $fn = $compile . '/'. $s .'.'. $bits[0]; - - + $compile = self::getCompileDir($bits[0], '', false); + $fn = $compile . '/'. $s .'.'. $bits[0]; if (!file_exists($fn)) { header('Content-Type: '. $this->types[$bits[0]]); @@ -65,7 +60,6 @@ class Pman_Core_Asset extends Pman { exit; } - $supportsGzip = !empty($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) !== false; @@ -119,45 +113,85 @@ class Pman_Core_Asset extends Pman { exit; } + function post($s='') { + if(!empty($_REQUEST['_clear_cache'])) { + $this->clearCompiledFilesCache(); + } + die('invalid'); } - static function getCompileDir($type) + static function getCompileDir($type, $module = '', $is_mkdir = true) { + $ff = HTML_FlexyFramework::get(); + + $ui = posix_getpwuid(posix_geteuid()); + + $compile_dir = session_save_path() . "/"; + + if (empty($module)) { + $module = $ff->project . (isset($ff->appNameShort) ? '_' . $ff->appNameShort : ''); + } + + switch($type) { case 'js': - $suffix - break; case 'css': + $compile_dir .= implode("-", array( + $ui['name'], + $module, + $ff->version, + "{$type}compile" + )); break; - case 'template': - break; + // template config? default: return false; } - exit; - - $ui = posix_getpwuid(posix_geteuid()); - - $ff = HTML_FlexyFramework::get(); - - $compile_dir = session_save_path() . '/' . implode("-", array( - $ui['name'], - $ff->project, - $ff->version, - "{$type}compile" - )); - if (file_exists($compile_dir)) { return $compile_dir; } + if(!$is_mkdir) { + return false; + } + if(mkdir($compile_dir, 0700, true)) { return $compile_dir; } return false; } + + function clearCompiledFilesCache() + { + $au = $this->getAuthUser(); + if (!$au && !in_array($_SERVER['REMOTE_ADDR'] , array('127.0.0.1','::1'))) { + $this->jerr("Cache can only be cleared by authenticated users"); + } + + require_once 'System.php'; + $ff = HTML_FlexyFramework::get(); + + $mods = $this->modulesList(); + $mods[] = $ff->project; // Pman - this was the old format... + $mods[] = ''; // Pman + appshortname.. + + foreach ($mods as $module) { + $compile_dir = $this->getCompileDir('js', $module, false); + + if(!empty($compile_dir)) { + System::rm(array('-r', $compile_dir)); + } + $compile_dir = $this->getCompileDir('css', $module, false); + + if(!empty($compile_dir)) { + System::rm(array('-r', $compile_dir)); + } + } + + $this->jok('DONE'); + } }