]> git.joonet.de Git - adminer.git/commitdiff
Compress CSS
authorJakub Vrana <jakub@vrana.cz>
Fri, 7 Sep 2012 05:20:44 +0000 (22:20 -0700)
committerJakub Vrana <jakub@vrana.cz>
Fri, 7 Sep 2012 15:38:10 +0000 (08:38 -0700)
adminer/file.inc.php
adminer/include/functions.inc.php
adminer/include/lang.inc.php
compile.php

index 53eafd3601d8c28288f8fbae06704775a2e70740..5d3332cdd3512068a15c2adc2fd41bbb219d9bfa 100644 (file)
@@ -6,7 +6,7 @@ if ($_GET["file"] == "favicon.ico") {
        echo "compile_file('../adminer/static/favicon.ico', 'add_quo_slashes');";
 } elseif ($_GET["file"] == "default.css") {
        header("Content-Type: text/css; charset=utf-8");
-       ?>compile_file('../adminer/static/default.css', 'minify_css');<?php
+       echo lzw_decompress("compile_file('../adminer/static/default.css', 'minify_css');");
 } elseif ($_GET["file"] == "functions.js") {
        header("Content-Type: text/javascript; charset=utf-8");
        ?>compile_file('../adminer/static/functions.js', 'jsShrink');compile_file('static/editing.js', 'jsShrink');<?php
index 37122a969d676cbb7942dc0f0e62d2ff282775f2..fb8cd35b290b82617038e787b3d3407f14ab5221 100644 (file)
@@ -929,3 +929,41 @@ var timeout = setTimeout(function () {
        }
        return array_keys($return);
 }
+
+// used in compiled version
+function lzw_decompress($binary) {
+       // convert binary string to codes
+       $dictionary_count = 256;
+       $bits = 8; // ceil(log($dictionary_count, 2))
+       $codes = array();
+       $rest = 0;
+       $rest_length = 0;
+       for ($i=0; $i < strlen($binary); $i++) {
+               $rest = ($rest << 8) + ord($binary[$i]);
+               $rest_length += 8;
+               if ($rest_length >= $bits) {
+                       $rest_length -= $bits;
+                       $codes[] = $rest >> $rest_length;
+                       $rest &= (1 << $rest_length) - 1;
+                       $dictionary_count++;
+                       if ($dictionary_count >> $bits) {
+                               $bits++;
+                       }
+               }
+       }
+       // decompression
+       $dictionary = range("\0", "\xFF");
+       $return = "";
+       foreach ($codes as $i => $code) {
+               $element = $dictionary[$code];
+               if (!isset($element)) {
+                       $element = $word . $word[0];
+               }
+               $return .= $element;
+               if ($i) {
+                       $dictionary[] = $word . $element[0];
+               }
+               $word = $element;
+       }
+       return $return;
+}
index edd1efbd5861f0d9052b17cfa5a00cd8cbc16ccd..41132e7548df3b53e2a5115f55487e3f191b6e33 100644 (file)
@@ -78,44 +78,6 @@ function switch_lang() {
        echo "</div>\n</form>\n";
 }
 
-// used in compiled version
-function lzw_decompress($binary) {
-       // convert binary string to codes
-       $dictionary_count = 256;
-       $bits = 8; // ceil(log($dictionary_count, 2))
-       $codes = array();
-       $rest = 0;
-       $rest_length = 0;
-       for ($i=0; $i < strlen($binary); $i++) {
-               $rest = ($rest << 8) + ord($binary[$i]);
-               $rest_length += 8;
-               if ($rest_length >= $bits) {
-                       $rest_length -= $bits;
-                       $codes[] = $rest >> $rest_length;
-                       $rest &= (1 << $rest_length) - 1;
-                       $dictionary_count++;
-                       if ($dictionary_count >> $bits) {
-                               $bits++;
-                       }
-               }
-       }
-       // decompression
-       $dictionary = range("\0", "\xFF");
-       $return = "";
-       foreach ($codes as $i => $code) {
-               $element = $dictionary[$code];
-               if (!isset($element)) {
-                       $element = $word . $word[0];
-               }
-               $return .= $element;
-               if ($i) {
-                       $dictionary[] = $word . $element[0];
-               }
-               $word = $element;
-       }
-       return $return;
-}
-
 if (isset($_POST["lang"]) && $_SESSION["token"] == $_POST["token"]) { // $token and $error not yet available
        cookie("adminer_lang", $_POST["lang"]);
        $_SESSION["lang"] = $_POST["lang"]; // cookies may be disabled
index c1ed443b3428278a1a22734abc54e03a587fe7a3..2f2bf08197a2b741d2543e446f731db8d27ee15b 100755 (executable)
@@ -254,7 +254,7 @@ function php_shrink($input) {
 }
 
 function minify_css($file) {
-       return preg_replace('~\\s*([:;{},])\\s*~', '\\1', preg_replace('~/\\*.*\\*/~sU', '', $file));
+       return add_quo_slashes(lzw_compress(preg_replace('~\\s*([:;{},])\\s*~', '\\1', preg_replace('~/\\*.*\\*/~sU', '', $file))));
 }
 
 function compile_file($match) {