forked from HomeSwitchHome/HomeSwitchHome-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
40 lines (30 loc) · 1.08 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
session_start();
$bdd = new PDO('mysql:host=localhost;dbname=hsh', 'root', '', [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*----------------------------------------------------------------------------------------------------------------------------*/
function escape($text)
{
return htmlspecialchars($text, ENT_QUOTES);
}
/*----------------------------------------------------------------------------------------------------------------------------*/
function showErrors($messages)
{
$messages = (array) $messages;
//Count != 0 donc ça équivaut à un true pour php
if(count($messages))
{
foreach($messages AS $error)
{
?>
<span class="error"><?= escape($error); ?></span>
<?php
}
}
}
/*----------------------------------------------------------------------------------------------------------------------------*/
function isConnected()
{
return isset($_SESSION["logged"]) && $_SESSION["logged"];
}
?>