This commit has been accessed 756 times via Git panel.
commit 13d9e3a4a155d2557576797a39eec9c900a1ebd3
tree 3dd941b577db60772a991416a033641db50dfce9
parent afd97fe881d84c9774a3c6f57e14a7431d34235e
author Engels Antonio <engels@majcms.org> 1339160349 +0800
committer Engels Antonio <engels@majcms.org> 1339160349 +0800
Fix modify, toggle, and delete settings for multiple aliases
diff --git a/index.php b/index.php
index 233c1ca..dbac353 100644
--- a/index.php
+++ b/index.php
@@ -717,10 +717,10 @@ if (isset($_SESSION['logged_uid'])) {
}
}
- if (isset($_POST['alias_mod']) and !empty($_POST['alias_mod']) and isset($_POST['alias_to']) and !empty($_POST['alias_to'])) {
+ if (isset($_POST['alias_mod']) and !empty($_POST['alias_mod']) and isset($_POST['alias_old']) and !empty($_POST['alias_old']) and isset($_POST['alias_to']) and !empty($_POST['alias_to'])) {
$alias_mod = trim($_POST['alias_mod']);
-
+ $alias_old = trim($_POST['alias_old']);
$alias_to = trim($_POST['alias_to']);
if (!preg_match("/@/",$alias_to) or preg_match("/@{$_SESSION['logged_uid']}/",$alias_to)) {
@@ -737,7 +737,7 @@ if (isset($_SESSION['logged_uid'])) {
nak("$alias_to does not exist");
}
else {
- $alias_query = mysql_query("update aliases set alias='$alias_to' where id='$alias_mod'");
+ $alias_query = mysql_query("update aliases set alias='$alias_to' where id='$alias_mod' and alias='$alias_old'");
if (!$alias_query) {
nak(strtolower(mysql_error()));
@@ -749,7 +749,7 @@ if (isset($_SESSION['logged_uid'])) {
}
else {
- $alias_query = mysql_query("update aliases set alias='$alias_to' where id='$alias_mod'");
+ $alias_query = mysql_query("update aliases set alias='$alias_to' where id='$alias_mod' and alias='$alias_old'");
if (!$alias_query) {
nak(strtolower(mysql_error()));
@@ -760,20 +760,21 @@ if (isset($_SESSION['logged_uid'])) {
}
}
- if (isset($_POST['alias_set']) and !empty($_POST['alias_set']) and isset($_POST['alias_do']) and !empty($_POST['alias_do'])) {
+ if (isset($_POST['alias_set']) and !empty($_POST['alias_set']) and isset($_POST['alias_usr']) and !empty($_POST['alias_usr']) and isset($_POST['alias_do']) and !empty($_POST['alias_do'])) {
$alias_set = trim($_POST['alias_set']);
+ $alias_usr = trim($_POST['alias_usr']);
$alias_do = trim($_POST['alias_do']);
if ($alias_do == "disable") {
$alias_do = "0";
- $alias_query = mysql_query("update aliases set mode='$alias_do' where id='$alias_set'");
+ $alias_query = mysql_query("update aliases set mode='$alias_do' where id='$alias_set' and alias='$alias_usr'");
if (!$alias_query) {
nak(strtolower(mysql_error()));
}
else {
- ack("$alias_set alias disabled");
+ ack("$alias_set alias of $alias_usr disabled");
}
}
@@ -792,28 +793,30 @@ if (isset($_SESSION['logged_uid'])) {
}
else {
$alias_do = "1";
- $alias_query = mysql_query("update aliases set mode='$alias_do' where id='$alias_set'");
+ $alias_query = mysql_query("update aliases set mode='$alias_do' where id='$alias_set' and alias='$alias_usr'");
if (!$alias_query) {
nak(strtolower(mysql_error()));
}
else {
- ack("$alias_set alias enabled");
+ ack("$alias_set alias of $alias_usr enabled");
}
}
}
}
- if (isset($_POST['alias_del']) and !empty($_POST['alias_del'])) {
+ if (isset($_POST['alias_del']) and !empty($_POST['alias_del']) and isset($_POST['alias_usr']) and !empty($_POST['alias_usr'])) {
$alias_del = trim($_POST['alias_del']);
- $alias_query = mysql_query("delete from aliases where id='$alias_del'");
+ $alias_usr = trim($_POST['alias_usr']);
+
+ $alias_query = mysql_query("delete from aliases where id='$alias_del' and alias='$alias_usr'");
if (!$alias_query) {
nak(strtolower(mysql_error()));
}
else {
- ack("$alias_del deleted");
+ ack("$alias_del alias of $alias_usr deleted");
}
}
}
@@ -1632,7 +1635,7 @@ echo "</tr>";
echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"text\" name=\"alias_add\" autocomplete=\"off\" maxlength=\"255\"></td><td><input class=\"input\" type=\"text\" name=\"alias_to\" autocomplete=\"off\" maxlength=\"128\"></td><td colspan=\"3\"><input class=\"button\" type=\"submit\" value=\"add\"></td></tr>";
echo "</form>";
- $get_aliases = mysql_query("select * from aliases where domain='{$_SESSION['logged_uid']}' order by id");
+ $get_aliases = mysql_query("select * from aliases where domain='{$_SESSION['logged_uid']}' order by id, alias");
while ($aliases_row = mysql_fetch_array($get_aliases)) {
@@ -1646,7 +1649,7 @@ echo "</tr>";
$alias_bg = "#eeeeee";
}
- echo "<tr bgcolor=\"$alias_bg\"><form method=\"post\"><input type=\"hidden\" name=\"alias_mod\" value=\"{$aliases_row[0]}\"><td>{$aliases_row[0]}</td><td><input class=\"input\" type=\"text\" name=\"alias_to\" maxlength=\"255\" autocomplete=\"off\" value=\"{$aliases_row[1]}\"></td><td><input class=\"button\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_set\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_do\" value=\"$alias_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$alias_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_del\" value=\"{$aliases_row[0]}\"><td><input class=\"button\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete the {$aliases_row[0]} alias of {$aliases_row[1]}?')) {return true;} else {return false;}\"></td></form></tr>";
+ echo "<tr bgcolor=\"$alias_bg\"><form method=\"post\"><input type=\"hidden\" name=\"alias_mod\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_old\" value=\"{$aliases_row[1]}\"><td>{$aliases_row[0]}</td><td><input class=\"input\" type=\"text\" name=\"alias_to\" maxlength=\"255\" autocomplete=\"off\" value=\"{$aliases_row[1]}\"></td><td><input class=\"button\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_set\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_do\" value=\"$alias_do\"><input type=\"hidden\" name=\"alias_usr\" value=\"{$aliases_row[1]}\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$alias_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_del\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_usr\" value=\"{$aliases_row[1]}\"><td><input class=\"button\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete the {$aliases_row[0]} alias of {$aliases_row[1]}?')) {return true;} else {return false;}\"></td></form></tr>";
}
echo "</table>";
tree 3dd941b577db60772a991416a033641db50dfce9
parent afd97fe881d84c9774a3c6f57e14a7431d34235e
author Engels Antonio <engels@majcms.org> 1339160349 +0800
committer Engels Antonio <engels@majcms.org> 1339160349 +0800
Fix modify, toggle, and delete settings for multiple aliases
diff --git a/index.php b/index.php
index 233c1ca..dbac353 100644
--- a/index.php
+++ b/index.php
@@ -717,10 +717,10 @@ if (isset($_SESSION['logged_uid'])) {
}
}
- if (isset($_POST['alias_mod']) and !empty($_POST['alias_mod']) and isset($_POST['alias_to']) and !empty($_POST['alias_to'])) {
+ if (isset($_POST['alias_mod']) and !empty($_POST['alias_mod']) and isset($_POST['alias_old']) and !empty($_POST['alias_old']) and isset($_POST['alias_to']) and !empty($_POST['alias_to'])) {
$alias_mod = trim($_POST['alias_mod']);
-
+ $alias_old = trim($_POST['alias_old']);
$alias_to = trim($_POST['alias_to']);
if (!preg_match("/@/",$alias_to) or preg_match("/@{$_SESSION['logged_uid']}/",$alias_to)) {
@@ -737,7 +737,7 @@ if (isset($_SESSION['logged_uid'])) {
nak("$alias_to does not exist");
}
else {
- $alias_query = mysql_query("update aliases set alias='$alias_to' where id='$alias_mod'");
+ $alias_query = mysql_query("update aliases set alias='$alias_to' where id='$alias_mod' and alias='$alias_old'");
if (!$alias_query) {
nak(strtolower(mysql_error()));
@@ -749,7 +749,7 @@ if (isset($_SESSION['logged_uid'])) {
}
else {
- $alias_query = mysql_query("update aliases set alias='$alias_to' where id='$alias_mod'");
+ $alias_query = mysql_query("update aliases set alias='$alias_to' where id='$alias_mod' and alias='$alias_old'");
if (!$alias_query) {
nak(strtolower(mysql_error()));
@@ -760,20 +760,21 @@ if (isset($_SESSION['logged_uid'])) {
}
}
- if (isset($_POST['alias_set']) and !empty($_POST['alias_set']) and isset($_POST['alias_do']) and !empty($_POST['alias_do'])) {
+ if (isset($_POST['alias_set']) and !empty($_POST['alias_set']) and isset($_POST['alias_usr']) and !empty($_POST['alias_usr']) and isset($_POST['alias_do']) and !empty($_POST['alias_do'])) {
$alias_set = trim($_POST['alias_set']);
+ $alias_usr = trim($_POST['alias_usr']);
$alias_do = trim($_POST['alias_do']);
if ($alias_do == "disable") {
$alias_do = "0";
- $alias_query = mysql_query("update aliases set mode='$alias_do' where id='$alias_set'");
+ $alias_query = mysql_query("update aliases set mode='$alias_do' where id='$alias_set' and alias='$alias_usr'");
if (!$alias_query) {
nak(strtolower(mysql_error()));
}
else {
- ack("$alias_set alias disabled");
+ ack("$alias_set alias of $alias_usr disabled");
}
}
@@ -792,28 +793,30 @@ if (isset($_SESSION['logged_uid'])) {
}
else {
$alias_do = "1";
- $alias_query = mysql_query("update aliases set mode='$alias_do' where id='$alias_set'");
+ $alias_query = mysql_query("update aliases set mode='$alias_do' where id='$alias_set' and alias='$alias_usr'");
if (!$alias_query) {
nak(strtolower(mysql_error()));
}
else {
- ack("$alias_set alias enabled");
+ ack("$alias_set alias of $alias_usr enabled");
}
}
}
}
- if (isset($_POST['alias_del']) and !empty($_POST['alias_del'])) {
+ if (isset($_POST['alias_del']) and !empty($_POST['alias_del']) and isset($_POST['alias_usr']) and !empty($_POST['alias_usr'])) {
$alias_del = trim($_POST['alias_del']);
- $alias_query = mysql_query("delete from aliases where id='$alias_del'");
+ $alias_usr = trim($_POST['alias_usr']);
+
+ $alias_query = mysql_query("delete from aliases where id='$alias_del' and alias='$alias_usr'");
if (!$alias_query) {
nak(strtolower(mysql_error()));
}
else {
- ack("$alias_del deleted");
+ ack("$alias_del alias of $alias_usr deleted");
}
}
}
@@ -1632,7 +1635,7 @@ echo "</tr>";
echo "<tr bgcolor=\"#ffffff\"><td><input class=\"input\" type=\"text\" name=\"alias_add\" autocomplete=\"off\" maxlength=\"255\"></td><td><input class=\"input\" type=\"text\" name=\"alias_to\" autocomplete=\"off\" maxlength=\"128\"></td><td colspan=\"3\"><input class=\"button\" type=\"submit\" value=\"add\"></td></tr>";
echo "</form>";
- $get_aliases = mysql_query("select * from aliases where domain='{$_SESSION['logged_uid']}' order by id");
+ $get_aliases = mysql_query("select * from aliases where domain='{$_SESSION['logged_uid']}' order by id, alias");
while ($aliases_row = mysql_fetch_array($get_aliases)) {
@@ -1646,7 +1649,7 @@ echo "</tr>";
$alias_bg = "#eeeeee";
}
- echo "<tr bgcolor=\"$alias_bg\"><form method=\"post\"><input type=\"hidden\" name=\"alias_mod\" value=\"{$aliases_row[0]}\"><td>{$aliases_row[0]}</td><td><input class=\"input\" type=\"text\" name=\"alias_to\" maxlength=\"255\" autocomplete=\"off\" value=\"{$aliases_row[1]}\"></td><td><input class=\"button\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_set\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_do\" value=\"$alias_do\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$alias_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_del\" value=\"{$aliases_row[0]}\"><td><input class=\"button\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete the {$aliases_row[0]} alias of {$aliases_row[1]}?')) {return true;} else {return false;}\"></td></form></tr>";
+ echo "<tr bgcolor=\"$alias_bg\"><form method=\"post\"><input type=\"hidden\" name=\"alias_mod\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_old\" value=\"{$aliases_row[1]}\"><td>{$aliases_row[0]}</td><td><input class=\"input\" type=\"text\" name=\"alias_to\" maxlength=\"255\" autocomplete=\"off\" value=\"{$aliases_row[1]}\"></td><td><input class=\"button\" type=\"submit\" value=\"mod\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_set\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_do\" value=\"$alias_do\"><input type=\"hidden\" name=\"alias_usr\" value=\"{$aliases_row[1]}\"><td align=\"center\" valign=\"middle\" width=\"10\"><input type=\"image\" src=\"images/{$alias_do}.png\"></td></form><form method=\"post\"><input type=\"hidden\" name=\"alias_del\" value=\"{$aliases_row[0]}\"><input type=\"hidden\" name=\"alias_usr\" value=\"{$aliases_row[1]}\"><td><input class=\"button\" type=\"submit\" value=\"del\" onclick=\"if (confirm('Do you really want to delete the {$aliases_row[0]} alias of {$aliases_row[1]}?')) {return true;} else {return false;}\"></td></form></tr>";
}
echo "</table>";