//header('Content-type: text/html; charset=utf-8');
//if (substr(strtolower($_SERVER['HTTP_HOST']),-2)=='eu')
// die('Сайтът е в процес на обновяване и ще е достъпен отново в 13:00. Молим да ни извините за неудобството!');
//die('The site is being updated and will be back online at 13:00. We apologize for the inconvinience!');
define('MAIN_DIR',dirname(__FILE__).'/');
define('LOG_DIR',MAIN_DIR.'log/');
define('INC_DIR',MAIN_DIR.'includes/');
define('H_DIR',MAIN_DIR.'handlers/');
define('D_DIR',MAIN_DIR.'design/');
function die_301($location) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.$location);
header('Content-Length: 0');
die();
}
function die_302($location) {
header('HTTP/1.1 302 Found');
header('Location: '.$location);
header('Content-Length: 0');
die();
}
function die_404() {header('HTTP/1.1 404 Not Found');require(D_DIR.'404.php');die();}
function die_500() {header('HTTP/1.1 500 Internal Server Error');require(D_DIR.'500.php');die();}
function mt() {list($u,$s)=explode(' ',microtime());return ((float)$u+(float)$s);}
require(INC_DIR.'db_config.php');
require(INC_DIR.'db.php');
$rewrite=false;
$domain=strtolower($_SERVER['HTTP_HOST']);
$domain_parts=explode('.',$domain);
$domain_parts_count=count($domain_parts);
if ($domain_parts_count>2 and $_SERVER['SERVER_ADDR']!='127.0.0.1') {
$domain=$domain_parts[$domain_parts_count-2].'.'.$domain_parts[$domain_parts_count-1];
$rewrite=true;
}
if (!$rs=db_select('domain_country','domain',array('domain_name'=>'"'.db_encode($domain).'"'))) die_500();
if ($row=mysqli_fetch_row($rs)) $country_code=$row[0]; else $country_code='bg';
if (!$rs=db_select('domain_name,country_phone,country_vat','domain JOIN country ON country_code=domain_country',
array('domain_country'=>'"'.$country_code.'"'),'ORDER BY domain_order LIMIT 1') or
!$row=mysqli_fetch_row($rs)) die_500();
$domain=$row[0];$phone=$row[1];$vat=$row[2];
$vat_percent='';
if ($vat<10) $vat_percent.='0.0'.$vat;
elseif ($vat<100) $vat_percent.='0.'.$vat;
else {
$d=$vat%100;$vat_percent.=((int)(($vat-$d)/100)).'.';
if ($d<10) $vat_percent.='0'.$d; else $vat_percent.=$d;
}
$vat_multiplier=1+$vat/10000;
if (!$rewrite and $domain!=$_SERVER['HTTP_HOST']) $rewrite=true;
$languages=array();
if (!$rs=db_select('cl_lang,language_name','country_language JOIN language ON language_code=cl_lang',
array('cl_country'=>'"'.$country_code.'"','cl_ready'=>1),'ORDER BY cl_order')) die_500();
while ($row=mysqli_fetch_row($rs)) $languages[$row[0]]=$row[1];
if (empty($languages)) die_500();
$default_language=key($languages);
$currencies=array();
if (!$rs=db_select('cc_currency','country_currency',array('cc_country'=>'"'.$country_code.'"'),'ORDER BY cc_order'))
die_500();
while ($row=mysqli_fetch_row($rs)) $currencies[$row[0]]=$row[0];
if (empty($currencies)) die_500();
$default_currency=key($currencies);
if ($q=strpos($_SERVER['REQUEST_URI'],'?',1)) {
$request_uri=substr($_SERVER['REQUEST_URI'],0,$q);
$rewrite=true;
}
else $request_uri=$_SERVER['REQUEST_URI'];
if ($request_uri=='/' or $request_uri=='/index.php' or $request_uri=='/dispatcher.php') {
if (isset($_COOKIE['site_lang']) and isset($languages[$_COOKIE['site_lang']]))
die_302('http://'.$domain.'/'.$_COOKIE['site_lang'].'/');
else die_302('http://'.$domain.'/'.$default_language.'/');
}
if (!$p1=strpos($request_uri,'/',1)) {
$lang=substr($request_uri,1);
if (!isset($languages[$lang])) {
if (isset($_COOKIE['site_lang']) and isset($languages[$_COOKIE['site_lang']]))
die_302('http://'.$domain.'/'.$_COOKIE['site_lang'].'/');
else die_302('http://'.$domain.'/'.$default_language.'/');
}
else die_301('http://'.$domain.'/'.$lang.'/');
}
else {
$lang=substr($request_uri,1,$p1-1);
if (!isset($languages[$lang])) {
if (isset($_COOKIE['site_lang']) and isset($languages[$_COOKIE['site_lang']]))
die_302('http://'.$domain.'/'.$_COOKIE['site_lang'].'/');
else die_302('http://'.$domain.'/'.$default_language.'/');
}
}
if (!isset($_COOKIE['site_lang']) or $_COOKIE['site_lang']!=$lang) setcookie('site_lang',$lang,time()+63000000,'/');
if (isset($_COOKIE['currency']) and isset($currencies[(int)$_COOKIE['currency']])) $currency=(int)$_COOKIE['currency'];
else {$currency=$default_currency;setcookie('currency',$currency,time()+63000000,'/');}
$last_position=strlen($request_uri)-1;
if ($p1==$last_position) {$path='';$par='';}
elseif ($p2=strpos($request_uri,'/-/',$p1)) {
if ($p2==$p1 or $p2==$p1+1) {$path='';$rewrite=true;}
else $path=substr($request_uri,$p1+1,$p2-$p1-1);
$p3=$p2+2;
if ($p3==$last_position) {$par='';$rewrite=true;}
elseif ($request_uri[$last_position]=='/') $par=substr($request_uri,$p3+1,-1);
else {$par=substr($request_uri,$p3+1);$rewrite=true;}
}
else {
if ($request_uri[$last_position]=='/') $path=substr($request_uri,$p1+1,-1);
else {$path=substr($request_uri,$p1+1);$rewrite=true;}
$par='';
}
$path_decoded=urldecode($path);
if ($path=='') $slug='';
elseif ($p=strrpos($path,'/')) {
$slug=urldecode(substr($path,$p+1));
if ($slug=='') $rewrite=true;
}
else $slug=$path_decoded;
if (!$rs=db_select('*','page JOIN page_tr ON page_id=pt_id AND pt_lang="'.$lang.'"',
array('pt_slug'=>'"'.db_encode($slug).'"','page_country IN ("--","'.$country_code.'")'))) die_500();
elseif (!$row=mysqli_fetch_assoc($rs)) {
if (!$rs=db_select('sh_page','slug_history',
array('sh_lang'=>'"'.$lang.'"','sh_country IN ("--","'.$country_code.'")',
'sh_slug'=>'"'.db_encode($slug).'"'))) die_500();
elseif ($row=mysqli_fetch_row($rs)) {
if (!$rs=db_select('*','page JOIN page_tr ON page_id=pt_id AND pt_lang="'.$lang.'"',
array('page_id'=>$row[0],'page_country IN ("--","'.$country_code.'")'))) die_500();
elseif (!$row=mysqli_fetch_assoc($rs)) {
if ($slug=='') die_500();
else die_404();
}
elseif ($row['page_ready']==0) die_500();
}
elseif ($slug=='') die_500();
else die_404();
}
elseif ($row['page_ready']==0) die_500();
$page=array(
'id'=>$row['page_id'],
'parent'=>$row['page_parent'],
'long_url'=>$row['page_long_url'],
'title'=>$row['pt_title'],
'path_title'=>$row['pt_path_title'],
'keywords'=>$row['pt_keywords'],
'description'=>$row['pt_description'],
'handler'=>$row['page_handler'],
'name'=>$row['page_name'],
'slug'=>$row['pt_slug'],
'additional_css'=>''
);
if ($page['id']==1) {
if (!$rs=db_select('page_id','page',array('page_name'=>'"Начална страница"','page_country="'.$country_code.'"')) or
!$row=mysqli_fetch_row($rs)) die_500();
$page['extra']=$row[0];
}
$proper_path=$page['slug'];
$menu_open=array($page['id']=>1);
$path_slugs=array();
//if ($page['id']>1)
// $path_slugs[]=array('long_url'=>$page['long_url'],'slug'=>urlencode($page['slug']),'title'=>$page['path_title']);
if ($page['parent']>1) {
$pp=$page['parent'];
do {
$menu_open[$pp]=1;
if (!$rs=db_select('page_parent,pt_slug,page_long_url,pt_path_title',
'page JOIN page_tr ON page_id=pt_id AND pt_lang="'.$lang.'"',array('page_id'=>$pp)) or
!$rr=mysqli_fetch_row($rs)) die_500();
$pp=$rr[0];
$path_slugs[]=array('long_url'=>$rr[2],'slug'=>urlencode($rr[1]),'title'=>$rr[3]);
if ($page['long_url']==1) $proper_path=$rr[1].'/'.$proper_path;
}
while ($pp>1);
}
if ($path_decoded!=$proper_path) $rewrite=true;
session_start();
if (isset($_SESSION['client']['log_id'])) {$log_id=$_SESSION['client']['log_id'];$logged=true;}
else {$log_id=0;$logged=false;}
$links=array();
function load_link($link_name,$page_name) {
global $links,$lang,$country_code;
if (!$rs=db_select('page_parent,page_long_url,pt_slug,pt_link_title',
'page JOIN page_tr ON page_id=pt_id AND pt_lang="'.$lang.'"',
array('page_country IN ("--","'.$country_code.'")',
'page_name'=>'"'.db_encode($page_name).'"')) or
!$row=mysqli_fetch_assoc($rs)) die_500();
$link=urlencode($row['pt_slug']);
if ($row['page_long_url']==1 and $row['page_parent']>1) {
$pp=$row['page_parent'];
do {
if (!$rsr=db_select('page_parent,pt_slug','page JOIN page_tr ON page_id=pt_id',
array('pt_id'=>$pp,'pt_lang'=>'"'.$lang.'"')) or
!$rr=mysqli_fetch_row($rsr)) die_500();
$pp=$rr[0];$link=urlencode($rr[1]).'/'.$link;
}
while ($pp>1);
}
$links[$link_name]=array('title'=>$row['pt_link_title'],'link'=>'/'.$lang.'/'.$link.'/');
}
require(INC_DIR.'element_types.php');
$elements=array();$shared=array();
function load_elements($parent_type,$parent,&$p) {
global $element_types,$lang,$country_code;
if (!$rs=db_select('element_id,element_type,element_name','element',
array('element_parent_type'=>$parent_type,'element_parent'=>$parent),'ORDER BY element_order')) die_500();
while ($row=mysqli_fetch_row($rs)) {
$p[$row[0]]=array(
'type'=>$row[1],
'name'=>$row[2],
'values'=>array(),
'children'=>array()
);
$v=&$element_types[$row[1]]['values'];
if (!empty($v)) {
if (!$rs2=db_select('content_name,content_text','content',
array('content_element'=>$row[0],'content_lang IN ("'.$lang.'","--")'))) die_500();
while ($row2=mysqli_fetch_row($rs2)) if (isset($v[$row2[0]])) {
$t=$v[$row2[0]];
if ($t>99) {
if (!$rs3=db_select('upload_name,upload_ext','upload',
array('upload_id'=>$row2[1],'upload_status'=>0,'upload_type'=>$t))) die_500();
if ($row3=mysqli_fetch_row($rs3))
$p[$row[0]]['values'][$row2[0]]=array(
'id'=>$row2[1],
'name'=>$row3[0],
'ext'=>$row3[1]
);
}
elseif ($t==31) {
if (!$rs3=db_select('page_parent,page_long_url,pt_slug,pt_link_title',
'page JOIN page_tr ON page_id=pt_id AND pt_lang="'.$lang.'"',
array('page_country IN ("--","'.$country_code.'")',
'page_id'=>$row2[1],'page_ready'=>1))) die_500();
if ($row3=mysqli_fetch_row($rs3)) {
$link=urlencode($row3[2]);
if ($row3[1]==1 and $row3[0]>1) {
$pp=$row3[0];
do {
if (!$rsr=db_select('page_parent,pt_slug','page JOIN page_tr ON page_id=pt_id',
array('pt_id'=>$pp,'pt_lang'=>'"'.$lang.'"')) or !$rr=mysqli_fetch_row($rsr))
die_500();
$pp=$rr[0];$link=urlencode($rr[1]).'/'.$link;
}
while ($pp>1);
}
$p[$row[0]]['values'][$row2[0]]=array(
'id'=>$row2[1],
'url'=>'/'.$lang.'/'.$link.'/',
'title'=>$row3[3]
);
}
}
else {
$p[$row[0]]['values'][$row2[0]]=$row2[1];
if ($row[1]==254 and $row2[0]=='CSS') $page['additional_css'].=$row2[1];
}
}
}
load_elements(1,$row[0],$p[$row[0]]['children']);
}
}
function load_shared($parent_type,$parent,&$p) {
global $element_types,$lang,$country_code;
if ($parent_type==0 and $parent==0)
$rs=db_query('(SELECT element_id,element_type,element_name FROM element WHERE element_country="--"'.
' AND element_parent_type=0 AND element_parent=0 ORDER BY element_order) UNION ALL'.
' (SELECT element_id,element_type,element_name FROM element WHERE element_country="'.$country_code.
'" AND element_parent_type=0 AND element_parent=0 ORDER BY element_order)');
else $rs=db_select('element_id,element_type,element_name','element',
array('element_parent_type'=>$parent_type,'element_parent'=>$parent),'ORDER BY element_order');
if (!$rs) die_500();
while ($row=mysqli_fetch_row($rs)) {
if (!isset($p[$row[2]]) or $p[$row[2]]['type']!=$row[1])
$p[$row[2]]=array(
'type'=>$row[1],
'values'=>array(),
'children'=>array()
);
$v=&$element_types[$row[1]]['values'];
if (!empty($v)) {
if (!$rs2=db_select('content_name,content_text','content',
array('content_element'=>$row[0],'content_lang IN ("'.$lang.'","--")'))) die_500();
while ($row2=mysqli_fetch_row($rs2)) if (isset($v[$row2[0]])) {
$t=$v[$row2[0]];
if ($t>99) {
if (!$rs3=db_select('upload_name,upload_ext','upload',
array('upload_id'=>$row2[1],'upload_status'=>0,'upload_type'=>$t))) die_500();
if ($row3=mysqli_fetch_row($rs3))
$p[$row[2]]['values'][$row2[0]]=array(
'id'=>$row2[1],
'name'=>$row3[0],
'ext'=>$row3[1]
);
}
elseif ($t==31) {
if (!$rs3=db_select('page_parent,page_long_url,pt_slug,pt_link_title',
'page JOIN page_tr ON page_id=pt_id AND pt_lang="'.$lang.'"',
array('page_country IN ("--","'.$country_code.'")',
'page_id'=>$row2[1],'page_ready'=>1))) die_500();
if ($row3=mysqli_fetch_row($rs3)) {
$link=urlencode($row3[2]);
if ($row3[1]==1 and $row3[0]>1) {
$pp=$row3[0];
do {
if (!$rsr=db_select('page_parent,pt_slug','page JOIN page_tr ON page_id=pt_id',
array('pt_id'=>$pp,'pt_lang'=>'"'.$lang.'"')) or !$rr=mysqli_fetch_row($rsr))
die_500();
$pp=$rr[0];$link=urlencode($rr[1]).'/'.$link;
}
while ($pp>1);
}
$p[$row[2]]['values'][$row2[0]]=array(
'id'=>$row2[1],
'url'=>'/'.$lang.'/'.$link.'/',
'title'=>$row3[3]
);
}
}
else $p[$row[2]]['values'][$row2[0]]=$row2[1];
}
}
load_shared(1,$row[0],$p[$row[2]]['children']);
}
}
if ($page['id']==1) load_elements(0,$page['extra'],$elements);
load_elements(0,$page['id'],$elements);
load_shared(0,0,$shared);
$settings=array();
if (!$rs=db_select('ss_name,ss_value','system_setting')) die_500();
while ($row=mysqli_fetch_row($rs)) $settings[$row[0]]=$row[1];
$proper_par='';
if (!empty($page['handler'])) require(H_DIR.$page['handler'].'.php');
if ($rewrite or $par!=$proper_par) {
$url='http://'.$domain.'/'.$lang.'/';
if ($proper_path!='') $url.=$proper_path.'/';
if ($proper_par!='') $url.='-/'.$proper_par.'/';
die_301($url);
}
if ($page['id']==1) {
if (!$rs=db_select('upload_id,upload_name,slide_link',
'slide JOIN upload ON upload_id=slide_image AND upload_status=0 AND upload_type=106',
array('slide_country'=>'"'.$country_code.'"','slide_lang'=>'"'.$lang.'"'),
'ORDER BY slide_order')) die_500();
$slides=array();
while ($row=mysqli_fetch_row($rs)) $slides[]=array('id'=>$row[0],'name'=>$row[1],'link'=>$row[2]);
}
else {
$language_links=array();
foreach ($languages as $lang_id=>$lang_name)
if ($lang_id==$lang) {
if ($proper_par=='') $language_links[$lang_id]=$proper_path.'/';
else $language_links[$lang_id]=$proper_path.'/-/'.$proper_par.'/';
}
elseif (!$rs=db_select('pt_slug','page_tr',array('pt_id'=>$page['id'],'pt_lang'=>'"'.$lang_id.'"')) or
!$row=mysqli_fetch_assoc($rs)) die_500();
else {
$link=urlencode($row['pt_slug']);
if ($page['long_url']==1 and $page['parent']>1) {
$pp=$page['parent'];
do {
if (!$rs=db_select('page_parent,pt_slug','page JOIN page_tr ON page_id=pt_id',
array('pt_id'=>$pp,'pt_lang'=>'"'.$lang_id.'"')) or !$rr=mysqli_fetch_row($rs)) die_500();
$pp=$rr[0];$link=urlencode($rr[1]).'/'.$link;
}
while ($pp>1);
}
if ($proper_par=='') $language_links[$lang_id]=$link.'/';
else $language_links[$lang_id]=$link.'/-/'.$proper_par.'/';
}
}
if (!$rs=db_select('upload_id,upload_name,upload_ext,banner_link',
'banner JOIN upload ON upload_id=banner_image AND upload_status=0 AND upload_type=140',
array('banner_country'=>'"'.$country_code.'"','banner_lang'=>'"'.$lang.'"'),
'ORDER BY banner_order')) die_500();
$banners=array();
while ($row=mysqli_fetch_row($rs))
$banners[]=array('banner'=>'/img/b/'.$lang.'/'.$row[0].'/'.$row[1].'.'.$row[2],'type'=>$row[2],'link'=>$row[3]);
$menus=array();
if (!$rs=db_select('*','menu')) die_500();
while ($row=mysqli_fetch_assoc($rs)) {
$menus[$row['menu_name']]=array();
if (!$rs2=db_select('mi_id,mi_visibility,mi_page,mit_title','menu_item JOIN menu_item_tr ON mi_id=mit_id AND mit_lang="'.$lang.'"',
array('mi_menu'=>$row['menu_id']),'ORDER BY mi_order')) die_500();
while ($row2=mysqli_fetch_assoc($rs2)) if ($row2['mi_visibility']==0 or ($row2['mi_visibility']==1 and !$logged) or ($row2['mi_visibility']==2 and $logged)) {
$item=array('title'=>$row2['mit_title']);
if ($row2['mi_page']==1) $item['link']='/'.$lang.'/';
elseif ($row2['mi_page']>1) {
if (!$rs3=db_select('page_parent,page_long_url,pt_slug',
'page JOIN page_tr ON page_id=pt_id AND pt_lang="'.$lang.'"',
array('page_country IN ("--","'.$country_code.'")',
'page_id'=>$row2['mi_page'],'page_ready'=>1))) die_500();
elseif ($row3=mysqli_fetch_assoc($rs3)) {
$link=urlencode($row3['pt_slug']);
if ($row3['page_long_url']==1 and $row3['page_parent']>1) {
$pp=$row3['page_parent'];
do {
if (!$rsr=db_select('page_parent,pt_slug','page JOIN page_tr ON page_id=pt_id',
array('pt_id'=>$pp,'pt_lang'=>'"'.$lang.'"')) or !$rr=mysqli_fetch_row($rsr)) die_500();
$pp=$rr[0];$link=urlencode($rr[1]).'/'.$link;
}
while ($pp>1);
}
$item['link']='/'.$lang.'/'.$link.'/';
}
}
$has_sub_active=false;
if ($row['menu_has_sub']==1) {
if (!$rs_sub=db_select('msi_page,msit_title',
'menu_sub_item JOIN menu_sub_item_tr ON msi_id=msit_id AND msit_lang="'.$lang.'"',
array('msi_item'=>$row2['mi_id']),'ORDER BY msi_order')) die_500();
if (mysqli_num_rows($rs_sub)) {
$item['sub']=array();
while ($row_sub=mysqli_fetch_assoc($rs_sub)) {
$sub_item=array('title'=>$row_sub['msit_title']);
if ($row_sub['msi_page']==1) $sub_item['link']='/'.$lang.'/';
elseif (!$rs3=db_select('page_parent,page_long_url,pt_slug',
'page JOIN page_tr ON page_id=pt_id AND pt_lang="'.$lang.'"',
array('page_country IN ("--","'.$country_code.'")',
'page_id'=>$row_sub['msi_page'],'page_ready'=>1))) die_500();
elseif ($row3=mysqli_fetch_assoc($rs3)) {
$link=urlencode($row3['pt_slug']);
if ($row3['page_long_url']==1 and $row3['page_parent']>1) {
$pp=$row3['page_parent'];
do {
if (!$rsr=db_select('page_parent,pt_slug','page JOIN page_tr ON page_id=pt_id',
array('pt_id'=>$pp,'pt_lang'=>'"'.$lang.'"')) or
!$rr=mysqli_fetch_row($rsr)) die_500();
$pp=$rr[0];$link=urlencode($rr[1]).'/'.$link;
}
while ($pp>1);
}
$sub_item['link']='/'.$lang.'/'.$link.'/';
}
else continue;
if (isset($menu_open[$row_sub['msi_page']])) $sub_item['active']=$has_sub_active=true;
$item['sub'][]=&$sub_item;
unset($sub_item);
}
}
}
if ($has_sub_active or isset($menu_open[$row2['mi_page']])) $item['active']=true;
$menus[$row['menu_name']][$row2['mi_id']]=&$item;
unset($item);
}
}
load_link('cart','Количка');
load_link('contact','Контакт');
load_link('gallery','Галерия');
load_link('sale','Разпродажба');
if ($logged) {
load_link('profile','Клиентски профил');
load_link('logout','Изход');
}
$galleries=array();
if (!$rs=db_select('*','gallery')) die_500();
while ($row=mysqli_fetch_assoc($rs)) {
$galleries[$row['gallery_name']]=array();
if (!$rs2=db_select('upload_id,upload_name','gallery_image'.
' JOIN upload ON upload_id=gi_image AND upload_status=0 AND upload_type=103',
array('gi_gallery'=>$row['gallery_id']),'ORDER BY gi_order')) die_500();
while ($row2=mysqli_fetch_row($rs2)) $galleries[$row['gallery_name']][]=array('id'=>$row2[0],'name'=>$row2[1]);
}
$common_discounts=array();
if (!$rs=db_select('discount_type,discount_target,discount_amount','discount',array(
'discount_country'=>'"'.$country_code.'"','discount_client'=>0,
'(discount_expiration="0000-00-00" OR discount_expiration>=CURDATE())'
))) die_500();
while ($row=mysqli_fetch_assoc($rs))
$common_discounts[$row['discount_type']][$row['discount_target']]=$row['discount_amount'];;
$personal_discounts=array();
if ($logged) {
if (!$rs=db_select('discount_type,discount_target,discount_amount','discount',array(
'discount_country'=>'"'.$country_code.'"','discount_client'=>$log_id,
'(discount_expiration="0000-00-00" OR discount_expiration>=CURDATE())'
))) die_500();
while ($row=mysqli_fetch_assoc($rs))
$personal_discounts[$row['discount_type']][$row['discount_target']]=$row['discount_amount'];
}
function formatPrice($n) {
if ($n<10) return '0,0'.$n; elseif ($n<100) return '0,'.$n;
else {
$d=$n%100;$t=((int)(($n-$d)/100)).',';
if ($d<10) return $t.'0'.$d; else return $t.$d;
}
}
if (isset($_SESSION['cart'])) {
$t=0;$cart_qt=0;
foreach ($_SESSION['cart']['products'] as $cp) {
$cart_qt+=$cp['qt'];
if (($currency==1 and $cp['discount_bgn']>0) or ($currency!=1 and $cp['discount_euro']>0)) {
if ($currency==1) $price=(int)round(($cp['price_bgn']-$cp['discount_bgn'])*$vat_multiplier);
elseif ($currency==0) $price=(int)round(($cp['price_euro']-$cp['discount_euro'])*$vat_multiplier);
else $price=(int)round(($cp['price_euro']-$cp['discount_euro'])*$vat_multiplier*$settings['ron_euro']/10000);
}
elseif ($cp['type']==2) {
if ($currency==1) $price=(int)round($cp['price_bgn']*$vat_multiplier);
elseif ($currency==0) $price=(int)round($cp['price_euro']*$vat_multiplier);
else $price=(int)round($cp['price_euro']*$vat_multiplier*$settings['ron_euro']/10000);
}
else {
$multiplier=1;
if (isset($personal_discounts[1][$cp['id']]))
$multiplier=min($multiplier,1-$personal_discounts[1][$cp['id']]/10000);
if (isset($common_discounts[1][$cp['id']]))
$multiplier=min($multiplier,1-$common_discounts[1][$cp['id']]/10000);
if (isset($personal_discounts[0][0])) $multiplier=min($multiplier,1-$personal_discounts[0][0]/10000);
if (isset($common_discounts[0][0])) $multiplier=min($multiplier,1-$common_discounts[0][0]/10000);
if ($currency==1) $price=(int)round($multiplier*$vat_multiplier*$cp['price_bgn']);
elseif ($currency==0) $price=(int)round($multiplier*$vat_multiplier*$cp['price_euro']);
else $price=(int)round($multiplier*$vat_multiplier*$cp['price_euro']*$settings['ron_euro']/10000);
}
$t+=$cp['qt']*$price;
}
$cart_price=formatPrice($t);
}
else {
$_SESSION['cart']=array('products'=>array());
$cart_qt=0;$cart_price='0,00';
}
$currency_names=array(
0=>'€',
1=>$shared['Хедър - Преводи']['children']['лв.']['values']['Текст'],
2=>$shared['Хедър - Преводи']['children']['lei']['values']['Текст']
);
$currency_text=&$currency_names[$currency];
$jquery_plugins=array('slides'=>'/ss/slides.min.jquery.js');
$jquery_onload=
'$("#footer_gallery").slides({'.
'preload:true,'.
'preloadImage:"/images/bottom/loading.gif",'.
'play:5000,'.
'pause:2500,'.
'pagination:false,'.
'generatePagination:false,'.
'generateNextPrev:false,'.
'hoverPause:true'.
'});';
$hide_cart = true;
require(D_DIR.'page.php');
?>