Example #1
0
 /**
  * Get whole cached translations data.
  *
  * @access   public
  * @return   array
  * @since    1.0.0-dev
  * @version  1.2.0-dev
  */
 public static function getCachedData()
 {
     if (static::$cachedData === NULL) {
         $cachedData = Cache::get(Router::getLang(), 'i18n');
         if ($cachedData === FALSE) {
             $cachedData = [];
         }
         static::$cachedData = $cachedData;
     }
     return static::$cachedData;
 }
Example #2
0
 /**
  * Main action to run cron jobs.
  *
  * @access   public
  * @since    2.33.0-dev, 2015-06-07
  * @version  2.39.0-dev
  */
 public function actionDefault()
 {
     if (!class_exists('\\Cron\\CronExpression')) {
         throw new Exception\Fatal('Cannot run Cron jobs without proper Cron library.');
     }
     $sTokenFromURL = Router::getParam('token');
     $sTokenFromConfig = Config::get('base.cron_token');
     $iCronJobsCompleted = 0;
     // check Cron token
     if ($sTokenFromURL !== $sTokenFromConfig) {
         throw new Exception\Code404();
     }
     // get all Cron jobs
     $aAllJobs = CronJobsHelper::getCronJobs();
     // count amount of all CRON jobs
     $iCronJobs = count($aAllJobs);
     // run a single CRON job
     foreach ($aAllJobs as $aJobData) {
         $sModule = $aJobData['module'];
         $sJobKey = base64_encode($aJobData[1] . '.' . $aJobData[2]);
         $aCache = Cache::get($sModule . '.' . $sJobKey, 'cron');
         $iRunDate = isset($aCache['time']) ? $aCache['time'] : NULL;
         $oCron = CronExpression::factory($aJobData[0]);
         if ($iRunDate === NULL || $iRunDate < time()) {
             switch ($aJobData[1]) {
                 case 'route':
                     $sURL = Route::factory($aJobData[2])->url();
                     file_get_contents($sURL);
                     break;
                 case 'file':
                 case 'url':
                     file_get_contents($aJobData[2]);
                     break;
                 case 'function':
                     call_user_func($aJobData[2]);
                     break;
             }
             $iNextRun = $oCron->getNextRunDate()->format('U');
             $aCacheToSave = ['time' => $iNextRun, 'last_execution_time' => time(), 'type' => $aJobData[1], 'param' => $aJobData[2]];
             Cache::set($aCacheToSave, $sModule . '.' . $sJobKey, 'cron', 0);
         }
     }
     // log that cron jobs turning on action was completed
     Log::insert('Cron jobs (in amount of ' . $iCronJobs . ') were checked and ' . $iCronJobsCompleted . ' of them were turned on.');
     // end of functionality
     exit;
 }
Example #3
0
 /**
  * Get Cron jobs from all modules of particular web application.
  *
  * @static
  * @access  public
  * @return  array
  * @since   1.1.0-dev
  * @version 1.1.0-dev
  */
 public static function getCronJobs()
 {
     $aAllJobs = [];
     foreach (Config::get('modules') as $sGroupName => $aGroup) {
         foreach (array_keys($aGroup) as $module) {
             $sDir = PATH_MODULES . $sGroupName . DS . $module . DS . 'config';
             $sFilePath = $sDir . DS . 'cron.php';
             if (file_exists($sDir) && file_exists($sFilePath)) {
                 $aCronData = Config::get($module . '.cron', NULL);
                 foreach ($aCronData as &$data) {
                     $jobKey = base64_encode($data[1] . '.' . $data[2]);
                     $aCache = Cache::get($module . '.' . $jobKey, 'cron');
                     $data['job_key'] = $jobKey;
                     $data['module'] = $module;
                     $data['time'] = isset($aCache['time']) ? $aCache['time'] : NULL;
                     $data['last_exe'] = isset($aCache['last_execution_time']) ? $aCache['last_execution_time'] : NULL;
                 }
                 $aAllJobs = array_merge($aAllJobs, $aCronData);
             }
         }
     }
     return $aAllJobs;
 }
Example #4
0
 /**
  * Get data about failed login operations from cache.
  *
  * @static
  * @access  private
  * @return  integer
  * @since   2.1.2-dev
  * @version 2.1.2-dev
  */
 public static function getCachedData()
 {
     $ip = Session::get('ip');
     $cacheData = Cache::get($ip, static::$cacheName);
     return $cacheData;
 }
Example #5
0
 /**
  * ACTION - Index action.
  *
  * @access   public
  * @return   View
  * @since    1.2.0-dev
  * @version  1.2.0-dev
  */
 public function actionIndex()
 {
     $this->setTitle(__('Interface translations'));
     $info = Cache::get('info', 'i18n');
     return View::factory('i18n/backend/index')->bind('info', $info);
 }
Example #6
0
 * @author         Krzysztof Trzos
 * @package        db_update
 * @subpackage     views\backend
 * @since          1.0.1, 2014-09-23
 * @version        1.2.0-dev
 */
use Plethora\Cache;
use Plethora\Form;
?>

<?php 
/* @var $oForm Form */
?>

<?php 
$sUpdateOutput = Cache::get('output', 'dbupdate');
?>

<?php 
echo __('Click the button below to update database.');
echo $oForm->render();
?>

<?php 
if (!empty($sUpdateOutput)) {
    ?>
    <h2><?php 
    echo __('Output data');
    ?>
:</h2>
    <pre><?php