Session->write('cakeAuth.lastUrl', $url); } // Function to Set / Get Session Vars function set($data='') { // Line 25 if( $data ) { $this->Session->write('cakeAuth', $data); $this->Session->write('cakeAuth.cacheRules', serialize($this->getRules($data['group_id']))); // Line 28 $this->Session->write('cakeAuth.noCheck', 0); } if($this->Session->check('cakeAuth') && $this->Session->valid('cakeAuth')) { $this->id = $this->Session->read('cakeAuth.id'); $this->externalId = $this->Session->read('cakeAuth.external_id'); $this->username = $this->Session->read('cakeAuth.username'); $this->login = $this->Session->read('cakeAuth.login'); $this->security = $this->Session->read('cakeAuth.security_level'); $this->groupId = $this->Session->read('cakeAuth.group_id'); $this->lastUrl = $this->Session->read('cakeAuth.lastUrl'); $this->cacheRules = unserialize($this->Session->read('cakeAuth.cacheRules') . ''); //Line 39 } elseif($this->Session->error()) { return $this->Session->error(); } return ($this->id != null); } // Logout Clean Session function logout() { // Line 48 $this->Session->del('cakeAuth'); if($this->Session->error()) { return $this->Session->error(); } } function _normalizeCheck($check = "") { $check = str_replace('/', '\/', $check); $check = str_replace('*', '.*', $check); $check = '/' . $check . '/'; return $check; } function getRules( $gid=null ) { if(empty($this->cacheRules)) { loadModel("CakeRule"); $CakeRule = new CakeRule; $this->cacheRules = $CakeRule->getRules( $gid ); for($i=0; $icacheRules); $i++) { $this->cacheRules[$i]['CakeRule']['action'] = $this->_normalizeCheck($this->cacheRules[$i]['CakeRule']['action']); } } return $this->cacheRules; } // Function to check the access for the controller / action function check($controller='', $action='') { $noCheck = $this->Session->read('cakeAuth.noCheck'); if($noCheck > 0) { $this->noCheck( $noCheck-- ); return true; } $checkStr = "{$controller}/{$action}/"; $allow = false; if($this->groupId) { $rules = $this->getRules($this->groupId); foreach( $rules as $data ) { $check = $data['CakeRule']['action']; if(preg_match($check, $checkStr, $matches)) $allow = $data['CakeRule']['allow']; } } return $allow; } function noCheck( $forTimes=1 ) { $this->Session->write('cakeAuth.noCheck', $forTimes); } function canDo( $checkStr = "", $debug=false ) { $allow = false; foreach( $this->cacheRules as $data ) { if(preg_match($data['CakeRule']['action'], $checkStr, $matches)) { $allow = $data['CakeRule']['allow']; if($debug) { echo "
";
          echo "preg_match({$data['CakeRule']['action']}, {$checkStr}, {$matches}))\n";
          echo $allow."\n";
          echo "-------------------------------------------------------------------\n";
          echo "
"; } } } return $allow; } } ?>