<?php
require('includes/application_top.php');
if (!tep_session_is_registered('customer_id')) {
tep_redirect(tep_href_link(FILENAME_LOGIN));
}
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_AVOFORM);
$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_AVOFORM));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>" />
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>" />
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
</head>
<body>
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><?php include(DIR_WS_MODULES . FILENAME_AVOFORM);
?></td>
</tr>
</table>
</td>
<tr>
<td>
<?php
if ($_POST){
/**
* удаляет html теги
* @param document string html-блок
* @return string строка без html тегов
*/
function del_html($document){
$search = array ("'<script[^>]*?>.*?
</script>'si",
"'<[\/\!]*?[^<>]*?>'si",
"'([\r\n])[\s]+'",
"'&(quot|#34);'i",
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(\d+);'e");
$replace = array ("",
"",
"\\1",
"\"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\\1)");
$text = preg_replace($search, $replace, $document);
return $text;
}
/**
* Создает POST-data из массива
* @param arr array исходный массив
* @param dop string[optional] <p>
* Если дополнительный параметр задам тогда будет сформироманна строка
* массив с именем <b>dop</b>
* </p>
* @return string POST-data
*/
function postpars($arr,$dop=""){
if (!is_array($arr)) return NULL;
$keys=array_keys($arr);
$data="";
foreach ($keys as $key){
if ($data) $data.="&";
if (is_array($arr[$key])) $data.=postpars($arr[$key],$key);
else{
if ($dop) $data.=$dop."%5B".$key."%5D=".$arr[$key];
else $data.=$key."=".$arr[$key];
}
}
//echo $data;
return $data;
}
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
$data=postpars($_POST);
if ($data==NULL) die('Ошибка POST запроса');
$ReqArr=array(
'Type'=>'GET',
'Host'=>'avo.ee',
'Location'=>'/',
'Cache-Contriol'=>'max-age=0',
'User-Agent'=>'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7',
'Accept-Charset'=>'utf-8,utf-8;q=0.7,*;q=0.3',
'Accept-Language'=>'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
'Connection'=>'keep-alive'
);
/**
* Создает HTTP-запрос из массива
* @param $ReqArr array
* @return string HTTP-запрос
*/
function CreateRequest($ReqArr){
if (!is_array($ReqArr)) return NULL;
if (!(isset($ReqArr['Type'])&&isset($ReqArr['Host'])&&isset($ReqArr['Location']))) return NULL;
$nl="\r\n";
$request=$ReqArr['Type']." ".$ReqArr['Location']." HTTP/1.1".$nl;
$request.="Host: ".$ReqArr['Host'].$nl;
$KeysArr=array_keys($ReqArr);
foreach ($KeysArr as $Key){
if ($Key!='Type' && $Key!='Host' && $Key!='Location' && $Key!='PostData')
$request.=$Key.': '.$ReqArr[$Key].$nl;
}
if ($ReqArr['Type']=='POST' && $ReqArr['PostData']!=NULL) {
$request.="Content-Length: ".strlen($ReqArr['PostData']).$nl;
$request.="Content-Type: application/x-www-form-urlencoded".$nl;
$request.=$nl;
$request.=$ReqArr['PostData'];
}
else $request.=$nl;
return $request;
}
/**
* Загружает данные по HTTP-запросу из массива
* @param $ReqArr array
* @param $onlyHeader bool[optional]
* <p>Если onlyHeader=true,тогда получается только заголовок ответа</p>
* @return string
*/
function HTTPConnect(&$ReqArr,$onlyHeader=false){
$request=CreateRequest($ReqArr);
$f_h=fsockopen($ReqArr['Host'],80);
if (!$f_h) {return NULL;}
fwrite($f_h,$request);
$responce="";
while(!feof($f_h)){
$responce.=fgetc($f_h);
if ($onlyHeader){
$str=substr($responce,strlen($responce)-4,4);
if ($str=="\r\n\r\n"){
$res_line=preg_split("/\r\n/",$responce);
foreach ($res_line as $iX){
if (substr($iX,0,11)=="Set-Cookie:")
$ReqArr['Cookie']=substr($iX,12,strlen($iX)-12);
}
break;
}
}
}
fclose($f_h);
return $responce;
}
if (HTTPConnect($ReqArr,true)==NULL) {
exit ("Подключение не удалось");
}
//username=tttt&password=ttttt2
$q="SELECT * FROM avo_conf limit 3";
$tid=tep_db_query($q);
$login;
$pass;
$k;
while ($res=mysql_fetch_array($tid)){
$$res[1]=$res[2];
}
$K_II=$k;
$ReqArr['Type']='POST';
$ReqArr['Location']='/clients/login/';
$ReqArr['PostData']='username='.$login.'&password='.$pass;
if (HTTPConnect($ReqArr,true)==NULL) {
exit ("Подключение не удалось");
}
$ReqArr['Location']="/parts/query/language/ru/";
$ReqArr['PostData']=postpars($_POST);
$responce=HTTPConnect($ReqArr);
if ($responce==NULL)
exit ("Подключение не удалось");
//$dom =domxml_new_doc();
$html=preg_split("/\<html/",$responce);
$html="<html".$html[1];
$cDet=0;
$dom=new DOMDocument();
$dom->loadHTML($html);
$tables=$dom->getElementsByTagName("table");
foreach ($tables as $table){
if ($table->getAttribute("class")=="queryTable"){
$html='<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>'.$dom->saveXML($table)."</body></html>";
$dom->loadHTML($html);
$trs=$dom->getElementsByTagName("tr");
$iVen=-1;
$Product=array();
foreach ($trs as $tr){
//
$html1='<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>'.$dom->saveXML($tr)."</body></html>";
$dom1=new DOMDocument();
$dom1->loadHTML($html1);
$ths=$dom1->getElementsByTagName("th");
if ($ths->length >0){
$html1='<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>'.$dom1->saveXML($ths->item(0))."</body></html>";
$dom1->loadHTML($html1);
$spans=$dom1->getElementsByTagName("span");
foreach ($spans as $span){
//echo $span->getAttribute("class");
if ($span->getAttribute("class")=="makeHeading"){
$iVen++;
$Product[$iVen]['vendor']=del_html($dom1->saveXML($span));
$Product[$iVen]['data']=array();
$iD=-1;
break;
}
}
} else{
if ($tr->getAttribute("class")=="row"){
//echo $dom->saveXML($tr);//;123578
$html1='<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head><body>'.$dom->saveXML($tr)."</body></html>";
$dom1->loadHTML($html1);
$tds=$dom1->getElementsByTagName("td");
$iD++;
$Product[$iVen]['data'][$iD]=array();
$Product[$iVen]['data'][$iD]['id']=$cDet;
$Product[$iVen]['data'][$iD]['sNumber']=del_html($dom1->saveXML($tds->item(1)));
$Product[$iVen]['data'][$iD]['fNumber']=del_html($dom1->saveXML($tds->item(2)));
$Product[$iVen]['data'][$iD]['about']=del_html($dom1->saveXML($tds->item(3)));
$Product[$iVen]['data'][$iD]['rPrise']= del_html($dom1->saveXML($tds->item(5)));
$Product[$iVen]['data'][$iD]['sPrise']= del_html($dom1->saveXML($tds->item(7)));
$Product[$iVen]['data'][$iD]['nPrise']=del_html($dom1->saveXML($tds->item(8)));
$Product[$iVen]['data'][$iD]['about']=iconv("UTF-8","UTF-8", preg_replace("/\n/","",$Product[$iVen]['data'][$iD]['about']));
$Product[$iVen]['data'][$iD]['nPrise']=preg_replace("/\s/","",$Product[$iVen]['data'][$iD]['nPrise'])*$K_II;
$cDet++;
}
}
//$th=$tr->getElementsByTagName("th");
//var_dump($tr);
///if (!is_object($th))echo $th;
//else echo $th->item[0];
}
break;
}
}
error_reporting(E_ALL ^ E_NOTICE);
$Product; //-готовый продукт)))
}
elseif (isset($_GET['Avo_table']) && $_GET['Avo_table']==1){
$Product=$_SESSION['Avo'];
}
define(PRODUCT_LISTING_DISPLAY_STYLE ,'list');
echo tep_draw_separator('pixel_trans.gif', '100%', '10');
if (PRODUCT_LISTING_DISPLAY_STYLE == 'list' && is_array($Product)) {
$_SESSION['Avo'] =$Product;
$list= array(BOX_SEARCH_PART,BOX_WAS_SEARCH,BOX_DESCRIPTION,BOX_PRICE,BOX_BUY);
foreach ($Product as $VendorArrays){
//echo ("<p class='pageHeading'>".$VendorArrays['vendor']."</p>");
$list= array("Искомая деталь", "Найденая","Описание","Цена","PRODUCT_LIST_BUY_NOW");
$list_box_contents=array();
$list_box_contents[0][] = array('align' => 'left',
'params' => 'class="productListing-heading" colspan="5"',
'text' => ' ' . $VendorArrays['vendor']. ' ');
foreach($list as $lc_text){
if ($lc_text=='PRODUCT_LIST_BUY_NOW') $lc_text ="Купить";
$list_box_contents[1][] = array('align' => $lc_align,
'params' => 'class="productListing-heading" ',
'text' => ' ' . $lc_text . ' ');
}
$rows = 0;
foreach ($VendorArrays['data'] as $detal){
$rows++;
if (($rows/2) == floor($rows/2)) {
$list_box_contents[] = array('params' => 'class="productListing-even"');
} else {
$list_box_contents[] = array('params' => 'class="productListing-odd"');
}
$cur_row = sizeof($list_box_contents) - 1;
$list_box_contents[$cur_row][] = array('align' => $lc_align,
'params' => 'class="productListing-data"',
'text' => $detal['sNumber']);
$list_box_contents[$cur_row][] = array('align' => $lc_align,
'params' => 'class="productListing-data"',
'text' => $detal['fNumber']);
$list_box_contents[$cur_row][] = array('align' => $lc_align,
'params' => 'class="productListing-data"',
'text' => $detal['about']);
$list_box_contents[$cur_row][] = array('align' => $lc_align,
'params' => 'class="productListing-data"',
'text' => round($detal['nPrise'],2));
// echo tep_session_id($ss)."<br>";
$lc_text = '<form name="cart_quantity" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params($detal) . 'action=add_product&products_id=' .$detal['id']) .'">
<input type="hidden" name="avo_product" value="1" >
<input type="hidden" name="products_id" value="'.$detal['id'].'" >
<input type="text" name="cart_quantity" value="1" maxlength="3" size="3">
' . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</form>';
$list_box_contents[$cur_row][] = array('align' => 'center',
'params' => 'class="productListing-data" ',
'text' => $lc_text);
}
// var_dump($list_box_contents);
new productListingBox($list_box_contents);
//var_dump($_SESSION);
}
}
/*
$list= array("Искомая деталь", "Найденая","Описание","Цена","PRODUCT_LIST_BUY_NOW");
//echo "<";
$list_box_contents=array();
//$Product=arraay();
$rows = 0;
foreach ($VendorArrays['data'] as $detal){
$rows++;
if (($rows/2) == floor($rows/2)) {
$list_box_contents[] = array('params' => 'class="productListing-even"');
} else {
$list_box_contents[] = array('params' => 'class="productListing-odd"');
}
$cur_row = sizeof($list_box_contents) - 1;
foreach($detal as $col){
$lc_text =$col;
$list_box_contents[$cur_row][] = array('align' => $lc_align,
'params' => 'class="productListing-data"',
'text' => $lc_text);
}
new productListingBox($list_box_contents);
}}}
/*
case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
$lc_text = '<form name="cart_quantity" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing['products_id']) . '"><input type="hidden" name="products_id" value="' . $listing['products_id'] . '"><input type="text" name="cart_quantity" value="1" maxlength="3" size="3"> ' . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</form>';
if ($listing['products_quantity'] <= 0 && STOCK_CHECK == 'true') $lc_text = ' ';
break;
}
}
}
}
echo PRODUCT_LISTING_DISPLAY_STYLE;
*/
?>
</td>
</tr>
</table></td>
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>