$theme = getRequestParam("theme", "", true); $package = getRequestParam("package", "", true); $type = getRequestParam("type", "", true); // Include Base and Core and Config. $man = new Moxiecode_ManagerEngine($type); require_once MCMANAGER_ABSPATH . "CorePlugin.php"; require_once "../config.php"; $man->dispatchEvent("onPreInit", array($type)); $mcConfig = $man->getConfig(); // Include all plugins $pluginPaths = $man->getPluginPaths(); foreach ($pluginPaths as $path) { require_once "../" . $path; } if ($package) { $compressor = new Moxiecode_JSCompressor(array('expires_offset' => 3600 * 24 * 10, 'disk_cache' => true, 'cache_dir' => '_cache', 'gzip_compress' => true, 'remove_whitespace' => true, 'charset' => 'UTF-8', 'name' => $theme . "_" . $package)); require_once '../classes/Utils/ClientResources.php'; $resources = new Moxiecode_ClientResources(); // Load theme resources $resources->load('../pages/' . $theme . '/resources.xml'); // Load plugin resources $plugins = explode(',', $mcConfig["general.plugins"]); foreach ($plugins as $plugin) { $resources->load('../plugins/' . $plugin . '/resources.xml'); } $man->dispatchEvent("onRequestResources", array($theme, $package, $type, "text/javascript", $resources)); $files = $resources->getFiles($package); if ($resources->isDebugEnabled() || checkBool($mcConfig["general.debug"])) { header('Content-type: text/javascript'); $pagePath = dirname($_SERVER['SCRIPT_NAME']); echo "// Debug enabled, scripts will be loaded without compression\n";
<?php @error_reporting(E_ALL ^ E_NOTICE); require_once '../classes/Utils/JSCompressor.php'; // Set the error reporting to minimal. @error_reporting(E_ERROR | E_WARNING | E_PARSE); $classes = getParam("classes"); $compressor = new Moxiecode_JSCompressor(array('expires_offset' => 3600 * 24 * 10, 'disk_cache' => true, 'cache_dir' => '_cache', 'gzip_compress' => true, 'remove_whitespace' => true, 'charset' => 'UTF-8')); // Load classes $classes = explode(',', $classes); foreach ($classes as $class) { $file = strtolower(str_replace(".", "/", $class)); $file = preg_replace('/\\/+/', '/', $file) . ".js"; $compressor->addFile($file); } $compressor->compress(); // * * Functions function getParam($name, $def = false) { if (!isset($_GET[$name])) { return $def; } return preg_replace("/[^0-9a-z\\.,_]+/i", "", $_GET[$name]); // Remove anything but 0-9,a-z,-_ }
// it gets to /js/ instead of /js/index.php $baseURL = $_SERVER["PHP_SELF"]; // Hmm, stange? if (strpos($baseURL, 'default.php/') > 0 || strpos($baseURL, 'index.php/') > 0) { $baseURL = $_SERVER["SCRIPT_NAME"]; } // Is file, get dir if (getFileExt($baseURL) == "php") { $baseURL = dirname($baseURL); } // Remove trailing slash if it has any if ($baseURL && $baseURL[strlen($baseURL) - 1] == '/') { $baseURL = substr($baseURL, 0, strlen($baseURL) - 1); } // Remove any weird // or /// items $baseURL = preg_replace('/\\/+/', '/', $baseURL); if ($compress) { $compressor = new Moxiecode_JSCompressor(array('expires_offset' => 3600 * 24 * 10, 'disk_cache' => true, 'cache_dir' => '_cache', 'gzip_compress' => true, 'remove_whitespace' => true, 'charset' => 'UTF-8')); // Compress these $compressor->addFile('mox.js'); $compressor->addFile('gz_loader.js'); $compressor->addContent("mox.defaultDoc = 'index.php';"); $compressor->addContent('mox.findBaseURL(/(\\/js\\/|\\/js\\/index\\.php)$/);'); $compressor->compress(); die; } else { header("Content-type: text/javascript"); require_once 'mox.js'; echo "\nmox.defaultDoc = 'index.php';\n"; echo "\nmox.findBaseURL(/(\\/js\\/|\\/js\\/index\\.php)\$/);\n"; }
// it gets to /js/ instead of /js/index.php $baseURL = $_SERVER["PHP_SELF"]; // Hmm, stange? if (strpos($baseURL, 'default.php/') > 0 || strpos($baseURL, 'index.php/') > 0) { $baseURL = $_SERVER["SCRIPT_NAME"]; } // Is file, get dir if (getFileExt($baseURL) == "php") { $baseURL = dirname($baseURL); } // Remove trailing slash if it has any if ($baseURL && $baseURL[strlen($baseURL) - 1] == '/') { $baseURL = substr($baseURL, 0, strlen($baseURL) - 1); } // Remove any weird // or /// items $baseURL = preg_replace('/\\/+/', '/', $baseURL); if ($compress) { $compressor = new Moxiecode_JSCompressor(array('expires_offset' => 3600 * 24 * 10, 'disk_cache' => true, 'cache_dir' => '_cache', 'gzip_compress' => false, 'remove_whitespace' => true, 'charset' => 'UTF-8')); // Compress these $compressor->addFile('mox.js'); $compressor->addFile('gz_loader.js'); $compressor->addContent("mox.baseURL = '" . $baseURL . "';"); $compressor->addContent("mox.defaultDoc = 'index.php';"); $compressor->compress(); die; } else { header("Content-type: text/javascript"); require_once 'mox.js'; echo "\nmox.baseURL = '" . $baseURL . "';\n"; echo "\nmox.defaultDoc = 'index.php';\n"; }