mirror of
https://github.com/vrana/adminer.git
synced 2025-08-09 08:06:59 +02:00
Use prefix for cookies
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@731 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -64,7 +64,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
|||||||
query_redirect("ALTER TABLE " . idf_escape($_GET["create"]) . implode(",", $fields) . ",\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
|
query_redirect("ALTER TABLE " . idf_escape($_GET["create"]) . implode(",", $fields) . ",\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
|
||||||
} else {
|
} else {
|
||||||
$path = preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]);
|
$path = preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]);
|
||||||
setcookie("Engine", $_POST["Engine"], strtotime("+1 month"), $path);
|
setcookie("adminer_engine", $_POST["Engine"], strtotime("+1 month"), $path);
|
||||||
query_redirect("CREATE TABLE " . idf_escape($_POST["name"]) . " (" . implode(",", $fields) . "\n) $status", $location, lang('Table has been created.'));
|
query_redirect("CREATE TABLE " . idf_escape($_POST["name"]) . " (" . implode(",", $fields) . "\n) $status", $location, lang('Table has been created.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ if ($_POST) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$row = array(
|
$row = array(
|
||||||
"Engine" => $_COOKIE["Engine"],
|
"Engine" => $_COOKIE["adminer_engine"],
|
||||||
"fields" => array(array("field" => "")),
|
"fields" => array(array("field" => "")),
|
||||||
"partition_names" => array(""),
|
"partition_names" => array(""),
|
||||||
);
|
);
|
||||||
|
@@ -254,6 +254,6 @@ function schema_mouseup(ev) {
|
|||||||
for (var key in table_pos) {
|
for (var key in table_pos) {
|
||||||
s += '_' + key + ':' + Math.round(table_pos[key][0] * 10000) / 10000 + 'x' + Math.round(table_pos[key][1] * 10000) / 10000;
|
s += '_' + key + ':' + Math.round(table_pos[key][0] * 10000) / 10000 + 'x' + Math.round(table_pos[key][1] * 10000) / 10000;
|
||||||
}
|
}
|
||||||
document.cookie = 'schema=' + encodeURIComponent(s.substr(1)) + '; expires=' + date + '; path=' + location.pathname + location.search;
|
document.cookie = 'adminer_schema=' + encodeURIComponent(s.substr(1)) + '; expires=' + date + '; path=' + location.pathname + location.search;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,14 +39,14 @@ function switch_lang() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET["lang"])) {
|
if (isset($_GET["lang"])) {
|
||||||
$_COOKIE["lang"] = $_GET["lang"];
|
$_COOKIE["adminer_lang"] = $_GET["lang"];
|
||||||
$_SESSION["lang"] = $_GET["lang"]; // cookies may be disabled
|
$_SESSION["lang"] = $_GET["lang"]; // cookies may be disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
$LANG = "en";
|
$LANG = "en";
|
||||||
if (isset($langs[$_COOKIE["lang"]])) {
|
if (isset($langs[$_COOKIE["adminer_lang"]])) {
|
||||||
setcookie("lang", $_GET["lang"], strtotime("+1 month"), preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]));
|
setcookie("adminer_lang", $_GET["lang"], strtotime("+1 month"), preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]));
|
||||||
$LANG = $_COOKIE["lang"];
|
$LANG = $_COOKIE["adminer_lang"];
|
||||||
} elseif (isset($langs[$_SESSION["lang"]])) {
|
} elseif (isset($langs[$_SESSION["lang"]])) {
|
||||||
$LANG = $_SESSION["lang"];
|
$LANG = $_SESSION["lang"];
|
||||||
} else {
|
} else {
|
||||||
|
@@ -4,7 +4,7 @@ page_header(lang('Database schema'), "", array(), $_GET["db"]);
|
|||||||
$table_pos = array();
|
$table_pos = array();
|
||||||
$table_pos_js = array();
|
$table_pos_js = array();
|
||||||
// saved in one cookie because there is a limit of 20 cookies per domain
|
// saved in one cookie because there is a limit of 20 cookies per domain
|
||||||
preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~', $_COOKIE["schema"], $matches, PREG_SET_ORDER); //! ':' in table name
|
preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~', $_COOKIE["adminer_schema"], $matches, PREG_SET_ORDER); //! ':' in table name
|
||||||
foreach ($matches as $i => $match) {
|
foreach ($matches as $i => $match) {
|
||||||
$table_pos[$match[1]] = array($match[2], $match[3]);
|
$table_pos[$match[1]] = array($match[2], $match[3]);
|
||||||
$table_pos_js[] = "\n\t'" . addcslashes($match[1], "\r\n'\\") . "': [ $match[2], $match[3] ]";
|
$table_pos_js[] = "\n\t'" . addcslashes($match[1], "\r\n'\\") . "': [ $match[2], $match[3] ]";
|
||||||
|
18
compile.php
18
compile.php
@@ -25,7 +25,7 @@ function lang_ids($match) {
|
|||||||
function put_file($match) {
|
function put_file($match) {
|
||||||
global $lang_ids;
|
global $lang_ids;
|
||||||
if ($match[2] == './lang/$LANG.inc.php') {
|
if ($match[2] == './lang/$LANG.inc.php') {
|
||||||
if ($_COOKIE["lang"]) {
|
if ($_COOKIE["adminer_lang"]) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
$return = "";
|
$return = "";
|
||||||
@@ -53,12 +53,12 @@ function put_file($match) {
|
|||||||
return "switch (\$LANG) {\n$return}\n";
|
return "switch (\$LANG) {\n$return}\n";
|
||||||
}
|
}
|
||||||
$return = file_get_contents(dirname(__FILE__) . "/adminer/$match[2]");
|
$return = file_get_contents(dirname(__FILE__) . "/adminer/$match[2]");
|
||||||
if ($match[2] != "./include/lang.inc.php" || !$_COOKIE["lang"]) {
|
if ($match[2] != "./include/lang.inc.php" || !$_COOKIE["adminer_lang"]) {
|
||||||
$tokens = token_get_all($return); // to find out the last token
|
$tokens = token_get_all($return); // to find out the last token
|
||||||
return "?>\n$return" . (in_array($tokens[count($tokens) - 1][0], array(T_CLOSE_TAG, T_INLINE_HTML), true) ? "<?php" : "");
|
return "?>\n$return" . (in_array($tokens[count($tokens) - 1][0], array(T_CLOSE_TAG, T_INLINE_HTML), true) ? "<?php" : "");
|
||||||
} elseif (preg_match('~\\s*(\\$pos = .*)~', $return, $match2)) {
|
} elseif (preg_match('~\\s*(\\$pos = .*)~', $return, $match2)) {
|
||||||
// single language lang() is used for plural
|
// single language lang() is used for plural
|
||||||
return "function lang(\$translation, \$number) {\n\t" . str_replace('$LANG', "'$_COOKIE[lang]'", $match2[1]) . "\n\treturn sprintf(\$translation[\$pos], \$number);\n}\n";
|
return "function lang(\$translation, \$number) {\n\t" . str_replace('$LANG', "'$_COOKIE[adminer_lang]'", $match2[1]) . "\n\treturn sprintf(\$translation[\$pos], \$number);\n}\n";
|
||||||
} else {
|
} else {
|
||||||
echo "lang() not found\n";
|
echo "lang() not found\n";
|
||||||
}
|
}
|
||||||
@@ -160,24 +160,24 @@ function php_shrink($input) {
|
|||||||
|
|
||||||
error_reporting(E_ALL & ~E_NOTICE);
|
error_reporting(E_ALL & ~E_NOTICE);
|
||||||
if ($_SERVER["argc"] > 1) {
|
if ($_SERVER["argc"] > 1) {
|
||||||
$_COOKIE["lang"] = $_SERVER["argv"][1]; // Adminer functions read language from cookie
|
$_COOKIE["adminer_lang"] = $_SERVER["argv"][1]; // Adminer functions read language from cookie
|
||||||
include dirname(__FILE__) . "/adminer/include/lang.inc.php";
|
include dirname(__FILE__) . "/adminer/include/lang.inc.php";
|
||||||
if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["lang"]])) {
|
if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["adminer_lang"]])) {
|
||||||
echo "Usage: php compile.php [lang]\nPurpose: Compile adminer[-lang].php from index.php.\n";
|
echo "Usage: php compile.php [lang]\nPurpose: Compile adminer[-lang].php from index.php.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
include dirname(__FILE__) . "/adminer/lang/$_COOKIE[lang].inc.php";
|
include dirname(__FILE__) . "/adminer/lang/$_COOKIE[adminer_lang].inc.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = "adminer" . ($_COOKIE["lang"] ? "-$_COOKIE[lang]" : "") . ".php";
|
$filename = "adminer" . ($_COOKIE["adminer_lang"] ? "-$_COOKIE[adminer_lang]" : "") . ".php";
|
||||||
$file = file_get_contents(dirname(__FILE__) . "/adminer/index.php");
|
$file = file_get_contents(dirname(__FILE__) . "/adminer/index.php");
|
||||||
$file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file);
|
$file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file);
|
||||||
$file = preg_replace("~if \\(isset\\(\\\$_SESSION\\[\"coverage.*\n}\n| && !isset\\(\\\$_SESSION\\[\"coverage\"\\]\\)~sU", '', $file);
|
$file = preg_replace("~if \\(isset\\(\\\$_SESSION\\[\"coverage.*\n}\n| && !isset\\(\\\$_SESSION\\[\"coverage\"\\]\\)~sU", '', $file);
|
||||||
if ($_COOKIE["lang"]) {
|
if ($_COOKIE["adminer_lang"]) {
|
||||||
// single language version
|
// single language version
|
||||||
$file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file);
|
$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 switch_lang(); ?>\n", "", $file);
|
||||||
$file = str_replace('<?php echo $LANG; ?>', $_COOKIE["lang"], $file);
|
$file = str_replace('<?php echo $LANG; ?>', $_COOKIE["adminer_lang"], $file);
|
||||||
} else {
|
} else {
|
||||||
$file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file);
|
$file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file);
|
||||||
}
|
}
|
||||||
|
6
lang.php
6
lang.php
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
error_reporting(E_ALL & ~E_NOTICE);
|
error_reporting(E_ALL & ~E_NOTICE);
|
||||||
if ($_SERVER["argc"] > 1) {
|
if ($_SERVER["argc"] > 1) {
|
||||||
$_COOKIE["lang"] = $_SERVER["argv"][1]; // Adminer functions read language from cookie
|
$_COOKIE["adminer_lang"] = $_SERVER["argv"][1]; // Adminer functions read language from cookie
|
||||||
include dirname(__FILE__) . "/adminer/include/lang.inc.php";
|
include dirname(__FILE__) . "/adminer/include/lang.inc.php";
|
||||||
if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["lang"]])) {
|
if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["adminer_lang"]])) {
|
||||||
echo "Usage: php lang.php [lang]\nPurpose: Update adminer/lang/*.inc.php from source code messages.\n";
|
echo "Usage: php lang.php [lang]\nPurpose: Update adminer/lang/*.inc.php from source code messages.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ foreach (array_merge(glob(dirname(__FILE__) . "/adminer/*.php"), glob(dirname(__
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (glob(dirname(__FILE__) . "/adminer/lang/" . ($_COOKIE["lang"] ? $_COOKIE["lang"] : "*") . ".inc.php") as $filename) {
|
foreach (glob(dirname(__FILE__) . "/adminer/lang/" . ($_COOKIE["adminer_lang"] ? $_COOKIE["adminer_lang"] : "*") . ".inc.php") as $filename) {
|
||||||
$messages = $messages_all;
|
$messages = $messages_all;
|
||||||
preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => .*[^,\n]),?~m", file_get_contents($filename), $matches, PREG_SET_ORDER);
|
preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => .*[^,\n]),?~m", file_get_contents($filename), $matches, PREG_SET_ORDER);
|
||||||
$s = "";
|
$s = "";
|
||||||
|
Reference in New Issue
Block a user