1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 19:42:38 +02:00
Daniel Neto 2023-03-11 19:35:40 -03:00
parent d50a618c41
commit 12a47cb43e
9 changed files with 132 additions and 137 deletions

View file

@ -11,12 +11,6 @@ if (!isset($global['systemRootPath'])) {
$global['bypassSameDomainCheck'] = 1; $global['bypassSameDomainCheck'] = 1;
inputToRequest(); inputToRequest();
/*
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED);
*/
_error_log("REQUEST: " . json_encode($_REQUEST)); _error_log("REQUEST: " . json_encode($_REQUEST));
_error_log("POST: " . json_encode($_REQUEST)); _error_log("POST: " . json_encode($_REQUEST));
_error_log("GET: " . json_encode($_GET)); _error_log("GET: " . json_encode($_GET));

View file

@ -1,56 +1,54 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
global $global, $config; global $global, $config;
if (!isset($global['systemRootPath'])) { if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/category.php'; require_once $global['systemRootPath'] . 'objects/category.php';
error_reporting(E_ALL & ~E_DEPRECATED); $obj = new stdClass();
$obj->error = true;
$obj = new stdClass(); $obj->msg = true;
$obj->error = true; $obj->categories_id = 0;
$obj->msg = true; $obj->image1 = 0;
$obj->categories_id = 0; $obj->image2 = 0;
$obj->image1 = 0; $obj->usergroups_ids_array = @$_REQUEST['usergroups_ids_array'];
$obj->image2 = 0;
$obj->usergroups_ids_array = @$_REQUEST['usergroups_ids_array']; if (!Category::canCreateCategory()) {
$obj->msg = __("Permission denied");
if (!Category::canCreateCategory()) { die(json_encode($obj));
$obj->msg = __("Permission denied"); }
die(json_encode($obj));
} $objCat = new Category(intval(@$_POST['id']));
$objCat->setName($_POST['name']);
$objCat = new Category(intval(@$_POST['id'])); $objCat->setClean_name($_POST['clean_name']);
$objCat->setName($_POST['name']); $objCat->setDescription($_POST['description']);
$objCat->setClean_name($_POST['clean_name']); $objCat->setIconClass($_POST['iconClass']);
$objCat->setDescription($_POST['description']); //$objCat->setNextVideoOrder($_POST['nextVideoOrder']);
$objCat->setIconClass($_POST['iconClass']); $objCat->setSuggested($_POST['suggested']);
//$objCat->setNextVideoOrder($_POST['nextVideoOrder']); $objCat->setParentId($_POST['parentId']);
$objCat->setSuggested($_POST['suggested']); $objCat->setPrivate($_POST['private']);
$objCat->setParentId($_POST['parentId']); $objCat->setAllow_download($_POST['allow_download']);
$objCat->setPrivate($_POST['private']); $objCat->setOrder($_POST['order']);
$objCat->setAllow_download($_POST['allow_download']); _error_log('CategoryAddnew: Saving '.$_POST['name']);
$objCat->setOrder($_POST['order']); $obj->categories_id = $objCat->save();
_error_log('CategoryAddnew: Saving '.$_POST['name']); //$objCat->setType($_POST['type'],$id);
$obj->categories_id = $objCat->save();
//$objCat->setType($_POST['type'],$id); if (!empty($obj->categories_id)) {
_error_log('CategoryAddnew: '.$obj->categories_id);
if (!empty($obj->categories_id)) { $obj->error = false;
_error_log('CategoryAddnew: '.$obj->categories_id); $path = Category::getCategoryPhotoPath($obj->categories_id);
$obj->error = false; $obj->image1 = saveCroppieImage($path['path'], "image1");
$path = Category::getCategoryPhotoPath($obj->categories_id); $obj->image1P = $path['path'];
$obj->image1 = saveCroppieImage($path['path'], "image1"); _error_log('CategoryAddnew: save image 1 '.$path['path']);
$obj->image1P = $path['path']; $path = Category::getCategoryBackgroundPath($obj->categories_id);
_error_log('CategoryAddnew: save image 1 '.$path['path']); $obj->image2 = saveCroppieImage($path['path'], "image2");
$path = Category::getCategoryBackgroundPath($obj->categories_id); $obj->image2P = $path['path'];
$obj->image2 = saveCroppieImage($path['path'], "image2"); _error_log('CategoryAddnew: save image 2 '.$path['path']);
$obj->image2P = $path['path'];
_error_log('CategoryAddnew: save image 2 '.$path['path']); // save usergroups
_error_log('CategoryAddnew: save usergroups '. json_encode($obj->usergroups_ids_array));
// save usergroups Category::setUsergroups($obj->categories_id, $obj->usergroups_ids_array);
_error_log('CategoryAddnew: save usergroups '. json_encode($obj->usergroups_ids_array)); }
Category::setUsergroups($obj->categories_id, $obj->usergroups_ids_array); die(json_encode($obj));
}
die(json_encode($obj));

View file

@ -10740,3 +10740,13 @@ function getDockerStatsURL()
{ {
return getDockerInternalURL() . "stat"; return getDockerInternalURL() . "stat";
} }
function set_error_reporting() {
if (!empty($global['debug'])) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
}else{
error_reporting(E_ERROR);
ini_set('display_errors', 0);
}
}

View file

@ -59,7 +59,7 @@ try {
} catch (Exception $exc) { } catch (Exception $exc) {
echo $exc->getTraceAsString(); echo $exc->getTraceAsString();
} }
error_reporting(error_reporting() & ~E_DEPRECATED);
$global['webSiteRootURL'] .= (substr($global['webSiteRootURL'], -1) == '/' ? '' : '/'); $global['webSiteRootURL'] .= (substr($global['webSiteRootURL'], -1) == '/' ? '' : '/');
$global['systemRootPath'] .= (substr($global['systemRootPath'], -1) == '/' ? '' : '/'); $global['systemRootPath'] .= (substr($global['systemRootPath'], -1) == '/' ? '' : '/');
$global['session_name'] = md5($global['systemRootPath']); $global['session_name'] = md5($global['systemRootPath']);
@ -180,6 +180,7 @@ require_once $global['systemRootPath'] . 'objects/plugin.php';
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/video.php'; require_once $global['systemRootPath'] . 'objects/video.php';
require_once $global['systemRootPath'] . 'plugin/AVideoPlugin.php'; require_once $global['systemRootPath'] . 'plugin/AVideoPlugin.php';
set_error_reporting();
setSiteLang(); setSiteLang();
adminSecurityCheck(); adminSecurityCheck();

View file

@ -1,67 +1,66 @@
<?php <?php
$config = dirname(__FILE__) . '/../../../videos/configuration.php'; $config = dirname(__FILE__) . '/../../../videos/configuration.php';
require_once $config; require_once $config;
error_reporting(E_ALL & ~E_DEPRECATED);
if (!isCommandLineInterface()) {
if (!isCommandLineInterface()) { return die('Command Line only');
return die('Command Line only'); }
}
$isCDNEnabled = AVideoPlugin::isEnabledByName('CDN');
$isCDNEnabled = AVideoPlugin::isEnabledByName('CDN');
if (empty($isCDNEnabled)) {
if (empty($isCDNEnabled)) { return die('Plugin disabled');
return die('Plugin disabled'); }
} ob_end_flush();
ob_end_flush(); set_time_limit(300);
set_time_limit(300); ini_set('max_execution_time', 300);
ini_set('max_execution_time', 300);
$global['rowCount'] = $global['limitForUnlimitedVideos'] = 999999;
$global['rowCount'] = $global['limitForUnlimitedVideos'] = 999999; $path = getVideosDir();
$path = getVideosDir(); $total = Video::getTotalVideos("", false, true, true, false, false);
$total = Video::getTotalVideos("", false, true, true, false, false); $videos = Video::getAllVideosLight("", false, true, false);
$videos = Video::getAllVideosLight("", false, true, false); $count = 0;
$count = 0;
$countSiteIdEmpty = 0;
$countSiteIdEmpty = 0; $countStatusNotActive = 0;
$countStatusNotActive = 0; $countMoved = 0;
$countMoved = 0;
$sites_id_to_move = [];
$sites_id_to_move = [];
foreach ($videos as $value) {
foreach ($videos as $value) { $count++;
$count++; //echo "{$count}/{$total} Checking {$global['webSiteRootURL']}v/{$value['id']} {$value['title']}" . PHP_EOL;
//echo "{$count}/{$total} Checking {$global['webSiteRootURL']}v/{$value['id']} {$value['title']}" . PHP_EOL; if (empty($value['sites_id'])) {
if (empty($value['sites_id'])) { $countSiteIdEmpty++;
$countSiteIdEmpty++; //echo "sites_id is not empty {$value['sites_id']}" . PHP_EOL;
//echo "sites_id is not empty {$value['sites_id']}" . PHP_EOL; continue;
continue; }
} if ($value['status'] !== Video::$statusActive) {
if ($value['status'] !== Video::$statusActive) { $countStatusNotActive++;
$countStatusNotActive++; //echo "The video status is not active {$value['status']}" . PHP_EOL;
//echo "The video status is not active {$value['status']}" . PHP_EOL; continue;
continue; }
} $countMoved++;
$countMoved++; $sites_id_to_move[] = $value['id'];
$sites_id_to_move[] = $value['id']; echo "{$key}/{$total} added to download {$global['webSiteRootURL']}v/{$value['id']} {$value['title']}" . PHP_EOL;
echo "{$key}/{$total} added to download {$global['webSiteRootURL']}v/{$value['id']} {$value['title']}" . PHP_EOL; }
}
$total = count($sites_id_to_move);
$total = count($sites_id_to_move); foreach ($sites_id_to_move as $key => $value) {
foreach ($sites_id_to_move as $key => $value) { echo "{$key}/{$total} Start download {$value}" . PHP_EOL;
echo "{$key}/{$total} Start download {$value}" . PHP_EOL; $startF = microtime(true);
$startF = microtime(true); //$response = CDNStorage::get($value, 10);
//$response = CDNStorage::get($value, 10); $response = CDNStorage::moveRemoteToLocal($value, false, false);
$response = CDNStorage::moveRemoteToLocal($value, false, false); if (empty($response)) {
if (empty($response)) { echo "{$key}/{$total} ERROR " . PHP_EOL;
echo "{$key}/{$total} ERROR " . PHP_EOL; } else {
} else { $endF = microtime(true) - $startF;
$endF = microtime(true) - $startF; $ETA = ($total - $key + 1) * $endF;
$ETA = ($total - $key + 1) * $endF; $ps = humanFileSize($response['totalBytesTransferred'] / ($endF));
$ps = humanFileSize($response['totalBytesTransferred'] / ($endF)); echo "{$key}/{$total} download done {$value} filesCopied={$response['filesCopied']} totalBytesTransferred=" . humanFileSize($response['totalBytesTransferred']) . " in " . secondsToDuration($endF) . " ETA: " . secondsToDuration($ETA) . " " . $ps . 'ps' . PHP_EOL;
echo "{$key}/{$total} download done {$value} filesCopied={$response['filesCopied']} totalBytesTransferred=" . humanFileSize($response['totalBytesTransferred']) . " in " . secondsToDuration($endF) . " ETA: " . secondsToDuration($ETA) . " " . $ps . 'ps' . PHP_EOL; }
} }
}
echo "SiteIdNotEmpty = $countSiteIdEmpty; StatusNotActive=$countStatusNotActive; Moved=$countMoved;" . PHP_EOL;
echo "SiteIdNotEmpty = $countSiteIdEmpty; StatusNotActive=$countStatusNotActive; Moved=$countMoved;" . PHP_EOL; echo PHP_EOL . " Done! " . PHP_EOL;
echo PHP_EOL . " Done! " . PHP_EOL; die();
die();

View file

@ -2,7 +2,6 @@
$config = dirname(__FILE__) . '/../../../videos/configuration.php'; $config = dirname(__FILE__) . '/../../../videos/configuration.php';
require_once $config; require_once $config;
error_reporting(E_ALL & ~E_DEPRECATED);
if (!isCommandLineInterface()) { if (!isCommandLineInterface()) {
return die('Command Line only'); return die('Command Line only');

View file

@ -22,8 +22,6 @@ if (empty($isCDNEnabled)) {
ob_end_flush(); ob_end_flush();
set_time_limit(0); set_time_limit(0);
ini_set('max_execution_time', 0); ini_set('max_execution_time', 0);
error_reporting(E_ALL & ~E_DEPRECATED);
ini_set('display_errors', '1');
/** /**
* @var mixed[] $global * @var mixed[] $global
*/ */

View file

@ -18,8 +18,6 @@ $index = intval(@$argv[2]);
ob_end_flush(); ob_end_flush();
set_time_limit(300); set_time_limit(300);
ini_set('max_execution_time', 300); ini_set('max_execution_time', 300);
error_reporting(E_ALL & ~E_DEPRECATED);
ini_set('display_errors', '1');
$global['rowCount'] = $global['limitForUnlimitedVideos'] = 999999; $global['rowCount'] = $global['limitForUnlimitedVideos'] = 999999;
$path = getVideosDir(); $path = getVideosDir();

View file

@ -21,8 +21,6 @@ $_2hours = $_1hour*2;
ob_end_flush(); ob_end_flush();
set_time_limit($_2hours); set_time_limit($_2hours);
ini_set('max_execution_time', $_2hours); ini_set('max_execution_time', $_2hours);
error_reporting(E_ALL & ~E_DEPRECATED);
ini_set('display_errors', '1');
$sort = @$argv[1]; $sort = @$argv[1];
if(strtolower($sort) !== 'asc'){ if(strtolower($sort) !== 'asc'){