您好,欢迎访问一九零五行业门户网

thinkphp3.12无限级留言与回复的留言板模块

本留言板程序使用了无限级分类的原理,可以实现无限级留言与回复。留言列表gclist保留了留言层次空格,使留言--回复层次分明.
功能上,本程序可以实现无限级留言与回复,即对留言回复,对回复的留言回复。当然你也可以作有限制的控制,使其只对留言回复,关键是在模板代码中去掉回复的留言中的“回复该留言”即可。欢迎去拍砖!
程序效果演示:w3note点com/guestbook
完整的留言程序代码下载:www点w3note点com-- ----------------------------
-- table structure for `wb_guestbook`
-- ----------------------------
drop table if exists `wb_guestbook`;
create table `eway_guestbook` (
  `id` int(10) unsigned not null auto_increment,
  `pid` int(10) not null,
  `email` varchar(50) not null,
  `path` varchar(100) not null,
  `username` varchar(30) not null,
  `updatetime` int(10) not null,
  `ip` varchar(15) not null,
  `url` varchar(200) not null,
  `inputtime` int(10) not null,
  `content` text not null,
  `verify` varchar(32) not null,
  `isreply` tinyint(1) not null,
  `status` tinyint(1) not null,
  primary key (`id`)
) engine=myisam auto_increment=42 default charset=utf8;
控制器guestbookaction.class.php
gclist(id,username,inputtime,pid,url,content,path,concat(path,'-',id) as bpath);
$this->assign('gklist', $garr['list']);
        $this->assign('page',$garr['page']);
        $this->display();
    }
// +----------------------------------------------------------------------
// | 添加留言
// +----------------------------------------------------------------------
public function add(){
        $this->adddata('guestbook');
}
// +----------------------------------------------------------------------
// | 网址跳转。如在表单url添加网址的话,点击会跳转到相关网站
// +----------------------------------------------------------------------
public function tourl(){
      $this->gettourl('guestbook');
      } 
}
?>
10){                
                return $data= msubstr($_post['username'],0,5);
            }else{
                return $data= $_post['username'];
            }
        }    
        } 
// +----------------------------------------------------------------------
// | path()返回子类的path,父类的path的值为0
// +----------------------------------------------------------------------    
     public function path(){
           $pid=isset($_post['pid'])?(int)$_post['pid']:0;
           $id=$_post['id'];
            if($pid==0){                
                return 0;
            }
$fat=$this->where(array('id' => $pid))->find();
            $data=$fat['path'].'-'.$fat['id'];            
            return $data;
        }
// +----------------------------------------------------------------------
// | content()过滤留言内容
// +----------------------------------------------------------------------          
    public function content() {
        if (isset ($_post['content']) && !empty ($_post['content'])) {
             $data =deletehtmltags($_post['content']);
             $data =safehtml($data);
            if (strlen($data) > 1000) {
                $data = msubstr($data, 0, 500);
            }
            return $data;
          }
           }
 // +----------------------------------------------------------------------
// | content()过滤url
// +----------------------------------------------------------------------              
    public function geturl(){
        if (isset ($_post['url'])) {
        $data = deletehtmltags($_post['url']);
        $data = safehtml($data);
        return $data=$data?$data:;
        }
    }    
// +----------------------------------------------------------------------
// |gclist($field,$where='',$pagesize=30)留言列表
// +----------------------------------------------------------------------
// |$field,字段
// +----------------------------------------------------------------------
// |$where查询条件,默认为空
// +----------------------------------------------------------------------
// |$pagesize分页记录,默认为30    
// +----------------------------------------------------------------------
// |使用方法,看上面的控制器调用
// +----------------------------------------------------------------------
public function gclist($field,$where='',$pagesize=30) {
      import(org.util.page);
                $count = $this->field('id')->where($where)->count();
     $p = new page($count, $pagesize);
$list=$this->field($field)->where($where)->order('bpath,id')->limit($p->firstrow . ',' . $p->listrows)->select();
foreach ($list as $k => $v) {
            $list[$k]['count'] = count(explode('-', $v['bpath']));
          $list[$k]['tousername']=$this->where(array('id'=> $v['pid']))->getfield('username');
            $str = '';
            if ($v['pid']  0) {
                for ($i = 0; $i                     $str .= ' ';
                }
                $str .= ' ';
            }
            $list[$k]['space'] = $str;
        }
        $p->setconfig('header', '篇');
        $p->setconfig('prev', «);
        $p->setconfig('next', '»');
        $p->setconfig('first', '|«');
        $p->setconfig('last', '»|');
        $page = $p->show();
        $arr=array('page'=>$page,'list'=>$list);
        return $arr;
    }
}
?>
ad:真正免费,域名+虚机+企业邮箱=0元
其它类似信息

推荐信息