LEPTON CMS 7.0.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
20// @ADD_cronjob 20230727, 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 $this->database = LEPTON_database::getInstance();
50 $this->oTwig = lib_twig_box::getInstance();
51 $this->mailer = LEPTON_mailer::getInstance();
52 $this->cj_time = time();
53
54 $cronjob_ini = LEPTON_PATH."/config/cronjob.ini.php";
55 $this->cj_array = parse_ini_file($cronjob_ini, true);
56
57 // set values
58 $this->cj_path = $this->cj_array['file_info']['path'];
59 $this->cj_file = $this->cj_array['file_info']['file'];
60 $this->cj_key = $this->cj_array['file_info']['key'];
61 $this->cj_interval = $this->cj_array['file_info']['interval'];
62
63 if(!isset($_SESSION['last_cronjob']))
64 {
65 $_SESSION['last_cronjob'] = $_SESSION['session_started'] - ($this->cj_interval +1);
66 }
67
68 if(strlen($this->cj_key) < AUTH_MIN_PASS_LENGTH)
69 {
70 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'));
71 }
72
73 if(!file_exists(LEPTON_PATH.$this->cj_path.$this->cj_file) )
74 {
75 die (LEPTON_tools::display('You have to specify a correct file in cronjob.ini.php to use this class!','pre','ui red message'));
76 }
77 }
78
79
80 public function send_mail( $id = -99 )
81 {
82 global $TEXT;
83
84 $sFrom = SERVER_EMAIL;
85 $sSendTo = SERVER_EMAIL;
86 $sSubject = 'cronjob_info';
87 $sMessage = "
88
89 ";
90
91 if (!$this->mailer->sendmail( $sFrom, $sSendTo, $sSubject, $sMessage))
92 {
93 $message = "Failure send mail";
94 echo(LEPTON_tools::display($message,'pre','ui red message'));
95 }
96 }
97}
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)