$posts = \Lib\Util::Busca2($posts,$keyword);
}
}
$itensPagina = 10;
$sort = $req->Get('sort', 'destaque_desc,data_desc,ordenamento_desc');
$rows = (int)$req->Get('rows', $itensPagina);
$page = (int)$req->Get('page', 1);
if ('' == $sort) {
$sort = 'destaque_desc,data_desc,ordenamento_desc';
}
if (1 > $rows) {
$rows = $itensPagina;
}
if (1 > $page) {
$page = 1;
}
$total = count($posts);
$pages = ceil($total / $rows);
if ($page > $pages) {
$page = $pages;
}
$offset = ($page - 1) * $rows;
$posts = Util::Sort($posts,$sort);
$posts = array_slice($posts, $offset, $rows);
$extras['posts'] = $posts;
if (isset($categoria->id)) {
$categoria->url = $req->controller.'/'.$categoria->slug;
$req->uri = $categoria->url;
/* METATAG */
$posts = \Lib\Util::Busca2($posts,$keyword);
}
}
$itensPagina = 10;
$sort = $req->Get('sort', 'destaque_desc,data_desc,ordenamento_desc');
$rows = (int)$req->Get('rows', $itensPagina);
$page = (int)$req->Get('page', 1);
if ('' == $sort) {
$sort = 'destaque_desc,data_desc,ordenamento_desc';
}
if (1 > $rows) {
$rows = $itensPagina;
}
if (1 > $page) {
$page = 1;
}
$total = count($posts);
$pages = ceil($total / $rows);
if ($page > $pages) {
$page = $pages;
}
$offset = ($page - 1) * $rows;
$posts = Util::Sort($posts,$sort);
$posts = array_slice($posts, $offset, $rows);
$extras['posts'] = $posts;
if (isset($categoria->id)) {
$categoria->url = $req->controller.'/'.$categoria->slug;
$req->uri = $categoria->url;
/* METATAG */
parent::IndexAction($req, $res, $extras);
}
public static function PostAction($req, $res, $extras = array()) {
$req->controller = 'posts';
$req->method = 'interna';
static::InternaAction($req, $res, $extras);
}
public static function CategoriaAction($req, $res, $extras = array()) {
list($categoria_slug) = $req->params;
$categoria = \Models\Blog\Categorias::getBySlug($categoria_slug);
$req->method = $categoria->slug;
static::IndexAction($req, $res, $extras);
}
public static function ImportarAction($req, $res, $extras = array()) {
\Models\Blog\Importador::Importar();
parent::IndexAction($req, $res, $extras);
}
}
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'))) {
$req->params[] = $req->method;
}
$req->params = array_merge($req->params, $req->params_old);
$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));
}
}
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'))) {
$req->params[] = $req->method;
}
$req->params = array_merge($req->params, $req->params_old);
$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));
}
}
<?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));
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);
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);
$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();
Key | Value |
orig_referer |
Key | Value |
USER | divinut |
HOME | /var/www/vhosts/divinut.com.br |
PATH_TRANSLATED | redirect:/./index.php/blog/350/diretor-da-divinut-foi-entrevistado-pela-reporter-cecilia-gomez-ojeda-do-programa-siembra-y-cosecha-em-choromoro-tucuman-para-ir-ao-ar-pelo-canal-rural-argentino-para-toda-a-america-latina-de-lingua-espanhola-assim-que-tivermos-o-link-da-reportagem/350/diretor-da-divinut-foi-entrevistado-pela-reporter-cecilia-gomez-ojeda-do-programa-siembra-y-cosecha-em-choromoro-tucuman-para-ir-ao-ar-pelo-canal-rural-argentino-para-toda-a-america-latina-de-lingua-espanhola-assim-que-tivermos-o-link-da-reportagem |
PATH_INFO | /blog/350/diretor-da-divinut-foi-entrevistado-pela-reporter-cecilia-gomez-ojeda-do-programa-siembra-y-cosecha-em-choromoro-tucuman-para-ir-ao-ar-pelo-canal-rural-argentino-para-toda-a-america-latina-de-lingua-espanhola-assim-que-tivermos-o-link-da-reportagem |
SCRIPT_NAME | /index.php |
REQUEST_URI | /blog/350/diretor-da-divinut-foi-entrevistado-pela-reporter-cecilia-gomez-ojeda-do-programa-siembra-y-cosecha-em-choromoro-tucuman-para-ir-ao-ar-pelo-canal-rural-argentino-para-toda-a-america-latina-de-lingua-espanhola-assim-que-tivermos-o-link-da-reportagem |
QUERY_STRING | |
REQUEST_METHOD | GET |
SERVER_PROTOCOL | HTTP/1.0 |
GATEWAY_INTERFACE | CGI/1.1 |
REDIRECT_URL | /blog/350/diretor-da-divinut-foi-entrevistado-pela-reporter-cecilia-gomez-ojeda-do-programa-siembra-y-cosecha-em-choromoro-tucuman-para-ir-ao-ar-pelo-canal-rural-argentino-para-toda-a-america-latina-de-lingua-espanhola-assim-que-tivermos-o-link-da-reportagem |
REMOTE_PORT | 50806 |
SCRIPT_FILENAME | /var/www/vhosts/divinut.com.br/httpdocs/index.php |
SERVER_ADMIN | root@localhost |
CONTEXT_DOCUMENT_ROOT | /var/www/vhosts/divinut.com.br/httpdocs |
CONTEXT_PREFIX | |
REQUEST_SCHEME | https |
DOCUMENT_ROOT | /var/www/vhosts/divinut.com.br/httpdocs |
REMOTE_ADDR | 34.231.229.59 |
SERVER_PORT | 443 |
SERVER_ADDR | 148.72.144.147 |
SERVER_NAME | www.divinut.com.br |
SERVER_SOFTWARE | Apache |
SERVER_SIGNATURE | |
PATH | /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin |
HTTP_USER_AGENT | claudebot |
HTTP_ACCEPT | */* |
HTTP_CONNECTION | close |
HTTP_X_ACCEL_INTERNAL | /internal-nginx-static-location |
HTTP_X_REAL_IP | 34.231.229.59 |
HTTP_HOST | www.divinut.com.br |
proxy-nokeepalive | 1 |
HTTPS | on |
PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY | 0 |
PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY | 0 |
PERL5LIB | /usr/share/awstats/lib:/usr/share/awstats/plugins |
SCRIPT_URI | https://www.divinut.com.br/blog/350/diretor-da-divinut-foi-entrevistado-pela-reporter-cecilia-gomez-ojeda-do-programa-siembra-y-cosecha-em-choromoro-tucuman-para-ir-ao-ar-pelo-canal-rural-argentino-para-toda-a-america-latina-de-lingua-espanhola-assim-que-tivermos-o-link-da-reportagem |
SCRIPT_URL | /blog/350/diretor-da-divinut-foi-entrevistado-pela-reporter-cecilia-gomez-ojeda-do-programa-siembra-y-cosecha-em-choromoro-tucuman-para-ir-ao-ar-pelo-canal-rural-argentino-para-toda-a-america-latina-de-lingua-espanhola-assim-que-tivermos-o-link-da-reportagem |
UNIQUE_ID | ZgUjOvaTr6-XmPR9dp7swwAAAI0 |
REDIRECT_STATUS | 200 |
REDIRECT_HTTPS | on |
REDIRECT_PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY | 0 |
REDIRECT_PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY | 0 |
REDIRECT_PERL5LIB | /usr/share/awstats/lib:/usr/share/awstats/plugins |
REDIRECT_SCRIPT_URI | https://www.divinut.com.br/blog/350/diretor-da-divinut-foi-entrevistado-pela-reporter-cecilia-gomez-ojeda-do-programa-siembra-y-cosecha-em-choromoro-tucuman-para-ir-ao-ar-pelo-canal-rural-argentino-para-toda-a-america-latina-de-lingua-espanhola-assim-que-tivermos-o-link-da-reportagem |
REDIRECT_SCRIPT_URL | /blog/350/diretor-da-divinut-foi-entrevistado-pela-reporter-cecilia-gomez-ojeda-do-programa-siembra-y-cosecha-em-choromoro-tucuman-para-ir-ao-ar-pelo-canal-rural-argentino-para-toda-a-america-latina-de-lingua-espanhola-assim-que-tivermos-o-link-da-reportagem |
REDIRECT_UNIQUE_ID | ZgUjOvaTr6-XmPR9dp7swwAAAI0 |
FCGI_ROLE | RESPONDER |
PHP_SELF | /index.php/blog/350/diretor-da-divinut-foi-entrevistado-pela-reporter-cecilia-gomez-ojeda-do-programa-siembra-y-cosecha-em-choromoro-tucuman-para-ir-ao-ar-pelo-canal-rural-argentino-para-toda-a-america-latina-de-lingua-espanhola-assim-que-tivermos-o-link-da-reportagem |
REQUEST_TIME_FLOAT | 1711612731.0067 |
REQUEST_TIME | 1711612731 |