Files
CTF/HTB/pollution/target/var.www.collect.app.controllers.login.php
Simon 82b0759f1e init htb
old htb folders
2023-08-29 21:53:22 +02:00

32 lines
722 B
PHP

<?php
use app\models\User;
$user = new User;
if(is_auth())
{
die(redirect('/home'));
}
if(isset($_POST['username']) && !empty($_POST['username']) && isset($_POST['password']) && !empty($_POST['password']))
{
if(!preg_match('/^[A-Za-z0-9]{1,20}$/',$_POST['username'])){
set_flash('User with invalid characters');
die(redirect('/login'));
}
$find = $user->find("username", $_POST['username']);
if($find->username == $_POST['username'] && $find->password == md5($_POST['password']))
{
set_session($find->username, $find->role);
die(redirect('/home'));
}
set_flash('Invalid credentials');
die(redirect('/login'));
}
require '../app/views/login.php';