#####################
####################
<?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 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());
}
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."
"."-------
".$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."
"."-------
".$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);
}
function htmlencode2($str){
$str=htmlspecialchars($str);
$str=nl2br($str);
return $str;
}
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;
}
}
?>
##########################
########################
<?php
require("func.php");
$sql="select * from boardinfo";
$sql_result=mysql_query($sql);
?>
论坛精华区
|
论坛信息
|
版面:精华区 | 版主:$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); ?> | 共有篇 | ">刷新浏览 |
回应 | 主 题 | 时 间 | 人气 | |
"; echo "[*]"; echo" | "; echo"$sql_row[title] | "; echo"$sql_row[writetime] | "; echo"$sql_row[hits] | "; echo""; } ?>|
}
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);
}
?>
标题: |
作者:() ')"> |
※ 来源: [◆FROM:] |