<?php
require_once dirname(__DIR__) . '/autoload.smart.php';

Class DBConnection {
    public $conn;
    function __construct(){
        $this->conn = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
        if(!$this->conn){
            die("Database Connection Failed. Error: ".$this->conn->error);
        }

    }
    function isMobileDevice(){
        $aMobileUA = array(
            '/iphone/i' => 'iPhone', 
            '/ipod/i' => 'iPod', 
            '/ipad/i' => 'iPad', 
            '/android/i' => 'Android', 
            '/blackberry/i' => 'BlackBerry', 
            '/webos/i' => 'Mobile'
        );
    
        //Return true if Mobile User Agent is detected
        foreach($aMobileUA as $sMobileKey => $sMobileOS){
            if(preg_match($sMobileKey, $_SERVER['HTTP_USER_AGENT'])){
                return true;
            }
        }
        //Otherwise return false..  
        return false;
    }
    function __destruct(){
         $this->conn->close();
    }
}
$_SESSION['id']=$_SESSION['trusto__'.DB_NAME]['user_logged_id'];
$_SESSION['full_name']=$_SESSION['trusto__'.DB_NAME]['user_logged_full_name'];
$_SESSION['Messages']=$_SESSION['trusto__'.DB_NAME]['permissions']['system_permissions']['Messages'];
$mydb = new DBConnection();
$conn = $mydb->conn;