2008-08-29 22:56:34 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2014-09-23 11:47:20 -04:00
|
|
|
* Sets up MinApp controller and serves files
|
2008-08-29 22:56:34 +00:00
|
|
|
*
|
|
|
|
* DO NOT EDIT! Configure this utility via config.php and groupsConfig.php
|
|
|
|
*
|
|
|
|
* @package Minify
|
|
|
|
*/
|
|
|
|
|
2015-09-28 15:36:52 -04:00
|
|
|
require __DIR__ . '/bootstrap.php';
|
2014-10-12 16:27:43 +03:00
|
|
|
|
2014-02-05 00:46:08 +11:00
|
|
|
// set config path defaults
|
|
|
|
$min_configPaths = array(
|
2015-09-28 15:36:52 -04:00
|
|
|
'base' => __DIR__ . '/config.php',
|
|
|
|
'test' => __DIR__ . '/config-test.php',
|
|
|
|
'groups' => __DIR__ . '/groupsConfig.php',
|
2014-02-04 12:37:40 +11:00
|
|
|
);
|
|
|
|
|
2014-02-05 00:46:08 +11:00
|
|
|
// check for custom config paths
|
2014-02-04 10:57:45 -05:00
|
|
|
if (!empty($min_customConfigPaths) && is_array($min_customConfigPaths)) {
|
|
|
|
$min_configPaths = array_merge($min_configPaths, $min_customConfigPaths);
|
2014-02-03 18:19:00 +11:00
|
|
|
}
|
|
|
|
|
2008-08-29 22:56:34 +00:00
|
|
|
// load config
|
2014-02-05 00:59:21 +11:00
|
|
|
require $min_configPaths['base'];
|
2008-08-29 22:56:34 +00:00
|
|
|
|
2012-03-15 14:00:50 -04:00
|
|
|
if (isset($_GET['test'])) {
|
2014-02-05 00:57:18 +11:00
|
|
|
include $min_configPaths['test'];
|
2012-03-15 14:00:50 -04:00
|
|
|
}
|
|
|
|
|
2014-09-23 11:47:20 -04:00
|
|
|
// use an environment object to encapsulate all input
|
2014-09-22 15:04:05 -04:00
|
|
|
$server = $_SERVER;
|
2009-01-26 00:44:43 +00:00
|
|
|
if ($min_documentRoot) {
|
2014-09-22 15:04:05 -04:00
|
|
|
$server['DOCUMENT_ROOT'] = $min_documentRoot;
|
|
|
|
}
|
|
|
|
$env = new Minify_Env(array(
|
|
|
|
'server' => $server,
|
|
|
|
));
|
|
|
|
|
2014-09-23 11:47:20 -04:00
|
|
|
// setup cache
|
2014-09-22 15:04:05 -04:00
|
|
|
if (!isset($min_cachePath)) {
|
2014-09-23 11:47:20 -04:00
|
|
|
$min_cachePath = '';
|
|
|
|
}
|
|
|
|
if (is_string($min_cachePath)) {
|
2014-09-22 15:04:05 -04:00
|
|
|
$cache = new Minify_Cache_File($min_cachePath, $min_cacheFileLocking);
|
2014-09-23 11:47:20 -04:00
|
|
|
} else {
|
|
|
|
$cache = $min_cachePath;
|
2008-09-03 19:42:41 +00:00
|
|
|
}
|
2009-01-26 00:44:43 +00:00
|
|
|
|
2014-09-23 11:09:09 -04:00
|
|
|
$server = new Minify($cache);
|
2014-09-22 15:04:05 -04:00
|
|
|
|
2014-09-23 11:47:20 -04:00
|
|
|
// TODO probably should do this elsewhere...
|
2014-09-23 11:09:09 -04:00
|
|
|
$min_serveOptions['minifierOptions']['text/css']['docRoot'] = $env->getDocRoot();
|
2009-03-06 02:43:12 +00:00
|
|
|
$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
|
Work on: Issue 125, Issue 126, Issue 132, Issue 134, Issue 138, Issue 139, Issue 147, Issue 149, Issue 151, Issue 162, Issue 166
2010-05-09 16:43:47 +00:00
|
|
|
// auto-add targets to allowDirs
|
|
|
|
foreach ($min_symlinks as $uri => $target) {
|
|
|
|
$min_serveOptions['minApp']['allowDirs'][] = $target;
|
|
|
|
}
|
2009-01-28 20:02:25 +00:00
|
|
|
|
2010-05-10 07:44:40 +00:00
|
|
|
if ($min_allowDebugFlag) {
|
2014-09-23 11:47:20 -04:00
|
|
|
// TODO get rid of static stuff
|
2014-09-23 11:09:09 -04:00
|
|
|
$min_serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($env);
|
2009-01-26 00:44:43 +00:00
|
|
|
}
|
2009-01-28 20:02:25 +00:00
|
|
|
|
2015-09-02 17:08:33 -03:00
|
|
|
if (!empty($min_concatOnly)) {
|
|
|
|
$min_serveOptions['concatOnly'] = true;
|
|
|
|
}
|
|
|
|
|
2009-01-28 20:02:25 +00:00
|
|
|
if ($min_errorLogger) {
|
|
|
|
if (true === $min_errorLogger) {
|
2010-09-30 04:31:58 +00:00
|
|
|
$min_errorLogger = FirePHP::getInstance(true);
|
2009-01-28 20:02:25 +00:00
|
|
|
}
|
2014-09-23 11:47:20 -04:00
|
|
|
// TODO get rid of global state
|
2010-09-30 04:31:58 +00:00
|
|
|
Minify_Logger::setLogger($min_errorLogger);
|
2008-09-05 04:22:57 +00:00
|
|
|
}
|
2009-01-28 20:02:25 +00:00
|
|
|
|
2008-10-28 00:25:40 +00:00
|
|
|
// check for URI versioning
|
2014-09-23 11:09:09 -04:00
|
|
|
if (null !== $env->get('v') || preg_match('/&\\d/', $env->server('QUERY_STRING'))) {
|
2008-10-28 00:25:40 +00:00
|
|
|
$min_serveOptions['maxAge'] = 31536000;
|
|
|
|
}
|
2014-02-04 11:00:25 -05:00
|
|
|
|
|
|
|
// need groups config?
|
2014-09-23 11:09:09 -04:00
|
|
|
if (null !== $env->get('g')) {
|
2008-09-18 01:56:29 +00:00
|
|
|
// well need groups config
|
2014-02-05 00:57:18 +11:00
|
|
|
$min_serveOptions['minApp']['groups'] = (require $min_configPaths['groups']);
|
2008-09-18 01:56:29 +00:00
|
|
|
}
|
2010-09-30 04:31:58 +00:00
|
|
|
|
2014-09-23 11:09:09 -04:00
|
|
|
if ($env->get('f') || null !== $env->get('g')) {
|
|
|
|
// serving!
|
2010-09-30 04:31:58 +00:00
|
|
|
if (! isset($min_serveController)) {
|
2014-09-23 11:09:09 -04:00
|
|
|
$sourceFactoryOptions = array();
|
2014-09-23 11:47:20 -04:00
|
|
|
|
|
|
|
// translate legacy setting to option for source factory
|
2014-09-22 15:04:05 -04:00
|
|
|
if (isset($min_serveOptions['minApp']['noMinPattern'])) {
|
|
|
|
$sourceFactoryOptions['noMinPattern'] = $min_serveOptions['minApp']['noMinPattern'];
|
|
|
|
}
|
2014-09-27 16:18:23 +03:00
|
|
|
$sourceFactory = new Minify_Source_Factory($env, $sourceFactoryOptions, $cache);
|
2014-09-22 15:04:05 -04:00
|
|
|
|
2014-09-23 11:09:09 -04:00
|
|
|
$min_serveController = new Minify_Controller_MinApp($env, $sourceFactory);
|
2010-09-30 04:31:58 +00:00
|
|
|
}
|
2014-09-22 15:04:05 -04:00
|
|
|
$server->serve($min_serveController, $min_serveOptions);
|
2014-09-20 10:47:59 +02:00
|
|
|
exit;
|
2014-09-23 11:09:09 -04:00
|
|
|
}
|
2014-09-22 15:04:05 -04:00
|
|
|
|
2014-09-23 11:09:09 -04:00
|
|
|
// not serving
|
|
|
|
if ($min_enableBuilder) {
|
|
|
|
header('Location: builder/');
|
2014-09-20 10:47:59 +02:00
|
|
|
exit;
|
2014-02-03 18:19:00 +11:00
|
|
|
}
|
2014-09-23 11:09:09 -04:00
|
|
|
|
|
|
|
header('Location: /');
|
|
|
|
exit;
|