data['LV_OPTIONS']['LV_SHOWPRICE_MODE']; $c = new CustomXML("lvconfig/options.xml"); $text = new CustomXML("lvconfig/options.xml"); /* device */ $deviceMustbeset = false; if (isset($conf->data['LV_OPTIONS']['LV_MOBILE_ENABLED']) && ($conf->data['LV_OPTIONS']['LV_MOBILE_ENABLED']==1)) { if ($pg->exists('device')) { $_SESSION['lv_device'] = $pg->device; } elseif (!isset($_SESSION['lv_device'])) { if (($pg->exists('device')) && ($pg->device == 'mob')) {$_SESSION['lv_device']='mob';} elseif (!$pg->exists('devicew')) {$deviceMustbeset = true;} else {if ($pg->devicew == 1) {$_SESSION['lv_device']='mob';} else {$_SESSION['lv_device']='desk';}} } } $tpl = new Template($_SESSION['lv_device'] == 'mob'); $tpl->assign('LV_DEVICE',$_SESSION['lv_device']); if ($pg->exists('max')) {exit;} if ($pg->exists("action")) { $action = $pg->action; } else { $action = ""; } $dir=dirname($_SERVER['PHP_SELF']); $httpreferrer = $_SERVER['HTTP_REFERER']; $fullhttps = $conf->data['LV_OPTIONS']['LV_ORDER_SSL_FULL'];; if (($fullhttps!=1) && ($action!="order") && isset($httpreferrer) && (strpos($httpreferrer,'ttps://')==1)) { /* if entering a nonsecured page with https redirect to http */ $thelocation = 'http://'.$_SERVER['HTTP_HOST']; if ($dir=='/'||$dir=='\\') { $thelocation.='/'; } else { if (strpos($dir,'\\')==false) { $dir=str_replace('\\','/',$dir); } $thelocation.=$dir.'/'; } $pgstring = ''; foreach ($pg->values as $k=>$v) { if ($pgstring != '') { $pgstring .= '&'; } $pgstring .= $k.'='.$v; } $thelocation.='index.php?'.$pgstring; header('location: '.$thelocation); } else { /* SSL Secured or not */ if (($fullhttps==1) || (($action=="order") && isset($conf->data['LV_OPTIONS']['LV_ORDER_SSL']) && ($conf->data['LV_OPTIONS']['LV_ORDER_SSL']==1))) { $shop_root_dir='https://'.$_SERVER['HTTP_HOST']; } else { $shop_root_dir='http://'.$_SERVER['HTTP_HOST']; } if (strpos($shop_root_dir,'https://')==true) { if (isset($conf->data['LV_OPTIONS']['LV_ORDER_SSL_NO_WWW']) && ($conf->data['LV_OPTIONS']['LV_ORDER_SSL_NO_WWW']==1)) { $shop_root_dir=str_replace('//www.','//',$shop_root_dir); } } /* *** */ if ($dir=='/'||$dir=='\\') { $shop_root_dir.='/'; } else { if (strpos($dir,'\\')==false) { $dir=str_replace('\\','/',$dir); } $shop_root_dir.=$dir.'/'; } $_SESSION['http_pref'] = $shop_root_dir; $tpl->assign('http_pref',$shop_root_dir); $_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)); /* Set VAT */ 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) { // } function BuildSearchIndex($showHomePage = False,$functionLanguage) { $index_arr = array( array('directory'=>'data/articles', 'files_ext'=>array('xml'), 'tags'=>array('LV_ARTICLES_DESCRIPTION','LV_ARTICLES_DESCRIPTIONANDMEASURE','LV_ARTICLES_SPECIFICATION','LV_ARTICLES_ARTICLECODE','LV_ARTICLES_ARTICLECODE2','LV_ARTICLES_SHORTMEMO','LV_ARTICLES_LONGMEMO','LV_ARTICLES_ARTICLECODE2'), 'url'=>array( 'action'=>'article', 'aid'=>'filename "/article_(\d+).xml/i"'), 'name'=>'LV_ARTICLES_DESCRIPTIONANDMEASURE', 'languages'=>array(), 'additional'=>array( 'price'=>'content "/(.+)<\/LV_ARTICLES_PRICE_EXVAT>/iU"', 'vat'=>'content "/(.+)<\/LV_ARTICLES_VAT>/iU"', 'manufacturer'=>'content "/(.+)<\/LV_ARTICLES_MANUFACTURER>/iU"', 'categories'=>'content "/(.+)<\/LV_ARTICLES_GROUP>/isU"', 'variantcats'=>'content "/(.+)<\/LV_ARTICLES_VARIANTPARENTSGROUP>/isU"') ), array('directory'=>'data/extrapages', 'files_ext'=>array('xml'), 'tags'=>array('LV_TITLE','LV_BODY'), 'url'=>array( 'action'=>'extra', 'extra'=>'filename "/(.+).xml/i"'), 'name'=>'LV_TITLE', 'languages'=>array() ) ); $clear_arr = array( 0=>array('dir'=>'./data/articles', 'languages'=>array()), 1=>array('dir'=>'./data/extrapages', 'languages'=>array()) ); $lang=$functionLanguage->getLanguageList(); foreach ($lang as $v) { $index_arr[0]['languages'][$v['code']]='LV_ARTICLES_LANG_'.strtoupper($v['code']); $index_arr[1]['languages'][$v['code']]='LV_'.strtoupper($v['code']); $clear_arr[0]['languages'][$v['code']]=$v['code']; $clear_arr[1]['languages'][$v['code']]=$v['code']; } try { $q=new Search(); $q->clear_index($clear_arr); $q->make_index($index_arr); } catch (Exception $e) { echo $e->__toString(); } if ($showHomePage) { header('location: index.php?action=home&lang='.strtoupper($functionLanguage->getCurrentLanguage())); } } function AddBasketToTemplate(&$loctpl, $currentLanguage, $lvShowPriceMode) { if (isset($_SESSION)) { $basket=new Basket(); $basket_summary=$basket->get_summary_small($currentLanguage, $lvShowPriceMode); $loctpl->assign('basket_summary',(isset($basket_summary[0]) ? $basket_summary[0] : NULL)); $loctpl->assign('basket_summary_addit',(isset($basket_summary[1]) ? $basket_summary[1] : NULL)); } } 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); // get group level id $group->level1 = -1; $group->level2 = -1; $group->level3 = -1; if ($group->current['LV_ID'] >= 20000000) { foreach ($group->fullstruct as $v) { if ($v['LV_ID'] == $group->current['LV_PARENT_ID']) { $group->level1 = $v['LV_PARENT_ID']; break; } } $group->level2 = $group->current['LV_PARENT_ID']; $group->level3 = $group->current['LV_ID']; } elseif ($group->current['LV_ID'] >= 10000000) { $group->level1 = $group->current['LV_PARENT_ID']; $group->level2 = $group->current['LV_ID']; } elseif ($group->current['LV_ID'] > 0) { $group->level1 = $group->current['LV_ID']; } $tpl->assign('LV_GROUP_LEVEL1',$group->level1); $tpl->assign('LV_GROUP_LEVEL2',$group->level2); $tpl->assign('LV_GROUP_LEVEL3',$group->level3); $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); //affilates system 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->get_template_vars('LV_LOGIN_ERROR')); } if (($member_mode == "Necessary") && ($action != "login") && ($tpl->get_template_vars('username') == "")) { $tpl->assign('LV_SHOPPINGCART_ENABLED',"0"); $tpl->assign('LV_ATTPROMOARTICLES_ENABLED',"0"); if ($member_showarticles != 1) { // if login is necessary, user isn't logged in and articles may not be shown to "un"logged users then show home page if (($action != "extra") && ($action != "home") && ($action != "formmail")) { $action = "home"; } } else { // if login is necessary, user isn't logged in and articles may be shown to "un"logged users then hide prices $tpl->assign('member_showprices',"0"); } } else { $tpl->assign('LV_ATTPROMOARTICLES_ENABLED',"1"); } // if url is called without details -> Show home page if (($action == "") && ($conf->data['LV_OPTIONS']['LV_LANGUAGE_SELECTION_PAGE'] == 0)) { $action = "home"; } //set base metatags $tpl->_tpl_vars['LV_METATAG'] = ''. "\n"; $tpl->_tpl_vars['LV_METATAG'] .= ''. "\n"; $tpl->_tpl_vars['LV_METATAG'] .= ''. "\n"; $tpl->_tpl_vars['LV_METATAG'] .= ''. "\n"; if ($_SESSION['lv_device']=='mob') { $tpl->_tpl_vars['LV_METATAG'] .= ''. "\n"; } if (($deviceMustbeset) && ($action != 'order')) { $pgstring = ''; foreach ($pg->values as $k=>$v) { if ($pgstring != '') { $pgstring .= '&'; } $pgstring .= $k.'='.$v; } $tpl->_tpl_vars['LV_METATAG'] .= ''; } $tpl->assign('action',$action); $tpl->_tpl_vars['LV_OPTIONS_SITETITLE'] = $tpl->_tpl_vars['LV_OPTIONS_SEARCHROBOT_TITLE']; 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 from created bij the offline back-office. if (!file_exists('sitemap.xml')) { $sitemap = new Genmap($language); } try{ // Article attention block $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(); } $tpl->_tpl_vars['LV_METATAG'] .= $language->xml_array['LV_META_TAGS']; $tpl->_tpl_vars['LV_METATAG'] = AddCanonicalTag($tpl->_tpl_vars['LV_METATAG'], $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); //Lightbox 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; } // Bottom scripts if (!isset($article['bottom_scripts'])) { $article['bottom_scripts'] = ''; } // Variants 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['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]['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'); } // Reviews 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)); } } $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); // Set meta tags $art->get_another_product($pg->aid); $tpl->_tpl_vars['LV_OPTIONS_SITETITLE'] = $art->xml['Logivert']['LV_META_TITLE']['LV_'.strtoupper($currentLanguage)]; $tpl->_tpl_vars['LV_METATAG'] .= $art->xml['Logivert']['LV_META_TAGS']['LV_'.strtoupper($currentLanguage)]; $tpl->_tpl_vars['LV_METATAG'] = AddCanonicalTag($tpl->_tpl_vars['LV_METATAG'], $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) { //print $e->__toString(); header('location: 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); // Set meta tags $tpl->_tpl_vars['LV_OPTIONS_SITETITLE'] = $extra->xml['LV_EXTRAPAGE']['LV_TITLE']['LV_'.strtoupper($currentLanguage)]; if (isset($extra->xml['LV_EXTRAPAGE']['LV_META_TAGS']) && isset($extra->xml['LV_EXTRAPAGE']['LV_META_TAGS']['LV_'.strtoupper($currentLanguage)])) { $tpl->_tpl_vars['LV_METATAG'] .= $extra->xml['LV_EXTRAPAGE']['LV_META_TAGS']['LV_'.strtoupper($currentLanguage)]; } $tpl->_tpl_vars['LV_METATAG'] = AddCanonicalTag($tpl->_tpl_vars['LV_METATAG'], $shop_root_dir, $action, $pg->extra, '', $currentLanguage); $tpl->_tpl_vars['formvalues'] = $_SESSION['formvalues']; $tpl->_tpl_vars['formsent'] = $_SESSION['formsent']; $tpl->_tpl_vars['errors'] = $_SESSION['errors']; $_SESSION['formvalues'] = null; $_SESSION['formsent'] = ""; $_SESSION['errors'] = ""; $tpl->assign('layout_include','page.extra.html'); $tpl->display('layout.html'); } catch (Exception $e) { //echo "Failed to assign $pg->extra probably because of: '$e->getMessage()'"; header('location: index.php?action=home&lang='.strtoupper($currentLanguage)); } break; case "page": if (isset($group->current)) { AddBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); if ($pg->exists('page')) { $page = $pg->page; } else { $page = 0; } $tpl->assign('current_page',$page); $art = new Articles(); $first = $page * $conf->data['LV_OPTIONS']['LV_ARTICLES_PER_PAGE']; $resource = $art->Select(('limit '.$first.','.$conf->data['LV_OPTIONS']['LV_ARTICLES_PER_PAGE']),$group_id); $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 { // $log->FullDump("LV_PERCENTAGE in vatitems.xml not set"); } } else { // $log->FullDump("Vat item number not exists"); } $a['vat'] = $real_vat; $a['availability']['availability_text'] = $a['availability'][$curr_lang]['availability_text']; $articles[]=$a; } $art->Free($resource); // Set meta tags $tpl->_tpl_vars['LV_OPTIONS_SITETITLE'] = $group->current['LV_GROUP_NAME']; $tpl->_tpl_vars['LV_METATAG'] .= $group->current['LV_METATAG']['LV_'.strtoupper($currentLanguage)]; $tpl->_tpl_vars['LV_METATAG'] = AddCanonicalTag($tpl->_tpl_vars['LV_METATAG'], $shop_root_dir, $action, $pg->group_id, $group->current['LV_GROUP_URLITEM'], $currentLanguage); $tpl->assign('articles',$articles); $tpl->assign('stock',$stock); $tpl->assign('layout_include','page.artlist.html'); $tpl->display('layout.html'); } else { header('location: 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); // collect manufacturers and quantities of this order foreach ($basket->data['articles'] as $tm) { 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']; // Check the manufacturer quantities of this order with the minimums foreach ($OrderedNumberManuf as $ONMkey => $ONMvalue) { 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'].dirname($_SERVER['PHP_SELF']); $_SESSION['http_document_root']='http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']); $action_url='https://'.$_SERVER['HTTP_HOST'].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->_tpl_vars['LV_METATAG'] = AddCanonicalTag($tpl->_tpl_vars['LV_METATAG'], $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)) { header('location: index.php?action=showbasket&lang='.strtoupper($currentLanguage)); exit; } } 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->_tpl_vars['LV_METATAG'] = AddCanonicalTag($tpl->_tpl_vars['LV_METATAG'], $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']); } $step_data = $order->get_data_for_step1(); $country=$step_data['country']; $tpl->assign('step_data',$step_data); $tpl->assign('country',$country); // load ways of divery, payment methods and countries $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'])) { //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'])) && ($v['LV_MAXORDER'] > 0) && ((round($v['LV_MINORDER'],2) > round($basket->data['additional']['basket_total_price_exvat'],2)) || (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_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"]; } } asort($paymethods_temp); $countries_list[$country]['LV_PAYMETHODITEMS']['LV_ITEMNUMBER']=array_keys($paymethods_temp); 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); $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'])) { header('location: index.php?action=showbasket&lang='.strtoupper($currentLanguage)); exit; } $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) { header('Location: index.php?action=order&step=1&error=1&lang='.strtoupper($currentLanguage)); exit; } 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'])) { header('location: index.php?action=showbasket&lang='.strtoupper($currentLanguage)); exit; } $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) { header('Location: index.php?action=order&step=2&error=1&lang='.strtoupper($currentLanguage)); exit; } $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'])) { header('location: index.php?action=showbasket&lang='.strtoupper($currentLanguage)); exit; } $order = unserialize($_SESSION['order_object']); $paysystem_form = $order->step3($tpl, $order, $status, $paymentid); if (!is_string($status) && ($status == 0)) { $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->get_template_vars('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); // Empty cart and eventualy lower stock if (isset($_SESSION['useStock']) && ($_SESSION['useStock'] > 0)) { $basket->clear_cart('all', True, True); } else { $basket->clear_cart('all', False); } unset($order_curr_lang); $tpl->assign('layout_include','page.cart_step4.html'); $tpl->display('layout.html'); } else { header('Location: 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); } header('location: index.php?action=showbasket&lang='.strtoupper($currentLanguage)); exit; break; case "start_with_empty_cart": $basket = new Basket(); $basket->clear_cart('all', False); header("Location: 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']); } header('location: index.php?action=showbasket&lang='.strtoupper($currentLanguage)); exit; } break; case "add_to_cart": if (CookiesEnabled($tpl)) { if ($pg->exists('artid') && $pg->exists('quantity')) { $errors=''; $valid=1; if (file_exists('./data/articles/article_'.$pg->artid.'.xml')) { $art=new Article($pg->artid); } else { header('location: index.php?action=home&lang='.strtoupper($currentLanguage)); exit; } 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['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 ($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; header('location: index.php?action=errors&lang='.strtoupper($currentLanguage)); exit; } if ($conf->data['LV_OPTIONS']['LV_SHOWORDERPAGEAFTERINBASKET_ENABLED']) { header('location: index.php?action=showbasket&lang='.strtoupper($currentLanguage)); } else { header('location: '.$httpreferrer.''); } exit; } else { header('location: 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 (!file_exists('./data/articles/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; } } header('location: '.$httpreferrer.''); } break; case "remove_from_cart": if ($pg->exists('artid')) { $basket=new Basket(); if ($pg->exists('additional')) { if ($basket->find_in_cart($pg->artid,'articles',$pg->additional, $currentLanguage)!=-1) { $basket->remove_from_cart($pg->artid,'all','articles',$pg->additional,$currentLanguage); } } else { if ($basket->find_in_cart($pg->artid,'articles',Null,$currentLanguage)!=-1) { $basket->remove_from_cart($pg->artid,'all','articles',Null,$currentLanguage); } } } header('location: '.$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); } } header('location: '.$httpreferrer.''); break; case "member": AddBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); $marea = new member($tpl,$pg->lang); $marea->Display(); break; case "mupdate": $marea = new member($tpl,$pg->lang); $marea->Update(); break; case "login": if (CookiesEnabled($tpl)) { if (!$validator->ProceedAuth()) { header("Location: index.php?action=home&passerror=1&lang=".strtoupper($currentLanguage)); } else { header("Location: index.php?action=home&lang=".strtoupper($currentLanguage)); } } break; case "logout": $validator->Logout(); header("Location: index.php?action=home&lang=".strtoupper($currentLanguage)); break; case "register": if (CookiesEnabled($tpl)) { AddBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); $marea = new member($tpl,$pg->lang); $marea->Register($currentLanguage); } break; case "add_to_wish_list": if (CookiesEnabled($tpl)) { if ($_SESSION['Alpha']==-1) { header('location: index.php?action=register&lang='.strtoupper($currentLanguage)); exit; } $wish = new WishList(); try { $wish->add2list($pg->artid, $language); $tpl->assign('artid', $pg->artid); } catch (Exception $e) { // $log->FullDump($e->getMessage()); } header('location: '.$httpreferrer.''); } break; case "remove_from_wish_list": if ($_SESSION['Alpha']==-1) { header('location: index.php?action=register&lang='.strtoupper($currentLanguage)); exit; } $wish = new WishList(); try { $wish->delete($pg->artid); $tpl->assign('artid', $pg->artid); } catch (Exception $e) { // $log->FullDump($e->getMessage()); } header('location: '.$httpreferrer.''); break; case "remove_from_pwish_list": if ($_SESSION['Alpha']==-1) { header('location: index.php?action=register&lang='.strtoupper($currentLanguage)); exit; } try { $wish = new Pwishlist($pg->list_id, "public"); $wish->delete($pg->artid); $tpl->assign('artid', $pg->artid); } catch (Exception $e) { // $log->FullDump($e->getMessage()); } header('location: '.$httpreferrer.''); break; case "add_to_public_wishlist": if (CookiesEnabled($tpl)) { if ($_SESSION['Alpha']==-1) { header('location: index.php?action=register&lang='.strtoupper($currentLanguage)); exit; } try{ $listid = $pg->listid; $artid = $pg->artid; } catch (Exception $e) { // $log->FullDump($e->getMessage()); } if (isset($listid) & isset($artid)) { try { $wish = new Pwishlist($listid,"public"); $wish->add2list($artid, $language); } catch (Exception $e) { // $log->FullDump($e->getMessage()); } header('location: '.$httpreferrer.''); } } break; case "private_wishlist": try{ if ($pg->send_email) { $wish = new WishList(); $wish->sendByMail($pg->allboxes, $tpl, $pg->email,$currentLanguage); } } catch (Exception $e) { // $log->FullDump($e->getMessage()); } try { if ($pg->into_cart) { $wish = new WishList(); $wish->addtocart($pg->allboxes,$tpl,$language,$lvShowPriceMode); } } catch (Exception $e) { // $log->FullDump($e->getMessage()); } 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) { // $log->FullDump($e->getMessage()); } header('location: '.$httpreferrer.''); } } catch (Exception $e) { // $log->FullDump($e->getMessage()); } break; case "wish_send_invitation": AddBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); try { $emails = $pg->emails; } catch (Exception $e) { unset($emails); // $log->FullDump($e->getMessage()); } try { $listid = $pg->listid; $tpl->assign("listid",$listid); } catch (Exception $e) { // $log->FullDump($e->getMessage()); } 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) { // $log->FullDump($e->getMessage()); } try { if ($pg->into_cart) { $wish = new Pwishlist($pg->list_id, $tpl); $wish->addtocart($pg->allboxes,$tpl,$language,$lvShowPriceMode); } } catch (Exception $e) { // $log->FullDump($e->getMessage()); } 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->get_template_vars('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); if (empty($search->indexes)) { BuildSearchIndex(False, $language); unset($search); $search = new Search($currentLanguage); } $res=$search->find($pg->keywords, $advanced); $tpl->assign('search_res',$res); AddBasketToTemplate($tpl, $currentLanguage, $lvShowPriceMode); $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); if (empty($search->indexes)) { BuildSearchIndex(False, $language); unset($search); $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('layout_include','page.search.html'); $tpl->display('layout.html'); break; case "rebuild_search_indexes": BuildSearchIndex(True, $language); break; case "map_site": $sitemap = new Genmap(); break; case "rebuild_articles_indexes": $a=new Articles(); if (isset($conf->data['LV_OPTIONS']['LV_ARTICLES_ORDER_FIELD']) && isset($conf->data['LV_OPTIONS']['LV_ARTICLES_ORDER_FIELD_MODE'])) { $a->make_index('./data/articles/index.lst',$conf->data['LV_OPTIONS']['LV_ARTICLES_ORDER_FIELD'],$conf->data['LV_OPTIONS']['LV_ARTICLES_ORDER_FIELD_MODE']); } else { $a->make_index(); } break; case "change_order_field": if ($pg->exists('field') && $pg->exists('mode')) { $fields=array('LV_ARTICLES_DESCRIPTIONANDMEASURE','LV_ARTICLES_ARTICLECODE','LV_ARTICLES_PRICE_EXVAT','LV_ARTICLES_ORDER'); if (!in_array(strtoupper($pg->field),$fields)) { echo 'The field "'.$pg->field.'" is not enabled to ordering'; exit; } if ($pg->mode!='asc' && $pg->mode!='desc') { echo 'The mode must be "asc" or "desc"'; exit; } $a=new Articles(); $a->make_index('./data/articles/index.lst',$pg->field,$pg->mode); } break; case "rebuild_static_articles": 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 { header('location: 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); header("location: 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->_tpl_vars['formvalues'] = $_SESSION['formvalues']; $tpl->_tpl_vars['formsent'] = $_SESSION['formsent']; $tpl->_tpl_vars['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); header("location: index.php?action=writeareview&lang=".$conf->data['LV_OPTIONS']['LV_MAIN_LANGUAGE']."&aid=".$pg->aid); break; default: if ($conf->data['LV_OPTIONS']['LV_LANGUAGE_SELECTION_PAGE']) { $tpl->display('index.html'); } else { header("location: index.php?action=home&lang=".$conf->data['LV_OPTIONS']['LV_MAIN_LANGUAGE']); exit; } break; } } ?>