/**
  * Записываем в файл log.ini. Очищаем файл каждые timeCleanLog суток. Отправляем содиржимое файла на email перед очисткой.
  * @return Boolean
  */
 public function log()
 {
     $this->ip = $this->getIP();
     $this->ips = $this->getIPs();
     $this->url = $this->getURL();
     $file = file($this->dataWrite);
     $txt = $this->url . ";";
     $dtime = date("d.m.y_G:i");
     $txt .= $dtime . ";";
     $txt .= $this->name . ";";
     $txt .= $this->tel . ";";
     foreach ($this->ips as $key => $value) {
         $txt .= $value . ";";
     }
     $txt .= "\n";
     if (isset($file[0]) && !empty($file[0])) {
         $firstLine = explode(";", $file[0]);
         // Вытягиваем первую строку файла log.ini
         $date = explode(".", str_replace('_', '.', $firstLine[1]));
         // Вытягиваем дату. Преобразуем к удобному формату. Разбиваем на отдельные части (год, месяц ...)
         $time = explode(":", $date[3]);
         // Разбиваем врем на отдельные части
         $unixTime = mktime($time[0], $time[1], 0, $date[1], $date[0], $date[2]);
         // Переводим в UNIXTIME
         $period = $this->timeCleanLog * 24 * 60 * 60;
         // Период за через который будем очищать log файл
         $timeNow = time();
         // Текущее время
         if ($timeNow > $unixTime + $period) {
             // Очищаем log файл если прошло больше чем $timeCleanLog суток
             // Отправляем письмо с содержанием log файла перед его очисткой.
             $subject = $dtime . " - Log файл  - " . $_SERVER['HTTP_HOST'];
             $message = "Log файл очистился за период: " . $this->timeCleanLog . " суток \n\n";
             $message .= "Содержимое файла:\n\n";
             foreach ($file as $key => $value) {
                 $message .= "\t{$value} \n";
             }
             $mail = new MailHelper();
             $mail->config->fromMail = '*****@*****.**';
             $mail->config->fromName = 'log';
             //$mail->addMail('*****@*****.**');
             $mail->addMail('*****@*****.**');
             $mail->sendMail($subject, $message, false);
             file_put_contents($this->dataWrite, "");
             // Очищаем файл dataWrite (log.ini) после отправки информации на email.
         }
     }
     file_put_contents($this->dataWrite, $txt, FILE_APPEND);
     // Записываем информацию в файл dataWrite (log.ini)
     return true;
 }
 protected function notifyAdmin($offenderID)
 {
     $offender = UserInfo::getByID($offenderID);
     $ue = new \Concrete\Core\User\Event\UserInfo($offender);
     Events::dispatch('on_private_message_over_limit', $ue);
     $admin = UserInfo::getByID(USER_SUPER_ID);
     Log::addEntry(t("User: %s has tried to send more than %s private messages within %s minutes", $offender->getUserName(), \Config::get('concrete.user.private_messages.throttle_max'), \Config::get('concrete.user.private_messages.throttle_max_timespan')), t('warning'));
     Loader::helper('mail');
     $mh = new MailHelper();
     $mh->addParameter('offenderUname', $offender->getUserName());
     $mh->addParameter('profileURL', BASE_URL . View::url('/profile', 'view', $offender->getUserID()));
     $mh->addParameter('profilePreferencesURL', BASE_URL . View::url('/profile/edit'));
     $mh->to($admin->getUserEmail());
     $mh->load('private_message_admin_warning');
     $mh->sendMail();
 }
		protected function notifyAdmin($offenderID) {
			$offender = UserInfo::getByID($offenderID);
			Events::fire('on_private_message_over_limit', $offender);
			$admin = UserInfo::getByID(USER_SUPER_ID);
			
			Log::addEntry(t("User: %s has tried to send more than %s private messages within %s minutes", $offender->getUserName(), USER_PRIVATE_MESSAGE_MAX, USER_PRIVATE_MESSAGE_MAX_TIME_SPAN),t('warning'));
			
			Loader::helper('mail');
			$mh = new MailHelper();
			
			$mh->addParameter('offenderUname', $offender->getUserName());
			$mh->addParameter('profileURL', BASE_URL . View::url('/profile', 'view', $offender->getUserID()));
			$mh->addParameter('profilePreferencesURL', BASE_URL . View::url('/profile/edit'));
			
			$mh->to($admin->getUserEmail());
			$mh->load('private_message_admin_warning');
			$mh->sendMail();
		}
Beispiel #4
0
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>发送邮件</title>
    <script src="../js/jumpTo.js"></script>
</head>
<body>
<?php 
/**
 * User: WQH
 * Date: 15/12/19
 * Time: 下午7:27
 */
require_once 'MailHelper.php';
$mailName = $_POST['mailName'];
$mailAddress = $_POST['mailAddress'];
$mailSubject = $_POST['mailSubject'];
//Debug
//echo 'mailName = ' . $mailName . '<br>';
//echo 'mailAddress = ' . $mailAddress . '<br>';
//echo 'mailSubject = ' . $mailSubject . '<br>';
$mHelper = new MailHelper();
if ($mHelper->sendMail($mailName . '(' . $mailAddress . ')' . "给我的反馈", $mailSubject)) {
    //echo "操作成功,<span id = \"jumpTo\">5</span>秒后将自动跳转到主页.. <script type = \"text/javascript\">countDown(5, 'http://www.wangqihang.cn/');</script>";
}
?>

</body>
</html>

Beispiel #5
0
            break;
        }
    }
}
// if data not empty then store into DB
if (!empty($data)) {
    Debug::logi("Seems to be a valid request... Try to decode JSON and save to DB.", 'REPORT');
    $json = json_decode($data, true);
    // check if device is in exception list
    if (isset($json['device_id']) && !empty($json['device_id']) && $cfg->isInReportExceptionDevices($json['device_id'])) {
        Debug::logi("Report ignored, device " . $json['device_id'] . " is in exception list.");
        exit;
    }
    // open db connection
    DBHelper::open();
    $values = ReportHelper::buildMySQLValuesArr($json);
    $result = DBHelper::insertReport($values);
    if (!$result) {
        Debug::loge('Inserting report data failed ! ' . DBHelper::getLastError(), 'REPORT');
        Debug::loge('Report content ' . print_r($values, true), 'REPORT');
    } else {
        Debug::logi('Report inserted with success !', 'REPORT');
    }
    if ($cfg->sendMailOnReportReceived()) {
        $package = explode('.', $json['PACKAGE_NAME']);
        MailHelper::sendMail($cfg->getReportMailRecipients(), '[MABL] New ' . (isset($json['IS_SILENT']) && $json['IS_SILENT'] > 0 ? 'SILENT ' : '') . 'report received for ' . $package[count($package) - 1] . ' !', ReportHelper::createMailContent(!$result, $package, $json));
    }
    DBHelper::close();
} else {
    Debug::loge('Invalid report request data ! ' . print_r($_REQUEST, true), 'REPORT');
}