doPost($secretKey, $url, $uniqueId); if (FALSE === $contents) return TRUE; // server trouble or busy if ('SUCCESS' == $contents) return TRUE; return FALSE; } function doPost ($secretKey, $url, $uniqueId) { $data = $this->buildQuery($secretKey, $url, $uniqueId); $headers = array( 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($data) ); $options = array( 'http' => array( 'method' => 'POST', 'header' => implode("\r\n", $headers), 'content' => $data, 'timeout' => 60 ) ); if (version_compare(PHP_VERSION, '5.0', '>=')) { $contents = file_get_contents('https://www.mellow-fellows.com/OMOW/', false, stream_context_create($options)); } else { $contents = $this->php4GetContents($options['http']); } return $contents; } function buildQuery ($secretKey, $url, $uniqueId) { $data = 'secretKey=' . $secretKey; $data .= '&url=' . urlencode($url); $data .= '&uniqueId=' . urlencode($uniqueId); $data .= '&remoteAddr=' . urlencode($_SERVER['REMOTE_ADDR']); $data .= '&userAgent=' . urlencode($_SERVER['HTTP_USER_AGENT']); return $data; } function php4GetContents($http_option) { $CrLf = "\r\n"; if (function_exists('curl_init')) { $curl = curl_init('https://www.mellow-fellows.com/OMOW/'); curl_setopt($curl, CURLOPT_HEADER, $http_option['header']); curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, $http_option['content']); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_USERAGENT, 'PHP/' . phpversion() . ' UpsNOMOWAgent'); $output= curl_exec($curl); return $output; } $wget = "wget -O - --post-data='" . $http_option['content'] . "' --header='" . str_replace($CrLf, ';', $http_option['header']) . "' https://www.mellow-fellows.com/OMOW/"; $response = shell_exec($wget); if ($response) return $response; $request = 'POST /OMOW/ HTTP/1.0' . $CrLf; $request .= 'Host: www.mellow-fellows.com' . $CrLf; $request .= 'User-Agent: PHP/' . phpversion() . ' UpsNOMOWAgent' . $CrLf; $request .= $http_option['header']; $request .= $CrLf . $CrLf; $request .= $http_option['content']; $fp = fsockopen('ssl://www.mellow-fellows.com', 443, $errno, $errstr, $http_option['timeout']); if (!$fp) { return FALSE; } fputs($fp, $request); $response = ''; while (!feof($fp)) { $response .= fgets($fp, 4096); } fclose($fp); $data = split($CrLf . $CrLf, $response, 2); return preg_match('/HTTP\/1\.[01] 200 OK/', $data[0])? $data[1]: FALSE; } } ?>