Allow running of command line scripts from any directory

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@619 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2009-05-29 16:34:55 +00:00
parent 540e2174e2
commit a4ece841c5
2 changed files with 19 additions and 19 deletions

View File

@@ -2,22 +2,22 @@
error_reporting(E_ALL & ~E_NOTICE);
if ($_SERVER["argc"] > 1) {
$_COOKIE["lang"] = $_SERVER["argv"][1];
include "./lang.inc.php";
include dirname(__FILE__) . "/lang.inc.php";
if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["lang"]])) {
echo "Usage: php _lang.php [lang]\nPurpose: Update lang.inc.php from source code messages.\n";
echo "Usage: php _lang.php [lang]\nPurpose: Update lang/*.inc.php from source code messages.\n";
exit(1);
}
}
$messages_all = array();
foreach (glob("*.php") as $filename) {
foreach (glob(dirname(__FILE__) . "/*.php") as $filename) {
$file = file_get_contents($filename);
if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) {
$messages_all += array_combine($matches[1], $matches[2]);
}
}
foreach (($_COOKIE["lang"] ? array("lang/$_COOKIE[lang].inc.php") : glob("lang/*.inc.php")) as $filename) {
foreach (($_COOKIE["lang"] ? array(dirname(__FILE__) . "/lang/$_COOKIE[lang].inc.php") : glob(dirname(__FILE__) . "/lang/*.inc.php")) as $filename) {
$messages = $messages_all;
preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => .*[^,\n]),?~m", file_get_contents($filename), $matches, PREG_SET_ORDER);
$s = "";