-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathboot.php
More file actions
77 lines (67 loc) · 1.91 KB
/
boot.php
File metadata and controls
77 lines (67 loc) · 1.91 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
<?php defined('BLUDIT') or die('BLUDIT');
// Language passed via $_GET['l']
$currentLanguage = 'en';
//
$acceptedLanguages = array('en','es','de','ru');
if (isset($_GET['l'])) {
if (in_array($_GET['l'], $acceptedLanguages)) {
$currentLanguage = $_GET['l'];
}
}
$json = file_get_contents(PATH_ROOT.'languages'.DS.$currentLanguage.'.json');
$languageArray = json_decode($json, true);
// Top bar links
if ($currentLanguage !== "en") {
$_topbar = array(
'documentation'=>'https://docs.bludit.com',
'themes'=>'https://themes.bludit.com/'.$currentLanguage.'/',
'plugins'=>'https://plugins.bludit.com/'.$currentLanguage.'/',
'pro'=>'https://pro.bludit.com/'.$currentLanguage.'/',
'website'=>DOMAIN.'/'.$currentLanguage.'/'
);
} else {
$_topbar = array(
'documentation'=>'https://docs.bludit.com',
'themes'=>'https://themes.bludit.com',
'plugins'=>'https://plugins.bludit.com',
'pro'=>'https://pro.bludit.com',
'website'=>DOMAIN
);
}
// Items and Item passed via $_GET['item']
$_items = false;
$_item = false;
$_whereAmI = 'home';
$_hreflang = array();
$_canonicalURL = '';
if (!empty($_GET['item'])) {
$itemName = sanitize($_GET['item']);
$_item = getItem($itemName);
$_whereAmI = 'item';
if ($_item===false) {
header("HTTP/1.0 404 Not Found");
exit;
} else {
// Canonical URL
$_canonicalURL = $_item['permalink'];
// hreflang
$_hreflang = array('en'=>rtrim(DOMAIN,'/').'/'.ITEM_TYPE.'/'.$itemName);
$tmpLanguages = $acceptedLanguages;
unset($tmpLanguages[0]);
foreach ($tmpLanguages as $lang) {
$_hreflang[$lang] = rtrim(DOMAIN,'/').'/'.$lang.'/'.ITEM_TYPE.'/'.$itemName;
}
}
} else {
$_items = getItems();
$_whereAmI = 'home';
// Canonical URL
$_canonicalURL = $_topbar['website'];
// hreflang
$_hreflang = array('en'=>DOMAIN);
$tmpLanguages = $acceptedLanguages;
unset($tmpLanguages[0]);
foreach ($tmpLanguages as $lang) {
$_hreflang[$lang] = rtrim(DOMAIN,'/').'/'.$lang.'/';
}
}