2008年8月8日星期五

Re: [fw-mvc] Prevent action from being executed

-- Hector Virgen <djvirgen@gmail.com> wrote
(on Friday, 08 August 2008, 11:49 AM -0700):
> Is there a way to know which route the router matched to the requested
> path?

Yes:

$router = Zend_Controller_Front::getInstance()->getRouter();
$route = $router->getCurrentRouteName();

> For example something like this could be very useful:
>
> <?php
>
> class IndexController extends Zend_Controller_Action
> {
> public function preDispatch()
> {
> $routeName = $this->_request->getRouteName();
> $actionName = $this->_request->getActionName();
> if ($actionName == 'menu' && $routename == 'default') {
> // handle appropriately
> }
> }
> }
>
> -Hector
>
> Giorgio Sironi wrote:
>
> 2008/8/8 Greg Freeman <greg@imagize.com.au>:
>
>
> How do you prevent an action from being called directly? I have an action
> that is used to render a menu response segment for the layout. I don't want
> people to be able to call it directly via a URL.
>
>
>
> Where is the problem, if you don't publish a link, people cannot guess
> the action name.. And even if they guess they only see a broken page,
> no security exploits.
>
>
>
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: