PageRenderTime 56ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/alfa.sms.class.php

https://github.com/wp-plugins/2stepauth-for-wordpress
PHP | 96 lines | 75 code | 17 blank | 4 comment | 4 complexity | c568e557f1ab5a194879cf70bfd39dcb MD5 | raw file
  1. <?php
  2. /*
  3. File containing code to send SMS meant for verification of mobile phone.
  4. Thanks to: Alfred Francis
  5. */
  6. include_once "alfa.curl.class.php";
  7. class AlfaSMS
  8. {
  9. var $username;
  10. var $password;
  11. var $number;
  12. var $msg;
  13. var $curl;
  14. var $login;
  15. var $post_data;
  16. var $content;
  17. var $url;
  18. var $ref;
  19. public function __construct()
  20. {
  21. $this->loginok=false;
  22. $this->curl=new AlfacURL();
  23. }
  24. public function login($username,$password)
  25. {
  26. $post_data = "username=".$username."&password=".$password;
  27. $url = "http://site1.way2sms.com/Login1.action";
  28. $ref="http://site1.way2sms.com/content/index.html";
  29. $content=($this->curl->post($url,$post_data,$ref));
  30. if(stristr($content,"Invalid Mobile No"))
  31. {
  32. $this->login=false;
  33. return false;
  34. }
  35. else
  36. {
  37. $this->login=true;
  38. return true;
  39. }
  40. }
  41. public function send($number,$msg)
  42. {
  43. if($this->login)
  44. {
  45. $msg=urlencode($msg);
  46. $post_data ="action=sa65sdf656fdfd&HiddenAction=instantsms&catnamedis=Birthday&login=&pass=&MobNo=".trim($number)."&textArea=".$msg;
  47. $url = "http://site1.way2sms.com/quicksms.action";
  48. $ref="http://site1.way2sms.com/jsp/InstantSMS.jsp";
  49. $content=($this->curl->post($url,$post_data,$ref));
  50. if(stristr($content,"successfully"))
  51. {
  52. return true;
  53. }
  54. else
  55. {
  56. return false;
  57. }
  58. }
  59. else
  60. {
  61. echo "<h2>Please login first before sending SMS</h2>";
  62. }
  63. }
  64. public function logout()
  65. {
  66. $post_data ="1=1";
  67. $url = "http://site1.way2sms.com/jsp/logout.jsp";
  68. $content=($this->curl->post($url,$post_data));
  69. if(stristr($content,"successfully"))
  70. {
  71. return true;
  72. }
  73. else
  74. {
  75. return false;
  76. }
  77. }
  78. }
  79. ?>