コード例 #1
0
 public function getList()
 {
     if (!extension_loaded('curl')) {
         $this->error('糗事百科插件需要开启PHP的CURL扩展');
     }
     $lists = S('QiuBai_content');
     if (!$lists) {
         $config = \Common\Controller\Addon::getConfig('QiuBai');
         $content = \Org\Net\Http::fsockopenDownload('http://www.qiushibaike.com');
         if ($content) {
             $regex = "/<div class=\"content\".*?>.*?--(.*?)--.*?<\\/div>/ism";
             preg_match_all($regex, $content, $match);
             $lists = array_map(function ($a, $b) {
                 return array('time' => time_format($a), 'content' => $b);
             }, $match[1], $match[0]);
             S('QiuBai_content', $lists, $config['cache_time']);
         }
     }
     if ($lists) {
         $this->success('成功', '', array('data' => $lists));
     } else {
         $this->error('获取糗事百科列表失败');
     }
     $this->assign('qiubai_list', $lists);
 }
コード例 #2
0
 /**
  * 系统邮件发送函数
  * @param string $receiver 收件人
  * @param string $subject 邮件主题
  * @param string $body 邮件内容
  * @param string $attachment 附件列表
  * @return boolean
  * @author jry <*****@*****.**>
  */
 function sendMail($receiver, $subject = '', $body = '', $attachment = null)
 {
     $addon_config = \Common\Controller\Addon::getConfig('Email');
     if ($addon_config['status']) {
         if (1 == $addon_config['MAIL_SMTP_TYPE']) {
             $mailHeader = "MIME-Version: 1.0" . "\r\n";
             $mailHeader .= "Content-type:text/html;charset=utf-8" . "\r\n";
             $mailHeader .= 'From: ' . C('WEB_SITE_TITLE') . '<' . $addon_config['MAIL_SMTP_USER'] . '>' . "\r\n";
             return mail($receiver, $subject, $body, $mailHeader) ? true : "邮件发送错误";
         } else {
             $mail_body_template = $addon_config['default'];
             //获取邮件模版配置
             $mail_body = str_replace("[MAILBODY]", $body, $mail_body_template);
             //使用邮件模版
             $mail = new \Common\Util\Email();
             $mail->setServer($addon_config['MAIL_SMTP_HOST'], $addon_config['MAIL_SMTP_USER'], $addon_config['MAIL_SMTP_PASS'], $addon_config['MAIL_SMTP_PORT'], $addon_config['MAIL_SMTP_SECURE']);
             //设置smtp服务器
             $mail->setFrom($addon_config['MAIL_SMTP_USER']);
             //设置发件人
             $mail->setReceiver($receiver);
             //设置收件人,多个收件人,调用多次
             $mail->setMail($subject . '|' . C('WEB_SITE_TITLE'), $mail_body);
             //设置邮件主题、内容
             return $mail->sendMail() ? true : false;
             //发送
         }
     } else {
         return false;
     }
 }
コード例 #3
0
 public function __construct()
 {
     parent::__construct();
 }