<?php include('config.php');
error_reporting(1);
$uri = $_SERVER['REQUEST_URI'];
$uri = str_replace($DOMAIN,'',$uri);
$uri = str_replace('.html','',$uri);
$uri = explode('/',$uri); $uriszam = count($uri); $uriszam--;
$CURPAGE = $uri[1];
//print_r($uri);
if (isset($_SESSION['userData']['jog'])) {
$_SESSION['lathatosag'] = '1'; } else {
$_SESSION['lathatosag'] = '0'; }
$le = mysql_query("SELECT * FROM oldalak WHERE content_seo_name = '".$CURPAGE."'");
if ($CURPAGE =="" or mysql_num_rows($le) == 0){
if (mysql_num_rows($le) == 0 and $CURPAGE !=""){ $SQL = mysql_fetch_assoc(mysql_query("SELECT * FROM oldalak WHERE content_seo_name='404'"));
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
}
else
{
header($_SERVER["SERVER_PROTOCOL"]." 200 ok");
$SQL = mysql_fetch_assoc(mysql_query("SELECT * FROM oldalak WHERE fooldal='1'"));
}
}else{
$SQL = mysql_fetch_assoc(mysql_query("SELECT * FROM oldalak WHERE content_seo_name = '".$CURPAGE."'"));
}
?>
<?php
//$template = str_replace('[tartalom]',$SQL['content_content'],$template);
if($SQL['cache'] == 1){
if (file_exists('cache/'.$SQL['content_seo_name'].'.html'))
{
$template = file_get_contents('cache/'.$SQL['content_seo_name'].'.html');
print($template);
}
else
{
$template = tartalom();
$myFile = 'cache/'.$SQL['content_seo_name'].'.html';
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $template);
fclose($fh);
print($template);
}
}else{
$template = tartalom();
print($template);
}
function tartalom()
{
global $SQL, $MODULS, $uri, $WEBPAGEURL, $LIMA, $CURPAGE, $uriszam, $WEBPAGENAME, $CurrentURL, $TEMPLATE, $MOBIL, $DOMAIN;
global $TITLE;
include('functions.php');
// template választása
if ($SQL['template'] != '' and file_exists('template/'.$TEMPLATE.'/'.$SQL['template'])){
$template = file_get_contents('template/'.$TEMPLATE.'/'.$SQL['template'].'');
}else
{
if(file_exists('template/'.$TEMPLATE.'/'.$SQL['content_seo_name'].'.html'))
{ $template = file_get_contents('template/'.$TEMPLATE.'/'.$SQL['content_seo_name'].'.html'); } else {
$template = file_get_contents('template/'.$TEMPLATE.'/index.html'); }
}
// főmenü
$fomenu ='';
$template = str_replace('[BASEREWRITE]',$CurrentURL.'template/'.$TEMPLATE.'/',$template);
// főmenü
if ($MOBIL != true) {
if (!isset($_SESSION['login'])){
$menusor = mysql_query('SELECT * FROM oldalak WHERE (pozicio="fomenu" and publikus="1") and (lathatosag="0" or lathatosag="2") ORDER BY sorrend');
}else {
$menusor = mysql_query('SELECT * FROM oldalak WHERE pozicio="fomenu" and publikus="1" ORDER BY sorrend');
}
//$menusor = mysql_query('SELECT * FROM oldalak WHERE pozicio="fomenu" and publikus="1" ORDER BY sorrend');
$sorsz = 0;
while ($i = mysql_fetch_assoc($menusor))
{
$sorsz++;
if (($CURPAGE == $i["content_seo_name"]) or ($CURPAGE =='' and $sorsz == 1) ){ $currentt = ' class="current" '; } else { $currentt = 'class="fmenu"'; }
$fomenu .= '<li '.$currentt.'><a href="'.$WEBPAGEURL.'/'.$i["content_seo_name"].'.html" '.$currentt.'>'.$i["content_name"].'</a></li>';
}
$template = str_replace('[fomenu]',$fomenu,$template);
}
// főmenü vége
if ($SQL['meta_leiras'] != ""){ $template = str_replace('[meta_leiras]',$SQL['meta_leiras'],$template); }
if ($SQL['meta_kulcs'] != ""){ $template = str_replace('[meta_kulcs]',$SQL['meta_kulcs'],$template); }
$template = str_replace('[meta_egyeb]',$SQL['meta_egyeb'],$template);
$tomb = array();
// lathatosag | 0 = mindenki, 1 = csak regisztraltak, 2 = különbözik
if ($SQL['lathatosag'] == "0"){
$tartalom = mysql_query('SELECT * FROM tartalom WHERE oldal_id="'.$SQL["content_seo_name"].'" and lathatosag="0"') or print(mysql_error()); }
elseif (($SQL['lathatosag'] == "1"))
{
if (isset($_SESSION['login'])) {
$tartalom = mysql_query('SELECT * FROM tartalom WHERE oldal_id="'.$SQL["content_seo_name"].'" and lathatosag="0"');
} else{
header($_SERVER["SERVER_PROTOCOL"]." 403 Access denied");
$tartalom = mysql_query('SELECT * FROM tartalom WHERE oldal_id="403"');
}
}else
{
$tartalom = mysql_query('SELECT * FROM tartalom WHERE oldal_id="'.$SQL["content_seo_name"].'" and lathatosag="'.$_SESSION['lathatosag'].'"');
}
if (mysql_num_rows($tartalom) > 0)
{
while($i = mysql_fetch_assoc($tartalom))
{
$tomb[$i['content_position']][] = $i['content_content'];
}
}
foreach($tomb as $i => $j)
{
$kiprint = '';
foreach($j as $k)
{
$kiprint .= $k;
}
if ($_SESSION['jog'] == 'admin') { $szf0 = '<div id="'.$i.'" class="editable_content">'; $szf1 = '</div>';}
$template = str_replace('['.$i.']',$szf0.$kiprint.$szf1,$template);
}
$template = str_replace('[logo]',$WEBPAGENAME['content'],$template);
// modulok
global $OLDALCIME;
$OLDALCIME = $SQL['content_name'];
$mods = file_get_contents($CurrentURL.'template/'.$TEMPLATE.'/modul_list.txt');
//$mods2 = explode('\r\n',$mods);
$mods2 = preg_split('/[\n\r]+/', $mods);
if (is_array($mods2))
{
foreach($mods2 as $i)
{
if ($i != '') { include('modulok/'.$i.'/index.php'); }
}
}
$template = str_replace('[title]',$TITLE,$template);
$template = str_replace('[CURRENTURL]',$_SERVER['REQUEST_URI'],$template);
// kimenet tisztítása
//$template = preg_replace('/[\r\n]+/', ' ', $template);
//$template = preg_replace('/\s/', ' ', $template);
return $template;
}
/*
# HttpRequestDetails.php
# Copyright (c) 2002 by Dr. Herong Yang,
http://www.herongyang.com/
#
print "<pre>\n";
print "\nContents of \$_GET:\n";
foreach ($_GET as $k => $v) {
print " $k = $v\n";
}
#
print "\nContents of \$_POST:\n";
foreach ($_POST as $k => $v) {
print " $k = $v\n";
}
#
print "\nContents of \$_COOKIE:\n";
foreach ($_COOKIE as $k => $v) {
print " $k = $v\n";
}
#
print "\nContents of \$_REQUEST:\n";
foreach ($_REQUEST as $k => $v) {
print " $k = $v\n";
}
#
print "\nContents of \$_SERVER:\n";
foreach ($_SERVER as $k => $v) {
print " $k = $v\n";
}
print "</pre>\n";
*/
?>