1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > thinkphp3.12无限级留言与回复的留言板模块

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

时间:2019-07-22 23:49:50

相关推荐

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

php教程|php手册

thinkphp代码,代码示例,代码参考,php短信,数据库备份代码,令牌验证,去除代码中的空白和注释留言板 留言

php教程-php手册

本留言板程序使用了无限级分类的原理,可以实现无限级留言与回复。留言列表gclist保留了留言层次空格,使留言–回复层次分明.

功能上,本程序可以实现无限级留言与回复,即对留言回复,对回复的留言回复。当然你也可以作有限制的控制,使其只对留言回复,关键是在模板代码中去掉回复的留言中的“回复该留言”即可。欢迎去拍砖!

易语言 excel 源码,vscode控制台窗口主机,ubuntu扩展平板,修改tomcat启动名,爬虫实战app,php 嵌入网页,青岛seo排名软件多少钱,免费的网站cmslzw

汽车票售票系统源码,ubuntu读取硬盘,tomcat下载设置多少位,小爬虫幼儿,php图片展示源码,百度seo优化培训外推lzw

程序效果演示:w3note点com/guestbook

在线站长工具源码,vscode内存检测工具,ubuntu识别upan,tomcat内存多久回收,爬虫采集系统,php判断是否为蜘蛛,seo优化哪家信誉好,典教育网站模板html5,化工企业网站模板lzw

完整的留言程序代码下载: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

<?php

// +----------------------------------------------------------------------

// | WBlog

// +----------------------------------------------------------------------

// | Copyright (c) www点w3note点com All rights reserved.

// +----------------------------------------------------------------------

// | Author: 网菠萝果

// +----------------------------------------------------------------------

// $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);

}

// +----------------------------------------------------------------------

// | 网址跳转。如在表单url添加网址的话,点击会跳转到相关网站

// +----------------------------------------------------------------------

public function tourl(){

$this->gettourl(Guestbook);

}

}

?>

<?php

// +----------------------------------------------------------------------

// | WBlog

// +----------------------------------------------------------------------

// | Copyright (c) w3note点com All rights reserved.

// | Author: 网菠萝果

// +----------------------------------------------------------------------

// $Id$

/**

+------------------------------------------------------------------------------

* @function 留言板模型

+------------------------------------------------------------------------------

*/

class GuestbookModel extends RelationModel{

// +----------------------------------------------------------------------

// | $_validate表单自动验证

// +----------------------------------------------------------------------

protected $_validate = array(

array(email, equire,请填写您的邮箱!),

array(email,email,邮箱格式错误!),

);

// +----------------------------------------------------------------------

// | $_auto表单自动填充

// +----------------------------------------------------------------------

protected $_auto=array(

array(status,1),

array(inputtime, ime,1,function),

array(content,content,1,callback),

array(url,geturl,1,callback),

array (inputtime, ime,1,function),

array(path,path,3,callback),

array(username,getusername,3,callback),

);

// +----------------------------------------------------------------------

// | getusername()过滤用户名

// +----------------------------------------------------------------------

public function getusername(){

if (isset ($_POST[username])) {

if(trim($_POST[username])==网菠萝果){

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()过滤留言内容

// +----------------------------------------------------------------------

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(path,id)->limit($P->firstRow . , . $P->listRows)->select();

foreach ($list as $k => $v) {

$list[$k][count] = count(explode(-, $v[path]));

$list[$k][ ousername]=$this->where(array(id=> $v[pid]))->getField(username);

$str = \;

if ($v[pid] 0) {

for ($i = 0; $i < $list[$k][count] * 2; $i++) {

$str .= ;

}

$str .= ;

}

$list[$k][space] = $str;

}

$P->setConfig(header, 篇);

$P->setConfig(prev, "«");

$P->setConfig( ext, »);

$P->setConfig(first, |«);

$P->setConfig(last, »|);

$page = $P->show();

$arr=array(page=>$page,list=>$list);

return $arr;

}

}

?>

AD:真正免费,域名+虚机+企业邮箱=0元

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。