<commit_before><?php

include_once 'database.php';

abstract class osoba{
    private $ime, $prezime, $id ;
    
    
}



class djelatnik extends osoba{
    private $mysqli, $username, $password;
    
    
     function __construct() {
        $con = new database();
        $this->mysqli = $con->getConnection();
    }
    
    public function chkLogin($user, $pass) {

        $query = $this->mysqli->prepare("SELECT djelatnik_id, ime, prezime, odjel, p_centar FROM djelatnici WHERE username = ? AND lozinka = ?");
        if($query === false){
            trigger_error("Krivi SQL upit: " . $query . ", ERROR: " . $this->mysqli->errno . " " . $this->mysqli->error, E_USER_ERROR);
        }

        $query->bind_param('ss', $user, $pass);

        if ($query->execute()) {
            $query->store_result();
            if ($query->num_rows() == 1) {
                
                $query->bind_result($this->id, $this->ime, $this->prezime, $this->odjel ,$this->p_centar );
                $query->fetch();

                $expire = time() + 60 * 60 * 999999;
                setcookie("user", "$this->ime $this->prezime", time()+86400, '/', '', '', TRUE);
                setcookie("id", $this->id, time()+86400, '/', '', '', TRUE);
                setcookie("odjel", $this->odjel, time()+86400, '/', '', '', TRUE);
                setcookie("centar", $this->p_centar, time()+86400, '/', '', '', TRUE);

                $query->close();
                header('Location: ./primke.php');
                exit();
            } else {
                $query->close();
                die('<script>alert("Nije pronađen korisnik")</script>');
            }
        } else {
            trigger_error(", ERROR: " . $conn->errno . " " . $conn->error, E_USER_ERROR);
            $query->close();
            exit();
        }
    }
    
    
    public function getDjelatnikById($id){<commit_msg>password postavljen na hash sha256 enkripciju, cookie postavljen na 1h<commit_after><?php

include_once 'database.php';

abstract class osoba{
    private $ime, $prezime, $id ;
    
    
}



class djelatnik extends osoba{
    private $mysqli, $username, $password;
    
    
     function __construct() {
        $con = new database();
        $this->mysqli = $con->getConnection();
    }
    
    public function chkLogin($user, $pass) {
        $pass = hash("sha256", $pass);
        
        $query = $this->mysqli->prepare("SELECT djelatnik_id, ime, prezime, odjel, p_centar FROM djelatnici WHERE username = ? AND lozinka = ?");
        if($query === false){
            trigger_error("Krivi SQL upit: " . $query . ", ERROR: " . $this->mysqli->errno . " " . $this->mysqli->error, E_USER_ERROR);
        }

        $query->bind_param('ss', $user, $pass);

        if ($query->execute()) {
            $query->store_result();
            if ($query->num_rows() == 1) {
                
                $query->bind_result($this->id, $this->ime, $this->prezime, $this->odjel ,$this->p_centar );
                $query->fetch();

                $expire = time() + 60 * 60 * 999999;
                setcookie("user", "$this->ime $this->prezime", time()+3600, '/', '', '', TRUE);
                setcookie("id", $this->id, time()+3600, '/', '', '', TRUE);
                setcookie("odjel", $this->odjel, time()+3600, '/', '', '', TRUE);
                setcookie("centar", $this->p_centar, time()+3600, '/', '', '', TRUE);

                $query->close();
                header('Location: ./primke.php');
                exit();
            } else {
                $query->close();
                die('<script>alert("Nije pronađen korisnik")</script>');
            }
        } else {
            trigger_error(", ERROR: " . $conn->errno . " " . $conn->error, E_USER_ERROR);
            $query->close();
            exit();
        }
    }
    
    
    public function getDjelatnikById($id){
{'fraction_non_alphanumeric': 0.1869542886492039, 'fraction_numerical': 0.016692347200821776, 'mean_word_length': 1.8766617429837518, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1303412', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1223, 'n_words': 229}