Ejemplo n.º 1
0
?>

<div class="container box">
	<div class="row">
		<div class="col-xs-12">
		<h2>Change your password here:</h2>
<?php 
$equal = true;
$success = false;
if (isset($_POST['user']) && isset($_POST['oldpwd']) && isset($_POST['newpwd']) && isset($_POST['newpwd2'])) {
    $username = $_POST['user'];
    $old = $_POST['oldpwd'];
    $new = $_POST['newpwd'];
    $new2 = $_POST['newpwd2'];
    if ($new == $new2 && $htpasswd->user_check($username, $old)) {
        $htpasswd->user_update($username, $new);
        ?>
			<div class="alert alert-info">Password changed successfully.</div>
		<?php 
    } else {
        ?>
				<div class="alert alert-danger">Could not change password.</div>
				<?php 
    }
}
?>
<div class="result alert alert-info" style="display: none;"></div>

		</div>
	</div>
	<div class=row>
Ejemplo n.º 2
0
			</div>				
				<?php 
    } else {
        $alert_class = "alert-danger";
        $alert_message = "Security problem detected, can not display password change form.";
        include_once 'includes/inline_message.php';
    }
}
if (isset($_POST['user']) && isset($_POST['key']) && isset($_POST['pwd'])) {
    $user = $_POST['user'];
    $key = $_POST['key'];
    $pwd = $_POST['pwd'];
    $meta_models = $htpasswd->get_metadata();
    $meta_model = $meta_models[$user];
    if (isset($meta_model) && $meta_model->mailkey === $key) {
        $htpasswd->user_update($user, $pwd);
        $meta_model->mailkey = random_password(8);
        $htpasswd->meta_update($meta_model);
        $alert_class = "alert-info";
        $alert_message = "Password changed.";
        include_once 'includes/inline_message.php';
    } else {
        $alert_class = "alert-danger";
        $alert_message = "Could not reset password.";
        include_once 'includes/inline_message.php';
    }
}
if ($show_standardform) {
    ?>
			<div class=row>
				<div class="col-xs-12 col-md-4">
Ejemplo n.º 3
0
        $meta_model->mailkey = random_password(8);
    }
    if (!check_username($username) || !check_password_quality($passwd)) {
        ?>
			<div class="alert alert-danger">
			<?php 
        echo "<p>User <em>" . htmlspecialchars($username) . "</em> is invalid!.</p>";
    } else {
        ?>
			<div class="alert alert-info">
			<?php 
        if (!$htpasswd->user_exists($username)) {
            $htpasswd->user_add($username, $passwd);
            echo "<p>User <em>" . htmlspecialchars($username) . "</em> created.</p>";
        } else {
            $htpasswd->user_update($username, $passwd);
            echo "<p>User <em>" . htmlspecialchars($username) . "</em> changed.</p>";
        }
        if ($use_metadata) {
            if (!$htpasswd->meta_exists($username)) {
                $htpasswd->meta_add($meta_model);
            } else {
                $htpasswd->meta_update($meta_model);
            }
        }
    }
    ?>
		</div>
    <?php 
}
?>
Ejemplo n.º 4
0
<?php

include_once '.htpasswd.php';
$user = $_SERVER['PHP_AUTH_USER'];
$newPass = file_get_contents('php://input');
$htpasswd = new htpasswd('[PATH TO .htpasswd]');
if ($htpasswd->user_update($user, $newPass)) {
    echo json_encode("Updated password");
}