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


$ref=$_SERVER["HTTP_REFERER"];
		 
if(isset($_SERVER["HTTP_REFERER"])){
	  if(!(ereg($_SERVER["HTTP_HOST"],$ref)))
		{
		   echo "Security!!";
		   exit();
		}
}



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


if(isset($_POST["submit"])) $submit=$_POST["submit"]; else $submit="";
$name = $_POST["_name"];
$pass = $_POST["_pass"];

		  switch($submit){
		  case"LOGIN";
		      if(($name) && ($pass)) $sess = $infoboard->adminlogin($name, $pass);
		  break;
		  case"NEW ADMIN";
		        $mail = $_POST["_mail"];
				$infoboard->adminsess();
				if(($name) && ($pass) && ($mail)){
					 if($_FILES["image"]["size"]){
						  $ext = strtolower($infoboard->getlast($_FILES["image"]["name"]));
						  if(move_uploaded_file($_FILES["image"]["tmp_name"], "../data/admin/".$name.".".$ext)){
							   $infoboard->iswrite("../data/admin/".$name.".ext.dat", $ext);
						  }
					  }

					   $fieldname="
					   _name,
					   _pass,
					   _mail
					   ";
					   $fieldvalue="
					   '".addslashes($name)."',
					   '".md5($pass)."',
					   '".addslashes($mail)."'
					   ";
					   $infoboard->tbinsert("_admin", $fieldname, $fieldvalue);
				}
		  break;
		  case"EDIT ADMIN";
		        $mail = $_POST["_mail"];
				$infoboard->adminsess();
				if(($name) && ($pass) && ($mail)){

					$oleext = $_POST["ext"];

					 if($_FILES["image"]["size"]){
						  $ext = strtolower($infoboard->getlast($_FILES["image"]["name"]));
						  if(move_uploaded_file($_FILES["image"]["tmp_name"], "../data/admin/".$name.".".$ext)){
							   $infoboard->iswrite("../data/admin/".$name.".ext.dat", $ext);
							   if($oleext){
								    if($oleext != $ext){
										  if(file_exists("../data/admin/".$name.".".$oleext)) unlink("../data/admin/".$name.".".$oleext);
									}
							   }
						  }
					  }

					   $fieldupdate="
					   _name='".addslashes($name)."',
					   _pass='".md5($pass)."',
					   _mail='".addslashes($mail)."'
					   ";
					   if($infoboard->tbupdate("_admin", $fieldupdate, "_cid", $iscon["idadmin"])){
						     session_register("admin");
							 $_SESSION["admin"] = $name;
							 session_register("mailadmin");
							 $_SESSION["mailadmin"] = $mail;
					   }
				}
		  break;
		  default;
		  }
refurl("", $_SERVER['HTTP_REFERER']);

?>
Return current item: infoboard