/home/u193142680/domains/catafesta.com.br/public_html/lib/Response.php
}
public function getCookies() {
return $this->cookies;
}
public function setCookies($cookies) {
$this->cookies = $cookies;
}
public function redirect($url) {
if (!preg_match('/^http[s]?/',$url)) {
$url = trim($this->req->base_url,'/').'/'.trim($url,'/');
}
$this->redirect_url = $url;
}
public function render($tpl,$vars = array()) {
if ($vars['req']) {
$req = $vars['req'];
}
//$vars['i18n'] = new I18n($req->language);
I18n::setup($req->language);
$view = $this->getView();
$this->content = $view->render($tpl,$vars);
//$this->header('Link','<static/css/style.css>; rel=preload; as=style');
//$doc = phpQuery::newDocument($this->content);
//phpQuery::selectDocument($doc);
/*
$links = pq('link[rel=stylesheet]');
/home/u193142680/domains/catafesta.com.br/public_html/lib/Response.php
}
public function getCookies() {
return $this->cookies;
}
public function setCookies($cookies) {
$this->cookies = $cookies;
}
public function redirect($url) {
if (!preg_match('/^http[s]?/',$url)) {
$url = trim($this->req->base_url,'/').'/'.trim($url,'/');
}
$this->redirect_url = $url;
}
public function render($tpl,$vars = array()) {
if ($vars['req']) {
$req = $vars['req'];
}
//$vars['i18n'] = new I18n($req->language);
I18n::setup($req->language);
$view = $this->getView();
$this->content = $view->render($tpl,$vars);
//$this->header('Link','<static/css/style.css>; rel=preload; as=style');
//$doc = phpQuery::newDocument($this->content);
//phpQuery::selectDocument($doc);
/*
$links = pq('link[rel=stylesheet]');
/home/u193142680/domains/catafesta.com.br/public_html/site/controllers/DefaultController.php
//return $res->redirect('404');
http_response_code(404);
$language = $req->language;
$meta = array();
$meta = \Models\Meta::get('404',$language,false);
if (!isset($meta->id)) {
$meta = new \stdclass();
\Lib\I18n::setup($language);
$titulo = \Lib\I18n::get('pagina-nao-encontrada',"Página não encontrada");
$Meta2 = \Models\Meta::get('home',$req->language,true);
$meta->title = $titulo.' - '.$Meta2->title;
}
$extras['meta'] = $meta;
return $res->render('404/index.twig',$extras);
}
$table = $record->table;
$modulo = \R::findOne('modulo', 'deleted = 0 and ativo = 1 and folder = ? limit 1', array($table));
if (!preg_match('/^(?<controller>.+)Controller\:\:(?<method>.+)Action$/', $modulo->site_controller, $matches)) {
//var_dump($modulo->site_controller);exit;
return $res->redirect('404');
}
//$req->params = array($slug);
$req->params_old = $req->params;
//trigger_error('1:' .print_r($req->params,1));
$req->params = array();
$req->params[] = $slug;
if (!in_array($req->method, array('index'))) {
/home/u193142680/domains/catafesta.com.br/public_html/site/controllers/DefaultController.php
<?php
namespace Controller;
use Lib\Config;
use Lib\View;
use Lib\MySession;
class DefaultController {
public static function IndexAction($req,$res, $extraArgs = array()) {
$tpl = $req->controller.'/'.$req->method.'.twig';
$view_dir = dirname(__DIR__).'/views';
if (!file_exists($view_dir.'/'.$tpl)) {
$tpl = 'home/index.twig';
//$res->redirect('404');
return static::ResolveSlug($req, $res, $extraArgs);
}
$publico = array('inicio');
if (!in_array($req->controller, $publico)) {
$Maior = MySession::get('maior');
if (null == $Maior && (\Lib\Util::pagespeed()==0)) {
\Lib\MySession::set('redirect_url',$_SERVER['PHP_SELF']);
return $res->redirect('inicio');
}
}
$defaultArgs = array(
'req' => $req,
'res' => $res
);
$args = $defaultArgs + $extraArgs;
$res->render($tpl,$args);
/home/u193142680/domains/catafesta.com.br/public_html/lib/Router.php
if ($cacheTime !== 0 && !isset($req->get->noCache) && in_array($req->type, array('GET'))) {
//CacheManager::setup($cache['config']);
//$cache = phpFastCache();
$cache_key = sha1($req->base_url.$req->controller.'/'.$req->method.'/'.join('/',$req->params).'?'.http_build_query((array)$req->get));
if (\Lib\Cache::exists($cache_key)) {
$cached = \Lib\Cache::get($cache_key,function() {});
}
//$cached = $cache->get($cache_key);
}
if (!$cached) {
$res->header('X-Cache','miss');
Hooks::call('before-action',array(&$req,&$res));
call_user_func_array(array($classname,$method), array($req,&$res));
Hooks::call('after-action',array(&$req,&$res));
if ($cacheTime !== 0 && !isset($req->get->noCache) && in_array($req->type, array('GET'))) {
\Lib\Cache::set($cache_key, $res->export());
/*
$res->on('background',function($cache,$cache_key,$res,$cacheTime){
$cache->set($cache_key,$res->export(),$cacheTime);
},array($cache,$cache_key,$res,$cacheTime));
*/
}
} else {
$res->import($cached);
$res->header('X-Cache','hit');
}
}
$req->end_time = microtime(true);
/home/u193142680/domains/catafesta.com.br/public_html/lib/Router.php
if ($cacheTime !== 0 && !isset($req->get->noCache) && in_array($req->type, array('GET'))) {
//CacheManager::setup($cache['config']);
//$cache = phpFastCache();
$cache_key = sha1($req->base_url.$req->controller.'/'.$req->method.'/'.join('/',$req->params).'?'.http_build_query((array)$req->get));
if (\Lib\Cache::exists($cache_key)) {
$cached = \Lib\Cache::get($cache_key,function() {});
}
//$cached = $cache->get($cache_key);
}
if (!$cached) {
$res->header('X-Cache','miss');
Hooks::call('before-action',array(&$req,&$res));
call_user_func_array(array($classname,$method), array($req,&$res));
Hooks::call('after-action',array(&$req,&$res));
if ($cacheTime !== 0 && !isset($req->get->noCache) && in_array($req->type, array('GET'))) {
\Lib\Cache::set($cache_key, $res->export());
/*
$res->on('background',function($cache,$cache_key,$res,$cacheTime){
$cache->set($cache_key,$res->export(),$cacheTime);
},array($cache,$cache_key,$res,$cacheTime));
*/
}
} else {
$res->import($cached);
$res->header('X-Cache','hit');
}
}
$req->end_time = microtime(true);
/home/u193142680/domains/catafesta.com.br/public_html/index.php
$regex = '#^http[s]?:\/\/(www\.)?(' . join("|", $hosts) . ')(\/' . preg_quote($request_uri) . ')?(\/)?(index\.php)?(\/)?#';
//trigger_error($regex);
$de = preg_replace('#^http[s]?:\/\/(www\.)?(' . join("|", $hosts) . ')(\/' . preg_quote($request_uri) . ')?(\/)?(index\.php)?(\/)?#', '', $de);
$para = preg_replace('#^http[s]?:\/\/(www\.)?(' . join("|", $hosts) . ')?(\/)?(index\.php)?(\/)?#', '', $para);
if ($request_uri == $de) {
$base_url = \Lib\Request::getBaseUrl();
$url = $base_url . $para;
//Header( “HTTP/1.1 301 Moved Permanently” );
header("Location: {$url}");
exit;
}
}
}
Router::init();