瀏覽代碼

Devices, Extensions, Gateways, Users: Bypass browser password manager prompt when saving.

reliberate 9 年之前
父節點
當前提交
7c43999b10
共有 2 個文件被更改,包括 34 次插入8 次删除
  1. 15 2
      core/users/signup.php
  2. 19 6
      core/users/usersupdate.php

+ 15 - 2
core/users/signup.php

@@ -279,7 +279,7 @@ if (count($_POST) > 0 && check_str($_POST["persistform"]) != "1") {
 	echo "</script>";
 
 	$tablewidth ='width="100%"';
-	echo "<form method='post' action=''>";
+	echo "<form name='frm' id='frm' method='post' action=''>";
 
 	echo "<table border='0' $tablewidth cellpadding='0' cellspacing='0'>";
 	echo "	<tr>\n";
@@ -350,12 +350,25 @@ if (count($_POST) > 0 && check_str($_POST["persistform"]) != "1") {
 	echo "	</tr>";
 	echo "	<tr>";
 	echo "		<td colspan='2' align='right'>";
-	echo "      	<br><input type='submit' name='submit' class='btn' value='".$text['button-create_account']."'>";
+	echo "      	<br><input type='button' class='btn' value='".$text['button-create_account']."' onclick='submit_form();'>";
 	echo "		</td>";
 	echo "	</tr>";
 	echo "</table>";
 	echo "</form>";
 
+	echo "<script>\n";
+//capture enter key to submit form
+	echo "	$(window).keypress(function(event){\n";
+	echo "		if (event.which == 13) { submit_form(); }\n";
+	echo "	});\n";
+// convert password fields to
+	echo "	function submit_form() {\n";
+	echo "		$('input:password').css('visibility','hidden');\n";
+	echo "		$('input:password').attr({type:'text'});\n";
+	echo "		$('form#frm').submit();\n";
+	echo "	}\n";
+	echo "</script>\n";
+
 //show the footer
 	require_once "resources/footer.php";
 ?>

+ 19 - 6
core/users/usersupdate.php

@@ -368,7 +368,7 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
 
 	//redirect the browser
 		$_SESSION["message"] = $text['message-update'];
-		if ($_REQUEST['submit'] == $text['button-add']) {
+		if ($_REQUEST['action'] == $text['button-add']) {
 			header("Location: usersupdate.php?id=".$user_uuid);
 		}
 		else {
@@ -435,13 +435,13 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
 	echo "	}";
 	echo "</script>";
 
-	echo "<form method='post' action=''>";
-
+	echo "<form name='frm' id='frm' method='post' action=''>\n";
+	echo "<input type='hidden' name='action' id='action' value=''>\n";
 	echo "<table $table_width cellpadding='0' cellspacing='0' border='0'>";
 	echo "<td align='left' width='90%' nowrap><b>".$text['header-user_edit']."</b></td>\n";
 	echo "<td align='right' nowrap>\n";
 	echo "	<input type='button' class='btn' onclick=\"window.location='index.php'\" value='".$text['button-back']."'>";
-	echo "	<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
+	echo "	<input type='button' class='btn' value='".$text['button-save']."' onclick=\"document.getElementById('action').value = '".$text['button-save']."'; submit_form();\">";
 	echo "</td>\n";
 	echo "</tr>\n";
 	echo "<tr>\n";
@@ -570,7 +570,7 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
 			}
 		}
 		echo "</select>";
-		echo "<input type='submit' name='submit' class='btn' value=\"".$text['button-add']."\">\n";
+		echo "<input type='button' class='btn' value=\"".$text['button-add']."\" onclick=\"document.getElementById('action').value = '".$text['button-add']."'; submit_form();\">\n";
 	}
 	unset($sql, $prep_statement, $result);
 
@@ -745,13 +745,26 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
 	echo "			<input type='hidden' name='id' value=\"$user_uuid\">";
 	echo "			<input type='hidden' name='username_old' value=\"$username\">";
 	echo "			<br>";
-	echo "			<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
+	echo "			<input type='button' class='btn' value='".$text['button-save']."' onclick=\"document.getElementById('action').value = '".$text['button-save']."'; submit_form();\">";
 	echo "		</td>";
 	echo "	</tr>";
 	echo "</table>";
 	echo "<br><br>";
 	echo "</form>";
 
+	echo "<script>\n";
+//capture enter key to submit form
+	echo "	$(window).keypress(function(event){\n";
+	echo "		if (event.which == 13) { submit_form(); }\n";
+	echo "	});\n";
+// convert password fields to
+	echo "	function submit_form() {\n";
+	echo "		$('input:password').css('visibility','hidden');\n";
+	echo "		$('input:password').attr({type:'text'});\n";
+	echo "		$('form#frm').submit();\n";
+	echo "	}\n";
+	echo "</script>\n";
+
 //include the footer
 	require_once "resources/footer.php";