alin';?>

首页 / 唠叨

自己的贴子,自己没法删除,哈哈

By alin •  2017-07-06 11:25:53 •  141次点击
貌似这段有问题,导致发贴慢:
if($_POST && $this->form_validation->run() === TRUE){
   if(time()-$user['lastpost']<$this->config->item('timespan')){
    $this->session->set_flashdata('error', '发帖最小间隔时间是'.$this->config->item('timespan').'秒!');
    redirect('topic/add');
   }
   
   $data = array(
    'title' => $this->input->post ('title'),
    'content' => $this->input->post ('content'),
    'node_id' => $node_id,
    'uid' => $uid,
    'addtime' => time(),
    'updatetime' => time(),
    'lastreply' => time(),
    'views' => 0,
    'ord'=>time()
   );
   $this->load->helper('format_content');
   $data['content']=format_content($data['content']);
   //开启审核时
   if($this->config->item('is_approve')=='on'){
    $data['is_hidden'] = 1; 
   }
   
   //标签
   $this->load->model('tag_m');
   if($this->config->item('auto_tag') =='on'){
    //自动获取关键词tag
    $data['keywords'] = $this->tag_m->get_tag_auto(strip_tags($data['title']), strip_tags($data['content']));
   } else{
    $data['keywords'] = $this->input->post ('keywords', true);
   }
   
   
   if($this->topic_m->add($data)){
    //最新贴子id
    $new_topic_id = $this->db->insert_id();
    
    //入tag表
    $this->tag_m->insert_tag($data['keywords'], $new_topic_id);
    
    //更新贴子数
    $this->db->set('listnum','listnum+1',false)->where('node_id',$node_id)->update('nodes');
    //更新统计
    $this->db->set('value','value+1',false)->where('item','total_topics')->update('site_stats');
    $stats=$this->db->where('item','today_topics')->get('site_stats')->row_array();
    if(!is_today(@$stats['update_time'])){
     $this->db->set('value',@$stats['value'],false)->set('update_time',time(),false)->where('item','yesterday_topics')->update('site_stats');
     $value=1;
    } else{
     $value='value+1';
    }
    $this->db->set('value',$value,false)->set('update_time',time(),false)->where('item','today_topics')->update('site_stats');
    //更新数据库缓存
    $this->db->cache_delete('/default', 'index');
    //更新发贴人的贴子数/最后发贴时间
    $this->db->set('lastpost',time(),false)->set('topics','topics+1',false)->where('uid',$uid)->update('users');
    //更新会员积分
    $this->config->load('userset');
    $this->user_m->update_credit($uid,$this->config->item('credit_post'));
    //审核未开启时
    if($this->config->item('is_approve')=='off'){
     redirect('topic/show/'.$new_topic_id); 
    } else {
     show_message('贴子通过审核才能在前台显示',site_url()); 
    }
   }

  }
0 回复 | 直到2017-09-23 01:01添加回复

回复

登录发表 or 还没有账号?去注册

StartBBS

现在注册 已注册请 登入
唠叨

大家一起来唠叨唠叨

此节点 新建话题 上一贴 下一贴

捐助startbbs