173 lines
7.0 KiB
PHP
173 lines
7.0 KiB
PHP
<?php
|
|
|
|
use BRSystems\Core\App\pubBugs\pubBugs;
|
|
use BRSystems\Core\App\pubExport\pubExport;
|
|
use BRSystems\Core\Cms\cmsAccountActivation\cmsAccountActivation;
|
|
use BRSystems\Core\Cms\cmsAccountManager\inc\cmsAccountManagerModule;
|
|
use BRSystems\Core\Cms\cmsMailEngine\cmsMailEngine;
|
|
use BRSystems\Core\Cms\cmsSvnProjectManager\cmsSvnProjectManager;
|
|
use BRSystems\Core\Library\cCron\cCron;
|
|
use BRSystems\Core\Library\cDbLog\cDbLogModule;
|
|
use BRSystems\Core\Library\cMail\cMail;
|
|
use BRSystems\Core\Library\cTimer\cTimer;
|
|
use BRSystems\Core\Library\cUrl\cUrl;
|
|
use BRSystems\Core\Sys\sysEmpty\inc\sysEmptyController;
|
|
use BRSystems\Core\Sys\sysUpdater\sysUpdater;
|
|
use BRSystems\Core\Sys\sysUsers\inc\sysUsersController;
|
|
|
|
const CRON_ID = 7;
|
|
startSessionSameSite(60 * 60 * 24);
|
|
|
|
// Increase time & memory limit
|
|
set_time_limit(60 * 5);
|
|
ini_set('memory_limit', '1024M');
|
|
|
|
//------------------------------------------------------------------
|
|
// Parse URL for extracting params kpsadmin12!@ - CC
|
|
// URL: http://www.elixirvault.lv/cron/ctp:ELIXIRVAULT-A94A8FE5CCB19BA61C4C0873D391E987982FBBD3/ct:check
|
|
// MAIL SEND INIT: screen -A -m -d -S elixirvault_mailer curl "http://local.elixirvault.lv/cron/ctp:ELIXIRVAULT-A94A8FE5CCB19BA61C4C0873D391E987982FBBD3/ct:send/id:1"
|
|
//------------------------------------------------------------------
|
|
$cms = false;
|
|
$url = new cUrl();
|
|
$url->parseUrl($cms, ADMINISTRATION_FOLDER);
|
|
|
|
//------------------------------------------------------------------
|
|
// Check hash & submit operations
|
|
//------------------------------------------------------------------
|
|
if ($sKey = getG('ctp')) {
|
|
if ($sKey == cMail::MAIL_REQUEST_KEY) {
|
|
|
|
// Simulate CRON user login :D
|
|
$user = new sysUsersController();
|
|
$user->suser->id = CRON_ID;
|
|
$user->suser->b2FAEnabled = true;
|
|
$user->suser->permissions = $user->oModule->loadUserPermissionArray(CRON_ID);
|
|
|
|
if ($debug = getG('debug')) {
|
|
$timer = new cTimer();
|
|
$timer->start();
|
|
}
|
|
|
|
switch (getG('ct')) {
|
|
|
|
//------------------------------------------------------------------
|
|
// Send immediately mail request
|
|
//------------------------------------------------------------------
|
|
case 'send':
|
|
if ($mailId = getG('id')) {
|
|
sleep(5);
|
|
$mailOverView = new cmsMailEngine(getFirstMatchByMapId(259, true));
|
|
$mailOverView->controller->cronSendMails([$mailId]);
|
|
}
|
|
break;
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
// Check immediately for new account activation
|
|
//------------------------------------------------------------------
|
|
case 'registration-activation':
|
|
sleep(5);
|
|
$mailActivationCRON = new cmsAccountActivation(getFirstMatchByMapId(839, true));
|
|
$mailActivationCRON->controller->chkUserRegDataCRONCall();
|
|
break;
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
// Different type of operations:
|
|
// Send mail, generate attachments, check
|
|
//------------------------------------------------------------------
|
|
case 'check':
|
|
|
|
// Call CRON every 2min
|
|
cDbLogModule::baseActionLog('chk_cron */2 * * * *');
|
|
|
|
//-------------------------------------------------------------------------
|
|
// Send mail
|
|
//-------------------------------------------------------------------------
|
|
$mailOverView = new cmsMailEngine(getFirstMatchByMapId(259, true));
|
|
$mailOverView->controller->cronSendMails();
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
// 1x per day do:
|
|
//-------------------------------------------------------------------------
|
|
$DATE = date("d-m-Y");
|
|
if (betweenTime(array(
|
|
"{$DATE} 05:00:00" => "{$DATE} 05:01:59",
|
|
/*"{$DATE} 14:50:00" => "{$DATE} 14:54:50",
|
|
"{$DATE} 00:00:00" => "{$DATE} 23:59:59"*/
|
|
))) {
|
|
// Generate Bug mails
|
|
// $cBugs = new pubBugs(getFirstMatchByMapId(699, true));
|
|
// $cBugs->controller->sendEmailWithCreatedList(
|
|
// strtotime("-1 day 00:00:00"),
|
|
// strtotime("-1 day 23:59:59")
|
|
// );
|
|
|
|
// Generate XML data files
|
|
$export = new pubExport(getFirstMatchByMapId(840)); // export site map id
|
|
$export->controller->genExportXML();
|
|
cDbLogModule::baseActionLog('XML GEN -- OK!');
|
|
|
|
// Clear access tokens, temp links, ect. from db
|
|
$cr = new cCron();
|
|
$cr->execBDEndCronScripts();
|
|
cDbLogModule::baseActionLog('CRON_CLEANUP -- OK!');
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
// Project export request check
|
|
//-------------------------------------------------------------------------
|
|
$oUpdRequest = new cmsSvnProjectManager();
|
|
$oUpdRequest->controller->chkActiveProjectExportRequests();
|
|
|
|
$oUpdRequest = new sysUpdater();
|
|
$oUpdRequest->controller->chkProjectUpdateStatus();
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
// Create times for cron call for gathering data for welcome page - EVERY HOUR
|
|
//-------------------------------------------------------------------------
|
|
$iTime = sysEmptyController::$iRefreshRate;
|
|
$x = $iTime;
|
|
$xx = strtotime("00:00:00");
|
|
|
|
$vDates = array();
|
|
while ($x < 24 * 60 * 60) { // 24h
|
|
$vDates["{$DATE} " . date('H:i:s', $xx + $x)] = "{$DATE} " . date('H:i:s', $xx + $x + 119);
|
|
$x += $iTime;
|
|
}
|
|
|
|
if (!!$vDates && betweenTime($vDates)) {
|
|
|
|
if (!!sysEmptyController::$vGAViews) {
|
|
foreach (sysEmptyController::$vGAViews as $k => $v) {
|
|
sysEmptyController::cronGatherDataAndSetToAPC(
|
|
$v,
|
|
'Elixir Vault Analytics application',
|
|
false,
|
|
true
|
|
);
|
|
}
|
|
}
|
|
cDbLogModule::baseActionLog('GOOGLE_API_USERS -- OK!');
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
}
|
|
|
|
if ($debug) {
|
|
$timer->stop();
|
|
echo round($timer->elapsed, 3);
|
|
}
|
|
} else {
|
|
http_response_code(404);
|
|
die();
|
|
}
|
|
}
|