0) { $query = $query ='SELECT *, RS_ITEMS.ID AS ID, RS_ITEMS.NAME AS NAME FROM RS_LINKS, RS_ITEMS WHERE RS_ITEMS.ID=RS_LINKS.REFCAT AND RS_LINKS.LINKTYPE=3 AND RS_LINKS.REFID=' . $cath . ' AND RS_ITEMS.STATUS>0 ORDER BY RS_ITEMS.DATE_ADDED DESC LIMIT ' . $rs_list_maxnews; } else { $query ='SELECT *, RS_ITEMS.ID AS ID, RS_ITEMS.NAME AS NAME FROM RS_ITEMS WHERE RS_ITEMS.STATUS>0 ORDER BY RS_ITEMS.DATE_ADDED DESC LIMIT ' . $rs_list_maxnews; } } else if ($news==2) { if ($cath>0) { $query = 'SELECT *, RS_ITEMS.NAME AS NAME, RS_ITEMS.ID AS ID, ITEMID, count(*) AS SUMORDER FROM RS_ORDERITEMS, RS_ITEMS, RS_LINKS WHERE RS_LINKS.LINKTYPE=3 AND RS_LINKS.REFID=' . $cath . ' AND RS_LINKS.REFCAT=RS_ITEMS.ID AND RS_ITEMS.ID = ITEMID GROUP BY ITEMID ORDER BY SUMORDER DESC'; } else { $query = 'SELECT *, ITEMID, count(*) AS SUMORDER FROM RS_ORDERITEMS, RS_ITEMS WHERE RS_ITEMS.ID = ITEMID GROUP BY ITEMID ORDER BY SUMORDER DESC'; } /* if ($cath>0) { $query = $query ='SELECT *, RS_ITEMS.ID AS ID, RS_ITEMS.NAME AS NAME FROM RS_LINKS, RS_ITEMS WHERE RS_ITEMS.ID=RS_LINKS.REFCAT AND RS_LINKS.LINKTYPE=3 AND RS_LINKS.REFID=' . $cath . ' AND RS_ITEMS.STATUS>0 ORDER BY RS_ITEMS.DATE_ADDED DESC LIMIT ' . $rs_list_maxnews; } else { $query ='SELECT *, RS_ITEMS.ID AS ID, RS_ITEMS.NAME AS NAME FROM RS_ITEMS WHERE RS_ITEMS.STATUS>0 ORDER BY RS_ITEMS.DATE_ADDED DESC LIMIT ' . $rs_list_maxnews; }*/ } else { $query = 'SELECT *, RS_ITEMS.ID AS ID, RS_ITEMS.NAME AS NAME FROM RS_LINKS, RS_ITEMS WHERE RS_ITEMS.ID=RS_LINKS.REFCAT AND RS_LINKS.LINKTYPE=3 AND RS_LINKS.REFID=' . $cath . ' AND RS_ITEMS.STATUS>0'; $query .=' ORDER BY ' . $order . ' ' . $ordertype; } // echo $news; // echo $query; $result=mysql_query($query); if (!$result) { die('Omlouvame se, nastala neocekavana chyba.'); } if (mysql_num_rows($result) == 0) { mysql_free_result($result); return Array(); } while ($row = mysql_fetch_assoc($result)) { array_push($texts, $row); } mysql_free_result($result); return $texts; } } function loadSearchItems($needle, $order, $ordertype) { global $db_type; $texts = Array(); if ($db_type=='MySQL') { //$query = 'SELECT *, RS_ITEMS.ID AS ID, RS_ITEMS.NAME AS NAME FROM RS_LINKS, RS_ITEMS WHERE RS_ITEMS.ID=RS_LINKS.REFCAT AND RS_LINKS.LINKTYPE=3 AND RS_ITEMS.NAME Like "%' . $needle . '%" AND RS_ITEMS.STATUS>0 ORDER BY ' . $order . ' ' . $ordertype; $query = 'SELECT *, RS_ITEMS.ID AS ID, RS_ITEMS.NAME AS NAME FROM RS_ITEMS WHERE RS_ITEMS.NAME Like "%' . $needle . '%" AND RS_ITEMS.STATUS>0 ORDER BY ' . $order . ' ' . $ordertype; //echo $query; $result=mysql_query($query); if (!$result) { die('Omlouvame se, nastala neocekavana chyba.'); } if (mysql_num_rows($result) == 0) { mysql_free_result($result); return Array(); } while ($row = mysql_fetch_assoc($result)) { array_push($texts, $row); } mysql_free_result($result); return $texts; } } function loadAdvancedSearchItems($byname, $name, $bydesc, $desc, $bycode, $code, $byauthor, $author, $byminprice, $minprice, $bymaxprice, $maxprice, $saleitem, $order, $ordertype) { global $db_type; $texts = Array(); if ($db_type=='MySQL') { $query = 'SELECT *, RS_ITEMS.ID AS ID, RS_ITEMS.NAME AS NAME FROM RS_ITEMS WHERE RS_ITEMS.STATUS>0 '; if ($byname) $query.= ' AND NAME Like "%' . $name . '%" '; if ($bydesc) $query.= ' AND MATCH(RS_ITEMS.DESCRIPTION) AGAINST("' . $description . '") '; if ($bycode) $query.= ' AND MATCH(RS_ITEMS.CODE) AGAINST("' . $code . '") '; if ($saleitem) $query.= ' AND RS_ITEMS.SALEITEM>0 '; if ($byminprice) $query.= ' AND RS_ITEMS.PRICE2>' . ((float) $minprice) . ' '; if ($bymaxprice) $query.= ' AND RS_ITEMS.PRICE2<' . ((float) $maxprice) . ' '; //MATCH(RS_ITEMS.CODE, RS_ITEMS.NAME, RS_ITEMS.DESCRIPTION) AGAINST("' . $needle . '") AND $query .= ' ORDER BY ' . $order . ' ' . $ordertype; //echo $query; $result=mysql_query($query); // echo mysql_error(); if (!$result) { // die('Omlouvame se, nastala neocekavana chyba.'); } if (mysql_num_rows($result) == 0) { mysql_free_result($result); return Array(); } while ($row = mysql_fetch_assoc($result)) { array_push($texts, $row); } mysql_free_result($result); return $texts; } } function loadNewItems($cath, $limit) { global $db_type; $texts = Array(); if ($db_type=='MySQL') { if ($cath) { $query = 'SELECT *, RS_ITEMS.NAME AS NAME, RS_ITEMS.ID AS ID, RS_LINKS.NAME AS LINKNAME FROM RS_ITEMS, RS_LINKS WHERE RS_ITEMS.STATUS>0 AND RS_LINKS.LINKTYPE=3 AND RS_LINKS.REFCAT=RS_ITEMS.ID AND RS_LINKS.REFID=' . $cath . ' ORDER BY RS_ITEMS.DATE_ADDED DESC LIMIT ' . $limit; } else { $query = 'SELECT * FROM RS_ITEMS WHERE RS_ITEMS.STATUS>0 ORDER BY DATE_ADDED DESC LIMIT ' . $limit; } // echo $query; $result=mysql_query($query); if (!$result) { die('Omlouvame se, nastala neocekavana chyba.'); } if (mysql_num_rows($result) == 0) { mysql_free_result($result); return Array(); } while ($row = mysql_fetch_assoc($result)) { array_push($texts, $row); } mysql_free_result($result); return $texts; } } function loadMostWantedItems($cath, $limit) { global $db_type; $texts = Array(); if ($db_type=='MySQL') { if ($cath) { $query = 'SELECT *, RS_ITEMS.NAME AS NAME, RS_ITEMS.ID AS ID, ITEMID, count(*) AS SUMORDER FROM RS_ORDERITEMS, RS_ITEMS, RS_LINKS WHERE RS_LINKS.LINKTYPE=3 AND RS_LINKS.REFID=' . $cath . ' AND RS_LINKS.REFCAT=RS_ITEMS.ID AND RS_ITEMS.ID = ITEMID GROUP BY ITEMID ORDER BY SUMORDER DESC LIMIT ' . $limit; } else { $query = 'SELECT *, ITEMID, count(*) AS SUMORDER FROM RS_ORDERITEMS, RS_ITEMS WHERE RS_ITEMS.ID = ITEMID GROUP BY ITEMID ORDER BY SUMORDER DESC LIMIT ' . $limit; } // echo $query; $result=mysql_query($query); if (!$result) { die('Omlouvame se, nastala neocekavana chyba.'); } if (mysql_num_rows($result) == 0) { mysql_free_result($result); return Array(); } while ($row = mysql_fetch_assoc($result)) { array_push($texts, $row); } mysql_free_result($result); return $texts; } } function loadDelivery($lang, $country) { global $db_type; $texts = Array(); if ($db_type=='MySQL') { $query = 'SELECT * FROM RS_CARRIAGE WHERE LANGCODE="' . $lang . '" AND COUNTRYCODE="' . $country . '" ORDER BY PRICE DESC'; $result=mysql_query($query); if (!$result) { die('Omlouvame se, nastala neocekavana chyba.'); } if (mysql_num_rows($result) == 0) { mysql_free_result($result); return Array(); } while ($row = mysql_fetch_assoc($result)) { $texts[$row['ID']] = $row; } mysql_free_result($result); return $texts; } } function loadOrders($login) { global $db_type; $texts = Array(); if ($db_type=='MySQL') { $query = 'SELECT * FROM RS_ORDERS WHERE LOGIN="' . $login . '" ORDER BY ID DESC'; $result=mysql_query($query); if (!$result) { die('Omlouvame se, nastala neocekavana chyba.'); } if (mysql_num_rows($result) == 0) { mysql_free_result($result); return Array(); } while ($row = mysql_fetch_assoc($result)) { $texts[$row['ID']] = $row; } mysql_free_result($result); return $texts; } } function SendCustomMail($mail, $subj, $body) { global $rs_sender; global $rs_email; $hheaders = 'MIME-Version: 1.0' . "\r\n"; $hheaders .= 'Content-type: text/plain; charset=iso-8859-2' . "\r\n"; $hheaders .= 'From: ' . AutoCzech($rs_sender, 'ISO-8859-2') . "\r\n"; $res = mail($mail, AutoCzech($subj, 'ISO-8859-2'), AutoCzech($body, 'ISO-8859-2'), $hheaders); return $res; } function availableLogin($user) { global $db_type; if ($db_type=="MySQL") { $hash = strtolower($password); $result=mysql_query("SELECT * FROM RS_CUSTOMERS WHERE LOGIN='$user' LIMIT 1"); if (!$result) { die('Omlouvame se, nastala neocekavana chyba.'); } $num = mysql_num_rows($result); mysql_free_result($result); return $num; } } function checkCustomer($user, $password) { global $db_type; if ($db_type=="MySQL") { $hash = strtolower($password); $result=mysql_query("SELECT * FROM RS_CUSTOMERS WHERE ACTIVE>0 AND LOGIN='$user' AND PASSWORD='$hash'"); // echo "SELECT * FROM RS_CUSTOMERS WHERE ACTIVE>0 AND LOGIN='$user' AND PASSWORD='$hash'"; if (!$result) { die('Omlouvame se, nastala neocekavana chyba.'); } $num = mysql_num_rows($result); $row = mysql_fetch_assoc($result); mysql_free_result($result); if ($num == 0) { return -1; } return $row; } } function forgotMail($address) { global $db_type; if ($db_type=="MySQL") { $address = mb_strtolower($address, 'UTF-8'); $result=mysql_query("SELECT * FROM RS_CUSTOMERS WHERE ACTIVE>0 AND SEND_MAIL='$address'"); if (!$result) { die('Omlouvame se, nastala neocekavana chyba.'); } $num = mysql_num_rows($result); $row = mysql_fetch_assoc($result); mysql_free_result($result); if ($num == 0) { return -1; } return $row; } } function addCustomer($login, $password, $bill_mail, $bill_firm, $bill_name, $bill_street, $bill_city, $bill_zipcode, $bill_phone, $bill_fax, $bill_ic, $bill_dic, $bill_country, $bill_dph, $date_added) { global $db_type; $password = mb_strtolower($password, 'UTF-8'); $bill_mail = mb_strtolower($bill_mail, 'UTF-8'); if ($db_type=='MySQL') { if (!mysql_query("INSERT INTO RS_CUSTOMERS (LOGIN, PASSWORD, ACTIVE, SEND_MAIL, BILL_FIRM, BILL_NAME, BILL_STREET, BILL_CITY, BILL_ZIPCODE, BILL_PHONE, BILL_FAX, BILL_IC, BILL_DIC, BILL_COUNTRY, BILL_DPH, DATE_ADDED) VALUES ('$login', '$password', 1, '$bill_mail', '$bill_firm', '$bill_name', '$bill_street', '$bill_city', '$bill_zipcode', '$bill_phone', '$bill_fax', '$bill_ic', '$bill_dic', '$bill_country', $bill_dph, '$date_added')")) { die('Omlouvame se, nastala neocekavana chyba.'); //die(mysql_error()); } return mysql_affected_rows(); } } function addOrder($login, $bill_mail, $bill_firm, $bill_name, $bill_street, $bill_city, $bill_zipcode, $bill_phone, $bill_fax, $bill_ic, $bill_dic, $bill_country, $bill_dph, $date_added, $send_name, $send_firm, $send_street, $send_city, $send_zip, $send_country, $send_phone, $sdeliverytype, $sdeliveryname, $sdeliveryprice, $items, $sum, $note, $langcode, $paytype) { global $db_type; global $rs_currency; $bill_mail = mb_strtolower($bill_mail, 'UTF-8'); if ($db_type=='MySQL') { $sdeliverytype = (int) $sdeliverytype; $sdeliveryprice = (float) $sdeliveryprice; $paytype = (int) $paytype; if (!mysql_query("INSERT INTO RS_ORDERS (ID, LOGIN, SEND_MAIL, SEND_NAME, SEND_FIRM, SEND_PHONE, SEND_STREET, SEND_ZIPCODE, SEND_CITY, SEND_COUNTRY, BILL_NAME, BILL_STREET, BILL_ZIPCODE, BILL_CITY, BILL_COUNTRY, BILL_FIRM, BILL_PHONE, BILL_FAX, BILL_IC, BILL_DIC, BILL_DPH, DATE_ADDED, DELIVERYTYPE, DELIVERYNAME, DELIVERYPRICE, PAYTYPE, NOTE, SUM) VALUES ('', '$login', '$bill_mail', '$send_name', '$send_firm', '$send_phone', '$send_street', '$send_zip', '$send_city', '$send_country', '$bill_name', '$bill_street', '$bill_zipcode', '$bill_city', '$bill_country', '$bill_firm', '$bill_phone', '$bill_fax', '$bill_ic', '$bill_dic', '$bill_dph', '$date_added', $sdeliverytype, '$sdeliveryname', $sdeliveryprice, $paytype, '$note', $sum)")) { die('Omlouvame se, nastala neocekavana chyba.'); // die(mysql_error()); } $id = mysql_insert_id(); $currency = $rs_currency[$langcode]; foreach ($items as $key => $val) { $arr = explode('#', $key); // echo $arr[0]; $it = item_get($arr[0]); $iid = $arr[0]; $price1 = $it['PRICE1']; $price2 = $it['PRICE2']; $code = $it['CODE']; $name = $it['NAME']; $varstr = ''; $vars = explode(',', $it['VARIANTS']); if (($it['VARIANTS']) && (count($arr)>1)) $varstr = ' (' . $vars[$arr[1]-1] . ')'; // echo "INSERT INTO RS_ORDERITEMS (ID, ITEMID, ORDERID, PIECES, PRICE1, PRICE2, CURRENCY, NAME) VALUES ('', $iid, $id, $val, $price1, $price2, '$currency', '$name')"; if (!mysql_query("INSERT INTO RS_ORDERITEMS (ID, ITEMID, ORDERID, PIECES, PRICE1, PRICE2, CURRENCY, NAME, CODE) VALUES ('', $iid, $id, $val, $price1, $price2, '$currency', '$name $varstr', '$code')")) { die('Omlouvame se, nastala neocekavana chyba.'); // die(mysql_error()); } } return $id; } } function modCustomer($login, $bill_mail, $bill_firm, $bill_name, $bill_street, $bill_city, $bill_zipcode, $bill_phone, $bill_fax, $bill_ic, $bill_dic, $bill_country, $bill_dph, $mailinglist, $mailinhtml) { global $db_type; $bill_mail = mb_strtolower($bill_mail, 'UTF-8'); if ($db_type=='MySQL') { if (!mysql_query("UPDATE RS_CUSTOMERS SET SEND_MAIL='$bill_mail', BILL_FIRM='$bill_firm', BILL_NAME='$bill_name', BILL_STREET='$bill_street', BILL_CITY='$bill_city', BILL_ZIPCODE='$bill_zipcode', BILL_PHONE='$bill_phone', BILL_FAX='$bill_fax', BILL_IC='$bill_ic', BILL_DIC='$bill_dic', BILL_COUNTRY='$bill_country',BILL_DPH=$bill_dph, MAILINGLIST=$mailinglist, MAILINHTML=$mailinhtml WHERE LOGIN='$login'")) { die('Omlouvame se, nastala neocekavana chyba.'); } return mysql_affected_rows(); } } function removeMail($bill_mail) { global $db_type; $bill_mail = mb_strtolower($bill_mail, 'UTF-8'); if ($db_type=='MySQL') { if (!mysql_query("DELETE FROM RS_MAILINGLIST WHERE MAIL='$bill_mail'")) { die('Omlouvame se, nastala neocekavana chyba.'); } $rs = mysql_affected_rows(); if (!mysql_query("UPDATE RS_CUSTOMERS SET MAILINGLIST=-1 WHERE SEND_MAIL='$bill_mail'")) { die('Omlouvame se, nastala neocekavana chyba.'); } return $rs+mysql_affected_rows(); } } function registerMail($bill_mail, $mailinglist, $mailinhtml) { global $db_type; $bill_mail = mb_strtolower($bill_mail, 'UTF-8'); if ($db_type=='MySQL') { if (!mysql_query("UPDATE RS_CUSTOMERS SET MAILINGLIST=-1 WHERE SEND_MAIL='$bill_mail'")) { die('Omlouvame se, nastala neocekavana chyba.'); // die(mysql_error()); } if (!mysql_query("UPDATE RS_CUSTOMERS SET MAILINGLIST=$mailinglist, MAILINHTML=$mailinhtml WHERE SEND_MAIL='$bill_mail'")) { die('Omlouvame se, nastala neocekavana chyba.'); // die(mysql_error()); } $rw1 = mysql_affected_rows(); if (!mysql_query("UPDATE RS_MAILINGLIST SET MAILINGLIST=-1 WHERE MAIL='$bill_mail'")) { die('Omlouvame se, nastala neocekavana chyba.'); // die(mysql_error()); } if (!mysql_query("UPDATE RS_MAILINGLIST SET MAILINGLIST=$mailinglist, MAILINHTML=$mailinhtml WHERE MAIL='$bill_mail'")) { die('Omlouvame se, nastala neocekavana chyba.'); // die(mysql_error()); } $rw = $rw1 + mysql_affected_rows(); if ($rw==0) { if (!mysql_query("INSERT INTO RS_MAILINGLIST (ID, MAIL, MAILINGLIST, MAILINHTML) VALUES ('', '$bill_mail', '$mailinglist', '$mailinhtml');")) { die('Omlouvame se, nastala neocekavana chyba.'); // die(mysql_error()); } return mysql_affected_rows(); } return rw; } } session_cache_limiter('private, must-revalidate'); session_start(); require '__configs/ht_setup.inc'; require '__utils/ht_misc.inc'; require '__smarty/Smarty.class.php'; db_connect(); $smarty = new Smarty; $smarty->template_dir = '__templates/'; $smarty->compile_dir = '__templates_c/'; $smarty->config_dir = '__configs/'; $smarty->cache_dir = '__cache/'; $smarty->compile_check = true; $smarty->debugging = false; $__tconfig = parse_ini_file('__configs/index.conf', true); $sections = loadSections($__tconfig['.Sections'], 'cs'); $cathegories = loadCathegories(); if (!session_is_registered($rs_code . 'userlangcode')) { session_register($rs_code . 'userlangcode'); $_SESSION[$rs_code . 'userlangcode'] = $__tconfig['.Informations']['DefaultLanguage']; $lcode = $__tconfig['.Informations']['DefaultLanguage']; } else { $lcode = $_SESSION[$rs_code . 'userlangcode']; } if (!session_is_registered($rs_code . 'customerlogin')) { session_register($rs_code . 'customerlogin'); $_SESSION[$rs_code . 'customerlogin'] = ''; $customerlogin = ''; } else { $customerlogin = $_SESSION[$rs_code . 'customerlogin']; } if (!session_is_registered($rs_code . $lcode . 'basket')) { session_register($rs_code . $lcode . 'basket'); $basket = Array(); $_SESSION[$rs_code . 'basket'] = serialize($basket); } else { $basket = unserialize($_SESSION[$rs_code . $lcode . 'basket']); } if (!session_is_registered($rs_code . $lcode . 'compare')) { session_register($rs_code . $lcode . 'compare'); $comparator = Array(); $_SESSION[$rs_code . 'compare'] = serialize($comparator); } else { $comparator = unserialize($_SESSION[$rs_code . $lcode . 'compare']); } // HANDLE CUSTOMER LOGIN if ($_GET['clogin']) { $user = mb_strtolower($_POST['Login'], 'UTF-8'); $pwd = $_POST['Password']; if (checkCustomer($user, $pwd)==-1) { $smarty->assign('CustomerLoginFailed', '1'); } else { $_SESSION[$rs_code . 'customerlogin'] = $user; $customerlogin = $user; } } if ($_GET['remove']) { $remail = ''; $showtexts = false; if ($_POST['Email']) $remail = $_POST['Email']; if ($_GET['Email']) $remail = $_GET['Email']; if ($_POST['MailInHTML']=='on') $mailinhtml=1; else $mailinhtml = 0; if ($_POST['add']) { registerMail($remail, (int) $_POST['MailingList'], $mailinhtml); $smarty->assign('CustomerMailAddSuccess', '1'); } else { if (removeMail($remail)>0) { $smarty->assign('CustomerMailRemoveSuccess', '1'); } else { $smarty->assign('CustomerMailRemoveFail', '1'); $smarty->assign('RemoveMailForm', 1); } } } if ($_GET['forgot']) { $res = forgotMail($_POST['Email']); $showtexts = false; if ($res == -1) { $smarty->assign('ForgotPasswordSendFail', '1'); $smarty->assign('ForgotPasswordMailForm', 1); } else { $mail = $res['SEND_MAIL']; $subj = $rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_forgot_subj']; $cnt = sprintf($rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_forgot_cnt'], $res['LOGIN'], $res['PASSWORD']); SendCustomMail($mail, $subj, $cnt); $smarty->assign('ForgotPasswordSendSuccess', '1'); } } if ($_GET['logout']) { $_SESSION[$rs_code . 'customerlogin'] = ''; $customerlogin = ''; } if ($_GET['clearcart']) { $basket = Array(); $_SESSION[$rs_code . $lcode . 'basket'] = serialize($basket); } if ($_GET['additem']) { $amount = 1; if (key_exists('pcs', $_POST)) $amount = (int) $_POST['pcs']; $iid = (int) $_GET['additem'] . '#' . $_POST['variant']; if (key_exists($iid, $basket)) { $basket[$iid]+=$amount; } else { $basket[$iid] = $amount; } $_SESSION[$rs_code . $lcode . 'basket'] = serialize($basket); } if ($_GET['addcompare']) { $iid = (int) $_GET['addcompare']; if (!in_array($iid, $comparator)) { $comparator[] = $iid; } $_SESSION[$rs_code . $lcode . 'compare'] = serialize($comparator); } if ($_GET['delcompare']) { $iid = (int) $_GET['delcompare']; //print_r($comparator); foreach ($comparator as $key => $val) if ($comparator[$key]==$iid) unset($comparator[$key]); $_SESSION[$rs_code . $lcode . 'compare'] = serialize($comparator); } if ($_GET['cancel']) { $cid = (int) $_GET['cancel']; if (cancelOrder($cid)) { $smarty->assign('CancelOrderSuccess', '1'); $us = customer_get($_SESSION[$rs_code . 'customerlogin']); $mail = $us['SEND_MAIL']; $subj = $rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_cancel_subj']; $cnt = sprintf($rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_cancel_cnt'], $cid); SendCustomMail($rs_email, $subj, $cnt); SendCustomMail($mail, $subj, $cnt); } else { $smarty->assign('CancelOrderFail', '1'); } } if ($_GET['updateitem']) { foreach ($basket as $key => $value) { if ($_POST['recalc']) if (key_exists('amount_' . $key, $_POST)) $basket[$key] = (int) $_POST['amount_' . $key]; if ($_POST['remove']) if (key_exists('remitem_' . $key, $_POST)) $basket[$key] = 0; } $basket = array_filter($basket); $_SESSION[$rs_code . $lcode . 'basket'] = serialize($basket); } // HANDLE CUSTOMER REGISTRATION if ($_GET['creg']) { $showtexts = false; $user = mb_strtolower($_POST['Login'], 'UTF-8'); $pwd = $_POST['Password']; $mail = $_POST['Email']; $company = $_POST['Company']; $name = $_POST['Name']; $address = $_POST['Address']; $city = $_POST['City']; $country = $_POST['Country']; $zip = $_POST['Zip']; $phone = $_POST['Phone']; $fax = $_POST['Fax']; $ic = $_POST['Ic']; $dic = $_POST['Dic']; if ($_POST['VAT']=='on') $VAT=1; else $VAT=0; if (availableLogin($user)>0) { $smarty->assign('RegistrationForm', 1); $smarty->assign('CREG_LoginUsed', 1); $smarty->assign('CREG_Login', $user); $smarty->assign('CREG_Password', $pwd); $smarty->assign('CREG_Email', $mail); $smarty->assign('CREG_Company', $company); $smarty->assign('CREG_Name', $name); $smarty->assign('CREG_Address', $address); $smarty->assign('CREG_City', $city); $smarty->assign('CREG_Country', $country); $smarty->assign('CREG_Zip', $zip); $smarty->assign('CREG_Phone', $phone); $smarty->assign('CREG_Fax', $fax); $smarty->assign('CREG_Ic', $ic); $smarty->assign('CREG_Dic', $dic); $smarty->assign('CREG_VAT', $VAT); } else { if (!addCustomer($user, $pwd, $mail, $company, $name, $address, $city, $zip, $phone, $fax, $ic, $dic, $rs_country, $VAT, date('Y-m-d H:i:s'))) { $smarty->assign('RegistrationForm', 1); $smarty->assign('CREG_RegFailed', 2); $smarty->assign('CREG_Login', $user); $smarty->assign('CREG_Password', $pwd); $smarty->assign('CREG_Email', $mail); $smarty->assign('CREG_Company', $company); $smarty->assign('CREG_Country', $country); $smarty->assign('CREG_Name', $name); $smarty->assign('CREG_Address', $address); $smarty->assign('CREG_City', $city); $smarty->assign('CREG_Zip', $zip); $smarty->assign('CREG_Phone', $phone); $smarty->assign('CREG_Fax', $fax); $smarty->assign('CREG_Ic', $ic); $smarty->assign('CREG_Dic', $dic); $smarty->assign('CREG_VAT', $VAT); } else { $_SESSION[$rs_code . 'customerlogin'] = $user; $smarty->assign('CREG_RegSucceeded', 1); $customerlogin = $user; $subj = $rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_reg_subj']; $cnt = sprintf($rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_reg_cnt'], $user, $pwd); SendCustomMail($mail, $subj, $cnt); } } } // HANDLE CUSTOMER PROPERTIES CHANGE if ($_GET['cprops']) { $showtexts = false; $mail = $_POST['Email']; $company = $_POST['Company']; $name = $_POST['Name']; $address = $_POST['Address']; $city = $_POST['City']; $country = $_POST['Country']; $zip = $_POST['Zip']; $phone = $_POST['Phone']; $fax = $_POST['Fax']; $ic = $_POST['Ic']; $dic = $_POST['Dic']; $mailinglist = $_POST['MailingList']; if ($_POST['mailinhtml']=='on') $mailinhtml = 1; else $mailinhtml = 0; if ($_POST['VAT']=='on') $VAT=1; else $VAT=0; if (modCustomer($_SESSION[$rs_code . 'customerlogin'], $mail, $company, $name, $address, $city, $zip, $phone, $fax, $ic, $dic, $rs_country, $VAT, $mailinglist, $mailinhtml)) { $smarty->assign('CUST_MODIFY_Success', 1); } else { $smarty->assign('CUST_MODIFY_Fail', 1); } } // HANDLE CUSTOMER PASSWORD CHANGE if ($_GET['cpass']) { $showtexts = false; $opwd = $_POST['Password']; $npwd = $_POST['NewPassword']; if (changePassword($_SESSION[$rs_code . 'customerlogin'], $opwd, $npwd)) { $res = customer_get($_SESSION[$rs_code . 'customerlogin']); $mail = $res['SEND_MAIL']; $subj = $rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_forgot_subj']; $cnt = sprintf($rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_forgot_cnt'], $res['LOGIN'], $res['PASSWORD']); SendCustomMail($mail, $subj, $cnt); $smarty->assign('CPWD_Success', 1); } else { $smarty->assign('CPWD_Fail', 1); $smarty->assign('ChangePasswordForm', 1); } } if ($_GET['lng']) { if (array_key_exists($_GET['lng'], $rs_languages)) $_SESSION[$rs_code . 'userlangcode'] = $_GET['lng']; $lcode = $_GET['lng']; } function produce($key, $smarty) { $links = loadLinks($key); $sitems = Array(); global $lcode; foreach ($links as $link) { if (($link['LANGUAGE_CODE']=='') || ($link['LANGUAGE_CODE']==$lcode)) { if (($link['LINKTYPE']==1) && ($link['INSERTTYPE']==1)) { $txt = texts_get($link['REFID']); $content .= $txt['CONTENT']; } if (($link['LINKTYPE']==2)) { array_push($sitems, Array('ID' => $link['ID'], 'Name' => $link['NAME'], 'Type' => 'Cathegory', 'Subsection' => produce($link['ID'], $smarty), 'Link' => 'index.php?view=' . $link['ID'])); } /* if (($link['LINKTYPE']==3)) { array_push($sitems, Array('Name' => $link['NAME'], 'Type' => 'File', 'Link' => 'file.php?get=' . $link['REFID'])); } if (($link['LINKTYPE']==1) && ($link['INSERTTYPE']==0)) { array_push($sitems, Array('Name' => $link['NAME'], 'Type' => 'Text', 'Link' => 'index.php?read=' . $link['REFID'])); }*/ } } return $sitems; } foreach ($sections as $key=>$value) { $struct = Array(); $links = loadLinks(0-$key); $content = ''; foreach ($links as $link) { // echo $link['LANGUAGE_CODE']==$lcode; if (($link['LANGUAGE_CODE']=='') || ($link['LANGUAGE_CODE']==$lcode)) { if (($link['LINKTYPE']==1)) { $txt = texts_get($link['REFID']); $content .= $txt['CONTENT']; $struct[] = $txt['CONTENT']; } } } $smarty->assign('Section' . $key, $content); $smarty->assign('Section' . $key . 'Struct', $struct); $arr = produce((0-$key), $smarty); $smarty->assign('Section' . $key . 'Items', $arr); } $readtext = 1; if ($_GET['view']) $readtext = $_GET['view']; else { $readtext = get_default(); $smarty->assign('FirstPage', true); } if ($_GET['viewitem']) { $showtexts = false; require_once('ht_item.inc'); } else { require_once('ht_art.inc'); } // ITEMS //// ORDER $ss = '&dosearch=' . $_GET['dosearch'] . '&searchtext=' . rawurlencode($_GET['searchtext']); $ss .= '&searchauthor=' . rawurlencode($_GET['searchauthor']); $ss .= '&searchcode=' . rawurlencode($_GET['searchcode']); $ss .= '&maxprice=' . rawurlencode($_GET['maxprice']); $ss .= '&minprice=' . rawurlencode($_GET['minprice']); $ss .= '&saleitem=' . rawurlencode($_GET['saleitem']); $ss .= '&searchdescription=' . rawurlencode($_GET['searchdescription']); $ss .= '&searchbyminprice=' . rawurlencode($_GET['searchbyminprice']); $ss .= '&searchbymaxprice=' . rawurlencode($_GET['searchbymaxprice']); $ss .= '&searchbyname=' . rawurlencode($_GET['searchbyname']); $ss .= '&searchbydescription=' . rawurlencode($_GET['searchbydescription']); $ss .= '&searchbycode=' . rawurlencode($_GET['searchbycode']); $ss .= '&searchbyauthor=' . rawurlencode($_GET['searchbyauthor']); $orderby = $rs_list_defaultorderby; $orderstyle = $rs_list_defaultorder; $listby = $rs_list_defaultlistby; $pagetab = 1; if (in_array((int) $_GET['listby'], $rs_list_listby)) $listby = $_GET['listby']; if ((int) $_GET['pagetab']>0) $pagetab = (int) $_GET['pagetab']; if ((int) $_POST['pagetab']>0) $pagetab = (int) $_POST['pagetab']; if ($_GET['orderby'] == 'PRICE2') $orderby = 'PRICE2'; // if ($_GET['orderby'] == 'DATE_ADDED') $orderby = 'DATE_ADDED'; if ($_GET['orderby'] == 'NAME') $orderby = 'NAME'; if ($_GET['orderby'] == 'AUTHOR') $orderby = 'AUTHOR'; if ($_GET['orderstyle'] == 'ASC') $orderstyle = 'ASC'; if ($_GET['orderstyle'] == 'DESC') $orderstyle = 'DESC'; // $smarty->assign('LIST_OrderByNews', 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&searchtext=' . rawurlencode($_GET['searchtext']) . '&orderby=DATE_ADDED&orderstyle=' . $orderstyle . '&listby=' . $listby); $smarty->assign('LIST_OrderByPrice', 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&searchtext=' . rawurlencode($_GET['searchtext']) . '&orderby=PRICE2&orderstyle=' . $orderstyle . '&searchadvanced=' . $_GET['searchadvanced'] . '&listby=' . $listby . $ss); $smarty->assign('LIST_OrderByName', 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&searchtext=' . rawurlencode($_GET['searchtext']) . '&orderby=NAME&orderstyle=' . $orderstyle . '&searchadvanced=' . $_GET['searchadvanced'] . '&listby=' . $listby. $ss); $smarty->assign('LIST_OrderByAuthor', 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&searchtext=' . rawurlencode($_GET['searchtext']) . '&orderby=AUTHOR&orderstyle=' . $orderstyle . '&searchadvanced=' . $_GET['searchadvanced'] . '&listby=' . $listby. $ss); $smarty->assign('LIST_OrderAscending', 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&searchtext=' . rawurlencode($_GET['searchtext']) . '&orderby=' . $orderby . '&searchadvanced=' . $_GET['searchadvanced'] . '&orderstyle=ASC&listby=' . $listby. $ss); $smarty->assign('LIST_OrderDescending', 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&searchtext=' . rawurlencode($_GET['searchtext']) . '&orderby=' . $orderby . '&searchadvanced=' . $_GET['searchadvanced'] . '&orderstyle=DESC&listby=' . $listby. $ss); $smarty->assign('LIST_OrderBy', $orderby); $smarty->assign('LIST_ListBy', $listby); $smarty->assign('LIST_OrderStyle', $orderstyle); $outs = Array(); foreach ($rs_list_listby as $val) { $outs[$val] = 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&searchtext=' . rawurlencode($_GET['searchtext']) . '&orderby=' . $orderby . '&orderstyle=' . $orderstyle . '&searchadvanced=' . $_GET['searchadvanced'] . '&listby=' . $val . $ss; } $smarty->assign('LIST_ListByLinks', $outs); if ($_GET['dosearch']) { $showtexts = false; if ($_GET['searchadvanced']) { if ($_GET['searchbyname']=='on') { $searchbyname = 1; $smarty->assign('SearchByName', 1); } else $searchbyname = 0; if ($_GET['searchbydescription']=='on') { $searchbydescription = 1; $smarty->assign('SearchByDescription', 1); } else $searchbydescription = 0; if ($_GET['searchinsales']=='on') { $saleitem = 1; $smarty->assign('SearchBySale', 1); } else $saleitem = 0; if ($_GET['searchbyminprice']=='on') { $smarty->assign('SearchByMinPrice', 1); $searchbyminprice = 1; } else $searchbyminprice = 0; if ($_GET['searchbymaxprice']=='on') { $smarty->assign('SearchByMaxPrice', 1); $searchbymaxprice = 1; } else $searchbymaxprice = 0; if ($_GET['searchbycode']=='on') { $smarty->assign('SearchByCode', 1); $searchbycode = 1; } else $searchbycode = 0; if ($_GET['searchbyauthor']=='on') { $smarty->assign('SearchByAuthor', 1); $searchbyauthor = 1; } else $searchbyauthor = 0; $smarty->assign('Search_Author', $_GET['searchauthor']); $smarty->assign('Search_Text', $_GET['searchtext']); $smarty->assign('Search_Code', $_GET['searchcode']); $smarty->assign('Search_MinPrice', $_GET['minprice']); $smarty->assign('Search_MaxPrice', $_GET['maxprice']); $smarty->assign('Search_Description', $_GET['searchdescription']); $out = loadAdvancedSearchItems($searchbyname, $_GET['searchtext'],$searchbydescription, $_GET['searchdescription'],$searchbycode, $_GET['searchcode'],$searchbyauthor, $_GET['searchauthor'],$searchbyminprice, $_GET['minprice'],$searchbymaxprice, $_GET['maxprice'],$saleitem, 'RS_ITEMS.' . $orderby, $orderstyle); } else { $smarty->assign('SearchByName', 1); if (strlen($_GET['searchtext'])>0) $out = loadSearchItems($_GET['searchtext'], 'RS_ITEMS.' . $orderby, $orderstyle); else $out = Array(); } $smarty->assign('SearchForm', 1); $smarty->assign('Search_Text', $_GET['searchtext']); } else if ($_GET['show']=='news') { $showtexts = false; $smarty->assign('LIST_News', 1); if ($_GET['view']>0) $out = loadItems($readtext, 'RS_ITEMS.' . $orderby, $orderstyle, 1); else $out = loadItems(0, 'RS_ITEMS.' . $orderby, $orderstyle, 1); } else if ($_GET['show']=='mostwanted') { $showtexts = false; $smarty->assign('LIST_News', 1); if ($_GET['view']>0) $out = loadItems($readtext, 'RS_ITEMS.' . $orderby, $orderstyle, 2); else $out = loadItems(0, 'RS_ITEMS.' . $orderby, $orderstyle, 2); } else { $out = loadItems($readtext, 'RS_ITEMS.' . $orderby, $orderstyle); } $cntout = count($out); $pages = Array(); for ($a = 1; ($a-1)*$listby<$cntout; $a++) { $pages[$a] = 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&orderby=' . $orderby . '&orderstyle=' . $orderstyle . '&listby=' . $listby . '&searchadvanced=' . $_GET['searchadvanced'] . '&pagetab=' . $a . $ss; } //print_r($pages); $smarty->assign('LIST_ListByPages', $pages); if (($pagetab)*$listby<$cntout) $smarty->assign('LIST_ListNextPage', 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&orderby=' . $orderby . '&orderstyle=' . $orderstyle . '&listby=' . $listby . '&searchadvanced=' . $_GET['searchadvanced'] . '&pagetab=' . ($pagetab+1) . $ss); if ($pagetab > 1) $smarty->assign('LIST_ListPrevPage', 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&orderby=' . $orderby . '&orderstyle=' . $orderstyle . '&listby=' . $listby . '&searchadvanced=' . $_GET['searchadvanced'] . '&pagetab=' . ($pagetab-1) . $ss); $smarty->assign('LIST_ListGoToPage', 'index.php?show=' . $_GET['show'] . '&view=' . $readtext . '&orderby=' . $orderby . '&orderstyle=' . $orderstyle . '&listby=' . $listby . '&searchadvanced=' . $_GET['searchadvanced'] . $ss); $smarty->assign('LIST_Page', $pagetab); $smarty->assign('LIST_Number', $cntout); $maxc = min(($pagetab)*$listby, $cntout); $res = Array(); for ($a = ($pagetab-1)*$listby; $a < $maxc; $a++) { $out[$a]['LINK'] = 'index.php?viewitem=' . $out[$a]['ID']; if ($out[$a]['VARIANTS']) { $vararr = explode(',', $out[$a]['VARIANTS']); for ($b = 0; $b< count($vararr); $b++) { $vararr[$b] = Array('ID'=>($b+1), 'Name' => $vararr[$b], 'BuyLink' => 'index.php?additem=' . $$out[$a]['ID'] . '&variant='. ($b+1)); } } $out[$a]['Variants'] = $vararr; $out[$a]['LinkCompare'] = 'index.php?addcompare=' . $out[$a]['ID']; if (file_exists($dir_photos . 'i' . $out[$a]['ID'] . '_prev.jpg')) $out[$a]['IMGLINK'] = $dir_photos . 'i' . $out[$a]['ID'] . '_prev.jpg'; else $out[$a]['IMGLINK'] = $out[$a]['LINK']; /* if ($out[$a]['VARIANTS']) $out[$a]['LINKBUY'] = 'index.php?viewitem=' . $out[$a]['ID']; else */ $out[$a]['LINKBUY'] = 'index.php?additem=' . $out[$a]['ID']; if (file_exists($dir_photos . 'i' . $out[$a]['ID'] . '_icon.jpg')) $out[$a]['THUMBNAIL'] = $dir_photos . 'i' . $out[$a]['ID'] . '_icon.jpg'; $res[] = $out[$a]; } $smarty->assign('Items', $res); $smarty->assign('CurrentLanguage', $lcode); $smarty->assign('ActualPage', 'ViewCategory'); $smarty->assign('PageID', $readtext); $smarty->assign('Subsection', $subsection); if (($_GET['show']=='basket') || ($_GET['additem'])) { $smarty->assign('ShowBasket', 1); $showtexts = false; } if (($_GET['show']=='props') || ($_GET['cprops'])) { $smarty->assign('CustomerPropertiesForm', 1); $showtexts = false; $smarty->assign('CUST', customer_get($_SESSION[$rs_code . 'customerlogin'])); $smarty->assign('CustomerPropertiesFormLink', 'index.php?cprops=1'); } if ($_GET['show']=='buy1') { $smarty->assign('FinishBuyForm', 1); $showtexts = false; $smarty->assign('CUST', customer_get($_SESSION[$rs_code . 'customerlogin'])); } if (($_GET['addcompare']) || ($_GET['delcompare']) || ($_GET['show']=='comparator')) { $smarty->assign('ComparatorForm', 1); $showtexts = false; } if (($_GET['cancel']) || ($_GET['show']=='orders')) { $smarty->assign('OrdersForm', 1); $showtexts = false; $smarty->assign('Statuses', $rs_order_status[$_SESSION[$rs_code . 'userlangcode']]); $myorders = loadOrders($_SESSION[$rs_code . 'customerlogin']); foreach ($myorders as $key => $val) { if ($val['STATUS']!='1') { $myorders[$key]['CANCELLINK'] = 'index.php?cancel=' . $val['ID']; } } $smarty->assign('Orders', $myorders); } if ($_GET['show']=='buy2') { $smarty->assign('FinishBuyForm2', 1); $showtexts = false; $deliveries = loadDelivery($_SESSION[$rs_code . 'userlangcode'], $_POST['Country']); //echo $_SESSION[$rs_code . 'userlangcode']; $company = $_POST['Company']; $mail = $_POST['Email']; $name = $_POST['Name']; $address = $_POST['Address']; $firm = $_POST['Company']; $city = $_POST['City']; $country = $_POST['Country']; $zip = $_POST['Zip']; $phone = $_POST['Phone']; $fax = $_POST['Fax']; $ic = $_POST['Ic']; $dic = $_POST['Dic']; if ($_POST['VAT']) $VAT = 1; else $VAT=0; $smarty->assign('DeliveryTypes', $deliveries); $cst = Array(); $cst['SEND_MAIL'] = $mail; $cst['BILL_FIRM'] = $firm; $cst['BILL_COUNTRY'] = $country; $cst['BILL_NAME'] = $name; $cst['BILL_STREET'] = $address; $cst['BILL_CITY'] = $city; $cst['BILL_ZIPCODE'] = $zip; $cst['BILL_PHONE'] = $phone; $cst['BILL_FAX'] = $fax; $cst['BILL_IC'] = $ic; $cst['BILL_DIC'] = $dic; $cst['BILL_DPH'] = $VAT; $smarty->assign('CUST', $cst); } if ($_GET['show']=='buy3') { $smarty->assign('FinishBuyForm3', 1); $showtexts = false; $deliveries = loadDelivery($_SESSION[$rs_code . 'userlangcode'], $_POST['Country']); $smarty->assign('DeliveryTypes', $deliveries); $company = $_POST['Company']; $mail = $_POST['Email']; $name = $_POST['Name']; $address = $_POST['Address']; $firm = $_POST['Company']; $city = $_POST['City']; $country = $_POST['Country']; $zip = $_POST['Zip']; $phone = $_POST['Phone']; $fax = $_POST['Fax']; $ic = $_POST['Ic']; $dic = $_POST['Dic']; $VAT = $_POST['VAT']; $sdelivery = $_POST['SDelivery']; $scompany = $_POST['SCompany']; $sname = $_POST['SName']; $saddress = $_POST['SAddress']; $sfirm = $_POST['SCompany']; $scity = $_POST['SCity']; $scountry = $_POST['SCountry']; $szip = $_POST['SZip']; $sphone = $_POST['SPhone']; $cst = Array(); $cst['SEND_MAIL'] = $mail; $cst['BILL_FIRM'] = $firm; $cst['BILL_COUNTRY'] = $country; $cst['BILL_NAME'] = $name; $cst['BILL_STREET'] = $address; $cst['BILL_CITY'] = $city; $cst['BILL_ZIPCODE'] = $zip; $cst['BILL_PHONE'] = $phone; $cst['BILL_FAX'] = $fax; $cst['BILL_IC'] = $ic; $cst['BILL_DIC'] = $dic; $cst['BILL_DPH'] = $VAT; $cst['SEND_FIRM'] = $sfirm; $cst['SDELIVERY'] = $sdelivery; $cst['SEND_COUNTRY'] = $scountry; $cst['SEND_NAME'] = $sname; $cst['SEND_STREET'] = $saddress; $cst['SEND_CITY'] = $scity; $cst['SEND_ZIPCODE'] = $szip; $cst['SEND_PHONE'] = $sphone; $smarty->assign('CUST', $cst); } if ($_GET['show']=='buy4') { $smarty->assign('FinishBuyForm4', 1); $deliveries = loadDelivery($_SESSION[$rs_code . 'userlangcode'], $_POST['Country']); $showtexts = false; $company = $_POST['Company']; $mail = $_POST['Email']; $name = $_POST['Name']; $address = $_POST['Address']; $firm = $_POST['Company']; $city = $_POST['City']; $country = $_POST['Country']; $zip = $_POST['Zip']; $phone = $_POST['Phone']; $fax = $_POST['Fax']; $ic = $_POST['Ic']; $dic = $_POST['Dic']; $VAT = $_POST['VAT']; $sdelivery = $_POST['SDelivery']; $scompany = $_POST['SCompany']; $sname = $_POST['SName']; $saddress = $_POST['SAddress']; $sfirm = $_POST['SCompany']; $scity = $_POST['SCity']; $scountry = $_POST['SCountry']; $szip = $_POST['SZip']; $sphone = $_POST['SPhone']; $note = $_POST['Note']; $sum = 0.0; $lines = ''; foreach ($basket as $key => $val) { $vala = explode('#', $key); $it = item_get($vala[0]); $sum+= $it['PRICE2']*$val; $varstr = ''; $vars = explode(',', $it['VARIANTS']); if (($it['VARIANTS']) && (count($vala)>1)) $varstr = ' (' . $vars[$vala[1]-1] . ')'; $lines .= sprintf($rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_order_line'], $it['NAME'] . $varstr, $val, $it['PRICE2']*$val); } if ($_SESSION[$rs_code . 'customerlogin']) $logu = $_SESSION[$rs_code . 'customerlogin']; else $logu = ''; $res = addOrder($logu, $mail, $firm, $name, $address, $city, $zip, $phone, $fax, $ic, $dic, $country, $VAT, date('Y-m-d H:i:s'), $sname, $sfirm, $saddress, $scity, $szip, $scountry, $sphone, $sdelivery, $deliveries[$sdelivery]['NAME'], $deliveries[$sdelivery]['PRICE'], $basket, $sum, $note, $_SESSION[$rs_code . 'userlangcode'], $deliveries[$sdelivery]['PAYBEFORE']); if ($res>0) { $basket = Array(); $_SESSION[$rs_code . $lcode . 'basket'] = serialize($basket); $smarty->assign('OrderSent_Success', 1); if ($deliveries[$sdelivery]['PAYBEFORE']) { $smarty->assign('Pay', 1); $smarty->assign('Pay_Account', $rs_shop_account); $smarty->assign('Pay_Amount', $sum); $smarty->assign('Pay_Symbol', $res); } $body = sprintf($rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_order_cnt'], $res, $logu, $mail, $name, $firm, $address, $city, $zip, $country, $ic, $dic, $VAT, $phone, $fax, $sname, $sfirm, $saddress, $scity, $szip, $scountry, $phone, $deliveries[$sdelivery]['NAME'], $deliveries[$sdelivery]['PRICE'], ($sum+$deliveries[$sdelivery]['PRICE']), $lines); // echo $rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_order_cnt']; // echo $res, $mail, $logu, $name, $firm, $address, $city, $zip, $country, $ic, $dic, $VAT, $phone, $fax, $sname, $sfirm, $saddress, $scity, $szip, $scountry, $phone, $deliveries[$sdelivery]['NAME'], $deliveries[$sdelivery]['PRICE'], $lines, ($sum+$deliveries[$sdelivery]['PRICE']); SendCustomMail($mail, $rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_order_subj'], $body); SendCustomMail($rs_email, $rs_lng[$_SESSION[$rs_code . 'userlangcode']]['mail_order_subj'], $body); $showtexts = false; if ($mail) $smarty->assign('FastMailRemove', 'index.php?remove=1&Email=' . rawurlencode($mail)); } else { $showtexts = false; $smarty->assign('OrderSent_Fail', 1); } } if ($_GET['show']=='password') { $smarty->assign('ChangePasswordForm', 1); $showtexts = false; $smarty->assign('ChangePasswordFormLink', 'index.php?cpass=1'); } $smarty->assign('CustomerPasswordLink', 'index.php?show=password'); // CART $basketitems = Array(); $pc = 0; $amount = 0; foreach ($basket as $key => $val) { $vala = explode('#', $key); $it = item_get($vala[0]); $varars = explode(',', $it['VARIANTS']); //print_r($vala); //print_r($varars); $varstr = ''; if (($it['VARIANTS']) && (count($vala)>1)) $varstr = ' (' . $varars[$vala[1]-1] . ')'; $basketitems[] = Array('ID' => $key, 'PIECES' => $val, 'CODE' => $it['CODE'], 'NAME' => $it['NAME'] . $varstr, 'PRICE2' => $it['PRICE2'], 'SUM' => $val*$it['PRICE2'], 'VARIANT' => $varars[$vala[1]-1], 'LINK' => 'index.php?viewitem=' . $it['ID']); $pc+=$val; $amount+= $it['PRICE2']*$val; } $smarty->assign('BasketItems', $basketitems); $smarty->assign('BasketFormUpdate', 'index.php?show=basket&updateitem=1'); // COMPARATOR $comparatoritems = Array(); foreach ($comparator as $val) { $it = item_get($val); $it['DELLINK'] = 'index.php?delcompare=' . $it['ID']; $it['LINK'] = 'index.php?viewitem=' . $it['ID']; $it['ORIGINALPRICE'] = $it['PRICE_ORIG']; if ($it['VARIANTS']) { $vararr = explode(',', $it['VARIANTS']); for ($b = 0; $b< count($vararr); $b++) { $vararr[$b] = Array('ID'=>($b+1), 'Name' => $vararr[$b], 'BuyLink' => 'index.php?additem=' . $it['ID'] . '&variant='. ($b+1)); } } $it['ItemVariants'] = $vararr; /* if ($it['VARIANTS']) $it['LINKBUY'] = 'index.php?viewitem=' . $it['ID']; else */ $it['LINKBUY'] = 'index.php?additem=' . $it['ID']; $thumb = ''; if (file_exists($dir_photos . 'i' . $it['ID'] . '_icon.jpg')) $thumb = $dir_photos . 'i' . $it['ID'] . '_icon.jpg'; $it['THUMBNAIL'] = $thumb; $preview = ''; if (file_exists($dir_photos . 'i' . $it['ID'] . '_prev.jpg')) $preview = $dir_photos . 'i' . $it['ID'] . '_prev.jpg'; $it['PREVIEW'] = $preview; $comparatoritems[] = $it; //$basketitems[] = Array('ID' => $key, 'PIECES' => $val, 'NAME' => $it['NAME'] . $varstr, 'PRICE2' => $it['PRICE2'], 'LINK' => 'index.php?viewitem=' . $it['ID']); } $smarty->assign('ComparatorItems', $comparatoritems); $smarty->assign('ComparatorItemsCount', count($comparatoritems)); $smarty->assign('Basket', $basket); //$smarty->assign('BasketPieces', count($basket)); $smarty->assign('BasketPieces', $pc); $smarty->assign('BasketLink', 'index.php?show=basket'); $smarty->assign('BasketAmount', $amount); if ($sdelivery) { $smarty->assign('CompletePrice', ($amount+$deliveries[$sdelivery]['PRICE'])); } // MISC $smarty->assign('HomeLink', 'index.php'); $smarty->assign('CustomerRegistrationLink', 'index.php?show=reg'); $smarty->assign('CustomerLoginLink', 'index.php?clogin=1'); $smarty->assign('ForgotPasswordLink', 'index.php?show=forgot'); $smarty->assign('CustomerLogin', $customerlogin); if ((!$_GET['dosearch']=='1') && ($cntout>0)) $smarty->assign('NewItemsLink', 'index.php?show=news&view=' . $readtext); else $smarty->assign('NewItemsLink', 'index.php?show=news'); if ((!$_GET['dosearch']=='1') && ($cntout>0)) $smarty->assign('MostWantedLink', 'index.php?show=mostwanted&view=' . $readtext); else $smarty->assign('MostWantedLink', 'index.php?show=mostwanted'); //$smarty->assign('MostWantedLink', 'index.php?show=mostwanted'); $smarty->assign('RegistrationFormLink', 'index.php?creg=1'); $smarty->assign('Countries', $rs_countries[$lcode]); $smarty->assign('CustomerLogoutLink', 'index.php?logout=1'); $smarty->assign('CustomerPropertiesLink', 'index.php?show=props'); $smarty->assign('RemoveMailFormLink', 'index.php?remove=1'); $smarty->assign('ForgotPasswordFormLink', 'index.php?forgot=1'); $smarty->assign('SearchFormLink', 'index.php?show=searchform'); $smarty->assign('CustomerOrdersLink', 'index.php?show=orders'); $smarty->assign('FinishBuy1', 'index.php?show=buy1'); $smarty->assign('ComparatorLink', 'index.php?show=comparator'); $smarty->assign('FinishBuy2', 'index.php?show=buy2'); $smarty->assign('FinishBuy3', 'index.php?show=buy3'); $smarty->assign('FinishBuy4', 'index.php?show=buy4'); // NEWS if ($_GET['dosearch']=='1') { $showtexts = false; $out = loadNewItems(0, $rs_newitems_selectfrom); } else { if ($cntout >0) $out = loadNewItems($readtext, $rs_newitems_selectfrom); else $out = loadNewItems(0, $rs_newitems_selectfrom); } $nitems = Array(); foreach ($out as $item) { $thumb = ''; if (file_exists($dir_photos . 'i' . $item['ID'] . '_icon.jpg')) $thumb = $dir_photos . 'i' . $item['ID'] . '_icon.jpg'; $nitems[] = Array('Name'=>$item['NAME'], 'Thumbnail' => $thumb, 'Link'=>'index.php?viewitem=' . $item['ID'], 'PriceInclVAT'=>$item['PRICE2']); } if ($rs_newitems_showitems>0) { shuffle($nitems); $nitems = array_slice($nitems, 0, $rs_newitems_showitems); } $smarty->assign('NewItems', $nitems); // MOSTWANTED if ($_GET['dosearch']=='1') { $showtexts = false; $out = loadMostWantedItems(0, $rs_mostwanted_selectfrom); } else { if ($cntout >0) $out = loadMostWantedItems($readtext, $rs_mostwanted_selectfrom); else $out = loadMostWantedItems(0, $rs_mostwanted_selectfrom); } $nitems = Array(); foreach ($out as $item) { $thumb = ''; if (file_exists($dir_photos . 'i' . $item['ID'] . '_icon.jpg')) $thumb = $dir_photos . 'i' . $item['ID'] . '_icon.jpg'; $nitems[] = Array('Name'=>$item['NAME'], 'Thumbnail' => $thumb, 'Link'=>'index.php?viewitem=' . $item['ID'], 'PriceInclVAT'=>$item['PRICE2']); } if ($rs_mostwanted_showitems>0) { shuffle($nitems); $nitems = array_slice($nitems, 0, $rs_mostwanted_showitems); } $smarty->assign('MostWantedItems', $nitems); // REG if ($_GET['show']=='reg') { $smarty->assign('RegistrationForm', 1); $showtexts = false; } if ($_GET['show']=='forgot') { $smarty->assign('ForgotPasswordForm', 1); $showtexts = false; } if ($_GET['show']=='remove') { $smarty->assign('RemoveMailForm', 1); $showtexts = false; } $smarty->assign('VARS_GET', $_GET); $smarty->assign('VARS_POST', $_POST); $out = Array(); for ($i = 0; $i < count($rs_mail_types[$_SESSION[$rs_code . 'userlangcode']]); $i++) { $out[$i+1] = $rs_mail_types[$_SESSION[$rs_code . 'userlangcode']][$i]; } $smarty->assign('MailChoices', $out); if ($showtexts) { $sec = mylink_get($readtext); $upper = Array(); $usec = $sec; while ($usec['REFCAT']>0) { $usec = mylink_get($usec['REFCAT']); $usec['LINK'] = 'index.php?view=' . $usec['ID']; if ($usec!=0) array_push($upper, $usec); } $smarty->assign('ActualSection', $sec); $smarty->assign('UpperSections', $upper); } if ($showtexts) $smarty->assign('Content', $content); $smarty->assign('MissingIcon', $rs_missing_icon); $smarty->register_function("advertising", "template_advertising"); $smarty->display('index.tpl'); db_close(); ?>