基本信息
源码名称:thinkphp3.2.3留言板带管理没有后台ajax上传图片功能
源码大小:1.47M
文件格式:.zip
开发语言:PHP
更新时间:2017-12-31
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 1 元 
   源码介绍

本系统来自[深入体验PHP项目开发].谭贞军第一章贝斯留言本
功能:
浏览留言
不需要注册发表留言
登录管理员
管理留言(删除,回复/编辑,置顶,显示/隐藏)
系统管理(内容保存在一个文件中,名称,logo,网址,以及一些设置)
管理员密码更改(只有一个管理员,密码没有加密)admin 123456

使用thinkphp 3.2.3版制作,是个人初学练习,其中应用了ajax技术,其中thinkphp中的,验证码,文件上传,文件创建读写,ajaxform一键上传文件,ajax点击管理状态,以及CURD基本技术。数据库方面只有两个表,操作上比较简单,页面主要用bootstrap,图标用的易贝软件的,欢迎测试使用,有问题留言。

<?php
namespace Home\Controller;
use Think\Controller;
class AdminController extends Controller {
    public function index(){
if(is_login()){
     $Guestbook = M('Guestbook'); // 实例化Guestbook对象
$count      = $Guestbook->count();// 查询满足要求的总记录数
$Page       = new \Think\Page($count,C('page_'));// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show       = $Page->show();// 分页显示输出
// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
$list = $Guestbook->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
$this->assign('list',$list);// 赋值数据集
$this->assign('page',$show);// 赋值分页输出
$this->display('list');
}
else{
$this -> error('无权访问此页面',U('Login/index'));
}
    }
public function dele(){
$id = I('id');
$act = I('act');
$gbook = M('Guestbook');
switch ($act)
{
case 'delete':
if($gbook->where('id='.$id)->delete()){
$this->ajaxreturn($resault = array('act' => 1, 'msg' => '删除成功!'));

break;
case 'topic':
$topic = $gbook->where('id='.$id)->getField('settop');
if($topic == 1){
$gbook->where('id='.$id)->setField('settop',0);
$this->ajaxreturn($resault = array('act' => 2, 'msg' => '取消置顶!', 'topic'=> 0));
}else if($topic == 0){
$gbook->where('id='.$id)->setField('settop',1);
$this->ajaxreturn($resault = array('act' => 2, 'msg' => '置顶成功!', 'topic'=> 1));
}
break;
case 'ifshow':
$ifshow = $gbook->where('id='.$id)->getField('ifshow');
if($ifshow == 1){
$gbook->where('id='.$id)->setField('ifshow',0);
$this->ajaxreturn($resault = array('act' => 3, 'msg' => '取消显示!', 'ifshow'=> 0));
}else if($ifshow == 0){
$gbook->where('id='.$id)->setField('ifshow',1);
$this->ajaxreturn($resault = array('act' => 3, 'msg' => '显示成功!', 'ifshow'=> 1));
}
break;
default:
  $this->ajaxreturn($resault = array('act' => 4, 'msg' => '没有任何操作!'));
}

}

public function bianji(){
if(is_login()){
$id = I('id');
$gbook = M('Guestbook');
$guestb = $gbook->where('id='.$id)->find(); 
$this->assign('guestb',$guestb);
$this->display('bian');
}
else{
$this -> error('无权访问此页面',U('Login/index'));
}
}
public function repty(){
$data['id'] = I('id');
$data['content'] = I('contect');
$data['repty'] = I('repty');
$gbook = M('Guestbook');
if( $gbook->save($data)){
$this->success('回复编辑成功',U('Admin/index'));
}
else{
$this->error('编辑出现问题',U('Admin/index'));
}
}

}
<?php
namespace Home\Controller;
use Think\Controller;
class MainController extends Controller {
    public function index(){
if(is_login()){

$this->display('main');
}
else{
$this -> error('无权访问此页面',U('Login/index'));
}
    }
public function peizhi(){
$arr =array(
'gb_name'               =>  I('gb_name'),    // 网站名称
    'gb_logo'               =>  I('gb_logo'), // logo标志
    'index_url'             =>  I('index_url'),          // 主页链接
    'page_'                 =>  I('num'),      // 页面显示记录
    'timejg'                =>  I('time'),          // 密码
    'replyadmtit'           =>  I('replyadmtit'),        // 显示管理员名称
    'ifauditing'            =>  I('ifauditing',1), 
);
$config = require(APP_PATH.'Home/Conf/config.php');

$config = array_merge($config, $arr); 
   //var_export($config);//结果与原来的$a相同
$info="<"."?php\nreturn ".var_export($config,true).";";
$filenum = fopen('Application/Home/Conf/config.php',"w");
if(fwrite($filenum,$info)){
$this->success('系统设置成功!',U('Main/index'));
}
else{
$this->error('系统设置失败!',U('Main/index'));
}
//ftruncate($filenum,0);
 
fclose($filenum);
}
public function password(){
if(is_login()){
$this->display('password');
}
}
public function yanpass(){
$old = I('oldpassword');
$new = I('newpassword');
$gbconfig = M('Gbconfig');
$user = $gbconfig->where('admin_pass="'.$old.'"')->find();
if($user){
if($gbconfig->where('id='.$user['id'].'')->setField('admin_pass',$new)){
$this->success('密码修改成功!',U('Main/index'));
}
else{
$this->error('密码修改失败!',U('Main/password'));
}
}else{
$this->error('旧密码不正确!',U('Main/password'));

}
}
public function upload(){
    $upload = new \Think\Upload();// 实例化上传类
    $upload->maxSize   =     3145728 ;// 设置附件上传大小
    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
    $upload->rootPath  =      './upload/'; // 设置附件上传根目录
    // 上传单个文件 
    $info   =   $upload->uploadOne($_FILES['photo1']);
    if(!$info) {// 上传错误提示错误信息
$default=array('msg'=>$upload->getError());
       // $this->error($upload->getError());
    }else{// 上传成功 获取上传文件信息
$default=array('msg'=>'上传成功','url'=> $info['savepath'].$info['savename']) ;  
    }
$this->ajaxreturn($default);
}




}