Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 KB | None | 0 0
  1. <?php
  2. //exit;
  3. if($_GET[from]!="*131#"){echo "Not from *131# text";exit;}else{}
  4. if($_GET[message]==""){echo "No text";exit;}else{}
  5. $king2=$_GET[message];
  6. if ( stripos($king2, "Mins") !== false )
  7. {
  8. $low= getStringBetween($king2,'Secs; ','; and');
  9. //if($low==""){$low="0";}else{}
  10. }else{
  11.  
  12. $low= getStringBetween($king2,'Airtime; ','; and');
  13. //if($low==""){$low="0";}else{}
  14. }
  15. $lowx= getStringBetween($king2,'have ','/');
  16.  
  17. $low=preg_replace("/[^0-9]/", "", $low);
  18. $lowx=preg_replace("/[^0-9]/", "", $lowx);
  19.  
  20.  
  21.  
  22. date_default_timezone_set('Africa/Nairobi');
  23. $afriuser='root';
  24. $afrihost='localhost';
  25. $afripass='';
  26. $afridb='bobsms';
  27. $con = mysql_connect($afrihost,$afriuser,$afripass);
  28. if (!$con)
  29. {
  30. // header("location: ".$nkere."unable/");
  31. die('Could not connect: ' . mysql_error());
  32.  
  33. }
  34.  
  35. mysql_select_db($afridb, $con);
  36.  
  37. //if ($_GET[id]==""){echo"under cos";exit;}else{}
  38. $timex=time();
  39. //$tlist='08,09,10,11,12,01,04,06,07';//sunday
  40. $tlist='08,19,10,11';
  41. $tlist="";
  42. //echo date("hA");exit;
  43. function getStringBetween($string, $start, $end){
  44. $string = " ".$string;
  45. $ini = strpos($string,$start);
  46. if ($ini == 0) return "";
  47. $ini += strlen($start);
  48. $len = strpos($string,$end,$ini) - $ini;
  49. return substr($string,$ini,$len);
  50. }
  51.  
  52. if ( !function_exists( 'hex2bin' ) ) {
  53. // pre 5.4 fallback
  54. function hex2bin( $str ) {
  55. $sbin = "";
  56. $len = strlen( $str );
  57. for ( $i = 0; $i < $len; $i += 2 ) {
  58. $sbin .= pack( "H*", substr( $str, $i, 2 ) );
  59. }
  60.  
  61. return $sbin;
  62. }
  63. }
  64.  
  65. function pdu2strg($pdu) {
  66. // chop and store bytes
  67. $number = 0;
  68. $bitcount = 0;
  69. $output = '';
  70. while (strlen($pdu)>1) {
  71. $byte = ord(hex2bin(substr($pdu,0,2)));
  72. $pdu=substr($pdu, 2);
  73. $number += ($byte << $bitcount);
  74. $bitcount++ ;
  75. $output .= chr($number & 0x7F);
  76. $number >>= 7;
  77. if (7 == $bitcount) {
  78. // save extra char
  79. $output .= chr($number);
  80. $bitcount = $number = 0;
  81. }
  82. }
  83. return $output;
  84. }
  85.  
  86.  
  87. ///////////////////
  88. ////////////////from other stiet
  89. function str2pdu($command)
  90. {
  91. $bin = "";
  92. for($i = 0; $i < strlen($command); $i++)
  93. $bin .= strrev(sprintf("%07b", ord($command[$i])));
  94.  
  95. $bin .= str_repeat("0", 8 - strlen($bin) % 8);
  96. $pdu = "";
  97. while(strlen($bin))
  98. {
  99. $symbol = substr($bin, 0, 8);
  100. $symbol = strrev($symbol);
  101. $bin = substr($bin, 8);
  102. $pdu .= binhex(substr($symbol,0,4)).binhex(substr($symbol,4));
  103. }
  104.  
  105. return $pdu;
  106. }
  107.  
  108. function pdu2str($pduanswer)
  109. {
  110. $pdu = pack("H*", $pduanswer);
  111. $bin = "";
  112. for($i = 0; $i < strlen($pdu); $i++)
  113. $bin .= strrev(sprintf("%08b", ord($pdu[$i])));
  114.  
  115. $hex = "";
  116. while(strlen($bin)>=7)
  117. {
  118. $symbol = substr($bin, 0, 7);
  119. $bin = substr($bin, 7);
  120.  
  121. $symbol = "0".strrev($symbol);
  122. $hex .= binhex(substr($symbol,0,4)).binhex(substr($symbol,4));
  123. }
  124.  
  125. return pack("H*", $hex);
  126. }
  127.  
  128. function binhex($string)
  129. {
  130. return strtoupper(dechex(bindec($string)));
  131. }
  132. // $hex contains 746573742073656e74656e63652e2e2e
  133. //echo str2pdu("*131#");
  134. //print Hex2String($hex);
  135. // outputs: test sentence...from=[from]&message=[message-text]&gate=[gateway]
  136. if ( stripos($_GET[message], " ") !== false )
  137. {
  138.  
  139. $from=mysql_escape_string(stripslashes($_GET[from]));
  140. $get=mysql_escape_string(stripslashes($_GET[message])); }else{
  141. $from=pdu2str($_GET[from]);
  142. $get=mysql_escape_string(stripslashes(pdu2str($_GET[message])));}
  143. $timex=date("d-m-Y h:ia");
  144. $somk=date("l d-m-y h:ia");
  145. $bird=strtolower($_GET[gate]);
  146. $t5=5*60;
  147. $tnow=time();
  148. if($bird=="com173"){
  149. if($lowx!=""){
  150. // echo "update reload set amount='$lowx' where part2='com173' ";
  151. $hsh=mysql_query("update reload set amount='$lowx',message='$lowx',times='$somk',used='' where part2='com173' ");
  152. }else{}
  153.  
  154. }else{}
  155. if ( (stripos($king2, "have") !== false ) && ($low=="")){$low="0";}else{}
  156. if($low!=""){
  157. // echo ("update reload set amount='$low',times='$somk',used='' where (part2='$bird' )and (timex +$t5<=$tnow )");exit;
  158. $hsh=mysql_query("update reload set amount='$low',times='$somk',used='',timex='$tnow' where (part2='$bird' )and (timex +$t5<=$tnow )");
  159. $matu++;
  160. }else{}
  161.  
  162.  
  163. $gf=mysql_query("insert into messages (phones,message,datex,portused) values('$from','$get','$timex','$_GET[gate]') ") or die (mysql_error());
  164. echo "ok";
  165. //$rowmat=mysql_fetch_array($gf);
  166. //echo"<b>$rowmat[number]</b> select * from reload where (timex+$timp <=$timex) limit 1";
  167.  
  168.  
  169. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement