mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Fixes
This commit is contained in:
parent
6d653ee4e6
commit
a352497442
25 changed files with 96 additions and 61 deletions
|
@ -12,7 +12,7 @@ if (!User::isAdmin()) {
|
|||
require_once $global['systemRootPath'] . 'videos/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'objects/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'objects/functions.php';
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
$config->setWebSiteTitle($_POST['webSiteTitle']);
|
||||
$imagePath = "videos/userPhoto/";
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ if (!User::isAdmin()) {
|
|||
die('{"error":"' . __("Permission denied") . '"}');
|
||||
}
|
||||
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
$config->setTheme($_POST['theme']);
|
||||
|
||||
echo '{"status":"' . $config->save() . '"}';
|
||||
|
|
|
@ -539,6 +539,7 @@ abstract class ObjectYPT implements ObjectInterface
|
|||
$saved = Cache::_setCache($name, $content);
|
||||
self::logTime($start, __LINE__, $name);
|
||||
if (!empty($saved)) {
|
||||
//_error_log('set cache saved '.$saved);
|
||||
return $saved;
|
||||
}else{
|
||||
_error_log('Error on set cache not saved ');
|
||||
|
@ -653,6 +654,7 @@ abstract class ObjectYPT implements ObjectInterface
|
|||
|
||||
if (class_exists('Cache')) {
|
||||
$cache = Cache::getCache($name, $lifetime, $ignoreMetadata);
|
||||
//var_dump($name, $lifetime, $ignoreMetadata);
|
||||
if (!empty($cache)) {
|
||||
self::setLastUsedCacheMode("Cache::getCache($name, $lifetime, $ignoreMetadata)");
|
||||
return $cache;
|
||||
|
@ -1134,7 +1136,7 @@ class VideoCacheHandler extends CacheHandler {
|
|||
|
||||
}
|
||||
if (empty($filename)) {
|
||||
var_dump($filename , $id, debug_backtrace());
|
||||
//var_dump($filename , $id, debug_backtrace());
|
||||
die('Filename not found');
|
||||
}
|
||||
return $filename;
|
||||
|
|
|
@ -11,7 +11,9 @@ includeConfigLog(__LINE__, basename(__FILE__));
|
|||
require_once $global['systemRootPath'] . 'objects/Object.php';
|
||||
includeConfigLog(__LINE__, basename(__FILE__));
|
||||
|
||||
class Configuration extends ObjectYPT{
|
||||
if(!class_exists('AVideoConf')){
|
||||
|
||||
class AVideoConf extends ObjectYPT{
|
||||
protected $id;
|
||||
protected $video_resolution;
|
||||
protected $webSiteTitle;
|
||||
|
@ -594,3 +596,9 @@ require_once \$global['systemRootPath'].'objects/include_config.php';
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!class_exists('Configuration')){
|
||||
class Configuration extends AVideoConf{}
|
||||
}
|
|
@ -17,7 +17,7 @@ require_once $global['systemRootPath'] . 'objects/functions.php';
|
|||
|
||||
_error_log("save configuration {$_POST['language']}");
|
||||
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
$config->setContactEmail($_POST['contactEmail']);
|
||||
$config->setLanguage($_POST['language']);
|
||||
$config->setWebSiteTitle($_POST['webSiteTitle']);
|
||||
|
|
|
@ -667,7 +667,7 @@ function setSiteSendMessage(\PHPMailer\PHPMailer\PHPMailer &$mail)
|
|||
$_POST["comment"] = '';
|
||||
}
|
||||
require_once $global['systemRootPath'] . 'objects/configuration.php';
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
$mail->CharSet = 'UTF-8';
|
||||
if ($config->getSmtp()) {
|
||||
_error_log("Sending SMTP Email");
|
||||
|
@ -4988,7 +4988,7 @@ function postVariables($url, $array, $httpcodeOnly = true, $timeout = 10)
|
|||
|
||||
function _session_write_close(){
|
||||
if (isSessionStarted()) {
|
||||
//_error_log(json_encode(debug_backtrace()));
|
||||
_error_log(json_encode(debug_backtrace()));
|
||||
@session_write_close();
|
||||
}
|
||||
}
|
||||
|
@ -5010,9 +5010,38 @@ function isSessionStarted() {
|
|||
}
|
||||
}
|
||||
|
||||
function session_start_preload(){
|
||||
global $_session_start_preload, $global;
|
||||
if(!class_exists('AVideoConf')){
|
||||
require $global['systemRootPath'] . 'objects/configuration.php';
|
||||
}
|
||||
if(!isset($_session_start_preload)){
|
||||
$_session_start_preload = 1;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
$config = new AVideoConf();
|
||||
|
||||
// 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');
|
||||
}
|
||||
}
|
||||
|
||||
function _session_start(array $options = [])
|
||||
{
|
||||
try {
|
||||
session_start_preload();
|
||||
if (isset($_GET['PHPSESSID']) && !_empty($_GET['PHPSESSID'])) {
|
||||
$PHPSESSID = $_GET['PHPSESSID'];
|
||||
unset($_GET['PHPSESSID']);
|
||||
|
@ -5038,7 +5067,15 @@ function _session_start(array $options = [])
|
|||
}
|
||||
} elseif (!isSessionStarted()) {
|
||||
//_error_log(json_encode(debug_backtrace()));
|
||||
$start = microtime(true);
|
||||
//_error_log('session_start 1');
|
||||
$session = @session_start($options);
|
||||
//_error_log('session_start 2');
|
||||
$takes = microtime(true) - $start;
|
||||
if($takes > 1){
|
||||
_error_log('session_start takes '.$takes.' seconds to open');
|
||||
_error_log(json_encode(debug_backtrace()));exit;
|
||||
}
|
||||
return $session;
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
|
@ -7475,6 +7512,10 @@ function avideoShutdown()
|
|||
echo '</pre>';
|
||||
}
|
||||
exit;
|
||||
}else{
|
||||
if(class_exists('Cache')){
|
||||
Cache::saveCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7660,8 +7701,8 @@ function _setcookie($cookieName, $value, $expires = 0)
|
|||
if (empty($expires)) {
|
||||
if (empty($config) || !is_object($config)) {
|
||||
require_once $global['systemRootPath'] . 'objects/configuration.php';
|
||||
if (class_exists('Configuration')) {
|
||||
$config = new Configuration();
|
||||
if (class_exists('AVideoConf')) {
|
||||
$config = new AVideoConf();
|
||||
}
|
||||
}
|
||||
if (!empty($config) && is_object($config)) {
|
||||
|
|
|
@ -132,24 +132,6 @@ $global['dont_show_us_flag'] = false;
|
|||
// this is for old versions
|
||||
|
||||
if (empty($doNotStartSessionbaseIncludeConfig)) {
|
||||
$config = new Configuration();
|
||||
//var_dump($config);exit;
|
||||
@_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'])) {
|
||||
|
|
|
@ -152,8 +152,13 @@ class PlayList extends ObjectYPT {
|
|||
}
|
||||
$sql .= self::getSqlFromPost("pl.");
|
||||
//var_dump($sql);
|
||||
$TimeLog1 = "playList getAllFromUser($userId)";
|
||||
$TimeLog1 = "playList getAllFromUser 1($userId)";
|
||||
TimeLogStart($TimeLog1);
|
||||
$cacheName = md5($sql);
|
||||
$rows = self::getCacheGlobal($cacheName, rand(300, 3600));
|
||||
if(!empty($rows)){
|
||||
return object_to_array($rows);
|
||||
}
|
||||
$res = sqlDAL::readSql($sql, $formats, $values, $refreshCacheFromPlaylist);
|
||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||
TimeLogEnd($TimeLog1, __LINE__);
|
||||
|
@ -229,10 +234,9 @@ class PlayList extends ObjectYPT {
|
|||
array_unshift($rows, $watch_later);
|
||||
}
|
||||
TimeLogEnd($TimeLog1, __LINE__);
|
||||
} else {
|
||||
//die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
|
||||
$rows = [];
|
||||
}
|
||||
|
||||
$response = self::setCacheGlobal($cacheName, $rows);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
@ -355,9 +359,9 @@ class PlayList extends ObjectYPT {
|
|||
}
|
||||
|
||||
public static function getAllFromUserVideo($userId, $videos_id, $publicOnly = true, $status = false) {
|
||||
$TimeLog1 = "playList getAllFromUser($userId, $videos_id)";
|
||||
$TimeLog1 = "playList getAllFromUser 2($userId, $videos_id)";
|
||||
TimeLogStart($TimeLog1);
|
||||
$cacheName = "getAllFromUserVideo_{$videos_id}" . DIRECTORY_SEPARATOR . "getAllFromUserVideo($userId, $videos_id)" . intval($publicOnly) . $status;
|
||||
$cacheName = "getAllFromUserVideo_{$videos_id}" . DIRECTORY_SEPARATOR . "getAllFromUserVideo($userId, $videos_id)" . intval($publicOnly) . $status.getRowCount();
|
||||
//var_dump($playlists_id, $sql);exit;
|
||||
$rows = self::getCacheGlobal($cacheName, 0);
|
||||
if (empty($rows)) {
|
||||
|
@ -369,7 +373,7 @@ class PlayList extends ObjectYPT {
|
|||
$rows[$key]['isOnPlaylist'] = in_array($videos_id, $videos);
|
||||
}
|
||||
TimeLogEnd($TimeLog1, __LINE__);
|
||||
self::setCacheGlobal($cacheName, $rows);
|
||||
$response = self::setCacheGlobal($cacheName, $rows);
|
||||
} else {
|
||||
$rows = object_to_array($rows);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ global $global, $config;
|
|||
if (!isset($global['systemRootPath'])) {
|
||||
require_once '../videos/configuration.php';
|
||||
}
|
||||
_session_write_close();
|
||||
//_session_write_close();
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Access-Control-Allow-Headers: Content-Type");
|
||||
header('Content-Type: application/json');
|
||||
|
@ -15,7 +15,7 @@ require_once $global['systemRootPath'] . 'videos/configuration.php';
|
|||
require_once './playlist.php';
|
||||
header('Content-Type: application/json');
|
||||
_error_log('playlistsFromUserVideos getAllFromUser '.$_GET['users_id']);
|
||||
_session_write_close();
|
||||
//_session_write_close();
|
||||
$row = PlayList::getAllFromUser($_GET['users_id'], false);
|
||||
foreach ($row as $key => $value) {
|
||||
foreach ($row[$key]['videos'] as $key2 => $value2) {
|
||||
|
|
|
@ -10,10 +10,8 @@ header('Content-Type: application/json');
|
|||
if (empty($_REQUEST['users_id'])) {
|
||||
forbiddenPage('You need a user');
|
||||
}
|
||||
if (session_status() !== PHP_SESSION_NONE) {
|
||||
_session_write_close();
|
||||
}
|
||||
|
||||
//setRowCount(100);
|
||||
require_once $global['systemRootPath'] . 'videos/configuration.php';
|
||||
require_once './playlist.php';
|
||||
header('Content-Type: application/json');
|
||||
|
|
|
@ -6,7 +6,7 @@ if (!isset($global['systemRootPath'])) {
|
|||
require_once '../videos/configuration.php';
|
||||
}
|
||||
require_once $global['systemRootPath'] . 'objects/captcha.php';
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
$valid = Captcha::validation(@$_POST['captcha']);
|
||||
if(User::isAdmin()){
|
||||
$valid = true;
|
||||
|
|
|
@ -2600,8 +2600,8 @@ if (typeof gtag !== \"function\") {
|
|||
}
|
||||
try {
|
||||
require_once $global['systemRootPath'] . 'objects/configuration.php';
|
||||
if (class_exists('Configuration')) {
|
||||
$config = new Configuration();
|
||||
if (class_exists('AVideoConf')) {
|
||||
$config = new AVideoConf();
|
||||
}
|
||||
$code = urlencode(static::createVerificationCode($users_id));
|
||||
//Create a new PHPMailer instance
|
||||
|
|
|
@ -4,7 +4,7 @@ if (!isset($global['systemRootPath'])) {
|
|||
require_once '../videos/configuration.php';
|
||||
}
|
||||
User::loginFromRequestIfNotLogged();
|
||||
_session_write_close();
|
||||
//_session_write_close();
|
||||
header('Content-Type: application/json');
|
||||
$start = microtime(true);
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ class API extends PluginAbstract
|
|||
if (empty($parameters['playlists_id'])) {
|
||||
//return new ApiObject("Playlist ID is empty", true, $parameters);
|
||||
$_POST['sort']['created'] = 'DESC';
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
$videos = Video::getAllVideos();
|
||||
$playlist = new PlayList($parameters['playlists_id']);
|
||||
$parameters['playlist_name'] = __('Date Added');
|
||||
|
@ -445,7 +445,7 @@ class API extends PluginAbstract
|
|||
global $global;
|
||||
$playlists = AVideoPlugin::loadPlugin("PlayLists");
|
||||
//var_dump($videos);exit;
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
$users_id = User::getId();
|
||||
$list = [];
|
||||
$obj = new stdClass();
|
||||
|
@ -1737,7 +1737,7 @@ class API extends PluginAbstract
|
|||
global $global;
|
||||
require_once $global['systemRootPath'] . 'objects/playlist.php';
|
||||
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
$users_id = User::getId();
|
||||
$list = [];
|
||||
if (!empty($users_id)) {
|
||||
|
|
|
@ -220,7 +220,7 @@ class Cache extends PluginAbstract {
|
|||
$this->end();
|
||||
}
|
||||
|
||||
self::saveCache();
|
||||
//self::saveCache();
|
||||
}
|
||||
|
||||
private function isREQUEST_URIWhitelisted() {
|
||||
|
@ -344,7 +344,7 @@ class Cache extends PluginAbstract {
|
|||
//return CachesInDB::_setCache($name, $value, $metadata['domain'], $metadata['ishttps'], $metadata['user_location'], $metadata['loggedType']);
|
||||
}
|
||||
|
||||
private static function saveCache() {
|
||||
static function saveCache() {
|
||||
global $cache_setCacheToSaveAtTheEnd;
|
||||
if(!empty($cache_setCacheToSaveAtTheEnd)){
|
||||
$metadata = self::getCacheMetaData();
|
||||
|
|
|
@ -240,7 +240,7 @@ class CachesInDB extends ObjectYPT
|
|||
|
||||
// Assuming you have a PDO connection $pdo
|
||||
$result = sqlDAL::writeSql($sql, implode('', $formats), $values);
|
||||
//_error_log("setBulkCache writeSql ".json_encode($result ));
|
||||
_error_log("setBulkCache writeSql total= ".count($placeholders));
|
||||
//var_dump($result, $sql, implode('', $formats), $values);exit;
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ require_once '../../videos/configuration.php';
|
|||
|
||||
ini_set('max_execution_time', 10);
|
||||
set_time_limit(10);
|
||||
_session_write_close();
|
||||
//_session_write_close();
|
||||
$pobj = AVideoPlugin::getDataObjectIfEnabled("Live");
|
||||
if (empty($pobj->server_type->value)) {
|
||||
ini_set('max_execution_time', 180);
|
||||
|
|
|
@ -229,8 +229,8 @@ Best regards,
|
|||
|
||||
if(empty($config) || !is_object($config)){
|
||||
require_once $global['systemRootPath'] . 'objects/configuration.php';
|
||||
if (class_exists('Configuration')) {
|
||||
$config = new Configuration();
|
||||
if (class_exists('AVideoConf')) {
|
||||
$config = new AVideoConf();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
require_once '../../videos/configuration.php';
|
||||
_session_write_close();
|
||||
//_session_write_close();
|
||||
require_once $global['systemRootPath'].'plugin/VideoTags/Objects/Tags.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ class WWBNIndex extends PluginAbstract
|
|||
|
||||
public function getYouPortalUser($email = "")
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
$configuration = new AVideoConf();
|
||||
|
||||
$data = array(
|
||||
"apiName" => "getUser",
|
||||
|
@ -186,7 +186,7 @@ class WWBNIndex extends PluginAbstract
|
|||
|
||||
private function getFeedStatus($host)
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
$configuration = new AVideoConf();
|
||||
|
||||
$data = array(
|
||||
"apiName" => "getFeedStatus",
|
||||
|
|
|
@ -11,7 +11,7 @@ require_once $global['systemRootPath']. "plugin/WWBNIndex/WWBNIndex.php";
|
|||
require_once $global['systemRootPath']. "objects/Channel.php";
|
||||
require_once $global['systemRootPath']. "plugin/LoginControl/pgp/functions.php";
|
||||
|
||||
$configuration = new Configuration();
|
||||
$configuration = new AVideoConf();
|
||||
$wwbnIndex = new WWBNIndex();
|
||||
$wwbnIndexModel = new WWBNIndexModel();
|
||||
$platformID = getPlatformId();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
require_once dirname(__FILE__) . '/../videos/configuration.php';
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
$global['isForbidden'] = true;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
|
|
@ -55,7 +55,7 @@ foreach ($custom as $key => $value) {
|
|||
$theme = getCurrentTheme();
|
||||
|
||||
if (empty($config)) {
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
}
|
||||
TimeLogEnd($timeLogHead, __LINE__);
|
||||
//$content = _ob_get_clean();
|
||||
|
|
|
@ -116,7 +116,7 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
|
|||
TimeLogEnd($tname, __LINE__, $tTolerance);
|
||||
echo getIncludeFileContent($global['systemRootPath'] . 'view/include/navbarMenuAndLogo.php', [], true);
|
||||
TimeLogEnd($tname, __LINE__, $tTolerance);
|
||||
//echo getIncludeFileContent($global['systemRootPath'] . 'view/include/navbarSearch.php', [], true);
|
||||
echo getIncludeFileContent($global['systemRootPath'] . 'view/include/navbarSearch.php', [], true);
|
||||
TimeLogEnd($tname, __LINE__, $tTolerance);
|
||||
?>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
require_once dirname(__FILE__) . '/../videos/configuration.php';
|
||||
$config = new Configuration();
|
||||
$config = new AVideoConf();
|
||||
$global['isForbidden'] = true;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue