data['LV_OPTIONS']['LV_SHOWPRICE_MODE']; if (isset($conf->data['LV_OPTIONS']['LV_BLOCKED']) && ($conf->data['LV_OPTIONS']['LV_BLOCKED']==1)) { echo 'This site is blocked by administrator.'; exit; } $deviceMustbeset = ((!isset($_SESSION['lv_device']) || ($_SESSION['lv_device']=='')) && ((isset($conf->data['LV_OPTIONS']['LV_MOBILE_ENABLED']) && ($conf->data['LV_OPTIONS']['LV_MOBILE_ENABLED']==1)) || (isset($conf->data['LV_OPTIONS']['LV_SOCIAL_ENABLED']) && ($conf->data['LV_OPTIONS']['LV_SOCIAL_ENABLED']==1)))); setSessionDevice($conf,$pg); $tpl = new Template($_SESSION['lv_device']); $tpl->assign('LV_DEVICE',$_SESSION['lv_device']); if ($pg->exists('max')) {exit;} if ($pg->exists("action")) { if ($pg->action == "a") { $pg->action = "article"; } if ($pg->action == "e") { $pg->action = "extra"; } if ($pg->action == "p") { $pg->action = "page"; } $action = $pg->action; } else { $action = ""; } if ($pg->exists("time")) { $pg->_unset("time"); } $httpreferrer = $_SERVER['HTTP_REFERER']; $fullhttps = $conf->data['LV_OPTIONS']['LV_ORDER_SSL_FULL'];; if (($fullhttps!=1) && ($action!="order") && isset($httpreferrer) && (strpos($httpreferrer,'ttps://'.$_SERVER['HTTP_HOST'])==1)) { lvredirect(redirectToHttp($dir,$pg)); } else { $shop_root_dir = getShopRootDir($fullhttps,$action,$conf); $_SESSION['http_pref'] = $shop_root_dir; $tpl->assign('http_pref',$shop_root_dir); if (isset($conf->data['LV_OPTIONS']['LV_MSHOP_SOURCE']) && ($conf->data['LV_OPTIONS']['LV_MSHOP_SOURCE']!='')) { $_SESSION['http_mshop'] = $conf->data['LV_OPTIONS']['LV_MSHOP_SOURCE']; } else { $_SESSION['http_mshop'] = $_SESSION['http_pref']; }; $tpl->assign('http_mshop',$_SESSION['http_mshop']); $_SESSION['http_pref_payment'] = str_replace('https://','http://',$shop_root_dir); $tpl->assign('http_pref_payment',str_replace('https://','http://',$shop_root_dir)); $tpl->assign('refferer',(isset($httpreferrer) ? $httpreferrer : NULL)); if (isset($_SESSION['vatitems'])) { $vatitems = $_SESSION['vatitems']; } else { $vatitems_xml=new CustomXML('lvconfig/vatitems.xml'); $vatitems=array(); foreach ($vatitems_xml->xml['LV_VATITEMS']['LV_VATITEM'] as $v) { $vatitems[$v['LV_NUMBER']]=$v; } unset($vatitems_xml); $_SESSION['vatitems'] = $vatitems; } try { $tpl->xmlArray2Smarty($conf->data['LV_OPTIONS']); $tpl->xmlArray2Smarty($conf->data['LV_TEXT']); $tpl->xmlArray2Smarty(array('LV_LANGUAGES_SELECTION'=>$conf->data['LV_LANGUAGES_SELECTION'])); $language = new Language($tpl); if ($pg->exists("lang") && $language->isLanguageExists($pg->lang)) { $tpl->assign('LV_LANGUAGECODE',$pg->lang); $language->setLanguage($pg->lang); $url = $_SERVER['REQUEST_URI']; $url = str_replace(('&lang='.$pg->lang),'',$url); $url = str_replace(('&lang='.$pg->lang),'',$url); if (strpos($url,'action=') == false) { if (strpos($url,'index.php?') != false) { $url = str_replace('index.php?','index.php',$url); } $url = str_replace('index.php','index.php?action=home',$url); } $tpl->assign('curr_url',$url); } else { $language->setLanguage($conf->data['LV_OPTIONS']['LV_LANGUAGECODE']); } $tpl->assign('RECOMMENDED_PRICE_SHOW_LANG',"LV_LANG_".strtoupper($language->getCurrentLanguage())); $currentLanguage = $language->getCurrentLanguage(); if (!isset($tpl->tpl_vars['curr_url']) || $tpl->tpl_vars['curr_url'] == '') { $tpl->assign('curr_url', $shop_root_dir.'index.php?action=home'); } } catch (Exception $e) { } if ($pg->exists('group_id')) { $group_id=$pg->group_id; } else { $group_id=0; } try { $group=new Groups($group_id,$currentLanguage); } catch (Exception $e) { echo $e->__toString(); } $tpl->assign('LV_MAIN_GROUPS',$group->main); $tpl->assign('LV_GROUPS_FULLSTRUCT',$group->fullstruct); getGroupLevelId($tpl, $group); $attr=new Attributes($conf,$pg->values['attr'],$currentLanguage); if ($attr->set) { $tpl->assign('LV_ATTR_FULLSTRUCT',$attr->fullstruct); } $extrapages = new extrapages($tpl,"./lvconfig/extrapages.xml",$currentLanguage); $tpl->assign('LV_PATH',$group->path); $tpl->assign('LV_SUBGROUPS',$group->sub); $tpl->assign('LV_CURRENT_GROUP',$group->current); $validator = new Login($tpl); if ($pg->exists('lv_af') && (preg_match( '/^\d*$/', $pg->lv_af) == 1)) { $_SESSION['lv_af']=$pg->lv_af; } elseif (isset($_SESSION['lv_af'])) { if($_SESSION['Alpha']!=-1) { unset($_SESSION['lv_af']); } } $tpl->assign('member_mode',$member_mode = $conf->data['logivert']['LV_MEMBER_MODE']); $tpl->assign('member_showarticles',$member_showarticles = $conf->data['logivert']['LV_MEMBER_SHOWARTICLES']); $tpl->assign('member_showprices',"1"); $attention = new Attention($tpl,$currentLanguage,true); $attention->Assign(-1,true); $promotion = new Attention($tpl,$currentLanguage,false); $promotion->Assign(-1,false); if ($pg->exists('passerror')) { $tpl->assign('loginerror',$tpl->getTemplateVars('LV_LOGIN_ERROR')); } if (($member_mode == "Necessary") && ($action != "login") && ($tpl->getTemplateVars('username') == "")) { $tpl->assign('LV_SHOPPINGCART_ENABLED',"0"); $tpl->assign('LV_ATTPROMOARTICLES_ENABLED',"0"); // if login is necessary, user isn't logged in and articles may not be shown to "un"logged users then show home page if ($member_showarticles != 1) { if (($action != "extra") && ($action != "home") && ($action != "formmail")) { $action = "home"; } // if login is necessary, user isn't logged in and articles may be shown to "un"logged users then hide prices } else { $tpl->assign('member_showprices',"0"); } } else { $tpl->assign('LV_ATTPROMOARTICLES_ENABLED',"1"); } if ($conf->data['LV_OPTIONS']['LV_CLIENT_DISPLAY_CHANGE_ENABLED']) { if (!isset($_SESSION['artldisplay']) || ($_SESSION['artldisplay'])) { $_SESSION['artldisplay'] = $conf->data['LV_OPTIONS']['LV_ARTLIST_COMPACTDISPLAY']; } if ($_SESSION['artldisplay'] == "0") { $conf->data['LV_OPTIONS']['LV_ARTLIST_COMPACTDISPLAY'] = "0"; $conf->data['LV_OPTIONS']['LV_ARTLIST_LINEDISPLAY'] = "1"; $tpl->assign('LV_CLIENT_ARTICLE_DISPLAY',1);} else { $conf->data['LV_OPTIONS']['LV_ARTLIST_COMPACTDISPLAY'] = "1"; $conf->data['LV_OPTIONS']['LV_ARTLIST_LINEDISPLAY'] = "0"; $tpl->assign('LV_CLIENT_ARTICLE_DISPLAY',0);} } setBaseMetatags($tpl,$deviceMustbeset,$baseMetatags); if (($action == "") && ($conf->data['LV_OPTIONS']['LV_LANGUAGE_SELECTION_PAGE'] == 0)) { $action = "home"; } $tpl->assign('action',$action); $tpl->assign('tags',getTags()); $tpl->assign('customblocks',getCustomblocks($conf->data['LV_OPTIONS']['LV_CUSTOMBLOCKS_ENABLED'])); switch ($action) { case "home": // Check if sitemap.xml exists. This is only needed if some error occured while creating the sitemap by the offline back-office. The creation of the sitemap offline is beter optimized, it's thereby adviced to use the sitemap created by the offline back-office. if (!file_exists('sitemap.xml')) { $sitemap = new Genmap($language); } try{ $conf_home=new ConfigLoader(array("lvconfig/articles_promotion_block.xml","lvconfig/articles_promotion.xml")); if (isset($conf_home->data['LV_ARTICLES_ATTENTION_BLOCK'])) { $tpl->xmlArray2Smarty(array('LV_ARTICLES_ATTENTION_BLOCK'=>$conf_home->data['LV_ARTICLES_ATTENTION_BLOCK'])); } if (isset($conf_home->data['LV_ARTICLES_PROMOTION_BLOCK'])) { $tpl->xmlArray2Smarty(array('LV_ARTICLES_PROMOTION_BLOCK'=>$conf_home->data['LV_ARTICLES_PROMOTION_BLOCK'])); } addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); } catch (Exception $e) { echo $e->__toString(); } $baseMetatags .= $language->xml_array['LV_META_TAGS']; $tpl->assign('LV_METATAG', AddCanonicalTag($baseMetatags, $shop_root_dir, $action, '', '', $currentLanguage)); $tpl->assign('layout_include','page.home.html'); $tpl->display('layout.html'); break; case "article": try{ addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); $art = new Article($pg->aid); $article=$art->data; if ($article['has_variantparents'] == 1) { $art = new Article($article['variantparents']['variant_parent']); $article = $art->data; $pg->aid = $article['nr']; } $curr_lang='lang_'.$currentLanguage; $article['description']=$article['description'][$curr_lang]; $article['descriptionandmeasure']=$article['descriptionandmeasure'][$curr_lang]; $article['measure']=$article['measure'][$curr_lang]; $article['urlitem']=$article['urlitem'][$curr_lang]; if (isset($article['specification'])) { $article['specification']=$article['specification'][$curr_lang]; } if (isset($article['shortmemo'])) { $article['shortmemo'] = $article['shortmemo'][$curr_lang]; } if (isset($article['longmemo'])) { $article['longmemo'] = $article['longmemo'][$curr_lang]; } $curr_lang2='LV_ARTICLES_'.strtoupper($curr_lang); if (isset($article['lightbox']) && isset($article['lightbox']['lightbox_big'])) { $article['use_lightbox'] = 1; if (!is_array($article['lightbox']['lightbox_big']['picture'])){ $article['lightbox']['lightbox_big']['picture']=array(0=>$article['lightbox']['lightbox_big']['picture']); } if (!is_array($article['lightbox']['lightbox_small']['picture'])){ $article['lightbox']['lightbox_small']['picture']=array(0=>$article['lightbox']['lightbox_small']['picture']); } } else { $article['use_lightbox'] = 0; } if (!isset($article['bottom_scripts'])) { $article['bottom_scripts'] = ''; } if ($article['use_variants']==0) { $article=$art->article_language_conversions($article,$art->get_stock_quantity($art['nr']),$currentLanguage); } elseif ($article['use_variants']==1) { $article_variants=array(); if (isset($article['variants']['variant_article'])) { if (!is_array($article['variants']['variant_article'])) { $article['variants']['variant_article']=array(0=>$article['variants']['variant_article']); } foreach ($article['variants']['variant_article'] as $v) { $a=$art->get_another_product($v,1); if ($a) { $a=$art->article_language_conversions($a,$art->get_stock_quantity($a['nr']),$currentLanguage); $a['descriptionandmeasure']=$a['descriptionandmeasure'][$curr_lang]; if (isset($a['shortmemo'])) { $a['shortmemo'] = $a['shortmemo'][$curr_lang]; } if (isset($a['longmemo'])) { $a['longmemo'] = $a['longmemo'][$curr_lang]; } if (isset($a['options_struct']['options_struct_item'][0]) && (sizeof($a['options_struct']['options_struct_item'][0]) == 0)) { unset($a['options_struct']); } if (isset($a['text_struct']['text_struct_item'][0]) && (sizeof($a['text_struct']['text_struct_item'][0]) == 0)) { unset($a['text_struct']); } $real_vat = 0; if (isset($vatitems[$a['vat']])) { if (isset($vatitems[$a['vat']]['LV_PERCENTAGE'])) { $real_vat = $vatitems[$a['vat']]['LV_PERCENTAGE']; } } $a['vat'] = $real_vat; $a['price_currname'] = $a['price_currname'][$curr_lang]; $a['availability']['availability_text'] = $a['availability'][$curr_lang]['availability_text']; $article_variants[]=$a; } } } $tpl->assign('article_variants',$article_variants); } if (isset($article['related_products']['item'])) { if (!is_array(current($article['related_products']['item']))) { $article['related_products']['item']=array(0=>$article['related_products']['item']); } foreach ($article['related_products']['item'] as $k=>$v) { $a=$art->get_another_product($v['article_nr']); if ($a) { if (is_array(current($a['LV_ARTICLES_GROUP']))) { $a_group=$a['LV_ARTICLES_GROUP']['LV_ARTICLES_ITEM'][0]; } else { $a_group=$a['LV_ARTICLES_GROUP']['LV_ARTICLES_ITEM']; } $article['related_products']['item'][$k]['group_id'] = $a_group; $article['related_products']['item'][$k]['descriptionandmeasure'] = $a['LV_ARTICLES_DESCRIPTIONANDMEASURE'][$curr_lang2]; $article['related_products']['item'][$k]['picturemini'] = $a['LV_ARTICLES_PICTUREMINI']; $article['related_products']['item'][$k]['picturesmall'] = $a['LV_ARTICLES_PICTURESMALL']; $article['related_products']['item'][$k]['price_currname'] = $a['LV_ARTICLES_PRICE_CURRNAME'][$curr_lang2]; $article['related_products']['item'][$k]['showprice_mode'] = $a['LV_ARTICLES_SHOWPRICE_MODE']; $article['related_products']['item'][$k]['urlitem'] = $a['LV_ARTICLES_URLITEM'][$curr_lang2]; $article['related_products']['item'][$k]['nr'] = $a['LV_ARTICLES_NR']; $real_vat = 0; if (isset($vatitems[$a['LV_ARTICLES_VAT']])) { if (isset($vatitems[$a['LV_ARTICLES_VAT']]['LV_PERCENTAGE'])) { $real_vat = $vatitems[$a['LV_ARTICLES_VAT']]['LV_PERCENTAGE']; } } $article['related_products']['item'][$k]['vat'] = $real_vat; } } } // Cross Marketing if (isset($article['cm']['cm_text'])) { $article['cm']['cm_text']=$article['cm']['cm_text'][$curr_lang]; if (isset($article['cm']['cm_item'])) { if (!is_array($article['cm']['cm_item'])) { $article['cm']['cm_item']=array(0=>$article['cm']['cm_item']); } foreach ($article['cm']['cm_item'] as $v) { $a=$art->get_another_product($v); if ($a) { if (is_array(current($a['LV_ARTICLES_GROUP']))) { $a_group=$a['LV_ARTICLES_GROUP']['LV_ARTICLES_ITEM'][0]; } else { $a_group=$a['LV_ARTICLES_GROUP']['LV_ARTICLES_ITEM']; } $real_vat = 0; if (isset($vatitems[$a['LV_ARTICLES_VAT']])) { if (isset($vatitems[$a['LV_ARTICLES_VAT']]['LV_PERCENTAGE'])) { $real_vat = $vatitems[$a['LV_ARTICLES_VAT']]['LV_PERCENTAGE']; } } $article['cm']['products'][] = array( 'nr'=>$a['LV_ARTICLES_NR'], 'group_id'=>$a_group, 'picturesmall'=>$a['LV_ARTICLES_PICTURESMALL'], 'picturemini'=>$a['LV_ARTICLES_PICTUREMINI'], 'description'=>$a['LV_ARTICLES_DESCRIPTION'][$curr_lang2], 'measure'=>$a['LV_ARTICLES_MEASURE'][$curr_lang2], 'descriptionandmeasure'=>$a['LV_ARTICLES_DESCRIPTIONANDMEASURE'][$curr_lang2], 'urlitem'=>$a['LV_ARTICLES_URLITEM'][$curr_lang2], 'price_currname'=>$a['LV_ARTICLES_PRICE_CURRNAME'][$curr_lang2], 'price'=>$a['LV_ARTICLES_PRICE_SHOW'], 'showprice_mode'=>$a['LV_ARTICLES_SHOWPRICE_MODE'], 'vat'=>$real_vat, 'first_group'=>$a['first_group']); } } } } if (isset($article['ecotaxes']['ecotax'])&&!is_array(current($article['ecotaxes']['ecotax']))) { $article['ecotaxes']['ecotax']=array(0=>$article['ecotaxes']['ecotax']); } if (!empty($article['recommendedprice'])) { if (is_array($article['recommendedprice'])) { $tpl->assign('INVALID_RECOMMENDED_PRICE','true'); } else { $tpl->assign('INVALID_RECOMMENDED_PRICE','false'); } } else { $tpl->assign('INVALID_RECOMMENDED_PRICE','false'); } if (isset($conf->data['LV_OPTIONS']['LV_REVIEW_ENABLED']) && ($conf->data['LV_OPTIONS']['LV_REVIEW_ENABLED']==1)) { if (isset($article['review_total']) && ($article['review_total']>=1)) { $article['reviews'] = $art->get_reviews($pg->aid,strtoupper($currentLanguage)); } } $article=$art->setArticleAttributes($conf,$article,$attr,$currentLanguage); $real_vat = 0; if (isset($vatitems[$article['vat']])) { if (isset($vatitems[$article['vat']]['LV_PERCENTAGE'])) { $real_vat = $vatitems[$article['vat']]['LV_PERCENTAGE']; } } $article['vat'] = $real_vat; $article['availability']['availability_text'] = $article['availability'][$curr_lang]['availability_text']; if (($article['options_struct'] != '') && isset($article['options_struct']['options_struct_item'][0]) && (sizeof($article['options_struct']['options_struct_item'][0]) == 0)) { unset($article['options_struct']); } if (($article['text_struct'] != '') && isset($article['text_struct']['text_struct_item'][0]) && (sizeof($article['text_struct']['text_struct_item'][0]) == 0)) { unset($article['text_struct']); } $tpl->assign('article',$article); $tpl->assign('group_id',$group_id); $tpl->assign('group_id_level1',$group->level1); $art->get_another_product($pg->aid); $tpl->assign('LV_OPTIONS_SITETITLE', $art->xml['Logivert']['LV_META_TITLE']['LV_'.strtoupper($currentLanguage)]); $baseMetatags .= $art->xml['Logivert']['LV_META_TAGS']['LV_'.strtoupper($currentLanguage)]; $tpl->assign('LV_METATAG', AddCanonicalTag($baseMetatags, $shop_root_dir, $action, $pg->aid, $art->data['urlitem'][$curr_lang], $currentLanguage)); $tpl->assign('layout_include','page.art.html'); $tpl->display('layout.html'); } catch (Exception $e) { lvredirect('index.php?action=home&lang='.strtoupper($currentLanguage)); } break; case "extra": try { if (strpos($pg->extra, 'A_') !== 0) { $pg->extra = 'A_'.$pg->extra; } addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); $extrapages->AssignPage($pg->extra,$currentLanguage); $extra = new extrapage($pg->extra); $tpl->assign('extra', $pg->extra); $tpl->assign('LV_OPTIONS_SITETITLE', $extra->xml['LV_EXTRAPAGE']['LV_SEARCHTITLE']['LV_'.strtoupper($currentLanguage)]); if (isset($extra->xml['LV_EXTRAPAGE']['LV_META_TAGS']) && isset($extra->xml['LV_EXTRAPAGE']['LV_META_TAGS']['LV_'.strtoupper($currentLanguage)])) { $baseMetatags .= $extra->xml['LV_EXTRAPAGE']['LV_META_TAGS']['LV_'.strtoupper($currentLanguage)]; } $tpl->assign('LV_METATAG', AddCanonicalTag($baseMetatags, $shop_root_dir, $action, $pg->extra, '', $currentLanguage)); $tpl->assign('formvalues', $_SESSION['formvalues']); $tpl->assign('formsent', $_SESSION['formsent']); $tpl->assign('errors', $_SESSION['errors']); $_SESSION['formvalues'] = null; $_SESSION['formsent'] = ""; $_SESSION['errors'] = ""; $tpl->assign('layout_include','page.extra.html'); $tpl->display('layout.html'); } catch (Exception $e) { lvredirect('index.php?action=home&lang='.strtoupper($currentLanguage)); } break; case "page": // fallthrough case "filter": case "tags": if (isset($group->current) || ($action == "filter") || ($action == "tags")) { addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); if ($pg->exists('page')) { $page = $pg->page; } else { $page = 0; } $tpl->assign('current_page',$page); $tpl->assign('group_id',$group_id); $tpl->assign('group_id_level1',$group->level1); $art = new Articles(); $first = $page * $conf->data['LV_OPTIONS']['LV_ARTICLES_PER_PAGE']; switch ($action) { case "page": $resource = $art->Select(('limit '.$first.','.$conf->data['LV_OPTIONS']['LV_ARTICLES_PER_PAGE']),$group_id); break; case "filter": $search = new Search($currentLanguage); $res = $search->artsWithAttributes(implode(",", $pg->values['attr']),$pg->values['price_from'],$pg->values['price_to']); $resource = $art->Select(('limit '.$first.','.$conf->data['LV_OPTIONS']['LV_ARTICLES_PER_PAGE']),"",$res); $tpl->assign('attr',$pg->values['attr']); $tpl->assign('price_from',$pg->values['price_from']); $tpl->assign('price_to',$pg->values['price_to']); $tpl->assign('scrollTop',$pg->values['scrollTop']); break; case "tags": $search = new Search($currentLanguage); $res = $search->artsWithArttags($pg->values['tagid'],$tagname); $resource = $art->Select(('limit '.$first.','.$conf->data['LV_OPTIONS']['LV_ARTICLES_PER_PAGE']),"",$res); break; } $pages = ceil($art->quantity_in_group/$conf->data['LV_OPTIONS']['LV_ARTICLES_PER_PAGE']); $tpl->assign('pages',$pages); $articles = array(); $stock = array(); $curr_lang = 'lang_'.$currentLanguage; while ($a=$art->Fetch($resource)) { if ($a['use_variants']==0) { $a->data=$a->article_language_conversions($a->data,$a->get_stock_quantity($a->data['nr']),$currentLanguage); } $a = $a->data; $a['description'] = $a['description'][$curr_lang]; $a['descriptionandmeasure']=$a['descriptionandmeasure'][$curr_lang]; $a['measure'] = $a['measure'][$curr_lang]; $a['specification'] = $a['specification'][$curr_lang]; $a['urlitem'] = $a['urlitem'][$curr_lang]; $a['compordertextvisible']['compordertext'] = (isset($a['compordertextvisible'][$curr_lang]['compordertext']) ? $a['compordertextvisible'][$curr_lang]['compordertext'] : ""); $a['shortmemo'] = $a['shortmemo'][$curr_lang]; if (isset($a['ecotaxes']['ecotax'])&&!is_array(current($a['ecotaxes']['ecotax']))) { $a['ecotaxes']['ecotax'] = array(0=>$a['ecotaxes']['ecotax']); } if (isset($a['options_struct']['options_struct_item'][0]) && (sizeof($a['options_struct']['options_struct_item'][0])==0)) { unset($a['options_struct']); } if (isset($a['text_struct']['text_struct_item'][0]) && (sizeof($a['text_struct']['text_struct_item'][0])==0)) { unset($a['text_struct']); } $real_vat; if (isset($vatitems[$a['vat']])) { if (isset($vatitems[$a['vat']]['LV_PERCENTAGE'])) { $real_vat = $vatitems[$a['vat']]['LV_PERCENTAGE']; } else { } } else { } $a['vat'] = $real_vat; $a['availability']['availability_text'] = $a['availability'][$curr_lang]['availability_text']; if (!isset($a['calcform']) || ($a['calcform']=='')) { $a['calcform'] = 0; }; $articles[]=$a; } $art->Free($resource); switch ($action) { // Set meta tags case "page": if (isset($group->current)) { $tpl->assign('LV_OPTIONS_SITETITLE', $group->current['LV_SEARCHTITLE']['LV_'.strtoupper($currentLanguage)]); $baseMetatags .= $group->current['LV_METATAG']['LV_'.strtoupper($currentLanguage)]; $tpl->assign('LV_METATAG', AddCanonicalTag($baseMetatags, $shop_root_dir, $action, $pg->group_id, $group->current['LV_GROUP_URLITEM'], $currentLanguage)); } break; case "filter": $tpl->assign('LV_OPTIONS_SITETITLE', $language->xml_array['LV_TEXT_FILTER']); $tpl->assign('LV_METATAG', $baseMetatags); break; } $tpl->assign('articles',$articles); $tpl->assign('stock',$stock); $tpl->assign('sortart',$_SESSION['sortart']); $tpl->assign('layout_include','page.artlist.html'); $tpl->display('layout.html'); } else { lvredirect('index.php?action=home&lang='.strtoupper($currentLanguage)); } break; case "showbasket": if (!isset($_SESSION)) { session_start(); } $basket=new Basket(); $errors=''; if ($pg->exists('calculate')) { if ($pg->exists('quantity') && is_array($pg->quantity)) { if ($pg->exists('ids') && is_array($pg->ids) && (count($pg->quantity) == count($pg->ids))) { $i = 0; $j = 0; unset($OrderedNumberManuf); $OrderedNumberManuf = array(); $z = count($pg->quantity); foreach ($basket->data['articles'] as $tm) { $tmp[$tm['id']][$j++] = $tm['ArtQuantity']; } $art = new Article($tm['id']); while ($i < $z) { if ($basket->find_in_cart($pg->ids[$i],'articles',$_POST['additional'][$i], $currentLanguage) == -1) { $errors.= diplayError('no such article in the cart'); $i++; continue; } // Check minimumquantity $art = new Article($pg->ids[$i]); if ($pg->quantity[$i] < $art['minimumquantity']) { $errors .= diplayError($art['descriptionandmeasure']['lang_'.$currentLanguage].': '.$language->xml_array['LV_TEXT_AT_LEAST'].' '.$art['minimumquantity']); } // Check stock if ($art->article_canbeordered($pg->quantity[$i])) { if (!array_key_exists($pg->ids[$i],$tmp)) { $i++; continue; } if ($pg->quantity[$i] < $tmp[$pg->ids[$i]][$i]) { if ($pg->exists('additional')) { $basket->remove_from_cart($pg->ids[$i],($tmp[$pg->ids[$i]][$i]-$pg->quantity[$i]),'articles',$pg->additional[$i],$currentLanguage); } else { $basket->remove_from_cart($pg->ids[$i],($tmp[$pg->ids[$i]][$i]-$pg->quantity[$i]),'articles',Null,$currentLanguage); } } elseif ($pg->quantity[$i] > $tmp[$pg->ids[$i]][$i]) { if ($pg->exists('additional')) { $basket->add_to_cart($pg->ids[$i],($pg->quantity[$i]-$tmp[$pg->ids[$i]][$i]),$currentLanguage,$lvShowPriceMode,'articles',$pg->additional[$i]); } else { $basket->add_to_cart($pg->ids[$i],($pg->quantity[$i]-$tmp[$pg->ids[$i]][$i]),$currentLanguage,$lvShowPriceMode,'articles'); } } } else { $art = $art->get_another_product($pg->ids[$i]); $errors .= diplayError($art['LV_ARTICLES_DESCRIPTIONANDMEASURE']['LV_ARTICLES_LANG_'.strtoupper($currentLanguage)].': '.$language->xml_array['LV_TEXT_MORE_THAN_IN_STOCK']); } $i++; } unset($tmp); } } } // Check on minimum manufacturer order amount if (($tpl->tpl_vars['LV_MINIMUMMANUFACTURERORDERAMOUNT_ENABLED'] == 1) && (file_exists("./lvconfig/manufacturers.xml")) && ($basket->data['articles'] != NULL)) { unset($OrderedNumberManuf); foreach ($basket->data['articles'] as $tm) { // collect manufacturers and quantities of this order unset($art); $art = new Article($tm['id']); $OrderedNumberManuf[$art->data['manufacturer']] = (isset($OrderedNumberManuf) ? $OrderedNumberManuf[$art->data['manufacturer']] : 0) + $tm['ArtQuantity']; } unset($art); $manufacturers = new CustomXML("./lvconfig/manufacturers.xml"); $manufacturers_array = $manufacturers->xml['LV_MANUFACTURERS']['LV_MANUFACTURER']; $manufacturersminorder_array = $manufacturers->xml['LV_MANUFACTURERS']['LV_MINIMUMORDERAMOUNT']; foreach ($OrderedNumberManuf as $ONMkey => $ONMvalue) { // Check the manufacturer quantities of this order with the minimums if ($ONMkey != '') { $minimumorderamount = $manufacturersminorder_array[array_search($ONMkey, $manufacturers_array)]; if ($ONMvalue < $minimumorderamount) { $errors .= diplayError($ONMkey.': '.$language->xml_array['LV_TEXT_AT_LEAST'].' '.$minimumorderamount); } } } unset($OrderedNumberManuf); unset($manufacturers); unset($manufacturers_array); unset($manufacturersminorder_array); } $basket_summary=$basket->get_summary($lvShowPriceMode,$currentLanguage); $tpl->assign('basket_summary',(isset($basket_summary[0]) ? $basket_summary[0] : NULL)); $tpl->assign('basket_summary_addit',(isset($basket_summary[1]) ? $basket_summary[1] : NULL)); $tpl->assign('basket_summary_gifts',$basket_summary[1]['summary_gifts']); $tpl->assign('basket_gifts_total_price',$basket_summary[1]['basket_gifts_total_price']); $tpl->assign('basket_total_price',$basket_summary[1]['basket_total_price']); $tpl->assign('ecotaxes_total_price',$basket_summary[1]['ecotaxes_total']); $tpl->assign('discount_on_total_order',$basket_summary[1]['discount_on_total_order']); $tpl->assign('discount_on_total_order_amount',$basket_summary[1]['discount_on_total_order_amount']); if ($errors!='') { $tpl->assign('errors',$errors); } if (!empty($basket_summary[1]['gift_articles']) && (count($basket->data['gifts'])<$basket->gifts_quantity)) { $tpl->assign('gift_articles',$basket_summary[1]['gift_articles']); $tpl->assign('gift_articles_on',1); } else { $tpl->assign('gift_articles_on',0); } if (isset($conf->data['LV_OPTIONS']['LV_ORDER_SSL']) && ($conf->data['LV_OPTIONS']['LV_ORDER_SSL']==1)) { $_SESSION['document_root']=$_SERVER['DOCUMENT_ROOT'].str_replace('\\','/',dirname($_SERVER['PHP_SELF'])); $_SESSION['http_document_root']='http://'.$_SERVER['HTTP_HOST'].str_replace('\\','/',dirname($_SERVER['PHP_SELF'])); $action_url='https://'.$_SERVER['HTTP_HOST'].str_replace('\\','/',dirname($_SERVER['PHP_SELF'])); if (isset($conf->data['LV_OPTIONS']['LV_ORDER_SSL_NO_WWW']) && ($conf->data['LV_OPTIONS']['LV_ORDER_SSL_NO_WWW']==1)) { $action_url=str_replace('//www.','//',$action_url); } } else { $action_url='index.php'; } $tpl->assign('LV_METATAG', AddCanonicalTag($baseMetatags, $shop_root_dir, $action, '', '', $currentLanguage)); $tpl->assign('action_url',$action_url); $tpl->assign('layout_include','page.cart.html'); $tpl->display('layout.html'); break; case "order" : $p_lang = strtoupper($currentLanguage); if(isset($_SESSION)) { $basket=new Basket(); $basket_summary=$basket->get_summary_small($currentLanguage, $lvShowPriceMode); $tpl->assign('basket_summary',(isset($basket_summary[0]) ? $basket_summary[0] : NULL)); $tpl->assign('basket_summary_addit',(isset($basket_summary[1]) ? $basket_summary[1] : NULL)); if(empty($basket_summary)) { lvredirect('index.php?action=showbasket&lang='.strtoupper($currentLanguage)); exit; } } addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); if ($pg->exists('step')) { $order_step = $pg->step; } else { $order_step=1; } $tpl->assign('action_url','index.php'); if (!$pg->exists('error')) { $_SESSION['out_array']=array(); } $tpl->assign('LV_METATAG', AddCanonicalTag($baseMetatags, $shop_root_dir, $action, $order_step, '', $currentLanguage)); switch ($order_step) { case 1 : if (!isset($_SESSION['order_object'])) { $order = new Order('',$currentLanguage); } else { $order=unserialize($_SESSION['order_object']); } if (!isset($_SESSION['out_array']['return_step_on_error'])) { $_SESSION['out_array']['return_step_on_error']=0; } if (isset($_POST['step']) && $_POST['step']==1) { if(isset($_POST['country'])) $order->set_country($_POST['country']); if(isset($_POST['way_of_delivery'])) $order->set_way_of_delivery($_POST['way_of_delivery']); } $step_data = $order->get_data_for_step1(); $country=$step_data['country']; $tpl->assign('step_data',$step_data); $tpl->assign('country',$country); $conf_order = new ConfigLoader(array("lvconfig/shipitems.xml","lvconfig/paymethoditems.xml","lvconfig/countries.xml")); if (!isset($conf_order->data['LV_COUNTRIES']['LV_COUNTRY'][0])) { $conf_order->data['LV_COUNTRIES']['LV_COUNTRY']= array(0=>$conf_order->data['LV_COUNTRIES']['LV_COUNTRY']); } $countries_list = $conf_order->data['LV_COUNTRIES']['LV_COUNTRY']; $order->set_country_name($countries_list[$country]['LV_NAME']); $country_id = -1; foreach ($countries_list as $k=>$v) { if ($v['LV_ID'] == $country) { $country_id = $k; if (($v['LV_ID'] != 0) && ($v['LV_EU'] == 1)) { $intracom = 1; } else { $intracom = 0; } } } $ship_items=array(); $ship_items_temp=array(); if (isset($countries_list[$country_id]['LV_SHIPITEMS']['LV_ITEMNUMBER'])) { if (count ($countries_list[$country_id]['LV_SHIPITEMS']['LV_ITEMNUMBER']) == 1) { $countries_list[$country_id]['LV_SHIPITEMS']['LV_ITEMNUMBER'] = array(0=>$countries_list[$country_id]['LV_SHIPITEMS']['LV_ITEMNUMBER']); } } if (!isset($conf_order->data['LV_SHIPITEMS']['ITEM']['0'])) { $conf_order->data['LV_SHIPITEMS']['ITEM'] = array(0=>$conf_order->data['LV_SHIPITEMS']['ITEM']); } foreach($conf_order->data['LV_SHIPITEMS']['ITEM'] as $key => $v){ if ((!isset($basket->data['shipitems_excluded'])) || ($basket->data['shipitems_excluded'] == NULL) || (!in_array($v['LV_SHIPITEMNUMBER'], $basket->data['shipitems_excluded']))) { $v["LV_SHIPDESCRIPTION"] = $v["LV_SHIPDESCRIPTION_$p_lang"]; $ship_items[$v['LV_SHIPITEMNUMBER']]=$v; if (isset($countries_list[$country_id]['LV_SHIPITEMS']['LV_ITEMNUMBER'])) { if (in_array($v['LV_SHIPITEMNUMBER'],$countries_list[$country_id]['LV_SHIPITEMS']['LV_ITEMNUMBER'])) { // Check maximum weight if ((isset($v['LV_MAXWEIGHT']) && ($v['LV_MAXWEIGHT'] > 0) && ($v['LV_MAXWEIGHT'] < $basket->data['additional']['weight_total'])) || (isset($v['LV_MINWEIGHT']) && ($v['LV_MINWEIGHT'] > 0) && ($v['LV_MINWEIGHT'] > $basket->data['additional']['weight_total']))){ //do not add -> max weight for ship item has been reached } else { // Check min and max order if ((isset($v['LV_MINORDER']) && isset($v['LV_MAXORDER'])) && ((round($v['LV_MINORDER'],2) > round($basket->data['additional']['basket_total_price_exvat'],2)) || (($v['LV_MAXORDER'] > 0) && (round($v['LV_MAXORDER'],2) < round($basket->data['additional']['basket_total_price_exvat'],2))))) { //do not add -> order total to low or to high } else { $ship_items_temp[$v['LV_SHIPITEMNUMBER']]=$v['LV_SHIPDESCRIPTION']; } } } } } } asort($ship_items_temp); $countries_list[$country]['LV_SHIPITEMS']['LV_ITEMNUMBER']=array_keys($ship_items_temp); unset($ship_items_temp); $paymethods=array(); $paymethods_temp=array(); $paymethods_temp2=array(); $paymethods_array = $conf_order->data['LV_PAYMETHODITEMS']['ITEM']; if (!isset($paymethods_array['0'])) { $paymethods_array = array(0 => $paymethods_array); } if (isset($countries_list[$country_id]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER'])) { if (count ($countries_list[$country_id]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER']) == 1) { $countries_list[$country_id]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER'] = array(0=>$countries_list[$country_id]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER']); } } foreach($paymethods_array as $v){ $paymethods[$v['LV_PAYMETHODITEMNUMBER']]=$v; if (in_array($v['LV_PAYMETHODITEMNUMBER'],$countries_list[$country]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER'])) { $paymethods_temp[$v['LV_PAYMETHODITEMNUMBER']]=$v["LV_PAYMETHODDESCRIPTION_$p_lang"]; } } // Check if all paymethoditem are active with selected shipitem if (isset($conf->data['LV_OPTIONS']['LV_CARTSTEP1_SHIPPINGCHANGE_ENABLED']) && ($conf->data['LV_OPTIONS']['LV_CARTSTEP1_SHIPPINGCHANGE_ENABLED']==1)) { if (isset($step_data['way_of_delivery'])) { $way_of_delivery = $step_data['way_of_delivery']; } else { $way_of_delivery = key($ship_items); } if (isset($ship_items[$way_of_delivery]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER'])) { if (count ($ship_items[$way_of_delivery]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER']) == 1) { $ship_items[$way_of_delivery]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER'] = array(0=>$ship_items[$way_of_delivery]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER']); } } foreach($ship_items[$way_of_delivery]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER'] as $v) { if (isset($paymethods_temp[$v])) { $paymethods_temp2[$v] = $paymethods_temp[$v]; } } } else { $paymethods_temp2 = $paymethods_temp; } asort($paymethods_temp2); $countries_list[$country]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER']=array_keys($paymethods_temp2); foreach ($paymethods as $k=>$v) { $paymethods[$k]['LV_PAYMETHODDESCRIPTION']=$paymethods[$k]["LV_PAYMETHODDESCRIPTION_$p_lang"]; $paymethods[$k]['LV_PAYMETHODINFOFIELD']=(isset($paymethods[$k]['LV_PAYMETHODINFOFIELDS']["LV_LANGUAGE_$p_lang"]) ? $paymethods[$k]['LV_PAYMETHODINFOFIELDS']["LV_LANGUAGE_$p_lang"] : ''); } unset($paymethods_temp); unset($paymethods_temp2); $tpl->assign('LV_SHIPITEMS',$ship_items); $tpl->assign('LV_PAYMETHODITEMS',$paymethods); $tpl->assign('countries_list',$countries_list); $tpl->assign('intracom',$intracom); if (isset($_SESSION['out_array']['ERROR']) && $_SESSION['out_array']['ERROR'][0]) { $errors=""; foreach ($_SESSION['out_array']['ERROR'] as $err) { $errors.= diplayError($language->xml_array[$err]); } $tpl->assign("error_str",$errors); } $_SESSION['order_object']=serialize($order); $tpl->assign('layout_include','page.cart_step1.html'); $tpl->display('layout.html'); break; case 2: if (!isset($_SESSION['order_object'])) { lvredirect('index.php?action=showbasket&lang='.strtoupper($currentLanguage)); } $order=unserialize($_SESSION['order_object']); if ( $_SESSION['out_array']['return_step_on_error']!=2 && isset($_POST['step']) && $_POST['step']==2) { $out=$order->step1($pg->values,$conf->data['logivert']['LV_MEMBER_MODE']); $_SESSION['out_array']=$order->get_errors(); } $order_data = $order->get_data_for_step2(); if ($order_data['paymethod_infofields'] != '') { $order_data['paymethod_infofield']=$order_data['paymethod_infofields']["LV_LANGUAGE_$p_lang"]; if (isset($order_data['paymethod_infofield']) && !isset($order_data['paymethod_infofield']['LV_FIELD'][0])) { $order_data['paymethod_infofield']['LV_FIELD']= array(0=>$order_data['paymethod_infofield']['LV_FIELD']); } } $tpl->xmlArray2Smarty($order_data); $_SESSION['order_object']=serialize($order); $errors=""; if ($_SESSION['out_array']['return_step_on_error']==1) { lvredirect('index.php?action=order&step=1&error=1&lang='.strtoupper($currentLanguage)); } elseif ($_SESSION['out_array']['return_step_on_error']==2) { if ($_SESSION['out_array']['ERROR'][0]) { foreach ($_SESSION['out_array']['ERROR'] as $err) { if (isset($language->xml_array[$err])) { $errors.= diplayError($language->xml_array[$err]); } else { $errors.= diplayError($err); } } } } if (isset($pg->values['errorstring']) && ($pg->values['errorstring'] != '')) { $errors.= diplayError($pg->values['errorstring']); } $tpl->assign("error_str",$errors); $tpl->assign('LV_TEXT_GENERALCONDITION',str_replace(array('
','
','
','
', '
', '
'),"",$language->xml_array['LV_TEXT_GENERALCONDITION'])); $tpl->assign('layout_include','page.cart_step2.html'); $tpl->display('layout.html'); break; case 3: if (!isset($_SESSION['order_object'])) { lvredirect('index.php?action=showbasket&lang='.strtoupper($currentLanguage)); } $order=unserialize($_SESSION['order_object']); if ($_SESSION['out_array']['return_step_on_error']!=3 && isset($_POST['step']) && $_POST['step']==3) { $out=$order->step2($pg->values, $tpl); $_SESSION['out_array']=$order->get_errors(); } $_SESSION['order_object']=serialize($order); if ($_SESSION['out_array']['return_step_on_error']==2) { lvredirect('index.php?action=order&step=2&error=1&lang='.strtoupper($currentLanguage)); } $tpl->xmlArray2Smarty($order->get_data_for_step3()); $tpl->assign('layout_include','page.cart_step3.html'); $tpl->display('layout.html'); break; case 4: if (!isset($_SESSION['order_object'])) { lvredirect('index.php?action=showbasket&lang='.strtoupper($currentLanguage)); } $order = unserialize($_SESSION['order_object']); $paysystem_form = $order->step3($tpl, $order, $status, $paymentid); if ( ((!is_string($status)) && ($status == 0)) || ((is_string($status)) && ($status == 'redirect')) ) { $tpl->xmlArray2Smarty($order->get_data_for_step4()); $tpl->assign('form',$paysystem_form); $order_curr_lang = $currentLanguage; $tpl->assign('lang',$order_curr_lang); $mail = $tpl->fetch("order_confirmation_$order_curr_lang.html"); $shopowneremail = $conf->data['LV_OPTIONS']['SHOP_OWNER_EMAIL']; $customeremail = $tpl->getTemplateVars('email'); $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=utf-8\n"; $headerscustomer .= "From: ".$shopowneremail."\n"; $headerscustomer .= "Reply-To: ".$shopowneremail."\n"; $headerscustomer .= "Return-Path: ".$shopowneremail."\n"; $headersowner .= "From: ".$customeremail."\n"; $headersowner .= "Reply-To: ".$customeremail."\n"; $headersowner .= "Return-Path: ".$customeremail."\n"; $thesubject = encode_iso88591(html_entity_decode($language->xml_array['LV_OPTIONS_SITETITLE'])); mail($customeremail,$thesubject,$mail,$headers . $headerscustomer); mail($shopowneremail,$thesubject,$mail,$headers . $headersowner); if (isset($_SESSION['useStock']) && ($_SESSION['useStock'] > 0)) { $basket->clear_cart('all', True, True); } else { $basket->clear_cart('all', False); } unset($order_curr_lang); if ((!is_string($status)) && ($status == 0)) { $tpl->assign('layout_include','page.cart_step4.html'); $tpl->display('layout.html'); } else { lvredirect($paymentid); } } else { lvredirect('index.php?action=order&step=2&error=1&errorstring='.urlencode($paymentid).'&lang='.strtoupper($currentLanguage)); } break; default: $tpl->assign('layout_include','page.cart_step1.html'); $tpl->display('layout.html'); break; } break; case "cancel_order": if (isset($_SESSION['out_array'])) { unset($_SESSION['out_array']); } if (isset($_SESSION['order_object'])) { $order=unserialize($_SESSION['order_object']); if ($order->ordername!='') { unlink('data/orders/'.$order->ordername); } unset($_SESSION['order_object'],$order); } lvredirect('index.php?action=showbasket&lang='.strtoupper($currentLanguage)); break; case "start_with_empty_cart": $basket = new Basket(); $basket->clear_cart('all', False); lvredirect('index.php'); break; case "add_multi_to_cart": if (CookiesEnabled($tpl)) { try { $multi_articles = $pg->article; } catch (Exception $e){ echo $e->__toString(); } $basket=new Basket(); foreach ($multi_articles as $key=>$value) { $basket->add_to_cart($value['artid'],$value['quantity'],$currentLanguage,$lvShowPriceMode,'articles',$value['additional']); } lvredirect('index.php?action=showbasket&lang='.strtoupper($currentLanguage)); } break; case "add_to_cart": if (CookiesEnabled($tpl)) { if ($pg->exists('artid') && $pg->exists('quantity')) { $errors=''; $valid=1; if (lvfile_exists($conf->data['LV_OPTIONS']['LV_CNST_PATH_DATAARTS_DOT'].'/article_'.$pg->artid.'.xml')) { $art=new Article($pg->artid); } else { lvredirect('index.php?action=home&lang='.strtoupper($currentLanguage)); } if (($art->data['options_struct'] != '') && ($art->data['options_struct']['options_struct_item'] != '')) { if (key($art->data['options_struct']['options_struct_item'])!='0') { $art->data['options_struct']['options_struct_item']=array(0=>$art->data['options_struct']['options_struct_item']); } foreach ($art->data['options_struct']['options_struct_item'] as $v) { if (!is_null($v['option_visible'])) { try { $additional_set = $pg->$v['option_visible']['option_b_name']; } catch (Exception $e) { $additional_set = "--**--IsEmpty--**--"; } if (($v['option_visible']['option_c_required'] == 1) && ($additional_set == "--**--IsEmpty--**--")) { $errors.= diplayError($language->xml_array['LV_TEXT_MESSAGE_THEFIELD'].' "'.$v['option_visible']['option_a_value']['lang_'.$currentLanguage].'" '.$language->xml_array['LV_TEXT_MESSAGE_MAYNOTBEEMPTY']); $valid=0; } } } } if (($art->data['text_struct'] != '') && ($art->data['text_struct']['text_struct_item'] != '')) { if (key($art->data['text_struct']['text_struct_item'])!='0') { $art->data['text_struct']['text_struct_item']=array(0=>$art->data['text_struct']['text_struct_item']); } foreach ($art->data['text_struct']['text_struct_item'] as $v) { if (!is_null($v['text_visible'])) { try { $additional_set = $pg->$v['text_visible']['text_b_name']; } catch (Exception $e) { $additional_set = ""; } if (($v['text_visible']['text_c_required'] == 1) && ($additional_set == "")) { $errors.= diplayError($language->xml_array['LV_TEXT_MESSAGE_THEFIELD'].' "'.$v['text_visible']['text_a_value']['lang_'.$currentLanguage].'" '.$language->xml_array['LV_TEXT_MESSAGE_MAYNOTBEEMPTY']); $valid=0; } } } } if (($art->data['pictbiblio'] != '') && ($art->data['pictbiblio']['item'] != '')) { if (key($art->data['pictbiblio']['item'])!='0') { $art->data['pictbiblio']['item']=array(0=>$art->data['pictbiblio']['item']); } foreach ($art->data['pictbiblio']['item'] as $v) { try { $additional_set = $pg->values['pictbiblio_rb_'.$v['nr']]; } catch (Exception $e) { $additional_set = ""; } if (($v['required'] == 1) && ($additional_set == "")) { $errors.= diplayError($language->xml_array['LV_TEXT_MESSAGE_THEFIELD'].' "'.$v['name'].'" '.$language->xml_array['LV_TEXT_MESSAGE_MAYNOTBEEMPTY']); $valid=0; } } } if (($art->data['datetime_struct'] != '') && ($art->data['datetime_struct']['datetime_struct_item'] != '')) { if (key($art->data['datetime_struct']['datetime_struct_item'])!='0') { $art->data['datetime_struct']['datetime_struct_item']=array(0=>$art->data['datetime_struct']['datetime_struct_item']); } foreach ($art->data['datetime_struct']['datetime_struct_item'] as $v) { if (!is_null($v['datetime_visible'])) { try { $additional_set = $pg->values['dp'.$v['datetime_visible']['datetime_b_name'].$pg->artid]; } catch (Exception $e) { $additional_set = ""; } if (($v['datetime_visible']['datetime_c_required'] == 1) && ($additional_set == "")) { $errors.= diplayError($language->xml_array['LV_TEXT_MESSAGE_THEFIELD'].' "'.$v['datetime_visible']['datetime_a_value']['lang_'.$currentLanguage].'" '.$language->xml_array['LV_TEXT_MESSAGE_MAYNOTBEEMPTY']); $valid=0; } } } } if (!is_numeric($pg->quantity) || ($pg->quantity < $art['minimumquantity'])) { $errors .= diplayError($language->xml_array['LV_TEXT_AT_LEAST'].' '.$art['minimumquantity']); $valid = 0; } $_SESSION['useStock'] = $art['use_stock']; $basket = new Basket(); $totalInBasket = 0; foreach ($basket->data['articles'] as $tm) { if ($tm['id'] == $art->data['nr']) { $totalInBasket = $totalInBasket + $tm['ArtQuantity']; } } if (!$art->article_canbeordered(($pg->quantity+$totalInBasket))) { $errors .= diplayError($language->xml_array['LV_TEXT_MORE_THAN_IN_STOCK']); $valid = 0; } if ($valid==1) { $basket->add_to_cart($pg->artid,$pg->quantity,$currentLanguage,$lvShowPriceMode,'articles',$pg->values); } else { $_SESSION['errors']=$errors; $_SESSION['errorsbackurl']=$httpreferrer; lvredirect('index.php?action=errors&lang='.strtoupper($currentLanguage)); } if ($conf->data['LV_OPTIONS']['LV_SHOWORDERPAGEAFTERINBASKET_ENABLED']) { lvredirect('index.php?action=showbasket&lang='.strtoupper($currentLanguage)); } else { lvredirect($httpreferrer); } exit; } else { lvredirect('index.php?action=home&lang='.strtoupper($currentLanguage)); exit; } } break; case "add_to_cart_gift": if (CookiesEnabled($tpl)) { if ($pg->exists('aid')) { $errors = ''; $valid = 1; if (!lvfile_exists($conf->data['LV_OPTIONS']['LV_CNST_PATH_DATAARTS_DOT'].'/article_'.$pg->aid.'.xml')) { exit; } $basket=new Basket(); if (count($basket->data['gifts'])<$basket->gifts_quantity) { $res=$basket->get_summary($lvShowPriceMode,$currentLanguage); if (empty($res[1]['gift_articles'])||!in_array($pg->aid,$res[1]['gifts_ids'])) { $valid=0; $errors.= diplayError('no such gift found'); } } else { $valid=0; $errors.= diplayError('you cannot add more gifts'); } if ($valid==1) { $basket->add_to_cart($pg->aid,1,$currentLanguage,$lvShowPriceMode,'gifts'); } else { $tpl->assign('errors',$errors); $tpl->assign('layout_include','page.errors.html'); $tpl->display('layout.html'); exit; } } lvredirect($httpreferrer); } break; case "remove_from_cart": if ($pg->exists('cartkey')) { $basket=new Basket(); $basket->removeart_from_cart_bycartid($pg->cartkey); } lvredirect($httpreferrer); break; case "remove_from_cart_gift": if ($pg->exists('artid')) { $basket=new Basket(); if ($basket->find_in_cart($pg->artid,'gifts',Null,$currentLanguage)!=-1) { $basket->remove_from_cart($pg->artid,'all','gifts',Null,$currentLanguage); } } lvredirect($httpreferrer); break; case "member": addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); addCountriesListToTemplate($tpl); $marea = new member($tpl,$pg->lang); $marea->Display(); break; case "mupdate": addCountriesListToTemplate($tpl); $marea = new member($tpl,$pg->lang); $marea->Update(); break; case "login": if (CookiesEnabled($tpl)) { if (!$validator->ProceedAuth()) { lvredirect('index.php?action=home&passerror=1&lang='.strtoupper($currentLanguage)); } else { if ($pg->exists("oldurl")) { lvredirect($pg->oldurl); } else { lvredirect('index.php?action=home&lang='.strtoupper($currentLanguage)); } } } break; case "logout": $validator->Logout(); if ($pg->exists("oldurl")) { lvredirect($pg->oldurl); } else { lvredirect('index.php?action=home&lang='.strtoupper($currentLanguage)); } break; case "register": if (CookiesEnabled($tpl)) { addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); addCountriesListToTemplate($tpl); $marea = new member($tpl,$pg->lang); $marea->Register($currentLanguage); } break; case "add_to_wish_list": if (CookiesEnabled($tpl)) { if ($_SESSION['Alpha']==-1) { lvredirect('index.php?action=register&lang='.strtoupper($currentLanguage)); } $wish = new WishList(); try { $wish->add2list($pg->artid, $language); $tpl->assign('artid', $pg->artid); } catch (Exception $e) { } lvredirect($httpreferrer); } break; case "remove_from_wish_list": if ($_SESSION['Alpha']==-1) { lvredirect('index.php?action=register&lang='.strtoupper($currentLanguage)); } $wish = new WishList(); try { $wish->delete($pg->artid); $tpl->assign('artid', $pg->artid); } catch (Exception $e) { } lvredirect($httpreferrer); break; case "remove_from_pwish_list": if ($_SESSION['Alpha']==-1) { lvredirect('index.php?action=register&lang='.strtoupper($currentLanguage)); } try { $wish = new Pwishlist($pg->list_id, "public"); $wish->delete($pg->artid); $tpl->assign('artid', $pg->artid); } catch (Exception $e) { } lvredirect($httpreferrer); break; case "add_to_public_wishlist": if (CookiesEnabled($tpl)) { if ($_SESSION['Alpha']==-1) { lvredirect('index.php?action=register&lang='.strtoupper($currentLanguage)); } try{ $listid = $pg->listid; $artid = $pg->artid; } catch (Exception $e) { } if (isset($listid) & isset($artid)) { try { $wish = new Pwishlist($listid,"public"); $wish->add2list($artid, $language); } catch (Exception $e) { } lvredirect($httpreferrer); } } break; case "private_wishlist": try { if ($pg->send_email) { $wish = new WishList(); $wish->sendByMail($pg->allboxes, $tpl, $pg->email,$currentLanguage); } } catch (Exception $e) { } try { if ($pg->into_cart) { $wish = new WishList(); $wish->addtocart($pg->allboxes,$tpl,$language,$lvShowPriceMode); } } catch (Exception $e) { } try { if ($pg->into_public_whish_list) { $wishes = split(",",$pg->allboxes); unset($wishes[0]); try { $listid = $pg->listid; $wish = new Pwishlist($listid,"public"); foreach ($wishes as $key=>$value) { if (is_numeric($value)) { $wish->add2list($value, $language); } } } catch (Exception $e) { } lvredirect($httpreferrer); } } catch (Exception $e) { } break; case "wish_send_invitation": addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); try { $emails = $pg->emails; } catch (Exception $e) { unset($emails); } try { $listid = $pg->listid; $tpl->assign("listid",$listid); } catch (Exception $e) { } if (!$emails) { $refferer = $httpreferrer; if (!$refferer) { $refferer = "http://".$_SERVER['HTTP_HOST']; } $tpl->assign('backurl', $refferer); $tpl->assign('layout_include','page.invitation.html'); $tpl->display('layout.html'); exit; } else { $wish = new Pwishlist($listid,"public"); $wish->SendInvitation($emails,$tpl,$currentLanguage); exit; } break; case "public_wishlist": try { if ($pg->send_email) { $wish = new Pwishlist($pg->list_id, $tpl); $wish->sendByMail($pg->allboxes, $tpl, $pg->email, $currentLanguage); } } catch (Exception $e) { } try { if ($pg->into_cart) { $wish = new Pwishlist($pg->list_id, $tpl); $wish->addtocart($pg->allboxes,$tpl,$language,$lvShowPriceMode); } } catch (Exception $e) { } break; case "ff_tab": break; case "recover": $data = new POST(); $recovery_lang = $currentLanguage; addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); if ($data->exists('login')&&($data->exists('email'))) { $users = new Users(); if ($users->loginExists($data->login)) { $userdata = $users->GetUserData($data->login); if ($userdata['email'] == $data->email) { $password = substr(sha1(rand()),0,10); $tpl->assign('sent',1); $userdata['password'] = $password; $users->Update($userdata['login'],$userdata); $mail = file_get_contents("./lvconfig/recovery_letter_$recovery_lang"); foreach ($userdata as $key=>$value) { $mail = str_replace("[$key]",$value,$mail); } $shopowneremail = $conf->data['LV_OPTIONS']['SHOP_OWNER_EMAIL']; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text; charset=utf-8\n"; $headers .= "From: ".$shopowneremail."\n"; $headers .= "Reply-To: ".$shopowneremail."\n"; $headers .= "Return-Path: ".$shopowneremail."\n"; $thesubject = encode_iso88591(html_entity_decode($language->xml_array['LV_FIELD_PASSWORD'].' - '.$language->xml_array['LV_OPTIONS_SITETITLE'])); mail($userdata['email'],$thesubject,$mail,$headers); $users->Update($userdata['login'],$userdata); } else { $tpl->assign('error',$tpl->getTemplateVars('LV_INCORRECT_EMAIL')); } } } $tpl->assign('layout_include','page.recovery.html'); $tpl->display('layout.html'); break; case "advanced_search": if (file_exists("./lvconfig/manufacturers.xml")) { $manufacturers = new CustomXML("./lvconfig/manufacturers.xml"); $manufacturers_array = $manufacturers->xml['LV_MANUFACTURERS']['LV_MANUFACTURER']; $tpl->assign("manufacturers", $manufacturers_array); } if (file_exists("./lvconfig/groups.xml")) { $sys_groups = new CustomXML("./lvconfig/groups.xml"); $sys_groups_array = $sys_groups->xml['LV_GROUPS']['ITEM']; } $tpl->assign('num',sizeof($sys_groups->xml['LV_GROUPS']['ITEM'])-1); addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); $tpl->assign('layout_include','page.search.advanced.html'); $tpl->display('layout.html'); break; case "advanced_search_results": $groups_list=$group->getGroupsPlainList($currentLanguage); $res=array(); foreach ($groups_list as $v) { if ($pg->exists('group_'.$v['id'])) { $res[] = $v['id']; } } function tree_walker($arr,$id) { $arr_tmp=array_keys($arr,$id); $res=$id; foreach ($arr_tmp as $v) { $res.=','.tree_walker($arr,$v); } return $res; } $groups_structure=$group->get_groups_structure(); if ($pg->exists('inc_subcat') && ($pg->inc_subcat==1 || $pg->inc_subcat=="on") && !empty($res)) { $groups_list=''; foreach ($res as $v) { $groups_list.=tree_walker($groups_structure,$v).','; } $groups_list=substr($groups_list,0,-1); if (empty($groups_list)) { $groups_list=implode(',',array_keys($groups_structure)); } } else { if (!empty($res)) { $groups_list=implode(',',$res); } else { $groups_list=implode(',',array_keys($groups_structure)); } } $advanced['categories']=$groups_list; $pg->exists('price_from') && $pg->price_from != ''?$advanced['price']=1:""; $pg->exists('price_to') && $pg->price_to != ""?$advanced['price']=1:""; try { $pg->exists('price_from') && $pg->price_from != ''?$advanced['from_price']=$pg->price_from:""; } catch (Exception $e) { echo $e->__toString(); } try { $pg->exists('price_to') && $pg->price_to != ""?$advanced['to_price']=$pg->price_to:""; } catch (Exception $e) {} try { $advanced['manufacturer'] = $pg->manufactures; } catch (Exception $e) {} try { if ($pg->treelistvalue != "") { $advanced['treelistvalue'] = $pg->treelistvalue; } } catch (Exception $e) {} $search=new Search($currentLanguage); $res=$search->find($pg->keywords, $advanced); $tpl->assign('search_res',$res); addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); $tpl->assign('sortart',$_SESSION['sortart']); $tpl->assign('layout_include','page.search.html'); $tpl->display('layout.html'); break; case "search": if (!$pg->exists('srchval') || $pg->srchval=='') { $pg->srchval = '<--NoSearchValues-->'; } $search = new Search($currentLanguage); $search_string = strtolower($pg->srchval); $res = $search->find($search_string); $tpl->assign('search_res',$res); addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); $tpl->assign('sortart',$_SESSION['sortart']); $tpl->assign('layout_include','page.search.html'); $tpl->display('layout.html'); break; case "errors": if (isset($_SESSION['errors']) && $_SESSION['errors']!='') { addBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); $tpl->assign('errors',$_SESSION['errors']); $tpl->assign('backurl',(isset($_SESSION['errorsbackurl'])?$_SESSION['errorsbackurl']:$httpreferrer)); $tpl->assign('layout_include','page.errors.html'); $tpl->display('layout.html'); } else { lvredirect('index.php?action=home&lang='.strtoupper($currentLanguage)); } break; case "formmail": $formm = new FormM(); $formmAccept = $formm->acceptCaptchaForm($conf, $tpl); if ($formmAccept == "1") { $formm->sendFormmail($conf); $_SESSION['formvalues'] = null; $_SESSION['formsent'] = "1"; $_SESSION['errors'] = ""; } else { $_SESSION['formvalues'] = $formm->collectFormvalues(); $_SESSION['formsent'] = "0"; $_SESSION['errors'] = $formmAccept; } unset($formm); lvredirect('index.php?action='.$_POST['lv_action'].'&extra='.$_POST['lv_extra'].'&lang='.$conf->data['LV_OPTIONS']['LV_MAIN_LANGUAGE']); break; case "writeareview": $art = new Article($pg->aid); $article = $art->data; $curr_lang='lang_'.$currentLanguage; $article['descriptionandmeasure']=$article['descriptionandmeasure'][$curr_lang]; if (isset($article['specification'])) { $article['specification']=$article['specification'][$curr_lang]; } $tpl->assign('formvalues', $_SESSION['formvalues']); $tpl->assign('formsent', $_SESSION['formsent']); $tpl->assign('errors', $_SESSION['errors']); $_SESSION['formvalues'] = null; $_SESSION['formsent'] = ""; $_SESSION['errors'] = ""; $tpl->assign('article',$article); $tpl->assign('layout_include','page.writeareview.html'); $tpl->display('layout.html'); break; case "writeareview_post": $formm = new FormM(); $formmAccept = $formm->acceptCaptchaForm($conf, $tpl); if ($formmAccept == "1") { $review = new Review(); $review->postReview($pg->aid,$pg->rate,$pg->title,$pg->text,$pg->name,$pg->email,$currentLanguage); unset($review); $_SESSION['formvalues'] = null; $_SESSION['errors'] = ""; $_SESSION['formsent'] = "1"; } else { $_SESSION['formvalues'] = $formm->collectFormvalues(); $_SESSION['formsent'] = "0"; $_SESSION['errors'] = $formmAccept; } unset($formm); lvredirect('index.php?action=writeareview&lang='.$conf->data['LV_OPTIONS']['LV_MAIN_LANGUAGE'].'&aid='.$pg->aid); break; case "sort_art": $_SESSION['sortart'] = $pg->sorting; if (($_SESSION['sortart']=='') || ($_SESSION['sortart']==0)) { $_SESSION['sortart'] = "1"; } lvredirect($httpreferrer); break; case "artldisplay": $_SESSION['artldisplay'] = $pg->display; if ($_SESSION['artldisplay']=='') { $_SESSION['artldisplay'] = "0"; } lvredirect($httpreferrer); break; default: if ($conf->data['LV_OPTIONS']['LV_LANGUAGE_SELECTION_PAGE']) { $tpl->display('index.html'); } else { lvredirect('index.php?action=home&lang='.$conf->data['LV_OPTIONS']['LV_MAIN_LANGUAGE']); } break; } } ?>