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

网友投稿 467 2022-09-06

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

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

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

SMS Web Sender Demo

SMS Web Sender DEMO!

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

Also, as you can see most of these are UK sites, not allof them will support international numbers!

Site
User
Password
Number (eg. +447123123123)
Message
Debug
   
 
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 "

Sent!

"; } else { echo "

Could not send :(

"; echo "

Go Back

"; }}?>

fail[0][check_type] = "body"; $this->fail[0][check_for] = "ERROR: 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] = "ERROR: 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(" 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(" } 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 = "mtnsms.com"; var $server_logout = "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 = "txtuk-"; //------------------------- // 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 = "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 = "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 = "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= var $login_script = "/mps/loginreq?pname=pfp&brand=uk_excite&targeturl= var $login_command = "acctname=[[USER]]&passwd=[[PASS]]&snonce=[[SNONCE]]&stime=[[STIME]]×kew=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= // 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(" $sms_obj->clear_cookies(); $result = $sms_obj->get_url($redirect_url); $redirect_url = $sms_obj->parse_redirect($result); //$sms_obj->set_cur_url(" //$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(" $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; } }?>

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
\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 = " $this->debug("[ACTION = POST] URL: ".$full_url); $data = "POST ".$url." HTTP/1.1\r\n"; $data .= $this->generate_ $data .= "Content-Type: application/x- $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(" return $result; } /********************** * GET URL ***********************/ function get_url($url, $showme=false) { $full_url = " $this->debug("[ACTION = GET] URL: ".$full_url); $data = "GET ".$url." HTTP/1.1\r\n"; $data .= $this->generate_ 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(" return $result; } /********************** * GENERATE HTTP HEADERS ***********************/ function generate_ { $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($ { $header_parts = explode("\r\n", $ 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) == "{ $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(" $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); }}?>

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));?>

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:MySQL数据库常用命令小结(mysql操作命令大全)
下一篇:mysql 数据库优化技巧(mysql特性)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~