Thread: [adminer-svn] SF.net SVN: adminer:[1020] trunk/compile.php
Database management in a single PHP file
Brought to you by:
jakubvrana
From: <jak...@us...> - 2009-08-26 12:37:08
|
Revision: 1020 http://adminer.svn.sourceforge.net/adminer/?rev=1020&view=rev Author: jakubvrana Date: 2009-08-26 12:36:59 +0000 (Wed, 26 Aug 2009) Log Message: ----------- Better consecutive echo handling Modified Paths: -------------- trunk/compile.php Modified: trunk/compile.php =================================================================== --- trunk/compile.php 2009-08-26 11:58:35 UTC (rev 1019) +++ trunk/compile.php 2009-08-26 12:36:59 UTC (rev 1020) @@ -103,20 +103,19 @@ if (!is_array($token)) { $token = array(0, $token); } + if ($tokens[$i+2][0] === T_CLOSE_TAG && $tokens[$i+3][0] === T_INLINE_HTML && $tokens[$i+4][0] === T_OPEN_TAG + && strlen(addcslashes($tokens[$i+3][1], "'\\")) < strlen($tokens[$i+3][1]) + 3 + ) { + $tokens[$i+2] = array(T_ECHO, 'echo'); + $tokens[$i+3] = array(T_CONSTANT_ENCAPSED_STRING, "'" . addcslashes($tokens[$i+3][1], "'\\") . "'"); + $tokens[$i+4] = array(0, ';'); + } if ($token[0] == T_COMMENT || $token[0] == T_WHITESPACE || ($token[0] == T_DOC_COMMENT && $doc_comment)) { $space = "\n"; } else { if ($token[0] == T_DOC_COMMENT) { $doc_comment = true; } - if ($token[0] == T_CLOSE_TAG && $tokens[$i+1][0] == T_INLINE_HTML && $tokens[$i+2][0] == T_OPEN_TAG - && strlen(addcslashes($tokens[$i+1][1], "'\\")) < strlen($tokens[$i+1][1]) + 4 - ) { - $tokens[$i] = array(T_ECHO, 'echo'); - $tokens[$i+1] = array(T_CONSTANT_ENCAPSED_STRING, "'" . addcslashes($tokens[$i+1][1], "'\\") . "'"); - $tokens[$i+2] = array(0, ';'); - $token = $tokens[$i]; - } if ($token[0] == T_VAR) { $shortening = false; } elseif (!$shortening) { @@ -126,8 +125,7 @@ } elseif ($token[0] == T_ECHO) { $in_echo = true; } elseif ($token[1] == ';' && $in_echo) { - $in_echo = false; - if ($tokens[$i+1][0] === T_WHITESPACE && $tokens[$i+2][0] === T_ECHO) { + if (in_array($tokens[$i+1][0], array(T_WHITESPACE, T_COMMENT)) && $tokens[$i+2][0] === T_ECHO) { next($tokens); $i++; } @@ -135,6 +133,8 @@ // join two consecutive echos next($tokens); $token[1] = '.'; //! join ''.'' and ""."" + } else { + $in_echo = false; } } elseif ($token[0] === T_VARIABLE && !isset($special_variables[$token[1]])) { $token[1] = '$' . $short_variables[$token[1]]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jak...@us...> - 2009-08-26 14:14:44
|
Revision: 1023 http://adminer.svn.sourceforge.net/adminer/?rev=1023&view=rev Author: jakubvrana Date: 2009-08-26 14:14:38 +0000 (Wed, 26 Aug 2009) Log Message: ----------- No comments without whitespace Modified Paths: -------------- trunk/compile.php Modified: trunk/compile.php =================================================================== --- trunk/compile.php 2009-08-26 13:43:17 UTC (rev 1022) +++ trunk/compile.php 2009-08-26 14:14:38 UTC (rev 1023) @@ -125,7 +125,7 @@ } elseif ($token[0] == T_ECHO) { $in_echo = true; } elseif ($token[1] == ';' && $in_echo) { - if (in_array($tokens[$i+1][0], array(T_WHITESPACE, T_COMMENT)) && $tokens[$i+2][0] === T_ECHO) { + if ($tokens[$i+1][0] === T_WHITESPACE && $tokens[$i+2][0] === T_ECHO) { next($tokens); $i++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jak...@us...> - 2009-08-27 07:28:58
|
Revision: 1025 http://adminer.svn.sourceforge.net/adminer/?rev=1025&view=rev Author: jakubvrana Date: 2009-08-27 07:28:48 +0000 (Thu, 27 Aug 2009) Log Message: ----------- Use comma in consecutive echos Modified Paths: -------------- trunk/compile.php Modified: trunk/compile.php =================================================================== --- trunk/compile.php 2009-08-26 14:27:12 UTC (rev 1024) +++ trunk/compile.php 2009-08-27 07:28:48 UTC (rev 1025) @@ -132,9 +132,13 @@ if ($tokens[$i+1][0] === T_ECHO) { // join two consecutive echos next($tokens); +<<<<<<< HEAD:compile.php $token[1] = '.'; //! join ''.'' and ""."" } else { $in_echo = false; +======= + $token[1] = ','; // '.' would conflict with "a".1+2 and would use more memory //! remove ',' and "," +>>>>>>> Use comma in consecutive echos:compile.php } } elseif ($token[0] === T_VARIABLE && !isset($special_variables[$token[1]])) { $token[1] = '$' . $short_variables[$token[1]]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jak...@us...> - 2009-08-27 07:36:55
|
Revision: 1027 http://adminer.svn.sourceforge.net/adminer/?rev=1027&view=rev Author: jakubvrana Date: 2009-08-27 07:36:41 +0000 (Thu, 27 Aug 2009) Log Message: ----------- Resolve conflict Modified Paths: -------------- trunk/compile.php Modified: trunk/compile.php =================================================================== --- trunk/compile.php 2009-08-27 07:33:29 UTC (rev 1026) +++ trunk/compile.php 2009-08-27 07:36:41 UTC (rev 1027) @@ -132,13 +132,9 @@ if ($tokens[$i+1][0] === T_ECHO) { // join two consecutive echos next($tokens); -<<<<<<< HEAD:compile.php - $token[1] = '.'; //! join ''.'' and ""."" + $token[1] = ','; // '.' would conflict with "a".1+2 and would use more memory //! remove ',' and "," } else { $in_echo = false; -======= - $token[1] = ','; // '.' would conflict with "a".1+2 and would use more memory //! remove ',' and "," ->>>>>>> Use comma in consecutive echos:compile.php } } elseif ($token[0] === T_VARIABLE && !isset($special_variables[$token[1]])) { $token[1] = '$' . $short_variables[$token[1]]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jak...@us...> - 2009-10-02 10:32:37
|
Revision: 1159 http://adminer.svn.sourceforge.net/adminer/?rev=1159&view=rev Author: jakubvrana Date: 2009-10-02 10:32:27 +0000 (Fri, 02 Oct 2009) Log Message: ----------- Separate static files Modified Paths: -------------- trunk/compile.php Modified: trunk/compile.php =================================================================== --- trunk/compile.php 2009-10-01 12:49:37 UTC (rev 1158) +++ trunk/compile.php 2009-10-02 10:32:27 UTC (rev 1159) @@ -187,7 +187,7 @@ $file = str_replace("<?php switch_lang(); ?>\n", "", $file); $file = str_replace('<?php echo $LANG; ?>', $_SESSION["lang"], $file); } -$file = str_replace('<script type="text/javascript" src="editing.js"></script>' . "\n", "", $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 $replace = 'h(preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"])) . "?file=\\1&version=' . $VERSION; $file = preg_replace('~\\.\\./adminer/static/(default\\.css|functions\\.js|favicon\\.ico)~', '<?php echo ' . $replace . '"; ?>', $file); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jak...@us...> - 2009-10-06 11:49:43
|
Revision: 1172 http://adminer.svn.sourceforge.net/adminer/?rev=1172&view=rev Author: jakubvrana Date: 2009-10-06 11:49:31 +0000 (Tue, 06 Oct 2009) Log Message: ----------- Build Adminer and Editor together Modified Paths: -------------- trunk/compile.php Modified: trunk/compile.php =================================================================== --- trunk/compile.php 2009-10-06 11:38:07 UTC (rev 1171) +++ trunk/compile.php 2009-10-06 11:49:31 UTC (rev 1172) @@ -17,8 +17,6 @@ return ($match[1] && $match[4] ? $s : "$match[1]'" . add_apo_slashes($s) . "'$match[4]"); } -$lang_ids = array(); // global variable simplifies usage in a callback function - function lang_ids($match) { global $lang_ids; $lang_id = &$lang_ids[stripslashes($match[1])]; @@ -80,7 +78,7 @@ // based on http://latrine.dgx.cz/jak-zredukovat-php-skripty function php_shrink($input) { $special_variables = array_flip(array('$this', '$GLOBALS', '$_GET', '$_POST', '$_FILES', '$_COOKIE', '$_SESSION', '$_SERVER')); - static $short_variables = array(); + $short_variables = array(); $shortening = true; $tokens = token_get_all($input); @@ -159,43 +157,41 @@ return call_user_func($match[2], file_get_contents(dirname(__FILE__) . "/$project/$match[1]")); } -$project = "adminer"; -if (file_exists(dirname(__FILE__) . "/" . $_SERVER["argv"][1] . "/index.php")) { - $project = $_SERVER["argv"][1]; - array_shift($_SERVER["argv"]); -} unset($_COOKIE["adminer_lang"]); $_SESSION["lang"] = $_SERVER["argv"][1]; // Adminer functions read language from session if (isset($_SESSION["lang"])) { include dirname(__FILE__) . "/adminer/include/lang.inc.php"; if (isset($_SERVER["argv"][2]) || !isset($langs[$_SESSION["lang"]])) { - echo "Usage: php compile.php [adminer] [lang]\nPurpose: Compile adminer[-lang].php from adminer/index.php.\n"; + echo "Usage: php compile.php [lang]\nPurpose: Compile adminer[-lang].php and editor[-lang].php.\n"; exit(1); } include dirname(__FILE__) . "/adminer/lang/$_SESSION[lang].inc.php"; } -$file = file_get_contents(dirname(__FILE__) . "/$project/index.php"); -$file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); -$file = str_replace('include "../adminer/include/coverage.inc.php";', '', $file); -$file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); // bootstrap.inc.php -$file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file); -$file = preg_replace_callback('~\\b(include|require) "([^"]*\\$LANG.inc.php)";~', 'put_file_lang', $file); -if ($_SESSION["lang"]) { - // single language version - $file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file); - $file = str_replace("<?php switch_lang(); ?>\n", "", $file); - $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 -$replace = 'h(preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"])) . "?file=\\1&version=' . $VERSION; -$file = preg_replace('~\\.\\./adminer/static/(default\\.css|functions\\.js|favicon\\.ico)~', '<?php echo ' . $replace . '"; ?>', $file); -$file = preg_replace('~\\.\\./adminer/static/([^\'"]*)~', '" . ' . $replace, $file); -$file = str_replace("../externals/jush/", "https://jush.svn.sourceforge.net/svnroot/jush/trunk/", $file); // mixed-content warning if Adminer runs on HTTPS and external files on HTTP -$file = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $file); -$file = php_shrink($file); +foreach (array("adminer", "editor") as $project) { + $lang_ids = array(); // global variable simplifies usage in a callback function + $file = file_get_contents(dirname(__FILE__) . "/$project/index.php"); + $file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); + $file = str_replace('include "../adminer/include/coverage.inc.php";', '', $file); + $file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); // bootstrap.inc.php + $file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file); + $file = preg_replace_callback('~\\b(include|require) "([^"]*\\$LANG.inc.php)";~', 'put_file_lang', $file); + if ($_SESSION["lang"]) { + // single language version + $file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file); + $file = str_replace("<?php switch_lang(); ?>\n", "", $file); + $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 + $replace = 'h(preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"])) . "?file=\\1&version=' . $VERSION; + $file = preg_replace('~\\.\\./adminer/static/(default\\.css|functions\\.js|favicon\\.ico)~', '<?php echo ' . $replace . '"; ?>', $file); + $file = preg_replace('~\\.\\./adminer/static/([^\'"]*)~', '" . ' . $replace, $file); + $file = str_replace("../externals/jush/", "https://jush.svn.sourceforge.net/svnroot/jush/trunk/", $file); // mixed-content warning if Adminer runs on HTTPS and external files on HTTP + $file = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $file); + $file = php_shrink($file); -$filename = $project . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php"; -fwrite(fopen($filename, "w"), $file); // file_put_contents() since PHP 5 -echo "$filename created.\n"; + $filename = $project . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php"; + fwrite(fopen($filename, "w"), $file); // file_put_contents() since PHP 5 + echo "$filename created.\n"; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jak...@us...> - 2010-04-23 23:53:13
|
Revision: 1492 http://adminer.svn.sourceforge.net/adminer/?rev=1492&view=rev Author: jakubvrana Date: 2010-04-23 23:53:07 +0000 (Fri, 23 Apr 2010) Log Message: ----------- Use version without -dev Modified Paths: -------------- trunk/compile.php Modified: trunk/compile.php =================================================================== --- trunk/compile.php 2010-04-23 23:52:05 UTC (rev 1491) +++ trunk/compile.php 2010-04-23 23:53:07 UTC (rev 1492) @@ -230,7 +230,7 @@ $file = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $file); $file = php_shrink($file); - $filename = $project . ($DRIVER ? "-$DRIVER" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php"; // . "-$VERSION" + $filename = $project . (preg_match('~-dev$~', $VERSION) ? "" : "-$VERSION") . ($DRIVER ? "-$DRIVER" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php"; fwrite(fopen($filename, "w"), $file); // file_put_contents() since PHP 5 echo "$filename created (" . strlen($file) . " B).\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |