From e8fe9e4afd1db7e5ba05899dbab27d5ace2bce0f Mon Sep 17 00:00:00 2001 From: andryeyev Date: Mon, 21 Dec 2015 15:28:45 +0200 Subject: [PATCH] + format price.php --- price.php | 239 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------- 1 file changed, 142 insertions(+), 97 deletions(-) diff --git a/price.php b/price.php index 63124d4..1ab96af 100644 --- a/price.php +++ b/price.php @@ -1,110 +1,155 @@ db; -$objCatalogs = $setup->setupClass("Catalogs"); - function escapeLoc($loc){ - $patterns = array(); - $patterns[0] = '/&/'; - $patterns[1] = '/\'/'; - $patterns[2] = '/"/'; - $patterns[3] = '/>/'; - $patterns[4] = '/db; + $objCatalogs = $setup->setupClass ("Catalogs"); + +function escapeLoc ($loc) { - return preg_replace('/[^a-zа-яё\.\,\?\! 0-9]/i','',$string);; + $patterns = array (); + $patterns[0] = '/&/'; + $patterns[1] = '/\'/'; + $patterns[2] = '/"/'; + $patterns[3] = '/>/'; + $patterns[4] = '/db->getOne('select new_code from catalogs_modifications where active=1 and product_id=? and new_code<>""',array($product_id)); -} +function nohtml ($string) +{ + return preg_replace ('/[^a-zа-яё\.\,\?\! 0-9]/i', '', $string); +} -print''; -print""; -print"" . date("Y-m-d h:m") . ""; -print"ExtremStyle"; -print""; -print""; +function modCodeNew ($product_id) +{ + global $objCatalogs; + return $objCatalogs->db->getOne ('select new_code from catalogs_modifications where active=1 and product_id=? and new_code<>""', array ( + $product_id + )); +} +print ''; +print ""; +print "" . date ("Y-m-d h:m") . ""; +print "ExtremStyle"; +print ""; +print ""; -$res = $db->getAll("select * from catalogs_rubrics where is_xml=?",array(0),DB_FETCHMODE_ASSOC); -//print_r($res); -$rubrics = array(); -print""; -foreach($res as $row){ -$rubrics[] = $row['id']; -print""; -print"" . $row['id'] . ""; -print"" . $row['parent_id'] . ""; -print"" . $row['name'] . ""; -print""; +$res = $db->getAll ("select * from catalogs_rubrics where is_xml=?", array ( + 0 +), DB_FETCHMODE_ASSOC); +// print_r($res); +$rubrics = array (); +print ""; +foreach ($res as $row) +{ + $rubrics[] = $row['id']; + print ""; + print "" . $row['id'] . ""; + print "" . $row['parent_id'] . ""; + print "" . $row['name'] . ""; + print ""; } -print""; +print ""; -print""; -foreach($rubrics as $rub){ -$res = $db->getAll("select p.*,r.translit as rubric_translit,r.is_xml2,b.name as brend,r.list_name from catalogs_products p LEFT JOIN catalogs_rubrics r ON r.id=p.rubric_id LEFT JOIN catalogs_brends b ON b.id=p.brend_id where p.rubric_id=? and p.count_modifications>0",array($rub),DB_FETCHMODE_ASSOC); -foreach($res as $row){ -print""; -print"" . $row['id'] . ""; -print"" . $row['rubric_id'] . ""; -if($row['rubric_id']!=14055)print"0" . $row['id'] . ""; -print""; -print"" . htmlspecialchars(escapeLoc($row['brend'])) . ""; -$row['ph1'] = $objCatalogs->getFilterPh1($row['id']); -$f = $objCatalogs->viewFilterProduct($row['id']); -$f_arr = array(); -foreach($f as $_f){$f_arr[] = $_f['name'];} -$f_str = (count($f_arr)>0) ? implode(', ',$f_arr) : ''; -print"" . htmlspecialchars(escapeLoc($row['ph1'])) .' '. htmlspecialchars(escapeLoc($row['list_name'])) .' '. htmlspecialchars(escapeLoc($row['brend'])) .' '. htmlspecialchars(escapeLoc($row['name'])) . ' ' . htmlspecialchars(escapeLoc($f_str)) .' '. modCodeNew($row['id']).""; -print"" . htmlspecialchars(nohtml(stripcslashes($row['text']))) . ""; -print"http://extremstyle.ua/" . htmlspecialchars(escapeLoc($row['rubric_translit'])) . "-catalogs/" . htmlspecialchars(escapeLoc($row['translit'])) . "-" . $row['id'] . "/"; -print"http://extremstyle.ua/uploaded/pic/catalogs/products/" . $row['pic'] . ""; -print"" . round($row['cine'] - ($row['cine']*$row['salepc']/100)) . ""; -//print"" . $row['cine'] . ""; -print"" . $row['cine'] . ""; -print""; -print"На складе"; -print""; -IF($row['is_xml2']==1 && $row['rubric_id']!=14055){ -if($row['sex']==1)$sex = 'Мужской'; -elseif($row['sex']==2)$sex = 'Женский'; -elseif($row['sex']==3)$sex = 'Детский'; -elseif($row['sex']==4)$sex = 'Унисекс'; -else $sex = ''; -$res_m = $db->getAll("select * from catalogs_modifications where active=1 and product_id=?",array($row['id']),DB_FETCHMODE_ASSOC); -foreach($res_m as $row_m){ -print''.$row_m['size'].''; -print''.(($row['rubric_id']==14055)?$row_m['color']:$row_m['color2']).''; -print''.$sex.''; -print''; -print''; -print''.htmlspecialchars(escapeLoc($row['list_name'])).''; -print''; -print''; -print''; -} -} - -print""; -}} -print""; +print ""; + + foreach ($rubrics as $rub) + { + $res = $db->getAll (" + select p.*,r.translit as rubric_translit,r.is_xml2,b.name as brend,r.list_name + from catalogs_products p + LEFT JOIN catalogs_rubrics r ON r.id=p.rubric_id + LEFT JOIN catalogs_brends b ON b.id=p.brend_id + where p.rubric_id=? + and p.count_modifications>0", + array ( + $rub + ), DB_FETCHMODE_ASSOC); + + foreach ($res as $row) + { + print ""; + print "" . $row['id'] . ""; + print "" . $row['rubric_id'] . ""; + + if ($row['rubric_id'] != 14055) + print "0" . $row['id'] . ""; + + print ""; + print "" . htmlspecialchars (escapeLoc ($row['brend'])) . ""; + + $row['ph1'] = $objCatalogs->getFilterPh1 ($row['id']); + $f = $objCatalogs->viewFilterProduct ($row['id']); + $f_arr = array (); + foreach ($f as $_f) + { + $f_arr[] = $_f['name']; + } + + $f_str = (count ($f_arr) > 0) ? implode (', ', $f_arr) : ''; + print "" . htmlspecialchars (escapeLoc ($row['ph1'])) . ' ' . htmlspecialchars (escapeLoc ($row['list_name'])) . ' ' . htmlspecialchars (escapeLoc ($row['brend'])) . ' ' . htmlspecialchars (escapeLoc ($row['name'])) . ' ' . htmlspecialchars (escapeLoc ($f_str)) . ' ' . modCodeNew ($row['id']) . ""; + print "" . htmlspecialchars (nohtml (stripcslashes ($row['text']))) . ""; + print "http://extremstyle.ua/" . htmlspecialchars (escapeLoc ($row['rubric_translit'])) . "-catalogs/" . htmlspecialchars (escapeLoc ($row['translit'])) . "-" . $row['id'] . "/"; + print "http://extremstyle.ua/uploaded/pic/catalogs/products/" . $row['pic'] . ""; + print "" . round ($row['cine'] - ($row['cine'] * $row['salepc'] / 100)) . ""; + // print"" . $row['cine'] . ""; + print "" . $row['cine'] . ""; + print ""; + print "На складе"; + print ""; + + IF ($row['is_xml2'] == 1 && $row['rubric_id'] != 14055) + { + if ($row['sex'] == 1) + $sex = 'Мужской'; + elseif ($row['sex'] == 2) + $sex = 'Женский'; + elseif ($row['sex'] == 3) + $sex = 'Детский'; + elseif ($row['sex'] == 4) + $sex = 'Унисекс'; + else + $sex = ''; + + $res_m = $db->getAll (" + select * + from catalogs_modifications + where active=1 + and product_id=?", array ( + $row['id'] + ), DB_FETCHMODE_ASSOC); + + foreach ($res_m as $row_m) + { + print '' . $row_m['size'] . ''; + print '' . (($row['rubric_id'] == 14055) ? $row_m['color'] : $row_m['color2']) . ''; + print '' . $sex . ''; + print ''; + print ''; + print '' . htmlspecialchars (escapeLoc ($row['list_name'])) . ''; + print ''; + print ''; + print ''; + } + } + + print ""; + } + } +print ""; -print""; +print ""; ?> \ No newline at end of file -- libgit2 0.21.4