|
##################### # 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); &nb
|