-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
56 lines (56 loc) · 2.21 KB
/
index.php
File metadata and controls
56 lines (56 loc) · 2.21 KB
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
<?php
//----------------------------------------------------------------------------------------------------
require_once('connection/pdoConnection.php');
//----------------------------------------------------------------------------------------------------
$route = parse_url($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$path = preg_replace('/^\//', '', $route['path']);
$targetPath = !isset( $path ) || empty( $path ) ? "home" : $path;
//----------------------------------------------------------------------------------------------------
$pageContent = "SELECT * FROM content WHERE path=:path";
$pageContent_stmt = $pdoConnection->prepare($pageContent);
$pageContent_stmt->bindValue('path', $targetPath);
$pageContent_stmt->execute();
$pageContent_result = $pageContent_stmt->fetch(PDO::FETCH_ASSOC);
//----------------------------------------------------------------------------------------------------
$validContent = !empty($pageContent_result) ? true : false;
//----------------------------------------------------------------------------------------------------
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>code.education - PHP - Projeto fase 3</title>
<?php require_once('./includes/head.php'); ?>
</head>
<body>
<?php require_once('./includes/header.php'); ?>
<section rule='content'>
<?php if($validContent) :?>
<div class="page-header">
<h1><span class="tweak-width"><?php echo $pageContent_result['title']; ?></span><small>Site simples em PHP</small></h1>
</div>
<div class="image">
<img src="<?php echo $pageContent_result['imagePath']; ?>"/>
</div>
<div class="content">
<span class="title"><?php echo $pageContent_result['title']; ?></span>
<?php
echo $pageContent_result['content'];
if($pageContent_result['path']=='contato') {
require_once('./includes/contact-form.php');
}
?>
</div>
<?php else :?>
<?php
if($targetPath=='resultado-busca'){
require_once('./includes/search.php');
} else {
require_once('./includes/not-found.php');
}
?>
<?php endif; ?>
</section>
<?php require_once('./includes/footer.php'); ?>
</body>
</html>