LEPTON CMS 7.5.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
lepton_cronjob.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
19
20// include cronjob file for external call
22{
23 public $cj_array = []; // content of cronjob.ini file
24 public string $cj_path = LEPTON_PATH;
25 public string $cj_file = '';
26 public string $cj_key = '';
27 public string $cj_interval = '-1';
28 public int $cj_time = -1;
29
30
31 public object|null $oTwig = null;
32 public object|null $database = null;
33 public object|null $mailer = null;
34 public static $instance;
35
36 // Return the instance of this class.
37 public static function getInstance()
38 {
39 if (null === static::$instance)
40 {
41 static::$instance = new static();
42 static::$instance->initialize();
43 }
44 return static::$instance;
45 }
46
47 public function initialize()
48 {
49 $info = '@DEPRECATED_TEMP 20251010: this class will be removed in L* > 7.5.0, use external cronjobs instead")';
50 echo(LEPTON_tools::display($info, 'pre','ui orange message'));
51 echo (LEPTON_tools::display(debug_print_backtrace(), 'pre','ui message'));
52
53 $this->database = LEPTON_database::getInstance();
54 $this->oTwig = lib_twig_box::getInstance();
55 $this->mailer = LEPTON_mailer::getInstance();
56 $this->cj_time = time();
57
58 $cronjob_ini = LEPTON_PATH."/config/cronjob.ini.php";
59 $this->cj_array = parse_ini_file($cronjob_ini, true);
60
61 // set values
62 $this->cj_path = $this->cj_array['file_info']['path'];
63 $this->cj_file = $this->cj_array['file_info']['file'];
64 $this->cj_key = $this->cj_array['file_info']['key'];
65 $this->cj_interval = $this->cj_array['file_info']['interval'];
66
67 if(!isset($_SESSION['last_cronjob']))
68 {
69 $_SESSION['last_cronjob'] = $_SESSION['SESSION_STARTED'] - ($this->cj_interval +1);
70 }
71
72 if(strlen($this->cj_key) < AUTH_MIN_PASS_LENGTH)
73 {
74 die (LEPTON_tools::display('NOT allowed: key must have a min of chars ("AUTH_MIN_PASS_LENGTH") in cronjob.ini.php','pre','ui red message'));
75 }
76
77 if(!file_exists(LEPTON_PATH.$this->cj_path.$this->cj_file) )
78 {
79 die (LEPTON_tools::display('You have to specify a correct file in cronjob.ini.php to use this class!','pre','ui red message'));
80 }
81 }
82
83
84 public function send_mail( $id = -99 )
85 {
86 global $TEXT;
87
88 $sFrom = SERVER_EMAIL;
89 $sSendTo = SERVER_EMAIL;
90 $sSubject = 'cronjob_info';
91 $sMessage = "
92
93 ";
94
95 if (!$this->mailer->sendmail( $sFrom, $sSendTo, $sSubject, $sMessage))
96 {
97 $message = "Failure send mail";
98 echo(LEPTON_tools::display($message,'pre','ui red message'));
99 }
100 }
101}
object null $oTwig
send_mail( $id=-99)
object null $mailer
object null $database
static getInstance(array &$settings=[])
static getInstance(&$settings=array())
static display(mixed $something_to_display="", string $tag="pre", string|null $css_class=null, bool|null $useVarDump=null)