Esempio n. 1
0
 /**
  *	Init Now
  *
  *	@return	void
  */
 public static function initNow()
 {
     require_once CTM_ROOT_PATH . "cache/server_cache/db_php/core_sources/installation_info.php";
     $_SERVER['REQUEST_URI'] = str_replace("&ajaxLoadSet", "/&ajaxLoadSet", CTM_URLEngine::URIString());
     CTM_Controller::PHPErrors();
     CTM_LoadTime::startTime();
     date_default_timezone_set("America/Sao_Paulo");
     if ($installation['is_installed'] == false) {
         if (CTM_ROOT_AREA == "admin") {
             header("Location: " . CTM_URLEngine::URLBase() . "installer/?app=install");
             exit;
         } else {
             CTM_Error::kernelError("The board is not installed");
         }
     } elseif (EW_THIS_VERSION > str_pad($installation['current_version'], 5, 0, STR_PAD_RIGHT)) {
         if (CTM_ROOT_AREA == "admin") {
             header("Location: " . CTM_URLEngine::URLBase() . "installer/?app=upgrade");
             exit;
         } else {
             CTM_Error::kernelError("The board is in update process");
         }
     }
     CTM_Cookies::$cookiePath = COOKIE_PATH;
     CTM_Cookies::$cookieDomain = COOKIE_DOMAIN;
     CTM_Registry::init();
     CTM_Command::instance()->registry();
     CTM_Registry::fetchDriver()->settings['mssql']['hostname'] = MSSQL_HOSTNAME;
     CTM_Registry::fetchDriver()->settings['mssql']['hostport'] = MSSQL_HOSTPORT;
     CTM_Registry::fetchDriver()->settings['mssql']['username'] = MSSQL_USERNAME;
     CTM_Registry::fetchDriver()->settings['mssql']['password'] = MSSQL_PASSWORD;
     CTM_Registry::fetchDriver()->settings['mssql']['database'] = CTMEW_CORE;
     CTM_Registry::fetchDriver()->settings['mssql']['persistent'] = MSSQL_PERSISTENT;
     CTM_Registry::fetchDriver()->settings['mssql']['debug'] = in_array("mssql", explode(",", CTM_SQL_DEBUG_MODE));
     CTM_Registry::fetchDriver()->settings['mssql']['log_folder'] = "MSSQL";
     CTM_Registry::fetchDriver()->Connect("mssql");
     if (CTM_Command::instance()->settings['CRONJOB']['ENABLE'] == TRUE) {
         $CronJob = new CronJob();
         $CronJob->Start(CTM_Command::instance()->settings['CRONJOB']['DEBUG']);
         $CronJob->RunAllTasks();
         $CronJob->Finish();
     }
     Authentication::init();
     CTM_Controller::Setup();
     CTM_Dashboard::init();
     CTM_Registry::setSetup("application", CTM_Dashboard::$application);
     if (CTM_ROOT_AREA == "public") {
         print self::GetContent();
         print "\r\n<!-- Effect Web " . EW_PUBLIC_VERSION . " / Powered by Erick-Master & Litlle / (c) 2012 -->";
     } else {
         CTM_ACPBoard::init(ACP_LOAD_MODULE);
     }
     exit;
 }
Esempio n. 2
0
 /**
  * Add a new cron job to the DB.
  *
  * @see CronJob
  * @param array $paramarray A paramarray of cron job feilds.
  * @return \Habari\CronJob
  */
 static function add_cron($paramarray)
 {
     // Delete any existing job with this same name
     if ($job = CronTab::get_cronjob($paramarray['name'])) {
         $job->delete();
     }
     $cron = new CronJob($paramarray);
     $result = $cron->insert();
     //If the new cron should run earlier than the others, rest next_cron to its strat time.
     $next_cron = DB::get_value('SELECT next_run FROM {crontab} ORDER BY next_run ASC LIMIT 1', array());
     if (intval(Options::get('next_cron')) > intval($next_cron)) {
         Options::set('next_cron', $next_cron);
     }
     return $result ? $cron : false;
 }
Esempio n. 3
0
            $this->Database->query("INSERT INTO tl_lock (name, tstamp) VALUES ('cron', {$time})");
            $this->Database->unlockTables();
            return false;
        }
        // Last execution was less than five minutes ago
        if ($objCron->tstamp > time() - 300) {
            $this->Database->unlockTables();
            return true;
        }
        // Store the new value
        $this->updateCronTxt($time);
        $this->Database->query("UPDATE tl_lock SET tstamp={$time} WHERE name='cron'");
        $this->Database->unlockTables();
        return false;
    }
    /**
     * Update the cron.txt file
     * @param integer
     */
    protected function updateCronTxt($time)
    {
        $objFile = new File('system/html/cron.txt');
        $objFile->write($time);
        $objFile->close();
    }
}
/**
 * Instantiate controller
 */
$objCronJob = new CronJob();
$objCronJob->run();
Esempio n. 4
0
 /**
  * Add a new cron job to the DB.
  *
  * @see CronJob
  * @param array $paramarray A paramarray of cron job feilds.
  */
 static function add_cron($paramarray)
 {
     $cron = new CronJob($paramarray);
     $result = $cron->insert();
     //If the new cron should run earlier than the others, rest next_cron to its strat time.
     $next_cron = DB::get_value('SELECT next_run FROM {crontab} ORDER BY next_run ASC LIMIT 1', array());
     if (intval(Options::get('next_cron')) > intval($next_cron)) {
         Options::set('next_cron', $next_cron);
     }
     return $result;
 }
Esempio n. 5
0
<?php

/**
 * @file
 * Initiate Cron Job Call
 */
require_once 'vendor/autoload.php';
require_once 'config/config.php';
require_once 'includes/class/CronJob.php';
$cronJob = new CronJob();
$cronJob->initialteRedmineCronJob();
//$cronJob->masterRedmineCronJob();
 protected function getCronExpression(CronJob $job)
 {
     return sprintf('%s %s %s %s %s %s', $job->getCronJobSchedule()->getMinute(), $job->getCronJobSchedule()->getHour(), $job->getCronJobSchedule()->getDay(), $job->getCronJobSchedule()->getMonth(), $job->getCronJobSchedule()->getWeekDay(), $job->getCronJobSchedule()->getYear());
 }
Esempio n. 7
0
 /**
  * Create a cronParser and check to see if we need to create new jobs
  *
  * @return void
  */
 function process()
 {
     global $db;
     $cronParser =& new CronParser($this->cronDefinition);
     if ($this->getId() && $cronParser->getLastRanUnix() > $this->getLastActualTimestamp()) {
         if (function_exists('writeLog')) {
             writeLog('creating job because ' . date('d-m-Y H:i', $cronParser->getLastRanUnix()) . ' > ' . date('d-m-Y H:i', $this->getLastActualTimestamp()) . ' (' . $cronParser->getLastRanUnix() . ' > ' . $this->getLastActualTimestamp() . ')');
         }
         $this->lastActualTimestamp = time();
         $sql = 'UPDATE `' . DB_NAME . '`.`' . TABLE_CRONTAB . '` SET `lastActualTimestamp`= ' . $db->Quote($this->lastActualTimestamp) . ' WHERE `id`= ' . $db->Quote($this->getId());
         $db->Execute($sql);
         $job = new CronJob();
         $job->createFromCrontab(&$this);
         $job->update();
     }
     return;
 }
Esempio n. 8
0
 /**
  *	Private: Run Task
  *	Run a CronTask
  *
  *	@return	void
  */
 private function loadRunTask()
 {
     $GLOBALS['task_error'] = FALSE;
     $this->DB->Arguments($_GET['id']);
     $this->DB->Query("SELECT 1 FROM dbo.CTM_CronJob WHERE Id = %d", $check_exists);
     if ($this->DB->CountRows($check_exists) < 1) {
         return $GLOBALS['task_error'] = TRUE;
     }
     $CronJob = new CronJob();
     $CronJob->Start(FALSE);
     $CronJob->RunTask($_GET['id']);
     $CronJob->GetCronJobLog($CronJobResult);
     $CronJob->Finish();
     $GLOBALS['cronjob_result'] = $CronJobResult;
 }
 public function formui_submit(FormUI $form)
 {
     if (isset($form->cron_id)) {
         $cron = CronTab::get_cronjob((int) $form->cron_id->value);
     } else {
         $required = array('cron_name', 'callback', 'description');
         foreach ($required as $req) {
             if (!$form->{$req}->value) {
                 Session::error(_t('%s is a required feild.', array(ucwords($req)), 'crontabmanager'));
                 return;
             }
         }
         $cron = new CronJob();
         //$cron->insert();
     }
     $cron->name = $form->cron_name->value;
     $cron->callback = strpos($form->callback->value, 'a:') === 0 || strpos($form->callback->value, 'O:') === 0 ? unserialize($form->callback->value) : $form->callback->value;
     $cron->increment = $form->increment->value ? $form->increment->value : 86400;
     $cron->next_run = HabariDateTime::date_create(isset($form->next_run) && $form->next_run->value ? $form->next_run->value : HabariDateTime::date_create());
     $cron->start_time = HabariDateTime::date_create($form->start_time->value ? $form->start_time->value : HabariDateTime::date_create());
     $cron->end_time = $form->end_time->value ? HabariDateTime::date_create($form->end_time->value) : null;
     $cron->description = $form->description->value;
     $cron->cron_class = $form->cron_class->value;
     if (intval(Options::get('next_cron')) > $cron->next_run->int) {
         Options::set('next_cron', $cron->next_run->int);
     }
     if ($cron->update()) {
         Session::notice(_t('Cron Job saved.', 'crontabmanager'));
     } else {
         Session::error(_t('Could not save Cron Job.', 'crontabmanager'));
     }
 }
Esempio n. 10
0
 public function Query($string, $db = NULL, $table = NULL, $writePrefix = 1)
 {
     $setTable = $db ? $db . ".dbo." . $table : $table;
     $string = str_replace("{*TABLE*}", $setTable, $string);
     $Query = self::$dbDriver->Query($string);
     if (!$Query) {
         parent::loadWrite("QUERY ERROR: " . $string, $writePrefix);
         return FALSE;
     }
     return $Query;
 }
Esempio n. 11
0
<?php

namespace Ventus\Survey;

//============================================================================================
// Config
//============================================================================================
require '../includes/php/bootstrap.php';
// SET SESSION to be cron specific, and set user_id to be 0
$SESSION = new \Zend_Session_Namespace('survey', true);
$SESSION->user_id = CRON_USER_ID;
//============================================================================================
// Models
//============================================================================================
$survey = new CronJob($dbo);
//============================================================================================
// Cron job: Run the crojob every day
// Send students who went to Ventus two days ago a survey link by e-mail
//============================================================================================
$survey->runAll();