Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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