欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ThinkPHP無限級分類原理實現(xiàn)留言與回復(fù)功能實例

 更新時間:2014年10月31日 11:57:47   投稿:shichen2014  
這篇文章主要介紹了ThinkPHP無限級分類原理實現(xiàn)留言與回復(fù)功能實例,并附帶有完整的項目源碼下載供大家學(xué)習(xí)參考,非常具有實用價值,需要的朋友可以參考下

本文所述留言板程序使用了無限級分類的原理,可以實現(xiàn)無限級留言與回復(fù)。留言列表gclist保留了留言層次空格,使留言--回復(fù)層次分明。分享給大家供大家參考。具體分析如下:

功能上,本程序可以實現(xiàn)無限級留言與回復(fù),即對留言回復(fù),對回復(fù)的留言回復(fù)。當然你也可以作有限制的控制,使其只對留言回復(fù),關(guān)鍵是在模板代碼中去掉回復(fù)的留言中的“回復(fù)該留言”即可。歡迎去拍磚!

程序效果如下圖所示:

完整源碼點擊此處本站下載。

數(shù)據(jù)表:

復(fù)制代碼 代碼如下:
-- ----------------------------    
-- 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;

代碼:

復(fù)制代碼 代碼如下:
<?php    
// +----------------------------------------------------------------------    
// | WBlog    
// +----------------------------------------------------------------------    
// | Copyright (c) 2008  http://www.w3note.com All rights reserved.    
// +----------------------------------------------------------------------    
// | Author: 網(wǎng)菠蘿果    
// +----------------------------------------------------------------------    
// $Id$    
/**    
 +------------------------------------------------------------------------------    
 * @class 留言板控制器GuestbookAction.class.php    
 +------------------------------------------------------------------------------    
 */
class GuestbookAction extends CommonAction {    
    public function index(){    
        $garr= D('Guestbook')->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');    
                         
        }    
// +----------------------------------------------------------------------    
// | 網(wǎng)址跳轉(zhuǎn)。如在表單url添加網(wǎng)址的話,點擊會跳轉(zhuǎn)到相關(guān)網(wǎng)站    
// +----------------------------------------------------------------------    
         
    public function tourl(){    
      $this->gettourl('Guestbook');    
      }     
}    
?>    
<?php    
// +----------------------------------------------------------------------    
// | WBlog    
// +----------------------------------------------------------------------    
// | Copyright (c) 2008   http://www.w3note.com All rights reserved.    
// | Author: 網(wǎng)菠蘿果    
// +----------------------------------------------------------------------    
// $Id$    
/**    
 +------------------------------------------------------------------------------    
 * @function 留言板模型 類GuestbookModel.class.php   
 +------------------------------------------------------------------------------    
 */
         
class GuestbookModel extends RelationModel{    
// +----------------------------------------------------------------------    
// | $_validate表單自動驗證    
// +----------------------------------------------------------------------    
         
     protected $_validate  = array(    
                array('email','require','請?zhí)顚懩泥]箱!'),    
                array('email','email','郵箱格式錯誤!'),     
                         
               );    
// +----------------------------------------------------------------------    
// | $_auto表單自動填充    
// +----------------------------------------------------------------------    
                  
        protected $_auto=array(    
                 array('status','1'),      
                 array('inputtime','time',1,'function'),    
                 array('content','content',1,'callback'),    
                 array('url','geturl',1,'callback'),                    
                 array ('inputtime','time',1,'function'),    
                 array('path','path',3,'callback'),     
                 array('username','getusername',3,'callback'),                         
                   );       
// +----------------------------------------------------------------------    
// | getusername()過濾用戶名    
// +----------------------------------------------------------------------            
      public function getusername(){    
          if (isset ($_POST['username'])) {    
            if(trim($_POST['username'])=='網(wǎng)菠蘿果'){    
                return $data= ' ̄□ ̄';        
            }elseif(strlen($_POST['username']) >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()過濾留言內(nèi)容    
// +----------------------------------------------------------------------            
    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     
// +----------------------------------------------------------------------    
// |使用方法,看上面的控制器調(diào)用    
// +----------------------------------------------------------------------    
         
     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 < $list[$k]['count'] * 2; $i++) {    
                    $str .= '&nbsp;';    
                }    
                $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;    
    }    
}    
?>

希望本文所述對大家的ThinkPHP框架程序設(shè)計有所幫助。

相關(guān)文章

  • ThinkPHP框架分布式數(shù)據(jù)庫連接方法詳解

    ThinkPHP框架分布式數(shù)據(jù)庫連接方法詳解

    這篇文章主要介紹了ThinkPHP框架分布式數(shù)據(jù)庫連接方法,結(jié)合實例形式詳細分析了thinkPHP框架針對分布式數(shù)據(jù)庫的連接方法、操作技巧與相關(guān)注意事項,需要的朋友可以參考下
    2017-03-03
  • php解壓縮zip和rar壓縮包文件的方法

    php解壓縮zip和rar壓縮包文件的方法

    項目涉及文檔處理,用戶上傳的包括 zip 和 rar 壓縮包,需要先將壓縮包解壓后再作處理。這篇文章主要介紹了php解壓縮zip和rar壓縮包文件,需要的朋友可以參考下
    2019-07-07
  • php中實現(xiàn)用數(shù)組嫵媚地生成要執(zhí)行的sql語句

    php中實現(xiàn)用數(shù)組嫵媚地生成要執(zhí)行的sql語句

    這篇文章主要介紹了php中實現(xiàn)用數(shù)組嫵媚地生成要執(zhí)行的sql語句,本文直接給出代碼示例,需要的朋友可以參考下
    2015-07-07
  • Codeigniter整合Tank Auth權(quán)限類庫詳解

    Codeigniter整合Tank Auth權(quán)限類庫詳解

    相交其他CodeIgniter的類庫,tank_auth,配置簡單,使用也簡單,并且作者也一直在更新。這篇文章主要介紹了Codeigniter整合Tank Auth權(quán)限類庫詳解,需要的朋友可以參考下
    2014-06-06
  • yii上傳文件或圖片實例

    yii上傳文件或圖片實例

    最近在看yii,yii有自帶上傳圖片的方法。簡單的貼代碼。分為兩塊,第一塊view:test.php。第二塊是controller:TestController.php
    2014-04-04
  • 詳解PHP數(shù)據(jù)壓縮、加解密(pack, unpack)

    詳解PHP數(shù)據(jù)壓縮、加解密(pack, unpack)

    網(wǎng)絡(luò)通信、文件存儲中經(jīng)常需要交換數(shù)據(jù),為了減少網(wǎng)絡(luò)通信流量、文件存儲大小以及加密通信規(guī)則,本文介紹了PHP數(shù)據(jù)壓縮、加解密,有興趣的可以了解一下。
    2016-12-12
  • 實例講解PHP頁面靜態(tài)化

    實例講解PHP頁面靜態(tài)化

    本篇文章主要給大家通過實例講解了PHP頁面靜態(tài)化的原理以及相關(guān)方法,對此有需要的朋友參考下吧。
    2018-02-02
  • 淺析Yii2集成富文本編輯器redactor實例教程

    淺析Yii2集成富文本編輯器redactor實例教程

    yii2集成另外一個強大好用的富文本編輯器Redactor。接下來通過本文給大家介紹Yii2集成富文本編輯器redactor實例教程,感興趣的朋友一起學(xué)習(xí)吧
    2016-04-04
  • php根據(jù)年月獲取季度的方法

    php根據(jù)年月獲取季度的方法

    這篇文章主要介紹了php根據(jù)年月獲取季度的方法,需要的朋友可以參考下
    2014-03-03
  • php實現(xiàn)微信支付之現(xiàn)金紅包

    php實現(xiàn)微信支付之現(xiàn)金紅包

    這篇文章主要為大家詳細介紹了php實現(xiàn)微信支付之現(xiàn)金紅包,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05

最新評論