Exemple #1
0
 private function data_post($arr)
 {
     foreach ($arr as $key => $a) {
         if (preg_match("/^permit_\\d+\$/i", $key)) {
             $permit[$key] = $a;
         }
     }
     if (is_array(@$permit)) {
         $permit = implode(',', @$permit);
     }
     $str = array('pid' => $this->input->post('pid'), 'cname' => $this->input->post('cname'), 'content' => cleanhtml($this->input->post('content')), 'keywords' => $this->input->post('keywords'), 'master' => $this->input->post('master'), 'permit' => @$permit);
     if ($this->input->post('ico')) {
         $str['ico'] = $this->input->post('ico');
     }
     return $str;
 }
Exemple #2
0
 public function show($topic_id = 1, $page = 1)
 {
     $content = $this->topic_m->get_topic_by_topic_id($topic_id);
     if (!$content) {
         show_message('贴子不存在', site_url('/'));
     } elseif (!$this->auth->user_permit($content['node_id'])) {
         //权限
         show_message('您无权访问此节点中的贴子');
     } else {
         //$this->output->cache(1);
         $content = $this->topic_m->get_topic_by_topic_id($topic_id);
         //取出处理
         $content['content'] = stripslashes($content['content']);
         $data['content'] = $content;
         //if(!$content){
         //	$this->myclass->notice('alert("贴子不存在");window.location.href="'.site_url('/').'";');
         //	exit;
         //}
         //更新浏览数
         $this->db->where('topic_id', $content['topic_id'])->update('topics', array('views' => $content['views'] + 1));
         //评论分页
         $limit = 10;
         $config['uri_segment'] = 4;
         $config['use_page_numbers'] = TRUE;
         $config['base_url'] = site_url('topic/show/' . $topic_id);
         $config['total_rows'] = @$content['comments'];
         $config['per_page'] = $limit;
         $config['prev_link'] = '←';
         $config['first_link'] = '首页';
         $config['last_link'] = '尾页';
         $config['prev_tag_open'] = '<li class=\'prev\'>';
         $config['prev_tag_close'] = '</li';
         $config['cur_tag_open'] = '<li class=\'active\'><span>';
         $config['cur_tag_close'] = '</span></li>';
         $config['num_tag_open'] = '<li>';
         $config['num_tag_close'] = '</li>';
         $config['next_link'] = '&rarr;';
         $config['next_tag_open'] = '<li class=\'next\'>';
         $config['next_tag_close'] = '</li>';
         $config['last_link'] = '尾页';
         $config['last_tag_open'] = '<li class=\'last\'>';
         $config['last_tag_close'] = '</li>';
         $config['num_links'] = 10;
         $this->load->library('pagination');
         $this->pagination->initialize($config);
         $start = ($page - 1) * $limit;
         $data['page'] = $page;
         $data['pagination'] = $this->pagination->create_links();
         //获取评论
         $this->load->model('comment_m');
         $data['comment'] = $this->comment_m->get_comment($start, $limit, $topic_id, $this->config->item('comment_order'));
         //获取当前分类
         $data['cate'] = $this->db->get_where('nodes', array('node_id' => $content['node_id']))->row_array();
         //上下主题
         $data['content']['previous'] = $this->topic_m->get_near_id($topic_id, $data['cate']['node_id'], 0);
         $data['content']['next'] = $this->topic_m->get_near_id($topic_id, $data['cate']['node_id'], 1);
         $data['content']['previous'] = $data['content']['previous']['topic_id'];
         $data['content']['next'] = $data['content']['next']['topic_id'];
         // 判断是不是已被收藏
         $data['in_favorites'] = '';
         $uid = $this->session->userdata('uid');
         if ($uid) {
             $user_fav = $this->db->get_where('favorites', array('uid' => $uid))->row_array();
             if ($user_fav && $user_fav['content']) {
                 if (strpos(' ,' . $user_fav['content'] . ',', ',' . $topic_id . ',')) {
                     $data['in_favorites'] = '1';
                 }
             }
         }
         //关键字tag
         if ($content['keywords']) {
             $data['tags'] = explode(',', $content['keywords']);
             $data['content']['keywords'] = $content['keywords'];
         } else {
             $data['content']['keywords'] = $content['title'];
         }
         //描述
         $data['content']['description'] = sb_substr(cleanhtml($content['content']), 200);
         //自定义tag_url
         $data['tag_url'] = array_keys($this->router->routes, 'tag/show/$1');
         if (is_array(@$data['tags'])) {
             foreach ($data['tags'] as $k => $v) {
                 $data['tag_list'][$k]['tag_title'] = $v;
                 $data['tag_list'][$k]['tag_url'] = str_replace('(:any)', urlencode($v), $data['tag_url'][0]);
             }
         }
         //相关贴子
         if (isset($data['tags'])) {
             $this->load->model('tag_m');
             $data['related_topic_list'] = $this->tag_m->get_related_topics_by_tag($data['tags'], 10);
         }
         //set top
         if (@$_GET['act'] == 'set_top') {
             if ($this->auth->is_admin() || $this->auth->is_master($content['node_id'])) {
                 $this->topic_m->set_top($content['topic_id'], $content['is_top']);
                 redirect('topic/show/' . $content['topic_id']);
             } else {
                 show_message('你无权置顶贴子');
             }
         }
         //开启storage config
         $this->load->config('qiniu');
         //获取分类
         $this->load->model('cate_m');
         $data['catelist'] = $this->cate_m->get_all_cates();
         $data['csrf_name'] = $this->security->get_csrf_token_name();
         $data['csrf_token'] = $this->security->get_csrf_hash();
         $this->load->view('topic_show', $data);
     }
 }
            for ($i = (int) $conf->diff_buffer_size; $i > 0; $i--) {
                $old_str .= $old_data[$off_set + (int) $conf->diff_buffer_size * 2 - $i];
            }
            $on_change = true;
        } else {
            // Change continuation
            $new_str .= $flow;
            for ($i = (int) $conf->diff_buffer_size; $i > 0; $i--) {
                $old_str .= $old_data[$off_set + (int) $conf->diff_buffer_size * 2 - $i];
            }
        }
    } else {
        // Identical changes
        if ($closed_change != $change_num) {
            $deleted_changes .= cleanhtml($old_str) . '<cutme>';
            $added_changes .= cleanhtml($new_str) . '<cutme>';
            $new_str = $old_str = '';
            $closed_change++;
        }
        $on_change = false;
    }
    $contents .= $flow;
    $size = $size + (int) $conf->diff_buffer_size;
    if ($size == (int) $conf->diff_buffer_size) {
        $off_sex = $off_set + (int) $conf->diff_buffer_size - 1;
    } else {
        $off_set = $off_set + (int) $conf->diff_buffer_size;
    }
}
// while
fclose($handle);