function change_filename_length() { try { w3_require_once(W3TC_LIB_W3_DIR . '/Request.php'); $new = W3_Request::get_integer('maxlength'); $this->_config->set('minify.auto.filename_length', $new); set_transient('w3tc_minify_tested_filename_length', true, 3600 * 24); $this->_config->save(); w3_require_once(W3TC_LIB_MINIFY_DIR . '/Minify/Cache/File.php'); $cache = new Minify_Cache_File(w3_cache_blog_dir('minify'), array('.htaccess', 'index.php', '*.old'), $this->_config->get_boolean('minify.file.locking'), $this->_config->get_integer('timelimit.cache_flush'), w3_get_blog_id() == 0 ? W3TC_CACHE_MINIFY_DIR : null); $cache->flush(); echo 1; } catch (Exception $ex) { echo $ex->getMessage(); } exit; }
function test_Minify_Cache_File() { $data = str_repeat(md5(time()) . 'í', 100); // 3400 bytes in UTF-8 $id = 'Minify_test_cache_noLock'; $prefix = 'Minify_Cache_File : '; $cache = new Minify_Cache_File(); echo "NOTE: Minify_Cache_File : path is set to: '" . $cache->getPath() . "'.\n"; assertTrue(true === $cache->store($id, $data), $prefix . 'store'); assertTrue(countBytes($data) === $cache->getSize($id), $prefix . 'getSize'); assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid'); ob_start(); $cache->display($id); $displayed = ob_get_contents(); ob_end_clean(); assertTrue($data === $displayed, $prefix . 'display'); assertTrue($data === $cache->fetch($id), $prefix . 'fetch'); // test with locks $id = 'Minify_test_cache_withLock'; $cache = new Minify_Cache_File('', true); assertTrue(true === $cache->store($id, $data), $prefix . 'store w/ lock'); assertTrue(countBytes($data) === $cache->getSize($id), $prefix . 'getSize'); assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid'); ob_start(); $cache->display($id); $displayed = ob_get_contents(); ob_end_clean(); assertTrue($data === $displayed, $prefix . 'display w/ lock'); assertTrue($data === $cache->fetch($id), $prefix . 'fetch w/ lock'); }
function test_Minify_Cache_File() { global $minifyCachePath; $data = str_repeat(md5(time()), 160); $id = 'Minify_test_cache_noLock'; $prefix = 'Minify_Cache_File : '; $cache = new Minify_Cache_File($minifyCachePath); assertTrue(true === $cache->store($id, $data), $prefix . 'store'); assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize'); assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid'); ob_start(); $cache->display($id); $displayed = ob_get_contents(); ob_end_clean(); assertTrue($data === $displayed, $prefix . 'display'); assertTrue($data === $cache->fetch($id), $prefix . 'fetch'); // test with locks $id = 'Minify_test_cache_withLock'; $cache = new Minify_Cache_File($minifyCachePath, true); assertTrue(true === $cache->store($id, $data), $prefix . 'store w/ lock'); assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize'); assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid'); ob_start(); $cache->display($id); $displayed = ob_get_contents(); ob_end_clean(); assertTrue($data === $displayed, $prefix . 'display w/ lock'); assertTrue($data === $cache->fetch($id), $prefix . 'fetch w/ lock'); }
$array = str_replace('array (', 'array(', var_export($sm, 1)); $symlinkOption = "\$min_symlinks = {$array};"; } } require __DIR__ . '/../bootstrap.php'; require __DIR__ . '/../config.php'; if (!$min_enableBuilder) { header('Content-Type: text/plain'); die('This application is not enabled. See https://github.com/mrclay/minify/blob/master/docs/BuilderApp.wiki.md'); } if (isset($min_builderPassword) && is_string($min_builderPassword) && $min_builderPassword !== '') { DooDigestAuth::http_auth('Minify Builder', array('admin' => $min_builderPassword)); } $cachePathCode = ''; if (!isset($min_cachePath) && !function_exists('sys_get_temp_dir')) { $detectedTmp = Minify_Cache_File::tmp(); $cachePathCode = "\$min_cachePath = " . var_export($detectedTmp, 1) . ';'; } ob_start(); ?> <!DOCTYPE html> <title>Minify URI Builder</title> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW"> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> <style> body {margin:1em 60px;} h1, h2, h3 {margin-left:-25px; position:relative;} h1 {margin-top:0;} #sources {margin:0; padding:0;} #sources li {margin:0 0 0 40px} #sources li input {margin-left:2px}
static function setCache($file, $data) { $cache = new Minify_Cache_File(); $cache->store($file, $data); }
function isStatic($file) { // FIX: Bail out if this is the root if ($file == WEB_FOLDER) { return false; } // FIX: clean webfolder from path before comparing $file = preg_replace('#^' . addslashes(WEB_FOLDER) . '#', '', $file); $root = rtrim($_SERVER['DOCUMENT_ROOT'], "/") . "/"; // check in the document root if (file_exists($root . $file)) { $target = $root . $file; return $target; } // check in the app public folders if (defined("APP")) { if (file_exists(APP . "public/" . $file)) { $target = APP . "public/" . $file; return $target; } if (is_dir(APP . "plugins/") && ($handle = opendir(APP . "plugins/"))) { while (false !== ($plugin = readdir($handle))) { if ($plugin == '.' || $plugin == '..') { continue; } if (is_dir(APP . "plugins/" . $plugin) && file_exists(APP . "plugins/" . $plugin . "/public/" . $file)) { $target = APP . "plugins/" . $plugin . "/public/" . $file; return $target; } } } } //check the cache (less than an hour old) $cache = new Minify_Cache_File(); //if( $cache->isValid($file, time("now")-3600) ) return $cache->tmp() ."/". $file; if ($cache->isValid("/{$_SERVER['HTTP_HOST']}/{$file}", 0)) { return $cache->tmp() . "/{$_SERVER['HTTP_HOST']}/" . $file; } // check in the base public folders if (defined("BASE")) { if (file_exists(BASE . "public/" . $file)) { $target = BASE . "public/" . $file; return $target; } $target = realpath(BASE . "../public/" . $file); if (file_exists($target)) { return $target; } if (is_dir(BASE . "plugins/") && ($handle = opendir(BASE . "plugins/"))) { while (false !== ($plugin = readdir($handle))) { if ($plugin == '.' || $plugin == '..') { continue; } if (is_dir(BASE . "plugins/" . $plugin) && file_exists(BASE . "plugins/" . $plugin . "/public/" . $file)) { $target = BASE . "plugins/" . $plugin . "/public/" . $file; return $target; } } } } // check in the plugins directory if (defined("PLUGINS")) { $files = glob(PLUGINS . "*/public/{$file}"); if ($files && count($files) > 0) { // arbitrary pick the first file - should have a comparison mechanism in place $target = $files[0]; return $target; } } # 110 looking into web root for plugins if (is_dir(SITE_ROOT . "/plugins")) { $files = glob(SITE_ROOT . "/plugins/*/public/{$file}"); if ($files && count($files) > 0) { // arbitrary pick the first file - should have a comparison mechanism in place $target = $files[0]; return $target; } } // return false if there are no results return false; }
function setCache($path, $content) { $cache = new Minify_Cache_File(); $cache->store($path, $content); }