Add owner restriction to container pages

feature/node-rewrite
Sven Slootweg 13 years ago
parent 00b3661201
commit fce6fed164

@ -44,4 +44,6 @@ class ContainerStopException extends ContainerException {}
class ContainerIpAddException extends ContainerException {} class ContainerIpAddException extends ContainerException {}
class ContainerIpRemoveException extends ContainerException {} class ContainerIpRemoveException extends ContainerException {}
class ContainerTrafficRetrieveException extends ContainerException {} class ContainerTrafficRetrieveException extends ContainerException {}
class UnauthorizedException extends Exception {}
?> ?>

@ -17,6 +17,11 @@ try
{ {
$sContainer = new Container($mainrouter->uParameters[1]); $sContainer = new Container($mainrouter->uParameters[1]);
if($sContainer->sUserId != $sUser->sId)
{
throw new UnauthorizedException("You are not authorized to control this container.");
}
$sError = ""; $sError = "";
$sPageContents = ""; $sPageContents = "";

@ -14,6 +14,15 @@
$_CVM = true; $_CVM = true;
require("includes/include.base.php"); require("includes/include.base.php");
if(!empty($_SESSION['userid']))
{
$sUser = new User($sUser);
}
else
{
$sUser = new User(0);
}
$sMainContents = ""; $sMainContents = "";
$sMainClass = ""; $sMainClass = "";
$sPageTitle = ""; $sPageTitle = "";
@ -25,6 +34,8 @@ $sPageContents = null;
$router = null; $router = null;
$sError = null; $sError = null;
try
{
$mainrouter = new CPHPRouter(); $mainrouter = new CPHPRouter();
$mainrouter->routes = array( $mainrouter->routes = array(
@ -38,6 +49,12 @@ $mainrouter->routes = array(
); );
$mainrouter->RouteRequest(); $mainrouter->RouteRequest();
}
catch (UnauthorizedException $e)
{
$sPageTitle = "Unauthorized";
$sMainContents = "You are not authorized to view this page.";
}
echo(Templater::InlineRender("main", $locale->strings, array( echo(Templater::InlineRender("main", $locale->strings, array(
'title' => $sPageTitle, 'title' => $sPageTitle,

Loading…
Cancel
Save