Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 class Manager { protected function dbConnect() { $db = new PDO('mysql:host=localhost;dbname=p4;charset=utf8', "root", ""); return $db; } } try { $dbh = new PDO('mysql:host=localhost;dbname=p4;charset=utf8', "root", ""); foreach($dbh->query('SELECT * from admin') as $row) { print_r(''); } $dbh = null; } catch (PDOException $e) { print "Erreur !: " . $e->getMessage() . "<br/>"; die(); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 //controler backen.php require_once('model/ChapterManager.php'); require_once('model/CommentManager.php'); require_once('model/AdminManager.php'); function indexAdmin() { $chapterManager = new ChapterManager(); $chapters = $chapterManager->getChapters(); $chapters2 = $chapterManager->getChapters(); $chapters3 = $chapterManager->getChapters(); require('view/backend/indexAdminView.php'); } function logout() { session_unset(); header('Location: index.php'); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 <?php //controler/ frontend.php require_once('model/ChapterManager.php'); require_once('model/CommentManager.php'); require_once('model/AdminManager.php'); function index() { $chapterManager = new ChapterManager(); $lastChapters = $chapterManager->getLastChapters(3); $adminManager = new AdminManager(); $login = $adminManager->getLogin(); $passHash = $adminManager->getPassHash(); if (isset($_POST['login']) AND $_POST['login'] === $login AND isset($_POST['pwd']) AND password_verify($_POST['pwd'], $passHash)) { $_SESSION['login'] = $_POST['login']; $_SESSION['pwd'] = $_POST['pwd']; header('Location: index.php'); } else { require('view/frontend/indexView.php'); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 //index.php require_once('controler/frontend.php'); require_once('controler/backend.php'); try { if (isset($_SESSION['login']) AND isset($_SESSION['pwd'])) { if (isset($_GET['action'])) { if ($_GET['action'] == 'createChapter') { if (isset($_POST['title']) AND isset($_POST['content']) AND isset($_FILES['img_chapter'])) { addChapter($_POST['title'], $_POST['content'], $_FILES['img_chapter']); } else { createChapter(); } } elseif ($_GET['action'] == 'deleteChapter') { if (isset($_POST['deleteChapter'])) { deleteChapter($_POST['deleteChapter']); } } elseif ($_GET['action'] == 'editChapter') { if (isset($_POST['title']) AND isset($_POST['content'])) { editChapter($_SESSION['idChapter'], $_POST['title'], $_POST['content'], $_FILES['img_chapter']); } else { rewriteChapter($_POST['editChapter']); } } elseif ($_GET['action'] == 'logout') { logout(); } elseif ($_GET['action'] == 'commentAdmin') { if (isset($_POST['commentAdmin'])) { commentAdmin($_POST['commentAdmin']); } else { commentAdmin($_SESSION['idChapterforComment']); } } elseif ($_GET['action'] == 'deleteComment') { removeComment($_POST['deleteComment']); } elseif ($_GET['action'] == 'editComment') { if (isset($_POST['message'])) { editComment($_SESSION['idComment'], $_POST['message']); } else { getComment($_POST['editComment']); } } } else { indexAdmin(); } } elseif (isset($_GET['action'])) { if ($_GET['action'] == 'chapters') { if (isset($_GET['id'])) { chapter($_GET['id']); } else { listChapters(); } } elseif ($_GET['action'] == 'contact') { contact(); } } else { index(); } } catch (Exception $e) { echo 'Exception reçue : ' . $e->getMessage() . ''; }
Partager