-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
64 lines (54 loc) · 1.36 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
include_once 'classes/Smarty.class.php';
$smarty = new Smarty();
// Configurações do Smarty
$smarty->template_dir = 'paginas/';
$smarty->config_dir = 'paginas/';
$smarty->compile_dir = 'paginas/cache/';
$smarty->cache_dir = 'paginas/cache/';
// Constantes da página
$smarty->assign('title', '.: Ordem de Serviços :.');
$smarty->assign('base', '//localhost/ordemdeservico/');
if (!empty($_GET['rota']) && substr($_GET['rota'], -1) == '/')
{
$_GET['rota'] = substr($_GET['rota'], 0, -1);
}
if (!empty($_GET['rota']) && $_GET['rota'] == 'login')
{
$smarty->display('login.tpl');
}
else
{
// Verifica se a rota não está vazia
if (!empty($_GET['rota']))
{
// pega a rota e coloca a extensão do ".tpl"
$page = "paginas/{$_GET['rota']}.tpl";
// verifica se o arquivo existe
if (file_exists($page))
{
ob_start();
$smarty->display($page);
$cache = ob_get_contents();
ob_end_clean();
$smarty->assign('content', $cache);
}
else
{
ob_start();
$smarty->display('erro404.tpl');
$cache = ob_get_contents();
ob_end_clean();
$smarty->assign('content', $cache);
}
}
else
{
ob_start();
$smarty->display('home.tpl');
$cache = ob_get_contents();
ob_end_clean();
$smarty->assign('content', $cache);
}
$smarty->display('index.tpl');
}