public function repost() { $id = (int) $this->input->get('id'); if (IS_POST || $this->callback && isset($_GET['submit'])) { // 执行转发操作 $content = trim(dr_safe_replace($this->callback ? $this->input->get('content') : $this->input->post('content'))); if (!$content) { if ($this->callback) { exit($this->callback . '(' . dr_json(0, lang('m-250')) . ')'); } else { exit(dr_json(0, lang('m-250'))); } } // 验证字数 if (($num = (int) $this->get_cache('member', 'setting', 'sns_post_num')) && strlen($content) > $num) { if ($this->callback) { exit($this->callback . '(' . dr_json(0, lang('m-213')) . ')'); } else { exit(dr_json(0, lang('m-213'))); } } $this->member_model->add_sns($this->uid, $content, '', 0, $id); if ($this->callback) { exit($this->callback . '(' . dr_json(1, lang('m-251')) . ')'); } else { exit(dr_json(1, lang('m-251'))); } } // 转发数据 $data = dr_sns_feed($id); if (!$data) { exit(lang('m-249')); } $data = $data['repost_id'] ? dr_sns_feed($data['repost_id']) : $data; // 表情符号 $this->load->helper('directory'); $this->template->assign('emotion', directory_map(FCPATH . 'member/statics/emotions/', 1)); $this->template->assign(array('data' => $data, 'group' => $this->db->where('uid', $this->uid)->order_by('ctime desc')->get('sns_follow_group')->result_array())); if ($this->callback) { ob_start(); $this->template->display('sns_repost.html'); $html = ob_get_contents(); ob_clean(); exit($this->callback . '(' . json_encode(array('html' => $html)) . ')'); } else { $this->template->display('sns_repost.html'); } }
/** * 附件管理 */ public function attachment() { $ext = dr_safe_replace($this->input->get('ext')); $table = $this->input->get('module'); $this->load->model('attachment_model'); if ($this->input->get('action') == 'more') { // ajax更多数据 $page = max((int) $this->input->get('page'), 1); $data = $this->attachment_model->limit($this->uid, $page, $this->pagesize, $ext, $table); if (!$data) { exit('null'); } $this->template->assign(array('list' => $data)); $this->template->display('account_attachment_data.html'); } else { // 检测可管理的模块 $module = array(); $modules = $this->get_cache('module', SITE_ID); if ($modules) { foreach ($modules as $dir) { $mod = $this->get_cache('module-' . SITE_ID . '-' . $dir); if ($this->_module_post_catid($mod, $this->markrule)) { $module[$dir] = $mod['name']; } } } $data = $this->attachment_model->limit($this->uid, 1, $this->pagesize, $ext, $table); $acount = $this->get_cache('member', 'setting', 'permission', $this->markrule, 'attachsize'); $acount = $acount ? $acount : 1024000; $ucount = $this->db->select('sum(`filesize`) as total')->where('uid', (int) $this->uid)->limit(1)->get('attachment')->row_array(); $ucount = (int) $ucount['total']; $acount = $acount * 1024 * 1024; $scount = max($acount - $ucount, 0); $this->template->assign(array('ext' => $ext, 'list' => $data, 'table' => $table, 'module' => $module, 'acount' => $acount, 'ucount' => $ucount, 'scount' => $scount, 'moreurl' => 'index.php?c=' . $this->router->class . '&m=' . $this->router->method . '&ext=' . $ext . '&action=more')); $this->template->display('account_attachment_list.html'); } }
/** * 发送短消息 * * @param intval $fromuid 发送者uid * @param string $fromusername 发送者username * @param array $data 发送数据 * @return string */ public function send($fromuid, $fromusername, $data) { if (!$fromuid || !$fromusername || !$data['username'] || !$data['message']) { return lang('m-062'); } $subject = dr_safe_replace(htmlspecialchars($data['subject'])); $message = dr_safe_replace(htmlspecialchars($data['message'])); // 查询会员数据 $member = array(); $username = explode(',', $data['username']); foreach ($username as $name) { $uid = get_member_id($name); if ($uid) { $member[$uid] = $name; } } if (!$member) { return lang('m-066'); } // 建立对应关系 $relationship = $existplid = $pm_member_insertsql = array(); // 多个对象是,关系数组为多位数组 foreach ($member as $key => $value) { if ($fromuid == $key) { return lang('m-067'); } //$key是接收者id $relationship[$key] = $this->_relationship($fromuid, $key); } // 处理标题 $subject = !$subject ? dr_strcut(dr_clearhtml($message), 80) : $subject; // 作为最后一条消息内容 $lastsummary = dr_strcut(dr_clearhtml($message), 150); // 短消息会话表中按“对应关系”来查询 $list = $this->db->select('plid, min_max')->where_in('min_max', $relationship)->get('pm_lists')->result_array(); if ($list) { foreach ($list as $t) { $existplid[$t['min_max']] = $t['plid']; // 获取到该关系的plid } } // 最后一条消息的数据组装 $lastmessage = array('lastauthorid' => $fromuid, 'lastauthor' => $fromusername, 'lastsummary' => $lastsummary); $lastmessage = dr_array2string($lastmessage); // 按照对应关系来插入消息表中,当对应关系在库中不存在时,重新创建一个对应关系表 foreach ($relationship as $key => $value) { if (!isset($existplid[$value])) { // 插入新的列表id $this->db->insert('pm_lists', array('authorid' => $fromuid, 'author' => $fromusername, 'pmtype' => 1, 'subject' => $subject, 'members' => 2, 'min_max' => $value, 'dateline' => SYS_TIME, 'lastmessage' => $lastmessage)); // 获取会话列表ID $plid = $this->db->insert_id(); // 将列表id插入到消息索引表中 $this->db->insert('pm_indexes', array('plid' => $plid)); // 得到一个短消息ID $pmid = $this->db->insert_id(); // 以回话列表id作为散列存储 $this->db->insert($this->_pm_tablename($plid), array('pmid' => $pmid, 'plid' => $plid, 'authorid' => $fromuid, 'message' => $message, 'dateline' => SYS_TIME, 'delstatus' => 0)); // 存储到“接受者的”消息状态表 $this->db->insert('pm_members', array('plid' => $plid, 'uid' => $key, 'isnew' => 1, 'pmnum' => 1, 'lastupdate' => 0, 'lastdateline' => SYS_TIME)); // 存储到“发送者的”消息状态表 $this->db->insert('pm_members', array('plid' => $plid, 'uid' => $fromuid, 'isnew' => 0, 'pmnum' => 1, 'lastupdate' => SYS_TIME, 'lastdateline' => SYS_TIME)); } else { // 获取上面查询的会话列表ID $plid = $existplid[$value]; // 将列表id插入到消息索引表中 $this->db->insert('pm_indexes', array('plid' => $plid)); // 得到一个短消息ID $pmid = $this->db->insert_id(); // 以回话列表id作为散列存储 $this->db->insert($this->_pm_tablename($plid), array('pmid' => $pmid, 'plid' => $plid, 'authorid' => $fromuid, 'message' => $message, 'dateline' => SYS_TIME, 'delstatus' => 0)); // 存储到“接受者的”消息状态表 if ($this->db->where('plid', $plid)->where('uid', $key)->count_all_results('pm_members')) { // 如果已经存在了就更新状态表 $this->db->where('plid', $plid)->where('uid', $key)->set('isnew', 1)->set('lastdateline', SYS_TIME)->set('pmnum', 'pmnum+1', FALSE)->update('pm_members'); } else { $this->db->insert('pm_members', array('plid' => $plid, 'uid' => $key, 'isnew' => 1, 'pmnum' => 1, 'lastupdate' => 0, 'lastdateline' => SYS_TIME)); } // 存储到“发送者的”消息状态表 if ($this->db->where('plid', $plid)->where('uid', $fromuid)->count_all_results('pm_members')) { // 如果已经存在了就更新状态表 $this->db->where('plid', $plid)->where('uid', $fromuid)->set('isnew', 0)->set('lastdateline', SYS_TIME)->set('pmnum', 'pmnum+1', FALSE)->update('pm_members'); } else { $this->db->insert('pm_members', array('plid' => $plid, 'uid' => $fromuid, 'isnew' => 0, 'pmnum' => 1, 'lastupdate' => SYS_TIME, 'lastdateline' => SYS_TIME)); } // 更新最后一条消息信息 $this->db->where('plid', $plid)->set('lastmessage', $lastmessage)->update('pm_lists'); } } // 插入用户的新短消息表 foreach ($member as $key => $value) { $this->db->replace('newpm', array('uid' => $key)); } return NULL; }
/** * 保存分组 */ public function group_save() { $gid = intval($this->input->post('gid')); $title = trim(dr_safe_replace($this->input->post('title'))); if (!$title) { exit(dr_json(0, lang('m-245'))); } $this->db->where('id', $gid)->where('uid', $this->uid)->update('sns_follow_group', array('title' => $title)); exit(dr_json(1, '')); }