forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinclude_config.php
93 lines (78 loc) · 3.32 KB
/
include_config.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
<?php
ini_set('error_log', $global['systemRootPath'] . 'videos/youphptube.log');
global $global, $config, $advancedCustom, $advancedCustomUser;
$global['mysqli'] = new mysqli($mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, @$mysqlPort);
if($global['mysqli']===false || !empty($global['mysqli']->connect_errno)){
include $global['systemRootPath'] . 'view/include/offlinePage.php';
exit;
}
$now = new DateTime();
$mins = $now->getOffset() / 60;
$sgn = ($mins < 0 ? -1 : 1);
$mins = abs($mins);
$hrs = floor($mins / 60);
$mins -= $hrs * 60;
$offset = sprintf('%+d:%02d', $hrs * $sgn, $mins);
$global['mysqli']->query("SET time_zone='$offset';");
require_once $global['systemRootPath'] . 'objects/mysql_dal.php';
require_once $global['systemRootPath'] . 'objects/configuration.php';
require_once $global['systemRootPath'] . 'objects/security.php';
$config = new Configuration();
// for update config from old versions
if (empty($global['configurationVersion']) || $global['configurationVersion'] < 2) {
Configuration::rewriteConfigFile();
}
$global['dont_show_us_flag'] = false;
// this is for old versions
session_write_close();
// server should keep session data for AT LEAST 1 hour
ini_set('session.gc_maxlifetime', $config->getSession_timeout());
// each client should remember their session id for EXACTLY 1 hour
session_set_cookie_params($config->getSession_timeout());
session_start();
// DDOS protection can be disabled in video/configuration.php
if(!empty($global['enableDDOSprotection'])) ddosProtection();
// set the reffer for youPHPTube
$url1['host'] = "";
if (!empty($_SERVER["HTTP_REFERER"])) {
if((strpos($_SERVER["HTTP_REFERER"], '/video/') !== false || strpos($_SERVER["HTTP_REFERER"], '/v/') !== false) && !empty($_SESSION["LAST_HTTP_REFERER"])){
$global["HTTP_REFERER"] = $_SESSION["LAST_HTTP_REFERER"];
$url1 = parse_url($global["HTTP_REFERER"]);
}else{
$global["HTTP_REFERER"] = $_SERVER["HTTP_REFERER"];
$url1 = parse_url($global["HTTP_REFERER"]);
}
}
if(!isset($_POST['redirectUri'])){
$_POST['redirectUri'] = "";
}
$url2 = parse_url($global['webSiteRootURL']);
if ($url1['host'] !== $url2['host']) {
$global["HTTP_REFERER"] = $global['webSiteRootURL'];
}
$_SESSION["LAST_HTTP_REFERER"] = $global["HTTP_REFERER"];
//var_dump($global["HTTP_REFERER"], $url1);exit;
$output = ob_get_clean();
ob_start("ob_gzhandler");
echo $output;
$_SESSION['lastUpdate'] = time();
$_SESSION['savedQuerys'] = 0;
require_once $global['systemRootPath'] . 'objects/Object.php';
require_once $global['systemRootPath'] . 'locale/function.php';
require_once $global['systemRootPath'] . 'objects/plugin.php';
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/video.php';
require_once $global['systemRootPath'] . 'plugin/YouPHPTubePlugin.php';
allowOrigin();
if (class_exists("Plugin")) {
YouPHPTubePlugin::getStart();
} else {
error_log("Class Plugin Not found: {$_SERVER['REQUEST_URI']}");
}
if (empty($global['bodyClass'])) {
$global['bodyClass'] = "";
}
$global['allowedExtension'] = array('gif', 'jpg', 'mp4', 'webm', 'mp3', 'ogg', 'zip');
$advancedCustom = YouPHPTubePlugin::getObjectData("CustomizeAdvanced");
$advancedCustomUser = YouPHPTubePlugin::getObjectData("CustomizeUser");
$sitemapFile = "{$global['systemRootPath']}sitemap.xml";