forked from Rehike/Rehike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.php
82 lines (66 loc) · 2.34 KB
/
boot.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
<?php
require "modules/Rehike/Constants.php";
// Include the Composer and Rehike autoloaders, respectively.
require "vendor/autoload.php";
require "modules/rehikeAutoloader.php";
// Does not properly autoload (this should be fixed)
include "modules/YukisCoffee/GetPropertyAtPath.php";
use Rehike\ControllerV2\Core as ControllerV2;
use Rehike\TemplateManager;
TemplateManager::registerGlobalState($yt);
// Pass resource constants to the templater
TemplateManager::addGlobal('ytConstants', $ytConstants);
TemplateManager::addGlobal('PIXEL', $ytConstants->pixelGif);
// Load general i18n files
use Rehike\i18n;
i18n::setDefaultLanguage("en");
i18n::newNamespace("main/regex")->registerFromFolder("i18n/regex");
i18n::newNamespace("main/misc")->registerFromFolder("i18n/misc");
////////////////////////////////////////////////
// Temporary Controller V1 compatibility code //
$twig = &TemplateManager::exposeTwig();
$template = &TemplateManager::exposeTemplate();
////////////////////////////////////////////////
// Controller V2 init
ControllerV2::registerStateVariable($yt);
// Player init
require "modules/playerCore.php";
$_playerCore = PlayerCore::main();
$yt->playerCore = $_playerCore;
$yt->playerBasepos = $_playerCore->basepos;
// Parse user preferences as stored by the YouTube application.
if (isset($_COOKIE["PREF"])) {
$PREF = explode("&", $_COOKIE["PREF"]);
$yt->PREF = (object) [];
for ($i = 0; $i < count($PREF); $i++) {
$option = explode("=", $PREF[$i]);
$title = $option[0];
$yt->PREF->$title = $option[1];
}
} else {
$yt->PREF = (object) [
"f5" => "20030"
];
}
// Aubrey added this to include timestamp in ytGlobalJsConfig.twig,
// should be moved
$yt -> version = json_decode(file_get_contents($root . "/.version"));
// Import all template functions
foreach (glob('modules/template_functions/*.php') as $file) include $file;
// should be moved
TemplateManager::addFunction('http_response_code', function($code) {
http_response_code($code);
});
// should be moved
TemplateManager::addFilter("base64_encode", function($a){
return base64_encode($a);
});
// Still referenced by some legacy code, otherwise this should
// be removed asap
function findKey($array, string $key) {
for ($i = 0, $j = count($array); $i < $j; $i++) {
if (isset($array[$i]->{$key})) {
return $array[$i]->{$key};
}
}
}