0
votes

This is a bit weird because I am seeing these bunch of errors in my log files and none of them correspond to any resources that I have. Infact I dont even recognize any of these resources that show up in the error files

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')

Resource res, fcs, open or the 2127250264.html - these are not resources in my application - so I'm not sure what these errors mean.

Can anyone shed any light on how I can go about debugging this.


EDIT

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');
    }
  }
}

And this is the class where I have defined the resources

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');
  }
}

2
show us the code in Acl.php please .tawfekov
Have updated the question with the code - ThanksGublooo

2 Answers

0
votes

I would guess (without seeing your My/Controller/Plugin/Acl.php) that you derive your resources from controller/module/action name. And someone accessed URL that you would not expect to be visited (maybe from older version of you application, that used to have different URLs).

0
votes

I had the same strange messages recently. As Tomáš suggested, I looked through apache access logs and found that there were missing files that were requested by one of my css sheets.

So when you have a missing file in your public folder - you might get errors like

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')

To solve this - simply find and remove requests for missing files in your css, html etc