Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simplify compile_file()

  • Loading branch information...
commit dd86e1892db211f08de2b44d935a0e4506cda1e9 1 parent e767663
Jakub Vrána authored
Showing with 15 additions and 12 deletions.
  1. +8 −8 adminer/file.inc.php
  2. +7 −4 compile.php
16 adminer/file.inc.php
View
@@ -3,21 +3,21 @@
if ($_GET["file"] == "favicon.ico") {
header("Content-Type: image/x-icon");
- echo "compile_file('../adminer/static/favicon.ico', 'add_quo_slashes');";
+ echo compile_file('../adminer/static/favicon.ico');
} elseif ($_GET["file"] == "default.css") {
header("Content-Type: text/css; charset=utf-8");
- echo lzw_decompress("compile_file('../adminer/static/default.css', 'minify_css');");
+ echo lzw_decompress(compile_file('../adminer/static/default.css', 'minify_css'));
} elseif ($_GET["file"] == "functions.js") {
header("Content-Type: text/javascript; charset=utf-8");
- echo lzw_decompress("compile_file('../adminer/static/functions.js;static/editing.js', 'minify_js');");
+ echo lzw_decompress(compile_file('../adminer/static/functions.js;static/editing.js', 'minify_js'));
} else {
header("Content-Type: image/gif");
switch ($_GET["file"]) {
- case "plus.gif": echo "compile_file('../adminer/static/plus.gif', 'add_quo_slashes');"; break;
- case "cross.gif": echo "compile_file('../adminer/static/cross.gif', 'add_quo_slashes');"; break;
- case "up.gif": echo "compile_file('../adminer/static/up.gif', 'add_quo_slashes');"; break;
- case "down.gif": echo "compile_file('../adminer/static/down.gif', 'add_quo_slashes');"; break;
- case "arrow.gif": echo "compile_file('../adminer/static/arrow.gif', 'add_quo_slashes');"; break;
+ case "plus.gif": echo compile_file('../adminer/static/plus.gif'); break;
+ case "cross.gif": echo compile_file('../adminer/static/cross.gif'); break;
+ case "up.gif": echo compile_file('../adminer/static/up.gif'); break;
+ case "down.gif": echo compile_file('../adminer/static/down.gif'); break;
+ case "arrow.gif": echo compile_file('../adminer/static/arrow.gif'); break;
}
}
exit;
11 compile.php
View
@@ -248,14 +248,14 @@ function php_shrink($input) {
}
function minify_css($file) {
- return add_quo_slashes(lzw_compress(preg_replace('~\\s*([:;{},])\\s*~', '\\1', preg_replace('~/\\*.*\\*/~sU', '', $file))));
+ return lzw_compress(preg_replace('~\\s*([:;{},])\\s*~', '\\1', preg_replace('~/\\*.*\\*/~sU', '', $file)));
}
function minify_js($file) {
if (function_exists('jsShrink')) {
$file = jsShrink($file);
}
- return add_quo_slashes(lzw_compress($file));
+ return lzw_compress($file);
}
function compile_file($match) {
@@ -264,7 +264,10 @@ function compile_file($match) {
foreach (explode(";", $match[1]) as $filename) {
$file .= file_get_contents(dirname(__FILE__) . "/$project/$filename");
}
- return call_user_func($match[2], $file);
+ if ($match[2]) {
+ $file = call_user_func($match[2], $file);
+ }
+ return '"' . add_quo_slashes($file) . '"';
}
$driver = "";
@@ -347,7 +350,7 @@ function compile_file($match) {
$file = str_replace('<?php echo $LANG; ?>', $_SESSION["lang"], $file);
}
$file = str_replace('<script type="text/javascript" src="static/editing.js"></script>' . "\n", "", $file);
- $file = preg_replace_callback("~compile_file\\('([^']+)', '([^']+)'\\);~", 'compile_file', $file); // integrate static files
+ $file = preg_replace_callback("~compile_file\\('([^']+)'(?:, '([^']*)')?\\)~", 'compile_file', $file); // integrate static files
$replace = 'h(preg_replace("~\\\\\\\\?.*~", "", ME)) . "?file=\\1&amp;version=' . $VERSION;
$file = preg_replace('~\\.\\./adminer/static/(default\\.css|functions\\.js|favicon\\.ico)~', '<?php echo ' . $replace . '"; ?>', $file);
$file = preg_replace('~\\.\\./adminer/static/([^\'"]*)~', '" . ' . $replace, $file);
Please sign in to comment.
Something went wrong with that request. Please try again.