-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathHttp.php
More file actions
79 lines (65 loc) · 2.45 KB
/
Http.php
File metadata and controls
79 lines (65 loc) · 2.45 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
declare(strict_types=1);
/**
* Fichier (bootstrap) du contexte HTTP (page web)
*
* Ce fichier doit contenir l'ensemble des directives d'initialisation
* nécessaire au chargement de toute l'application pour une exécution
* d'une page web (script php à destination du web)
*
* Ce fichier est systématiquement à inclure en haut de chaque
* page.
*
* @author Perrick Penet <perrick@noparking.fr>
* @author Olivier Hoareau <olivier@phppro.fr>
* @copyright 2010 Association Française des Utilisateurs de PHP
*
* @category AFUP
* @package AFUP
* @group Bootstraps
*/
// chargement des paramétrages génériques / multi-contextuels de l'application
use Afup\Site\Corporate\Site;
use Smarty\Smarty;
require_once __DIR__ . '/../../../vendor/autoload.php';
require_once __DIR__ . '/_Common.php';
// initialisation de la session / requête
if (ob_get_level() === 0) {
ob_start();
}
// mise à jour des paramétrages PHP en fonction de la configuration
if (getenv('APP_ENV') === 'prod') {
ini_set('error_reporting', (string) (E_ALL ^ E_WARNING ^ E_NOTICE));
ini_set('display_errors', '0');
} else {
ini_set('error_reporting', (string) E_ALL);
ini_set('display_errors', '1');
}
header('Content-type: text/html; charset=UTF-8');
// choix du 'sous-site' en fonction de l'url
$serveur = '';
$url = $_SERVER['REQUEST_URI'];
if (strrpos((string) $url, '?') !== false) {
$position = strrpos((string) $url, '?');
$url = substr((string) $url, 0, $position);
}
$position = strrpos((string) $url, '/');
$url = substr((string) $_SERVER['REQUEST_URI'], 0, $position);
$parties = explode('/', $url);
$sous_site = array_pop($parties);
// initialisation de Smarty, le moteur de template (html)
$smarty = new Smarty();
$smarty->setTemplateDir([
AFUP_CHEMIN_RACINE . 'templates/' . $sous_site . '/',
AFUP_CHEMIN_RACINE . 'templates/commun/',
]);
$smarty->setCompileDir(AFUP_CHEMIN_RACINE . 'cache/templates');
$smarty->compile_id = $sous_site;
$smarty->use_sub_dirs = true;
$smarty->compile_check = Smarty::COMPILECHECK_ON;
$smarty->registerPlugin("modifier","stripslashes", "stripslashes");
$smarty->registerPlugin("modifier","floatval", "floatval");
$smarty->assign('url_base', 'https://' . $_SERVER['HTTP_HOST'] . '/');
$smarty->assign('chemin_template', $serveur . '/templates/' . $sous_site . '/');
$smarty->assign('chemin_javascript', $serveur . '/javascript/');
require_once(__DIR__ . '/commonStart.php');