. * * @package phpservermon * @author Pepijn Over * @copyright Copyright (c) 2008-2014 Pepijn Over * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 * @version Release: @package_version@ * @link http://phpservermon.neanderthal-technology.com/ **/ class txtmsgInetworx extends txtmsgCore { // ========================================================================= // [ Fields ] // ========================================================================= // ========================================================================= // [ Methods ] // ========================================================================= /** * Send a text message to one or more recipients * * @param string $subject * @param string $body * @return boolean */ public function sendSMS($message) { if(empty($this->recipients)) { return false; } $errors = 0; foreach($this->recipients as $receiver) { if(!$this->executeSend($message, $receiver, $this->originator)) { $errors++; } } $this->recipients = array(); return ($errors > 0) ? false : true; } /** * Performs the actual send operation * * @param string $subject * @param string $body * @param string $receiver * @param string $sender * @return unknown */ protected function executeSend($message, $receiver, $sender) { $con_https[0] = 'sms.inetworx.ch'; $con_https[1] = '443'; $con_https[2] = 'inetworxag:conn2smsapp'; $posturl = "/smsapp/sendsms.php"; if(!empty($receiver)) { $postvars = 'user=' . urlencode($this->username) . '&pass=' . urlencode($this->password) . '&sender=' . urldecode($sender) . '&rcpt=' . urlencode($receiver) . '&msgbody=' . urlencode($message) ; //if enabled, it sends a flash-message (not stored in Inbox!!) //$postvars .= "&mclass=1"; $rtnval = $this->_auth_https_post(array($con_https[0], $con_https[1], $con_https[2], $posturl, $postvars)); return $rtnval; //echo "SMS-Send-Result: $rtnval"; } else { return false; } } protected function _auth_https_post($inarray) { // AUTH_HTTPS_POST: Request POST URL using basic authentication and SSL. // Input: inarray[0]: host name // inarray[1]: service port // inarray[2]: user/password // inarray[3]: URL request // inarray[4]: POST variables // Output: Message returned by server. // Build the header. $header = "POST ".$inarray[3]." HTTP/1.0\r\n"; $header .= "Authorization: Basic ".base64_encode("$inarray[2]")."\r\n"; $header .= "Host: ".$inarray[0]."\r\n"; $header .= "Content-type: application/x-www-form-urlencoded\r\n"; $header .= "Content-length: ".strlen($inarray[4])."\r\n\r\n"; // Connect to the server. $connection = fsockopen("ssl://".$inarray[0], $inarray[1], &$errnum, &$errdesc, 10); $msg = ""; if (! $connection){ $msg = $errdesc." (".$errnum.")"; } else { socket_set_blocking($connection,false); fputs($connection,$header.$inarray[4]); while (! feof($connection)) { $newline = fgets($connection,128); switch ($newline) { // Skip http headers. case (strstr($newline, 'Content-')): break; case (strstr($newline, 'HTTP/1')): break; case (strstr($newline, 'Date:')): break; case (strstr($newline, 'Server:')): break; case (strstr($newline, 'X-Powered-By:')): break; case (strstr($newline, 'Connection:')): break; case "": break; case "\r\n": break; default: $msg .= $newline; } //end switch } //end while fclose($connection); } //end else return $msg; } //end function auth_https_post } ?>