try {
$con->setpwd ($user, $newpass);
} catch (Exception $e) {
+ if ($e->getMessage () == anydbConnection::err_query) {
+ error_request ();
+ }
error_server ();
}
setcookies ($user, $newpass);
try {
$con->setpwd ($newuser_name, $newuser_password);
} catch (Exception $e) {
+ if ($e->getMessage () == anydbConnection::err_query) {
+ error_request ();
+ }
error_server ();
}
success_newuser ($newuser_name);
/*
* set password $pwd for user $usrname. If $usrname does not exist, create
- * it
+ * it.
+ * throws an err_query error in case $pwd is null
*/
public function setpwd($usrname, $pwd);
}
public function setpwd ($user_name, $pwd) {
+ if (strlen ($pwd) == 0) {
+ throw new Exception (anydbConnection::err_query);
+ }
$usrname_escaped = mysql_real_escape_string ($user_name);
if ($this->user_exists ($user_name)) {
$query = sprintf ("UPDATE %susers SET pwd='%s' WHERE name like '%s';",
UnconsistentError: "<?php ptrans('Server reply was inconsistent.')?>",
DelSucces: "<?php ptrans('Removal took place correctly.')?>",
UpdateSucces: "<?php ptrans('Save took place correctly.')?>",
+ emptyPasswordError: "<?php ptrans('Password cannot be empty')?>",
userPasswordmatchError: "<?php ptrans('Passwords do not match.')?>",
changeSamePass: "<?php ptrans('New password is the same as old password.')?>",
changePassBadPass: "<?php ptrans('Bad password.')?>",
<link rel="stylesheet" href="./media/install.css" type="text/css" >
<title><?php ptrans ('SYP wizard')?></title>
<script type="text/javascript">
+ var sypStrings = {
+ emptyPasswordError: "<?php ptrans('Password cannot be empty')?>"
+ };
+
function init () {
if (document.getElementById('db_host')) {
document.getElementById('db_host').focus();
document.getElementById('admin_pass').select();
}
}
+
+ function checkpwd () {
+ var pass = document.getElementById('admin_pass').value;
+ if (!pass) {
+ document.getElementById('empty_pass_error').innerHTML = sypStrings.emptyPasswordError;
+ document.getElementById('empty_pass_error').style.display = "block";
+ document.getElementById('admin_pass').focus();
+ return false;
+ }
+ return true;
+ }
</script>
</head>
<body onload="init()">
if ($users_table_exists) {
par_success (trans ('Found user table.'));
} else {
- if (isset($_POST ["admin_pass"])) {
+ $empty_pass = (isset ($_POST ["admin_pass"]) && (strlen ($_POST ["admin_pass"]) == 0));
+ if ($_POST ["admin_pass"]) {
try {
$connection->create_users_table (true);
} catch (Exception $e) {
par_success (trans ('Admin password initialized.'));
} else {
- print ('<form class="center" method="post" action="">
+ print ('<form class="center" method="post" action="" onsubmit="return checkpwd()">
<label for="admin_pass">' . trans ("choose admin password") . '</label>
- <input id="admin_pass" name="admin_pass" type="password">
- <input type="submit">
- </form>');
+ <input id="admin_pass" name="admin_pass" type="password">');
+ if ($empty_pass) {
+ print ('<p class="error" id="empty_pass_error">' . trans('Password cannot be empty') . '</p>');
+ } else {
+ print ('<p class="error" style="display: none" id="empty_pass_error"></p>');
+ }
+ print ('<br><input type="submit"></form>');
leave ();
}
}
"SYP wizard"
=> "",
+ "Password cannot be empty"
+ => "",
+
"exist but is not a directory"
=> "",
"Assistant d'installation de SYP"
,
+ "Password cannot be empty"
+ =>
+ "Le mot de passe ne peut pas ĂȘtre vide"
+ ,
+
"exist but is not a directory"
=>
"existe mais n'est pas un répertoire"
return;
}
+ if (!newpass) {
+ this.commError(SypStrings.emptyPasswordError);
+ $("#pass_new").focus().select();
+ return;
+ }
+
var curpass = $("#pass_current").val();
if (newpass == curpass) {
this.commError(SypStrings.changeSamePass);
return;
}
+ if (!newuser_pass) {
+ this.commError(SypStrings.emptyPasswordError);
+ $("#pass_new").focus().select();
+ return;
+ }
+
this.commError("");
AjaxMgr.add({