shell bypass 403
<?
App::uses('PrivateController', 'Controller');
class PrivateContactosController extends PrivateController {
public function beforeFilter() {
parent::beforeFilter();
array_push($this->uses, 'Contacto');
}
public function home() {
$this->getListado('Contacto', 20, $this->App->getOrden('Contacto'));
$this->getOrigenes($this->listado);
$this->renderView();
}
public function show() {
$this->Contacto->id = $this->params->id;
if (!$this->Contacto->exists()) {
$this->Session->setFlash('Contacto no encontrado.' . $this->btnClose, 'default', array('class' => 'alert alert-danger'));
$this->redirect(array('controller' => 'private_contactos', 'action' => 'home'));
}
$contacto = $this->Contacto->findById($this->Contacto->id);
//Marcamos el contacto como leído
$this->Contacto->updateAll(array('leido' => true), array('Contacto.id' => $contacto['Contacto']['id']));
$this->set('contacto', $contacto);
$this->getOrigenes(array($contacto));
$this->renderView();
}
//Método que prepara los orígenes de los contactos
private function getOrigenes($contactos) {
$origenes = array();
$entidades = array();
foreach ($contactos as $c) {
if (!empty($c['Contacto']['entidad']) && !empty($c['Contacto']['entidad_id'])) {
if (!array_key_exists($c['Contacto']['entidad'], $entidades)) {
$entidades[$c['Contacto']['entidad']] = array();
}
if (!in_array($c['Contacto']['entidad_id'], $entidades[$c['Contacto']['entidad']])) {
$entidades[$c['Contacto']['entidad']][] = $c['Contacto']['entidad_id'];
}
}
}
foreach ($entidades as $k => $v) {
$entidad = Inflector::camelize($k);
array_push($this->uses, $entidad);
foreach ($this->{$entidad}->find('all', array('conditions' => array("$entidad.id" => $v), 'recursive' => false)) as $e) {
$origenes[$k][(int) $e[$entidad]['id']] = $e;
}
}
$this->set('origenes', $origenes);
}
}