这有点奇怪,因为我在日志文件中看到这些错误,并且它们都不对应于我拥有的任何资源。事实上,我甚至不会识别错误文件中出现的任何这些资源
2010-12-26T12:19:46+00:00 ERR (3): Error Message Resource 'res' not found 2010-12-26T12:19:46+00:00 ERR (3): Stack Trace #0 /var/www/application/library/Zend/Acl.php(691): Zend_Acl->get('res') #1 /var/www/application/library/My/Controller/Plugin/Acl.php(29): Zend_Acl->isAllowed('guest', 'res', '2127250264.html') 2010-12-26T12:50:21+00:00 ERR (3): Error Message Resource 'fcs' not found 2010-12-26T12:50:21+00:00 ERR (3): Stack Trace #0 /var/www/application/library/Zend/Acl.php(691): Zend_Acl->get('fcs') #1 /var/www/application/library/My/Controller/Plugin/Acl.php(29): Zend_Acl->isAllowed('guest', 'fcs', 'ident2') 2010-12-26T12:50:22+00:00 ERR (3): Error Message Resource 'open' not found 2010-12-26T12:50:22+00:00 ERR (3): Stack Trace #0 /var/www/application/library/Zend/Acl.php(691): Zend_Acl->get('open') #1 /var/www/application/library/My/Controller/Plugin/Acl.php(29): Zend_Acl->isAllowed('guest', 'open', '1')
资源res,fcs,open或2127250264.html - 这些不是我的应用程序中的资源 - 所以我不确定这些错误是什么意思。
任何人都可以了解我如何进行调试。
修改
class My_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract { private $_acl = null; public function __construct(Zend_Acl $acl) { $this->_acl = $acl; } public function preDispatch(Zend_Controller_Request_Abstract $request) { //As in the earlier example, authed users will have the role user $role = (Zend_Auth::getInstance()->hasIdentity()) ? 'user' : 'guest'; $controller = $request->getControllerName(); $action = $request->getActionName(); $requestUri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); $session = new Zend_Session_Namespace('lastRequest'); // Temporary fix not to save view-image as last requested URL if(strpos($requestUri, 'snapshot')==false && $controller != 'register' && $controller != 'login' && $action != 'view-image' && $action != 'play-video' && $action != 'config') { //save the requested action only if it is not login $session->lastRequestUri = $requestUri; } if(!$this->_acl->isAllowed($role, $controller, $action)) { //If the user has no access we send him elsewhere by changing the request $request->setModuleName('default') ->setControllerName('login') ->setActionName('log'); } } }
这是我定义资源的类
class My_Acl extends Zend_Acl { public function __construct() { //Add a new role called "guest" $this->addRole(new Zend_Acl_Role('guest')); //Add a role called user, which inherits from guest $this->addRole(new Zend_Acl_Role('user'), 'guest'); //Add a resource called page $this->add(new Zend_Acl_Resource('video')); $this->add(new Zend_Acl_Resource('error')); $this->add(new Zend_Acl_Resource('index')); $this->add(new Zend_Acl_Resource('login')); $this->add(new Zend_Acl_Resource('register')); $this->add(new Zend_Acl_Resource('profile')); $this->add(new Zend_Acl_Resource('edit-profile')); $this->add(new Zend_Acl_Resource('css')); $this->add(new Zend_Acl_Resource('js')); $this->add(new Zend_Acl_Resource('images')); $this->add(new Zend_Acl_Resource('snapshots')); //Finally, we want to allow guests to view pages $this->allow('guest', 'css'); $this->allow('guest', 'js'); $this->allow('guest', 'snapshots'); $this->allow('guest', 'images'); $this->allow('guest', 'error'); $this->allow('guest', 'login'); $this->allow('guest', 'index'); $this->allow('guest', 'register'); $this->allow('guest', 'profile','view-profile'); $this->allow('guest', 'profile','view-image'); $this->allow('guest', 'profile','all-videos'); $this->allow('guest', 'profile','all-fans'); $this->allow('guest', 'profile','favorite-artists'); $this->allow('guest', 'profile','favorite-videos'); $this->allow('guest', 'video','display-thumb'); $this->allow('guest', 'video', 'config'); $this->allow('guest', 'video', 'play'); $this->allow('guest', 'video', 'play-video'); $this->allow('guest', 'video', 'new-videos'); $this->allow('guest', 'video', 'category'); $this->allow('guest', 'video', 'index'); $this->allow('guest', 'video', 'search'); $this->allow('user', 'video'); $this->allow('user', 'profile'); } }
答案 0 :(得分:0)
我猜想(没有看到你的My / Controller / Plugin / Acl.php)你从控制器/模块/动作名称中获取资源。有人访问了您不希望访问的URL(可能来自您的应用程序的旧版本,曾经有过不同的URL)。
答案 1 :(得分:0)
我最近收到了同样奇怪的消息。正如Tomáš建议的那样,我查看了apache访问日志,发现我的一张css表中有丢失的文件。
因此,当您的公用文件夹中缺少文件时 - 可能会出现
等错误 2011-02-22T02:44:49+03:00 DEBUG (7): Resource 'css' not found
/usr/local/Zend/Acl.php(777): Zend_Acl->get('css')
/home/www/public_html/application/plugins/AccessControl.php(61): Zend_Acl->isAllowed('guest', 'css', 'img')
要解决此问题 - 只需在css,html等中查找并删除丢失文件的请求