Location: PHPKode > projects > infoboard > infoboard/_req/infoboardedit.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();

if($iscon["user"]){
	 $and = " and _userid='".$iscon["iduser"]."'";
}elseif($iscon["admin"]){
	 $and = "";
}else{
	 refback($iscon["lang"][112]);
}

$counticon = $infoboard->isread("../data/icon.dat");


if(isset($_POST["editact"])) $editact=$_POST["editact"]; else $editact="";
if(isset($_POST["cid"])) $cid=$_POST["cid"]; else $cid="";
if(!$cid) exit();

if(isset($_POST["cat"])) $cat=$_POST["cat"]; else $cat="";
if(!$cat) exit();


$qid=$_POST["qid"];


$qlevel=$_POST["_qlevel"];
$alevel=$_POST["_alevel"];
$readlevel=$_POST["_readlevel"];

$checkq=$_POST["_checkq"];
$checka=$_POST["_checka"];

$checkpic=$_POST["_checkpic"];
$uppic=$_POST["_uppic"];



$infoboard->isconnect();

$check = 0;

if(!$iscon["admin"]){
		  switch($editact){
		  case"1";
				$check = $checkq;
		  break;
		  case"2";
				$check = $checka;
		  break;
		  case"3";
				$check = $checkq;
		  break;
		  case"4";
				$check = $checka;
		  break;
		  default;
		  }
		  if($check > 0) refback($iscon["lang"][122]);
}


$olepic = $_POST["olepic"];
if($olepic){
	 $temp=$olepic;
}else{
	 $temp=rand(0,999).time();
}

$oleext = $_POST["oleext"];


$picname = "";
$ext="";
$updatepic="";

if($_POST["format"] == 1){
	  if(isset($_FILES["image1"]["size"])){
		   if($_FILES["image1"]["size"]) $ext=$infoboard->up1($temp, $uppic);
	  }
}elseif($_POST["format"] == 2){
	  $count=0;
	  for($i=2; $i<=9; $i++){
		   if(isset($_FILES["image".$i]["size"])){
			    if($_FILES["image".$i]["size"]) $count++;
		   }
	  }
	  if($count > 0) $ext=$infoboard->up2($temp, $uppic);
}

if($ext){
	 if($oleext){
		  if($_POST["format"] == 1){
			    if($oleext != $ext){
					  if(file_exists("../data/pic/".$olepic.".".$oleext)) unlink("../data/pic/".$olepic.".".$oleext);
				}
		  }
	 }
	 $picname=$temp;
	 $updatepic=$temp.".".$ext;
}else{
	 $picname=$olepic;
	 $ext=$oleext;
}


$detail=$_POST["_detail"];
$detail = $infoboard->geticon(stripslashes($detail), $counticon);


if(isset($_POST["inputcode"])) $incode=$_POST["inputcode"]; else $incode="";
if(isset($_POST["previewcode"])) $precode=$_POST["previewcode"]; else $precode="";


if(trim($incode)){
	 $code = $incode;
}else{
	 $code = $precode;
}

$target=$_POST["target"];
$save = "";

$update = date("d-m-Y H:i", time());
$update ="<br />".$update;


		  switch($editact){
		  case"1";
		        $data = $infoboard->fieldselect("_infoboardq", "_edit", "_cid", $cid);
		        $topic=$_POST["topic"];
				$fieldupdate="
				_topic='".addslashes($topic)."',
				_detail='".addslashes($detail)."',
				_code='".addslashes($code)."',
				_pic='".$picname."',
				_ext='".$ext."',
				_edit='".$data.$update."'
				";
				$save=$infoboard->tbupdateat("_infoboardq", $fieldupdate, "_cid='".$cid."' ".$and."");
		  break;
		  case"2";
		        $data = $infoboard->fieldselect("_infoboarda", "_edit", "_cid", $cid);
				$fieldupdate="
				_detail='".addslashes($detail)."',
				_code='".addslashes($code)."',
				_pic='".$picname."',
				_ext='".$ext."',
				_edit='".$data.$update."'
				";
				$save=$infoboard->tbupdateat("_infoboarda", $fieldupdate, "_cid='".$cid."' ".$and."");
		  break;
		  case"3";
		        $data = $infoboard->fieldselect("_infoboardi", "_edit", "_cid", $cid);
				$fieldupdate="
				_detail='".addslashes($detail)."',
				_code='".addslashes($code)."',
				_pic='".$picname."',
				_ext='".$ext."',
				_edit='".$data.$update."'
				";
				$save=$infoboard->tbupdateat("_infoboardi", $fieldupdate, "_cid='".$cid."' and _target='1' ".$and."");
		  break;
		  case"4";
		        $data = $infoboard->fieldselect("_infoboardi", "_edit", "_cid", $cid);
				$fieldupdate="
				_detail='".addslashes($detail)."',
				_code='".addslashes($code)."',
				_pic='".$picname."',
				_ext='".$ext."',
				_edit='".$data.$update."'
				";
				$save=$infoboard->tbupdateat("_infoboardi", $fieldupdate, "_cid='".$cid."' and _target='2' ".$and."");
		  break;
		  default;
		  }
		  
		  if($save){
			   if(trim($incode)) $infoboard->codewrite($cid, $target, $incode);
			   $exp = explode($iscon["_s"], $_POST["idpage"]);
			   $infoboard->savecache($exp[0], $exp[1]);
			   if($updatepic) $infoboard->tbupdate("_infoboardq", "_piccover='".$updatepic."' , _coverformat='".$_POST["format"]."'", "_cid", $qid);
			   refurl($iscon["lang"][105], "../".$infoboard->txtmod()."topic".$iscon["_s"].$_POST["idpage"].$infoboard->extmod());
		  }else{
			   refback($iscon["lang"][123]);
		  }

$infoboard->isclose();

?>
Return current item: infoboard