BBS;一个文件的,修改于某某程序
时间:2008-05-01
来源:互联网
BBS;一个文件的,修改于某某程序
演示:http://simplephp.cn/bbs
演示:http://simplephp.cn/bbs
复制PHP内容到剪贴板
<?php
/**************************
@Filename: index.php
@Version : 0.0.1
@Author : leo
@Update : 2007-11-01
@Content : PHP by Editplus
**************************/
require_once('include/function.php');
require_once('include/config.php');
require_once('smarty/Smarty.class.php');
require_once('FCK/fckeditor.php');
$action=$_REQUEST["action"];
//实例 Smarty
$smarty=new Smarty();
$smarty->template_dir = 'templates';
$smarty->compile_dir = 'templates_c';
$smarty->left_delimiter="<_";
$smarty->right_delimiter="_>";
//实例 FCK
function editor($filedName,$value="请填写内容吧!")
{
global $smarty;
$fck=new FCKeditor($filedName);
$fck->BasePath="FCK/";
$fck->ToolbarSet="Default";
$fck->Height="200";
$fck->Width="100%";
$fck->Value=$value;
$editor=$fck->CreateHtml();
$smarty->assign("EDITOR",$editor);
}
switch ($action)
{
case "showuserlogin":
$smarty->assign("PAGETITLE","用户登陆");
$smarty->assign("ACTIONVALUE","userlogin");
$smarty->display("userlogin.html");
break;
case "userlogin":
$smarty->assign("PAGETITLE","用户登陆");
$username=post("username");
$userpwd=post("userpwd");
$usercheck=post("usercheck");
if(empty($username)||empty($userpwd)||empty($usercheck))
{
$msg="请填写完整, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
if(strtoupper($_SESSION['code'])<>strtoupper($usercheck)){
$msg="验证码不正确, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$userloginsql="select discuz_user.userpwd from discuz_user where username='{$username}'";
$login=mysql_query($userloginsql) ;
$loginre=mysql_fetch_array($login);
if($userpwd==$loginre[userpwd])
{
$_SESSION['login']="true";
$_SESSION['username']=$username;
$msg="登陆成功!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$msg="帐号或密码不正确, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
}
break;
case "userloginout":
session_unset();
$msg="注销成功!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
break;
case "showadduser":
$smarty->assign("PAGETITLE","注册新用户");
$smarty->assign("ACTIONVALUE","adduser");
$smarty->display("adduser.html");
break;
case "adduser":
$smarty->assign("PAGETITLE","注册新用户");
$username=post("username");
$userpwd=post("userpwd");
$usersex=post("usersex");
$usercheck=post("usercheck");
$usertime=date("Y-m-d H:i:s");
if(empty($username)||empty($userpwd))
{
$msg="请填写完整, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
if(strtoupper($_SESSION['code'])<>strtoupper($usercheck)){
$msg="验证码不正确, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$addusersql="insert into discuz_user (username,userpwd,usersex,usertime)values('$username','$userpwd','$usersex','$usertime')";
mysql_query($addusersql);
$_SESSION['login']="true";
$_SESSION['username']=$username;
$msg="添加成功!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
}
break;
case "showadd":
if(!$_SESSION['login'])
{
$msg="请先登陆或注册!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$smarty->assign("PAGETITLE","添加内容");
$smarty->assign("ACTIONVALUE","addnews");
$smarty->assign("LOGIN",$_SESSION['login']);
$smarty->assign("USERNAME",$_SESSION['username']);
EDITOR("NEWSCONTENT");
$smarty->display("addnews.html");
}
break;
case "addnews":
if(!$_SESSION['login'])
{
$msg="请先登陆或注册!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$newsname=post("newsname");
$newsauthor=$_SESSION['username'];
$newscontent=postcontent("NEWSCONTENT");
$newstime=date("Y-m-d H:i:s");
if(empty($newsname)||empty($newscontent))
{
$msg="请填写完整, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$sql="insert into discuz_news(newsname,newsauthor,newsview,newsreply,newstime,newscontent,lastreplytime)values('$newsname','$newsauthor','0','0','$newstime','$newscontent','$newstime')";
mysql_query($sql);
$msg="添加成功!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
}
break;
case "showreply":
$newsID=$_GET[newsID];
$newssql="select * from discuz_news where id={$newsID}";
$res=mysql_query($newssql);
$rs=mysql_fetch_array($res);
$newsname=$rs[newsname];
$newsauthor=$rs[newsauthor];
$newstime=$rs[newstime];
$newscontent=$rs[newscontent];
$newsauthorsql="select * from discuz_user where username='{$newsauthor}'";
$newsauthorr=mysql_query($newsauthorsql);
$newsauthorrs=mysql_fetch_array($newsauthorr);
if($newsauthorrs[usersex]=="1"){$newsauthorsex="女";}else{$newsauthorsex="男";}
$newsauthortime=$newsauthorrs[usertime];
$newsview=$rs[newsview];
$newsview++;
$addreplysql="update discuz_news set newsview={$newsview} where id={$newsID}";
mysql_query($addreplysql);
$replysql="select * from discuz_reply where replynewsid={$newsID}";
$replyre=mysql_query($replysql);
while($replyrers=mysql_fetch_array($replyre))
{
$usersql="select * from discuz_user where username='{$replyrers[replyauthor]}'";
$userr=mysql_query($usersql);
$userre=mysql_fetch_array($userr);
if($userre[usersex]=="1"){$usersex="女";}else{$usersex="男";}
$replylist[]=array(
"PEPLYAUTHOR" =>$replyrers[replyauthor],
"USERSEX" => $usersex,
"USERTIME" => $userre["usertime"],
"REPLYTIME" => $replyrers["replytime"],
"REPLYNAME" => $replyrers["replyname"],
"REPLYCONTENT" => $replyrers["replycontent"],
);
}
$smarty->assign("PAGETITLE","内容回复");
$smarty->assign("NEWSNAME",$newsname);
$smarty->assign("NEWSAUTHOR",$newsauthor);
$smarty->assign("NEWSAUTHORSEX",$newsauthorsex);
$smarty->assign("NEWSAUTHORTIME",$newsauthortime);
$smarty->assign("NEWSTIME",$newstime);
$smarty->assign("NEWSCONTENT",$newscontent);
$smarty->assign("REPLYLIST",$replylist);
$smarty->assign("NEWSID",$newsID);
$smarty->assign("ACTIONVALUE","addreply");
EDITOR("REPLYCONTENT");
$smarty->assign("LOGIN",$_SESSION['login']);
$smarty->assign("USERNAME",$_SESSION['username']);
$smarty->display("showall.html");
break;
case "addreply":
if(!$_SESSION['login'])
{
$msg="请先登陆或注册!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$replyname=post("replyname");
$replycontent=postcontent("REPLYCONTENT");
$replyauthor=$_SESSION['username'];
$replytime=date("Y-m-d H:i:s");
$replynewsid=$_POST['newsID'];
if(empty($replycontent))
{
$msg="请填写具体内容, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
else
{
$sql="insert into discuz_reply (replyauthor,replycontent,replytime,replynewsid,replyname)values('$replyauthor','$replycontent','$replytime','$replynewsid','$replyname')";
mysql_query($sql);
$addreplysql="update discuz_news set newsreply=newsreply+1 where id={$replynewsid}";
mysql_query($addreplysql);
$lastreplysql="update discuz_news set lastreplytime='$replytime' where id={$replynewsid}";
mysql_query($lastreplysql);
$msg="添加成功!<a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
}
break;
case "del":
$newsID=get("id");
if(empty($newsID))
{
$msg="缺少参数!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$sql="select * from discuz_news where id=$newsID";
$res=mysql_query($sql);
if(mysql_num_rows($res)<0)
{
$msg="该记录不存在!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
else
{
mysql_query("delete from discuz_news where id=$newsID");
$msg="删除成功!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
}
break;
default:
$sql="select discuz_news.* from discuz_news order by lastreplytime desc";
$res=mysql_query($sql);
while($rs=mysql_fetch_array($res))
{
$newsname=strlen($rs["newsname"])>10?substr($rs["newsname"],0,50):$rs["newsname"];
if(empty($lastreplytime)){$lastreplytime=$rs["newstime"];}
$newslist[]=array(
"ID" => $rs['id'],
"NEWSNAME" => $newsname,
"NEWSAUTHOR"=> $rs["newsauthor"],
"NEWSVIEW" => $rs["newsview"],
"NEWSREPLY" => $rs["newsreply"],
"NEWSTIME" => $rs["newstime"],
"NEWSTIME" => $rs["newstime"],
"NEWSNEWTIME" =>$rs["lastreplytime"],
);
}
$smarty->assign("PAGETITLE","论坛首页");
$smarty->assign("NEWSLIST",$newslist);
$smarty->assign("LOGIN",$_SESSION['login']);
$smarty->assign("USERNAME",$_SESSION['username']);
$smarty->display("index.html");
}
?>
[ 本帖最后由 happynet 于 2008-4-30 17:32 编辑 ] PHP代码:
<?php
/**************************
@Filename: index.php
@Version : 0.0.1
@Author : leo
@Update : 2007-11-01
@Content : PHP by Editplus
**************************/
require_once('include/function.php');
require_once('include/config.php');
require_once('smarty/Smarty.class.php');
require_once('FCK/fckeditor.php');
$action=$_REQUEST["action"];
//实例 Smarty
$smarty=new Smarty();
$smarty->template_dir = 'templates';
$smarty->compile_dir = 'templates_c';
$smarty->left_delimiter="<_";
$smarty->right_delimiter="_>";
//实例 FCK
function editor($filedName,$value="请填写内容吧!")
{
global $smarty;
$fck=new FCKeditor($filedName);
$fck->BasePath="FCK/";
$fck->ToolbarSet="Default";
$fck->Height="200";
$fck->Width="100%";
$fck->Value=$value;
$editor=$fck->CreateHtml();
$smarty->assign("EDITOR",$editor);
}
switch ($action)
{
case "showuserlogin":
$smarty->assign("PAGETITLE","用户登陆");
$smarty->assign("ACTIONVALUE","userlogin");
$smarty->display("userlogin.html");
break;
case "userlogin":
$smarty->assign("PAGETITLE","用户登陆");
$username=post("username");
$userpwd=post("userpwd");
$usercheck=post("usercheck");
if(empty($username)||empty($userpwd)||empty($usercheck))
{
$msg="请填写完整, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
if(strtoupper($_SESSION['code'])<>strtoupper($usercheck)){
$msg="验证码不正确, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$userloginsql="select discuz_user.userpwd from discuz_user where username='{$username}'";
$login=mysql_query($userloginsql) ;
$loginre=mysql_fetch_array($login);
if($userpwd==$loginre[userpwd])
{
$_SESSION['login']="true";
$_SESSION['username']=$username;
$msg="登陆成功!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$msg="帐号或密码不正确, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
}
break;
case "userloginout":
session_unset();
$msg="注销成功!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
break;
case "showadduser":
$smarty->assign("PAGETITLE","注册新用户");
$smarty->assign("ACTIONVALUE","adduser");
$smarty->display("adduser.html");
break;
case "adduser":
$smarty->assign("PAGETITLE","注册新用户");
$username=post("username");
$userpwd=post("userpwd");
$usersex=post("usersex");
$usercheck=post("usercheck");
$usertime=date("Y-m-d H:i:s");
if(empty($username)||empty($userpwd))
{
$msg="请填写完整, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
if(strtoupper($_SESSION['code'])<>strtoupper($usercheck)){
$msg="验证码不正确, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$addusersql="insert into discuz_user (username,userpwd,usersex,usertime)values('$username','$userpwd','$usersex','$usertime')";
mysql_query($addusersql);
$_SESSION['login']="true";
$_SESSION['username']=$username;
$msg="添加成功!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
}
break;
case "showadd":
if(!$_SESSION['login'])
{
$msg="请先登陆或注册!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$smarty->assign("PAGETITLE","添加内容");
$smarty->assign("ACTIONVALUE","addnews");
$smarty->assign("LOGIN",$_SESSION['login']);
$smarty->assign("USERNAME",$_SESSION['username']);
EDITOR("NEWSCONTENT");
$smarty->display("addnews.html");
}
break;
case "addnews":
if(!$_SESSION['login'])
{
$msg="请先登陆或注册!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$newsname=post("newsname");
$newsauthor=$_SESSION['username'];
$newscontent=postcontent("NEWSCONTENT");
$newstime=date("Y-m-d H:i:s");
if(empty($newsname)||empty($newscontent))
{
$msg="请填写完整, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$sql="insert into discuz_news(newsname,newsauthor,newsview,newsreply,newstime,newscontent,lastreplytime)values('$newsname','$newsauthor','0','0','$newstime','$newscontent','$newstime')";
mysql_query($sql);
$msg="添加成功!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
}
break;
case "showreply":
$newsID=$_GET[newsID];
$newssql="select * from discuz_news where id={$newsID}";
$res=mysql_query($newssql);
$rs=mysql_fetch_array($res);
$newsname=$rs[newsname];
$newsauthor=$rs[newsauthor];
$newstime=$rs[newstime];
$newscontent=$rs[newscontent];
$newsauthorsql="select * from discuz_user where username='{$newsauthor}'";
$newsauthorr=mysql_query($newsauthorsql);
$newsauthorrs=mysql_fetch_array($newsauthorr);
if($newsauthorrs[usersex]=="1"){$newsauthorsex="女";}else{$newsauthorsex="男";}
$newsauthortime=$newsauthorrs[usertime];
$newsview=$rs[newsview];
$newsview++;
$addreplysql="update discuz_news set newsview={$newsview} where id={$newsID}";
mysql_query($addreplysql);
$replysql="select * from discuz_reply where replynewsid={$newsID}";
$replyre=mysql_query($replysql);
while($replyrers=mysql_fetch_array($replyre))
{
$usersql="select * from discuz_user where username='{$replyrers[replyauthor]}'";
$userr=mysql_query($usersql);
$userre=mysql_fetch_array($userr);
if($userre[usersex]=="1"){$usersex="女";}else{$usersex="男";}
$replylist[]=array(
"PEPLYAUTHOR" =>$replyrers[replyauthor],
"USERSEX" => $usersex,
"USERTIME" => $userre["usertime"],
"REPLYTIME" => $replyrers["replytime"],
"REPLYNAME" => $replyrers["replyname"],
"REPLYCONTENT" => $replyrers["replycontent"],
);
}
$smarty->assign("PAGETITLE","内容回复");
$smarty->assign("NEWSNAME",$newsname);
$smarty->assign("NEWSAUTHOR",$newsauthor);
$smarty->assign("NEWSAUTHORSEX",$newsauthorsex);
$smarty->assign("NEWSAUTHORTIME",$newsauthortime);
$smarty->assign("NEWSTIME",$newstime);
$smarty->assign("NEWSCONTENT",$newscontent);
$smarty->assign("REPLYLIST",$replylist);
$smarty->assign("NEWSID",$newsID);
$smarty->assign("ACTIONVALUE","addreply");
EDITOR("REPLYCONTENT");
$smarty->assign("LOGIN",$_SESSION['login']);
$smarty->assign("USERNAME",$_SESSION['username']);
$smarty->display("showall.html");
break;
case "addreply":
if(!$_SESSION['login'])
{
$msg="请先登陆或注册!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$replyname=post("replyname");
$replycontent=postcontent("REPLYCONTENT");
$replyauthor=$_SESSION['username'];
$replytime=date("Y-m-d H:i:s");
$replynewsid=$_POST['newsID'];
if(empty($replycontent))
{
$msg="请填写具体内容, <a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
else
{
$sql="insert into discuz_reply (replyauthor,replycontent,replytime,replynewsid,replyname)values('$replyauthor','$replycontent','$replytime','$replynewsid','$replyname')";
mysql_query($sql);
$addreplysql="update discuz_news set newsreply=newsreply+1 where id={$replynewsid}";
mysql_query($addreplysql);
$lastreplysql="update discuz_news set lastreplytime='$replytime' where id={$replynewsid}";
mysql_query($lastreplysql);
$msg="添加成功!<a href=# onclick='history.go(-1)'>返回</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
}
break;
case "del":
$newsID=get("id");
if(empty($newsID))
{
$msg="缺少参数!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}else{
$sql="select * from discuz_news where id=$newsID";
$res=mysql_query($sql);
if(mysql_num_rows($res)<0)
{
$msg="该记录不存在!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
else
{
mysql_query("delete from discuz_news where id=$newsID");
$msg="删除成功!返回<a href=./index.php>首页</a>";
$smarty->assign("MSG",$msg);
$smarty->display("msg.html");
}
}
break;
default:
$sql="select discuz_news.* from discuz_news order by lastreplytime desc";
$res=mysql_query($sql);
while($rs=mysql_fetch_array($res))
{
$newsname=strlen($rs["newsname"])>10?substr($rs["newsname"],0,50):$rs["newsname"];
if(empty($lastreplytime)){$lastreplytime=$rs["newstime"];}
$newslist[]=array(
"ID" => $rs['id'],
"NEWSNAME" => $newsname,
"NEWSAUTHOR"=> $rs["newsauthor"],
"NEWSVIEW" => $rs["newsview"],
"NEWSREPLY" => $rs["newsreply"],
"NEWSTIME" => $rs["newstime"],
"NEWSTIME" => $rs["newstime"],
"NEWSNEWTIME" =>$rs["lastreplytime"],
);
}
$smarty->assign("PAGETITLE","论坛首页");
$smarty->assign("NEWSLIST",$newslist);
$smarty->assign("LOGIN",$_SESSION['login']);
$smarty->assign("USERNAME",$_SESSION['username']);
$smarty->display("index.html");
}
?>
作者: happynet 发布时间: 2008-04-30
注释太少了。。。。。。
作者: luzhou 发布时间: 2008-05-01
先拿下来,回去慢慢研究
作者: 36huangjianhua 发布时间: 2008-05-02
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28