public function after() { $this->ajax->config(array_replace($this->ajax_config, $this->ajax(), array('exit_allowed' => false, 'return' => true))); parent::after(); if (Phery::is_ajax(true)) { try { if (($response = $this->ajax->process()) !== false) { $this->response->headers(array('Content-Type' => 'application/json'))->body($response); } } catch (PheryException $exc) { Kohana::$log->add(Log::ERROR, $exc->getMessage()); $answer = PheryResponse::factory(); if ($exc->getCode() === Phery::ERROR_CSRF) { $answer->renew_csrf($this->ajax); } $this->response->headers(array('Content-Type' => 'application/json'))->body($answer); } } }
/** * Renew the CSRF token on a given Phery instance * Resets any selectors that were being chained before * * @param Phery $instance Instance of Phery * @return PheryResponse */ public function renew_csrf(Phery $instance) { if ($instance->config('csrf') === true) { $this->cmd(13, array($instance->csrf())); } return $this; }
break; case 'redirect': return array(true, true); break; default: return array('Not Found', '<h1>404 Not Found</h1><p>The requested url was not found</p>'); break; } } else { return array('Welcome', '<h1>Welcome!</h1>'); } } $pseudo_controller = pseudo_controller(); $content = $menu . $pseudo_controller[1]; try { $phery->config(array('exceptions' => true, 'csrf' => true))->data(array('menu' => $menu))->views(array('#container' => function ($data, $param) { $render = pseudo_controller(); if ($render[0] === true) { return PheryResponse::factory()->json(array('doesnt work'))->j('#wont select')->text('because redirect clear all commands')->redirect('?page=home', $param['view']); } return PheryResponse::factory()->render_view($param['menu'] . $render[1], array('title' => $render[0])); }))->callback(array('before' => 'mem_start', 'after' => 'mem_end'))->set(array('readcode' => function ($config) { $file = fopen(realpath(__FILE__), 'r'); global $end_line; $r = new PheryResponse(); if (!empty($config['from']) && !empty($config['to']) && (int) $config['from'] > 0 && (int) $config['to'] > 0 && (int) $config['to'] < $end_line) { $lines = 1; $code = array(); while (fgets($file) !== false) { if (++$lines === (int) $config['from']) { break;