Location: PHPKode > projects > Real Estate Management > admin/pb_events.php
<?php

//define ("PB_CRYPT_LINKS" , "1");

function DoEvents($this) {
	global $_CONF , $_TSM;

	$_TSM["MENU"] = "";

	//checking if user is logged in
	if (!$_SESSION["minibase"]["user"]) {

		if ($_SERVER["REQUEST_METHOD"] == "POST") {

			//autentificate
			$user = $this->db->QFetchArray("select * from {$this->tables[users]} where `user_login` = '{$_POST[user]}' AND `user_password` = '{$_POST[pass]}'");

			if (is_array($user)) {
				$_SESSION["minibase"]["user"] = 1;
				$_SESSION["minibase"]["raw"] = $user;

				//redirecing to viuw sites
				header("Location: $_CONF[default_location]");
				exit;
			} else
				return $this->templates["login"]->blocks["Login"]->output;

		} else
			return $this->templates["login"]->blocks["Login"]->output;
	}
	if ($_SESSION["minibase"]["raw"]["user_level"] == 0) {
		$_TSM["MENU"] = $this->templates["login"]->blocks["MenuAdmin"]->output;
	} else {
		$_TSM["MENU"] = $this->templates["login"]->blocks["MenuUser"]->output;
	}

	if (!$_POST["task_user"])
		$_POST["task_user"] = $_SESSION["minibase"]["user"];

	if($_SESSION["minibase"]["raw"]["user_level"] == 1) {
		$_CONF["forms"]["adminpath"] = $_CONF["forms"]["userpath"];
	}

	switch ($_GET["sub"]) {
		case "logout":
			unset($_SESSION["minibase"]["user"]);
			header("Location: index.php");

			return $this->templates["login"]->EmptyVars();
		break;

		case "properties":
		case "schools":
		case "areas":	
		case "types":
		case "photos":

			if ($_POST["price"]) {
				$_POST["price"] = str_replace("," , "" , $_POST["price"]);				
			}

			if ($_POST["selling_price"]) {
				$_POST["selling_price"] = str_replace("," , "" , $_POST["selling_price"]);
			}
			
			
		
			if (($_GET["sub"] == "properties") && ($_GET["action"] == "details")) {
				$task = new CSQLAdmin("photos", $_CONF["forms"]["admintemplate"],$this->db,$this->tables , $extra);
				$extra["details"]["after"] = $task->DoEvents();				

			}
			
			
			$data = new CSQLAdmin($_GET["sub"], $_CONF["forms"]["admintemplate"],$this->db,$this->tables , $extra);
			return $data->DoEvents();
		break;

		case "users":

			if (!$_POST["job_date"]) {
				$_POST["job_date"] = time();
			}

			if (!$_POST["job_user"]) {
				$_POST["job_user"] = $_SESSION["minibase"]["raw"]["user_id"];
			}

			$data = new CSQLAdmin($_GET["sub"], $_CONF["forms"]["admintemplate"],$this->db,$this->tables);
			return $data->DoEvents();
		break;

		case "settings":

			$file = $_GET["sub"] . ".xml";

			$data = new CForm($_CONF["forms"]["admintemplate"],$this->db,$this->tables);

			if ($_GET["action"] == "store") {
				if (is_array($values = $data->Validate($_CONF["forms"]["adminpath"] . $file,$_POST))) {

					return $data->Show($_CONF["forms"]["adminpath"] . $file, $values);
				} else {

					$this->vars->SetAll($_POST);
					$this->vars->Save();

					header("location: index.php?mod=eshop&sub=" . $_GET["sub"]);
					exit;
				}
				
			}
					
			return $data->Show($_CONF["forms"]["adminpath"] . $file , array("values"=>$this->vars->data));

		break;

	}
}

?>
Return current item: Real Estate Management