//////////////////////////////////////////////////////////////////////////////// // m3Rlin's PHP2SMS 1.1 // http://php2sms.sourceforge.net/ // // Copyright (c) 2003-2004 Jacob Dybala aka 'm3Rlin' // This script can be used under the terms of the GNU Public License (GPL), // either vesion 2.0 or newer. A copy of the license can be read at // http://www.gnu.org/copyleft/gpl.html // // // If you like this script or feel that I should buy myself a beer please go to // http://www.m3rlin.org/sms/donation.php and make a donation. PayPal and credit // card donations are accepted. Any amount is good! Thank you in advance! // // This version offers support for: // .:: [ Poland ] ::. // pl.idea - IDEA // .:: [ United States of America ] ::. // att - AT&T Wireless // cingular - Cingular Wireless // t-mobile - T-Mobile // uscc - US Cellular // // // Adding new networks is very easy as long as the provider offers an WWW->SMS // gateway. If you would like to add a new network to this list please e-mail // me @ m3Rlin@m3Rlin.org and I will add support for your network. I would like // to test the script to makesure it works with the new networks before I // officially add support. // // How to use: // Visit http://php2sms.sourceforge.net/#network for a basic tutorial or figure the // code our yourself :-) It's pretty self-explanatory. // // Created : Nov-14-2003 // Modified: Nov-21-2003 // // History // ------- // 1.00 [Nov-17-2003] // * Initial version. Offered support for AT&T and T-Mobile. // // 1.10 [Nov-21-2003] // + Cingular Wireless, US Cellular, IDEA PL networks added. // + Added 'results' variable to wait for site reply if needed. Settings // 'results' to '0' or omitting it greatly speeds up SMS sending. //////////////////////////////////////////////////////////////////////////////// $user_agent = "Mozilla/5.0 Galeon/1.2.6 (Linux i686; U;) Gecko"; echo 'sending'; function post_it($datastream, $url) { $url = preg_replace('@^http://@i', '', $url); $host = substr($url, 0, strpos($url, '/')); $uri = strstr($url, '/'); $reqbody = ''; foreach($datastream as $key=>$val) { if (!empty($reqbody)) { $reqbody.= '&'; } $reqbody.= $key.'='.urlencode($val); } $socket = fsockopen($host, 80, $errno, $errstr, 5); if (!$socket) { $result['errno'] = $errno; $result['errstr'] = $errstr; return $result; } else { $contentlength = strlen($reqbody); $reqheader = "POST $uri HTTP/1.1\r\n" ."Host: $host\nUser-Agent: $user_agent\r\n" ."Content-Type: application/x-www-form-urlencoded\r\n" ."Content-Length: $contentlength\r\n\r\n" ."$reqbody\r\n"; fputs($socket, $reqheader); if ($_GET['result'] == '1') { while (!feof($socket)) { $result[] = fgets($socket, 512); } } fclose($socket); return $result; } } $from = $_GET['from']; $to = $_GET['to']; $subject = urldecode($_GET['subject']); $message = urldecode($_GET['message']); if ($_GET['network'] == 't-mobile') { $data['txtNum'] = $to; $data['txtFrom'] = $from; $data['txtMessage'] = $message; $data['hdnpublic'] = '1'; $data['msgTermsUse'] = 'on'; $result = post_it($data, 'http://www.t-mobile.com/messaging/default.asp'); } elseif ($_GET['network'] == 'att') { $data['pin'] = $to; $data['from'] = $from; $data['subject'] = $subject; $data['message'] = $message; $result = post_it($data, 'http://www.mobile.att.net/messagecenter/pagersend.cgi'); } elseif ($_GET['network'] == 'uscc') { $data['number'] = $to; $data['message'] = $message; $result = post_it($data, 'http://66.77.16.246/index.php'); } elseif ($_GET['network'] == 'cingular') { $data['TO'] = $to; $data['FROM'] = $from; // Can be a number or e-mail address $data['MESSAGE'] = $message; $data['SUBJECT'] = $subject; $result = get_it($data, 'http://208.62.68.135/msgresult.shtml'); } elseif ($_GET['network'] == 'pl.idea') { // The is a hidden value generated by the server. It is 'token' $fp = fopen('http://sms.idea.pl/', 'r'); while (!feof($fp)) { $rip .= fgets($fp, 1024); } fclose($fp); eregi('([0-9a-zA-Z]{8}\-[0-9a-zA-Z]{4}\-[0-9a-zA-Z]{4}\-[0-9a-zA-Z]{4}\-[0-9a-zA-Z]{12})', $rip, $match); $data['token'] = $match; $data['RECIPIENT'] = $to; $data['SENDER'] = $from; // First and last name $data['SHORT_MESSAGE'] = $message; $data['CHK_RESP'] = 'on'; $data['respInfo'] = '2'; $result = get_it($data, 'http://sms.idea.pl/sendsms.aspx'); } if (isset ($result['errno'])) { $errno = $result['errno']; $errstr = $result['errstr']; echo "Error $errno $errstr"; exit; } else { for ($i = 0; $i< count($result); $i++) { echo $result[$i]; } }