| Server IP : 188.114.96.3 / Your IP : 216.73.216.143 Web Server : Apache System : Linux sv058.home.net.pl 6.8.2 husak_dirty_pages_fix #1 SMP PREEMPT_DYNAMIC Tue Apr 2 22:06:51 CEST 2024 x86_64 User : ( 3194769) PHP Version : 8.5.12 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /polana/pracownik/ |
Upload File : |
<?php
declare(strict_types=1);
require_once dirname(__DIR__).'/includes/functions.php';$user=require_staff_portal();if($_SERVER['REQUEST_METHOD']==='POST'){verify_csrf();try{$current=(string)($_POST['current_password']??'');$new=(string)($_POST['new_password']??'');$repeat=(string)($_POST['repeat_password']??'');$stmt=db()->prepare('SELECT password_hash FROM users WHERE id=? LIMIT 1');$stmt->execute([(int)$user['id']]);$hash=(string)$stmt->fetchColumn();if(!password_verify($current,$hash))throw new RuntimeException('Obecne hasło jest nieprawidłowe.');if(strlen($new)<8)throw new RuntimeException('Nowe hasło musi mieć minimum 8 znaków.');if($new!==$repeat)throw new RuntimeException('Nowe hasła nie są identyczne.');db()->prepare('UPDATE users SET password_hash=? WHERE id=?')->execute([password_hash($new,PASSWORD_DEFAULT),(int)$user['id']]);flash('success','Hasło zostało zmienione.');redirect('/pracownik/profil.php');}catch(Throwable $e){flash('error',$e->getMessage());redirect('/pracownik/profil.php');}}render_staff_header('Profil','profile'); ?>
<div class="staff-title"><div><h1>Profil</h1><p><?= e($user['name']?:$user['username']) ?> · <?= e(staff_role_label((string)$user['role'])) ?></p></div></div>
<section class="staff-section"><h2>Zmień hasło</h2><form method="post" class="staff-form"><?= csrf_field() ?><label>Obecne hasło<input type="password" name="current_password" required autocomplete="current-password"></label><label>Nowe hasło<input type="password" name="new_password" required minlength="8" autocomplete="new-password"></label><label>Powtórz nowe hasło<input type="password" name="repeat_password" required minlength="8" autocomplete="new-password"></label><button>Zmień hasło</button></form><a class="staff-logout" href="/admin/logout.php">Wyloguj się</a></section>
<?php render_staff_footer('profile'); ?>