Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 368 lines (345 sloc) 13.755 kb
56ac3d18 »
2012-05-25 Mark scripts as executable
1 #!/usr/bin/env php
667bfec4 » jakubvrana
2007-07-02 Decomposition
2 <?php
1bc77f88 » jakubvrana
2009-08-28 Report user errors
3 error_reporting(6135); // errors and warnings
e1bc7af8 » jakubvrana
2009-06-13 Change directory structure
4 include dirname(__FILE__) . "/adminer/include/version.inc.php";
bf4f0a1f »
2012-03-08 Replace JSMin by JsShrink
5 include dirname(__FILE__) . "/externals/JsShrink/jsShrink.php";
7f3b4f2b » jakubvrana
2009-05-29 Version checker
6
89436789 » jakubvrana
2007-07-09 sprintf() in lang()
7 function add_apo_slashes($s) {
8 return addcslashes($s, "\\'");
9 }
10
f3c59bb3 »
2012-09-22 Unuse binary characters
11 function binary_latin($s) {
12 return preg_replace_callback('~[\0- ]~', 'binary_latin_callback', $s);
13 }
14
15 function binary_latin_callback($match) {
16 return ' ' . chr(ord($match[0]) + ord('0'));
415f500f »
2012-09-06 Don't use \r\n in compiled strings
17 }
18
0970a583 » jakubvrana
2007-07-05 Prepare for single language version
19 function remove_lang($match) {
bba76d8d » jakubvrana
2007-08-04 Flatten $translations
20 global $translations;
438ca058 » jakubvrana
2007-07-26 Separate languages
21 $idf = strtr($match[2], array("\\'" => "'", "\\\\" => "\\"));
bba76d8d » jakubvrana
2007-08-04 Flatten $translations
22 $s = ($translations[$idf] ? $translations[$idf] : $idf);
64ba9242 » jakubvrana
2009-06-21 Comments
23 if ($match[3] == ",") { // lang() has parameters
89436789 » jakubvrana
2007-07-09 sprintf() in lang()
24 return "$match[1]" . (is_array($s) ? "lang(array('" . implode("', '", array_map('add_apo_slashes', $s)) . "')," : "sprintf('" . add_apo_slashes($s) . "',");
25 }
26 return ($match[1] && $match[4] ? $s : "$match[1]'" . add_apo_slashes($s) . "'$match[4]");
0970a583 » jakubvrana
2007-07-05 Prepare for single language version
27 }
28
4738060a » jakubvrana
2008-05-23 Use numeric language IDs to save bytes
29 function lang_ids($match) {
30 global $lang_ids;
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
31 $lang_id = &$lang_ids[stripslashes($match[1])];
6591d485 »
2012-05-13 Replace isset($var) by $var !== null
32 if ($lang_id === null) {
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
33 $lang_id = count($lang_ids) - 1;
34 }
0116b9d1 » jakubvrana
2009-09-10 Don't set cookie in compile scripts
35 return ($_SESSION["lang"] ? $match[0] : "lang($lang_id$match[2]");
4738060a » jakubvrana
2008-05-23 Use numeric language IDs to save bytes
36 }
37
667bfec4 » jakubvrana
2007-07-02 Decomposition
38 function put_file($match) {
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
39 global $project;
b95f24ea » jakubvrana
2009-07-03 Editor: User friendly data editor
40 if (basename($match[2]) == '$LANG.inc.php') {
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
41 return $match[0]; // processed later
438ca058 » jakubvrana
2007-07-26 Separate languages
42 }
b95f24ea » jakubvrana
2009-07-03 Editor: User friendly data editor
43 $return = file_get_contents(dirname(__FILE__) . "/$project/$match[2]");
0116b9d1 » jakubvrana
2009-09-10 Don't set cookie in compile scripts
44 if (basename($match[2]) != "lang.inc.php" || !$_SESSION["lang"]) {
64ba9242 » jakubvrana
2009-06-21 Comments
45 $tokens = token_get_all($return); // to find out the last token
6bb1401d » jakubvrana
2009-06-01 Remove ?><?php
46 return "?>\n$return" . (in_array($tokens[count($tokens) - 1][0], array(T_CLOSE_TAG, T_INLINE_HTML), true) ? "<?php" : "");
9a4cabe8 »
2011-07-11 Simplify single language version
47 } elseif (preg_match('~\\s*(\\$pos = (.+\n).+;)~sU', $return, $match2)) {
64ba9242 » jakubvrana
2009-06-21 Comments
48 // single language lang() is used for plural
e37c427e »
2010-12-30 Function get_lang useful for customization
49 return "function get_lang() {
50 return '$_SESSION[lang]';
51 }
52
53 function lang(\$translation, \$number) {
9a4cabe8 »
2011-07-11 Simplify single language version
54 \$pos = $match2[2]\t\t: " . (preg_match("~\\\$LANG == '$_SESSION[lang]'.* \\? (.+)\n~U", $match2[1], $match3) ? $match3[1] : "1") . '
55 );
7f1fcc22 »
2012-06-04 Format numbers in translations
56 $translation = str_replace("%d", "%s", $translation[$pos]);
57 $number = number_format($number, 0, ".", lang(\',\'));
58 return sprintf($translation, $number);
e37c427e »
2010-12-30 Function get_lang useful for customization
59 }
60 ';
6bb1401d » jakubvrana
2009-06-01 Remove ?><?php
61 } else {
62 echo "lang() not found\n";
667bfec4 » jakubvrana
2007-07-02 Decomposition
63 }
64 }
65
5d257861 »
2012-09-02 Compress translations
66 function lzw_compress($string) {
67 // compression
68 $dictionary = array_flip(range("\0", "\xFF"));
69 $word = "";
70 $codes = array();
71 for ($i=0; $i <= strlen($string); $i++) {
72 $x = $string[$i];
73 if (strlen($x) && isset($dictionary[$word . $x])) {
74 $word .= $x;
75 } elseif ($i) {
76 $codes[] = $dictionary[$word];
77 $dictionary[$word . $x] = count($dictionary);
78 $word = $x;
79 }
80 }
81 // convert codes to binary string
82 $dictionary_count = 256;
83 $bits = 8; // ceil(log($dictionary_count, 2))
84 $return = "";
85 $rest = 0;
86 $rest_length = 0;
87 foreach ($codes as $code) {
88 $rest = ($rest << $bits) + $code;
89 $rest_length += $bits;
90 $dictionary_count++;
91 if ($dictionary_count >> $bits) {
92 $bits++;
93 }
94 while ($rest_length > 7) {
95 $rest_length -= 8;
96 $return .= chr($rest >> $rest_length);
97 $rest &= (1 << $rest_length) - 1;
98 }
99 }
100 return $return . ($rest_length ? chr($rest << (8 - $rest_length)) : "");
101 }
102
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
103 function put_file_lang($match) {
b4b59779 »
2010-11-15 Include only active translations
104 global $lang_ids, $project, $langs;
0116b9d1 » jakubvrana
2009-09-10 Don't set cookie in compile scripts
105 if ($_SESSION["lang"]) {
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
106 return "";
107 }
0317638e »
2012-09-03 Compress each translation separately
108 $return = "";
b4b59779 »
2010-11-15 Include only active translations
109 foreach ($langs as $lang => $val) {
110 include dirname(__FILE__) . "/adminer/lang/$lang.inc.php"; // assign $translations
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
111 $translation_ids = array_flip($lang_ids); // default translation
112 foreach ($translations as $key => $val) {
6591d485 »
2012-05-13 Replace isset($var) by $var !== null
113 if ($val !== null) {
0317638e »
2012-09-03 Compress each translation separately
114 $translation_ids[$lang_ids[$key]] = implode("\t", (array) $val);
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
115 }
116 }
f3c59bb3 »
2012-09-22 Unuse binary characters
117 $return .= "
118 case '$lang': \$compressed = '" . add_apo_slashes(binary_latin(lzw_compress(implode("\n", $translation_ids)))) . "'; break;";
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
119 }
0317638e »
2012-09-03 Compress each translation separately
120 $translations_version = crc32($return);
5d257861 »
2012-09-02 Compress translations
121 return '$translations = &$_SESSION["translations"];
ccd12466 »
2012-09-03 Save translations version
122 if ($_SESSION["translations_version"] != ' . $translations_version . ') {
123 $translations = array();
124 $_SESSION["translations_version"] = ' . $translations_version . ';
125 }
57d0c4c6 »
2012-09-16 Fix switching language in compiled version
126 if (!$translations) {
0317638e »
2012-09-03 Compress each translation separately
127 switch ($LANG) {' . $return . '
128 }
129 $translations = array();
f3c59bb3 »
2012-09-22 Unuse binary characters
130 foreach (explode("\n", lzw_decompress(latin_binary($compressed))) as $val) {
0317638e »
2012-09-03 Compress each translation separately
131 $translations[] = (strpos($val, "\t") ? explode("\t", $val) : $val);
132 }
5d257861 »
2012-09-02 Compress translations
133 }
134 ';
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
135 }
136
16f42102 » jakubvrana
2009-04-15 Function minification
137 function short_identifier($number, $chars) {
138 $return = '';
a06f4c15 » jakubvrana
2009-04-15 Size reduction by minification of variables
139 while ($number >= 0) {
b0666e53 »
2012-05-16 Remove unnecessary { } in compile
140 $return .= $chars[$number % strlen($chars)];
a06f4c15 » jakubvrana
2009-04-15 Size reduction by minification of variables
141 $number = floor($number / strlen($chars)) - 1;
142 }
143 return $return;
144 }
145
004d7a96 » jakubvrana
2009-07-24 Link
146 // based on http://latrine.dgx.cz/jak-zredukovat-php-skripty
794192d9 » jakubvrana
2007-09-04 php_shrink()
147 function php_shrink($input) {
cbdf09d8 »
2011-05-12 Show version in comment (thanks to David Grudl)
148 global $VERSION;
815eb26e » jakubvrana
2009-05-08 Use one token for all
149 $special_variables = array_flip(array('$this', '$GLOBALS', '$_GET', '$_POST', '$_FILES', '$_COOKIE', '$_SESSION', '$_SERVER'));
12d2c6db » jakubvrana
2009-10-06 Build Adminer and Editor together
150 $short_variables = array();
a06f4c15 » jakubvrana
2009-04-15 Size reduction by minification of variables
151 $shortening = true;
16f42102 » jakubvrana
2009-04-15 Function minification
152 $tokens = token_get_all($input);
153
b0666e53 »
2012-05-16 Remove unnecessary { } in compile
154 // remove unnecessary { }
155 //! change also `while () { if () {;} }` to `while () if () ;` but be careful about `if () { if () { } } else { }
156 $shorten = 0;
157 $opening = -1;
158 foreach ($tokens as $i => $token) {
159 if (in_array($token[0], array(T_IF, T_ELSE, T_ELSEIF, T_WHILE, T_DO, T_FOR, T_FOREACH), true)) {
160 $shorten = ($token[0] == T_FOR ? 4 : 2);
161 $opening = -1;
162 } elseif (in_array($token[0], array(T_SWITCH, T_FUNCTION, T_CLASS, T_CLOSE_TAG), true)) {
163 $shorten = 0;
164 } elseif ($token === ';') {
165 $shorten--;
166 } elseif ($token === '{') {
167 if ($opening < 0) {
168 $opening = $i;
169 } elseif ($shorten > 1) {
170 $shorten = 0;
171 }
172 } elseif ($token === '}' && $opening >= 0 && $shorten == 1) {
173 unset($tokens[$opening]);
174 unset($tokens[$i]);
175 $shorten = 0;
176 $opening = -1;
177 }
178 }
179 $tokens = array_values($tokens);
180
16f42102 » jakubvrana
2009-04-15 Function minification
181 foreach ($tokens as $i => $token) {
182 if ($token[0] === T_VARIABLE && !isset($special_variables[$token[1]])) {
183 $short_variables[$token[1]]++;
184 }
185 }
c27a8774 » jakubvrana
2009-04-16 Minify defined functions only
186
16f42102 » jakubvrana
2009-04-15 Function minification
187 arsort($short_variables);
0ced6d33 »
2011-08-09 Preserve short variable names between versions if possible
188 $chars = implode(range('a', 'z')) . '_' . implode(range('A', 'Z'));
189 // preserve variable names between versions if possible
190 $short_variables2 = array_splice($short_variables, strlen($chars));
191 ksort($short_variables);
192 ksort($short_variables2);
193 $short_variables += $short_variables2;
16f42102 » jakubvrana
2009-04-15 Function minification
194 foreach (array_keys($short_variables) as $number => $key) {
0ced6d33 »
2011-08-09 Preserve short variable names between versions if possible
195 $short_variables[$key] = short_identifier($number, $chars); // could use also numbers and \x7f-\xff
16f42102 » jakubvrana
2009-04-15 Function minification
196 }
a06f4c15 » jakubvrana
2009-04-15 Size reduction by minification of variables
197
541561be »
2012-09-03 Minimize space around %
198 $set = array_flip(preg_split('//', '!"#$%&\'()*+,-./:;<=>?@[\]^`{|}'));
794192d9 » jakubvrana
2007-09-04 php_shrink()
199 $space = '';
200 $output = '';
ff85f125 » jakubvrana
2009-06-01 Join echos
201 $in_echo = false;
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
202 $doc_comment = false; // include only first /**
ff85f125 » jakubvrana
2009-06-01 Join echos
203 for (reset($tokens); list($i, $token) = each($tokens); ) {
794192d9 » jakubvrana
2007-09-04 php_shrink()
204 if (!is_array($token)) {
205 $token = array(0, $token);
206 }
dbf95669 » jakubvrana
2009-08-26 Better consecutive echo handling
207 if ($tokens[$i+2][0] === T_CLOSE_TAG && $tokens[$i+3][0] === T_INLINE_HTML && $tokens[$i+4][0] === T_OPEN_TAG
415f500f »
2012-09-06 Don't use \r\n in compiled strings
208 && strlen(add_apo_slashes($tokens[$i+3][1])) < strlen($tokens[$i+3][1]) + 3
dbf95669 » jakubvrana
2009-08-26 Better consecutive echo handling
209 ) {
210 $tokens[$i+2] = array(T_ECHO, 'echo');
415f500f »
2012-09-06 Don't use \r\n in compiled strings
211 $tokens[$i+3] = array(T_CONSTANT_ENCAPSED_STRING, "'" . add_apo_slashes($tokens[$i+3][1]) . "'");
dbf95669 » jakubvrana
2009-08-26 Better consecutive echo handling
212 $tokens[$i+4] = array(0, ';');
213 }
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
214 if ($token[0] == T_COMMENT || $token[0] == T_WHITESPACE || ($token[0] == T_DOC_COMMENT && $doc_comment)) {
794192d9 » jakubvrana
2007-09-04 php_shrink()
215 $space = "\n";
216 } else {
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
217 if ($token[0] == T_DOC_COMMENT) {
218 $doc_comment = true;
cbdf09d8 »
2011-05-12 Show version in comment (thanks to David Grudl)
219 $token[1] = substr_replace($token[1], "* @version $VERSION\n", -2, 0);
c16c57b1 » jakubvrana
2009-07-11 E-mail sending
220 }
a06f4c15 » jakubvrana
2009-04-15 Size reduction by minification of variables
221 if ($token[0] == T_VAR) {
222 $shortening = false;
223 } elseif (!$shortening) {
224 if ($token[1] == ';') {
225 $shortening = true;
226 }
ff85f125 » jakubvrana
2009-06-01 Join echos
227 } elseif ($token[0] == T_ECHO) {
228 $in_echo = true;
229 } elseif ($token[1] == ';' && $in_echo) {
e2bc1daa » jakubvrana
2009-08-26 No comments without whitespace
230 if ($tokens[$i+1][0] === T_WHITESPACE && $tokens[$i+2][0] === T_ECHO) {
ff85f125 » jakubvrana
2009-06-01 Join echos
231 next($tokens);
c030c163 » jakubvrana
2009-07-30 Compile inline HTML to echo
232 $i++;
233 }
234 if ($tokens[$i+1][0] === T_ECHO) {
235 // join two consecutive echos
ff85f125 » jakubvrana
2009-06-01 Join echos
236 next($tokens);
02046d69 » jakubvrana
2009-09-23 Windows support in e-mail attachments
237 $token[1] = ','; // '.' would conflict with "a".1+2 and would use more memory //! remove ',' and "," but not $var","
dbf95669 » jakubvrana
2009-08-26 Better consecutive echo handling
238 } else {
239 $in_echo = false;
ff85f125 » jakubvrana
2009-06-01 Join echos
240 }
16f42102 » jakubvrana
2009-04-15 Function minification
241 } elseif ($token[0] === T_VARIABLE && !isset($special_variables[$token[1]])) {
242 $token[1] = '$' . $short_variables[$token[1]];
a06f4c15 » jakubvrana
2009-04-15 Size reduction by minification of variables
243 }
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
244 if (isset($set[substr($output, -1)]) || isset($set[$token[1][0]])) {
794192d9 » jakubvrana
2007-09-04 php_shrink()
245 $space = '';
246 }
247 $output .= $space . $token[1];
248 $space = '';
249 }
250 }
251 return $output;
252 }
253
9ee9cf08 » jakubvrana
2009-06-26 Remove code generation
254 function minify_css($file) {
dd86e189 »
2012-09-06 Simplify compile_file()
255 return lzw_compress(preg_replace('~\\s*([:;{},])\\s*~', '\\1', preg_replace('~/\\*.*\\*/~sU', '', $file)));
9ee9cf08 » jakubvrana
2009-06-26 Remove code generation
256 }
257
e767663f »
2012-09-06 Compress JS
258 function minify_js($file) {
63c9873c »
2012-09-06 Fix JUSH compilation
259 $file = str_replace("'../externals/jush/'", "location.protocol + '//www.adminer.org/static/'", $file);
e767663f »
2012-09-06 Compress JS
260 if (function_exists('jsShrink')) {
261 $file = jsShrink($file);
262 }
dd86e189 »
2012-09-06 Simplify compile_file()
263 return lzw_compress($file);
e767663f »
2012-09-06 Compress JS
264 }
265
9ee9cf08 » jakubvrana
2009-06-26 Remove code generation
266 function compile_file($match) {
df03f4f0 » jakubvrana
2009-07-13 Join editing.js in compilation
267 global $project;
e767663f »
2012-09-06 Compress JS
268 $file = "";
269 foreach (explode(";", $match[1]) as $filename) {
270 $file .= file_get_contents(dirname(__FILE__) . "/$project/$filename");
271 }
dd86e189 »
2012-09-06 Simplify compile_file()
272 if ($match[2]) {
273 $file = call_user_func($match[2], $file);
274 }
f3c59bb3 »
2012-09-22 Unuse binary characters
275 return "latin_binary('" . add_apo_slashes(binary_latin($file)) . "')";
9ee9cf08 » jakubvrana
2009-06-26 Remove code generation
276 }
277
e6726941 »
2010-05-07 Rename $driver to $jush
278 $driver = "";
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
279 if (file_exists(dirname(__FILE__) . "/adminer/drivers/" . $_SERVER["argv"][1] . ".inc.php")) {
e6726941 »
2010-05-07 Rename $driver to $jush
280 $driver = $_SERVER["argv"][1];
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
281 array_shift($_SERVER["argv"]);
282 }
283
0116b9d1 » jakubvrana
2009-09-10 Don't set cookie in compile scripts
284 unset($_COOKIE["adminer_lang"]);
285 $_SESSION["lang"] = $_SERVER["argv"][1]; // Adminer functions read language from session
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
286 include dirname(__FILE__) . "/adminer/include/lang.inc.php";
0116b9d1 » jakubvrana
2009-09-10 Don't set cookie in compile scripts
287 if (isset($_SESSION["lang"])) {
288 if (isset($_SERVER["argv"][2]) || !isset($langs[$_SESSION["lang"]])) {
7e97fcd0 » Jakub Vrana
2012-02-17 Compile usage
289 echo "Usage: php compile.php [driver] [lang]\nPurpose: Compile adminer[-driver][-lang].php and editor[-driver][-lang].php.\n";
7418af0c » jakubvrana
2007-07-05 Czech translation
290 exit(1);
291 }
0116b9d1 » jakubvrana
2009-09-10 Don't set cookie in compile scripts
292 include dirname(__FILE__) . "/adminer/lang/$_SESSION[lang].inc.php";
7418af0c » jakubvrana
2007-07-05 Czech translation
293 }
bba76d8d » jakubvrana
2007-08-04 Flatten $translations
294
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
295 // check function definition in drivers
296 $filename = dirname(__FILE__) . "/adminer/drivers/mysql.inc.php";
297 preg_match_all('~\\bfunction ([^(]+)~', file_get_contents($filename), $matches); //! respect context (extension, class)
298 $functions = array_combine($matches[1], $matches[0]);
299 unset($functions["__destruct"], $functions["Min_DB"], $functions["Min_Result"]);
e6726941 »
2010-05-07 Rename $driver to $jush
300 foreach (glob(dirname(__FILE__) . "/adminer/drivers/" . ($driver ? $driver : "*") . ".inc.php") as $filename) {
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
301 if ($filename != "mysql.inc.php") {
302 $file = file_get_contents($filename);
303 foreach ($functions as $val) {
304 if (!strpos($file, "$val(")) {
360218be »
2012-09-16 Print compile errors to STDERR
305 fprintf(STDERR, "Missing $val in $filename\n");
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
306 }
307 }
308 }
309 }
310
e6726941 »
2010-05-07 Rename $driver to $jush
311 include dirname(__FILE__) . "/adminer/include/pdo.inc.php";
955e6b44 »
2011-06-04 PostgreSQL supports only functions
312 $features = array("call" => "routine", "dump", "event", "privileges", "procedure" => "routine", "processlist", "routine", "scheme", "sequence", "status", "trigger", "type", "user" => "privileges", "variables", "view");
12d2c6db » jakubvrana
2009-10-06 Build Adminer and Editor together
313 foreach (array("adminer", "editor") as $project) {
314 $lang_ids = array(); // global variable simplifies usage in a callback function
315 $file = file_get_contents(dirname(__FILE__) . "/$project/index.php");
e6726941 »
2010-05-07 Rename $driver to $jush
316 if ($driver) {
6420c584 » jakubvrana
2010-05-05 Schema support for PostgreSQL
317 $connection = (object) array("server_info" => 5.1); // MySQL support is version specific
e6726941 »
2010-05-07 Rename $driver to $jush
318 $_GET[$driver] = true; // to load the driver
319 include_once dirname(__FILE__) . "/adminer/drivers/$driver.inc.php";
955e6b44 »
2011-06-04 PostgreSQL supports only functions
320 foreach ($features as $key => $feature) {
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
321 if (!support($feature)) {
955e6b44 »
2011-06-04 PostgreSQL supports only functions
322 if (!is_int($key)) {
323 $feature = $key;
324 }
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
325 $file = str_replace("} elseif (isset(\$_GET[\"$feature\"])) {\n\tinclude \"./$feature.inc.php\";\n", "", $file);
326 }
327 }
328 if (!support("routine")) {
329 $file = str_replace("if (isset(\$_GET[\"callf\"])) {\n\t\$_GET[\"call\"] = \$_GET[\"callf\"];\n}\nif (isset(\$_GET[\"function\"])) {\n\t\$_GET[\"procedure\"] = \$_GET[\"function\"];\n}\n", "", $file);
330 }
331 }
12d2c6db » jakubvrana
2009-10-06 Build Adminer and Editor together
332 $file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file);
333 $file = str_replace('include "../adminer/include/coverage.inc.php";', '', $file);
e6726941 »
2010-05-07 Rename $driver to $jush
334 if ($driver) {
335 $file = preg_replace('(include "../adminer/drivers/(?!' . preg_quote($driver) . ').*\\s*)', '', $file);
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
336 }
12d2c6db » jakubvrana
2009-10-06 Build Adminer and Editor together
337 $file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); // bootstrap.inc.php
e678e467 »
2010-05-21 Remove unsupported features in single driver version
338 if ($driver) {
339 foreach ($features as $feature) {
340 if (!support($feature)) {
341 $file = preg_replace("((\t*)" . preg_quote('if (support("' . $feature . '")') . ".*\n\\1\\})sU", '', $file);
342 }
343 }
4b9d451d »
2010-05-28 SQLite version supports two systems
344 if (count($drivers) == 1) {
30cfa613 »
2010-06-08 Fix MySQL only version
345 $file = str_replace('<?php echo html_select("driver", $drivers, DRIVER); ?>', "<input type='hidden' name='driver' value='" . ($driver == "mysql" ? "server" : $driver) . "'>" . reset($drivers), $file);
4b9d451d »
2010-05-28 SQLite version supports two systems
346 }
e678e467 »
2010-05-21 Remove unsupported features in single driver version
347 }
12d2c6db » jakubvrana
2009-10-06 Build Adminer and Editor together
348 $file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file);
5d257861 »
2012-09-02 Compress translations
349 $file = preg_replace_callback('~\\b(include|require) "([^"]*\\$LANG.inc.php)";~', 'put_file_lang', $file);
415f500f »
2012-09-06 Don't use \r\n in compiled strings
350 $file = str_replace("\r", "", $file);
12d2c6db » jakubvrana
2009-10-06 Build Adminer and Editor together
351 if ($_SESSION["lang"]) {
352 // single language version
353 $file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file);
354 $file = str_replace("<?php switch_lang(); ?>\n", "", $file);
355 $file = str_replace('<?php echo $LANG; ?>', $_SESSION["lang"], $file);
356 }
357 $file = str_replace('<script type="text/javascript" src="static/editing.js"></script>' . "\n", "", $file);
dd86e189 »
2012-09-06 Simplify compile_file()
358 $file = preg_replace_callback("~compile_file\\('([^']+)'(?:, '([^']*)')?\\)~", 'compile_file', $file); // integrate static files
1be289e8 »
2011-02-09 Optimize compiling files
359 $replace = 'h(preg_replace("~\\\\\\\\?.*~", "", ME)) . "?file=\\1&amp;version=' . $VERSION;
4815c7d0 »
2012-04-15 Don't use AJAX links and forms
360 $file = preg_replace('~\\.\\./adminer/static/(default\\.css|functions\\.js|favicon\\.ico)~', '<?php echo ' . $replace . '"; ?>', $file);
12d2c6db » jakubvrana
2009-10-06 Build Adminer and Editor together
361 $file = preg_replace('~\\.\\./adminer/static/([^\'"]*)~', '" . ' . $replace, $file);
362 $file = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $file);
363 $file = php_shrink($file);
c02bd441 » jakubvrana
2009-07-20 Use $filename
364
e6726941 »
2010-05-07 Rename $driver to $jush
365 $filename = $project . (preg_match('~-dev$~', $VERSION) ? "" : "-$VERSION") . ($driver ? "-$driver" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php";
12d2c6db » jakubvrana
2009-10-06 Build Adminer and Editor together
366 fwrite(fopen($filename, "w"), $file); // file_put_contents() since PHP 5
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
367 echo "$filename created (" . strlen($file) . " B).\n";
12d2c6db » jakubvrana
2009-10-06 Build Adminer and Editor together
368 }
Something went wrong with that request. Please try again.