Пример #1
0
 public function samMaintenance()
 {
     $options = self::getSettings();
     if (false === ($mDate = get_transient('sam_maintenance_date'))) {
         $date = new DateTime('now');
         if ($options['mail_period'] == 'monthly') {
             $date->modify('+1 month');
             $nextDate = new DateTime($date->format('Y-m-01 02:00'));
             $diff = $nextDate->format('U') - $_SERVER['REQUEST_TIME'];
         } else {
             $dd = 8 - (int) $date->format('N');
             $date->modify("+{$dd} day");
             $nextDate = new DateTime($date->format('Y-m-d 02:00'));
             $diff = (8 - (int) $date->format('N')) * DAY_IN_SECONDS;
         }
         $format = get_option('date_format') . ' ' . get_option('time_format');
         set_transient('sam_maintenance_date', $nextDate->format($format), $diff);
         if ($options['mailer'] || $options['keepStats'] > 0) {
             include_once 'sam.tools.php';
             if ($options['mailer']) {
                 $mailer = new SamMailer($options);
                 $mailer->sendMails();
             }
             if ($options['keepStats'] > 0) {
                 $cleaner = new SamStatsCleaner(self::getSettings());
                 $cleaner->clear();
             }
         }
     }
 }
Пример #2
0
                 echo json_encode(array('success' => true));
             } else {
                 echo json_encode(array('success' => false));
             }
         } else {
             echo json_encode(array('success' => false));
         }
     } else {
         echo json_encode(array('success' => false));
     }
     break;
 case 'sam_ajax_sam_maintenance':
     if (false === ($mDate = get_transient('sam_maintenance_date')) && $options['mailer']) {
         include_once 'sam.tools.php';
         $mailer = new SamMailer($options);
         $samSM = $mailer->sendMails();
         $date = new DateTime('now');
         if ($options['mail_period'] == 'monthly') {
             $date->modify('+1 month');
             $nextDate = new DateTime($date->format('Y-m-01 02:00'));
             $diff = $nextDate->format('U') - $_SERVER['REQUEST_TIME'];
         } else {
             $dd = 8 - (int) $date->format('N');
             $date->modify("+{$dd} day");
             $nextDate = new DateTime($date->format('Y-m-d 02:00'));
             $diff = (8 - (int) $date->format('N')) * DAY_IN_SECONDS;
         }
         $format = get_option('date_format') . ' ' . get_option('time_format');
         set_transient('sam_maintenance_date', $nextDate->format($format), $diff);
         echo json_encode(array('success' => true, 'send_mail' => $samSM));
     } else {