Ejemplo n.º 1
0
 /**
  * 分类导出
  */
 public function store_class_exportOp()
 {
     $lang = Language::getLangContent();
     if (chksubmit()) {
         $model_class = Model('store_class');
         //分类信息
         $class_list = $model_class->getTreeClassList();
         @header("Content-type: application/unknown");
         @header("Content-Disposition: attachment; filename=store_class.csv");
         if (is_array($class_list)) {
             foreach ($class_list as $k => $v) {
                 $tmp = array();
                 //序号
                 $tmp['sc_sort'] = $v['sc_sort'];
                 //深度
                 for ($i = 1; $i <= $v['deep'] - 1; $i++) {
                     $tmp[] = '';
                 }
                 //名称
                 $tmp['sc_name'] = replaceSpecialChar($v['sc_name']);
                 //转码 utf-gbk
                 if (strtoupper(CHARSET) == 'UTF-8') {
                     switch ($_POST['if_convert']) {
                         case '1':
                             $tmp_line = iconv('UTF-8', 'GB2312//IGNORE', join(',', $tmp));
                             break;
                         case '0':
                             $tmp_line = join(',', $tmp);
                             break;
                     }
                 } else {
                     $tmp_line = join(',', $tmp);
                 }
                 $tmp_line = str_replace("\r\n", '', $tmp_line);
                 echo $tmp_line . "\r\n";
             }
         }
         exit;
     }
     Tpl::showpage('store_class.export');
 }
 function editPost()
 {
     //权限判读 (管理员和创建者)
     $pid = isset($_REQUEST['pid']) ? intval($_REQUEST['pid']) : 0;
     $post = $this->post->where('id=' . $pid . ' AND is_del=0')->find();
     //管理员或者帖子主人
     if (!$post) {
         $this->error('帖子回复不存在');
     }
     if (!($this->isadmin || $post['uid'] == $this->mid)) {
         $this->error('无权限');
     }
     if (isset($_POST['editsubmit']) && trim($_POST['editsubmit']) == 'do') {
         $content_i = replaceSpecialChar(h($_POST['content']));
         if (empty($content_i)) {
             $this->error('内容或者标题不能为空');
         }
         $content = h($_POST['content']);
         $map['attach'] = !empty($_POST['attach']) ? serialize($_POST['attach']) : '';
         $map['content'] = $content;
         $ret = $this->post->where('id=' . $pid . " AND istopic=0")->save($map);
         if ($ret) {
             redirect(__APP__ . "/Topic/topic/gid/{$this->gid}/tid/" . $post['tid']);
         } else {
             $this->error('修改失败');
         }
     }
     $this->assign('smileList', $this->getSmile($this->opts['ico_type']));
     $this->assign('smilePath', $this->getSmilePath($this->opts['ico_type']));
     $this->assign('post', $post);
     $this->setTitle($this->siteTitle['edit_topic']);
     $this->display();
 }