require_once "system/config.php";
$db = new DataBase();
if (!$http_vars['page']) $http_vars['page'] = 'index';
elseif ($http_vars['page']!='index') $http_vars['page'] = 'index/'.$http_vars['page'];
if ($_SESSION['sess_startplay']) $startplay = $_SESSION['sess_startplay'];
else $startplay = 'true';
$page_elems = explode("/", $http_vars['page']);
$root_link = $page_elems[0];
$first_link = $page_elems[1];
$last_link = $page_elems[count($page_elems)-1];
$clear_link = str_replace('index', null, $http_vars['page']);
if ($http_vars['lang'])
{
$_SESSION['sess_lang'] = $http_vars['lang'];
$lang = $http_vars['lang'];
if (preg_match("/voltanov/", $_SERVER['HTTP_REFERER']))
$referer = $_SERVER['HTTP_REFERER'];
else
$referer = '/';
header("Location: $referer");
exit();
}
$parent = null;
$pageLink = null;
$first_title = null;
$i=0;
foreach ($page_elems as $p_el)
{
if (!$parent)
{
$pages = $db->get("pages", "lang = '$lang' and parent_id is null and identify = '$p_el'");
$parent = $pages[0]['id'];
$p = $pages[0];
$pageLink .= '/'.$p['identify'];
$p['link'] = $pageLink;
$path_array[] = $p;
if ($i==1) $first_title = $p['title'];
}
else
{
$pages = $db->get("pages", "lang = '$lang' and parent_id = '$parent' and identify = '$p_el'");
$parent = $pages[0]['id'];
$p = $pages[0];
$pageLink .= '/'.$p['identify'];
$p['link'] = $pageLink;
$path_array[] = $p;
if ($i==1) $first_title = $p['title'];
}
$i++;
}
$p = $pages[0];
$templates = $db->get("templates", "id = '$p[template_id]'");
$t = $templates[0];
$siteKeywords = ($p[keywords])?$p[keywords]:$t[keywords];
$siteDescription = ($p[description])?$p[description]:$t[description];
$siteOutput = $t['code'];
if ($p['redirect'])
{
header("Location: ".$p['redirect']);
exit();
}
if ($http_vars['page']=='index')
{
$p['code'] = $p['code'];
}
$siteOutput = str_replace("{::Content::}", $p['code'], $siteOutput);
if ($http_vars['page'] == 'index/contacts')
{
$s_pages = $db->get("pages", "id = '10'");
$s_p = $s_pages[0];
$siteOutput = str_replace("{::Page_Coords::}", $s_p['code'], $siteOutput);
}
include "includes/main_menu.php";
include "includes/sub_menu.php";
include "includes/banner.php";
include "includes/logotypes.php";
if ( preg_match("/portfolio(\/[A-z0-9]*)?/", $http_vars['page']))
include "includes/projects.php";
if ( preg_match("/music(\/[A-z0-9]*)?/", $http_vars['page']))
include "includes/music.php";
if ($http_vars['page']=='index')
{
$siteOutput = str_replace('', '', $siteOutput);
include "includes/news.php";
}
if ($lang=='rus')
{
$siteOutput = str_replace("{::Error_Name_Message::}", 'Вы не представились!', $siteOutput);
$siteOutput = str_replace("{::Error_Mail_message::}", 'Вы не указали свой email!', $siteOutput);
$siteOutput = str_replace("{::Error_Text_Message::}", 'Вы не заполнили сообщение!', $siteOutput);
}
else
{
$siteOutput = str_replace("{::Error_Name_Message::}", 'Specify your name!', $siteOutput);
$siteOutput = str_replace("{::Error_Mail_message::}", 'Specify your email!', $siteOutput);
$siteOutput = str_replace("{::Error_Text_Message::}", 'Specify your message!', $siteOutput);
}
$siteOutput = str_replace('', '', $siteOutput);
$siteOutput = str_replace("{::startplay::}", $startplay, $siteOutput);
$siteOutput = str_replace("{::Page::}", ($first_link?$first_link:'index'), $siteOutput);
$siteOutput = str_replace("{::Title::}", $p['title'], $siteOutput);
$siteOutput = str_replace("{::Keywords::}", $siteKeywords, $siteOutput);
$siteOutput = str_replace("{::Description::}", $siteDescription, $siteOutput);
$siteOutput = str_replace("{::SiteTitle::}", $p['title'], $siteOutput);
$siteOutput = str_replace("{::PathMenu::}", $pathMenu, $siteOutput);
$siteOutput = str_replace("{::PageName::}", null, $siteOutput);
$pages = $db->get("pages", "lang = '$lang' and parent_id is null and identify = '$p_el'");
$siteOutput = str_replace("{::PageAlt::}", ($first_title)?$first_title:$p['title'], $siteOutput);
$file_bg = ($p['file_id_2'])?$p['file_id_2']:$t['file_id_2'];
if ($file_bg)
$siteOutput = str_replace("{::PatternBg::}", "background-image: url(/attach/$file_bg); ", $siteOutput);
else
$siteOutput = str_replace("{::PatternBg::}", null, $siteOutput);
$file_logo = ($p['file_id_3'])?$p['file_id_3']:$t['file_id_3'];
$atts_logo = $db->get('attachments', 'id = '.$file_logo);
if ($atts_logo[0]['file'])
$siteOutput = str_replace("{::Logo::}", "
", $siteOutput);
else
$siteOutput = str_replace("{::Logo::}", null, $siteOutput);
$siteOutput = str_replace("{::bg::}", ($p['bg'])?$p['bg']:$t['bg'], $siteOutput);
$siteOutput = str_replace("{::bg1::}", ($p['bg1'])?$p['bg1']:$t['bg1'], $siteOutput);
$siteOutput = str_replace("{::cl::}", ($p['cl'])?$p['cl']:$t['cl'], $siteOutput);
$siteOutput = str_replace("{::cl1::}", ($p['cl1'])?$p['cl1']:$t['cl1'], $siteOutput);
$http_vars['data']['title'] = strip_tags($http_vars['data']['title']);
$http_vars['data']['mail'] = strip_tags($http_vars['data']['mail']);
$http_vars['data']['text'] = strip_tags($http_vars['data']['text']);
if ($http_vars['data']['title'] && $http_vars['data']['mail'] && $http_vars['data']['text'] && !$http_vars['control'])
{
$db->set("faq", array("coords" => $http_vars['data']['mail'], "title" => $http_vars['data']['title'], "annotation" => $http_vars['data']['text'], "date" => date("Y-m-d H:i:s"), "active" => "N"));
$letter = "ФИО: ".$http_vars['data']['title']."\r\n";
$letter .= "EMail: ".$http_vars['data']['mail']."\r\n";
$letter .= "Сообщение: ".$http_vars['data']['text'];
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=WINDOWS-1251\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
$headers .= "From: ".$http_vars['data']['title']." <".$http_vars['data']['mail'].">\r\n";
$headers .= "Reply-To: ".$http_vars['data']['title']." <".$http_vars['data']['mail'].">\r\n";
// @mail($config['optional']['email'], "Сообщение с сайта ".$config['site']['domain'], $letter, $headers);
if ($lang=='rus')
{
$siteOutput = str_replace("{::Message::}", 'Ваше сообщение отправлено!', $siteOutput);
$siteOutput = str_replace("{::FormDisplay::}", 'none', $siteOutput);
$siteOutput = str_replace("{::MessageDisplay::}", 'block', $siteOutput);
}
else
{
$siteOutput = str_replace("{::Message::}", 'Your message has been sent!', $siteOutput);
$siteOutput = str_replace("{::FormDisplay::}", 'none', $siteOutput);
$siteOutput = str_replace("{::MessageDisplay::}", 'block', $siteOutput);
}
}
else
{
$siteOutput = str_replace("{::FormDisplay::}", 'block', $siteOutput);
$siteOutput = str_replace("{::MessageDisplay::}", 'none', $siteOutput);
}
print $siteOutput;
?>