shell bypass 403
<?
App::uses('PrivateController', 'Controller');
class PrivateSlidersController extends PrivateController {
public function beforeFilter() {
parent::beforeFilter();
array_push($this->uses, 'Slider', 'Inmueble');
}
public function home() {
$this->getListado('Slider', 20, $this->App->getOrden('Slider'));
$this->renderView();
}
public function add() {
$this->set('inmuebles', $this->Inmueble->find('list', array('conditions' => array('Inmueble.publicado' => true), 'fields' => 'id, listado_destacados_ref_title', 'order' => array('Inmueble.referencia' => 'ASC'))));
if ($this->request->is('post')) {
$this->Slider->create();
unset($this->request->data['Slider']['id'], $this->request->data['Slider']['orden'], $this->request->data['Slider']['created'], $this->request->data['Slider']['modified']); //campos que no son modificables por el usuario
if ($this->Slider->save($this->request->data)) {
$this->Session->setFlash('Slider añadido con éxito.' . $this->btnClose, 'default', array('class' => 'alert alert-success'));
$this->redirect(array('controller' => 'private_sliders', 'action' => 'home'));
} else {
$this->errores = $this->Slider->validationErrors;
}
}
$this->renderView();
}
public function edit() {
$this->set('inmuebles', $this->Inmueble->find('list', array('conditions' => array('Inmueble.publicado' => true), 'fields' => 'id, listado_destacados_ref_title', 'order' => array('Inmueble.referencia' => 'ASC'))));
$this->Slider->id = $this->params->id;
if (!$this->Slider->exists()) {
$this->Session->setFlash('Slider no encontrado.' . $this->btnClose, 'default', array('class' => 'alert alert-danger'));
$this->redirect(array('controller' => 'private_sliders', 'action' => 'home'));
}
$slider = $this->Slider->findById($this->Slider->id);
if ($this->request->is('put') || $this->request->is('post')) {
unset($this->request->data['Slider']['id'], $this->request->data['Slider']['orden'], $this->request->data['Slider']['created'], $this->request->data['Slider']['modified']); //campos que no son modificables por el usuario
if ($this->Slider->save($this->request->data)) {
$this->Session->setFlash('Slider actualizado con éxito.' . $this->btnClose, 'default', array('class' => 'alert alert-success'));
$this->redirect(array('controller' => 'private_sliders', 'action' => 'home'));
} else {
$this->errores = $this->Slider->validationErrors;
}
} else {
$this->request->data = $slider;
}
$this->set('slider', $slider);
$this->renderView();
}
public function delete() {
$this->Slider->id = $this->params->id;
if (!$this->Slider->exists()) {
$this->Session->setFlash('Slider no encontrado.' . $this->btnClose, 'default', array('class' => 'alert alert-danger'));
$this->redirect(array('controller' => 'private_sliders', 'action' => 'home'));
}
if ($this->Slider->delete()) {
$this->Session->setFlash('Slider eliminado con éxito.' . $this->btnClose, 'default', array('class' => 'alert alert-success'));
} else {
$this->Session->setFlash('El slider no pudo ser eliminado.' . $this->btnClose, 'default', array('class' => 'alert alert-danger'));
}
$this->redirect(array('controller' => 'private_sliders', 'action' => 'home'));
}
public function ordenar() {
$this->Slider->id = $this->params->id;
if (!$this->Slider->exists()) {
$this->Session->setFlash('Slider no encontrado.' . $this->btnClose, 'default', array('class' => 'alert alert-danger'));
$this->redirect(array('controller' => 'private_sliders', 'action' => 'home'));
}
$slider = $this->Slider->findById($this->Slider->id);
switch ($this->params->orden) {
case 'up':
$otro = $this->Slider->findByOrden((int) $slider['Slider']['orden'] - 1);
if (!empty($otro)) {
$this->Slider->updateAll(array('Slider.orden' => (int) $slider['Slider']['orden']), array('Slider.id' => $otro['Slider']['id']));
$this->Slider->updateAll(array('Slider.orden' => (int) $slider['Slider']['orden'] - 1), array('Slider.id' => $this->Slider->id));
}
break;
case 'down':
$otro = $this->Slider->findByOrden((int) $slider['Slider']['orden'] + 1);
if (!empty($otro)) {
$this->Slider->updateAll(array('Slider.orden' => (int) $slider['Slider']['orden']), array('Slider.id' => $otro['Slider']['id']));
$this->Slider->updateAll(array('Slider.orden' => (int) $slider['Slider']['orden'] + 1), array('Slider.id' => $this->Slider->id));
}
break;
}
$this->Session->setFlash('Sliders actualizados con éxito.' . $this->btnClose, 'default', array('class' => 'alert alert-success'));
$this->redirect(array('controller' => 'private_sliders', 'action' => 'home'));
}
}