X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=Asset.php;h=92e43cbba844120cd4a1481d8489fcd7caa342bf;hp=407ffb7bb17ac0db1a8100a28b61d46b2261fdae;hb=refs%2Fheads%2Fwip_alan_T5884_add_photo_to_report;hpb=02c39cdf9d3284d5691ea4bf7b29a3a000956cbe diff --git a/Asset.php b/Asset.php index 407ffb7b..92e43cbb 100644 --- a/Asset.php +++ b/Asset.php @@ -36,14 +36,6 @@ class Pman_Core_Asset extends Pman { function get($s='', $opts = Array()) { - if( - !empty($_REQUEST['_clear_cache']) && - !empty($_REQUEST['_clear_module']) - ) { - $this->clearCompiledFilesCache($_REQUEST['_clear_module']); - } - - $this->sessionState(0); $bits = explode('/', $s); @@ -57,9 +49,8 @@ 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'; - + $compile = self::getCompileDir($bits[0], '', false); + $fn = $compile . '/'. $s .'.'. $bits[0]; if (!file_exists($fn)) { @@ -124,6 +115,10 @@ class Pman_Core_Asset extends Pman { } function post($s='') { + if(!empty($_REQUEST['_clear_cache'])) { + $this->clearCompiledFilesCache(); + } + die('invalid'); } @@ -135,7 +130,10 @@ class Pman_Core_Asset extends Pman { $compile_dir = session_save_path() . "/"; - $module = (empty($module)) ? $ff->project : $module; + if (empty($module)) { + $module = $ff->project . (isset($ff->appNameShort) ? '_' . $ff->appNameShort : ''); + } + switch($type) { case 'js': @@ -167,25 +165,33 @@ class Pman_Core_Asset extends Pman { return false; } - function clearCompiledFilesCache($module) + 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 $mod) { + foreach ($mods as $module) { $compile_dir = $this->getCompileDir('js', $module, false); if(!empty($compile_dir)) { - System::rm(array('-r', $compiledir)); + System::rm(array('-r', $compile_dir)); } $compile_dir = $this->getCompileDir('css', $module, false); if(!empty($compile_dir)) { - System::rm(array('-r', $compiledir)); + System::rm(array('-r', $compile_dir)); } } - - + $this->jok('DONE'); } }