예제 #1
0
 public function sendTo($data = array())
 {
     if (!$data) {
         return FALSE;
     }
     $this->emailParam['to'] = $data['to'];
     $this->emailParam['from'] = $data['from'] ? $data['from'] : $this->settings['sendcloud']['from'];
     //需要审核的域名
     $this->emailParam['fromname'] = $data['fromname'] ? $data['fromname'] : $this->settings['sendcloud']['fromname'];
     $this->emailParam['html'] = html_entity_decode(hg_back_value($data['content']));
     $options = array('http' => array('method' => 'POST', 'content' => http_build_query($this->emailParam)));
     $context = stream_context_create($options);
     $result = file_get_contents($this->settings['sendcloud']['url'], false, $context);
     $result = json_decode($result, 1);
     if ($result && is_array($result) && $result['message'] == 'success') {
         return TRUE;
         //发送成功
     } else {
         return FALSE;
         //发送失败
     }
 }
예제 #2
0
 /**
  * 创建投稿.
  *
  * column_id array('main' => 模块ID,'has_child'=> 1, 'child'=> 子栏目id ,'desc'=> 描述(模块名称>子栏目名称))
  * @param  condition
  * @return Response
  */
 public function create()
 {
     $title = trim($this->input['title']);
     $content = trim($this->input['content']);
     $column_id = $this->input['column_id'];
     $column_path = trim($this->input['column_path']);
     if ($this->input['member_id']) {
         $member_id = $this->input['member_id'];
         $member_name = $this->input['member_name'];
     } elseif ($this->user['user_id']) {
         $member_id = $this->user['user_id'];
         $member_name = $this->user['user_name'];
     }
     $app_id = intval($this->input['app_id']);
     if ($_FILES['photos']) {
         $count = count($_FILES['photos']['name']);
         for ($i = 0; $i < $count; $i++) {
             foreach ($_FILES['photos'] as $k => $v) {
                 $photo[$k] = $_FILES['photos'][$k][$i];
             }
             $contentImage[] = $this->uploadimg($photo);
         }
     }
     $data = array('title' => $title, 'content_image' => $contentImage[0] ? serialize($contentImage) : '', 'column_id' => $column_id, 'column_path' => $column_path, 'member_id' => $member_id, 'member_name' => $member_name, 'app_id' => $app_id, 'create_time' => TIMENOW);
     $this->check_request($data);
     $vid = $this->mode->create($data);
     //创建内容表
     $this->mode->createContent(array('id' => $vid, 'content' => $content));
     if ($vid) {
         $data['id'] = $vid;
         $data['status_text'] = $this->settings['general_audit_status'][0];
         $data['content'] = hg_back_value(html_entity_decode(stripcslashes($content)));
         $data['content_image'] = $contentImage;
         //$this->addLogs('创建',$data,'','创建' . $vid);此处是日志,自己根据情况加一下
         $this->addItem($data);
         $this->output();
     }
 }
예제 #3
0
 /**
  * 会话信息
  * 
  * @param int $session_id  会话ID
  * @param string $field 需要查询的字段 
  * @return array  会话新
  */
 function session_info($session_id, $field = '*', $condition = '')
 {
     if (!$session_id) {
         return false;
     }
     $sql = 'SELECT ' . $field . ' FROM ' . DB_PREFIX . 'session WHERE id = ' . $session_id . $condition;
     $info = $this->db->query_first($sql);
     $sqls = 'SELECT COUNT(*) as total FROM ' . DB_PREFIX . 'session_user WHERE session_id=' . $session_id . '';
     $count = $this->db->query($sqls);
     while ($r = $this->db->fetch_array($count)) {
         if ($info) {
             $info['count'] = $r['total'];
         }
     }
     if ($info) {
         $info['title'] = hg_back_value($info['title']);
         $info['settings'] = $info['settings'] ? unserialize($info['settings']) : array();
         if (isset($info['last_uavatar'])) {
             $info['last_uavatar'] = $info['last_uavatar'] ? unserialize($info['last_uavatar']) : array();
         }
     }
     return $info;
 }
예제 #4
0
 /**
  *
  * @Description  有官方回复优先显示官方回复,其次为推荐答案
  * @author Kin
  * @date 2013-6-14 上午10:23:48
  */
 public function getSeekhelplist($condition, $orderby, $offset, $count, $sort_id = 0)
 {
     if (!$offset && !$count) {
         $limit = '';
     } else {
         $limit = " limit {$offset}, {$count}";
     }
     $sql = 'SELECT  sh.*, c.content
             FROM ' . DB_PREFIX . 'seekhelp  sh
             LEFT JOIN ' . DB_PREFIX . 'content c ON sh.id = c.id
             WHERE 1 ' . $condition . $orderby . $limit;
     $query = $this->db->query($sql);
     $res = array();
     $Ids = array();
     $memberIds = array();
     while ($row = $this->db->fetch_array($query)) {
         $row['title'] = stripcslashes($row['title']);
         $row['content'] = hg_back_value(stripcslashes(urldecode($row['content'])));
         $row['format_create_time'] = date('Y-m-d H:i:s', $row['create_time']);
         $row['status_name'] = $this->settings['seekhelp_status'][$row['status']];
         $row['state'] = $row['status'];
         //只为纪录操作使用,其他无用
         $memberIds[$row['id']] = $row['member_id'];
         $Ids[$row['id']] = $row['reply_id'];
         switch ($row['status']) {
             case 0:
                 $row['status_name'] = '待审核';
                 break;
             case 1:
                 $row['status_name'] = '已审核';
                 break;
             case 2:
                 $row['status_name'] = '被打回';
                 break;
         }
         $res[] = $row;
     }
     $sql = 'SELECT * FROM ' . DB_PREFIX . 'section
             WHERE sort_id=' . $sort_id;
     $query = $this->db->query($sql);
     while ($row = $this->db->fetch_array($query)) {
         $sectionInfo[] = $row;
     }
     foreach ($res as $k => $v) {
         foreach ($sectionInfo as $ko => $vo) {
             if ($v['section_id'] == $vo['id']) {
                 $res[$k]['section_name'] = $vo['name'];
             }
         }
     }
     if (!empty($memberIds)) {
         $member_ids = implode(',', $memberIds);
         //新旧会员处理
         if (defined('SEEKHELP_NEW_MEMBER') && SEEKHELP_NEW_MEMBER) {
             if ($this->settings['App_members']) {
                 $members = array();
                 $temp_members = $this->members->get_newUserInfo_by_ids($member_ids);
                 if ($temp_members && !empty($temp_members) && is_array($temp_members)) {
                     foreach ($temp_members as $val) {
                         $members[$val['member_id']] = $val;
                     }
                 }
                 //hg_pre($members);exit();
             }
         } else {
             if ($this->settings['App_member']) {
                 $members = $this->member->getMemberByIds($member_ids);
                 $members = $members[0];
             }
         }
     }
     if (!empty($Ids)) {
         $materials = $this->handle_materials($Ids);
     }
     foreach ($res as $key => $val) {
         if ($materials && $materials[$val['id']] && is_array($materials[$val['id']])) {
             foreach ($materials[$val['id']] as $k => $v) {
                 $res[$key][$k] = $v;
             }
         }
         if ($members[$val['member_id']]) {
             if (defined('SEEKHELP_NEW_MEMBER') && SEEKHELP_NEW_MEMBER) {
                 $res[$key]['member_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($members[$val['member_id']]['nick_name']) : $members[$val['member_id']]['nick_name'];
                 $res[$key]['member_avatar'] = $members[$val['member_id']]['avatar'];
                 $res[$key]['member_level'] = intval($members[$val['member_id']]['digital']);
             } else {
                 $res[$key]['member_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($members[$val['member_id']]['nick_name']) : $members[$val['member_id']]['nick_name'];
                 $res[$key]['member_avatar'] = array('host' => $members[$val['member_id']]['host'], 'dir' => $members[$val['member_id']]['dir'], 'filepath' => $members[$val['member_id']]['filepath'], 'filename' => $members[$val['member_id']]['filename']);
             }
         }
         //初始化默认值
     }
     //数据异常处理
     $sql = 'DELETE FROM ' . DB_PREFIX . 'materials WHERE flag = 1';
     $this->db->query($sql);
     return $res;
 }