56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
include "include/database.php";
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
//
|
|
// Process all actions to change a users password
|
|
//
|
|
$naction = "";
|
|
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
|
|
|
switch (strtolower($naction)) {
|
|
case "update":
|
|
$record_num = intval($_SESSION['UserInfo']['record_num']);
|
|
|
|
if ($_SESSION['UserInfo']['password'] != $_POST['old_password']) {
|
|
break;
|
|
}
|
|
|
|
if (!array_key_exists('password1', $_POST) || strlen($_POST['password1']) == 0) {
|
|
break;
|
|
}
|
|
|
|
if (!array_key_exists('password2', $_POST) || strlen($_POST['password2']) == 0) {
|
|
break;
|
|
}
|
|
|
|
if ($_POST['password1'] != $_POST['password2']) {
|
|
break;
|
|
}
|
|
|
|
// Update the password
|
|
$rnum = $_SESSION['UserInfo']['record_num'];
|
|
$password1 = $_POST['password1'];
|
|
$query = "update users set password = '$password1' " .
|
|
"where school_num = $base_school_num " .
|
|
"and record_num = $rnum";
|
|
db_query($query);
|
|
|
|
// $_SESSION['UserInfo']['password'] = $password1;
|
|
|
|
// Validate user accounts that are 'Pending'
|
|
if ($_SESSION['UserInfo']['status'] == 'Pending') {
|
|
$query = "update users set status = 'Active' where record_num = $rnum";
|
|
db_query($query);
|
|
$_SESSION['UserInfo']['status'] = 'Active';
|
|
}
|
|
}
|
|
|
|
?>
|