欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

php编写的发送SMS消息的类 可以下载打包文件

程序员文章站 2022-05-16 17:19:40
...

这是一个用php编写的发送SMS消息的类,他可以连接SMS服务器,完成用户验证,并发送SMS信息到用户手机中

 

<html>
<head>
<title>SMS Web Sender Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<h2>SMS Web Sender DEMO!</h2>

<?php
if ($action != "submit") {
?>

<i>Any username or password you enter here will not be stored
 in any way (although we're not using SSL either)</i>

<p><i>Also, as you can see most of these are UK sites, not all
of them will support international numbers!</i></p>

<form method="post" action="demo.php">
  <table width="600" border="0" cellspacing="0" cellpadding="4">
    <tr> 
      <td align="right"><b>Site</b></td>
      <td> 
        <select name="site">
          <option value="txtuk_net">txtuk.net (no login)</option>
          <option value="mtnsms_com">mtnsms.com</option>
          <option value="lycos_co_uk">lycos.co.uk</option>
          <option value="excite_co_uk">excite.co.uk</option>
          <option value="uboot_com">uboot.com</option>
          <option value="genie_co_uk">genie.co.uk</option>
        </select>
      </td>
    </tr>
    <tr> 
      <td align="right"><b>User</b></td>
      <td>
        <input type="text" name="user">
      </td>
    </tr>
    <tr> 
      <td align="right"><b>Password</b></td>
      <td>
        <input type="password" name="pass">
      </td>
    </tr>
    <tr>
      <td valign="top" align="right"><b>Number</b></td>
      <td>
        <input type="text" name="number">
        (eg. +447123123123)</td>
    </tr>
    <tr> 
      <td valign="top" align="right"><b>Message</b></td>
      <td>
        <textarea name="message" cols="40" rows="8"></textarea>
      </td>
    </tr>
    <tr> 
      <td align="right"><b>Debug</b></td>
      <td>
        <input type="checkbox" name="debug" value="yes">
      </td>
    </tr>
    <tr> 
      <td align="right">&nbsp;</td>
      <td>&nbsp; </td>
    </tr>
    <tr> 
      <td align="right">&nbsp;</td>
      <td>
	  	<input type="hidden" name="action" value="submit">
        <input type="submit" name="Submit" value="Send!">
      </td>
    </tr>
  </table>
</form>

<?php

} else {

	// contains the site details
	include("sites.php");

	// contains main class
	include("class.sms_web_sender.php");

	if (empty($number) || empty($site) || empty($message)) {
		die("Make sure number, site and message are not empty");
	}

	if (!empty($debug) && $debug == "yes") {
		$debug = true;
	} else {
		$debug = false;
	}

	// signature bit of text that's required by some
	// sites like MTNSMS.com, you can leave as is
	$signature = "*";

	// create instance of sms web sender the one
	// optional argument will determine if
	// debug is turned on or not
	$sms = new sms_web_sender($debug);

	// add accounts
	// 1st argument: username
	// 2nd argument: password
	// 3rd argument: server
	// 4th argument: weight (this is only useful when
	//               shuffling the logins, the higher
	//               the weight, the more likely it'll
	//               be placed near the top of the list)
	//               default if left blank: 1
	$sms->add_login("$user", "$pass", "$site");

	// add Proxy Server details if required
	// I haven't tested this myself, feature of jm_sms
	//$sms->setProxyServer("proxyserver");
	//$sms->setProxyPort(81);
	//$sms->setProxyUser("proxyusername");
	//$sms->setProxyPass("proxypassword");
	//$sms->setProxy(true);

	// passes the number, signature and message in an array
	$result = $sms->send_sms(array("number"=>$number, "signature"=>$signature, "message"=>$message));

	if ($result) {
		echo "<h2>Sent!</h2>";
	} else {
		echo "<h2>Could not send :(</h2>";
		echo "<p><a href=\"javascript:history.back()\">Go Back</a></p>";
	}

}

?>

</body>
</html>

 

 

<?php
if (!defined("_SITES_INCLUDED")) {
	define("_SITES_INCLUDED", 1);
}

define("CLASS_NAME", "sms_web_sender");

/**************************************
 each class needs to have these functions
 + login()
 + logout()
 + send_sms()
***************************************/

class sms_global
{
	// takes a +44 international style number and returns a UK style number
	// eg. +447977777777 becomes 07977777777
	// used for some sites which don't accept the international format (genie.co.uk - 8/12/01)
	function uk_num_format($number)
	{
		return preg_replace("/\\+[0-9]{2}([0-9]+)/", "0$1", $number);
	}

	// get rid of the + sign in the number
	function strip_plus_sign($number)
	{
		return str_replace("+", "", $number);
	}

	// return the country code from a number
	function country_code($number)
	{
		if (preg_match("/^\\+([0-9]{2})[0-9]+/", $number, $matches)) {
			return $matches[1];
		} else {
			return false;
		}
	}

	// return the value of a hidden html form field
	function hidden_field_val($html, $field_name)
	{
		if (preg_match('/type="?hidden"? name="?'.$field_name.'"? value="?([^"]+)"?/i', $html, $matches)) {
			return $matches[1];
		}
	}
}


/********************************************************************************************************
*****************
* LYCOS.CO.UK   *
*****************
********************************************************************************************************/
	class lycos_co_uk extends sms_global
	{
		//-------------------------
		// SERVER DETAILS
		//-------------------------
		var $server			= "sms.lycos.co.uk";
		var $server_login	= "login.lycos.co.uk";
		var $server_logout	= "login.lycos.co.uk";

		//-------------------------
		// LOGIN
		// vars - [[USER]] [[PASS]]
		//-------------------------
		var $login_script = "/bin/membership/len_login?StatusCookie=OK";
		var $login_command = "member_name=[[USER]]&service=lycos&redirect=http%3A%2F%2Fsms.lycos.co.uk%2Fmobile%2F&target_url=&fail_url=&format=&password=[[PASS]]&product=SMS&x=20&y=10";

		// check for this URL
		var $success_url = "/bin/membership/len_cookie";

		// next URL
		var $next_url = "/mobile/message_center/message_center.jsp";

		// message delivered url
		var $message_delivered_url = "/mobile/message_center/message_delivered.jsp";

		//-------------------------
		// SEND SMS
		// vars - [[TIMESTAMP]] [[GSM_NUMBER]] [[MESSAGE]] [[SIG]]
		//-------------------------
		// check for success string
		var $success_string = "SMS message sent to:";

		// check for quota string
		var $quota_exceeded_string = "You tried to send";

		// send command
		var $send_command = "myaction=send&timestamp=[[TIMESTAMP]]&buddy=No+buddies&recsource=receiver&receiver=[[GSM_NUMBER]]&format=sms&body=[[MESSAGE]]&phrase=--+Select+a+phrase+--";

		// send URL
		var $send_script = "/mobile/message_center/message_center.jsp";

		// message
		var $send_message = "[[MESSAGE]]";

		// logout URL
		var $logout_script = "/bin/membership/len_logout?redirect=http:%2F%2Fsms.lycos.co.uk%2Fmobile";

		// failure checks
		var $fail = array();

		
		/**************************
		 constructor
		***************************/
		function lycos_co_uk()
		{
			//-------------------------
			// FAILED LOGINS CLUES
			// vars - [[USER]]
			//-------------------------
			$this->fail[0][check_type]	= "body";
			$this->fail[0][check_for]	= "<b>ERROR:</b> The password supplied for";
			$this->fail[0][debug_msg]	= "Incorrect password for user: [[USER]]";

			$this->fail[1][check_type]	= "body";
			$this->fail[1][check_for]	= "<b>ERROR:</b> There is no member";
			$this->fail[1][debug_msg]	= "User name not found: [[USER]]";
		}

		/**************************
		 login
		***************************/
		function login(&$sms_obj)
		{
			if (isset($this->server_login)) {
				$sms_obj->set_server($this->server_login);
			}

			// grab login string 
			$command = $this->login_command;
			$command = str_replace("[[USER]]", urlencode($sms_obj->get_username()), $command);
			$command = str_replace("[[PASS]]", $sms_obj->get_password(), $command);

			$result = $sms_obj->post_url($this->login_script, $command);
			$redirect_url = $sms_obj->parse_redirect($result);

			// check for incorrect login details
			if (is_array($this->fail)) {
				for ($x=0; $x < count($this->fail); $x++) {
					$check_in = ($this->fail[$x][check_type] == "body") ? $result : $redirect_url;
					if (strstr($check_in, $this->fail[$x][check_for]) != "") {
						$sms_obj->debug(str_replace("[[USER]]", $sms_obj->get_username(), $this->fail[$x][debug_msg]));
						return false;
					}
				}
			}

			$sms_obj->set_cur_url("http://".$sms_obj->get_server().$redirect_url);
			if (strstr($redirect_url, $this->success_url)) {
				$sms_obj->debug("Redirect URL matches Success URL: ".$this->success_url);
				// switch to main server at this point (incase login servers were used)
				$sms_obj->set_server($this->server);
				$sms_obj->set_cur_url("http://".$sms_obj->get_server().$this->next_url);
			}
			return true;
		}

		/**************************
		 send sms
		***************************/
		function send_sms($options, &$sms_obj)
		{
			// has to have $message, $signature, $number
			extract($options);

			if (!$sms_obj->login()) {
				$sms_obj->debug("Unable to log in");
				return false;
			}

			$tmp_message = $this->send_message;
			$tmp_message = str_replace("[[TIMESTAMP]]", time(), $message);
			$tmp_message = str_replace("[[GSM_NUMBER]]", urlencode($number), $message);
			$tmp_message = str_replace("[[SIG]]", urlencode($signature), $message);
			$tmp_message = str_replace("[[MESSAGE]]", urlencode($message), $message);

			$message = $tmp_message;

			$command = $this->send_command;
			$command = str_replace("[[GSM_NUMBER]]", urlencode($number), $command);
			$command = str_replace("[[SIG]]", urlencode($signature), $command);
			$command = str_replace("[[MESSAGE]]", urlencode($message), $command);

			$result = $sms_obj->post_url($this->send_script, $command);

			if (strstr($result, $this->message_delivered_url)) {
				$sms_obj->debug("SMS Message Sent Successfully");
				return true;
			} else {
				$sms_obj->debug("SMS Send Failed");
				// echo $result;
				if (strstr($result, $this->quota_exceeded_string)) {
					$sms_obj->debug("Quota for current user [".$sms_obj->get_username()."] exceeded.");
				}
				return false;
			}
		}

		/**************************
		 logout
		***************************/
		function logout(&$sms_obj)
		{
			$sms_obj->debug("Logging out...");
			if (isset($this->server_logout)) {
				$sms_obj->set_server($this->server_logout);
			}
			$sms_obj->get_url($this->logout_script);
			return true;
		}
	}

/********************************************************************************************************
*****************
* MTNSMS.COM    *
*****************
********************************************************************************************************/
	class mtnsms_com extends sms_global
	{
		//-------------------------
		// SERVER DETAILS
		//-------------------------
		var $server			= "www.mtnsms.com";
		var $server_logout	= "www.mtnsms.com";

		//-------------------------
		// LOGIN
		// vars - [[USER]] [[PASS]]
		//-------------------------
		var $login_script = "/session.asp";
		var $login_command = "username=[[USER]]&password=[[PASS]]&email=&joinusclick=no&returl=&x=40&y=43";

		// check for this URL
		var $success_url = "/members/contacts/contacts.asp";

		// next URL
		var $next_url = "/sms/xsms.asp";

		//-------------------------
		// SEND SMS
		// vars - [[TIMESTAMP]] [[GSM_NUMBER]] [[MESSAGE]] [[SIG]]
		//-------------------------
		// check for success string
		var $success_string = "your message sent to";

		// check for success url
		var $message_delivered_url = "/sms/msgSent.asp";

		// check for quota string
		var $quota_exceeded_string = "Daily message quota exceeded";

		// send command
		var $send_command = "smsToCTs=&smsToNumbers=[[GSM_NUMBER]]&smsMessage=[[MESSAGE]]&smsSig=1&smsSigDyna=[[SIG]]&msgCL=138&lenSSig=4&lenLSig=3&lenSysSig=11";

		// send URL
		var $send_script = "/sms/xsms.asp";

		// message
		var $send_message = "[[MESSAGE]]";

		// logout URL
		var $logout_script = "/logout.asp";

		// failure checks
		var $fail = array();

		
		/**************************
		 constructor
		***************************/
		function mtnsms_com()
		{
			//-------------------------
			// FAILED LOGINS CLUES
			// vars - [[USER]]
			//-------------------------
			$this->fail[0][check_type]	= "URL";
			$this->fail[0][check_for]	= "/registration/";
			$this->fail[0][debug_msg]	= "User name not found: [[USER]]";

			$this->fail[1][check_type]	= "URL";
			$this->fail[1][check_for]	= "err=204";
			$this->fail[1][debug_msg]	= "Incorrect password for user: [[USER]]";
		}

		/**************************
		 login
		***************************/
		function login(&$sms_obj)
		{
			if (isset($this->server_login)) {
				$sms_obj->set_server($this->server_login);
			}

			// grab login string 
			$command = $this->login_command;
			$command = str_replace("[[USER]]", urlencode($sms_obj->get_username()), $command);
			$command = str_replace("[[PASS]]", $sms_obj->get_password(), $command);

			$result = $sms_obj->post_url($this->login_script, $command);
			$redirect_url = $sms_obj->parse_redirect($result);

			// check for incorrect login details
			if (is_array($this->fail)) {
				for ($x=0; $x < count($this->fail); $x++) {
					$check_in = ($this->fail[$x][check_type] == "body") ? $result : $redirect_url;
					if (strstr($check_in, $this->fail[$x][check_for]) != "") {
						$sms_obj->debug(str_replace("[[USER]]", $sms_obj->get_username(), $this->fail[$x][debug_msg]));
						return false;
					}
				}
			}
			

			$result = $sms_obj->get_url($redirect_url);
			if (strstr($redirect_url, $this->success_url)) {
				$sms_obj->debug("Redirect URL matches Success URL: ".$this->success_url);
				// switch to main server at this point (incase login servers were used)
				$sms_obj->set_server($this->server);
				$sms_obj->get_url($this->next_url);
			}

			return true;
		}

		/**************************
		 send sms
		***************************/
		function send_sms($options, &$sms_obj)
		{
			// should have $message, $signature, $number
			extract($options);

			if (!$sms_obj->login()) {
				$sms_obj->debug("Unable to log in");
				return false;
			}

			$tmp_message = $this->send_message;
			$tmp_message = str_replace("[[TIMESTAMP]]", time(), $message);
			$tmp_message = str_replace("[[GSM_NUMBER]]", urlencode($number), $message);
			$tmp_message = str_replace("[[SIG]]", urlencode($signature), $message);
			$tmp_message = str_replace("[[MESSAGE]]", urlencode($message), $message);

			$message = $tmp_message;

			$command = $this->send_command;
			$command = str_replace("[[GSM_NUMBER]]", urlencode($number), $command);
			$command = str_replace("[[SIG]]", urlencode($signature), $command);
			$command = str_replace("[[MESSAGE]]", urlencode($message."\n"), $command);

			$result = $sms_obj->post_url($this->send_script, $command);

			if (strstr($result, $this->message_delivered_url)) {
				$sms_obj->debug("SMS Message Sent Successfully");
				return true;
			} else {
				$sms_obj->debug("SMS Send Failed");
				// echo $result;
				if (strstr($result, $this->quota_exceeded_string)) {
					$sms_obj->debug("Quota for current user [".$sms_obj->get_username()."] exceeded.");
				}
				return false;
			}
		}

		/**************************
		 logout
		***************************/
		function logout(&$sms_obj)
		{
			$sms_obj->debug("Logging out...");
			if (isset($this->server_logout)) {
				$sms_obj->set_server($this->server_logout);
			}
			$sms_obj->get_url($this->logout_script);
			return true;
		}
	}


/********************************************************************************************************
*****************
* TXTUK.NET     *
*****************
********************************************************************************************************/
	class txtuk_net extends sms_global
	{
		//-------------------------
		// SERVER DETAILS
		//-------------------------
		var $server = "www.txtuk.net";

		//-------------------------
		// LOGIN
		// vars - [[USER]] [[PASS]]
		//-------------------------
		var $login_script = "/sendtxtmsg.php";

		//-------------------------
		// SEND SMS
		// vars - [[TIMESTAMP]] [[GSM_NUMBER]] [[MESSAGE]] [[SIG]]
		//-------------------------
		// check for success string
		var $success_string = "Message Sent to";

		// send command
		var $send_command =	"back=default&tnumber=[[GSM_NUMBER]]&message=[[MESSAGE]]";

		// send URL
		var $send_script = "/action_sendtxtmsg.php";

		// message
		var $send_message = "[[MESSAGE]]";

		// failure checks
		var $fail = array();

		
		/**************************
		 constructor
		***************************/
		function txtuk_net()
		{
			//-------------------------
			// FAILED LOGINS CLUES
			// vars - [[USER]]
			//-------------------------
			$this->fail[0][check_type]	= "body";
			$this->fail[0][check_for]	= "Message not authorised";
			$this->fail[0][debug_msg]	= "Problems sending!";
		}

		/**************************
		 login
		***************************/
		function login(&$sms_obj)
		{
			$result = $sms_obj->get_url($this->login_script);
			$sms_obj->parse_redirect($result);

			return true;
		}

		/**************************
		 send sms
		***************************/
		function send_sms($options, &$sms_obj)
		{
			// has to have $message, $signature, $number
			extract($options);

			if (!$sms_obj->login()) {
				$sms_obj->debug("Unable to log in");
				return false;
			}

			$tmp_message = $this->send_message;
			$tmp_message = str_replace("[[TIMESTAMP]]", time(), $message);
			$tmp_message = str_replace("[[GSM_NUMBER]]", urlencode($number), $message);
			$tmp_message = str_replace("[[SIG]]", urlencode($signature), $message);
			$tmp_message = str_replace("[[MESSAGE]]", urlencode($message), $message);

			$message = $tmp_message;

			$command = $this->send_command;
			$command = str_replace("[[GSM_NUMBER]]", urlencode($number), $command);
			$command = str_replace("[[SIG]]", urlencode($signature), $command);
			$command = str_replace("[[MESSAGE]]", urlencode($message), $command);

			$result = $sms_obj->post_url($this->send_script, $command);

			if (strstr($result, $this->success_string)) {
				$sms_obj->debug("SMS Message Sent Successfully");
				return true;
			} else {
				$sms_obj->debug("SMS Send Failed");
				// echo $result;
				return false;
			}
		}

		/**************************
		 logout
		***************************/
		function logout(&$sms_obj)
		{
			return true;
		}
	}

/********************************************************************************************************
*****************
* GENIE.CO.UK   *
*****************
********************************************************************************************************/
	class genie_co_uk extends sms_global
	{
		//-------------------------
		// SERVER DETAILS
		//-------------------------
		var $server			= "www.genie.co.uk";

		//-------------------------
		// LOGIN
		// vars - [[USER]] [[PASS]]
		//-------------------------
		var $pre_login_script = "/";
		var $login_script = "/login/doLogin";
		var $login_command = "username=[[USER]]&password=[[PASS]]&x=9&y=9";

		//-------------------------
		// SEND SMS
		// vars - [[TIMESTAMP]] [[GSM_NUMBER]] [[MESSAGE]] [[SIG]]
		//-------------------------
		// check for success string
		var $success_string = "has been sent";

		// check for quota string
		var $quota_exceeded_string = "You tried to send";

		// send command
		var $send_command = "RECIPIENT=[[GSM_NUMBER]]&ABNUMBER=&left=103&SUBJECT=&check=0&MESSAGE=[[MESSAGE]]&action=Send";

		// send URL
		var $send_script = "/public/gmail/smsconfirm.html";

		// message
		var $send_message = "[[MESSAGE]]";

		// logout URL
		var $logout_script = "/logout/";

		// failure checks
		var $fail = array();

		
		/**************************
		 constructor
		***************************/
		function genie_co_uk()
		{
			//-------------------------
			// FAILED LOGINS CLUES
			// vars - [[USER]]
			//-------------------------
			$this->fail[0][check_type]	= "body";
			$this->fail[0][check_for]	= "User Name and/or Password you entered";
			$this->fail[0][debug_msg]	= "Incorrect user/pass for user: [[USER]]";
		}

		/**************************
		 login
		***************************/
		function login(&$sms_obj)
		{
			/** NOT NECESSARY! ********
			***************************
			$result = $sms_obj->get_url($this->pre_login_script);
			$redirect_url = $sms_obj->parse_redirect($result);
			$sms_obj->get_url($redirect_url);

			if (isset($this->server_login)) {
				$sms_obj->set_server($this->server_login);
			}
			*/

			// grab login string 
			$command = $this->login_command;
			$command = str_replace("[[USER]]", urlencode($sms_obj->get_username()), $command);
			$command = str_replace("[[PASS]]", $sms_obj->get_password(), $command);

			$result = $sms_obj->post_url($this->login_script, $command);
			$redirect_url = $sms_obj->parse_redirect($result);
			
			// check for incorrect login details
			if (is_array($this->fail)) {
				for ($x=0; $x < count($this->fail); $x++) {
					$check_in = ($this->fail[$x][check_type] == "body") ? $result : $redirect_url;
					if (strstr($check_in, $this->fail[$x][check_for]) != "") {
						$sms_obj->debug(str_replace("[[USER]]", $sms_obj->get_username(), $this->fail[$x][debug_msg]));
						return false;
					}
				}
			}

			if (!$redirect_url) {
				return false;
			}

			return true;
		}

		/**************************
		 send sms
		***************************/
		function send_sms($options, &$sms_obj)
		{
			// has to have $message, $signature, $number
			extract($options);

			if (!$sms_obj->login()) {
				$sms_obj->debug("Unable to log in");
				return false;
			}

			$tmp_message = $this->send_message;
			$tmp_message = str_replace("[[TIMESTAMP]]", time(), $message);
			$tmp_message = str_replace("[[GSM_NUMBER]]", urlencode($this->uk_num_format($number)), $message);
			$tmp_message = str_replace("[[SIG]]", urlencode($signature), $message);
			$tmp_message = str_replace("[[MESSAGE]]", urlencode($message), $message);

			$message = $tmp_message;

			$command = $this->send_command;
			$command = str_replace("[[GSM_NUMBER]]", urlencode($this->uk_num_format($number)), $command);
			$command = str_replace("[[SIG]]", urlencode($signature), $command);
			$command = str_replace("[[MESSAGE]]", urlencode($message), $command);

			$result = $sms_obj->post_url($this->send_script, $command);
			if (strstr($result, $this->success_string)) {
				$sms_obj->debug("SMS Message Sent Successfully");
				return true;
			} else {
				$sms_obj->debug("SMS Send Failed");
				// echo $result;
				if (strstr($result, $this->quota_exceeded_string)) {
					$sms_obj->debug("Quota for current user [".$sms_obj->get_username()."] exceeded.");
				}
				return false;
			}
		}

		/**************************
		 logout
		***************************/
		function logout(&$sms_obj)
		{
			$sms_obj->debug("Logging out...");
			if (isset($this->server_logout)) {
				$sms_obj->set_server($this->server_logout);
			}
			$sms_obj->get_url($this->logout_script);
			return true;
		}
	}


/********************************************************************************************************
*****************
* UBOOT.COM     *
*****************
********************************************************************************************************/
	class uboot_com extends sms_global
	{
		//-------------------------
		// SERVER DETAILS
		//-------------------------
		var $server			= "www.uboot.com";

		//-------------------------
		// LOGIN
		// vars - [[USER]] [[PASS]]
		//-------------------------
		var $login_script = "/cgi-bin/login.fcgi/uk/login";
		var $login_command = "unickname=[[USER]]&password=[[PASS]]&x=80&y=4";

		//-------------------------
		// SEND SMS
		// vars - [[TIMESTAMP]] [[GSM_NUMBER]] [[MESSAGE]] [[SIG]]
		//-------------------------
		// check for success string
		var $success_string = "transmit_done.gif";

		// check for quota string
		var $quota_exceeded_string = "You tried to send";

		// send command
		var $send_command = "p=csn&a=formaction&messageclass=Uboot%3A%3AMessages%3A%3ASMS&abook=addressbook&unickname=&unumber=&netw=&mobileno=[[GSM_NUMBER]]&smsno=[[GSM_NUMBER]]&date=&time=&num=0&body=[[MESSAGE]]&send.x=43&send.y=6";

		// send URL
		var $send_script = "/cgi-bin/ubox.fcgi";

		// message
		var $send_message = "[[MESSAGE]]";

		// logout URL
		var $logout_script = "/cgi-bin/login.fcgi/uk/dologout";

		// failure checks
		var $fail = array();

		
		/**************************
		 constructor
		***************************/
		function uboot_com()
		{
			//-------------------------
			// FAILED LOGINS CLUES
			// vars - [[USER]]
			//-------------------------
			$this->fail[0][check_type]	= "body";
			$this->fail[0][check_for]	= "entered is not valid";
			$this->fail[0][debug_msg]	= "Incorrect telephone number entered";
		
			$this->fail[1][check_type]	= "body";
			$this->fail[1][check_for]	= "doesn't exist";
			$this->fail[1][debug_msg]	= "User name not found: [[USER]]";

			$this->fail[2][check_type]	= "body";
			$this->fail[2][check_for]	= "password you entered does not match";
			$this->fail[2][debug_msg]	= "Incorrect password for user: [[USER]]";
		
		}

		/**************************
		 login
		***************************/
		function login(&$sms_obj)
		{

			// grab login string 
			$command = $this->login_command;
			$command = str_replace("[[USER]]", urlencode($sms_obj->get_username()), $command);
			$command = str_replace("[[PASS]]", $sms_obj->get_password(), $command);

			$result = $sms_obj->post_url($this->login_script, $command);
			$redirect_url = $sms_obj->parse_redirect($result);
			
			// check for incorrect login details
			if (is_array($this->fail)) {
				for ($x=0; $x < count($this->fail); $x++) {
					$check_in = ($this->fail[$x][check_type] == "body") ? $result : $redirect_url;
					if (strstr($check_in, $this->fail[$x][check_for]) != "") {
						$sms_obj->debug(str_replace("[[USER]]", $sms_obj->get_username(), $this->fail[$x][debug_msg]));
						return false;
					}
				}
			}

			if (!$redirect_url) {
				return false;
			}

			return true;
		}

		/**************************
		 send sms
		***************************/
		function send_sms($options, &$sms_obj)
		{
			// has to have $message, $signature, $number
			extract($options);

			if (!$sms_obj->login()) {
				$sms_obj->debug("Unable to log in");
				return false;
			}

			$tmp_message = $this->send_message;
			$tmp_message = str_replace("[[TIMESTAMP]]", time(), $message);
			$tmp_message = str_replace("[[GSM_NUMBER]]", urlencode($this->strip_plus_sign($number)), $message);
			$tmp_message = str_replace("[[SIG]]", urlencode($signature), $message);
			$tmp_message = str_replace("[[MESSAGE]]", urlencode($message), $message);

			$message = $tmp_message;

			$command = $this->send_command;
			$command = str_replace("[[GSM_NUMBER]]", urlencode($this->strip_plus_sign($number)), $command);
			$command = str_replace("[[SIG]]", urlencode($signature), $command);
			$command = str_replace("[[MESSAGE]]", urlencode($message), $command);

			$result = $sms_obj->post_url($this->send_script, $command);
			if (strstr($result, $this->success_string)) {
				$sms_obj->debug("SMS Message Sent Successfully");
				return true;
			} else {
				$sms_obj->debug("SMS Send Failed");
				// echo $result;
				if (strstr($result, $this->quota_exceeded_string)) {
					$sms_obj->debug("Quota for current user [".$sms_obj->get_username()."] exceeded.");
				}
				return false;
			}
		}

		/**************************
		 logout
		***************************/
		function logout(&$sms_obj)
		{
			$sms_obj->debug("Logging out...");
			if (isset($this->server_logout)) {
				$sms_obj->set_server($this->server_logout);
			}
			$sms_obj->get_url($this->logout_script);
			return true;
		}
	}


/********************************************************************************************************
*****************
* EXCITE.CO.UK  *
*****************
********************************************************************************************************/
	class excite_co_uk extends sms_global
	{
		//-------------------------
		// SERVER DETAILS
		//-------------------------
		var $server = "www.excite.co.uk";
		var $server_prelogin = "reg.excite.co.uk";
		var $server_login = "reg.excite.com";
		var $server_logout = "reg.excite.com";

		//-------------------------
		// LOGIN
		// vars - [[USER]] [[PASS]]
		//-------------------------
		var $prelogin_script = "/mps/login?pname=pfp&brand=uk_excite&targeturl=http://www.excite.co.uk/";
		var $login_script = "/mps/loginreq?pname=pfp&brand=uk_excite&targeturl=http://www.excite.co.uk/&uid=";
		var $login_command = "acctname=[[USER]]&passwd=[[PASS]]&snonce=[[SNONCE]]&stime=[[STIME]]&timeskew=none&crep=none&jerror=none&gofer=Sign+in";

		//-------------------------
		// SEND SMS
		// vars - [[TIMESTAMP]] [[GSM_NUMBER]] [[MESSAGE]] [[SIG]] [[COUNTRY_CODE]]
		//-------------------------
		// check for success string
		var $success_string = "Has Been Sent To";

		// check for quota string
		var $quota_exceeded_string = "Quota Exceeded";

		// send command
		var $send_command = "partial_address=[[GSM_NUMBER]]&message=[[MESSAGE]]&country_code=[[COUNTRY_CODE]]";

		// send URL
		var $send_script = "/mobile/sms/sent/";

		// message
		var $send_message = "[[MESSAGE]]";

		// logout URL
		var $logout_script = "/mps/signout_val?easyvalue=easy&completevalue=complete&signout_opt=complete&pname=pfp&brand=uk_excite&targeturl=http%3A%2F%2Fwww.excite.co.uk%2F";

		// failure checks
		var $fail = array();

		
		/**************************
		 constructor
		***************************/
		function excite_co_uk()
		{
			//-------------------------
			// FAILED LOGINS CLUES
			// vars - [[USER]]
			//-------------------------
			$this->fail[0][check_type]	= "body";
			$this->fail[0][check_for]	= "cannot recall your password";
			$this->fail[0][debug_msg]	= "Incorrect username/password for user: [[USER]]";
		
		}

		/**************************
		 login
		***************************/
		function login(&$sms_obj)
		{
			
			$sms_obj->set_server($this->server_prelogin);
			$result = $sms_obj->get_url($this->prelogin_script);
			$redirect_url = $sms_obj->parse_redirect($result);

			$sms_obj->set_server($this->server_login);

			// grab login string 
			$command = $this->login_command;
			$command = str_replace("[[USER]]", urlencode($sms_obj->get_username()), $command);
			$command = str_replace("[[PASS]]", $sms_obj->get_password(), $command);
			$command = str_replace("[[SNONCE]]", urlencode($this->hidden_field_val($result, "snonce")), $command);
			$command = str_replace("[[STIME]]", urlencode($this->hidden_field_val($result, "stime")), $command);

			$result = $sms_obj->post_url($this->login_script, $command);
			$redirect_url = $sms_obj->parse_redirect($result);
			
			// check for incorrect login details
			if (is_array($this->fail)) {
				for ($x=0; $x < count($this->fail); $x++) {
					$check_in = ($this->fail[$x][check_type] == "body") ? $result : $redirect_url;
					if (strstr($check_in, $this->fail[$x][check_for]) != "") {
						$sms_obj->debug(str_replace("[[USER]]", $sms_obj->get_username(), $this->fail[$x][debug_msg]));
						return false;
					}
				}
			}

			if (!$redirect_url) {
				return false;
			}
			
			$sms_obj->set_cur_url("http://reg.excite.co.uk/mps/login?pname=pfp&brand=uk_excite&targeturl=http://www.excite.co.uk/");
			$sms_obj->clear_cookies();
			$result = $sms_obj->get_url($redirect_url);
			$redirect_url = $sms_obj->parse_redirect($result);
			//$sms_obj->set_cur_url("http://reg.excite.co.uk/mps/login?pname=pfp&brand=uk_excite&targeturl=http://www.excite.co.uk/");
			//$result = $sms_obj->get_url($redirect_url);
			$sms_obj->set_server($this->server);
			return true;
		}

		/**************************
		 send sms
		***************************/
		function send_sms($options, &$sms_obj)
		{
			// has to have $message, $signature, $number
			extract($options);

			if (!$sms_obj->login()) {
				$sms_obj->debug("Unable to log in");
				return false;
			}

			$tmp_message = $this->send_message;
			$tmp_message = str_replace("[[TIMESTAMP]]", time(), $message);
			$tmp_message = str_replace("[[GSM_NUMBER]]", urlencode($this->strip_plus_sign($number)), $message);
			$tmp_message = str_replace("[[SIG]]", urlencode($signature), $message);
			$tmp_message = str_replace("[[MESSAGE]]", urlencode($message), $message);

			$message = $tmp_message;

			$command = $this->send_command;
			$command = str_replace("[[GSM_NUMBER]]", urlencode($this->strip_plus_sign($number)), $command);
			$command = str_replace("[[SIG]]", urlencode($signature), $command);
			$command = str_replace("[[MESSAGE]]", urlencode($message), $command);
			$command = str_replace("[[COUNTRY_CODE]]", urlencode($this->country_code($number)), $command);

			// too quick? didn't think they'd check it, nice feature,
			// but seems limit is only enforced on the confirmation page
			$sms_obj->debug("Sleep for 20 seconds (otherwise Excite will complain you're too quick :)");
			sleep(20);
			$sms_obj->set_cur_url("http://www.excite.co.uk/mobile/sms/confirm/");
			$result = $sms_obj->post_url($this->send_script, $command);

			if (strstr($result, $this->success_string)) {
				$sms_obj->debug("SMS Message Sent Successfully");
				return true;
			} else {
				$sms_obj->debug("SMS Send Failed");
				// echo $result;
				if (strstr($result, $this->quota_exceeded_string)) {
					$sms_obj->debug("Quota for current user [".$sms_obj->get_username()."] exceeded.");
				}
				return false;
			}
		}

		/**************************
		 logout
		***************************/
		function logout(&$sms_obj)
		{
			$sms_obj->debug("Logging out...");
			if (isset($this->server_logout)) {
				$sms_obj->set_server($this->server_logout);
			}
			$sms_obj->get_url($this->logout_script);
			return true;
		}
	}


?>

 

 

<?php
if (!defined("_SITES_INCLUDED")) {
	include("sites.php");
}

class sms_web_sender {

	var $server;
	var $server_obj;
	var $cookies = array();
	var $login = array();
	var $cur_url;
	var $do_debug = false;
	var $proxy_server;
	var $proxy_port;
	var $proxy_user;
	var $proxy_pass;
	var $proxy = false;


	/**********************
	* SET/GET FUNCTIONS
	***********************/
	function get_server() {
		return $this->server;
	}
	function set_server($server) {
		return $this->server = $server;
	}
	function get_cur_url() {
		return $this->cur_url; 
	}
	function set_cur_url($cur_url) {
		return $this->cur_url = $cur_url; 
	}
	function get_debug() {
		return $this->do_debug; 
	}
	function set_debug($debug) {
		return $this->do_debug = $debug; 
	}
	function get_proxy_server() {
		return $this->proxy_server; 
	}
	function set_proxy_server($proxy_server) {
		return $this->proxy_server = $proxy_server;
	}
	function get_proxy_port() {
		return $this->proxy_port; 
	}
	function set_proxy_port($proxy_port) {
		return $this->proxy_port = $proxy_port; 
	}
	function get_proxy_user() {
		return $this->proxy_user;
	}
	function set_proxy_user($proxy_user) {
		return $this->proxy_user = $proxy_user;
	}
	function get_proxy_pass() {
		return $this->proxy_pass;
	}
	function set_proxy_pass($proxy_pass) {
		return $this->proxy_pass = $proxy_pass;
	}
	function get_proxy() {
		return $this->proxy;
	}
	function set_proxy($proxy) {
		return $this->proxy = $proxy;
	}

	/**********************
	* CONSTRUCTOR
	* sets initial username, password, debug, and server
	***********************/
	// $server name will determine which class to use
	function sms_web_sender($debug=false, $username="", $password="", $server="")
	{
		if ($debug) {
			$this->set_debug(true);
		}
		if (!empty($server)) {
			$this->add_login($username, $password, $server);
		}
	}

	/**********************
	* SET SITE
	***********************/
	function set_site($site)
	{
		if (class_exists($site)) {
			set_time_limit(60);
			$this->clear_cookies();
			$this->debug($site." class being used");
			$this->server_obj = new $site;
			$this->set_server($this->server_obj->server);
			$this->set_cur_url($this->get_server());
			return true;
		} else {
			$this->debug($site." class Not Found!");
			if (!$this->next_login()) {
				$this->debug("No more servers: Exiting..");
				exit;
			}
			return false;
		}
	}

	/**********************
	* ADD LOGIN
	***********************/
	function add_login($username, $password, $server, $weight=1)
	{
		$this->login[] = array($username, $password, $server, $weight, count($this->login));
		return true;
	}

	/**********************
	* SHUFFLE LOGINS
	***********************/
	function shuffle_logins()
	{
		$tmp_array = array();
		$shuffled = array();

		// create new array holding biased amount
		// of each login (based on weight)
		foreach ($this->login as $val) {
			for ($x=1; $x<=$val[3]; $x++) {
				$tmp_array[] = $val;
			}
		}

		// loop through logins randomly picking out
		// login details to put in the new array
		while (count($shuffled) < count($this->login)) {
			mt_srand((double) microtime() * 1000000);
			$rand_pick = mt_rand(0, count($tmp_array));
			if ($rand_pick > 0) $rand_pick--;
			$remove_id = $tmp_array[$rand_pick][4];
			$shuffled[] = $tmp_array[$rand_pick];
			foreach ($tmp_array as $key=>$val) {
				if ($val[4] == $remove_id) {
					unset($tmp_array[$key]);
				}
			}
			// reset the keys
			$tmp_array = array_values($tmp_array);
		}
		
		// replace our logins array with our shuffled array
		$this->login = $shuffled;
		return true;
	}

	/**********************
	* GET USERNAME
	***********************/
	function get_username()
	{
		return $this->login[key($this->login)][0];
	}

	/**********************
	* GET PASSWORD
	***********************/
	function get_password()
	{
		return $this->login[key($this->login)][1];
	}

	/**********************
	* GET SITE
	***********************/
	function get_site()
	{
		return $this->login[key($this->login)][2];
	}

	/**********************
	* NEXT LOGIN
	***********************/
	function next_login()
	{
		if (next($this->login)) {
			$this->debug("Advancing to next user.");
			return $this->set_site($this->get_site());
		} else {
			$this->debug("No more configured users.");
			return false;
		}
	}

	/**********************
	* DEBUG OUTPUT
	***********************/
	function debug($line)
	{
		if ($this->do_debug) {
			echo "- $line<br>\n";
			flush();
		}
		return true;
	}

	/**********************
	* GET COOKIES
	***********************/
	function get_cookies()
	{
		$cookies = implode("; ", $this->cookies);
		$this->debug("Using cookies: ".$cookies);
		return $cookies;
	}

	/**********************
	* PROCESS COOKIE
	***********************/
	function process_cookie($cookie)
	{
		// sample cookie
		// NAME=VALUE; path=/;  domain=.mydomain.com;  expires=Wednesday, 31-Dec-2010 12:10:00 GMT; 

		$cookie_valid = true;
		$cookie = trim($cookie);
		if (substr($cookie, -1) == ";") $cookie = substr($cookie, 0, -1);
		$cookie = explode(";", $cookie, 2);
		$cookie_attributes = trim($cookie[1]);
		$cookie_name_val = explode("=", $cookie[0], 2);
		$cookie_name = trim($cookie_name_val[0]);
		$cookie_val = trim($cookie_name_val[1]);
		if ($cookie_val == "") {
			$cookie_valid = false;
		}
		if (preg_match("/expires=[a-z, ]*([0-9]{1,2}[- ][a-z]+[- ][0-9]{4})/i", $cookie_attributes, $matches)) {
			if (strtotime($matches[1]) < time()) {
				$this->debug("(-) Expired: ".implode(";", $cookie));
				$cookie_valid = false;
			}
		}
		
		if (!$cookie_valid) {
			return false;
		} else {
			$this->cookies["$cookie_name"] = "$cookie_name=$cookie_val";
			$this->debug("(+) Set-Cookie: ".implode(";", $cookie));
			return true;
		}

	}

	/**********************
	* SET COOKIES
	***********************/
	function set_cookies($cookie)
	{
		return $this->process_cookie($cookie);
	}

	/**********************
	* CLEAR COOKIES
	***********************/
	function clear_cookies()
	{
		$this->cookies = array();
		return true;
	}

	/**********************
	* POST URL
	***********************/
	function post_url($url, $formdata, $showme=false)
	{
		$full_url = "http://".$this->get_server().$url;
		$this->debug("[ACTION = POST] URL: ".$full_url);
		$data =  "POST ".$url." HTTP/1.1\r\n";
		$data .= $this->generate_http_header();
		$data .= "Content-Type: application/x-www-form-urlencoded\r\n";
		$data .= "Content-Length: ".strlen($formdata)."\r\n\r\n";
		$data .= $formdata;
		
		do {
			$errno = 0;
			$fp = @fsockopen(($this->get_proxy() ? $this->get_proxy_server() : $this->get_server()), ($this->get_proxy() ? $this->get_proxy_port() : 80), $errno, $errstr, 30);
			if ($errno) {
				$this->debug("Retrying Failed POST (".$errno."): ".$errstr);
				sleep(1);
			}
		} while($errno);

		// shows HTTP POST request
		if ($showme) die($data);

		$result = "";
		fputs($fp, $data);
		while(!feof($fp)) {
			$result .= fgets($fp, 128);
		}
		fclose($fp);
		$this->set_cur_url("http://".$this->get_server().$url);
		return $result;
	}

	/**********************
	* GET URL
	***********************/
	function get_url($url, $showme=false)
	{
		$full_url = "http://".$this->get_server().$url;
		$this->debug("[ACTION = GET] URL: ".$full_url);
		$data =  "GET ".$url." HTTP/1.1\r\n";
		$data .= $this->generate_http_header()."\r\n";

		do {
			$errno = 0;
			$fp = @fsockopen(($this->get_proxy() ? $this->get_proxy_server() : $this->get_server()), ($this->get_proxy() ? $this->get_proxy_port() : 80), $errno, $errstr, 30);
			if ($errno) {
				$this->debug("Retrying Failed GET (".$errno."): ".$errstr);
				sleep(1);
			}
		} while($errno);

		// shows HTTP GET request
		if ($showme) die($data);

		$result = "";
		fputs ($fp, $data);
		while (!feof($fp)) {
			$result .= fgets($fp, 128);
		}
		fclose($fp);
		$this->set_cur_url("http://".$this->get_server().$url);
		return $result;
	}

	/**********************
	* GENERATE HTTP HEADERS
	***********************/
	function generate_http_header()
	{
		$data  = "Referer: ".$this->get_cur_url()."\r\n";
		//$data .= "User-Agent: Mozilla/4.72 [en] (X11; U; Linux 2.2.14-5.0 i586)\r\n";
		$data .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:0.9.4) Gecko/20011019 Netscape6/6.2\r\n";
		$data .= "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\n";
		// line below enabled will not let us search through returned html (as it'll be compressed and appear garbled)
		//$data .= "Accept-Encoding: gzip\r\n";
		$data .= "Accept-Language: en-gb\r\n";
		$data .= "Accept-Charset: iso-8859-1,*,utf-8\r\n";
		$data .= "Cookie: ".$this->get_cookies()."\r\n";
		$data .= "Host: ".$this->get_server()."\r\n";
		$data .= "Cache-Control: max-age=259200\r\n";
		$data .= "Connection: close\r\n";
		if ($this->get_proxy())
			$data .= "Proxy-Authorization: Basic ".base64_encode($this->get_proxy_user().":".$this->get_proxy_pass())."\r\n";
		return $data;
	}

	/**********************
	* PARSE REDIRECT
	***********************/
	function parse_redirect($http_header)
	{
		$header_parts = explode("\r\n", $http_header);
		while(list($key, $val) = each($header_parts)) {
			if (substr($val, 0, 10) == "Location: ") {
				$location = substr($val, 10);
			} else if (preg_match("/^Set-Cookie: /i", substr($val, 0, 12))) {
				$this->set_cookies(substr($val, 12));
			}
		}
		if (!empty($location) && substr($location, 0, 7) == "http://") {
			$location = substr($location, 7);
			if (!strstr($location, "/")) {
				$this->set_server($location);
			} else {
				$this->set_server(substr($location, 0, strpos($location, "/")));
			}
			if (substr_count($location, "/") == 0) {
				$location = "/";
			} else {
				$location = substr($location, strpos($location, "/"));
			}
		}
		if (!empty($location)) {
			$location = trim($location);
			$location = ($location[0] != "/") ? "/".$location : $location;
			$this->debug("Found HTTP Redirect To: ".$location);
			return $location;
		} else {
			return false;
		}
	}

	/**********************
	* LOGIN
	***********************/
	function login()
	{
		$result = $this->server_obj->login($this);
	
		if (!$result && $this->next_login()) {
			return $this->login();
		} else {
			return $result;
		}
	}
	
	/**********************
	* SEND SMS
	***********************/
	function send_sms($options)
	{
		if (!is_object($this->server_obj)) {
			$this->set_site($this->get_site());
		}
		$this->set_cur_url("http://".$this->get_server()."/");
		$result = $this->server_obj->send_sms($options, $this);
	
		if (!$result && $this->next_login()) {
			return $this->send_sms($options);
		} else {
			return $result;
		}
	}

	/**********************
	* LOGOUT
	* not necessary for most stuff
	***********************/
	function logout()
	{
		return $this->server_obj->logout($this);
	}

}
?>

 

 

<?php
/*
$Date: 2001/12/09 03:51:55 $
$Revision: 1.2 $
-------------------------------------------------
SMS WEB SENDER 0.1 (08-DEC-2001)
Keyvan Minoukadeh - keyvan@k1m.com
http://www.k1m.com/
-------------------------------------------------
This is an example file showing you how to use
the class...
*/

// contains the site details
include("sites.php");

// contains main class
include("class.sms_web_sender.php");

// your mobile number in international format (+###########)
$number = "+447123123123";

// signature bit of text that's required by some
// sites like MTNSMS.com, you can leave as is
$signature = "*";

// main body of the message
$message = "This is a test message";

// create instance of sms web sender the one
// optional argument will determine if
// debug is turned on or not
$sms = new sms_web_sender(true);

// add accounts
// 1st argument: username
// 2nd argument: password
// 3rd argument: server
// 4th argument: weight (this is only useful when
//               shuffling the logins, the higher
//               the weight, the more likely it'll
//               be placed near the top of the list)
//               default if left blank: 1
$sms->add_login("user", "pass", "uboot_com", 1);
$sms->add_login("user", "pass", "genie_co_uk", 1);
$sms->add_login("user", "pass", "lycos_co_uk", 10);
$sms->add_login("user", "pass", "mtnsms_com", 1);
$sms->add_login("user", "pass", "excite_co_uk", 5);
$sms->add_login("", "", "txtuk_net", 1);

// shuffle logins
$sms->shuffle_logins();

// add Proxy Server details if required
// I haven't tested this myself, feature of jm_sms
//$sms->setProxyServer("proxyserver");
//$sms->setProxyPort(81);
//$sms->setProxyUser("proxyusername");
//$sms->setProxyPass("proxypassword");
//$sms->setProxy(true);

// passes the number, signature and message in an array
$sms->send_sms(array("number"=>$number, "signature"=>$signature, "message"=>$message));

?>