<?php

ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(E_ALL);

session_start();

/* Connexion base de données MYSQL / PDO */
$host = "localhost";
$user = "islamopedie_sms";
$password = "P@r@dis456386";
$dbname = "islamopedie_sms";
$upload_path = "";
$repertoire = "";

try
{
	$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
}
catch(Exception $e)
{
	echo "<center><H1>Le site est temporairement indisponible</H1><p>Veuillez nous excuser pour la gêne occasioner</p><p>Database connecting error.</p></center>";
	exit();
}

function isconnected()
{
	global $pdo;
	
	$SQL = "SELECT COUNT(*) FROM admin WHERE email = '".$_SESSION['email']."' AND password = '".$_SESSION['password']."'";
	$reponse = $pdo->query($SQL);
	$req = $reponse->fetch();

	if($req[0] == 0)
	{
		header("Location: index.php");
		exit;
	}
}

function AntiInjectionSQL($value)
{
    $search = array("\\",  "\x00", "\n",  "\r",  "'",  '"', "\x1a");
    $replace = array("\\\\","\\0","\\n", "\\r", "\'", '\"', "\\Z");

    return str_replace($search, $replace, $value);
}

function getParametre($identifiant)
{
	global $pdo;
	
	$SQL = "SELECT * FROM configuration WHERE parametre = '$identifiant'";
	$reponse = $pdo->query($SQL);
	$req = $reponse->fetch();
	
	return $req['valeur'];
}

?>