Location: PHPKode > projects > infoboard > infoboard/_req/delete.php
<?
session_start();
include("../data/connect.php");
include("../data/_uconfig.php");
include("../_class/lang.php");
include("../_class/lang_".$iscon["getlang"].".php");

include("../_class/_func.php");
include("../_class/class.global.php");
include("../_class/class.req.php");

$infoboard = new req_infoboard();
$infoboard->checksess();
$infoboard->adminsess();

$infoboard->isconnect();
$delete = "";

if(isset($_GET["action"])) $action=$_GET["action"]; else $action="";


		  switch($action){
		  case"delgroup";
		      if(isset($_GET["idcat"])) $idcat=$_GET["idcat"]; else $idcat="";
		      $query=mysql_db_query($infoboard->dbname, "select * from _infoboardq  where _cat='".$idcat."'");
			   while($result = @mysql_fetch_array($query)){
				    $qid = $result["_cid"];
					$infoboard->delpic($result["_picformat"], $result["_pic"], $result["_ext"]);
					$infoboard->delcode($qid, 1);
					$infoboard->delins($idcat, "_qid='".$qid."' and _target='1'");
					$infoboard->deltb($qid, "_infoboardq");
					$query2=mysql_db_query($infoboard->dbname, "select * from _infoboarda  where _cat='".$idcat."' and _qid='".$qid."'");
					while($result2 = @mysql_fetch_array($query2)){
						  $aid = $result2["_cid"];
						  $infoboard->delpic($result2["_picformat"], $result2["_pic"], $result2["_ext"]);
						  $infoboard->delcode($aid, 2);
						  $infoboard->delins($idcat, "_aid='".$aid."' and _target='2'");
						  $infoboard->deltb($aid, "_infoboarda");
					}
			   }
			   if($infoboard->deltb($idcat, "_group")) $delete = true;
		  break;
		  case"deltopic";
		      if(isset($_GET["cid"])) $cid=$_GET["cid"]; else $cid="";
			  if(!$cid) exit();
		      $query=mysql_db_query($infoboard->dbname, "select * from _infoboardq  where _cid='".$cid."'");
			   if($result =@mysql_fetch_array($query)){
				    $idcat = $result["_cat"];
					$infoboard->delpic($result["_picformat"], $result["_pic"], $result["_ext"]);
					$infoboard->delcode($cid, 1);
					$infoboard->delins($idcat, "_qid='".$cid."' and _target='1'");
					$query2=mysql_db_query($infoboard->dbname, "select * from _infoboarda  where _cat='".$idcat."' and _qid='".$cid."'");
					while($result2 = @mysql_fetch_array($query2)){
						  $aid = $result2["_cid"];
						  $infoboard->delpic($result2["_picformat"], $result2["_pic"], $result2["_ext"]);
						  $infoboard->delcode($aid, 2);
						  $infoboard->delins($idcat, "_aid='".$aid."' and _target='2'");
						  $infoboard->deltb($aid, "_infoboarda");
					}
					if($infoboard->deltb($cid, "_infoboardq")) $delete = true;
			   }
		  break;
		  case"delans";
		      if(isset($_GET["cid"])) $cid=$_GET["cid"]; else $cid="";
			  if(!$cid) exit();
			  $query=mysql_db_query($infoboard->dbname, "select * from _infoboarda  where _cid='".$cid."'");
			  if($result = @mysql_fetch_array($query)){
					$qid = $result["_qid"];
				    $idcat = $result["_cat"];
					$infoboard->delpic($result["_picformat"], $result["_pic"], $result["_ext"]);
					$infoboard->delcode($cid, 2);
					$insert=0;
					$query2=mysql_db_query($infoboard->dbname, "select * from _infoboardi  where _cat='".$idcat."' and _aid='".$cid."' and _target='2'");
					while($result2 = @mysql_fetch_array($query2)){
						  $infoboard->delpic($result2["_picformat"], $result2["_pic"], $result2["_ext"]);
						  $infoboard->delcode($result2["_cid"], 3);
						  if($infoboard->deltb($result2["_cid"], "_infoboardi")){
							   $insert++;
						  }
					}
					if($infoboard->deltb($cid, "_infoboarda")){
						 if($insert > 0){
							   $fieldupdate="
							   _insert=_insert-$insert,
							   _reply=_reply-1
							   ";
						 }else{
							   $fieldupdate="
							   _reply=_reply-1
							   ";
						 }
						 if($infoboard->tbupdate("_infoboardq", $fieldupdate, "_cid", $qid)){
							   $delete = true;
						 }
					}
			  }
		  break;
		  case"delins";
		      if(isset($_GET["cid"])) $cid=$_GET["cid"]; else $cid="";
			  if(!$cid) exit();
			  
			  $query=mysql_db_query($infoboard->dbname, "select * from _infoboardi  where _cid='".$cid."'");
			  if($result = @mysql_fetch_array($query)){
				   $qid = $result["_qid"];
				   $infoboard->delpic($result["_picformat"], $result["_pic"], $result["_ext"]);
				   $infoboard->delcode($cid, 3);
				   if($infoboard->deltb($cid, "_infoboardi")){
					     $fieldupdate="
						 _insert=_insert-1
						 ";
						 if($infoboard->tbupdate("_infoboardq", $fieldupdate, "_cid", $qid)){
							   $delete = true;
						 }
				   }
			  }
		  break;
		  case"delicon";
		     if(file_exists("../data/icon/i".$_GET["cid"].".gif")){
				 unlink("../data/icon/i".$_GET["cid"].".gif");
				 $delete = true;
			 }
		  break;

		  case"deluser";
		     if($infoboard->deltb($_GET["cid"], "_user")){
				   if(isset($_GET["ext"])){
					     if(file_exists("../data/user/i".$_GET["n"].".".$_GET["ext"])) unlink("../data/user/i".$_GET["n"].".".$_GET["ext"]);
				   }
				   $delete = true;
			 }
		  break;

		  case"deladmin";
		     if($infoboard->deltb($_GET["cid"], "_admin")){
				   $delete = true;
			 }
		  break;

		  case"pic";
		      $tbact="";
		      $tb = $_GET["tb"];
			  if($tb == "topic"){
				  $tbact = "_infoboardq";
			  }elseif($tb == "ans"){
				  $tbact = "_infoboarda";
			  }elseif($tb == "ins"){
				   $tbact = "_infoboardi";
			  }

			  $fieldupdate="
			  _activeimg='1',
			  _pic='',
			  _ext=''
			  ";
			  if($infoboard->tbupdate($tbact, $fieldupdate, "_cid", $_GET["cid"])){
				    $infoboard->delpic($_GET["f"], $_GET["n"], $_GET["ex"]);
					$infoboard->updateproof("improof", $_GET["cat"], $_GET["page"]);
				    $delete = true;
			  }
		  break;
		  default;
		  }
		  if($delete) refurl($iscon["lang"][105], $_SERVER['HTTP_REFERER']);

?>
Return current item: infoboard