diff --git a/frontend/includes/include.exceptions.php b/frontend/includes/include.exceptions.php index 81b2173..d5f718f 100644 --- a/frontend/includes/include.exceptions.php +++ b/frontend/includes/include.exceptions.php @@ -44,4 +44,6 @@ class ContainerStopException extends ContainerException {} class ContainerIpAddException extends ContainerException {} class ContainerIpRemoveException extends ContainerException {} class ContainerTrafficRetrieveException extends ContainerException {} + +class UnauthorizedException extends Exception {} ?> diff --git a/frontend/module.vps.php b/frontend/module.vps.php index aba388f..2bf67f0 100644 --- a/frontend/module.vps.php +++ b/frontend/module.vps.php @@ -17,6 +17,11 @@ try { $sContainer = new Container($mainrouter->uParameters[1]); + if($sContainer->sUserId != $sUser->sId) + { + throw new UnauthorizedException("You are not authorized to control this container."); + } + $sError = ""; $sPageContents = ""; diff --git a/frontend/rewrite.php b/frontend/rewrite.php index 33c54d9..b58572b 100644 --- a/frontend/rewrite.php +++ b/frontend/rewrite.php @@ -14,6 +14,15 @@ $_CVM = true; require("includes/include.base.php"); +if(!empty($_SESSION['userid'])) +{ + $sUser = new User($sUser); +} +else +{ + $sUser = new User(0); +} + $sMainContents = ""; $sMainClass = ""; $sPageTitle = ""; @@ -25,19 +34,27 @@ $sPageContents = null; $router = null; $sError = null; -$mainrouter = new CPHPRouter(); +try +{ + $mainrouter = new CPHPRouter(); -$mainrouter->routes = array( - 0 => array( - '^/?$' => "module.home.php", - '^/containers/?$' => "module.list.php", - '^/login/?$' => "module.login.php", - '^/logout/?$' => "module.logout.php", - '^/([0-9]+)(/.*)?$' => "module.vps.php" - ) -); + $mainrouter->routes = array( + 0 => array( + '^/?$' => "module.home.php", + '^/containers/?$' => "module.list.php", + '^/login/?$' => "module.login.php", + '^/logout/?$' => "module.logout.php", + '^/([0-9]+)(/.*)?$' => "module.vps.php" + ) + ); -$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( 'title' => $sPageTitle,