<?php
if($_POST['CHANGE'])
{
$OldPass = sha1
(md5($Core->ClearText($_POST['OLDPASS']))); $NewPass = sha1
(md5($Core->ClearText($_POST['NEWPASS'])));
if(!$OldPass || !$NewPass)
{
if($Lang == 'pl')
{
$View->Load("pl_info");
$View->Add("title", "Błąd :: Puste pola");
$View->Add("header", "Błąd! Puste pola!");
$View->Add("info", "Pola formularza nie mogą być puste!");
$View->Add("back", "change_pass.html");
$View->Out();
}
else
{
$View->Load("en_info");
$View->Add("title", "Error :: Empty fields");
$View->Add("header", "Error! Empty fields!");
$View->Add("info", "Form fields can not be empty!");
$View->Add("back", "change_pass.html");
$View->Out();
}
}
else
{
$Query = $MySQL->prepare("SELECT `pass` FROM `users` WHERE `id`=:one");
$Query->bindValue(":one", $_SESSION['id'], PDO::PARAM_INT);
$Query->execute();
$Fetch = $Query->fetch();
if($Fetch['pass'] != $OldPass)
{
if($Lang == 'pl')
{
$View->Load("pl_info");
$View->Add("title", "Błąd :: Błędne hasło");
$View->Add("header", "Błędne hasło!");
$View->Add("info", "Stare hasło nie zgadza się z tym zapisanym w bazie danych!");
$View->Add("back", "change_pass.html");
$View->Out();
}
else
{
$View->Load("en_info");
$View->Add("title", "Error :: Bad pass");
$View->Add("header", "Bad pass!");
$View->Add("info", "Old password does not match the data stored in the database!");
$View->Add("back", "change_pass.html");
$View->Out();
}
}
else
{
$Query = $MySQL->prepare("UPDATE `users` SET `pass`=:one WHERE `id`=:two");
$Query->bindValue(":one", $NewPass, PDO::PARAM_STR);
$Query->bindValue(":two", $_SESSION['id'], PDO::PARAM_INT);
$Query->execute();
$Core->AddLogs('Zmieniono hasło', 'Pass Changed', 0);
if($Lang == 'pl')
{
$View->Load("pl_info");
$View->Add("title", "Hasło zmienione");
$View->Add("header", "Hasło zmienione!");
$View->Add("info", "Hasło zostało pomyślnie zmienione!");
$View->Add("back", "change_pass.html");
$View->Out();
}
else
{
$View->Load("en_info");
$View->Add("title", "Pass change");
$View->Add("header", "Pass change!");
$View->Add("info", "The pass was changed!");
$View->Add("back", "change_pass.html");
$View->Out();
}
}
}
}
else
{
if($Lang == 'pl')
{
$Info = '<form method="post" action="change_pass.html">
<input type="hidden" name="CHANGE" value="true">
<br>Stare hasło<br><br><input type="password" name="OLDPASS"><br>
<br>Nowe hasło<br><br><input type="password" name="NEWPASS"><br>
<br><button type="submit" class="przycisk">Zmień <i class="fa fa-chevron-circle-right"></i> </button>
</form>';
$View->Load("pl_logged_home");
$View->Add('title', 'Zmiana hasła');
$View->Add('header', 'Zmiana hasła');
$View->Add('info', $Info);
$View->Out();
}
else
{
$Info = '<form method="post" action="change_pass.html">
<input type="hidden" name="CHANGE" value="true">
<br>Old pass<br><br><input type="password" name="OLDPASS"><br>
<br>New pass<br><br><input type="password" name="NEWPASS"><br>
<br><button type="submit" class="przycisk">Change <i class="fa fa-chevron-circle-right"></i> </button>
</form>';
$View->Load("en_logged_home");
$View->Add('title', 'Change Pass');
$View->Add('header', 'Change Pass');
$View->Add('info', $Info);
$View->Out();
}
}
?>