$action=$_GET["action"];$S_id=$_GET["S_id"];if($action=="add"){$B_title=htmlspecialchars($_POST["B_title"]);$B_sort=$_POST["B_sort"];$B_content=htmlspecialchars($_POST["B_content"]);$S_sh=getrs("select * from SL_bsort where S_id=".intval($B_sort),"S_sh");echo$B_sort;if($S_sh==1){$B_sh=0;}else{$B_sh=1;}mysqli_query($conn,"insert into SL_bbs(B_title,B_content,B_time,B_mid,B_sort,B_sh) values('".$B_title."','".$B_content."','".date('Y-m-d H:i:s')."',".$_SESSION["M_id"].",".$B_sort.",".$B_sh.")");$sql="Select * from SL_bbs order by B_id desc limit 1";$result=mysqli_query($conn,$sql);$row=mysqli_fetch_assoc($result);if(mysqli_num_rows($result)>0){$B_id=$row["B_id"];}if($B_sh==1){box("发布成功!","item.php?id=".$B_id,"success");}else{box("发布成功!请等待审核","./","success");}}$_SESSION["from"]=$C_dir."bbs/bbs.php?S_id=".$S_id;$sql="Select * from SL_slide order by S_id desc limit 1";$result=mysqli_query($conn,$sql);$row=mysqli_fetch_assoc($result);if(mysqli_num_rows($result)>0){if($C_memberbg==""||is_null($C_memberbg)){$S_pic=$row["S_pic"];}else{$S_pic=$C_memberbg;}}
$sql="Select * from SL_bbs,SL_bsort,SL_member,SL_lv where B_sort=S_id and B_mid=M_id and M_lv=L_id and B_id=".$id;$result=mysqli_query($conn,$sql);$row=mysqli_fetch_assoc($result);if(mysqli_num_rows($result)>0){$B_title=lang($row["B_title"]);$B_content=lang($row["B_content"]);$B_time=$row["B_time"];$B_sort=$row["B_sort"];$S_title=lang($row["S_title"]);$B_view=$row["B_view"];$M_login=$row["M_login"];$M_pic=$row["M_pic"];$L_title=$row["L_title"];}if(substr($M_pic,0,4)!="http"){$M_pic="../media/".$M_pic;}$sql2="Select count(*) as B_count from SL_bbs where B_sub=".$id;$result2=mysqli_query($conn,$sql2);$row2=mysqli_fetch_assoc($result2);$B_count=$row2["B_count"];if($action=="reply"){$B_contentx=$_POST["B_content"];$debug("insert into SL_bbs(B_title,B_content,B_time,B_mid,B_sub,B_sort) values('[回复]".$B_title."','".$B_contentx."','".date('Y-m-d H:i:s')."',".$_SESSION["M_id"].",".$id.",".$B_sort.")");mysqli_query($conn,"insert into SL_bbs(B_title,B_content,B_time,B_mid,B_sub,B_sort) values('[回复]".$B_title."','".$B_contentx."','".date('Y-m-d H:i:s')."',".$_SESSION["M_id"].",".$id.",".$B_sort.")");box("回复成功!","item.php?id=".$id,"success");}
简单说一下逻辑,第一步执行的sql语句是查询帖子的详细内容($id帖子id)
1
$sql="Select * from SL_bbs,SL_bsort,SL_member,SL_lv where B_sort=S_id and B_mid=M_id and M_lv=L_id and B_id=".$id;
if($action=="reply"){$B_contentx=$_POST["B_content"];$debug("insert into SL_bbs(B_title,B_content,B_time,B_mid,B_sub,B_sort) values('[回复]".$B_title."','".$B_contentx."','".date('Y-m-d H:i:s')."',".$_SESSION["M_id"].",".$id.",".$B_sort.")");mysqli_query($conn,"insert into SL_bbs(B_title,B_content,B_time,B_mid,B_sub,B_sort) values('[回复]".$B_title."','".$B_contentx."','".date('Y-m-d H:i:s')."',".$_SESSION["M_id"].",".$id.",".$B_sort.")");box("回复成功!","item.php?id=".$id,"success");}
<?phprequire'../conn/conn2.php';require'../conn/function.php';if($_COOKIE["user"]==""||$_COOKIE["pass"]==""){setcookie("user","");setcookie("pass","");setcookie("auth","");Header("Location:index.php");die();}else{$sql="select * from SL_admin where A_login like '".filter_keyword($_COOKIE["user"])."' and A_pwd like '".filter_keyword($_COOKIE["pass"])."'";$result=mysqli_query($conn,$sql);$row=mysqli_fetch_assoc($result);if(mysqli_num_rows($result)>0){}else{setcookie("user","");setcookie("pass","");setcookie("auth","");Header("Location:index.php");die();}}$DownName=$_GET["DownName"];if(strpos($DownName,".php")!==false){die("禁止下载PHP格式文件!");}downtemplateAction($DownName);functiondowntemplateAction($f){header("Content-type:text/html;charset=utf-8");$file_name=$f;$file_name=iconv("utf-8","gb2312",$file_name);$file_path=$file_name;if(!file_exists($file_path)){echo"下载文件不存在!";exit;}$fp=fopen($file_path,"r");$file_size=filesize($file_path);Header("Content-type: application/octet-stream");Header("Accept-Ranges: bytes");Header("Accept-Length:".$file_size);Header("Content-Disposition: attachment; filename=".$file_name);$buffer=1024;$file_count=0;while(!feof($fp)&&$file_count<$file_size){$file_con=fread($fp,$buffer);$file_count+=$buffer;echo$file_con;}fclose($fp);}?>
当cookie中设置了user和pass时,代码执行到12行:
1
$sql="select * from SL_admin where A_login like '".filter_keyword($_COOKIE["user"])."' and A_pwd like '".filter_keyword($_COOKIE["pass"])."'";