<?php
class db
{
    private $host = 'ewg.dedicated.co.za';
    private $user = 'elegaysv_Code2';
    private $pass = 'EWG2Cod!@#';
    private $db = 'elegaysv_unleashed_k9';
    private $conn;

    public function __construct()
    {
        $this->conn = new mysqli($this->host, $this->user, $this->pass, $this->db);
        if ($this->conn->connect_error) {
            die("Connection failed: " . $this->conn->connect_error);
        }
    }

    public function query($sql)
    {
        $result = $this->conn->query($sql);
        if (strpos($sql, 'INSERT') !== false) {
            return $this->conn->insert_id;
        }
        return $result;
    }

    public function user_log($message)
    {

        $this->query("INSERT INTO `user_log` (`user_id`,`log`) VALUES ({$_SESSION['user_id']},'$message')");
    }

    public function disconnect()
    {
        $this->conn->close();
    }
}
?>