$start_page = microtime(true);
header('Content-Type: text/html; charset=UTF-8');
require_once('_includes/init.php');
if ($printMode = isset($_REQUEST['print'])) {
$template = new template($db, $lang, 'print');
} else {
$template = new template($db, $lang, DEFAULT_TEMPLATE);
}
if (DATABASE_CONNECTED) {
if ((!isset($_REQUEST['oldal']) || empty($_REQUEST['oldal'])) && isset($_REQUEST['id'])) {
if (($content = LoadContentByID($db, $lang, $_REQUEST['id'])) !== false) {
//
// Replace template - if needed
if (!empty($content->template) && !$printMode) $template->LoadTemplate($content->template);
//
// Show the content regardless of it's actual type/content
$template->OnContent($content->DisplayHTML($printMode));
if (!$printMode && check_right(USER_PUBLISHER)) {
//echo '
';
$template->OnContent("
');
}
} else {
$template->OnContent('##ContentNotFound##');
if (!$printMode && check_right(USER_PUBLISHER)) {
//echo '
';
$template->OnContent("
");
}
}
} elseif (!$printMode && isset($_REQUEST['oldal']) && !empty($_REQUEST['oldal'])) {
$oldal = preg_replace('|[^_A-Za-z0-9]|','',$_REQUEST['oldal']);
if (!empty($oldal) && is_file("_pages/{$oldal}.php")) {
$template->StartContentCapture();
include("_pages/{$oldal}.php");
$template->StopContentCapture();
} else {
$template->OnContent('##ContentNotFound##');
}
} elseif(!$printMode && isset($_REQUEST['cat'])) {
//
// Show the real category or the archived items?
$cat = explode('_', strtoupper($_REQUEST['cat']));
if (isset($cat[1])) {
$requestedNodes = getChildCategories($db, $cat[0]);
$where_clause = '(c.ID IN (' . implode(',', $requestedNodes) . ')) AND (reg.FValidUntil IS NOT NULL) AND (reg.FValidUntil <= now())';
$title_text = ' (##Archived##)';
} else {
$requestedNodes = getChildCategories($db, $cat[0]);
$where_clause = '(c.ID IN (' . implode(',', $requestedNodes) . ')) AND (reg.FDate <= now()) AND ((reg.FValidUntil IS NULL) OR (reg.FValidUntil >= now()))';
$title_text = '';
}
unset($cat,$requestedNodes);
//
// Run the query
$rs = $db->Query("
SELECT
reg.*,
UNIX_TIMESTAMP(reg.FDate) AS StartFMT,
COALESCE(am.FIntro, a.FIntro) AS Intro,
COALESCE(am.FText, a.FText) AS Text,
COALESCE(am.FCaption, reg.FCaption) AS Caption,
a.FShowInHeadline,
c.FShowDate,
c.ID AS CatID
FROM
###content_registry reg
JOIN ###articles a ON reg.ID = a.ID
JOIN ###categories c ON a.TCategories_ID = c.ID
LEFT OUTER JOIN ###articles_multilingual am JOIN ###lang_languages l ON (l.FCode = '{$lang->CurrentLanguage}') AND (l.ID = am.LanguageID) ON (am.ArticleID = a.ID)
WHERE
{$where_clause}
ORDER BY
reg.FDate DESC,
Caption ASC
");
echo $db->GetLastError();
//
// Show results...
if(($row = $rs->Fetch()) !== FALSE) {
$template->OnContent("##ArticleCategory::{$row['CatID']}##{$title_text}
\n");
do {
$intro = !empty($row['Intro'])?nl2br($row['Intro']):'';
$print = ''.($row['FShowDate']?'%1$s | ':'') . (strip_tags($row['Text'])==''?'%2$s
':'%2$s').'%3$s
';
$template->OnContent(sprintf(
$print,
format_date($row['StartFMT']),
$row['Caption'],
$row['Intro'],
make_content_url($row)
));
} while (($row = $rs->Fetch()) !== FALSE);
} else {
$template->OnContent("Ebben a kategóriában nincsen megjeleníthető tartalom
\n");
}
} else header('Location: /');
} else echo 'Nincs kapcsolat az adatbazissal!';
$template->RenderTemplate();
$memory_usage = function_exists('memory_get_usage')?' and by consuming ' . round(memory_get_usage()/1024,1) . ' kilobytes of memory':'';
echo "";
if (!$printMode && isset($_SESSION['DEBUG_SQL'])&&($_SESSION['DEBUG_SQL']===true)) {
echo '';
$db->ShowLog();
echo '
';
}
?>