<?php

   if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS']!=="on")
  {
     $redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
     header("Location:$redirect");
  }


  $host = "108.179.217.11";
  $user = "robalibr_eli-t";
  $pass = "&#TAh]zXevwe";
  $db = "eli-t_demo";

//for security should not be able to write.
$readonlyUser = $user;
$readonlyPass = $pass;
/*
 *Remmember also credentials on DataTable
 *assets/DataTables/config.php
 *
*/
//die("test");

//error_reporting(E_ALL);
$con = mysqli_connect($host,$user,$pass,$db);





// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$root = "https://demo.eli-tpr.com/";
mysqli_query($con,"SET SQL_BIG_SELECTS=1");
mysqli_query($con,"SET time_zone = '+0:00';");
/// Connecting PDO

$dsn = "mysql:host=" . $host . ";dbname=" . $db;
try{
   //PDO Instance
$pdo = new PDO($dsn, $user, $pass);
$pdo->SetAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e){
   die("Error connection pdo!!!");
   echo "Error: " . $e->getMessage();
}

// Include and instantiate the class.
$isAdmin = stripos($_SERVER['SCRIPT_NAME'],"/admin/")===false?false:true;
$folder = $isAdmin?"..":".";
require_once "$folder/assets/Mobile_Detect.php";
$detect = new Mobile_Detect;

function getNewConnection($readonly = false){
  global $host,$user,$pass,$db,$readonlyUser,$readonlyPass;
  if($readonly){
    return mysqli_connect($host,$readonlyUser,$readonlyPass,$db);
  }else{
    return mysqli_connect($host,$user,$pass,$db);
  }

}

?>
