Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function createContent(){
- global $db;
- global $db2;
- global $contentAction;
- global $uri;
- global $gloablURL;
- global $XYU;
- global $pageDescription;
- global $pageKeyWords;
- global $pageTitle;
- global $tplService;
- global $tpl;
- global $lang;
- global $orderUrl;
- $orderBy= 'ORDER BY `ind` ASC';
- for($i=1;$i<count($uri);$i++)
- {
- if($uri[$i]=='asc')
- {
- $orderUrl='asc';
- $orderBy='ORDER BY `price` ASC';
- unset($uri[$i]);
- }
- else if($uri[$i]=='desc')
- {
- $orderUrl='desc';
- $orderBy='ORDER BY `price` DESC';
- unset($uri[$i]);
- }
- }
- if($lang=='/en')
- {
- $slogan='Your treasury';
- $metal = 'Metal';
- $wood = 'Wood';
- $stone = 'Stone';
- $glass = 'Glass';
- $other = 'Other';
- $cartTitle = 'The Loot';
- $welcomeHeader = '';
- $welcomeText = '<strong>Conquistador</strong>— it\'s your personal treasury. The shop offers original gifts and souvenirs, which are suitable for any celebration. All the items are high-quality handmade products, so your gift would always be unique and special.';
- $smContacts = 'Shop of unique gifts';
- $footerText = 'All materials copyright protected by copyright law and their complete or partial copying without permission is prohibited.';
- $copyright = 'Shop of unique gifts';
- $cabinet_auth = 'My account';
- $cabinet_noauth = 'Log in | Register';
- $emptyCategoryMessage = 'The category is being updated. Please visit this page later.';
- }
- else if($lang=='/ua')
- {
- $uotpl = 'Ua';
- $action_text = 'Акцii';
- $top_text = 'Топ';
- $slogan='Твоя скарбниця';
- $metal = 'Метал';
- $wood = 'Дерево';
- $stone = 'Камiнь';
- $glass = 'Скло';
- $other = 'Iнше';
- $cartTitle = 'Награбоване';
- $welcomeHeader = '';
- $welcomeText = '<strong>Конкiстадор</strong> – це Ваша скарбниця оригінальних, гідних предметів ручної роботи,
- створених з натуральних матеріалів. Ми безпосередньо співпрацюємо з майстрами з
- України і ближнього зарубіжжя, щоб докласти Вам дійсно унікальні подарунки найвищої якості.';
- $smContacts = 'Магазин унікальних подарунків';
- $footerText = 'Всі права на матеріали сайту захищені законом про авторське право та їх повне або часткове копіювання без дозволу заборонено.';
- $copyright = 'Магазин унікальних подарунків';
- $cabinet_auth = 'Мiй кабiнет';
- $cabinet_noauth = 'Увiйти | Реєстрацiя';
- $emptyCategoryMessage = 'Данний роздiл наповнюється. Будь ласка, заходьте пізніше.';
- }
- else
- {
- $uotpl = '';
- $action_text = 'Акции';
- $top_text = 'Топ';
- $slogan='Твоя сокровищница';
- $metal = 'Металл';
- $wood = 'Дерево';
- $stone = 'Камень';
- $glass = 'Стекло';
- $other = 'Разное';
- $cartTitle = 'Награбленное';
- $welcomeHeader = '';
- $welcomeText = '<strong>Конкистадор</strong> – это Ваша сокровищница оригинальных, достойных предметов ручной работы,
- созданных из натуральных материалов. Мы непосредственно сотрудничаем с мастерами из
- Украины и ближнего зарубежья, чтобы предложить Вам действительно уникальные подарки высочайшего качества.';
- $smContacts = 'Магазин уникальных подарков';
- $footerText = 'Все права на материалы сайта защищены законом об авторском праве и их полное или частичное копирование без разрешения запрещено.';
- $copyright = 'Магазин уникальных подарков';
- $cabinet_auth = 'Мой кабинет';
- $cabinet_noauth = 'Вход | Регистрация';
- $emptyCategoryMessage = 'Данный раздел в стадии наполнения. Зайдите, пожалуйста, позже.';
- }
- if (!empty($_SESSION['UID']))
- $tpl->set('#cabinet',null,array('cabinet'=>$cabinet_auth,'lang'=>$lang));
- else
- $tpl->set('#cabinet',null,array('cabinet'=>$cabinet_noauth,'lang'=>$lang));
- $tpl->set('#footerContent',null,array('text'=>$footerText,'copyright'=>$copyright));
- $tpl->set('#smContacts',null,array('smContacts'=>$smContacts));
- if($uri['1']!='shop')
- $tpl->set('#welcome',null,array('welcomeHeader'=>$welcomeHeader,'welcomeText'=>$welcomeText));
- else
- {
- $aforizm = $db->queryOneRecord("SELECT * FROM `aforizm` ORDER BY RAND() LIMIT 1");
- $tpl->set('#welcome','shop',array('welcomeText'=>$aforizm['text']));
- }
- $tpl->set('#cartTitle',null,array('cartTitle'=>$cartTitle));
- $baselang = substr($lang, '1');
- $baselang = '_'.$baselang;
- if($baselang!='_en' AND $baselang!='_ua') $baselang='';
- $tpl->set('#topMenu',null,array('lang'=>$lang,'slogan'=>$slogan,'wood'=>$wood,'metal'=>$metal,'stone'=>$stone,'glass'=>$glass,'other'=>$other));
- $inner = '';
- $metaArray = Array(
- 'title'=>'title',
- 'description'=>'description',
- 'keywords'=>'keywords'
- );
- $footer = createFooter();
- $UID = $_SESSION['UID'];
- if(!empty($_SESSION['UID'])){
- $U = $db->queryOneRecord("select * from `users` where `id`='{$_SESSION['UID']}' limit 1");
- }
- $EUR = $db->queryOneRecord("SELECT * FROM `sitedate` WHERE `id`='2'");
- $USD = $db->queryOneRecord("SELECT * FROM `sitedate` WHERE `id`='1'");
- $currency = $USD['value'];
- $uriEl = uriLastEl();
- if(!empty($contentAction) AND empty($uri['2'])){
- $metaData=$db->queryOneRecord("SELECT * FROM `meta` WHERE `module`='$contentAction'");
- $metaArray = Array(
- 'keywords' => $metaData['keywords'],
- 'description' => $metaData['description'],
- 'title' => $metaData['title']
- );
- }
- else if(!empty($contentAction) AND !empty($uri['2'])){
- $metaData=$db->queryOneRecord("SELECT * FROM `meta` WHERE `module`='".$uri['2']."'");
- $metaArray = Array(
- 'keywords' => $metaData['keywords'],
- 'description' => $metaData['description'],
- 'title' => $metaData['title']
- );
- }
- $contentTemplate = $contentAction;
- $contentTemplate=strtr($contentTemplate,
- array(
- "signin"=>"sign",
- "account"=>"sign",
- )
- );
- $tpl->set('#body',null,Array(
- 'wrapperClass'=>$contentTemplate
- ));
- $tpl->set('#content',$contentTemplate);
- $metaArray = Array(
- 'keywords' => $metaData['keywords'],
- 'description' => $metaData['description'],
- 'title' => $metaData['title']
- );
- if($uri[1]=='cart')
- {
- if($uri['2']=='finish')
- $metaArray = Array(
- 'keywords' => 'Заказ оформлен - интернет-магазин conquistador.com.ua',
- 'description' => 'Заказ оформлен - интернет-магазин conquistador.com.ua',
- 'title' => 'Заказ оформлен - интернет-магазин conquistador.com.ua',
- );
- if($uri['2']=='order')
- $metaArray = Array(
- 'keywords' => 'Оформление заказа - интернет-магазин conquistador.com.ua',
- 'description' => 'Оформление заказа - интернет-магазин conquistador.com.ua',
- 'title' => 'Оформление заказа - интернет-магазин conquistador.com.ua',
- );
- if($uri['2']=='order')
- $metaArray = Array(
- 'keywords' => 'Оформление заказа - интернет-магазин conquistador.com.ua',
- 'description' => 'Оформление заказа - интернет-магазин conquistador.com.ua',
- 'title' => 'Оформление заказа - интернет-магазин conquistador.com.ua',
- );
- }
- if($contentAction=="index"){
- $count=0;
- if(!$UID){
- $basCount = count($_SESSION['basket']);
- }else{
- $basItems = $db->queryAllRecords("select * from `basketitems` where `uid`='$UID'");
- $basCount = count($basItems);
- }
- if($basCount>1) $compresion = '<a href="/comparison/">Сравнить</a>';
- $items = $db->queryAllRecords("SELECT `items`.`id`,`items`.`actionprice` AS `price`,`items`.`url` AS `url`, `items`.`iid`,
- `brands`.`url` AS `brand`,`items`.`hit`,`items`.`new`,
- `sitedate`.`value`/`items`.`price` AS `price2`,`items`.`descriptor` AS `name`,`items`.`descriptor_en` AS `name_en`,
- `items`.`descriptor_ua` AS `name_ua`,`items`.`file2`,`items`.`prev-width`
- FROM `items`
- JOIN `partisions` AS `brands` ON `items`.`iid`=`brands`.`id`
- JOIN `sitedate` ON `sitedate`.`id`='1'
- WHERE `items`.`show`!='true' AND `items`.`action`='true' order by `items`.`iid` DESC LIMIT 5");
- for($i=0;$i<count($items);$i++){
- $items[$i]['lang'] = $lang;
- $tag = null;
- $test = checkInBasket($items[$i]['id']);
- $test = intval ($test);
- if (file_exists($_SERVER['DOCUMENT_ROOT'].'/items_img/'.$items[$i]['iid'].'/'.$items[$i]['id'].'/'.$items[$i]['url'].'-prev.jpg'))
- $items[$i]['file2']='/items_img/'.$items[$i]['iid'].'/'.$items[$i]['id'].'/'.$items[$i]['url'].'-prev.jpg';
- $classes = Array('toBaskcet','outFromBasket');
- $lableses = Array('Отложить','Убрать');
- $part = $db->queryOneRecord("SELECT `url` FROM `partisions` WHERE `id`=(
- SELECT `iid` FROM `partisions` WHERE `url`='{$items[$i]['brand']}')");
- if($part['url']!='')$items[$i]['part']=$part['url'];
- else $items[$i]['part']=$items[$i]['brand'];
- $class = $classes[$test];
- $items[$i]['name']=$items[$i]['name'.$baselang];
- $baskLable = $lableses[$test];
- $items[$i]['baskClass'] =$class;
- $items[$i]['baskLable'] =$baskLable;
- $curr1 = '€';
- $curr2 = '$';
- if($lang=='/en')
- {
- $items[$i]['price']=roundPrice('uah',$items[$i]['price'],$currency);
- $items[$i]['price2']=roundPrice('usd',$items[$i]['price'],$currency);
- $items[$i]['price']=roundPrice('eur',$items[$i]['price'],$EUR['value']);
- }
- else
- {
- $items[$i]['price']=roundPrice('uah',$items[$i]['price'],$currency);
- $items[$i]['price2']=roundPrice('usd',$items[$i]['price'],$currency);
- }
- if($items[$i]['price']==0){
- $items[$i]['price2'] = null;
- if($lang=='/en')
- $items[$i]['price'] = "no price";
- else
- $items[$i]['price'] = "Цена не указана";
- }
- else
- {
- if($lang=='/en')
- {
- $items[$i]['price']=$curr1.$items[$i]['price'];
- $items[$i]['price2']=$curr2.$items[$i]['price2'];
- }
- else
- {
- $items[$i]['price']=$items[$i]['price'].' грн';
- $items[$i]['price2']=$curr2.$items[$i]['price2'];
- }
- }
- if($items[$i]['new']) $tag .= "new ";
- if($items[$i]['hit']) $tag .= "hit ";
- $items[$i]['tag'] = $tag;
- }
- $tpl->set('.indexProduct',null, $items);
- $items = $db->queryAllRecords("SELECT `items`.`id`,`items`.`price` AS `price`,`items`.`url` AS `url`,`items`.`iid`,
- `brands`.`url` AS `brand`,`items`.`hit`,`items`.`new`,
- `sitedate`.`value`/`items`.`price` AS `price2`,`items`.`descriptor` AS `name`,`items`.`descriptor_en` AS `name_en`,
- `items`.`descriptor_ua` AS `name_ua`,`items`.`file2`,`items`.`prev-width`
- FROM `items`
- JOIN `partisions` AS `brands` ON `items`.`iid`=`brands`.`id`
- JOIN `sitedate` ON `sitedate`.`id`='1'
- WHERE `items`.`show`!='true' AND `items`.`hit`='true' order by `items`.`iid` DESC LIMIT 5"); //
- for($i=0;$i<count($items);$i++){
- $items[$i]['lang'] = $lang;
- $tag = null;
- $test = checkInBasket($items[$i]['id']);
- $test = intval ($test);
- if (file_exists($_SERVER['DOCUMENT_ROOT'].'/items_img/'.$items[$i]['iid'].'/'.$items[$i]['id'].'/'.$items[$i]['url'].'-prev.jpg'))
- $items[$i]['file2']='/items_img/'.$items[$i]['iid'].'/'.$items[$i]['id'].'/'.$items[$i]['url'].'-prev.jpg';
- $classes = Array('toBaskcet','outFromBasket');
- $lableses = Array('Отложить','Убрать');
- $part = $db->queryOneRecord("SELECT `url` FROM `partisions` WHERE `id`=(
- SELECT `iid` FROM `partisions` WHERE `url`='{$items[$i]['brand']}')");
- if($part['url']!='')$items[$i]['part']=$part['url'];
- else $items[$i]['part']=$items[$i]['brand'];
- $class = $classes[$test];
- $items[$i]['name']=$items[$i]['name'.$baselang];
- $baskLable = $lableses[$test];
- $items[$i]['baskClass'] =$class;
- $items[$i]['baskLable'] =$baskLable;
- $curr1 = '€';
- $curr2 = '$';
- if($lang=='/en')
- {
- $items[$i]['price']=roundPrice('uah',$items[$i]['price'],$currency);
- $items[$i]['price2']=roundPrice('usd',$items[$i]['price'],$currency);
- $items[$i]['price']=roundPrice('eur',$items[$i]['price'],$EUR['value']);
- }
- else
- {
- $items[$i]['price']=roundPrice('uah',$items[$i]['price'],$currency);
- $items[$i]['price2']=roundPrice('usd',$items[$i]['price'],$currency);
- }
- if($items[$i]['price']==0){
- $items[$i]['price2'] = null;
- if($lang=='/en')
- $items[$i]['price'] = "no price";
- else
- $items[$i]['price'] = "Цена не указана";
- }
- else
- {
- if($lang=='/en')
- {
- $items[$i]['price']=$curr1.$items[$i]['price'];
- $items[$i]['price2']=$curr2.$items[$i]['price2'];
- }
- else
- {
- $items[$i]['price']=$items[$i]['price'].' грн';
- $items[$i]['price2']=$curr2.$items[$i]['price2'];
- }
- }
- if($items[$i]['new']) $tag .= "new ";
- if($items[$i]['hit']) $tag .= "hit ";
- $items[$i]['tag'] = $tag;
- }
- $tpl->set('#mainAction','def',array('action'=>$action_text));
- $tpl->set('#mainTop','def',array('top'=>$top_text));
- $tpl->set('.indexTopProduct',null, $items);
- $tpl->set('#indexProductCart',null,array('incart'=>$basCount));
- }else if ($contentAction=="shop"){
- $tpl->set('#shopContent');
- if(!empty($uri['2']) AND empty($uri['3'])){
- $metaData = $db->queryOneRecord("SELECT `title`,`keywords`, `description` FROM `partisions` WHERE `url`='".$uri['2']."' LIMIT 1");
- }
- if(!empty($uri['3']) AND empty($uri['4'])){
- $metaData = $db->queryOneRecord("SELECT `title`,`keywords`, `description` FROM `partisions` WHERE `url`='".$uri['3']."' LIMIT 1");
- }
- if(!empty($uri['4'])){
- $metaData = $db->queryOneRecord("SELECT `title`,`keywords`, `description` FROM `items` WHERE `url`='".$uri['4']."' LIMIT 1");
- }
- $metaArray = Array(
- 'keywords' => $metaData['keywords'],
- 'description' => $metaData['description'],
- 'title' => $metaData['title']
- );
- $cat = null;
- $position = null;
- $items = Array();
- $allOk=true;
- $catalog = $db->queryAllRecords("select `name`,`type`,`url` from `partisions` where `iid`='0' order by `ind` DESC");
- $mainContainer = $tpl->set('#shopMainMenuContainer',null,null,true);
- $mainLisTpl = $tpl->set('#partitionList',null,null,true);
- $fly = Array();
- $catalogCount = 0;
- if(!empty($uri['4'])) $uriEl=$uri['3'];
- if(!empty($uri['2']) AND preg_match('/^page[0-9]{1,3}$/',$uri['3'])){
- $uriEl=$uri['2'];
- }
- else if(!empty($uri['2']) AND empty($uri['3'])){
- $uriEl=$uri['2'];
- }
- else if(!empty($uri['3']) AND !preg_match('/^page[0-9]{1,3}$/',$uri['3'])){
- $uriEl=$uri['3'];
- }
- else if(!empty($uri['3']) AND preg_match('/^page[0-9]{1,3}$/',$uri['3'])){
- $uriEl=$uri['2'];
- }
- else if(!empty($uri['3']) AND preg_match('/^page[0-9]{1,3}$/',$uri['4'])){
- $uriEl=$uri['3'];
- }
- $currentID=$db->queryOneRecord("SELECT * FROM `partisions` WHERE `url`='{$uriEl}'");
- $catTitle = $currentID['name'.$baselang];
- $currentIID = $currentID['iid'];
- $currentID=$currentID['id'];
- $tpl->set('#catTitle',null,array('category-Title'=>$catTitle));
- for($i=0;$i<count($catalog);$i++){
- if($catalog[$i]['url']==$uri[2]){
- $catalog[$i]['class']='active';
- if(!empty($uri[3]))$catalog[$i]['class']='active Lnk';
- }else $catalog[$i]['class']='inline';
- $catalog[$i]['lang']=$lang;
- if($catalog[$i]['type']){
- $tmpVar = null;
- foreach($fly as $f){
- $tmpVar .= $tpl->replace($mainLisTpl,$f);
- }
- $catalogueMain .= $tpl->replace($mainContainer,Array('content'=>$tmpVar));
- $fly = Array();
- $catalogCount = 0;
- }else{
- $fly[] = $catalog[$i];
- }
- $catalogCount++;
- }
- $mainContainer = $tpl->set('#shopMainMenuHolder',null,Array('content'=>$catalogueMain));
- $uriLE = uriLastEl();
- if(!empty($uri['2'])){
- if(!empty($uri['2']) AND preg_match('/^page[0-9]{1,3}$/',$uri['3'])){
- $uriLe=$uri['2'];
- }
- else if(!empty($uri['2']) AND empty($uri['3'])){
- $uriLe=$uri['2'];
- }
- else if(!empty($uri['3']) AND !preg_match('/^page[0-9]{1,3}$/',$uri['3'])){
- $uriLe=$uri['3'];
- }
- else if(!empty($uri['3']) AND preg_match('/^page[0-9]{1,3}$/',$uri['4'])){
- $uriLe=$uri['3'];
- }
- $currCAT = $db->queryOneRecord("SELECT * FROM `partisions` WHERE `url`='{$uriLe}'");
- $treeArray = treee($currentID);
- $treeArrayLength = count($treeArray);
- if($treeArrayLength>1){
- $pathLi = $tpl->set("#pathFinderLi",null,null,true);
- $pathInsideUl = $tpl->set("#pathFinderInsideContainer",null,null,true);
- $pathinsideLi = $tpl->set("#pathFinderInsideLi",null,null,true);
- $pathinsideWidthUl = $tpl->set("#pathFinderInsideUl",null,null,true);
- $pathinsideLiActive = $tpl->set("#pathFinderInsideLiActive",null,null,true);
- for($i=$treeArrayLength-1;$i>-1;$i--){
- $item = &$treeArray[$i];
- $item['part']=$uri[2];
- $itemList = null;
- if($item['part']!=$item['url'])
- $item['part']= "{$item['part']}/{$item['url']}";
- foreach($item['items'] as &$it){
- $it['part']=$uri[2];
- if($it['active'])
- $itemList.=$tpl->replace($pathinsideLi,$it);
- else
- $itemList.=$tpl->replace($pathinsideLiActive,$it);
- }
- $item['inside']=$tpl->replace($pathInsideUl,Array('content'=>$itemList));
- $item['lang']=$lang;
- $breadcrumbs.=$tpl->replace($pathLi,$item);
- }
- //$tpl->set("#pathFinder",null,Array('content'=>$breadcrumbs));
- }
- }
- //----------Если мы в корне каталога-------------//
- if(empty($uri['2'])){
- $catalogueTplId = 'root';
- header('Location:/');
- }else{
- $catalogueTplId = 'items';
- }
- //----------Если мы в /каталог/категория-------------//
- if(empty($uri['3']) AND !empty($uri['2'])){
- $currentID=$db->queryOneRecord("SELECT * FROM `partisions` WHERE `url`='{$uri['2']}' AND `iid`='0'");
- $currentID=$currentID['id'];
- if(empty($childNodes))$partitionList = $db->queryAllRecords("SELECT * FROM `partisions` WHERE `iid`='{$currentID}'");
- else $partitionList=$childNodes;
- if(count($partitionList)>0){
- if(empty($XYU)){ parseChildEl(getChildElements($currentID));
- $XYU=substr($XYU,0,-1);
- }
- $items=$db->queryAllRecords("SELECT * FROM `items` WHERE `show`!='true' AND `iid` IN($XYU)
- $orderBy LIMIT 0,12");
- }
- else
- $items=$db->queryAllRecords("SELECT * FROM `items` WHERE `show`!='true' AND `iid` ='{$currentID}' $orderBy LIMIT 0,12");
- if (empty($items)) $emptyCategoryFlag = true;
- if($emptyCategoryFlag != true) $tpl->set('#sortBlock'.$orderUrl,'def',array('lang'=>$lang,'part'=>$uri['2'],'url'=>'','page'=>''));
- }
- //----------Если мы в /каталог/категория/страницаХ-------------//
- if(!empty($uri['3']) AND preg_match('/^page[0-9]{1,3}$/',$uri['3'])){
- $tpl->set('#sortBlock'.$orderUrl,'def',array('lang'=>$lang,'part'=>$uri['2'],'url'=>'','page'=>'/'.$uri['3']));
- $currentID=$db->queryOneRecord("SELECT * FROM `partisions` WHERE `url`='{$uri['2']}' AND `iid`='0'");
- $currentID=$currentID['id'];
- preg_match('/[0-9]*$/',$uri['3'],$pageID);
- $limits=countLimits($pageID['0']);
- $partitionList = $db->queryAllRecords("SELECT * FROM `partisions` WHERE `iid`='{$currentID}'");
- if(count($partitionList)>0){
- if(empty($XYU)){parseChildEl(getChildElements($currentID));
- $XYU=substr($XYU,0,-1);
- }
- $items=$db->queryAllRecords("SELECT * FROM `items` WHERE `show`!='true' AND `iid` IN($XYU) $orderBy LIMIT {$limits['0']},{$limits['1']}");
- }
- else
- $items=$db->queryAllRecords("SELECT * FROM `items` WHERE `show`!='true' AND `iid` ='{$currentID}' $orderBy LIMIT {$limits['0']},{$limits['1']}");
- }
- //----------Если мы в /каталог/категория/подкатегория-------------//
- if(!empty($uri['3']) AND !preg_match('/^page[0-9]{1,3}$/',$uri['3']) AND empty($uri['4'])){
- $tpl->set('#sortBlock'.$orderUrl,'def',array('lang'=>$lang,'part'=>$uri['2'],'url'=>'/'.$uri['3'],'page'=>''));
- $currentID=$db->queryOneRecord("SELECT * FROM `partisions` WHERE `url`='{$uri['3']}'");
- $currentID=$currentID['id'];
- $partitionList = $db->queryAllRecords("SELECT * FROM `partisions` WHERE `iid`='{$currentID}'");
- if(count($partitionList)>0){
- if(empty($XYU)){parseChildEl(getChildElements($currentID));
- $XYU=substr($XYU,0,-1);
- }
- $items=$db->queryAllRecords("SELECT * FROM `items` WHERE `show`!='true' AND `iid` IN ($XYU) $orderBy LIMIT 0,12");
- }
- else
- $items=$db->queryAllRecords("SELECT * FROM `items` WHERE `show`!='true' AND `iid` = '$currentID' $orderBy LIMIT 0,12");
- //echo $currCAT['iid'];
- if($currCAT['iid']!='0')
- {
- $inonelevel = $db->queryAllRecords("SELECT * FROM `partisions` WHERE `iid`!={$currCAT['iid']} AND `name` LIKE '%{$currCAT['name']}%'");
- if(!empty($inonelevel))
- {
- $tpl->set('#iflinked');
- $tpl->set('.linkedMenuElement',null,$inonelevel);
- }
- }
- }
- //----------Если мы в /каталог/категория/подкатегория/страницаX-------------//
- if(!empty($uri['4']) AND preg_match('/^page[0-9]{1,3}$/',$uri['4'])){
- $tpl->set('#sortBlock'.$orderUrl,'def',array('lang'=>$lang,'part'=>$uri['2'],'url'=>'/'.$uri['3'],'page'=>'/'.$uri['4']));
- preg_match('/[0-9]*$/',$uri['4'],$pageID);
- $limits=countLimits($pageID['0']);
- $currentID=$db->queryOneRecord("SELECT * FROM `partisions` WHERE `url`='{$uri['3']}'");
- $currentID=$currentID['id'];
- $partitionList = $db->queryAllRecords("SELECT * FROM `partisions` WHERE `iid`='{$currentID}'");
- if(count($partitionList)>0){
- if(empty($XYU)){ parseChildEl(getChildElements($currentID));
- $XYU=substr($XYU,0,-1);
- }
- $items=$db->queryAllRecords("SELECT * FROM `items` WHERE `show`!='true' AND `iid` IN ($XYU) $orderBy LIMIT {$limits['0']},{$limits['1']}");
- }
- else
- $items=$db->queryAllRecords("SELECT * FROM `items` WHERE `show`!='true' AND `iid` = '$currentID' $orderBy LIMIT {$limits['0']},{$limits['1']}");
- }
- if(!empty($items)){
- foreach($items as $itms){
- $pqr.=$itms['iid'].",";
- }
- $qstr=substr($pqr, 0, -1);
- if(!empty($items))$scts=$db->queryAllRecords("SELECT `url`,`id` FROM `partisions` WHERE `id` IN($qstr) LIMIT 0,12");
- $partUrls = Array();
- foreach($scts as $s)
- $partUrls[$s['id']]=$s['url'];
- foreach($items as &$itms){
- $itms['part'] = $uri[2];
- $itms['brand'] = $partUrls[$itms['iid']];
- }
- }
- $curr1 = '€';
- $curr2 = '$';
- for($i=0;$i<count($items);$i++){
- if($items[$i]['action']=='true') $items[$i]['price']=$items[$i]['actionprice'];
- $items[$i]['lang']=$lang;
- if (file_exists($_SERVER['DOCUMENT_ROOT'].'/items_img/'.$items[$i]['iid'].'/'.$items[$i]['id'].'/'.$items[$i]['url'].'-prev.jpg'))
- $items[$i]['file2']='/items_img/'.$items[$i]['iid'].'/'.$items[$i]['id'].'/'.$items[$i]['url'].'-prev.jpg';
- if($lang=='/en')
- {
- $baskClass = 'toBaskcet';
- $baskLable = 'Buy it!';
- }
- if($lang=='/ua')
- {
- $baskClass = 'toBaskcet';
- $baskLable = 'Купити!';
- }
- else if($lang!='/en' AND $lang!='/ua')
- {
- $baskClass = 'toBaskcet';
- $baskLable = 'Купить!';
- }
- if($lang=='/en')
- {
- $items[$i]['price']=roundPrice('uah',$items[$i]['price'],$currency);
- $items[$i]['price2']=roundPrice('usd',$items[$i]['price'],$currency);
- $items[$i]['price']=roundPrice('eur',$items[$i]['price'],$EUR['value']);
- }
- else
- {
- $items[$i]['price']=roundPrice('uah',$items[$i]['price'],$currency);
- $items[$i]['price2']=roundPrice('usd',$items[$i]['price'],$currency);
- }
- if($items[$i]['price']==0){
- $items[$i]['price2'] = null;
- if($lang=='/en')
- $items[$i]['price'] = "no price";
- else
- $items[$i]['price'] = "Цена не указана";
- }
- else
- {
- if($lang=='/en')
- {
- $items[$i]['price']=$curr1.$items[$i]['price'];
- $items[$i]['price2']=$curr2.$items[$i]['price2'];
- }
- else
- {
- $items[$i]['price']=$items[$i]['price'].' грн';
- $items[$i]['price2']=$curr2.$items[$i]['price2'];
- }
- }
- if(!empty($items[$i]['file2']) AND file_exists("gallery/photo/{$items[$i]['file2']}"))
- $items[$i]['img'] = "/gallery/photo/{$items[$i]['file2']}";
- else
- $items[$i]['img'] = "/img/shop/nophoto.gif";
- if(checkInBasket($items[$i]['id'])){
- if($lang=='/en')
- {
- $baskClass = 'outFromBasket';
- $baskLable = 'Remove from cart';
- }
- if($lang=='/ua')
- {
- $baskClass = 'outFromBasket';
- $baskLable = 'Прибрати';
- }
- else if($lang!='/en' AND $lang!='/ua')
- {
- $baskClass = 'outFromBasket';
- $baskLable = 'Убрать';
- }
- }
- if($lang=='/en')
- $items[$i]['articleTitle']='Article: ';
- else
- $items[$i]['articleTitle']='Артикул: ';
- $items[$i]['name']=$items[$i]['name'.$baselang];
- $items[$i]['caption'] = strip_tags($items[$i]['caption'.$baselang]);
- $items[$i]['basketClass'] = $baskClass;
- $items[$i]['basketLable'] = $baskLable;
- }
- if(!empty($uri[4]) AND !preg_match('/^page[0-9]{1,3}$/',$uri['4'])){
- $currentID=$db->queryOneRecord("SELECT * FROM `partisions` WHERE `url`='{$uri['3']}'");
- $currentID=$currentID['id'];
- //П�?ДАРЫ ПОзиция карточка товара
- $catalogueTplId = 'position';
- $cart = $_SESSION['basket'];
- //foreach($cart as $c)
- //{
- // echo $c['0'].' ';
- //}
- if($lang=='/en')
- $tpl->set('#priceTitle',null,array('priceTitle'=>'Price'));
- else if($lang=='/ua')
- $tpl->set('#priceTitle',null,array('priceTitle'=>'Цiна'));
- else
- $tpl->set('#priceTitle',null,array('priceTitle'=>'Цена'));
- $items = $db->queryOneRecord("select * from `items` where `url`='".$uri[4]."' order by `ind` limit 1");
- $pageTitle = $items['title'];
- $metaArray = Array(
- 'keywords' => $items['keywords'.$baselang],
- 'description' => $items['description'.$baselang],
- 'title' => $items['title'.$baselang]
- );
- $items['stock'] = (!empty($items['stok']))?'Нет в наличии':'Есть в наличии';
- if(checkInBasket($items['id'])){
- if($lang=='/en')
- {
- $baskClass = 'outFromBasket';
- $baskLable = 'Remove from cart';
- }
- if($lang=='/ua')
- {
- $baskClass = 'outFromBasket';
- $baskLable = 'Прибрати';
- }
- else if($lang!='/en' AND $lang!='/ua')
- {
- $baskClass = 'outFromBasket';
- $baskLable = 'Убрать';
- }
- }
- if($baselang!='_en' AND $baselang!='_ua')
- $baselang = '';
- $items['name']=$items['name'.$baselang];
- if($items['action']=='true') $items['price']=$items['actionprice'];
- $items['text']=$items['text'.$baselang];
- $items['caption']=$items['caption'.$baselang];
- $items['descriptor']=$items['descriptor'.$baselang];
- $items['title']=$items['title'.$baselang];
- $items['keywords']=$items['keywords'.$baselang];
- $items['description']=$items['description'.$baselang];
- $items['top']=$items['top'.$baselang];
- $items['header']=$items['header'.$baselang];
- if($items['action']=='true') $items['price']=$items['actionprice'];
- if($items['price']!=''){
- if($lang!='/en')
- {
- $items['price']=roundPrice('uah',$items['price'],$currency);
- $items['price2']=roundPrice('usd',$items['price'],$currency);
- $items['price']=$items['price'].' грн';
- $items['price2']=$curr2.$items['price2'];
- }
- else
- {
- $items['price']=roundPrice('uah',$items['price'],$currency);
- $items['price2']=roundPrice('usd',$items['price'],$currency);
- $items['price']=roundPrice('eur',$items['price'],$EUR['value']);
- $items['price']=$curr1.$items['price'];
- $items['price2']=$curr2.$items['price2'];
- }
- }else{
- $items['price2'] = null;
- if($lang=='/en')
- $items['price'] = "no price";
- else
- $items['price'] = "Цена не указана";
- }
- if($lang=='/en')
- {
- $baskClass = 'toBaskcet';
- $baskLable = 'Buy it!';
- }
- if($lang=='/ua')
- {
- $baskClass = 'toBaskcet';
- $baskLable = 'Купити!';
- }
- else if($lang!='/en' AND $lang!='/ua')
- {
- $baskClass = 'toBaskcet';
- $baskLable = 'Купить!';
- }
- if(checkInBasket($items['id'])){
- if($lang=='/en')
- {
- $baskClass = 'outFromBasket';
- $baskLable = 'Remove from cart';
- }
- if($lang=='/ua')
- {
- $baskClass = 'outFromBasket';
- $baskLable = 'Прибрати';
- }
- else if($lang!='/en' AND $lang!='/ua')
- {
- $baskClass = 'outFromBasket';
- $baskLable = 'Убрать';
- }
- }
- if($lang=='/en')
- $items['articleTitle']='Article:';
- else
- $items['articleTitle']='Артикул:';
- $items['basketClass'] = $baskClass;
- $items['basketLable'] = $baskLable;
- $items['comments'] = createComments($items['id']);
- if(!empty($items['file1']) && file_exists("gallery/photo/{$items['file1']}"))
- $items['img'] = "/gallery/photo/{$items['file1']}";
- else
- $items['img'] = "/img/shop/nophoto.gif";
- $tableIn = null;
- $table = explode(";",$items['table']);
- $fly = Array();
- foreach($table as $elem){
- $lines = explode("—",$elem);
- $fly[] = Array(
- 'var'=>$lines[0],
- 'val'=>$lines[1]
- );
- }
- $tpl->set('.tableItems',null,$fly);
- $position = $items;
- }
- //Картинки на странице товара
- //собираем массив
- // foreach ($items as $key => $value) {
- //if (strstr($key, 'photo_') && $value != '')
- $photo['big'] = '/items_img/'.$items['iid'].'/'.$items['id'].'/'.$items['url'].'-1-big.jpg';
- $photo['zoom'] = '/items_img/'.$items['iid'].'/'.$items['id'].'/'.$items['url'].'-1-zoom.jpg';
- $tpl->set('#mainImage',null,$photo);
- $j=0;
- for($i=1;$i<=5;$i++)
- {
- if (file_exists($_SERVER['DOCUMENT_ROOT'].'/items_img/'.$items['iid'].'/'.$items['id'].'/'.$items['url'].'-'.$i.'-big.jpg'))
- {
- $thumbs[$j]['zoom']='/items_img/'.$items['iid'].'/'.$items['id'].'/'.$items['url'].'-'.$i.'-zoom.jpg';
- $thumbs[$j]['thumb']='/items_img/'.$items['iid'].'/'.$items['id'].'/'.$items['url'].'-'.$i.'-big.jpg';
- }
- $j++;
- }
- //}
- //echo '<img src="/items_img/'.$items['iid'].'/'.$items['id'].'/'.$items['url'].'-big.jpg'.'"/>';
- //Вызываем шаблон.Он генерит стока элементов вредных скока элементов в массиве
- $tpl->set('.positionThumbs',null,$thumbs);
- $tpl->set('#catalogue',$catalogueTplId,$position);
- $tpl->set('.catalogueItemsList',null,$items);
- // Получаем дерево категорий
- $globalParent = getParentRec($currentID);
- $parent = get_parent($currentID);
- $categories = get_ctgs_tree( 0, 0 );
- if(empty($uri['3']))
- $globalLevel = '0';
- else if(!empty($uri['3']))
- {
- $category = $db->queryAllRecords("SELECT * FROM `partisions` WHERE `iid`='{$currentID}'");
- if(!empty($category))
- $globalLevel = '2';
- else
- $globalLevel = '3';
- }
- $i=0;
- foreach($categories as $c)
- {
- $c_query .=$c['id'].',';
- }
- $c_query = substr($c_query,0,-1);
- //print_r($categories);
- //$categories = $db->queryAllRecords("SELECT * FROM `partisions` WHERE `id` IN ($c_query) ORDER BY `name`");
- //print_r($categories);
- foreach ($categories as $ctg)
- {
- $level = $ctg['level'];
- if($globalLevel != 0)
- {
- if($level == 1)
- {
- if($ctg['iid']==$globalParent['id'])
- {
- $levelOne[$i]['name']=$ctg['name'.$baselang];
- $levelOne[$i]['lang']=$lang;
- $levelOne[$i]['part']=$globalParent['url'];
- $levelOne[$i]['url']=$ctg['url'];
- $parent_parent = get_parent($parent['iid']);
- if($ctg['id']==$currentID OR $ctg['id']==$currentIID OR $ctg['id']==$parent_parent['iid'])
- $levelOne[$i]['class']='active';
- else
- $levelOne[$i]['class']='inline';
- }
- }
- if($level == 2)
- {
- if($ctg['iid']==$currentID)
- {
- $l2MenuElements[$i]['name']=$ctg['name'.$baselang];
- $l2MenuElements[$i]['lang']=$lang;
- $l2MenuElements[$i]['part']=$globalParent['url'];
- $l2MenuElements[$i]['url']=$ctg['url'];
- if($ctg['id']==$currentID OR $ctg['id']==$currentIID)
- $l2MenuElements[$i]['class']='active';
- else
- $l2MenuElements[$i]['class']='inline';
- }
- }
- }
- if($globalLevel!=0)
- {
- if($globalLevel==2 OR $globalLevel==3)
- {
- if($level == 2)
- {
- if($ctg['iid']==$currentIID)
- {
- $l2MenuElements[$i]['name']=$ctg['name'.$baselang];
- $l2MenuElements[$i]['lang']=$lang;
- $l2MenuElements[$i]['part']=$globalParent['url'];
- $l2MenuElements[$i]['url']=$ctg['url'];
- if($ctg['id']==$currentID OR $ctg['id']==$currentIID)
- $l2MenuElements[$i]['class']='active';
- else
- $l2MenuElements[$i]['class']='inline';
- }
- }
- if($level == 3)
- {
- if($ctg['iid']==$currentID)
- {
- $middleMenuElements[$i]['name'] = $ctg['name'.$baselang];
- $middleMenuElements[$i]['lang'] = $lang;
- $middleMenuElements[$i]['part'] = $globalParent['url'];
- $middleMenuElements[$i]['url'] = $ctg['url'];
- if($ctg['id']==$currentID OR $ctg['id']==$currentIID)
- $middleMenuElements[$i]['class']='active';
- else
- $middleMenuElements[$i]['class']='inline';
- }
- }
- }
- if($globalLevel==3)
- {
- if($level == 2)
- {
- $parent = get_parent($currentIID);
- if($ctg['id']==$currentIID OR $parent['iid']==$ctg['iid'])
- {
- $l2MenuElements[$i]['name']=$ctg['name'.$baselang];
- $l2MenuElements[$i]['lang']=$lang;
- $l2MenuElements[$i]['part']=$globalParent['url'];
- $l2MenuElements[$i]['url']=$ctg['url'];
- if($ctg['id']==$currentID OR $ctg['id']==$currentIID)
- $l2MenuElements[$i]['class']='active';
- else
- $l2MenuElements[$i]['class']='inline';
- }
- }
- if($level == 3)
- {
- if($ctg['iid']==$currentID OR $ctg['iid']==$currentIID)
- {
- $middleMenuElements[$i]['name'] = $ctg['name'.$baselang];
- $middleMenuElements[$i]['lang'] = $lang;
- $middleMenuElements[$i]['part'] = $globalParent['url'];
- $middleMenuElements[$i]['url'] = $ctg['url'];
- if($ctg['id']==$currentID OR $ctg['id']==$currentIID)
- $middleMenuElements[$i]['class']='active';
- else
- $middleMenuElements[$i]['class']='inline';
- }
- }
- }
- }
- else
- {
- if($level == 1)
- {
- if($ctg['iid']==$globalParent['id'])
- {
- $levelOne[$i]['name']=$ctg['name'.$baselang];
- $levelOne[$i]['lang']=$lang;
- $levelOne[$i]['part']=$globalParent['url'];
- $levelOne[$i]['url']=$ctg['url'];
- }
- }
- }
- $i++;
- }
- if($emptyCategoryFlag != true)
- {
- $tpl->set('#menuSidebar',null,null);
- $tpl->set('.levelPartMenu',null,$levelOne);
- $tpl->set('.menuLevelTwo',null,$l2MenuElements);
- $tpl->set('.middleMenuElement',null,$middleMenuElements);
- $tpl->set('#mainCategoryName',null,array('name'=>$globalParent['name'.$baselang],'lang'=>$lang,'url'=>$globalParent['url']));
- }
- else
- $tpl -> set ("#emptyCategory", null, array('message'=>$emptyCategoryMessage));
- if($catalogueTplId=='items'){
- if(!empty($uri['2'])){
- $tpl->set('#filters','def',Array(
- 'minprice'=>$minprice,
- 'maxprice'=>$maxprice
- ));
- if(count($filters))
- $tpl->set('#filtersHead','def',Array('header'=>'Отфильтровать'));
- $tpl->set('.filtersItemsList',null,$filters);
- $tpl->set('#filterJs');
- }
- }else if($catalogueTplId=='root'){
- //fuck
- }else{
- }
- if(empty($uri['4']) OR (!empty($uri['4']) AND preg_match('/^page[0-9]{1,3}$/',$uri['4'])))
- $pageList = null;
- if(!empty($uri['2']) AND (!empty($uri['3']) AND preg_match('/^page[0-9]{1,3}$/',$uri['3'])))
- $pageList.=createPagesList($uri['2']);
- else if(!empty($uri['2']) AND (empty($uri['3'])))
- $pageList.=createPagesList($uri['2']);
- else if(!empty($uri['2']) AND (!empty($uri['3']) AND !preg_match('/^page[0-9]{1,3}$/',$uri['4'])))
- $pageList.=createPagesList($uri['3']);
- else if(!empty($uri['2']) AND (!empty($uri['3']) AND preg_match('/^page[0-9]{1,3}$/',$uri['4'])))
- $pageList.=createPagesList($uri['3']);
- }else if ($contentAction=="comparison"){
- if(isset($_SESSION['UID'])){
- $UID = $_SESSION['UID'];
- $it = $db->queryAllRecords("select * from `basketitems` where `uid`='$UID'");
- $_SESSION['basket'] = Array();
- foreach($it as $e){
- $_SESSION['basket'][] = Array($e['itemid'],$e['size'],$e['type'],$e['price']);
- }
- }
- $fills = Array('name','price');
- $fillsL = Array('Товар','цена');
- $lables = Array();
- $typs = Array();
- $items = Array();
- $qItems = Array();
- for($i=0;$i<count($_SESSION['basket']);$i++){
- $fly = Array();
- $itemData = $db->queryOneRecord("select * from `items` where `id`='".$_SESSION['basket'][$i][0]."'");
- $qItems[] = $itemData;
- $lines = explode(';',$itemData['table']);
- foreach($lines as $l){
- $itLi = explode('—',$l);
- $name = $itLi[0];
- $teg = toTeg($name);
- $fly[]= Array($teg,$itLi[1]);
- $test = true;
- foreach($typs as $t){
- if($t==$teg)
- $test = false;
- }
- if($test && !empty($teg)){
- $typs[] = $teg;
- $lables[] = $name;
- }
- }
- $items[$i] = $fly;
- }
- $tdTpl = $tpl->set('#tdTpl',null,null,true);
- $trTpl = $tpl->set('#trTpl',null,null,true);
- $co = 0;
- foreach($fills as $f){
- $td = null;
- for($i=0;$i<count($_SESSION['basket']);$i++){
- $itemId = $_SESSION['basket'][$i][0];
- $val = $qItems[$i][$f];
- if($f=='price'){
- $val = $val*$currency.'грн '.$val.'$';
- }
- $td .= $tpl->replace($tdTpl,Array('content'=>$val));
- }
- $tr .= $tpl->replace($trTpl,Array(
- 'content'=>$td,
- 'lable'=>null,
- 'class'=>(($co==0)?'name':null)
- ));
- $co++;
- }
- $classCounter = 0;
- for($j=0;$j<count($typs);$j++){
- $t = $typs[$j];
- $l = $lables[$j];
- $td = null;
- for($i=0;$i<count($items);$i++){
- $test = true;
- foreach($items[$i] as $it){
- if($it[0]==$t){
- $value = $it[1];
- $td .= $tpl->replace($tdTpl,Array('content'=>$value));
- $test = false;
- }
- }
- if($test){
- $td .= $tpl->replace($tdTpl,Array('content'=>'—'));
- }
- }
- $class = ($classCounter%2==0)?' class="line"':'';
- $tr .= $tpl->replace($trTpl,Array('content'=>$td,'lable'=>$l));
- $classCounter++;
- }
- $tpl->set("#comp",null,Array('content'=>$tr));
- }else if($contentAction=="info"){
- $tpl->set('#info','index');
- $path = $db->queryAllRecords("select * from `articlepart` order by `ind` DESC");
- foreach($path as &$pth){
- if($pth['url']==$uri['2']) $pth['tpl']='active';
- }
- $tpl->set('.infoPath',null,$path);
- if(empty($uri[2])){
- $infoTplPosition = 'index';
- $tpl->set('#indexImage');
- $headersTpl = Array('#newHeader','#rewHeader');
- $templates = Array('.infoIndexNewsTheme','.infoIndexReviewsTheme');
- $parts = $db->queryAllRecords("select `name`,`url`,`id` from `articlepart` order by `ind` ASC limit 2");
- $counter = 0;
- foreach($parts as $p){
- $news = $db->queryAllRecords("select * from `articles` where `iid`='{$p['id']}' order by `ind` DESC limit 5");
- foreach($news as &$n){
- $n['comments'] = countComments('articles',$n['id']);
- $n['part'] = $p['url'];
- }
- $tpl->set($headersTpl[$counter],null,Array('name'=>$p['name']));
- $tpl->set($templates[$counter],null,$news);
- $counter++;
- }
- }else if(!empty($uri[2]) && empty($uri[4])){
- $infoTplPosition = 'list';
- $page = $db->queryOneRecord("select `id`,`name`,`url` from `articlepart` where `url`='{$uri[2]}'");
- if(empty($page))header("location: /404");
- $pageName = $page['name'];
- }else if(!empty($uri[4])){
- $infoTplPosition = 'page';
- }
- $tpl->set('#container',$infoTplPosition,Array(
- 'name'=>$pageName
- ));
- if($infoTplPosition == 'index'){
- $news = $db->queryAllRecords("select * from `articles` where `iid`='247' limit 5");
- $reviews = $db->queryAllRecords("select * from `articles` where `iid`='246' limit 5");
- foreach($news as &$i){
- $i['part'] = $page['news'];
- $i['page'] = 0;
- }
- foreach($reviews as &$i){
- $i['part'] = $page['Obzor'];
- $i['page'] = 0;
- }
- $tpl->set('.infoIndexNewsTheme',null,$news);
- $tpl->set('.infoIndexReviewsTheme',null,$reviews);
- }else if($infoTplPosition == 'list'){
- $counts = $db->queryAllRecords("select `id` from `articles` where `iid`='{$page['id']}'");
- $counts = count($counts);
- $leedsOnPage = 6;
- if($counts>$leedsOnPage){
- $pageId = $uri[3];
- if(!empty($pageId)){
- $pageId = explode("-",$pageId);
- $pageId = intval($pageId[1]);
- }else $pageId = 1;
- if($pageId==0)$pageId=1;
- $pageId--;
- $leftLimit = $pageId*$leedsOnPage;
- $rightLimit = $leedsOnPage;
- $pageLables = Array('Предыдущая','Следующая');
- $PC = 0;
- foreach($pageLables as $lable){
- $fly = Array();
- $tmpId = $pageId+$PC;
- if($tmpId==0){
- $tmpId = 1;$fly['tpl']='passive';
- }else if($tmpId>$counts-1){
- $tmpId = $counts;
- }
- $fly['part']=$uri[2];
- $fly['id']=$tmpId;
- $fly['name']=$lable;
- $pages[] = $fly;
- $PC=2;
- }
- $tpl->set('.pageSlider',null,$pages);
- $limit = "limit $leftLimit,$rightLimit";
- }else{
- $tpl->set('#pagesEmpty');
- }
- $items = $db->queryAllRecords("select * from `articles` where `iid`='{$page['id']}' $limit");
- foreach($items as &$i){
- $i['part'] = $page['url'];
- $i['page'] = 0;
- }
- $tpl->set('.infoNewsTheme',null,$items);
- }else{
- $item = $db->queryOneRecord("select * from `articles` where `url`='{$uri[4]}'");
- if(empty($item))header("location: /404");
- $item['comments'] = createComments($item['id']);
- $tpl->set('#pageContainer','def',$item);
- }
- }else if($contentAction=="cart"){
- //print_r($_SESSION['basket']);
- $cartAction = !empty($uri['2'])?$uri['2']:'index';
- $cartPage = 'index';
- $tpl->set('#cartOrderGet',$uotpl,null);
- $tpl->set('#cartSummT',$uotpl,null);
- if(!empty($UID)){
- $itemsPrew = $db->queryAllRecords("
- select DISTINCT
- `items`.`id`,`items`.`iid`,`items`.`url`,`items`.`id` as `itemid`,`name`,`price`,`price`,`size`,`file3` from `items`,`basketitems`
- where `items`.`id` in
- (select `itemid` from `basketitems` where `uid`='$UID' and `type`='prew')
- ");
- $itemsTrue = $db->queryAllRecords("
- select DISTINCT
- `items`.`id`,`items`.`iid`,`items`.`action`,`items`.`url`,`items`.`id` as `itemid`,`name`,`name_en`,`name_ua`,`items`.`actionprice`,`price`,`price`,`size`,`file3` from `items`,`basketitems` where `items`.`id` in
- (select `itemid` from `basketitems` where `uid`='$UID' and `type`='')
- ");
- }else{
- if(count($_SESSION['basket'])>0){
- foreach($_SESSION['basket'] as $b){
- $fly = Array();
- $fly = $db->queryOneRecord("select * from `items` where `id`='{$b[0]}'");
- $fly['size'] = $b[1];
- $fly['itemid'] = $b[0];
- if($b[2]=='prew') $itemsPrew[] = $fly;
- else $itemsTrue[] = $fly;
- }
- }
- }
- $summCount = count($itemsPrew)+count($itemsTrue);
- if($summCount==0) $cartPage = 'empty';
- $summ = null;
- for($i=0;$i<2;$i++){
- $e = ($i==0)? $itemsPrew : $itemsTrue;
- if(!empty($e)){
- foreach($e as &$item){
- if($item['action']=='true') $item['price']=$item['actionprice'];
- if($lang=='' OR $lang=='/ru' OR $lang=='/ua')
- {
- $item['price'] = roundPrice('uah',$item['price']);
- $item['cost']=$item['price']*$item['size'];
- }
- else
- {
- $item['price'] = roundPrice('eur',$item['price'],$EUR['value']);
- $item['cost']=$item['price']*$item['size'];
- }
- $summ += $item['cost'];
- $p = getParentRec($item['iid']);
- $b = getParent($item['iid']);
- $item['part']=$p['url'];
- $item['brand']=$b['url'];
- if (file_exists($_SERVER['DOCUMENT_ROOT'].'/items_img/'.$item['iid'].'/'.$item['id'].'/'.$item['url'].'-prev.jpg'))
- $item['file2']='/items_img/'.$item['iid'].'/'.$item['id'].'/'.$item['url'].'-prev.jpg';
- //}else if(!empty($item['file1']) && file_exists("gallery/photo/{$item['file1']}")){
- // $item['file2']="/gallery/photo/{$item['file1']}";
- //}else{
- // $item['file2']="/img/nophoto.png";
- //}
- if($i==1)$summ+=$item['price2'];
- }
- }
- if($i==0)
- $itemsPrew = $e;
- else
- $itemsTrue = $e;
- }
- $fills = Array('name','phone','email','text','deliver','buy');
- foreach($fills as $f) $form[$f]=$_POST[$f];
- if($summCount>1){
- $tpl->set('#cartComparsion','else');
- }
- $tpl->set('#cartBody',$cartAction,$form);
- $tpl->set("#cartPage",$cartPage);
- $tpl->set("#reserverHeader",$uotpl,null);
- //$tpl->set("#reserverHeader2",$uotpl,null);
- //$tpl->set('.reserverItems'.$uotpl,null,$itemsPrew);
- $tpl->set('.orderItems'.$uotpl,null,$itemsTrue);
- $tpl->set('#cartSummT',$uotpl,null);
- if($cartAction=='order'){
- if(empty($itemsTrue))
- header('location:/cart');
- $delivery = $db->queryAllRecords("select * from `listmenu` where `type`='deliver' order by `id`");
- foreach($delivery as &$d){
- if($d['id']==$_POST['deliver'])$d['selected']='selected="selected"';
- else $d['selected']=null;
- }
- $buy = $db->queryAllRecords("select * from `listmenu` where `type`='pay' order by `id`");
- foreach($buy as &$d){
- if($d['id']==$_POST['buy'])$d['selected']='selected="selected"';
- else $d['selected']=null;
- }
- if(!empty($_SESSION['UID']))
- $userData = $db->queryOneRecord("SELECT * FROM `buyers` WHERE `id`={$_SESSION['UID']}");
- else
- $userData = array();
- $tpl->set('#payName',$uotpl,array('name'=>$userData['name']));
- $tpl->set('#payPhone',$uotpl,array('phone'=>$userData['phone']));
- $tpl->set('#payMail',$uotpl,array('email'=>$userData['email']));
- $tpl->set("#payDetails",$uotpl,null);
- $tpl->set('.payType','def',$buy);
- $tpl->set('#payHeader',$uotpl,$buy);
- $tpl->set('.delivery','def',$delivery);
- $tpl->set('#orderContent',$uotpl,null);
- $tpl->set('#cartSumm',$uotpl,Array('summ'=>$summ));
- $tpl->set('.orderItems'.$uotpl,'def',$itemsTrue);
- }
- else if ($cartAction == 'finish')
- {
- //print_r($_REQUEST);
- if($_SESSION['UID']!='')
- $tpl->set('#payFinish',$uotpl,null);
- else
- $tpl->set('#payFinish',$uotpl,array());
- }
- else
- {
- $tpl->set('.reserverItems'.$uotpl,null,$itemsTrue);
- }
- if($_POST['action']=='buy'){
- //print_r($_POST);
- if(!empty($form['name']) && $form['phone']){
- if(!empty($itemsTrue)){
- if(!empty($form['deliver'])){
- foreach($delivery as $d){
- if($d['id']==$form['deliver']){
- $form['deliver'] = $d['name'];
- }
- }
- }
- if(!empty($form['buy'])){
- foreach($buy as $d){
- if($d['id']==$form['buy']) $form['buy'] = $d['name'];
- }
- }
- foreach($form as $k=>$f){
- $fillsStr .= "`$k`='$f',";
- }
- $newId = $db->queryOneRecord("SELECT MAX(id) FROM `orders`");$newId=$newId[0]+1;
- $q = "
- insert into `orders` set
- `id`='$newId',
- `iid`='$UID',
- `type`='new',
- $fillsStr
- `currency`='$currency'
- ";
- $insert = $db->query($q);
- //fuck
- //print_r($itemsTrue);
- foreach($itemsTrue as $it){
- if($it['action']=='true') $it['price']=$it['actionprice'];
- $insert = $db->query("
- insert into `orderitems` set
- `iid`='$newId',
- `itemid`='{$it['itemid']}',
- `count`='{$it['size']}',
- `buyprice`='{$it['price']}'
- ");
- }
- if(!empty($UID)){
- $delete = $db->query("delete from `basketitems` where `uid`='$UID' and `type`=''");
- }else{
- //print_r($_SESSION['basket']);
- $baskLen = count($_SESSION['basket']);
- for($i=0;$i<$baskLen;$i++){
- //print_r($_SESSION['basket']);
- //$_SESSION['basket'][$i][2];
- if($_SESSION['basket'][$i][2]==''){
- //echo $_SESSION['basket'][0];
- unset($_SESSION['basket'][$i]);
- //array_splice($_SESSION['basket'], $i, 1, null);
- //$i--;
- }
- }
- }
- /* === */
- $msg = ('Пользователь <a href="http://conquistador.com.ua/admin/ru/orders/new/">оформил заказ</a>');
- SendMsgToAdmins('Оформлен заказ!', $msg);
- header("location: $lang/cart/finish");
- }
- }
- }
- }
- else if($contentAction=="content"){
- if(!empty($uri[3])) header("location: /404");
- //fuck
- $lnk = $uri[2];
- $article = $db->queryOneRecord("select * from `sitecontent` where `url`='$lnk'");
- if(empty($article)) header("location: /404");
- $metaArray = Array(
- 'keywords' => $article['keywords'],
- 'description' => $article['description'],
- 'title' => $article['title']
- );
- $setArray['name']= $article['name'];
- $setArray['caption']=$article['caption'];
- $setArray['text']=$article['text'];
- $tpl->set('#module','index',$setArray);
- }else if($contentAction=="account"){
- $tpl->set('#globalClass','def',Array('class'=>$contentAction));
- if($UID!=''){
- $display='none';
- if($_POST['action']=='update'){
- $display='block';
- $userinfocurrent=$db->queryOneRecord("SELECT * FROM `buyers` WHERE `id`='$UID'");
- if(check_pwd($_POST['password'],$userinfocurrent['password']) AND check_pwd($_POST['password2'],$userinfocurrent['password'])){
- $name = $_POST['name'];
- $phone = $_POST['phone'];
- $password = hash_pwd($_POST['password']);
- $email = $_POST['email'];
- $pref = "UPDATE `buyers` SET";
- $postf = "WHERE `id`='$UID'";
- $db->query("$pref `name`='$name',`phone`='$phone', `password`='$password',`email`='$email' $postf");
- $userActionResult='�?нформация успешно обновлена';
- }else{
- $userActionResult='Неверный пароль или пароли не совпадают!';
- }
- //header('location:/account');
- }if($_POST['action']=='chpass'){
- $display='block';
- $userinfocurrent=$db->queryOneRecord("SELECT * FROM `buyers` WHERE `id`='$UID'");
- if(check_pwd($_POST['oldpassword'],$userinfocurrent['password'])
- AND $_POST['newpassword']==$_POST['newpassword2']){
- $password = hash_pwd($_POST['newpassword']);
- $pref = "UPDATE `buyers` SET";
- $postf = "WHERE `id`='$UID'";
- $db->query("$pref `password`='$password' $postf");
- $userActionResult='Пароль успешно изменен';
- }else{
- $userActionResult='Неверный пароль или пароли не совпадают!';
- }
- //header('location:/account');
- }
- $fills = Array('id','date','name','phone','type','summ');
- $Array = $db->queryAllRecords("select * from `orders` WHERE `iid`='".$UID."' order by `date` DESC");
- if($lang=='' OR $lang=='/ru')
- {
- $itemsTr = $tpl->set('#orderItemsList','def',null,true);
- $uotpl = '';
- }
- else if ($lang=='/ua')
- {
- $itemsTr = $tpl->set('#orderItemsList','ua',null,true);
- $uotpl = 'Ua';
- }
- else if ($lang=='/en')
- {
- $itemsTr = $tpl->set('#orderItemsList','en',null,true);
- $uotpl = 'En';
- }
- $tpl->set('#userData',$uotpl,null);
- $tpl->set('#userChpass',$uotpl,null);
- $tpl->set('#accountHeader',$uotpl,null);
- $tableHtml = null;
- if(count($Array)>0){
- $tpl->set('#basket','cart',null);
- $tpl->set('#userOrdersHeader',$uotpl,null);
- foreach($Array as &$e){
- $buyCurrency = $e['currency'];
- $summ = null;
- $inline = null;
- $total = null;
- $positions = null;
- $items = $db->queryAllRecords("SELECT `items`.`id` as `itemid`,`items`.`price`,`items`.`name`,`items`.`name_en`,`items`.`name_ua`,`items`.`url`,`orderitems`.`buyprice`,`orderitems`.`count` FROM `items` JOIN `orderitems` ON `items`.`id`=`orderitems`.`itemid` AND `orderitems`.`iid`='{$e['id']}' WHERE `items`.`id` IN (SELECT `itemid` FROM `orderitems` WHERE `iid`={$e['id']})");
- //print_r($items);
- $tmpId = null;
- foreach($items as &$f){
- //print_r($f);
- if($lang=='/ua' OR $lang=='' OR $lang=='/ru')
- {
- $price = roundPrice('uah',$f['price']);
- $f['price']=$price;
- $f['buyprice']=roundPrice('uah',$f['buyprice']);
- }
- else
- {
- $tmplt = 'en';
- $price = roundPrice('eur',roundPrice('uah',$f['price']),$EUR['value']);
- $f['price']=$price;
- $f['buyprice']=roundPrice('eur',$f['buyprice'],$EUR['value']);
- }
- $summ = $f['count']*$f['buyprice'];
- $f['cost'] = $summ;
- $total += $summ;
- if($f['itemid']!=$tmpId){
- $positions .= $tpl->replace($itemsTr,$f);
- $tmpId = $f['itemid'];
- }
- }
- $date = explode(" ",$e['date']);
- $day = explode("-",$date[0]);
- $time = $date[1];
- $e['date'] = "{$day[2]}.{$day[1]}.{$day[0]} в {$date[1]}";
- $e['items'] = $positions;
- $e['total'] = $total;
- }//
- $tpl->set('.userOrders'.$uotpl,'def',$Array);
- }else{
- $tpl->set('#basket','empty'.$uotpl,null);
- }
- //#basket empty{{
- $B = $db->queryOneRecord("select * from `buyers` where `id`='$UID'");
- $bName=$B['name'];
- $bPhone=$B['phone'];
- $bMail=$B['email'];
- $bPass=$B['password'];
- $bPass2=$B['password'];
- }
- else{
- Header("location:/signin");
- }
- $tpl->set('#position','account',Array(
- 'userName'=>$bName,
- 'userPhone'=>$bPhone,
- 'email'=>$bMail,
- ));
- }else if($contentAction=="signin" ){
- $tpl->set('#globalClass','def',Array('class'=>$contentAction));
- $tpl->set('#position','login',null);
- if($uri['2']=='recovered')
- {
- $tpl->set('#msg',null,array('msg'=>'Новый пароль отправлен на указанный e-mail адрес'));
- }
- else
- {
- $tpl->set('#signTitle',null,null);
- $tpl->set('#tabTitles',null,null);
- if($UID==''){
- if($_POST['action']=='restorepw'){
- restore_pwd($_POST['email']);
- }
- if($_POST['action']=='register' || $_POST['action']=='update'){
- $name = $_POST['name'];
- $password = $_POST['password'];
- $email = $_POST['email'];
- $phone = $_POST['phone'];
- $arr = Array('phone','password','password2','name');$necessarily = $arr;
- $mach = Array('phone','name');
- $val = sign('buyers',$arr,$necessarily,$mach);
- if($val==true){
- if($_POST['action']=='register'){
- $newId = $db->queryOneRecord("SELECT max( id ) FROM `buyers`");$newId=$newId[0]+1;
- $pref = "
- INSERT INTO `buyers` SET
- `id`='$newId',
- ";
- $postf = null;
- }else{
- $pref = "UPDATE `buyers` SET";
- $UID = $_SESSION['UID'];
- $postf = "WHERE `id`='$UID'";
- }
- $items = $db->query("
- $pref
- `name`='$name',`password`='".hash_pwd($password)."',`email`='$email',`phone`='$phone' $postf");
- if($_POST['action']=='register'){
- $_SESSION['UID'] = $newId;
- header( 'Location: /account') ;
- }
- }else{
- $alert = $val;
- }
- }else if($_POST['action']=='login'){
- $phone_chk=validate_phone($_POST['phone']);
- if($phone_chk!=false){
- $user_pw=$db->queryOneRecord("SELECT * FROM `buyers` WHERE `phone`='".$phone_chk."'");
- $val = check_pwd($_POST['password'],$user_pw['password']);
- if($val==true){
- $phone=$_POST['phone'];
- $B = $db->queryOneRecord("select * from `buyers` where `phone`='$phone'");
- $_SESSION['UID'] = $B['id'];
- Header('Location:/account');
- }
- }else{
- }
- }
- $Header = 'Авторизация';
- $sabmitLable = 'Зарегистрироваться';
- $actionReg = 'register';
- $prewForm = null;
- $alert=null;
- $email = null;
- $password = null;
- $password2 = null;
- $name = null;
- $email = $_POST['email'];
- $password = $_POST['password'];
- $password2 = $_POST['password2'];
- $name = $_POST['name'];
- }else{
- Header('Location:/account');
- }
- $tpl->set('#fills','def',Array(
- 'name'=>null,
- 'email'=>null,
- 'password'=>null,
- 'password2'=>null
- ));
- }
- }else if($contentAction=="logout"){
- session_destroy();
- Header('Location:/');
- }else if($contentAction=="map"){
- $lang = (empty($lang)) ? 'ru' : str_replace('/','',$lang);
- $filename = "tpl/sitemap_". $lang . ".html";
- if (!file_exists($filename) or !is_readable($filename)) $smdata = "Failed to read sitemap file $filename";
- else $smdata = file_get_contents ($filename);
- $tpl->set('#sitemap-container',null, array('sm-content' => $smdata));
- }else if($contentAction=="mail"){
- if(!empty($_SESSION['feedBackUserName'])) $nameSend = $_SESSION['feedBackUserName'];
- if(!empty($_SESSION['feedBackUserMail'])) $emailSend = $_SESSION['feedBackUserMail'];
- if(isset($_SESSION['userId'])){
- $user = $db->queryOneRecord("select * from `articles` where `id`='{$_SESSION['userId']}' limit 1");
- $nameUser = $user['name'];
- $mailUser = $user['email'];
- }
- if($_POST['action']=="feedback"){
- $nameSend = $_POST['name'];
- $emailSend = $_POST['email'];
- $textSend = $_POST['text'];
- if(!empty($nameSend) && !empty($emailSend) && !empty($textSend)){
- $s_name = $_SERVER['SERVER_NAME'];
- $items = $db->query("INSERT INTO `feedback` SET `name`='$nameSend', `email`='$emailSend', `text`='$textSend'");
- $admins = $db->queryAllRecords("select * from `users` where `email`!=''");
- $sub = $tplService->set('#feedBackAdminMail','def',Array(
- 'userName'=>$nameSend,
- ),true);
- $textToAdmin = $tplService->set('#feedBackAdminMail','def',Array(
- 'userName'=>$nameSend,
- 'email'=>$emailSend,
- 'text'=>$textSend
- ),true);
- foreach($admins as $userAdmin){
- sendMail(
- $userAdmin['email'],
- $textToAdmin,
- 'Cross Feedback',
- 'Магазин '.$s_name,
- 'admin@'.$s_name
- );
- }
- $messag = 'Сообщение успешно отправлено!';
- $textSend = null;
- $_SESSION['feedBackUserName'] = $nameSend;
- $_SESSION['feedBackUserMail'] = $emailSend;
- }else{
- $messag = 'Необходимо заполнить все поля!';
- }
- }
- $tpl->set('#fills','def',Array(
- 'err'=>$messag,
- 'name'=>$nameSend,
- 'email'=>$emailSend,
- 'text'=>$textSend,
- ));
- }
- else if($contentAction=="search"){
- require_once('search.php');
- if (empty($result)) $tpl->set('#emptyCategory', null, array('message' => 'По запросу «'.$good_query.'» ничего не найдено.'));
- else {
- $tpl->set('#emptyCategory', null, array('message' => 'По запросу «'.$good_query.'» найдены такие позиции:'));
- $output = $db->queryAllRecords('SELECT * FROM `items` WHERE id IN ('.implode ($result, ',').') AND `show` != "true"');
- foreach($output as &$r)
- {
- $tmp_b=get_parent($r['iid']);
- $tmp_p=getParentRec($r['iid']);
- $r['part'] = $tmp_p['url'];
- $r['brand'] = $tmp_b['url'];
- $r['lang'] = $lang;
- $r['price2'] = roundPrice('usd',$r['price'],$USD['value']);
- if (file_exists($_SERVER['DOCUMENT_ROOT'].'/items_img/'.$r['iid'].'/'.$r['id'].'/'.$r['url'].'-prev.jpg'))
- $r['file2']='/items_img/'.$r['iid'].'/'.$r['id'].'/'.$r['url'].'-prev.jpg';
- }
- // {part} {brand} {url}
- $tpl->set('.catalogueItemsList', 'def', $output);
- }
- }
- $tpl->set('#meta','def',$metaArray);
- return $inner;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment