-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
98 lines (84 loc) · 2.74 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* Gravity Department - Design Docs
* https://github.com/gravitydepartment/design-docs
*
* @author Brendan Falkowski
* @copyright Gravity Department. All rights reserved.
*/
// ----------------------------------------------
// Error reporting
// Only enabled if domain looks like a local environment.
if (
strstr($_SERVER['HTTP_HOST'], '.dev')
|| strstr($_SERVER['HTTP_HOST'], '.local')
|| strstr($_SERVER['HTTP_HOST'], '.test')
|| strstr($_SERVER['HTTP_HOST'], 'localhost')
) {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
}
// ----------------------------------------------
// App files
// Extend $defaults with $config
require('app/config-defaults.php');
require('config.php');
$config = array_merge($defaults, $config);
require('app/functions.php');
// ----------------------------------------------
// Vendor modules
require('vendor/dipper/Dipper.php');
require('vendor/parsedown/Parsedown.php');
// ----------------------------------------------
// Determine module type
if (isset($_GET['p1'])) {
$p1 = $_GET['p1'];
if (validateModuleRequest($p1)) {
switch ($p1) {
case 'debug':
$template = 'debug';
break;
/*
case 'page':
$template = $_GET['p2'];
break;
*/
case 'patchwork':
$template = 'patchwork';
break;
case 'patterns':
if (!isset($_GET['p2']) && !isset($_GET['p3'])) {
$template = 'pattern-list';
} elseif (!isset($_GET['p2']) || !isset($_GET['p3'])) {
$template = 'not-found';
} else {
$folder = $_GET['p2'];
$pattern = $_GET['p3'];
// Check file request is validly formatted (not directory traversal)
if (validatePatternRequest($folder, $pattern) === false) {
$template = 'not-found';
} else {
// Check file exists
if (validateFileExists($folder, $pattern) === false) {
$template = 'not-found';
} else {
$template = 'pattern-view';
}
}
}
break;
default:
$template = 'not-found';
}
} else {
$template = 'not-found';
}
} else {
$template = 'home';
}
// ----------------------------------------------
// Render page
include('app/partials/header.php');
include('app/templates/' . $template . '.php');
include('app/partials/footer.php');