基于mysql的论坛(3)

##################### # func.php
######### #################### ?php
require(config.inc.php); ##### 检查用户是否存在 ##### function
is_user_exits($name) { $name=trim($name);
$name=ereg_replace(‘,‘,$name); $name=htmlspecialchars($name);
$SQL=SELECT name FROM user WHERE name=’$name’;
$result=mysql_query($SQL) or die(mysql_error());
$row=mysql_fetch_Array($result); $name=$row[name]; return $name; }
##### 检查版面是否存在 ##### function
is_board_exits($baord){ $sql=select name from boardinfo where
name=’$baord’; $result=mysql_query($sql) or die(出现错误);
$row=mysql_fetch_array($result); $name=$row[name]; return $name; }
##### 添加新用户 Function ##### function adduser(){ global
$name,$sex,$realname,$password,$address,$oicq,$homepage,$phone,$email,$qm,$regtime;
$name=trim($name); $name=ereg_replace(‘,‘,$name);
$password=trim($password); $name=htmlspecialchars($name);
$realname=htmlspecialchars($realname);
$address=htmlspecialchars($address); $oicq=htmlspecialchars($oicq);
$homepage=htmlspecialchars($homepage); $phone=htmlspecialchars($phone);
$email=htmlspecialchars($email); $qm=htmlencode2($qm);
$regtime=date(Y-m-d H:i:s); $sql=insert into user
(name,sex,realname,password,address,oicq,homepage,score,phone,email,qm,regtime,slaveboard)
values(‘$name’,’$sex’,’$realname’,’$password’,’$address’,’$oicq’,’$homepage’,’0′,’$phone’,’$email’,’$qm’,’$regtime’,”);
mysql_query($sql) or die(mysql_error()); } ##### URL 重定向
###### function redirect2($url){ header(Location:$url); }
##### 创建版面 ###### function
create_board_table($name,$chinesename){ $name=trim($name); $sql=CREATE
TABLE $name(id int(11) NOT NULL AUTO_INCREMENT,title varchar(50) NOT
NULL,writer varchar(50) NOT NULL,cont longtext, size int,writetime
varchar(20) NOT NULL,hits int(4) DEFAULT ‘0’,good varchar(1),renum
int(4) DEFAULT ‘0’,slaveid int(11) DEFAULT ‘0’,fromip
varchar(15),PRIMARY KEY (id)); mysql_query($sql); $sql=insert into
boardinfo (name,chinesename) values(‘$name’,’$chinesename’);
mysql_query($sql); } ###### 删除版面 ###### function
drop_board_table($name){ $sql=drop table $name; mysql_query($sql);
$sql=delete from boardinfo where name=’$name’; mysql_query($sql); }
######## 修改版面 ### function
update_board($name,$chinesename) { $sql=update boardinfo set
name=’$name’,chinesename=’$chinesename’ where name=’$name’;
mysql_query($sql); } ##### 添加文章 ###### function
add_doc($board){ global
$title,$name,$cont,$writer,$fromip,$writetime,$qm,$new_topic_score;
$title=trim($title); $title=substr($title,0,49); $size=strlen($cont);
$cont=htmlencode2($cont); $cont=$cont.br.——-br.$qm;
$writetime=date(Y-m-d H:i:s); $fromip=getenv(remote_addr);
$name=htmlspecialchars($name); $writer=$name; $sql=insert into $board
(title,writer,cont,size,writetime,fromip)
values(‘$title’,’$name’,’$cont’,’$size’,’$writetime’,’$fromip’);
mysql_query($sql); add_score($writer,$new_topic_score); } #####
回复文章 ##### function re_doc($board,$slaveid){ global
$title,$name,$cont,$writer,$fromip,$writetime,$qm,$re_topic_score;
$title=trim($title); $title=substr($title,0,49); $size=strlen($cont);
$cont=htmlencode2($cont); $cont=$cont.br.——-br.$qm;
$writetime=date(Y-m-d H:i:s); $name=htmlspecialchars($name);
$writer=$name; $fromip=getenv(remote_addr); $sql=insert into $board
(title,writer,cont,size,writetime,slaveid,fromip)
values(‘$title’,’$writer’,’$cont’,’$size’,’$writetime’,’$slaveid’,’$fromip’);
mysql_query($sql); $sql=update $board set renum=renum+1 where
id=$slaveid; mysql_query($sql); add_score($writer,$re_topic_score);
} ##### 删除文章 #### function del_doc($board,$id){ global
$remove_score; $sql=select * from $board where id=$id;
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result);
$writer=$sql_row[writer]; remove_score($writer,$remove_score);
$slaveid=$sql_row[slaveid]; $sql=select * from $board where
id=$slaveid; $sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result);if ($sql_row[renum]0){
$sql=update $board set renum=renum-1 where id=$slaveid;
mysql_query($sql); } $sql=delete from $board where id=$id;
mysql_query($sql); $sql=delete from $board where slaveid=$id;
mysql_query($sql); } #### 转换 html 特殊字符和 br #####
function htmlencode2($str){ $str=htmlspecialchars($str);
$str=nl2br($str); return $str; } ##### 增加一个 hit ####
function add_one_hit($board,$id){ $sql=update $board set hits=hits+1
where id=$id; mysql_query($sql); } ##### 检查用户密码 ####
function check_user_password($name,$password){ $name=trim($name);
$name=ereg_replace(‘,‘,$name); $name=htmlspecialchars($name);
$password=trim($password); $sql=select password from user where
name=’$name’; $sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result);
if($password$sql_row[password]){ $result=0; } else{ $result=1;
setcookie (jl_forum[name],$name); setcookie
(jl_forum[password],$password); } return $result; } #####
检查管理员密码 #### function check_admin_password(){ $sql=select
* from user where name=’$jl_forum[name]’;
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result); if
($jl_forum[password]==$sql_row[password]){ $result=1; } else {
$result=0; } if ($sql_row[slaveboard]==$jl_forum[board]){
$result=1; } else { $result=0; }return $result; } #####
修改个人资料 #### function change_profile($name){ global
$sex,$realname,$password,$address,$oicq,$homepage,$phone,$email,$qm;
$name=trim($name); $name=htmlspecialchars($name);
$realname=htmlspecialchars($realname);
$address=htmlspecialchars($address); $oicq=htmlspecialchars($oicq);
$homepage=htmlspecialchars($homepage); $phone=htmlspecialchars($phone);
$email=htmlspecialchars($email); $qm=htmlencode2($qm); $sql=update user
set
sex=’$sex’,realname=’$realname’,password=’$password’,address=’$address’,oicq=’$oicq’,homepage=’$homepage’,phone=’$phone’,email=’$email’,qm=’$qm’
where name=’$name’; mysql_query($sql); } ##### 显示错误 ####
function show_error($id){ redirect2(wrong.php?id=$id); } #####
增加版主 #### function add_admin($board,$name){ $name=trim($name);
$sql=update user set slaveboard=’$board’ where name=’$name’;
mysql_query($sql); } ##### 删除版主 ##### function
del_admin($name){ $name=trim($name); $name=htmlspecialchars($name);
$sql=update user set slaveboard=” where name=’$name’;
mysql_query($sql); } ##### 贴子转精华 #### function
set_good($board,$id){ $sql=update $board set good=’y’ where id=$id;
mysql_query($sql); } ##### 转出精华 ### function
set_no_good($board,$id){ $sql=update $board set good=” where id=$id;
mysql_query($sql); } ##### 导出签名 ##### function
expl_qm($name){ $name=htmlspecialchars($name); $sql=select qm from user
where name=’$name’; $sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result); $qm=$sql_row[qm]; return
$qm; } ##### 管理员 ##### function adminok() { if
($jl_admin[name]==$admin_name and
$jl_admin[password]==$admin_password) { return 1; } else { return 0;
} } ##### 增加积分 ##### function add_score($name,$num) {
$name=htmlspecialchars($name); $sql=update user set score=score+$num
where name=’$name’; mysql_query($sql); } ##### 减少积分 ####
function remove_score($name,$num) { $name=htmlspecialchars($name);
$sql=update user set score=score-$num where name=’$name’;
mysql_query($sql); } #### 发送留言 #### function sendmsg() {
global $fromname,$name,$cont; $name=htmlspecialchars($name);
$fromname=htmlspecialchars($fromname); $cont=htmlencode2($cont);
$wt=date(Y-m-d H:i:s); $sql=insert into message
(name,fromname,cont,writetime) values
(‘$name’,’$fromname’,’$cont’,’$wt’); mysql_query($sql); } ####
删除留言 #### function delmsg($id) { $sql=delete from message where
id=$id; mysql_query($sql); } ### 留言是否属于这个人 #####
function is_this_user($id) { $sql=select name from message where
id=$id; $sql_result=mysql_query($sql);
$sql_row=mysql_fetch_row($sql_result); if
($sql_row[name]==$jl_forum[name]) { return 1; } else { return 0; }
} ? ########################## # good.php
########## ########################
?php require(func.php); $sql=select * from boardinfo;
$sql_result=mysql_query($sql); ? html head titlemain/title meta
content=text/html; charset=gb2312 link rel=stylesheet type=text/css
href=css/page.css /head body bgcolor=#FFFFFF background=image/bg.gif
table width=90% border=1 cellspacing=0 cellpadding=0 align=center
bordercolorlight=#FFCC99 bordercolordark=#FFCC99 tr bgcolor=#CCFF99td
div align=centerb论坛精华区/b/div /td /tr tr align=centertd form
method=post action=good_list.php select name=board option
selected请选择版面/option ?php
while($sql_row=mysql_fetch_array($sql_result)){ ?option value=?php
echo $sql_row[name];??php echo $sql_row[chinesename];?/option ?php
} ? /select br input type=submit name=Submit value=进入 /form /td /tr tr
bgcolor=#CCFF99td div align=centerb论坛信息/b/div /td /tr tr td ?php
include info.php;? /td /tr /table /body /html
########################### # good_list.php
###########
########################### ?php
require(func.php); if(!is_board_exits($board)){ $board=computer; }
$sql=select * from boardinfo where name=’$board’;
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result);
$chinesename=$sql_row[chinesename]; setcookie
(jl_forum[chinesename],$chinesename); $sql=select name from user
where slaveboard=’$board’; $sql_result=mysql_query($sql); ? html head
titleList/title meta content=text/html; charset=gb2312 link
rel=stylesheet type=text/css href=css/index.css script
language=javascript function
openwin(board,id){window.open(good_read.php?board=+board+&id=+id,,height=460,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no);
} function
post(board){window.open(post.php?board=+board,,height=500,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no);
} /script /head body bgcolor=#FFFFFF background=image/bg.gif ?php
include header.php;? br table width=100% border=1 cellspacing=0
cellpadding=0 bordercolorlight=#000000 bordercolordark=#FFFFFF trtd
height=20 width=22% bgcolor=#eeeeee版面:?php echo $chinesename;
?精华区/td td height=20 width=34% bgcolor=#eeeeee版主:?php while
($sql_row=mysql_fetch_array($sql_result)) { echo $sql_row[name].;
} # 选择出留言纪录; $sql=select * from $board where good=’y’;
$temp=mysql_query($sql); $sum=mysql_num_rows($temp);
$totalpage=ceil($sum/$pagesize); if ($sum==0) { $totalpage=1; } # 分页
if($page1 or empty($page)){ $page=1; } elseif ($page$totalpage){
$page=$totalpage; } $offset=($page-1)*$pagesize; $sql=select * from
$board where good=’y’ order by id desc limit $offset,$pagesize;
$sql_result=mysql_query($sql); ? /td td height=20 width=15%
bgcolor=#eeeeee共有?php echo $sum; ?篇/td td height=20 width=12%a
href=’javascript:post(?php echo $board;?)’img src=image/newtopic.jpg
width=92 height=21 border=0 alt=发新贴子/a/td td height=20 align=center
width=17%a href=?php echo
$php_self?board=$board&page=$page;?刷新浏览/a/td /tr /table br table
width=100% border=1 cellspacing=0 cellpadding=1
bordercolorlight=#CCCCCC bordercolordark=#FFFFFF tr bgcolor=#995100
align=center td width=6%font color=#FFFFFF回应/font/td td width=67%
bgcolor=#995100font color=#FFFFFF主 题/font/td td width=20%font
color=#FFFFFF时 间/font/td td width=7%font color=#FFFFFF人气/font/td
/tr tr bgcolor=#FFCC99 td colspan=5 height=2/td /tr ?php while
($sql_row=mysql_fetch_array($sql_result)) { echotr; echotd width=6%
bgcolor=#FFF5DD align=center; echo [*]; echo/td; echotd
bgcolor=#E8FDEE width=56%font face=宋体a
href=’javascript:openwin($board,$sql_row[id])’
title=作者:$sql_row[writer]
大小:$sql_row[size]字节$sql_row[title]/a/font/td; echotd width=18%
bgcolor=#FFF5DD align=center$sql_row[writetime]/td; echotd width=6%
bgcolor=#E8FDEE align=center$sql_row[hits]/td; echo/tr; } ? tr
bgcolor=#FFCC99 td colspan=5 align=center height=2/td /tr /table div
align=right form method=post action=?php echo $php_self;? 共b?php echo
$totalpage;?/b页 第b?php echo $page;?/b页・?php if ($page!=1){
$back=$page-1; echoa href=$php_self?board=$board&page=1首页/a a
href=$php_self?board=$board&page=$back/a; } if ($page==1){ echo首页 ; }
if($page!=$totalpage){ $next=$page+1; echo a
href=$php_self?board=$board&page=$next/a a
href=$php_self?board=$board&page=$totalpage尾页/a; }
if($page==$totalpage){ echo 尾页; } ?・input type=submit name=goto
value=转到 input type=text name=page size=2 页/form /div ?php include
footer.php;? /body /html
############################
###good_read.php ######
######################3 ?php require (func.php);
if ($re){ if (!is_board_exits($board)){ show_error(7); $founderr=1; }
$sql=select slaveid from $board where id=$id;
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result);
if($sql_row[slaveid]!=0){ show_error(1); $founderr=1; } if
(!check_user_password($name,$password)){ show_error(4); $founderr=1;
} if (strlen($title)50){ show_error(6); $founderr=1; } if
(empty($title)){ show_error(2); $founderr=1; } if ($qm){
$qm=expl_qm($name); } if(!$founderr){ re_doc($board,$id); $sql=select
* from $board where id=$id; $sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result); $title=$sql_row[title];
$writer=$sql_row[writer]; $cont=$sql_row[cont];
$writetime=$sql_row[writetime]; $hits=$sql_row[$hits];
$fromip=$sql_row[fromip]; $sql=select * from $board where
slaveid=$id; $sql_result=mysql_query($sql); #
$sql_row=mysql_fetch_array($sql_result); } } elseif ($add){ if
(!is_board_exits($board)){ show_error(7); $founderr=1; } if
(empty($title)){ show_error(2); $founderr=1; } if
(!check_user_password($name,$password)){ show_error(4); $founderr=1;
} if (strlen($title)50){ show_error(6); $founderr=1; } if ($qm){
$qm=expl_qm($name); $founderr=1; } if (!$founderr){ add_doc($board); }
} else { if (!is_board_exits){ show_error(7); }
add_one_hit($board,$id); $sql=select * from $board where id=$id;
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result); $title=$sql_row[title];
$writer=$sql_row[writer]; $cont=$sql_row[cont];
$writetime=$sql_row[writetime]; $hits=$sql_row[$hits];
$fromip=$sql_row[fromip]; $sql=select * from $board where
slaveid=$id order by id desc; $sql_result=mysql_query($sql);
#$sql_row=mysql_fetch_array($sql_result); } ? html head title?php
echo $title;?/title meta content=text/html; charset=gb2312 link
rel=stylesheet type=text/css href=css/index.css script
language=javascript function
sendmsg(name){window.open(sendmsg.php?name=+name,,height=200,width=500,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no);
} /script /head body bgcolor=#666699 ?php include ad.php;?br hr noshade
width=98% size=1 table width=98% border=1 cellspacing=0 cellpadding=2
align=center bordercolorlight=#CCCCCC bordercolordark=#FFFFFF tr
bgcolor=#666666 tdfont color=#FFcc00b标题:?php echo
$title;?/b/font/td /tr tr td bgcolor=#eeeeee作者:?php echo
$writer;?(?php echo $writetime;?) a href=javascript:sendmsg(‘?php echo
$writer;?’)img src=image/icon1.gif width=18 height=17 alt=给作者留言
border=0/a a href=userinfo.php?name=?php echo $writer;?img
src=image/profile.gif width=16 height=16 alt=察看用户资料 border=0/a/td
/tr tr td bgcolor=#ffffef?php echo $cont;?/td /tr tr bgcolor=#e8eee0
td※ 来源:?php echo $jl_forum[chinesename];? [◆FROM:?php echo
$fromip;?]/td /tr /table br ?php includefooter.php;?br /body /html

# post.php ?php require(config.inc.php); $sql=select * from boardinfo
where name=’$board’; $sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result); ? html head
title发新贴子/title link rel=stylesheet type=text/css href=css/index.css
/head body bgcolor=#666666 ?php include ad.php;?br hr noshade width=80%
size=1 table width=80% border=1 cellspacing=0 cellpadding=0 align=center
bordercolorlight=#686898 bordercolordark=#FFFFFF tr align=center
valign=top bgcolor=#666699tdfont size=3 color=#336699bfont
color=#CCFFFF发 贴 子/font/b/fontbr /td /tr tr bgcolor=#ffffeftd/td
/tr tr bgcolor=#e8eee0tdbr 您的贴子将被发表在b?php echo
$sql_row[chinesename];?/b版块 /td /tr /table br form method=post
action=read.php table width=98% border=1 cellspacing=0 cellpadding=0
align=center bordercolorlight=#336699 bordercolordark=#FFFFFF
bgcolor=#666699 trtd width=89 bgcolor=#acc0fa align=right用户名:/td
td width=224input type=text name=name style=font-size: 9pt;
background-color: #FFFFFF; color: #3366FF; border: 1 solid #000000
value=?php echo $jl_forum[name];? size=17 maxlength=16 font
color=#FF0000* /font /td td width=63 bgcolor=#acc0fa
align=right密码:/td td width=160input type=password name=password
size=10 maxlength=16 style=font-size: 9pt; background-color: #FFFFFF;
color: #FF0000; border: 1 solid #000000 font color=#FF0000*/font
font color=#FF0000 /font /td /tr trtd colspan=4font
color=#FFFFFF主题:/fontinput type=text name=title size=50 maxlength=50
style=font-size: 9pt; background-color: #FFFFFF; color: ##3366FF;
border: 1 solid #000000 font color=#FF0000* /font/td /tr trtd
colspan=4 font color=#FFFFFF内容:/fontbr textarea name=cont cols=70
rows=12 wrap=VIRTUAL/textarea br input type=button name=Submit2
value=取消 onclick=window.close() input type=submit name=add value=提交
input type=checkbox name=qm value=qm checked font
color=#FFFFFF使用签名/fontinput type=hidden name=board value=?php echo
$board;? /td /tr /table /form ?php include footer.php;?br /body /html #
query.php ?php require(func.php); $sql=select * from boardinfo;
$sql_result=mysql_query($sql); ? html head titlemain/title meta
content=text/html; charset=gb2312 link rel=stylesheet type=text/css
href=css/page.css /head body bgcolor=#FFFFFF background=image/bg.gif
table width=90% border=1 cellspacing=0 cellpadding=0 align=center
bordercolorlight=#FFCC99 bordercolordark=#FFCC99 tr bgcolor=#CCFF99td
div align=centerb论坛贴子查询/b/div /td /tr tr align=centertd form
method=post action=query_list.php 在select name=board option
selected请选择版面/option ?php
while($sql_row=mysql_fetch_array($sql_result)){ ?option value=?php
echo $sql_row[name];??php echo $sql_row[chinesename];?/option ?php
} ? /select 中查询br input type=text name=query_str size=40
maxlength=40 br input type=submit name=title value=按主题查询 input
type=submit name=cont value=按内容查询 input type=submit name=writer
value=按作者查询 /form /td /tr tr bgcolor=#CCFF99td div
align=centerb论坛信息/b/div /td /tr tr td ?php include info.php;? /td
/tr /table /body /html # query_list.php ?php require(func.php); if
(!empty($query_str)) { if(!is_board_exits($board)){ $board=computer;
} if ($title){ $submit=title; } elseif ($cont) { $submit=cont; } elseif
($writer) { $submit=writer; } else { $submit=title; } $sql=select *
from $board where ($submit like ‘%$query_str%’);
$temp=mysql_query($sql); $sum=mysql_num_rows($temp); if ($sum!=0) {
$sql=select * from boardinfo where name=’$board’;
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result);
$chinesename=$sql_row[chinesename]; setcookie
(jl_forum[chinesename],$chinesename); $sql=select name from user
where slaveboard=’$board’; $sql_result=mysql_query($sql); ? html head
titleList/title meta content=text/html; charset=gb2312 link
rel=stylesheet type=text/css href=css/index.css script
language=javascript function
openwin(board,id){window.open(good_read.php?board=+board+&id=+id,,height=460,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no);
} function
post(board){window.open(post.php?board=+board,,height=500,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no);
} /script /head body bgcolor=#FFFFFF background=image/bg.gif ?php
include header.php;? br table width=100% border=1 cellspacing=0
cellpadding=0 bordercolorlight=#000000 bordercolordark=#FFFFFF tr td
height=20 width=22% bgcolor=#E8E8E8版面:?php echo $chinesename; ?/td
td height=20 width=29% bgcolor=#E8E8E8版主:?php while
($sql_row=mysql_fetch_array($sql_result)) { echo $sql_row[name].;
} # 选择出留言纪录; $totalpage=ceil($sum/$pagesize); # 分页 if($page1
or empty($page)){ $page=1; } elseif ($page$totalpage){ $page=$totalpage;
} elseif ($totalpage==0) { $page=0; } $offset=($page-1)*$pagesize;
$sql=select * from $board where ($submit like ‘%$query_str%’) order by
id desc limit $offset,$pagesize; $sql_result=mysql_query($sql); ? /td
td height=20 width=17% bgcolor=#E8E8E8查询到?php echo $sum; ?条纪录/td
td height=20 colspan=2 width=32%a href=’javascript:post(?php echo
$board;?)’img src=image/newtopic.jpg width=92 height=21 border=0
alt=发新贴子/a/td /tr /table br table width=100% border=1 cellspacing=0
cellpadding=1 bordercolorlight=#CCCCCC bordercolordark=#eeeeee tr
bgcolor=#995100 align=center td width=6%font color=#FFFFFF回应/font/td
td width=67% bgcolor=#995100font color=#FFFFFF主 题/font/td td
width=20%font color=#FFFFFF时 间/font/td td width=7%font
color=#FFFFFF人气/font/td /tr tr bgcolor=#FFCC99 td colspan=5
height=2/td /tr ?php while ($sql_row=mysql_fetch_array($sql_result))
{ echotr; echotd width=6% bgcolor=#E8E8E8 align=center; echo [*];
echo/td; echotd bgcolor=#E8FDEE width=56%font face=宋体a
href=’javascript:openwin($board,$sql_row[id])’
title=作者:$sql_row[writer]
大小:$sql_row[size]字节$sql_row[title]/a/font/td; echotd width=18%
bgcolor=#FFF5DD align=center$sql_row[writetime]/td; echotd width=6%
bgcolor=#E8FDEE align=center$sql_row[hits]/td; echo/tr; } ? tr
bgcolor=#FFCC99 td colspan=5 align=center height=2/td /tr /table div
align=right form method=post action=?php echo $php_self;? input
type=hidden name=?php echo $submit;? value=y input type=hidden
name=query_str value=?php echo $query_str;? 共b?php echo
$totalpage;?/b页 第b?php echo $page;?/b页・?php if ($page!=1){
$back=$page-1; echoa
href=$php_self?board=$board&page=1&$submit=y&query_str=$query_str首页/a
a
href=$php_self?board=$board&page=$back&$submit=y&query_str=$query_str/a;
} if ($page==1){ echo首页 ; } if($page!=$totalpage){ $next=$page+1; echo
a
href=$php_self?board=$board&page=$next&$submit=y&query_str=$query_str/a
a
href=$php_self?board=$board&page=$totalpage&$submit=y&query_str=$query_str尾页/a;
} if($page==$totalpage){ echo 尾页; } ?・转到input type=submit name=goto
value=转到 input type=text name=page size=2 页/form /div ?php include
footer.php;? /body /html ?php } else { show_error(10); } } else {
show_error(9); } # read.php ?php require (func.php); if ($re){
$sql=select slaveid from $board where id=$id;
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result);
if($sql_row[slaveid]!=0){ show_error(1); $founderr=1; } if
(!check_user_password($name,$password)){ show_error(4); $founderr=1;
} if (empty($title)){ show_error(2); $founderr=1; } if ($qm){
$qm=expl_qm($name); } if(!$founderr){ re_doc($board,$id); setcookie
(jl_forum[name],$name); $sql=select * from $board where id=$id;
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result); $title=$sql_row[title];
$writer=$sql_row[writer]; $cont=$sql_row[cont];
$writetime=$sql_row[writetime]; $hits=$sql_row[$hits];
$fromip=$sql_row[fromip]; $sql=select * from $board where
slaveid=$id; $sql_result=mysql_query($sql); #
$sql_row=mysql_fetch_array($sql_result); } } elseif ($add){ if
(!is_board_exits($board)){ show_error(7); $founderr=1; } if
(empty($title)){ show_error(2); $founderr=1; } if
(!check_user_password($name,$password)){ show_error(4); $founderr=1;
} if ($qm){ $qm=expl_qm($name); } if (!$founderr){ add_doc($board);
$add=1; setcookie (jl_forum[name],$name); } } else { if
(!is_board_exits){ show_error(7); } add_one_hit($board,$id);
$sql=select * from $board where id=$id;
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result); $title=$sql_row[title];
$writer=$sql_row[writer]; $cont=$sql_row[cont];
$writetime=$sql_row[writetime]; $hits=$sql_row[$hits];
$fromip=$sql_row[fromip]; $sql=select * from $board where
slaveid=$id; $sql_result=mysql_query($sql);
#$sql_row=mysql_fetch_array($sql_result); } ? html head title?php
echo $title;?/title meta content=text/html; charset=gb2312 link
rel=stylesheet type=text/css href=css/index.css script
language=javascript function
sendmsg(name){window.open(sendmsg.php?name=+name,,height=200,width=500,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no);
} /script /head body bgcolor=#666699 ?php include ad.php;?br hr noshade
width=98% size=1 table width=98% border=1 cellspacing=0 cellpadding=2
align=center bordercolorlight=#CCCCCC bordercolordark=#FFFFFF tr
bgcolor=#666666 tdfont color=#FFcc00b标题:?php echo
$title;?/b/font/td /tr tr td bgcolor=#eeeeee作者:?php echo
$writer;?(?php echo $writetime;?) a href=javascript:sendmsg(‘?php echo
$writer;?’)img src=image/icon1.gif width=18 height=17 alt=给作者留言
border=0/a a href=userinfo.php?name=?php echo $writer;?img
src=image/profile.gif width=16 height=15 alt=察看用户资料 border=0/a/td
/tr tr bgcolor=#ffffeftd?php echo $cont;?/td /tr tr bgcolor=#e8eee0
td※ 来源:?php echo $jl_forum[chinesename];? [◆FROM:?php echo
$fromip;?]/td /tr /table br ?php if ($add!=1){
while($sql_row=mysql_fetch_array($sql_result)) { ? table width=98%
border=1 cellspacing=0 cellpadding=2 align=center
bordercolorlight=#CCCCCC bordercolordark=#FFFFFF tr bgcolor=#015C71
tdfont color=#ffffff标题:?php echo $sql_row[title];?/font/td /tr tr
bgcolor=#eeeeee td作者:?php echo $sql_row[writer];?(?php echo
$sql_row[writetime];?) a href=javascript:sendmsg(‘?php echo
$sql_row[writer];?’)img src=image/icon1.gif width=18 height=17
alt=给作者留言 border=0/a a href=userinfo.php?name=?php echo
$sql_row[writer];?img src=image/profile.gif width=17 height=15
alt=察看用户资料 border=0/a/td /tr tr bgcolor=#ffffeftd?php echo
$sql_row[cont];?/td /tr tr bgcolor=#e8eee0 td※ 来源:?php echo
$jl_forum[chinesename];? [◆FROM:?php echo
$sql_row[fromip];?]/td /tr /table ?php } ? form method=post
action=read.php table width=98% border=0 cellspacing=0 cellpadding=0
align=center tr td table width=40 border=1 cellspacing=0 cellpadding=0
height=20 bordercolorlight=#000099 bordercolordark=#FFFFFF tr
valign=middle align=center bgcolor=#acc0fa td height=17回复/td /tr
/table /td /tr /table table width=98% border=1 cellspacing=0
cellpadding=0 align=center bordercolorlight=#686898
bordercolordark=#CCCCCC tr td width=8% align=right
bgcolor=#acc0fa用户名/td td width=33% input type=text name=name size=17
maxlength=16 value=?php echo $jl_forum[name];? font color=#FFFFFF*
/font/td td width=7% bgcolor=#acc0fa align=center密码/td td width=52%
input type=password name=password size=17 maxlength=16 font
color=#FFFFFF* /font/td /tr tr td width=8% align=right
bgcolor=#acc0fa标题:/td td colspan=3 input type=text name=title
size=40 maxlength=50 font color=#FFFFFF * /font/td /tr tr td width=8%
align=right bgcolor=#acc0fa内容:/td td colspan=3 textarea name=cont
cols=60 rows=3 wrap=VIRTUAL/textarea /td /tr tr td width=8% align=right
bgcolor=#acc0fa/td td colspan=3 input type=button name=clear
value=关闭窗口 onclick=window.close() input type=submit name=re
value=提交 input type=checkbox name=qm value=qm checked font
color=#FFFFFF使用签名 input type=hidden name=board value=?php echo
$board;? input type=hidden name=id value=?php echo $id;? /font/td /tr
/table ?php } ? br /form ?php includefooter.php;?br /body /html

##################### # func.php
######### #################### “.”——-
“.$qm; $writetime=date(“Y-m-d H:i:s”); $fromip=getenv(“remote_addr”);
$name=htmlspecialchars; $writer=$name; $sql=”insert into $board
(title,writer,cont,size,writetime,fromip)
values(‘$title’,’$name’,’$cont’,’$size’,’$writetime’,’$fromip’)”;
mysql_query; add_score($writer,$new_topic_score); } #####
回复文章 ##### function re_doc{ global
$title,$name,$cont,$writer,$fromip,$writetime,$qm,$re_topic_score;
$title=trim; $title=substr; $size=strlen; $cont=htmlencode2;
$cont=$cont.”
“.”——-
“.$qm; $writetime=date(“Y-m-d H:i:s”); $name=htmlspecialchars;
$writer=$name; $fromip=getenv(“remote_addr”); $sql=”insert into $board
(title,writer,cont,size,writetime,slaveid,fromip)
values(‘$title’,’$writer’,’$cont’,’$size’,’$writetime’,’$slaveid’,’$fromip’)”;
mysql_query; $sql=”update $board set renum=renum+1 where id=$slaveid”;
mysql_query; add_score($writer,$re_topic_score); } #####
删除文章 #### function del_doc{ global $remove_score; $sql=”select
* from $board where id=$id”; $sql_result=mysql_query;
$sql_row=mysql_fetch_array; $writer=$sql_row[writer];
remove_score($writer,$remove_score); $slaveid=$sql_row[slaveid];
$sql=”select * from $board where id=$slaveid”;
$sql_result=mysql_query; $sql_row=mysql_fetch_array;if {
$sql=”update $board set renum=renum-1 where id=$slaveid”; mysql_query;
} $sql=”delete from $board where id=$id”; mysql_query; $sql=”delete
from $board where slaveid=$id”; mysql_query; } #### 转换 html
特殊字符和
##### function htmlencode2{ $str=htmlspecialchars; $str=nl2br;
return $str; } ##### 增加一个 hit #### function add_one_hit{
$sql=”update $board set hits=hits+1 where id=$id”; mysql_query; }
##### 检查用户密码 #### function check_user_password{
$name=trim; $name=ereg_replace(“‘”,”‘”,$name); $name=htmlspecialchars;
$password=trim; $sql=”select password from user where name=’$name'”;
$sql_result=mysql_query; $sql_row=mysql_fetch_array;
if($password<>$sql_row[password]){ $result=0; } else{
$result=1; setcookie (“jl_forum[name]”,$name); setcookie
(“jl_forum[password]”,$password); } return $result; } #####
检查管理员密码 #### function check_admin_password(){ $sql=”select
* from user where name=’$jl_forum[name]'”;
$sql_result=mysql_query; $sql_row=mysql_fetch_array; if
($jl_forum[password]==$sql_row[password]){ $result=1; } else {
$result=0; } if ($sql_row[slaveboard]==$jl_forum[board]){
$result=1; } else { $result=0; }return $result; } #####
修改个人资料 #### function change_profile{ global
$sex,$realname,$password,$address,$oicq,$homepage,$phone,$email,$qm;
$name=trim; $name=htmlspecialchars; $realname=htmlspecialchars;
$address=htmlspecialchars; $oicq=htmlspecialchars;
$homepage=htmlspecialchars; $phone=htmlspecialchars;
$email=htmlspecialchars; $qm=htmlencode2; $sql=”update user set
sex=’$sex’,realname=’$realname’,password=’$password’,address=’$address’,oicq=’$oicq’,homepage=’$homepage’,phone=’$phone’,email=’$email’,qm=’$qm’
where name=’$name'”; mysql_query; } ##### 显示错误 ####
function show_error{ redirect2(“wrong.php?id=$id”); } #####
增加版主 #### function add_admin{ $name=trim; $sql=”update user set
slaveboard=’$board’ where name=’$name'”; mysql_query; } #####
删除版主 ##### function del_admin{ $name=trim;
$name=htmlspecialchars; $sql=”update user set slaveboard=” where
name=’$name'”; mysql_query; } ##### 贴子转精华 #### function
set_good{ $sql=”update $board set good=’y’ where id=$id”; mysql_query;
} ##### 转出精华 ### function set_no_good{ $sql=”update $board
set good=” where id=$id”; mysql_query; } ##### 导出签名
##### function expl_qm{ $name=htmlspecialchars; $sql=”select qm
from user where name=’$name'”; $sql_result=mysql_query;
$sql_row=mysql_fetch_array; $qm=$sql_row[qm]; return $qm; }
##### 管理员 ##### function adminok() { if
($jl_admin[name]==$admin_name and
$jl_admin[password]==$admin_password) { return 1; } else { return 0;
} } ##### 增加积分 ##### function add_score {
$name=htmlspecialchars; $sql=”update user set score=score+$num where
name=’$name'”; mysql_query; } ##### 减少积分 #### function
remove_score { $name=htmlspecialchars; $sql=”update user set
score=score-$num where name=’$name'”; mysql_query; } #### 发送留言
#### function sendmsg() { global $fromname,$name,$cont;
$name=htmlspecialchars; $fromname=htmlspecialchars; $cont=htmlencode2;
$wt=date(“Y-m-d H:i:s”); $sql=”insert into message
(name,fromname,cont,writetime) values
(‘$name’,’$fromname’,’$cont’,’$wt’)”; mysql_query; } #### 删除留言
#### function delmsg { $sql=”delete from message where id=$id”;
mysql_query; } ### 留言是否属于这个人 ##### function
is_this_user { $sql=”select name from message where id=$id”;
$sql_result=mysql_query; $sql_row=mysql_fetch_row; if
($sql_row[name]==$jl_forum[name]) { return 1; } else { return 0; }
} ?> ########################## # good.php
########## ########################

main

论坛精华区
论坛信息

########################### # good_list.php
###########
###########################

List

版面:
精华区
版主: 共有
">刷新浏览

回应

主 题

时 间

人气

“; echo”

“; echo “[*]”; echo”

“; echo”

$sql_row[title])

“; echo”

$sql_row[writetime]

“; echo”

$sql_row[hits]

“; echo””; } ?>

############################
###good_read.php ######
######################3


标题:
作者:
(
) ‘)"> ">
※ 来源:
[◆FROM:
]
You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图