function lx($id = null) { App::import('Helper', 'Base'); $base = new BaseHelper(); $id = $base->decode($id); if (!$id) { $this->Session->setFlash('Invalid URL'); $this->redirect(array('action' => 'index'), null, true); } $this->data = $this->Link->findById($id, array('recursive' => false)); if (!$this->data) { $this->Session->setFlash('Invalid URL'); $this->redirect(array('action' => 'index'), null, true); } $log = ClassRegistry::init('Log'); $log->create(array('link_id' => $id, 'referrer' => $this->referer(), 'address' => $this->RequestHandler->getClientIP())); $log->save(); header('Location: ' . $this->data['Link']['url']); }