/var/www/vhosts/abascalrural.com.br/httpdocs/site/controllers/EventosController.php
$meta = array();
$meta = \Models\Meta::get('404',$language,false);
if (!isset($meta->id)) {
$meta = new \stdclass();
$titulo = 'Página não encontrada';
$Meta2 = \Models\Meta::get('home',$req->language,true);
$meta->title = $titulo.' - '.$Meta2->title;
}
$extras['titulo'] = 'Pagina não encontrado';
$req->meta = $meta;
$extras['meta'] = $meta;
$req->method = '404';
parent::IndexAction($req, $res, $extras);
}
$pagina->url = $req->controller.'/interna/'.$pagina->slug;
//trigger_error($pagina->url);
/* METATAG */
$meta = array();
$meta = \Models\Meta::get($pagina->url,$req->language,false);
//$pagina = $pagina;
if (!isset($meta->id)) {
$Meta2 = \Models\Meta::get('home',$req->language,true);
$meta = new \stdclass();
$meta->title = strip_tags(html_entity_decode($pagina->titulo)).' - '.$Meta2->title;
$meta->description = \Lib\Util::text_break($pagina->texto,170);
$meta->keywords = \Lib\Util::linkfy($pagina->texto,170);
$meta->keywords = explode('-', $meta->keywords);
$meta->keywords = array_unique($meta->keywords);
$meta->keywords = join(',', $meta->keywords);
/var/www/vhosts/abascalrural.com.br/httpdocs/site/controllers/EventosController.php
$meta = array();
$meta = \Models\Meta::get('404',$language,false);
if (!isset($meta->id)) {
$meta = new \stdclass();
$titulo = 'Página não encontrada';
$Meta2 = \Models\Meta::get('home',$req->language,true);
$meta->title = $titulo.' - '.$Meta2->title;
}
$extras['titulo'] = 'Pagina não encontrado';
$req->meta = $meta;
$extras['meta'] = $meta;
$req->method = '404';
parent::IndexAction($req, $res, $extras);
}
$pagina->url = $req->controller.'/interna/'.$pagina->slug;
//trigger_error($pagina->url);
/* METATAG */
$meta = array();
$meta = \Models\Meta::get($pagina->url,$req->language,false);
//$pagina = $pagina;
if (!isset($meta->id)) {
$Meta2 = \Models\Meta::get('home',$req->language,true);
$meta = new \stdclass();
$meta->title = strip_tags(html_entity_decode($pagina->titulo)).' - '.$Meta2->title;
$meta->description = \Lib\Util::text_break($pagina->texto,170);
$meta->keywords = \Lib\Util::linkfy($pagina->texto,170);
$meta->keywords = explode('-', $meta->keywords);
$meta->keywords = array_unique($meta->keywords);
$meta->keywords = join(',', $meta->keywords);
/var/www/vhosts/abascalrural.com.br/httpdocs/site/controllers/EventosController.php
if ($proximo > count($Eventos)-1) {
$proximo = reset($Eventos);
} else {
$proximo = $Eventos[$proximo];
}
$extras['anterior'] = $anterior;
$extras['proximo'] = $proximo;
/* FIM */
parent::IndexAction($req, $res, $extras);
}
public static function PaginaAction($req, $res, $extras = array()) {
$req->controller = 'eventos';
$req->method = 'interna';
static::InternaAction($req, $res, $extras);
}
}
/var/www/vhosts/abascalrural.com.br/httpdocs/site/controllers/DefaultController.php
$args = $defaultArgs + $extras;
return $res->render('404/index.twig',$args);
}
$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->controller = static::Pascal2KebabCase($matches['controller']);
$req->method = static::Pascal2KebabCase($matches['method']);
return call_user_func_array('\\Controller\\'.$modulo->site_controller, array($req, $res, $extras));
}
/*
public static function ResolveSlug($req, $res, $extras = array()) {
$slug = $req->controller;
$record = \R::findOne('slugs','deleted = 0 and slug = ? limit 1', array($slug));
if (!isset($record->id)) {
//return $res->redirect('404');
http_response_code(404);
$language = $req->language;
$meta = array();
$meta = \Models\Meta::get('404',$language,false);
if (!isset($meta->id)) {
/var/www/vhosts/abascalrural.com.br/httpdocs/site/controllers/DefaultController.php
$args = $defaultArgs + $extras;
return $res->render('404/index.twig',$args);
}
$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->controller = static::Pascal2KebabCase($matches['controller']);
$req->method = static::Pascal2KebabCase($matches['method']);
return call_user_func_array('\\Controller\\'.$modulo->site_controller, array($req, $res, $extras));
}
/*
public static function ResolveSlug($req, $res, $extras = array()) {
$slug = $req->controller;
$record = \R::findOne('slugs','deleted = 0 and slug = ? limit 1', array($slug));
if (!isset($record->id)) {
//return $res->redirect('404');
http_response_code(404);
$language = $req->language;
$meta = array();
$meta = \Models\Meta::get('404',$language,false);
if (!isset($meta->id)) {
/var/www/vhosts/abascalrural.com.br/httpdocs/site/controllers/DefaultController.php
<?php
namespace Controller;
use Lib\Config;
use Lib\View;
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);
}
$defaultArgs = array(
'req' => $req,
'res' => $res
);
$args = $defaultArgs + $extraArgs;
$res->render($tpl,$args);
}
public static function Pascal2KebabCase($input) {
//return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $input));
return strtolower(preg_replace('/(?<!^)[A-Z]/', '-$0', $input));
}
public static function ResolveSlug($req, $res, $extras = array()) {
$slug = $req->controller;
$record = \R::findOne('slugs','deleted = 0 and slug = ? limit 1', array($slug));
/var/www/vhosts/abascalrural.com.br/httpdocs/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);
/var/www/vhosts/abascalrural.com.br/httpdocs/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);
/var/www/vhosts/abascalrural.com.br/httpdocs/index.php
$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();