set() public static method

public static set ( $k, $v )
 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(); // 启用已续费且流量未超过的用户
 }
Example #2
0
 /**
  * 淘宝自动发货API
  * 创建卡号
  *
  * @JSON
  */
 public function createCard()
 {
     $CURR_KEY = $_SERVER['HTTP_AUTHORIZATION'];
     if (!$CURR_KEY) {
         header("HTTP/1.1 405 Method Not Allowed");
         exit;
     }
     $KEY = Option::get('SYSTEM_API_KEY');
     if ($KEY == null) {
         $KEY = password_hash(Utils::randomChar(12) . time(), PASSWORD_BCRYPT);
         Option::set('SYSTEM_API_KEY', $KEY);
     }
     $CURR_KEY = str_replace('Basic ', '', $CURR_KEY);
     $CURR_KEY = md5($CURR_KEY . ENCRYPT_KEY);
     $KEY = md5($KEY . ENCRYPT_KEY);
     if (strtoupper($KEY) == strtoupper($CURR_KEY)) {
         $card = new Card();
         $card->card = substr(hash("sha256", time() . Utils::randomChar(10)) . time(), 1, 26);
         $card->add_time = time();
         $card->type = intval(trim($_POST['type']));
         $card->info = trim($_POST['info']);
         $card->status = 1;
         $card->save();
         return array('error' => 0, 'message' => 'success', 'card' => $card);
     } else {
         return array('error' => 1, 'message' => 'Bad Request');
     }
 }
Example #3
0
 public function toQueue($bool, $flag = false)
 {
     $this->queued = $bool;
     if (!$flag) {
         Option::set('mail_queue', $bool === true ? 1 : 0);
     } else {
         Option::set('mail_queue', 1);
     }
 }
 public function isAvailable()
 {
     $className = Utils::getShortName($this);
     $config = Option::get('MAIL_' . $className);
     if (!$config) {
         $_config = array('region' => 'cn-hangzhou', 'accessKey' => 'yourAccessKey', 'accessSecret' => 'yourAccessSecret', 'accountName' => '*****@*****.**', 'tagName' => 'yourTagName', 'alias' => 'SS Cat');
         Option::set('MAIL_' . $className, json_encode($_config));
         // 设定默认配置
         return false;
     }
     return true;
 }
Example #5
0
 public function isAvailable()
 {
     $className = Utils::getShortName($this);
     $config = Option::get('MAIL_' . $className);
     if (!$config) {
         $_config = array('from' => '某科学的H本 <*****@*****.**>');
         Option::set('MAIL_' . $className, json_encode($_config));
         // 设定默认配置
         return false;
     }
     return true;
 }
Example #6
0
 public function isAvailable()
 {
     $className = Utils::getShortName($this);
     $config = Option::get('MAIL_' . $className);
     if (!$config) {
         $_config = array("mailgun_key" => "key-********************", 'mailgun_domain' => 'post.mloli.com', 'from' => '某科学的H本 <*****@*****.**>');
         Option::set('MAIL_' . $className, json_encode($_config));
         // 设定默认配置
         return false;
     }
     return true;
 }
Example #7
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);
     }
 }
Example #8
0
 public function isAvailable()
 {
     $className = Utils::getShortName($this);
     $config = Option::get('MAIL_' . $className);
     if (!$config) {
         $_config = array("server" => "smtp.exmail.qq.com", 'from' => '发件人名 <*****@*****.**>', "address" => "*****@*****.**", "smtp_name" => "*****@*****.**", "smtp_pass" => "请填写密码", "smtp_ssl" => "ssl");
         Option::set('MAIL_' . $className, json_encode($_config));
         // 设定默认配置
         return false;
     }
     return true;
 }
Example #9
0
 public static function fileCheck()
 {
     $channel = Option::get('channel') == 'dev' ?: 'stable';
     $current_version = Option::get("version");
     $data = self::doGet(self::UPDATE_SERVER . "file.json?channel={$channel}&ver={$current_version}");
     if (!$data) {
         return -1;
     }
     // 请求更新服务器失败
     $data = json_decode($data, true);
     $file_list = $data['list'];
     if (!$file_list) {
         return -2;
     }
     // 更新服务器文件列表为空
     $err_file = $list = array();
     foreach ($file_list as $file) {
         $path = $file['path'];
         $hash = $file['hash'];
         $file_hash = md5_file(ROOT_PATH . "{$path}");
         if ($file_hash != $hash) {
             $err_file[] = array($path, $hash);
             $list[] = $path;
         }
     }
     if (!$list) {
         return 0;
     }
     // 无文件更新
     Option::set('new_version', 1);
     sort($list);
     sort($err_file);
     Downloader::save('kk_updater', $err_file);
     Downloader::save('need_download', $err_file);
     return $list;
 }
Example #10
0
 /**
  * @JSON
  * @return array
  * @throws Error
  */
 public function saveCustomMailContent()
 {
     $type = $_POST['custom_type'];
     // 获得修改类型
     if (strpos($type, 'custom_mail_') !== false) {
         $content = $_POST['content'];
         // 取得修改的内容
         if (!$content) {
             throw new Error('Parameter error', 405);
         }
         Option::set('$type', $content);
         return array('error' => 0, 'message' => '保存完毕');
     } else {
         throw new Error('Parameter error', 405);
     }
 }
Example #11
0
 /**
  * 获取下一个端口号
  * @return mixed
  */
 public static function getNewPort()
 {
     $current_port = Option::get('current_port');
     Option::set('current_port', intval($current_port) + 1);
     return $current_port;
 }
Example #12
0
 /**
  * 更新 邮件系统设置
  *
  * @JSON
  */
 public function update()
 {
     $result['error'] = 0;
     $result['message'] = '保存完成';
     foreach ($_POST as $key => $val) {
         if (!empty($val) && strpos($key, 'mail_') !== false) {
             if (strpos($key, 'mailer') === false) {
                 // 判断是否为 mail_mailer <- 这个字段是用于是被当前设定的邮件类名,此配置无需存入数据库
                 $k = str_replace('mail_', '', $key);
                 $data[$k] = trim($val);
             }
         }
     }
     if (!empty($_POST['mail_mailer'])) {
         $config = json_encode($data);
         $mailer = trim($_POST['mail_mailer']);
         Option::set('MAIL_' . $mailer, $config);
         Option::set('MAIL_AVAILABLE', $mailer);
     } else {
         $result['error'] = 1;
         $result['message'] = '保存失败,参数不完整';
     }
     Option::init();
     return $result;
 }