$port = "80"; } $contenttype = @$_REQUEST['contenttype']; if (empty($contenttype)) { $contenttype = "text/xml"; } $data = @$GLOBALS["HTTP_RAW_POST_DATA"]; // define content type header("Content-type: " . $contenttype); if (empty($data)) { $result = send_request(); } else { // post XML $posting = new HTTP_Client($host, $port, $data); $posting->set_path($path); $result = $posting->send_request(); } // strip leading text from result and output result $len = strlen($result); $pos = strpos($result, "<"); if ($pos > 1) { $result = substr($result, $pos, $len); } //$result = str_replace("xlink:","",$result); echo $result; // define class with functions to open socket and post XML // from http://www.phpbuilder.com/annotate/message.php3?id=1013274 by Richard Hundt class HTTP_Client { var $host; var $path;
function Program() { $param = $this->param . "?id=" . $this->id . "&phoneNumber=" . urlencode($this->phone_number) . "&psw=" . $this->pwd . "&textSms=" . urlencode($this->text_sms) . "&descripcion=" . urlencode($this->descriptionEP) . "&fecha=" . $this->dateEP . "&hora=" . $this->timeEP . "&periodicidadEnvio=" . $this->periodEP; if ($this->from != "") { $param .= "&remite=" . urlencode($this->from); } $url = $this->servletProgram . $param; $httpclient = new HTTP_Client($this->server, $this->port, $timeout = 30); $httpclient->path = $url; $resultado = $httpclient->send_request(); if ($resultado == -1) { $this->smsResult = "KO"; $this->smsDescription = "Error de conexión al servidor SMS"; } else { $simple = $resultado; // Decodifico el resultado $p = xml_parser_create(); $skipWhite = xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($p, $simple, $vals, $index); xml_parser_free($p); $auxResult = $index[RESULT][0]; $estadoResult = $vals[$auxResult][value]; $auxDescription = $index[DESCRIPTION][0]; $estadoDescription = $vals[$auxDescription][value]; $auxCredito = $index[CREDIT][0]; $estadoCredito = $vals[$auxCredito][value]; $this->smsResult = $estadoResult; $this->smsDescription = $estadoDescription; $this->smsCredit = $estadoCredito; } return $resultado; }