Example #1
0
 public function send()
 {
     $to = $this->getString('to');
     $title = $this->getString('title');
     $content = $this->getString('content');
     $taskId = $this->getString('taskId');
     common\loadClass::getService('Mail')->send($to, $title, $content, $taskId);
     return null;
 }
Example #2
0
 protected function initUsedModel()
 {
     $pattern = "/(Model)\$/si";
     $vars = get_class_vars(get_class($this));
     $models = common\Utils::preg_grep_keys($pattern, $vars);
     if (!empty($models)) {
         foreach ($models as $model) {
             $this->{$model} = common\loadClass::getModel($model);
         }
     }
 }
Example #3
0
 public function online()
 {
     $olUids = common\Utils::online();
     $idsArr = \array_keys($olUids);
     $where = "id in (" . implode(',', $idsArr) . ")";
     $userInfo = common\loadClass::getService('User')->fetchWhere($where);
     $result = array();
     foreach ($userInfo as $user) {
         $result[$user->id] = $user->hash();
     }
     return $result;
 }
Example #4
0
 public function savereg()
 {
     $username = $this->getString($this->params, 'username');
     $password = $this->getString($this->params, 'password');
     $icon = $this->getString($this->params, 'icon', 'noface.jpg');
     $service = common\loadClass::getService('User');
     $result = $service->addUser($username, $password, $icon);
     if ($result) {
         return common\Utils::jump("main", "main", array("msg" => "注册成功"));
     }
     return common\Utils::showMsg("注册失败");
 }
Example #5
0
 public function getOnlineList()
 {
     $olUids = common\Utils::online();
     if (empty($olUids)) {
         return array();
     }
     $idsArr = \array_keys($olUids);
     $where = "id in (" . implode(',', $idsArr) . ")";
     $userInfo = common\loadClass::getService('User')->fetchWhere($where);
     $result = array();
     foreach ($userInfo as $user) {
         $result[$user->id] = $user->hash();
     }
     $this->sendOne(Request::getFd(), common\Cmd::OLLIST, $result);
 }
Example #6
0
 private function initUsedModel()
 {
     $pattern = "/(Model)\$/si";
     $vars = get_class_vars(get_class($this));
     $models = common\Utils::preg_grep_keys($pattern, $vars);
     if (!empty($models)) {
         foreach ($models as $model) {
             $this->{$model} = common\loadClass::getModel($model);
         }
     }
     //add Service
     $servicePattern = "/(Service)\$/si";
     $services = common\Utils::preg_grep_keys($servicePattern, $vars);
     if (!empty($services)) {
         foreach ($services as $service) {
             $this->{$service} = common\loadClass::getService($service);
         }
     }
 }
Example #7
0
 public function send($to, $title, $content, $taskId)
 {
     $mail = common\loadClass::getPhpMail();
     $mail->isSMTP();
     $mail->Host = ZConfig::getField('mail', 'smtp_host');
     $mail->Port = ZConfig::getField('mail', 'smtp_port', 25);
     $mail->SMTPAuth = true;
     $mail->Username = ZConfig::getField('mail', 'username');
     $mail->Password = ZConfig::getField('mail', 'password');
     $mail->setFrom(ZConfig::getField('mail', 'from', $mail->Username), ZConfig::getField('mail', 'sendname', 'zmail_server'));
     $mail->addAddress($to);
     $mail->Subject = $title;
     $mail->Body = $content;
     if (!$mail->send()) {
         common\Log::info([$taskId, $to, $title, $content, $mail->ErrorInfo], 'error');
         return false;
     }
     common\Log::info([$taskId, $to, $title, $content, $mail->ErrorInfo], 'success');
     return true;
 }
Example #8
0
 public function __construct()
 {
     $this->dao = common\loadClass::getDao('User');
 }
Example #9
0
 public function _after()
 {
     common\loadClass::getDao('User')->closeDb();
 }
Example #10
0
 public function offline()
 {
     common\loadClass::getService('Chat')->offline();
 }
Example #11
0
 private static function getModel($name)
 {
     if (!isset(self::$model[$name])) {
         self::$model[$name] = common\loadClass::getModel($name);
     }
     return self::$model[$name];
 }