getInstance() static public method

static public getInstance ( )
Esempio n. 1
0
 public function notify()
 {
     $log = Logger::getInstance();
     $log->debug('ALIPAY Notify');
     echo 'success';
     exit;
 }
 public function run()
 {
     $users = User::getUserArrayByExpire();
     $notificationMail = Option::get('mail_stop_expire_notification');
     $mailContentTemplate = Option::get('custom_mail_stop_expire_content');
     if (!$notificationMail) {
         Option::set('mail_stop_expire_notification', 0);
         // 设置邮件提醒的系统参数
     }
     $mailer = Mailer::getInstance();
     $mailer->toQueue(true);
     foreach ($users as $user) {
         $user->stop();
         Logger::getInstance()->info('user [' . $user->email . '] 未续费或流量超用已被暂停服务');
         if ($notificationMail) {
             $mail = new Mail();
             $mail->to = $user->email;
             $mail->subject = '[' . SITE_NAME . '] ' . "用户 {$user->nickname},您的账户由于未续费或流量超用已被暂停服务";
             $params = ['nickname' => $user->nickname, 'email' => $user->email, 'useTraffic' => Utils::flowAutoShow($user->flow_up + $user->flow_down), 'transfer' => Utils::flowAutoShow($user->transfer), 'expireTime' => date('Y-m-d H:i:s', $user->expireTime)];
             $mailContent = Utils::placeholderReplace($mailContentTemplate, $params);
             $mailContent .= "<p style=\"padding: 1.5em 1em 0; color: #999; font-size: 12px;\">—— 本邮件由 " . SITE_NAME . " (<a href=\"" . BASE_URL . "\">" . BASE_URL . "</a>) 账户管控系统发送</p>";
             $mail->content = $mailContent;
             $mailer->send($mail);
         }
     }
     // 避免频繁更新 Option 单例对象,循环结束后再执行
     if ($notificationMail) {
         Option::set('mail_queue', 1);
     }
     // 2016-04-26 15:00 - by @Sendya Fixed issue #62
     // User::enableUsersByExpireTime(); // 启用已续费且流量未超过的用户
 }
Esempio n. 3
0
 public function run()
 {
     if (!Option::get('mail_queue')) {
         return;
     }
     Logger::getInstance()->info('mail queue running..');
     $mailer = Mailer::getInstance();
     $mailer->toQueue(false, true);
     // set to queue.
     $mailQueue = MMail::getQueueList();
     if (count($mailQueue) > 0) {
         foreach ($mailQueue as $mail) {
             $mail->delete();
             $mail->content = htmlspecialchars_decode($mail->content);
             Logger::getInstance()->info('send mail to ' . $mail->to);
             $mailer->send($mail);
         }
     } else {
         Option::set('mail_queue', 0);
     }
 }
Esempio n. 4
0
 /**
  * 通知
  * @param array $order
  * @return string
  */
 public function notify(array $order)
 {
     $log = Logger::getInstance();
     $log->debug('Alipay Run..');
     foreach ($order as $key => $v) {
         $log->debug('K:' . $key . ', V:' . $v);
     }
     $t = Trade::getByTrade($order['trade']);
     if (!$t) {
         $trade = new Trade();
         $trade->time = $order['time'];
         $trade->title = $order['title'];
         $trade->trade = $order['trade'];
         $trade->name = $order['name'];
         $trade->amount = $order['amount'];
         $trade->has_notify = 0;
         $trade->save();
     } else {
         if ($t->has_notify == 1) {
             return 'done';
         }
     }
     //MD5加密下当作签名传过去好校验是不是自己的
     $order['sig'] = strtoupper(md5($this->token));
     return "success";
     /*
     $ch = curl_init($this->notify);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($order));
     curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     $response = curl_exec($ch);
     
     
     //print_r($response);
     if(curl_errno($ch)) return curl_error($ch);
     if($response == 'success') {
         $this->db->update('trade',['has_notify' => 1],['AND' => [['trade' => $order['trade']]]]);
         return 'success';
     } else {
         return '服务器未返回正确的参数。';
     }
     */
 }
Esempio n. 5
0
 /**
  * 重发校验码
  * @JSON
  * @Authorization
  */
 public function resend()
 {
     if ($_POST['auth'] == 'y') {
         $user = User::getCurrent();
         $code = Utils::randomChar(10);
         $forgePwdCode['verification'] = $code;
         $forgePwdCode['time'] = time();
         $user->forgePwdCode = json_encode($forgePwdCode);
         $mailer = Mailer::getInstance();
         $mailer->toQueue(false);
         $mail = new Mail();
         $mail->to = $user->email;
         $mail->subject = '[' . SITE_NAME . '] 新账户注册邮箱校验';
         $mail->content = Option::get('custom_mail_verification_content');
         $params = ['code' => $code, 'nickname' => $user->nickname, 'email' => $user->email, 'useTraffic' => Utils::flowAutoShow($user->flow_up + $user->flow_down), 'transfer' => Utils::flowAutoShow($user->transfer), 'expireTime' => date('Y-m-d H:i:s', $user->expireTime), 'REGISTER_URL' => base64_encode($user->email . "\t" . $forgePwdCode['verification'] . "\t" . $forgePwdCode['time'])];
         $mail->content = Utils::placeholderReplace($mail->content, $params);
         $mailer->send($mail);
         $user->save();
         Logger::getInstance()->info('user [' . $user->email . '] find password, code ' . $code);
     }
     return array('error' => 0, 'message' => '重新发送邮件成功。');
 }