コード例 #1
0
ファイル: nitro.php プロジェクト: artlabsdesign/missbloom
 public function cron()
 {
     $this->load->model('tool/nitro');
     $this->model_tool_nitro->loadCore();
     if (!$this->model_tool_nitro->from_cron_url()) {
         return;
     }
     if (!getNitroPersistence('CRON.Remote.Delete')) {
         return;
     }
     $tasks = array();
     $now = time();
     if (getNitroPersistence('CRON.Remote.Delete')) {
         $period = getNitroPersistence('PageCache.ExpireTime');
         $period = !empty($period) ? $period : NITRO_PAGECACHE_TIME;
         $tasks[] = '- Delete files older than ' . date('Y-m-d H:i:s', $now - $period);
         cleanNitroCacheFolders('index.html', $period);
     }
     if (getNitroPersistence('CRON.Remote.SendEmail')) {
         $subject = 'NitroPack Remote CRON job';
         $message = 'Time of execution: ' . date('Y-m-d H:i:s', $now) . PHP_EOL . PHP_EOL;
         $message .= 'Executed tasks: ' . PHP_EOL . implode(PHP_EOL, $tasks) . PHP_EOL . PHP_EOL;
         sendNitroMail(getOpenCartSetting('config_email'), $subject, $message);
     }
 }
コード例 #2
0
ファイル: cron.php プロジェクト: artlabsdesign/missbloom
if (!isCli()) {
    exit;
}
// We expect this to always be on, but just in case...
if (!getNitroPersistence('CRON.Local.Status')) {
    exit;
}
if (!getNitroPersistence('CRON.Local.PreCache') && !getNitroPersistence('CRON.Local.Delete')) {
    exit;
}
$tasks = array();
if (getNitroPersistence('CRON.Local.Delete')) {
    $period = getNitroPersistence('PageCache.ExpireTime');
    $period = !empty($period) ? $period : NITRO_PAGECACHE_TIME;
    $tasks[] = '- Delete files older than ' . date('Y-m-d H:i:s', $now - $period);
    cleanNitroCacheFolders('index.html', $period);
}
if (getNitroPersistence('CRON.Local.PreCache')) {
    $precache_progress = '- Precache sitemap files.';
    $token = getNitroPersistence('CRON.Remote.Token');
    $url = HTTP_SERVER . 'index.php?route=tool/nitro/get_pagecache_stack&cron_token=' . $token;
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    $data = curl_exec($ch);
    curl_close($ch);
    if (!empty($data)) {
        $urls = json_decode($data);
        $total = count($urls);