This repository has been archived by the owner on May 17, 2023. It is now read-only.
forked from oakmac/autocompletejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
84 lines (70 loc) · 1.85 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
<?php
// neutralize magic quotes
// http://blogs.sitepoint.com/2005/03/02/magic-quotes-headaches/
if (get_magic_quotes_gpc()) { $_REQUEST = array_map('stripslashes', $_REQUEST); $_GET = array_map('stripslashes', $_GET); $_POST = array_map('stripslashes', $_POST); $_COOKIE = array_map('stripslashes', $_COOKIE); }
// config
require('php/config.php');
// load AC functions
require('php/AC.php');
// poor man's routing :)
$URI = explode('/', $_SERVER['REQUEST_URI']);
if ($URI[0] === '') {
array_shift($URI);
}
if ($URI[0] === 'autocompletejs') {
array_shift($URI);
}
// chop off any GET parameters from the last entry in the array
$URI[count($URI)-1] = preg_replace('/\?.+$/', '', $URI[count($URI)-1]);
// fill in the URI array with blanks so we don't get any array index errors
for ($i = 0; $i < 10; $i++) {
if (isset($URI[$i]) === false) {
$URI[$i] = '';
}
$URI[$i] = strtolower($URI[$i]);
}
// homepage
if ($URI[0] === '') {
require(APP_PATH.'pages/home.php');
die;
}
// docs
if ($URI[0] === 'docs') {
require(APP_PATH.'pages/docs.php');
die;
}
// examples
if ($URI[0] === 'examples' && $URI[1] === '') {
require(APP_PATH.'pages/examples.php');
die;
}
// single example
if ($URI[0] === 'examples' && $URI[1] !== '') {
$example = AC::getExample($URI[1]);
if ($example !== false) {
require(APP_PATH.'pages/single_example.php');
die;
}
}
// themes
if ($URI[0] === 'themes') {
require(APP_PATH.'pages/themes.php');
die;
}
// download
if ($URI[0] === 'download') {
require(APP_PATH.'pages/download.php');
die;
}
// license
if ($URI[0] === 'license') {
// just redirect them to the GitHub page for now
header('HTTP/1.1 307 Temporary Redirect');
header('Location: https://github.com/oakmac/autocompletejs/blob/master/LICENSE');
die;
}
// anything else 404's
header('HTTP/1.1 404 Not Found');
require(APP_PATH.'pages/404.php');
die;
?>