daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Feb 4th, 2016 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. error_reporting(E_ALL);
  3. ob_implicit_flush(true);
  4.  
  5.  
  6. include_once "class.curl.php";
  7. include_once "class.sms.php";
  8.  
  9. $smsapp=new sms();
  10. $smsapp->setGateway('way2sms');
  11.  
  12.  
  13. echo "Logging in  ... ";
  14. $smsapp->login('10 digit number','way2sms password');
  15.  
  16. echo "Sending SMS ... ";
  17. $result=$smsapp->send('receipient number','text message');
  18.  
  19. if($result=='true')
  20. {
  21.     echo "Message sent";
  22. }
  23. else
  24. {  
  25.     echo "Error encountered : ".$smsapp->getLastError();
  26. }
  27.  
  28. ?>
  29.    
  30. <?php
  31. class sms
  32. {
  33.     var $username;
  34.     var $password;
  35.     var $curl;
  36.     var $server;
  37.     var $loginDone;
  38.     var $debugMode;
  39.     var $data;
  40.     var $error;
  41.     public function __construct()
  42.     {
  43.         $this->curl=new cURL();
  44.     //  $this->curl->setProxy("");
  45.         $this->loginDone=false;
  46.         $this->debugMode=false;
  47.         $this->data=array();
  48.     }
  49.     public function setGateway($serverName)
  50.     {
  51.         switch($serverName)
  52.         {
  53.             case '160by2':
  54.             $this->server='160by2';
  55.             break;
  56.  
  57.             case 'way2sms':
  58.             $this->server='way2sms';
  59.             break;
  60.  
  61.             case 'airtel':
  62.             $this->server='airtel';
  63.             break;
  64.  
  65.             default :
  66.             $this->server='way2sms';
  67.  
  68.         }
  69.     }
  70.     public function login($username,$password)
  71.     {
  72.         $server=$this->server;
  73.  
  74.         call_user_func(array($this,"login_$server"),$username,$password);
  75.         $this->loginDone=true;
  76.  
  77.     }
  78.     public function send($number,$msg)
  79.     {
  80.         $server=$this->server;
  81.         if($this->loginDone)
  82.         return call_user_func(array($this,"send_$server"),$number,$msg);
  83.         else
  84.         {
  85.             echo "<h2>Please login first before sending SMS</h2>";
  86.         }
  87.  
  88.     }
  89.     private function login_way2sms($username,$password)
  90.     {
  91.         $out=($this->curl->post("http://www.way2sms.com","1=1"));
  92.         $pattern="/Location:(.+?)n/";
  93.         preg_match($pattern,$out,$matches);
  94.         $domain=trim($matches[1]);
  95.  
  96.         $this->data['domain']=$domain;
  97.  
  98.         $out= $this->curl->post("{$domain}auth.cl","username=$username&password=$password&Submit=Sign+in");
  99.  
  100.         $pattern="/Location:(.+?)n/";
  101.         preg_match($pattern,$out,$matches);
  102.         $referer=trim($matches[1]);
  103.         $this->data['referer']=$referer;
  104.  
  105.  
  106.     }
  107.  
  108.  
  109.     private function send_way2sms($number,$msg)
  110.     {
  111.         $domain=$this->data['domain'];
  112.         $html=$this->curl->post("{$domain}jsp/InstantSMS.jsp?val=0","1=1",$this->data['referer']);
  113.         if($this->debugMode)
  114.         {
  115.         echo "<h2>After logging in, the HTML returned by server is</h2>";
  116.         echo $html;
  117.         }
  118.  
  119.         $pattern = '/name="Action".+?value="(.*)"/';
  120.         preg_match($pattern, $html, $matches);
  121.  
  122.         $custfrom=$matches[1];
  123.         $msg=urlencode($msg);
  124.         $html=$this->curl->post("{$domain}FirstServletsms?custid=","custid=undefined&HiddenAction=instantsms&Action={$custfrom}&login=&pass=&MobNo=$number&textArea=$msg");
  125.         $pattern = '/class="style1">(.+?)</span>/';
  126.         preg_match($pattern, $html, $matches);
  127.         $out=($matches[1]);
  128.  
  129.         if(!preg_match("/successfully/",$out))
  130.         {
  131.         $this->setError($out);
  132.         return false;
  133.         }
  134.         else
  135.         {
  136.         return true;
  137.         $this->setError("No errors");
  138.         }
  139.  
  140.     }
  141.     public function getLastError()
  142.     {
  143.         return $this->error;
  144.  
  145.     }
  146.     private function setError($error)
  147.     {
  148.         $this->error=$error;
  149.     }
  150.     private function login_160by2($username,$password)
  151.     {
  152.     //  $out2=$this->curl->get("http://m.160by2.com");
  153.         $out=$this->curl->post("http://m.160by2.com/LoginCheck.asp?l=1&txt_msg=&mno=","txtUserName=$username&txtPasswd=$password&RememberMe=Yes&cmdSubmit=Login");
  154.         $pattern="/MyMenu.asp?Msg=(.+?)&/";
  155.  
  156.         preg_match($pattern,$out,$matches);
  157.         $id=trim($matches[1]);
  158.         $this->data['id']=$id;
  159.  
  160.     }
  161.  
  162.     private function send_160by2($number,$msg)
  163.     {
  164.         $msg=urlencode($msg);
  165.         $id=$this->data['id'];
  166.         $out1=$this->curl->post("http://m.160by2.com/SaveCompose.asp?l=1","txt_mobileno=$number&txt_msg=$msg&cmdSend=Send+SMS&TID=&T_MsgId=&Msg=$id");
  167.         //echo $out1;
  168.         $pattern = '/<table.+?>(.+)</table/s';
  169.         preg_match($pattern, $out1, $matches);
  170.  
  171.         $out=strip_tags(@$matches[1]);
  172.         if(count($matches)<1)
  173.         {
  174.         $pattern="/<div.+?background:.+?yellow.+?>(.+?)</div>/s";
  175.  
  176.         preg_match($pattern,$out1,$matches);
  177.  
  178.         $out=strip_tags($matches[1]);
  179.         }
  180.  
  181. //
  182.     //  echo "out is $out";
  183.  
  184.         if(!preg_match("/successfully/i",$out))
  185.         {
  186.  
  187.         $this->setError($out);
  188.  
  189.         return false;
  190.         }
  191.         else
  192.         {
  193.         return true;
  194.         $this->setError("No errors");
  195.         }
  196.  
  197.     }
  198.  
  199.     private function login_airtel($username,$password)
  200.     {
  201.         $this->data['username']=$username;
  202.         $this->data['password']=$password;
  203.  
  204.     }
  205.  
  206.  
  207.     private function send_airtel($number,$msg)
  208.     {
  209.  
  210.     }
  211. }
  212.  
  213. ?>
  214.    
  215. if($result=='true')
  216. to
  217. if($result == true)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top