<?php
defined('_ISVALID') or exit;

class VAuth {
    public static function loginForm() {
        global $smarty;
        return $smarty->fetch('tpl_login.tpl');
    }
    
    public static function registerForm() {
        global $smarty;
        return $smarty->fetch('tpl_register.tpl');
    }
    
    public static function processLogin() {
        $username = VSecurity::postParam('username', 'string');
        $password = VSecurity::postParam('password', 'string');
        
        if ($username && $password) {
            // Basic authentication logic
            global $class_database;
            $sql = "SELECT * FROM db_accountuser WHERE usr_user = ? AND usr_password = ?";
            $user = $class_database->execute($sql, [$username, md5($password)]);
            
            if ($user && count($user) > 0) {
                VSession::setUserSession($user[0]);
                return ['success' => 'Login successful'];
            }
        }
        
        return ['error' => 'Invalid credentials'];
    }
}
?>