Permalink
Browse files

Save e-mail from to cookie

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1082 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent 1e55d47 commit 319cba4b1192f01bb505352cfd9ffb28fcd9a3a5 jakubvrana committed Sep 9, 2009
Showing with 14 additions and 5 deletions.
  1. +1 −2 adminer/create.inc.php
  2. +9 −0 adminer/include/functions.inc.php
  3. +1 −1 adminer/include/lang.inc.php
  4. +3 −2 editor/include/adminer.inc.php
View
@@ -82,8 +82,7 @@
if (strlen($TABLE)) {
query_redirect("ALTER TABLE " . idf_escape($TABLE) . "$fields\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
} else {
- $path = preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]);
- setcookie("adminer_engine", $_POST["Engine"], gmmktime(0, 0, 0, gmdate("n") + 1), $path);
+ cookie("adminer_engine", $_POST["Engine"]);
query_redirect("CREATE TABLE " . idf_escape($_POST["name"]) . " (" . substr($fields, 0, -1) . "\n) $status", $location, lang('Table has been created.'));
}
}
@@ -154,6 +154,15 @@ function where_link($i, $column, $value) {
return "&where%5B$i%5D%5Bcol%5D=" . urlencode($column) . "&where%5B$i%5D%5Bop%5D=%3D&where%5B$i%5D%5Bval%5D=" . urlencode($value);
}
+/** Set cookie valid for 1 month
+* @param string
+* @param string
+* @return bool
+*/
+function cookie($name, $value) {
+ return setcookie($name, $value, gmmktime(0, 0, 0, gmdate("n") + 1), preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]));
+}
+
/** Send Location header and exit
* @param string
* @param string
@@ -44,7 +44,7 @@ function switch_lang() {
$LANG = "en";
if (isset($langs[$_COOKIE["adminer_lang"]])) {
- setcookie("adminer_lang", $_COOKIE["adminer_lang"], gmmktime(0, 0, 0, gmdate("n") + 1), preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]));
+ cookie("adminer_lang", $_COOKIE["adminer_lang"]);
$LANG = $_COOKIE["adminer_lang"];
} elseif (isset($langs[$_SESSION["lang"]])) {
$LANG = $_SESSION["lang"];
@@ -185,7 +185,7 @@ function selectEmailPrint($emailFields, $columns) {
global $confirm;
if ($emailFields) {
echo '<fieldset><legend><a href="#fieldset-email" onclick="return !toggle(\'fieldset-email\');">' . lang('E-mail') . "</a></legend><div id='fieldset-email'" . ($_POST["email_append"] ? "" : " class='hidden'") . ">\n";
- echo "<p>" . lang('From') . ": <input name='email_from' value='" . h($_POST["email_from"]) . "'>\n";
+ echo "<p>" . lang('From') . ": <input name='email_from' value='" . h($_POST ? $_POST["email_from"] : $_COOKIE["adminer_email"]) . "'>\n";
echo lang('Subject') . ": <input name='email_subject' value='" . h($_POST["email_subject"]) . "'>\n";
echo "<p><textarea name='email_message' rows='15' cols='60'>" . h($_POST["email_message"] . ($_POST["email_append"] ? '{$' . "$_POST[email_addition]}" : "")) . "</textarea><br>\n";
echo "<select name='email_addition'>" . optionlist($columns, $_POST["email_addition"]) . "</select> <input type='submit' name='email_append' value='" . lang('Insert') . "'>\n"; //! JavaScript
@@ -274,7 +274,7 @@ function selectEmailProcess($where, $foreignKeys) {
foreach ($this->rowDescriptions($rows, $foreignKeys) as $row) {
$replace = array();
foreach ($matches[1] as $val) {
- $replace['{$' . "$val}"] = $row[$val];
+ $replace['{$' . "$val}"] = $row[$val]; //! allow literal {$name}
}
$email = $row[$_POST["email_field"]];
if (is_email($email) && mail($email, email_header(strtr($subject, $replace)), strtr($message, $replace),
@@ -285,6 +285,7 @@ function selectEmailProcess($where, $foreignKeys) {
}
}
}
+ cookie("adminer_email", $_POST["email_from"]);
redirect(remove_from_uri(), lang('%d e-mail(s) have been sent.', $sent));
}
return false;

0 comments on commit 319cba4

Please sign in to comment.