Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/kjvdictionary_store/modules/crontab/ |
Upload File : |
<?php
namespace modules\crontab;
//to do: if crontab does not exist, use a central website
// requires pcntl_fork
class main extends \moduleMain {
use \modules\input\traits {
\modules\input\traits::__construct as __ConstructInput;
}
private $model_cron;
public function __construct() {
parent::__construct(__DIR__);
$this->__ConstructInput();
$this->model_cron = $this->LoadModel('cron_model');
}
// register hooks
public function Activate() {
hook_add('crontab.add', [$this, '__crontab_add']);
hook_add('crontab.remove', [$this, '__crontab_remove']);
hook_add('crontab.running', [$this, '__crontab_running']); // is the current process running within the Tick() process
}
// run php from the command line to see if pcntl_fork exists
private function _validateExecutable() {
$exe = $this->model_cron->getExecutable();
$safe = escapeshellcmd($exe);
$commandline = $safe . ' -r \'echo (function_exists("pcntl_fork") ? 1 : 0);\'';
$output = `$commandline`;
return (int)$output;
}
public function Validate() {
// this only works for the CLI version of php. Not present in apache2
$ok = $this->_validateExecutable();
if (! $ok) {
return ['result' => 1000, 'message' => 'PCNTL functions not available on this PHP-CLI installation.'];
// also make sure it is not present in php.ini::disable_functions
}
return TRUE;
}
// on activate: add entry to crontab - run every minute
public function onEnable() {
return $this->model_cron->AddCron('* * * * *', [$this, 'tick'], TRUE);
}
// on deactivate - remove it
public function onDisable() {
return $this->model_cron->RemoveCron([$this, 'tick']);
}
public function __crontab_add($schedule, $command) {
return $this->model_cron->AddCron($schedule, $command, TRUE);
}
public function __crontab_remove($command) {
return $this->model_cron->RemoveCron($command);
}
public function __crontab_running(&$result) {
$result = $this->model_cron->IsRunning();
}
// this is called from crontab every minute; should not generate any output
// /~/crontab/tick
/** everyone */
final function tick() {
header('Content-type: text/plain');
// get the hostname from settings
$hostname = $this->settings['hostname'] ?? '';
if ($hostname != '') $this->BaseUrl($hostname);
list($dd,$mm,$hh,$ii,$yy) = explode(',', gmdate('j,n,G,i,Y'));
if (isset($_GET['time'])) {
list($h, $i) = explode(':', $_GET['time']);
$hh = intval($h, 10);
$ii = intval($i, 10);
}
$dt = gmmktime($hh, $ii, 0, $mm, $dd, $yy);
set_time_limit(0);
$this->model_cron->Tick($dt);
exit;
}
/* final function test() {
header('Content-type: text/plain');
$m = $this->AddCron('* * * * *', [$this, 'Event'], TRUE);
var_dump($m);
exit;
} */
}