<?php
if (!defined('_SAPE_USER')){
define('_SAPE_USER', '08fbaf0518cf9d0132d221f5a0337409');
}
require_once($_SERVER['DOCUMENT_ROOT'].'/'._SAPE_USER.'/sape.php');
$o['host'] = 'karman.ru';
$sape = new SAPE_client($o);
unset($o);
$start_time = microtime();
$start_array = explode(" ",$start_time);
$start_time = $start_array[1] + $start_array[0];
defined('BASE_DIR') or define('BASE_DIR',$_SERVER['DOCUMENT_ROOT'] . '/');
include_once(BASE_DIR . 'config/config.php');
include_once(BASE_DIR . 'config/dbconn.php');
include_once(BASE_DIR . 'modules/lib.php');
include_once(BASE_DIR . 'modules/cache.php');
include_once(BASE_DIR . 'templates/default/menu.php');
/*$start_time = microtime();
$start_array = explode(" ",$start_time);
$start_time = $start_array[1] + $start_array[0];*/
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
$_HTML = Array();
$_META = Array();
$_METATAGS = Array();
$gam;
function search()
{
return include 'include/search.php';
}
function getsearch()
{
return include 'include/getsearch.php';
}
function getContent2($p1,$p2,$name)
{
include 'include/getContent2.php';
}
function getModelImg($category,$brand,$model,$index="1")
{
return include 'include/getModelImg.php';
}
function getBrandImg($brand)
{
return include 'include/getBrandImg.php';
}
function getModel1($category,$brand,$model,$class="b")
{
return include 'include/getModel1.php';
}
function getModels($category,$brand)
{
return include 'include/getModels.php';
}
function getCategory($category)
{
return include 'include/getCategory.php';
}
function getModel2($category,$brand,$model)
{
return include 'include/getModel2.php';
}
function getbrandlist($category)
{
return include 'include/getbrandlist.php';
}
function getmodellist($category,$brand)
{
return include 'include/getmodellist.php';
}
function getmodels_rnd($category)
{
return include 'include/getmodels_rnd.php';
}
function getModel_rnd($category,$model)
{
return include 'include/getModel_rnd.php';
}
function getnewsbrief()
{
return include 'include/getnewsbrief.php';
}
function getContent($pageid,$category,$brand,$model)
{
return include 'include/getContent.php';
}
/******************************picture******************************/
function replace_getPict($curr)
{
return include 'include/replace_getPict.php';
}
function return_getPict($pos)
{
return include 'include/return_getPict.php';
}
function getPict($category,$pages)
{
include 'include/getPict.php';
}
/*___________________________________________end of pict___________________________*/
/******************************theme********************************/
function replace_getTheme($curr)
{
return include 'include/replace_getTheme.php';;
}
function return_getTheme($pos)
{
return include 'include/return_getTheme.php';
}
function getTheme($category,$pages)
{
include 'include/getTheme.php';
}
function getGames($category,$pages)
{
include 'include/getGames.php';
}
function replace_getGames($curr)
{
return include 'include/replace_getGames.php';;
}
function return_getGames($pos)
{
return include 'include/return_getGames.php';
}
/*___________________________________________end of theme___________________________*/
function getAbout() {
include 'include/getAbout.php';
}
function getConnect() {
global $_HTML, $_META;
session_start();
if (isset($_POST['submit']))
{
$confirm_id = (eregi('^[a-z0-9]{32}$', $_POST['confirm_id'])) ? $_POST['confirm_id'] : '';
$result = mysql_query("SELECT * FROM captcha WHERE confirm_id = '$confirm_id' LIMIT 1");
$row = mysql_fetch_assoc($result);
if (!$row || $_POST['confirm'] !== $row['code'] || $_POST['nameF']==='' || $_POST['textF']===''|| $_POST['emailF']==='' )
{
$_HTML['content'] .='<p style=color:red>Заполните все поля, либо проверьте на правильность:</p>';
}
else
{
$session_id = (eregi("^[a-z0-9]{32}$", session_id())) ? session_id() : '';
mysql_query("DELETE FROM captcha WHERE session_id = '$session_id'");
session_destroy();
$head = "Content-type: text/html; charset=utf-8";
if (mail("softvsofte@gmail.com", $_POST['nameF'], $_POST['textF'], "From: ".$_POST['mailF']." \r\n", $head)) {
$_HTML['content'] .='<p style=color:red>Спасибо за связь</p>';
} else {
$_HTML['content'] .= "some error happen";
}
$_HTML['content'] .='';
}
//echo $_POST['confirm'] . '|' . $row['code'] . '<br />';
}
$confirm_id = md5(uniqid($_SERVER['REMOTE_ADDR']));
$_HTML['content'] .='
<strong>Обратная связь</strong>
<form method="post">
<input type="text" name="nameF" size="30" value='.$_POST['nameF'].'>Имя<br>
<input type="text" name="mailF" size="30" value='.$_POST['mailF'].'>E:mail<br>
<textarea name="textF" style="width: 342px; height: 184px">'.$_POST['textF'].'</textarea><br>
<img src="include/captcha.php?id='.$confirm_id.'">
<input type="text" name="confirm" size="30">
<input type="hidden" name="confirm_id" value="'.$confirm_id.'">
<br>
<input type="submit" name="submit" value="Отправить">
</form>';
}
function meta($pageid,$cat,$what)
{
global $_HTML, $_META, $_GET;
/*$cat = ($pageid > 0) ? $_GET['p2'] : 0;*/
if ($what=='title') {$_HTML['title'] = from_cache('1_'.$pageid.'_'.$cat.'_'.$what);
} else {
$_META[$what] = from_cache('1_'.$pageid.'_'.$cat.'_'.$what);}
}
header('Content-type: text/html; charset="utf-8"', true);
$template = file_get_contents(BASE_DIR . 'templates/default/index.php');
$p1 = _param('p1');
$p2 = _param('p2');
$p3 = _param('p3');
$_HTML['title'] = "";
$_HTML['descr'] = "";
$_HTML['head'] = "";
$_META['description'] = "";
$_HTML['body'] = "";
$_META['keywords'] = "";
$_HTML['content'] = '';
$_HTML['in_main'] .= "";
//*MAIN PART - define $_HTML['title'], $_HTML['body'], $_META['keywords'], $_META['description']
$_HTML['title'] = '';
$_HTML['body'] = '';
$_META['keywords'] = '';
$_META['description'] = '';
$main = false;
$catalog = false;
$category = '';
$brand = '';
$model = '';
if ($p1 == "" || $p1 == "index") {
$main = true;
} elseif ($p1 == "articles"){
getContent2($p1,$p2,'Статьи');
} elseif ($p1 == "review"){
getContent2($p1,$p2,'Обзоры');
} elseif ($p1 == "news"){
getContent2($p1,$p2,'Новости');
} elseif ($p1 == "games"){
getGames($p2,$p3);
} elseif ($p1 == "theme"){
getTheme($p2,$p3);
} elseif ($p1 == "pict"){
getPict($p2,$p3);
} elseif ($p1 == "about"){
getAbout();
} elseif ($p1 == "connect"){
getConnect();
} else {
$catalog = true;
$category = $p1;
$brand = $p2;
$model = $p3;
/*echo $category;
echo $brand;
echo $model;*/
}
if ($main) {
include 'include/main.php';
}
include 'include/indx.php';
$cat = 0;
$pageid=0;
if ($main || $catalog) {
if ($category!="")$pageid=1;
if ($brand!="")$pageid=2;
if ($model!="")$pageid=3;
if ($main) {$cat==0;} else {
$q=mysql_query("SELECT * FROM `karman_categories` WHERE `uri`=\"$p1\"");
$f = mysql_fetch_array($q);
$cat = $f['id'];
}
meta($pageid,$cat,'title');
meta($pageid,$cat,'description');
meta($pageid,$cat,'keywords');
}
$_HTML['body']=$pageid;
if($category=="cart") {
$_HTML['content'] = "<div class=\"main\">".getCart()."</div>";
}
elseif($category=="search") {
$_HTML['content'] = "<div class=\"main\">".search()."</div>";
}
elseif ($catalog) {
$_HTML['content'] = "<div class=\"main\">".getContent($pageid,$category,$brand,$model)."</div>";
}
/************/
$q_categories = mysql_query("SELECT `name`,`uri` FROM `karman_categories`");
$_HTML['categorytags'] = '';
for ($i=0;$i<mysql_num_rows($q_categories);$i++)
{
$f_categories = mysql_fetch_array($q_categories);
$_HTML['categorytags'] .= "<a href=\"/$f_categories[uri]/\">$f_categories[name]</a>";
}
$_HTML['head'] = '';
foreach ($_META as $km=>$m) {
foreach ($_METATAGS as $km=>$v) {
$m = str_replace("@@_".$k."_@@",$v,$m);
}
}
foreach ($_META as $k=>$v) {
$_HTML['head'] .= '<meta name="'.$k.'" content="'.$v.'" />';
}
/* $_HTML['body'] = 'Some text';
$_HTML['title'] = 'Untitled';*/
/*Release*/
//while (strrpos($template,"@@_")!==false)
$k=@array_keys($t[all]);
$cart_col=0;
$sum=0;
for ($i=0; $i<count($k); $i++) {
$id=$k[$i];
if($t[$id][kol]) {$cart_col+=$t[$id][kol]; $sum+=$t[$id][kol]*$t[$id][price];}
else $cart_col+=1;
}
$_SESSION['t']=$t;
//$_HTML['kol'] = $t[1][kol];
$_HTML['kol'] = $cart_col;
$_HTML['sum'] = $sum;
if($cart_col>0) $_HTML['oform'] = "<div id=t5><a href=\"/cart/\">Оформить заказ</a></div>";
else $_HTML['oform'] = "<div id=t5></div>";
if($p1 == "theme" || $p1 == "games" || $p1 == "pict"){
$qq = mysql_query("SELECT * FROM `karman_d` WHERE name='".$p1."' ");
for ($i=0;$i<mysql_num_rows($qq);$i++)
{
$ff = mysql_fetch_array($qq);
}
$template=str_replace('@@_title_@@',$ff['title'],$template);
$template=str_replace('@@_head_@@','<meta name="description" content="'.$ff['desk'].'" /><meta name="keywords" content="'.$ff['keyword'].'" />',$template);
$template=str_replace('@@_descr_@@',$ff['mini'],$template);
$template=str_replace('@@_name_games_@@',$gam,$template);
}
foreach ($_HTML as $k=>$v) {
$template = str_replace("@@_".$k."_@@",$v,$template);
}
$template=str_replace('<img src="http://web.mobiguru.ru/web/minus.gif">',htmlspecialchars_decode('–'),$template);
$template=str_replace('##getPic##','
<li>» <a href="/pict/">Картинки</a></li>
<li>» <a href="/theme/">Темы</a></li>
<li>» <a href="/games/">Игры</a></li>
',$template);
//Cache : start
$template=str_replace("@@_sape_@@",'<p style="font-size:8px; text-align:center">'.mb_convert_encoding($sape->return_links($n), "UTF-8", "CP1251").'</p>',$template);
echo $template;
$end_time = microtime();$end_array = explode(" ",$end_time);
$end_time = $end_array[1] + $end_array[0];
$time = $end_time - $start_time;
printf("<p align=center>Страница сгенерирована за %f секунд<p>",$time);
//Cache : end
//echo $sape->return_links($n);