修改密码里新增修改昵称

This commit is contained in:
2024-10-11 15:34:04 +08:00
parent 192f2abe25
commit f539323000
2 changed files with 140 additions and 122 deletions

View File

@@ -12,7 +12,9 @@ if(isset($OJ_LANG)){
<title>Set Password</title> <title>Set Password</title>
<hr> <hr>
<center><h3><?php echo $MSG_USER."-".$MSG_SETPASSWORD?></h3></center> <center>
<h3><?php echo $MSG_USER . "-" . $MSG_SETPASSWORD ?></h3>
</center>
<div class='container'> <div class='container'>
@@ -23,11 +25,17 @@ if(isset($_POST['do'])){
$user_id = $_POST['user_id']; $user_id = $_POST['user_id'];
$passwd = $_POST['passwd']; $passwd = $_POST['passwd'];
$nick = $_POST['nick'];
if ($nick != "") {
$sql = "update `users` set `nick`=? where `user_id`=? and user_id not in( select user_id from privilege where rightstr='administrator')";
pdo_query($sql, $nick, $user_id);
$sql = "update solution set nick=? where user_id=?";
pdo_query($sql, $nick, $user_id);
if(false){
$user_id = stripslashes($user_id);
$passwd = stripslashes($passwd);
} }
if ($passwd != "") {
$passwd = pwGen($passwd); $passwd = pwGen($passwd);
$sql = "update `users` set `password`=? where `user_id`=? and user_id not in( select user_id from privilege where rightstr='administrator')"; $sql = "update `users` set `password`=? where `user_id`=? and user_id not in( select user_id from privilege where rightstr='administrator')";
@@ -37,37 +45,48 @@ if(isset($_POST['do'])){
else else
echo "<center><h4 class='text-danger'>There is No such User " . htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8') . "! or User " . htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8') . " is administrator!</h4></center>"; echo "<center><h4 class='text-danger'>There is No such User " . htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8') . "! or User " . htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8') . " is administrator!</h4></center>";
} }
}
?> ?>
<form action=changepass.php method=post class="form-horizontal"> <form action=changepass.php method=post class="form-horizontal">
<div class="form-group"> <div class="form-group">
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_USER_ID ?></label> <label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_USER_ID ?></label>
<?php if (isset($_GET['uid'])) { ?> <?php if (isset($_GET['uid'])) { ?>
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_GET['uid'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div> <div class="col-sm-3"><input name="user_id" class="form-control"
value="<?php echo htmlentities($_GET['uid'], ENT_QUOTES, 'UTF-8'); ?>" type="text" required></div>
<?php } else if (isset($_POST['user_id'])) { ?> <?php } else if (isset($_POST['user_id'])) { ?>
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div> <div class="col-sm-3"><input name="user_id" class="form-control"
value="<?php echo htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8'); ?>" type="text" required>
</div>
<?php } else { ?> <?php } else { ?>
<div class="col-sm-3"><input name="user_id" class="form-control" placeholder="<?php echo $MSG_USER_ID."*"?>" type="text" required ></div> <div class="col-sm-3"><input name="user_id" class="form-control" placeholder="<?php echo $MSG_USER_ID . "*" ?>"
type="text" required></div>
<?php } ?> <?php } ?>
</div> </div>
<div class="form-group">
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_NICK ?></label>
<div class="col-sm-3"><input name="nick" class="form-control" placeholder="<?php echo $MSG_NICK . "*" ?>"
type="text" autocomplete="off"></div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_PASSWORD ?></label> <label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_PASSWORD ?></label>
<div class="col-sm-3"><input name="passwd" class="form-control" placeholder="<?php echo $MSG_PASSWORD."*"?>" type="password" autocomplete="off" required ></div> <div class="col-sm-3"><input name="passwd" class="form-control" placeholder="<?php echo $MSG_PASSWORD . "*" ?>"
type="password" autocomplete="off"></div>
</div> </div>
<div class="form-group"> <div class="form-group">
<?php require_once("../include/set_post_key.php"); ?> <?php require_once("../include/set_post_key.php"); ?>
<div class="col-sm-offset-4 col-sm-2"> <div class="col-sm-offset-4 col-sm-2">
<button name="do" type="hidden" value="do" class="btn btn-default btn-block" ><?php echo $MSG_SAVE?></button> <button name="do" type="hidden" value="do"
class="btn btn-default btn-block"><?php echo $MSG_SAVE ?></button>
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2">
<button name="submit" type="button" onclick='$("input[name=passwd]").attr("type","text");' class="btn btn-default btn-block">Show</button> <button name="submit" type="button" onclick='$("input[name=passwd]").attr("type","text");'
class="btn btn-default btn-block">Show</button>
</div> </div>
</div> </div>
</form> </form>
</div> </div>

View File

@@ -12,7 +12,9 @@ if(isset($OJ_LANG)){
<title>Set Password</title> <title>Set Password</title>
<hr> <hr>
<center><h3><?php echo $MSG_USER."-".$MSG_SETPASSWORD?></h3></center> <center>
<h3><?php echo $MSG_USER . "-" . $MSG_SETPASSWORD ?></h3>
</center>
<div class='container'> <div class='container'>
@@ -25,14 +27,7 @@ if(isset($_POST['do'])){
$passwd = $_POST['passwd']; $passwd = $_POST['passwd'];
$nick = $_POST['nick']; $nick = $_POST['nick'];
if(false){ if ($nick != "") {
$user_id = stripslashes($user_id);
$passwd = stripslashes($passwd);
}
if ($nick!="")
{
$sql = "update `users` set `nick`=? where `user_id`=? and user_id not in( select user_id from privilege where rightstr='administrator')"; $sql = "update `users` set `nick`=? where `user_id`=? and user_id not in( select user_id from privilege where rightstr='administrator')";
pdo_query($sql, $nick, $user_id); pdo_query($sql, $nick, $user_id);
@@ -41,8 +36,7 @@ if ($nick!="")
} }
if ($passwd!="") if ($passwd != "") {
{
$passwd = pwGen($passwd); $passwd = pwGen($passwd);
$sql = "update `users` set `password`=? where `user_id`=? and user_id not in( select user_id from privilege where rightstr='administrator')"; $sql = "update `users` set `password`=? where `user_id`=? and user_id not in( select user_id from privilege where rightstr='administrator')";
@@ -58,36 +52,41 @@ if ($passwd!="")
<div class="form-group"> <div class="form-group">
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_USER_ID ?></label> <label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_USER_ID ?></label>
<?php if (isset($_GET['uid'])) { ?> <?php if (isset($_GET['uid'])) { ?>
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_GET['uid'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div> <div class="col-sm-3"><input name="user_id" class="form-control"
value="<?php echo htmlentities($_GET['uid'], ENT_QUOTES, 'UTF-8'); ?>" type="text" required></div>
<?php } else if (isset($_POST['user_id'])) { ?> <?php } else if (isset($_POST['user_id'])) { ?>
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div> <div class="col-sm-3"><input name="user_id" class="form-control"
value="<?php echo htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8'); ?>" type="text" required>
</div>
<?php } else { ?> <?php } else { ?>
<div class="col-sm-3"><input name="user_id" class="form-control" placeholder="<?php echo $MSG_USER_ID."*"?>" type="text" required ></div> <div class="col-sm-3"><input name="user_id" class="form-control" placeholder="<?php echo $MSG_USER_ID . "*" ?>"
type="text" required></div>
<?php } ?> <?php } ?>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-offset-3 col-sm-3 control-label">昵称</label> <label class="col-sm-offset-3 col-sm-3 control-label">昵称</label>
<div class="col-sm-3"><input name="nick" class="form-control" placeholder="昵称" type="text" autocomplete="off" ></div> <div class="col-sm-3"><input name="nick" class="form-control" placeholder="昵称" type="text"
autocomplete="off"></div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_PASSWORD ?></label> <label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_PASSWORD ?></label>
<div class="col-sm-3"><input name="passwd" class="form-control" placeholder="<?php echo $MSG_PASSWORD?>" type="password" autocomplete="off" ></div> <div class="col-sm-3"><input name="passwd" class="form-control" placeholder="<?php echo $MSG_PASSWORD ?>"
type="password" autocomplete="off"></div>
</div> </div>
<div class="form-group"> <div class="form-group">
<?php require_once("../include/set_post_key.php"); ?> <?php require_once("../include/set_post_key.php"); ?>
<div class="col-sm-offset-4 col-sm-2"> <div class="col-sm-offset-4 col-sm-2">
<button name="do" type="hidden" value="do" class="btn btn-default btn-block" ><?php echo $MSG_SAVE?></button> <button name="do" type="hidden" value="do"
class="btn btn-default btn-block"><?php echo $MSG_SAVE ?></button>
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2">
<button name="submit" type="button" onclick='$("input[name=passwd]").attr("type","text");' class="btn btn-default btn-block">Show</button> <button name="submit" type="button" onclick='$("input[name=passwd]").attr("type","text");'
class="btn btn-default btn-block">Show</button>
</div> </div>
</div> </div>
</form> </form>
</div> </div>