Minu VIKO : $_SESSION[firstname] $_SESSION[lastname]
|
|
Parooli muutmine
EOHTML;
}
function success_page()
{
return <<Parooli muutmine õnnestus. Palun sisene uue parooli abil.
Logi sisse
|
EOHTML;
}
function password_submiting_page()
{
return <<
NB! Paroolivahetuse järel peate uuesti sisse logima kasutades selleks uut parooli.
EOHTML;
}
require("opetaja_auth.php");
include("../include/authenticate.php");
$PASSWORD_PATTERN = "^[a-zA-Z0-9]+$"; // TODO!
$PASSWORD_MIN_LENGTH = 4;
if(isset($_POST['submit']))
{
$errors = Array();
if ( !authenticate_student($_SESSION['username'], $_POST['old_password']) )
{
// Wrong old password
$errors[1]= "Vale parool. Parooli muutmiseks tuleb sisestada kehtiv parool.";
}
if ( $_POST['new_password'] != $_POST['new_password_repeat'] )
{
// Mismatching passwords
$errors[2]= "Paroolid, mis sa sisestasid ei ühti. Palun sisesta sama parool kaks korda.";
}
if ( !ereg($PASSWORD_PATTERN, $_POST['new_password']) )
{
// Password contains illegal characters
$errors[3]= "Parool sisaldab lubamatuid tähemärke";
}
if ( strlen($_POST['new_password']) < $PASSWORD_MIN_LENGTH )
{
// Password is too short
$errors[4]= "Parooli pikkuseks peab olema vähemalt 4 tähemärki";
}
if ( empty($errors) )
{
// If everything is correct, then change the password
save_password( $_SESSION['username'], $_POST['new_password'] );
// logout
session_start();
session_unset();
session_destroy();
// generate success page
include("../include/header_teacher_main.php");
echo head_section();
echo( success_page() );
include("../include/footer2.php");
}
else
{
// generate failure page
include("../include/header_teacher_main.php");
echo head_section();
// List all error messages
echo( "" );
foreach ($errors as $error)
{
echo( "Viga: $error
\n" );
}
echo( "
\n" );
echo( password_submiting_page() );
include("../include/footer2.php");
}
}
else
{
// generate initial page
include("../include/header_teacher_main.php");
echo head_section();
echo( password_submiting_page() );
include("../include/footer2.php");
}
?>
|
Parooli muutmine
Parooli muutmine õnnestus. Palun logi välja ja seejärel sisene uue parooli abil.
Logi välja
|
\n");
if(isset($error1))
{
print("Vale parool. Parooli muutmiseks tuleb sisestada kehtiv parool.
\n");
}
if(isset($error2))
{
print("Paroolid, mis sa sisestasid ei ühti. Palun sisesta sama parool kaks korda.
\n");
}
if(isset($error3) && !isset($error6))
{
print("Parool sisaldab lubamatuid tähemärke
\n");
}
if(isset($error4))
{
print("Parooli pikkuseks peab olema vähemalt 4 tähemärki
\n");
}
print("\n");
}
}
$result = @mysql_query("SELECT * FROM Users WHERE user_id='$_SESSION[user_id]'");
while($row = mysql_fetch_array($result))
{
$username = $row["username"];
}
?>
NB! Paroolivahetuse järel peate uuesti sisse logima kasutades selleks uut parooli.