diff --git a/install/checkConfiguration.php b/install/checkConfiguration.php index e5fdd4c5b..79e752bcc 100644 --- a/install/checkConfiguration.php +++ b/install/checkConfiguration.php @@ -1,240 +1,240 @@ post = $_POST; if (!file_exists($_POST['systemRootPath'] . "index.php")) { $obj->error = "Your system path to application ({$_POST['systemRootPath']}) is wrong"; echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); $mysqli = @new mysqli($_POST['databaseHost'], $_POST['databaseUser'], $_POST['databasePass'], "", $_POST['databasePort']); /* * This is the "official" OO way to do it, * BUT $connect_error was broken until PHP 5.2.9 and 5.3.0. */ if ($mysqli->connect_error) { $obj->error = ('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error); echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); if ($_POST['createTables'] == 2) { $sql = "CREATE DATABASE IF NOT EXISTS {$_POST['databaseName']}"; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error creating database: " . $mysqli->error; echo json_encode($obj); exit; } } $mysqli->select_db($_POST['databaseName']); error_log("Installation: ".__LINE__); /* $cmd = "mysql -h {$_POST['databaseHost']} -u {$_POST['databaseUser']} -p {$_POST['databasePass']} {$_POST['databaseName']} < {$_POST['systemRootPath']}install/database.sql"; exec("{$cmd} 2>&1", $output, $return_val); if ($return_val !== 0) { $obj->error = "Error on command: {$cmd}"; echo json_encode($obj); exit; } */ error_log("Installation: ".__LINE__); if ($_POST['createTables'] > 0) { error_log("Installation: ".__LINE__); // Temporary variable, used to store current query $templine = ''; $installFile = "{$_POST['systemRootPath']}install/database.sql"; if(!file_exists($installFile)){ $obj->error = "File Not found {$installFile}"; echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); // Read in entire file $lines = file($installFile); if(empty($lines)){ $obj->error = "File is empty {$installFile}"; echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); // Loop through each line $obj->error = ""; foreach ($lines as $line) { // Skip it if it's a comment if (substr($line, 0, 2) == '--' || $line == '') continue; // Add this line to the current segment $templine .= $line; // If it has a semicolon at the end, it's the end of the query if (substr(trim($line), -1, 1) == ';') { // Perform the query //error_log("Installation: ".$templine); if (!$mysqli->query($templine)) { error_log("Installation: SQL ERROR ".$mysqli->error); $obj->error = ('Error performing query \'' . $templine . '\': ' . $mysqli->error . '

'); } // Reset temp variable to empty $templine = ''; } } error_log("Installation: ".__LINE__); } error_log("Installation: ".__LINE__); $sql = "DELETE FROM users WHERE id = 1 "; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error deleting user: " . $mysqli->error; echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); $sql = "INSERT INTO users (id, user, email, password, created, modified, isAdmin) VALUES (1, 'admin', '" . $_POST['contactEmail'] . "', '" . md5($_POST['systemAdminPass']) . "', now(), now(), true)"; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error creating admin user: " . $mysqli->error; echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); $sql = "DELETE FROM categories WHERE id = 1 "; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error deleting category: " . $mysqli->error; echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); $sql = "INSERT INTO categories (id, name, clean_name, description, created, modified) VALUES (1, 'Default', 'default','', now(), now())"; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error creating category: " . $mysqli->error; echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); $sql = "DELETE FROM configurations WHERE id = 1 "; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error deleting configuration: " . $mysqli->error; echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); $encoder = 'https://encoder1.avideo.com/'; if(is_dir("{$_POST['systemRootPath']}Encoder")){ $encoder = "{$_POST['webSiteRootURL']}Encoder/"; } $sql = "INSERT INTO configurations (id, video_resolution, users_id, version, webSiteTitle, language, contactEmail, encoderURL, created, modified) " . " VALUES " . " (1, '858:480', 1,'{$installationVersion}', '{$_POST['webSiteTitle']}', '{$_POST['mainLanguage']}', '{$_POST['contactEmail']}', '{$encoder}', now(), now())"; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error creating configuration: " . $mysqli->error; echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); $sql = "INSERT INTO `plugins` VALUES (NULL, 'a06505bf-3570-4b1f-977a-fd0e5cab205d', 'active', now(), now(), '', 'Gallery', 'Gallery', '1.0');"; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error enabling Gallery Plugin: " . $mysqli->error; echo json_encode($obj); exit; } error_log("Installation: ".__LINE__); $mysqli->close(); if(empty($_POST['salt'])){ $_POST['salt'] = uniqid(); } $content = "error = "Error copying the encoding progress sample files. Check whether the directory {$_POST['systemRootPath']}videos/ exists and the process have permission"; echo json_encode($obj); exit; } */ error_log("Installation: ".__LINE__); $obj->success = true; echo json_encode($obj); error_log("Installation: ".__LINE__); \ No newline at end of file diff --git a/objects/include_config.php b/objects/include_config.php index 57be2471b..42532d007 100644 --- a/objects/include_config.php +++ b/objects/include_config.php @@ -1,187 +1,187 @@ $value2) { if (stripos($_SERVER['HTTP_USER_AGENT'], $value2) !== false) { break 2; } } } die('Bot Found ' . $_SERVER['HTTP_USER_AGENT']); } } } $global['avideoStartMicrotime'] = microtime(true); require_once __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php'; $global['webSiteRootURL'] .= (substr($global['webSiteRootURL'], -1) == '/' ? '' : '/'); $global['systemRootPath'] .= (substr($global['systemRootPath'], -1) == '/' ? '' : '/'); $global['session_name'] = md5($global['systemRootPath']); session_name($global['session_name']); if (empty($global['logfile'])) { $global['logfile'] = $global['systemRootPath'] . 'videos/avideo.log'; } ini_set('error_log', $global['logfile']); global $global, $config, $advancedCustom, $advancedCustomUser; $global['mysqli'] = new mysqli($mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, @$mysqlPort); if ($global['mysqli'] === false || !empty($global['mysqli']->connect_errno)) { error_log("MySQL connect_errno[{$global['mysqli']->connect_errno}] {$global['mysqli']->connect_error}", AVideoLog::$ERROR); include $global['systemRootPath'] . 'view/include/offlinePage.php'; exit; } // if you set it on configuration file it will help you to encode if (!empty($global['mysqli_charset'])) { $global['mysqli']->set_charset($global['mysqli_charset']); } 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 2020-05-11 if (empty($global['webSiteRootPath']) || $global['configurationVersion'] < 3.1) { 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()); //Fix “set SameSite cookie to none” warning if (version_compare(PHP_VERSION, '7.3.0') >= 0) { setcookie('key', 'value', ['samesite' => 'None', 'secure' => true]); } else { header('Set-Cookie: cross-site-cookie=name; SameSite=None; Secure'); setcookie('key', 'value', time() + $config->getSession_timeout(), '/; SameSite=None; Secure'); } session_start(); // DDOS protection can be disabled in video/configuration.php if (!empty($global['enableDDOSprotection'])) { ddosProtection(); } // set the referrer for aVideo $url1['host'] = ''; $global['HTTP_REFERER'] = ''; if (!empty($_SERVER['HTTP_REFERER'])) { if (( strpos($_SERVER['HTTP_REFERER'], '/video/') !== false || strpos($_SERVER['HTTP_REFERER'], '/v/') !== false ) && !empty($_SESSION['LAST_HTTP_REFERER'])) { if (strpos($_SESSION['LAST_HTTP_REFERER'], 'cache/css/') !== false || strpos($_SESSION['LAST_HTTP_REFERER'], 'cache/js/') !== false || strpos($_SESSION['LAST_HTTP_REFERER'], 'cache/img/') !== false) { $_SESSION['LAST_HTTP_REFERER'] = $global['webSiteRootURL']; } $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']); } } //var_dump($global['HTTP_REFERER']);exit; if (!isset($_POST['redirectUri'])) { $_POST['redirectUri'] = ''; } if (!empty($_POST['redirectUri']) && strpos($_POST['redirectUri'], 'logoff.php') !== false) { $_POST['redirectUri'] = ''; } if (!empty($_GET['redirectUri']) && strpos($_GET['redirectUri'], 'logoff.php') !== false) { $_GET['redirectUri'] = ''; } $url2 = parse_url($global['webSiteRootURL']); if (!empty($url1['host']) && !empty($url2['host']) && $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/AVideoPlugin.php'; fixSystemPath(); ObjectYPT::checkSessionCacheBasedOnLastDeleteALLCacheTime(); getDeviceID(); allowOrigin(); $baseName = basename($_SERVER['SCRIPT_FILENAME']); if ($baseName !== 'xsendfile.php' && class_exists('Plugin')) { AVideoPlugin::getStart(); } elseif ($baseName !== 'xsendfile.php') { _error_log("Class Plugin Not found: {$_SERVER['REQUEST_URI']}"); } if (empty($global['bodyClass'])) { $global['bodyClass'] = ''; } $global['allowedExtension'] = array('gif', 'jpg', 'mp4', 'webm', 'mp3', 'm4a', 'ogg', 'zip', 'm3u8'); if (empty($global['avideo_resolutions'])) { $global['avideo_resolutions'] = array(240, 360, 480, 540, 720, 1080, 1440, 2160); } sort($global['avideo_resolutions']); $advancedCustom = AVideoPlugin::getObjectData('CustomizeAdvanced'); if (empty($global['disableTimeFix'])) { /* $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';"); */ ObjectYPT::setTimeZone(); } $avideoLayout = AVideoPlugin::getObjectData('Layout'); $avideoCustomizeUser = $advancedCustomUser = AVideoPlugin::getObjectData('CustomizeUser'); $avideoCustomize = $customizePlugin = AVideoPlugin::getObjectData('Customize'); $avideoPermissions = $permissionsPlugin = AVideoPlugin::getObjectData('Permissions'); $avideoPlayerSkins = AVideoPlugin::getObjectData('PlayerSkins'); if (!empty($_GET['type'])) { $metaDescription = " {$_GET['type']}"; } elseif (!empty($_GET['showOnly'])) { $metaDescription = " {$_GET['showOnly']}"; }