<?php

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


$host = "localhost";
$user = "elisamue_autoacc";
$pass = "11azruRyH";
$db = "elisamue_autoacc";
$readonlyUser = "elisamue_autoacc";
$readonlyPass = "11azruRyH";
/*
 *Recuerda credenciales de 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://autoaccesorios.eli-tpr.com/";
mysqli_query($con,"SET SQL_BIG_SELECTS=1");
mysqli_query($con,"SET time_zone = '-4: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);
  }

}

?>
