#3 system docu cache & cron + fixes
This commit is contained in:
parent
0a36d3144f
commit
915824c883
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_api
|
||||
* @package SYSTEM\API
|
||||
*/
|
||||
namespace SYSTEM\API;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_api
|
||||
* @package SYSTEM\API
|
||||
*/
|
||||
namespace SYSTEM\API;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_api
|
||||
* @package SYSTEM\API
|
||||
*/
|
||||
namespace SYSTEM\API;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_api
|
||||
* @package SYSTEM\API
|
||||
*/
|
||||
namespace SYSTEM\API;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_api
|
||||
* @package SYSTEM\API
|
||||
*/
|
||||
namespace SYSTEM\API;
|
||||
|
||||
|
||||
2
cache/cache.php
vendored
2
cache/cache.php
vendored
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_cache
|
||||
* @package SYSTEM\CACHE
|
||||
*/
|
||||
namespace SYSTEM\CACHE;
|
||||
|
||||
|
||||
2
cache/cache_css.php
vendored
2
cache/cache_css.php
vendored
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_cache
|
||||
* @package SYSTEM\CACHE
|
||||
*/
|
||||
namespace SYSTEM\CACHE;
|
||||
|
||||
|
||||
2
cache/cache_filemask.php
vendored
2
cache/cache_filemask.php
vendored
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_cache
|
||||
* @package SYSTEM\CACHE
|
||||
*/
|
||||
namespace SYSTEM\CACHE;
|
||||
|
||||
|
||||
2
cache/cache_js.php
vendored
2
cache/cache_js.php
vendored
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_cache
|
||||
* @package SYSTEM\CACHE
|
||||
*/
|
||||
namespace SYSTEM\CACHE;
|
||||
|
||||
|
||||
2
cache/cache_scss.php
vendored
2
cache/cache_scss.php
vendored
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_cache
|
||||
* @package SYSTEM\CACHE
|
||||
*/
|
||||
namespace SYSTEM\CACHE;
|
||||
|
||||
|
||||
2
cache/qq/SYS_CACHE_CHECK.php
vendored
2
cache/qq/SYS_CACHE_CHECK.php
vendored
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_sql
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
|
||||
2
cache/qq/SYS_CACHE_DELETE.php
vendored
2
cache/qq/SYS_CACHE_DELETE.php
vendored
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_sql
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
|
||||
2
cache/qq/SYS_CACHE_DELETE_ALL.php
vendored
2
cache/qq/SYS_CACHE_DELETE_ALL.php
vendored
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_sql
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
|
||||
2
cache/qq/SYS_CACHE_PUT.php
vendored
2
cache/qq/SYS_CACHE_PUT.php
vendored
@ -7,7 +7,7 @@
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package system_sql
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
|
||||
@ -1,10 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\CONFIG
|
||||
*/
|
||||
namespace SYSTEM\CONFIG;
|
||||
|
||||
/**
|
||||
* Config Class provided by System for configuration of the System Environment.
|
||||
*/
|
||||
class config {
|
||||
/** array Holding all the Config Data */
|
||||
private static $config;
|
||||
|
||||
/**
|
||||
* Get Config Setting
|
||||
*
|
||||
* @param int $config_id Config ID to be retrieved
|
||||
* @return mixed Returns the requested Config Content or NULL
|
||||
*/
|
||||
public static function get($config_id){
|
||||
if( !isset(self::$config) ||
|
||||
!is_array(self::$config) ||
|
||||
@ -13,16 +32,26 @@ class config {
|
||||
return self::$config[$config_id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Config Setting
|
||||
*
|
||||
* @param int $config_id Config ID to be written
|
||||
* @param mixed $value Config Value to be written
|
||||
* @return NULL Returns NULL
|
||||
*/
|
||||
public static function set($config_id, $value){
|
||||
if( !isset(self::$config) ||
|
||||
!is_array(self::$config)){
|
||||
self::$config = array();}
|
||||
|
||||
self::$config[$config_id] = $value;
|
||||
}
|
||||
self::$config[$config_id] = $value;}
|
||||
|
||||
//array( array(ID, VALUE), array(ID, VALUE))
|
||||
/**
|
||||
* Set Array of Config Settings
|
||||
*
|
||||
* @param array $id_value_array Array containing Config IDs as Key and Value as Value to that Key. array( array(ID, VALUE), array(ID, VALUE))
|
||||
* @return NULL Returns NULL
|
||||
*/
|
||||
public static function setArray($id_value_array){
|
||||
foreach($id_value_array as $v){
|
||||
self::set($v[0], $v[1]);}}
|
||||
}
|
||||
}
|
||||
@ -1,30 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\CONFIG
|
||||
*/
|
||||
namespace SYSTEM\CONFIG;
|
||||
|
||||
/**
|
||||
* ConfigID Class provided by System for System Environment Config IDs.
|
||||
* Extend this class for your own purposes.
|
||||
*/
|
||||
class config_ids {
|
||||
|
||||
/** int Error Reporting Level within the Application */
|
||||
const SYS_CONFIG_ERRORREPORTING = 1;
|
||||
/** int Base URL for the Application */
|
||||
const SYS_CONFIG_PATH_BASEURL = 2;
|
||||
/** int Base Path for the Application */
|
||||
const SYS_CONFIG_PATH_BASEPATH = 3;
|
||||
/** int Relative Path to the System Library based on BASEPATH setting */
|
||||
const SYS_CONFIG_PATH_SYSTEMPATHREL = 4;
|
||||
|
||||
/** int Default Result the Application will return*/
|
||||
const SYS_CONFIG_DEFAULT_RESULT = 5;
|
||||
/** string Result Type JSON */
|
||||
const SYS_CONFIG_DEFAULT_RESULT_JSON = 'json';
|
||||
/** string Result Type MsgPack */
|
||||
const SYS_CONFIG_DEFAULT_RESULT_MSGPACK = 'msgpack';
|
||||
|
||||
/** int Database Driver to be used */
|
||||
const SYS_CONFIG_DB_TYPE = 11;
|
||||
/** string Database Driver MYSQL */
|
||||
const SYS_CONFIG_DB_TYPE_MYS = 'mysql';
|
||||
/** string Database Driver PostgreSQL */
|
||||
const SYS_CONFIG_DB_TYPE_PG = 'postgresql';
|
||||
/** int Default Database Host used by the Application */
|
||||
const SYS_CONFIG_DB_HOST = 12;
|
||||
/** int Default Database Port used by the Application */
|
||||
const SYS_CONFIG_DB_PORT = 13;
|
||||
/** int Default Database User used by the Application */
|
||||
const SYS_CONFIG_DB_USER = 14;
|
||||
/** int Default Database Password used by the Application */
|
||||
const SYS_CONFIG_DB_PASSWORD = 15;
|
||||
/** int Default Database Databasename used by the Application */
|
||||
const SYS_CONFIG_DB_DBNAME = 16;
|
||||
|
||||
/** int Languages supported by the Application */
|
||||
const SYS_CONFIG_LANGS = 21;
|
||||
/** int Default Language of the Application */
|
||||
const SYS_CONFIG_DEFAULT_LANG = 22;
|
||||
|
||||
/** int Logextraction path used by the Application */
|
||||
const SYS_CRON_LOG2SQLITE_PATH = 30;
|
||||
|
||||
/** int Projectname of the Application */
|
||||
const SYS_SAI_CONFIG_PROJECT = 54;
|
||||
}
|
||||
@ -1,7 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\CRON
|
||||
*/
|
||||
namespace SYSTEM\CRON;
|
||||
|
||||
class cron {
|
||||
/**
|
||||
* Cron Class provided by System for Tasks occurring repeateadly.
|
||||
*/
|
||||
class cron {
|
||||
/**
|
||||
* Check if given Class is a compatible Cronjob
|
||||
*
|
||||
* @param class $class Cronclass extending cronjob
|
||||
* @return bool Returns true or false
|
||||
*/
|
||||
public static function check($class){
|
||||
if( !\class_exists($class) ||
|
||||
!\is_array($parents = \class_parents($class)) ||
|
||||
@ -9,6 +28,11 @@ class cron {
|
||||
return false;}
|
||||
return true;}
|
||||
|
||||
/**
|
||||
* Run all registered Cronjobs if its time to do so.
|
||||
*
|
||||
* @return JSON Returns Json::ok()
|
||||
*/
|
||||
public static function run(){
|
||||
$crons = \SYSTEM\SQL\SYS_CRON_LIST::QQ();
|
||||
while($cron = $crons->next()){
|
||||
@ -35,6 +59,12 @@ class cron {
|
||||
return \SYSTEM\LOG\JsonResult::ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine next run of a given Cronjob
|
||||
*
|
||||
* @param class $class Cronjob class
|
||||
* @return time Returns the requested time
|
||||
*/
|
||||
public static function next($class){
|
||||
$cron = \SYSTEM\SQL\SYS_CRON_GET::Q1(array($class));
|
||||
//check module
|
||||
@ -49,6 +79,12 @@ class cron {
|
||||
$cron[\SYSTEM\SQL\system_cron::FIELD_MONTH]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine last run of a given Cronjob
|
||||
*
|
||||
* @param class $class Cronjob class
|
||||
* @return time Returns the requested time
|
||||
*/
|
||||
public static function last($class){
|
||||
$cron = \SYSTEM\SQL\SYS_CRON_GET::Q1(array($class));
|
||||
//check module
|
||||
@ -63,10 +99,21 @@ class cron {
|
||||
$cron[\SYSTEM\SQL\system_cron::FIELD_MONTH]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the Status of a Cronjob
|
||||
*
|
||||
* @param class $class Cronjob class
|
||||
* @param int $status Status to be written
|
||||
* @return bool Returns true or false
|
||||
*/
|
||||
private static function status($class, $status){
|
||||
//new \SYSTEM\LOG\CRON('Cron Status for Class '.$class.' updated to: '. \SYSTEM\CRON\cronstatus::text($status));
|
||||
return \SYSTEM\SQL\SYS_CRON_UPD::QI(array($status,time(),$class));}
|
||||
|
||||
/**
|
||||
* Determines the time when the System-Cronjobs were executed the last time.
|
||||
*
|
||||
* @return time Returns the time last visited
|
||||
*/
|
||||
public static function last_visit(){
|
||||
return \SYSTEM\SQL\SYS_CRON_LAST_VISIT::Q1()['last_run'];}
|
||||
}
|
||||
@ -1,6 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\CRON
|
||||
*/
|
||||
namespace SYSTEM\CRON;
|
||||
|
||||
/**
|
||||
* Conjob Class provided by System to delete System Cache.
|
||||
*/
|
||||
class cron_cache_delete extends \SYSTEM\CRON\cronjob{
|
||||
/**
|
||||
* Run the Cronjob and delete all Cache entries.
|
||||
*
|
||||
* @return int Return a Cronstatus for the Cron Class to update the db.
|
||||
*/
|
||||
public static function run(){
|
||||
if(!\SYSTEM\SQL\SYS_CACHE_DELETE_ALL::QI()){
|
||||
return cronstatus::CRON_STATUS_FAIL;}
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\CRON
|
||||
*/
|
||||
namespace SYSTEM\CRON;
|
||||
|
||||
/**
|
||||
* Conjob Class provided by System to extract Logentries into sqlite files.
|
||||
*/
|
||||
class cron_log2sqlite extends \SYSTEM\CRON\cronjob{
|
||||
/**
|
||||
* Run the Cronjob and extract Data from log, write it to sqlite files
|
||||
*
|
||||
* @return int Return a Cronstatus for the Cron Class to update the db.
|
||||
*/
|
||||
public static function run(){
|
||||
//find oldest value
|
||||
$oldest = \SYSTEM\SQL\SYS_LOG_OLDEST::Q1();
|
||||
|
||||
@ -1,6 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\CRON
|
||||
*/
|
||||
namespace SYSTEM\CRON;
|
||||
class cronjob{
|
||||
public static function run(){
|
||||
new \RuntimeException("Unimplemented!");}
|
||||
|
||||
/**
|
||||
* Conjob Class provided by System to derive from for custom Cronjobs.
|
||||
*/
|
||||
abstract class cronjob{
|
||||
/**
|
||||
* Run the Cronjob and execute its task
|
||||
*
|
||||
* @return int Return a Cronstatus for the Cron Class to update the db.
|
||||
*/
|
||||
public abstract static function run();
|
||||
}
|
||||
@ -1,28 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\CRON
|
||||
*/
|
||||
namespace SYSTEM\CRON;
|
||||
|
||||
/**
|
||||
* Cronstatus Class provided by System for Cronjob stati.
|
||||
*/
|
||||
class cronstatus {
|
||||
/** int Cron executed successfully */
|
||||
const CRON_STATUS_SUCCESFULLY = 0;
|
||||
/** int Cron is running */
|
||||
const CRON_STATUS_RUNNING = 1;
|
||||
/** int Cron execution failed within the Cronjob */
|
||||
const CRON_STATUS_FAIL = 2;
|
||||
/** int Cron execution failed because of Problems with the Cron-Class */
|
||||
const CRON_STATUS_FAIL_CLASS = 3;
|
||||
|
||||
/** int Placeholder where Userstates should start */
|
||||
const CRON_STATUS_USER_STATES = 99;
|
||||
|
||||
/**
|
||||
* Convert Cron Status to a text value.
|
||||
*
|
||||
* @param int $status Value from this Class
|
||||
* @return string Returns the requested status as text
|
||||
*/
|
||||
public static function text($status){
|
||||
switch($status){
|
||||
case self::CRON_STATUS_SUCCESFULLY:
|
||||
$status = 'SUCCESFULLY';
|
||||
break;
|
||||
$status = 'SUCCESFULLY';break;
|
||||
case self::CRON_STATUS_RUNNING:
|
||||
$status = 'RUNNING';
|
||||
break;
|
||||
$status = 'RUNNING';break;
|
||||
case self::CRON_STATUS_FAIL:
|
||||
$status = 'FAIL';
|
||||
break;
|
||||
$status = 'FAIL';break;
|
||||
case self::CRON_STATUS_FAIL_CLASS:
|
||||
$status = 'FAIL_CLASS';
|
||||
break;
|
||||
$status = 'FAIL_CLASS';break;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
@ -1,6 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\CRON
|
||||
*/
|
||||
namespace SYSTEM\CRON;
|
||||
|
||||
/**
|
||||
* Crontime Class provided by System for Cronjob time calculation.
|
||||
*/
|
||||
class crontime {
|
||||
/**
|
||||
* Determine next time based on a basetime and crontab-style modificators
|
||||
*
|
||||
* @param time $base_time Time which the calculation should be based upon
|
||||
* @param int $min Minutes-Modificator for next run
|
||||
* @param int $hour Hour-Modificator for next run
|
||||
* @param int $day Day-Modificator for next run
|
||||
* @param int $day_week Day-Of-The-Week-Modificator for next run
|
||||
* @param int $month Month-Modificator for next run
|
||||
* @return time Returns the requested time
|
||||
*/
|
||||
public static function next($base_time,$min,$hour,$day,$day_week,$month){
|
||||
list( $now_min, $now_hour, $now_day, $now_month, $now_day_week ) = preg_split( "/ /", date("i H d n N", $base_time ) );
|
||||
list( $next_min, $next_hour, $next_day, $next_month, $next_year) = preg_split( "/ /", date("i H d n Y", $base_time ) );
|
||||
@ -20,11 +45,20 @@ class crontime {
|
||||
$day_week = $day_week % 6; // 7 and 0 both mean Sunday
|
||||
$now_day_week = $now_day_week % 6; // 7 and 0 both mean Sunday
|
||||
$next_day += abs($day_week - $now_day_week);}
|
||||
//new \SYSTEM\LOG\INFO(print_r(array($base_time,$min,$hour,$day,$day_week,$month),true));
|
||||
//new \SYSTEM\LOG\INFO(print_r(array($now_min, $now_hour, $now_day, $now_month, $now_day_week),true));
|
||||
//new \SYSTEM\LOG\INFO(print_r(array($next_hour, $next_min, 0, $next_month, $next_day, $next_year),true));
|
||||
return mktime($next_hour, $next_min, 0, $next_month, $next_day, $next_year);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine last time based on a basetime and crontab-style modificators
|
||||
*
|
||||
* @param time $base_time Time which the calculation should be based upon
|
||||
* @param int $min Minutes-Modificator for last run
|
||||
* @param int $hour Hour-Modificator for last run
|
||||
* @param int $day Day-Modificator for last run
|
||||
* @param int $day_week Day-Of-The-Week-Modificator for last run
|
||||
* @param int $month Month-Modificator for last run
|
||||
* @return time Returns the requested time
|
||||
*/
|
||||
public static function last($base_time,$min,$hour,$day,$day_week,$month){
|
||||
list( $now_min, $now_hour, $now_day, $now_month, $now_day_week ) = preg_split( "/ /", date("i H d n N", $base_time ) );
|
||||
list( $last_min, $last_hour, $last_day, $last_month, $last_year) = preg_split( "/ /", date("i H d n Y", $base_time ) );
|
||||
@ -46,13 +80,60 @@ class crontime {
|
||||
$last_day -= abs($day_week - $now_day_week);}
|
||||
return mktime($last_hour, $last_min, 0, $last_month, $last_day, $last_year);
|
||||
}
|
||||
/**
|
||||
* Determine if time for next run lies in the past based on a lastrun,
|
||||
* a basetime and crontab-style modificators
|
||||
*
|
||||
* @param time $base_time Time upon which is checked if the calculated time is in the past
|
||||
* @param time $last_run Time which the calculation should be based upon
|
||||
* @param int $min Minutes-Modificator for next run
|
||||
* @param int $hour Hour-Modificator for next run
|
||||
* @param int $day Day-Modificator for next run
|
||||
* @param int $day_week Day-Of-The-Week-Modificator for next run
|
||||
* @param int $month Month-Modificator for next run
|
||||
* @return bool Returns true or false based upon if the calculated Date lies in the past
|
||||
*/
|
||||
public static function check($base_time,$last_run,$min,$hour,$day,$day_week,$month){
|
||||
//new \SYSTEM\LOG\INFO('next:'.self::next($last_run, $min, $hour, $day, $day_week, $month).' bt:'.$base_time.' last:'.$last_run.' dif:'.(self::next($last_run, $min, $hour, $day, $day_week, $month) - time($base_time)).' run:'.(self::next($last_run, $min, $hour, $day, $day_week, $month) <= time($base_time) ? 'run' : 'not run'));
|
||||
return self::next($last_run, $min, $hour, $day, $day_week, $month) <= $base_time ? true : false;}
|
||||
public static function next_now($min,$hour,$day,$day_week,$month){
|
||||
return self::next(time(),$min,$hour,$day,$day_week,$month);}
|
||||
public static function last_now($min,$hour,$day,$day_week,$month){
|
||||
return self::last(time(),$min,$hour,$day,$day_week,$month);}
|
||||
|
||||
/**
|
||||
* Determine if time for next run lies in the past based on a lastrun and
|
||||
* crontab-style modificators using system-time as compare-time.
|
||||
*
|
||||
* @param time $last_run Time which the calculation should be based upon
|
||||
* @param int $min Minutes-Modificator for next run
|
||||
* @param int $hour Hour-Modificator for next run
|
||||
* @param int $day Day-Modificator for next run
|
||||
* @param int $day_week Day-Of-The-Week-Modificator for next run
|
||||
* @param int $month Month-Modificator for next run
|
||||
* @return bool Returns true or false based upon if the calculated Date lies in the past
|
||||
*/
|
||||
public static function check_now($last_run,$min,$hour,$day,$day_week,$month){
|
||||
return self::check(time(),$last_run,$min,$hour,$day,$day_week,$month);}
|
||||
|
||||
/**
|
||||
* Determine next time based on the system-time and crontab-style modificators
|
||||
*
|
||||
* @param int $min Minutes-Modificator for next run
|
||||
* @param int $hour Hour-Modificator for next run
|
||||
* @param int $day Day-Modificator for next run
|
||||
* @param int $day_week Day-Of-The-Week-Modificator for next run
|
||||
* @param int $month Month-Modificator for next run
|
||||
* @return time Returns the requested time
|
||||
*/
|
||||
public static function next_now($min,$hour,$day,$day_week,$month){
|
||||
return self::next(time(),$min,$hour,$day,$day_week,$month);}
|
||||
|
||||
/**
|
||||
* Determine last time based on system-time and crontab-style modificators
|
||||
*
|
||||
* @param int $min Minutes-Modificator for last run
|
||||
* @param int $hour Hour-Modificator for last run
|
||||
* @param int $day Day-Modificator for last run
|
||||
* @param int $day_week Day-Of-The-Week-Modificator for last run
|
||||
* @param int $month Month-Modificator for last run
|
||||
* @return time Returns the requested time
|
||||
*/
|
||||
public static function last_now($min,$hour,$day,$day_week,$month){
|
||||
return self::last(time(),$min,$hour,$day,$day_week,$month);}
|
||||
}
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get a specific cron entry
|
||||
*/
|
||||
class SYS_CRON_GET extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pgsql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to find the cronjob which had ben run the most reacent
|
||||
*/
|
||||
class SYS_CRON_LAST_VISIT extends \SYSTEM\DB\QQ {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pgsql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get all Cronjobs from Database
|
||||
*/
|
||||
class SYS_CRON_LIST extends \SYSTEM\DB\QQ {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pgsql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to update a cronjobs status and lastrun
|
||||
*/
|
||||
class SYS_CRON_UPD extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pgsql(){return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user