fputs($fp, "User-Agent: OpenSeaMap-Editor/0.1.2\r\n"); fputs($fp, "Authorization: Basic " . $login . "\r\n"); fputs($fp, "Content-type: text/xml; charset=utf-8\r\n"); fputs($fp, "Content-length: " . strlen($data) . "\r\n"); fputs($fp, "Connection: Keep-Alive\r\n\r\n"); fputs($fp, $data . "\r\n"); $header = "not yet"; while (!feof($fp)) { $line = fgets($fp, 1024); if ($line == "\r\n" && $header == "not yet") { $header = "passed"; } if ($header == "passed") { $response .= $line; } /*else { $arg = split(":", $line); if ($arg[0] == "status") { $status .= trim($arg[1]); } }*/ } } fclose($fp); /*if ($status != "200") { $response = "Error:" .$status; }*/ return trim($response); } $_response = sendOSM($_url, createUrl($_todo, $_changset_id), base64_encode($_user_name . ":" . $_user_password), createChangeSet($_comment)); echo $_response;
$fp = @fsockopen($url, 80, $errno, $errstr); if (!$fp) { return "{$errstr} ({$errno})\n"; } else { fputs($fp, $method . " " . $path . " HTTP/1.1\r\n"); fputs($fp, "Host: " . $url . "\r\n"); fputs($fp, "User-Agent: OpenSeaMap-Editor/0.1.0\r\n"); fputs($fp, "Authorization: Basic " . $login . "\r\n"); fputs($fp, "Content-type: text/xml; charset=utf-8\r\n"); fputs($fp, "Content-length: " . strlen($data) . "\r\n"); fputs($fp, "Connection: Keep-Alive\r\n\r\n"); fputs($fp, $data . "\r\n"); $response = ""; $header = "not yet"; while (!feof($fp)) { $line = fgets($fp, 1024); if ($line == "\r\n" && $header == "not yet") { $header = "passed"; } if ($header == "passed") { $response .= $line; } } } fclose($fp); return trim($line); } //$_response = "antwort: " .$_method ." - " .$_url .$_path; $_response = sendOSM($_url, $_path, base64_encode($_user_name . ":" . $_user_password), $_data, $_method); echo trim($_response); //echo trim($_data);