Location: PHPKode > projects > RabbitBB - Online Web Storage Project > mywebdrive/PHP_CON/maincontroller.php
<?PHP


$rootpath=$_SERVER['DOCUMENT_ROOT'] . "/";
include_once($rootpath . "common.php");


if (is_array($_GET) && (isset($_GET['action'])))
   doGet($_GET);
elseif (is_array($_POST) && (isset($_POST['action'])))
   doPost($_POST);
else
   exit;


function doGet($request)
{
	global $rootpath, $webappcfg, $rb;

	if ($request['action']=="formlogin")
	{
		if (isset($_SESSION['user_id']))
		{
			if ($_SESSION['login']==1)
			{
				// Redirect to index page
				//header("Location:http://" . $webappcfg['httphost'] . "/");
				include($rootpath . "webdrive/index.php");
				return;
			}
		}
		else
		{
			include($rootpath . "login/index.php");
			return;
		}
	}
	elseif ($request['action']=="login")
	{
		if (!isset($request['f_login']) || !isset($request['f_password']))
		{
			echo ("Hacking Attempt");
			return;
		}
		include_once($webappcfg['APPPATH'] . "/user/include.php");
		$tbsua = new BSUserAccount();
		$checking = $tbsua->authUser($request['f_login'], $request['f_password']);
		if ($checking>0)
		{
			//$_SESSION['user_id'] = $checking;
			//$_SESSION['login'] = 1;
			NSession::loginnow($checking);
			header("Location:http://".$_SERVER['HTTP_HOST']."/webdrive/index.php");
			return;
		}
		elseif ($checking==ACCOUNTNOTACTIVE)
		{
			$response['error'] = "ACCOUNTNOTACTIVE";
			include($rootpath . "login/index.php");
			return;
		}
		elseif ($checking==WRONGPASSWORD)
		{
			$response['error'] = "WRONGPASSWORD";
			include($rootpath . "login/index.php");
			return;
		}
		elseif ($checking==NOTEXISTINGUSER)
		{
			$response['error'] = "NOTEXISTINGUSER";
			include($rootpath . "login/index.php");
			return;
		}
	}
	elseif ($request['action']=="machinelogin")
	{
		if (!isset($request['f_login']) || !isset($request['f_password']))
		{
			echo ("EMPTY");
			return;
		}
		include_once($webappcfg['APPPATH'] . "/user/include.php");
		$tbsua = new BSUserAccount();
		$checking = $tbsua->authUser($request['f_login'], $request['f_password']);
		if ($checking>0)
		{
			NSession::loginnow($checking);
			echo("LOGINSUCCESS");
			return;
		}
		else
		{
			echo("WRONGPASSWORD");
			return;
		}
	}
	elseif ($request['action']=="logout")
	{
		if (isset($_SESSION['user_id']))
			unset($_SESSION['user_id']);
		if (isset($_SESSION['login']))
			unset($_SESSION['login']);
		include($rootpath . "index.php");
	}
	elseif ($request['action']=="initaccount")
	{
		include_once($webappcfg['APPPATH'] . "/file/include.php");
		include_once($webappcfg['APPPATH'] . "/dir/include.php");

		include_once($webappcfg['APPPATH'] . "/general/include.php");
		include_once($webappcfg['APPPATH'] . "/rename/include.php");
		include_once($webappcfg['APPPATH'] . "/init/include.php");

		$response = array();
		
		$bsia = new BSInitAccount();
	
		$request['ownerid'] = NSession::getuid();
		$response = $bsia->initAccount($request, $response);
		if ($response['result'] == true)
			echo("SUCCESS");
		else
		{
			print_r($response);
		}
	}
}

function doPost($request)
{
	doGet($request);
}

?>
Return current item: RabbitBB - Online Web Storage Project