function ManualPOST($url, $post) { // $url = 'http://edost.ru//edost_calc_kln.php'; // $post = 'to_city=839&strah=17550&id=2387&p=vN4g7IgFKMSbpOMGSL9cW6S15YuxxnX5&weight=73.5&ln=51&wd=62&hg=116&zip='; $parse_url = parse_url($url); $path = $parse_url["path"]; $host = $parse_url["host"]; $rez = ""; self::$NowErr = false; set_error_handler(array('edost_class', 'my_error_handler')); $fp = fsockopen($host, 80, $errno, $errstr, 4); //4 - ????. ????? ??????? restore_error_handler(); if ($errno == 13) { return 'Err14'; } //??????: ????????? ??????? ?? ????????? ????????? ?????? ?? ?????? if (self::$NowErr) { return ''; } //?????? //Mage::log($post, null, 'edostlog.log'); if ($fp) { $out = "POST " . $path . " HTTP/1.0\n" . "Host: " . $host . "\n" . "Referer: " . $url . "\n" . "Content-Type: application/x-www-form-urlencoded\n" . "Content-Length: " . strlen($post) . "\n\n" . $post . "\n\n"; fputs($fp, $out); $q = 0; while ($gets = fgets($fp, 512)) { $rez .= $gets; $q++; } fclose($fp); $rez = stristr($rez, "<?xml version="); //???????? ????????? } Mage::log($rez, true, 'edostlog.log'); return $rez; }
function ManualPOST ($url, $post) { $parse_url = parse_url($url); $path = $parse_url["path"]; $host= $parse_url["host"]; $rez = ""; self::$NowErr = false; set_error_handler(array('edost_class','my_error_handler')); $fp = fsockopen($host, 80, $errno, $errstr, 4); //4 - макс. время запроса restore_error_handler(); if ($errno == 13) return('Err14'); //Ошибка: Настройки сервера не позволяют отправить запрос на расчет if (self::$NowErr) return(''); //Ошибка if ($fp){ $out = "POST ".$path." HTTP/1.0\n". "Host: ".$host."\n". "Referer: ".$url."\n". "Content-Type: application/x-www-form-urlencoded\n". "Content-Length: ".strlen($post)."\n\n". $post."\n\n"; fputs($fp, $out); $q = 0; while($gets=fgets($fp,512)) { $rez.= $gets; $q++; } fclose($fp); if ($this->test==0) $rez=stristr($rez, "<?xml version="); //отрезаем заголовок } return($rez); }