1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00
Daniel Neto 2024-04-01 10:56:36 -03:00
parent ea2e649f17
commit 7ec296ff28
2 changed files with 23 additions and 22 deletions

View file

@ -1,7 +1,7 @@
<?php <?php
require_once __DIR__ . '/../../videos/configuration.php'; require_once __DIR__ . '/../../videos/configuration.php';
if (!isCommandLineInterface()) { if (!isCommandLineInterface() && !User::isAdmin()) {
forbiddenPage(); forbiddenPage();
} }

View file

@ -7,7 +7,7 @@ if (!isCommandLineInterface() && !User::isAdmin()) {
return die('Command Line only'); return die('Command Line only');
} }
if(!AVideoPlugin::isEnabledByName('Scheduler')){ if (!AVideoPlugin::isEnabledByName('Scheduler')) {
return die('Scheduler is disabled'); return die('Scheduler is disabled');
} }
@ -20,49 +20,50 @@ $total1 = count($rowActive);
$rows = Scheduler_commands::getAllActiveAndReady(); $rows = Scheduler_commands::getAllActiveAndReady();
$total2 = count($rows); $total2 = count($rows);
if(!isCommandLineInterface()){ if (!isCommandLineInterface()) {
echo '<pre>'; echo '<pre>';
} }
if(empty($rows)){ if (empty($rows)) {
//echo ("Scheduler row is empty".PHP_EOL); //echo ("Scheduler row is empty".PHP_EOL);
} }
$rows2 = Scheduler_commands::getAllScheduledTORepeat(); $rows2 = Scheduler_commands::getAllScheduledTORepeat();
if(empty($rows)){ if (empty($rows)) {
//echo ("Scheduler row2 is empty".PHP_EOL); //echo ("Scheduler row2 is empty".PHP_EOL);
} }
$total3 = count($rows2); $total3 = count($rows2);
//_log("There are {$total1} active requests; getAllActiveAndReady={$total2} getAllScheduledTORepeat={$total3} on time ". json_encode(Scheduler_commands::getTimesNow())); //_log("There are {$total1} active requests; getAllActiveAndReady={$total2} getAllScheduledTORepeat={$total3} on time ". json_encode(Scheduler_commands::getTimesNow()));
foreach ($rows as $value) { foreach ($rows as $value) {
_log("getAllActiveAndReady run ". json_encode($value)); _log("getAllActiveAndReady run " . json_encode($value));
$id = Scheduler::run($value['id']); $id = Scheduler::run($value['id']);
if(empty($id)){ if (empty($id)) {
_log("error [{$value['id']}] callbackURL={$value['callbackURL']}"); _log("error [{$value['id']}] callbackURL={$value['callbackURL']}");
} }
} }
foreach ($rows2 as $value) { foreach ($rows2 as $value) {
_log("getAllScheduledTORepeat run ". json_encode($value)); _log("getAllScheduledTORepeat run " . json_encode($value));
$id = Scheduler::run($value['id']); $id = Scheduler::run($value['id']);
if(empty($id)){ if (empty($id)) {
_log("error [{$value['id']}] callbackURL={$value['callbackURL']} ".json_encode($value)); _log("error [{$value['id']}] callbackURL={$value['callbackURL']} " . json_encode($value));
} }
} }
$lastVisitFile = Scheduler::setLastVisit(); $lastVisitFile = Scheduler::setLastVisit();
if(!empty($lastVisitFile) && !empty($lastVisitFile['size'])){ if (!empty($lastVisitFile) && !empty($lastVisitFile['size'])) {
//echo 'Saved '.json_encode($lastVisitFile); //echo 'Saved '.json_encode($lastVisitFile);
//_error_log("Last visit set {$lastVisitFile}"); //_error_log("Last visit set {$lastVisitFile}");
}else{ } else {
$msg = 'ERROR: Last visit NOT set '.json_encode($lastVisitFile); $msg = 'ERROR: Last visit NOT set ' . json_encode($lastVisitFile);
echo $msg.PHP_EOL; echo $msg . PHP_EOL;
_error_log($msg); _error_log($msg);
} }
function _log($msg){ function _log($msg)
{
if(!isCommandLineInterface()){ if (!isCommandLineInterface()) {
echo date('Y-m-d H:i:s').' '.$msg.'<br>'; echo date('Y-m-d H:i:s') . ' ' . $msg . '<br>';
} }
_error_log("Scheduler::run {$msg}"); _error_log("Scheduler::run {$msg}");
@ -97,6 +98,6 @@ if ($current_day == '1' && $current_hour == '0' && $current_minute == '00') {
//echo ("Scheduler executeEveryMonth".PHP_EOL); //echo ("Scheduler executeEveryMonth".PHP_EOL);
AVideoPlugin::executeEveryMonth(); AVideoPlugin::executeEveryMonth();
} }
if(!isCommandLineInterface()){ if (!isCommandLineInterface()) {
echo '</pre>'; echo '</pre>';
} }