Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //exit;
- if($_GET[from]!="*131#"){echo "Not from *131# text";exit;}else{}
- if($_GET[message]==""){echo "No text";exit;}else{}
- $king2=$_GET[message];
- if ( stripos($king2, "Mins") !== false )
- {
- $low= getStringBetween($king2,'Secs; ','; and');
- //if($low==""){$low="0";}else{}
- }else{
- $low= getStringBetween($king2,'Airtime; ','; and');
- //if($low==""){$low="0";}else{}
- }
- $lowx= getStringBetween($king2,'have ','/');
- $low=preg_replace("/[^0-9]/", "", $low);
- $lowx=preg_replace("/[^0-9]/", "", $lowx);
- date_default_timezone_set('Africa/Nairobi');
- $afriuser='root';
- $afrihost='localhost';
- $afripass='';
- $afridb='bobsms';
- $con = mysql_connect($afrihost,$afriuser,$afripass);
- if (!$con)
- {
- // header("location: ".$nkere."unable/");
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db($afridb, $con);
- //if ($_GET[id]==""){echo"under cos";exit;}else{}
- $timex=time();
- //$tlist='08,09,10,11,12,01,04,06,07';//sunday
- $tlist='08,19,10,11';
- $tlist="";
- //echo date("hA");exit;
- function getStringBetween($string, $start, $end){
- $string = " ".$string;
- $ini = strpos($string,$start);
- if ($ini == 0) return "";
- $ini += strlen($start);
- $len = strpos($string,$end,$ini) - $ini;
- return substr($string,$ini,$len);
- }
- if ( !function_exists( 'hex2bin' ) ) {
- // pre 5.4 fallback
- function hex2bin( $str ) {
- $sbin = "";
- $len = strlen( $str );
- for ( $i = 0; $i < $len; $i += 2 ) {
- $sbin .= pack( "H*", substr( $str, $i, 2 ) );
- }
- return $sbin;
- }
- }
- function pdu2strg($pdu) {
- // chop and store bytes
- $number = 0;
- $bitcount = 0;
- $output = '';
- while (strlen($pdu)>1) {
- $byte = ord(hex2bin(substr($pdu,0,2)));
- $pdu=substr($pdu, 2);
- $number += ($byte << $bitcount);
- $bitcount++ ;
- $output .= chr($number & 0x7F);
- $number >>= 7;
- if (7 == $bitcount) {
- // save extra char
- $output .= chr($number);
- $bitcount = $number = 0;
- }
- }
- return $output;
- }
- ///////////////////
- ////////////////from other stiet
- function str2pdu($command)
- {
- $bin = "";
- for($i = 0; $i < strlen($command); $i++)
- $bin .= strrev(sprintf("%07b", ord($command[$i])));
- $bin .= str_repeat("0", 8 - strlen($bin) % 8);
- $pdu = "";
- while(strlen($bin))
- {
- $symbol = substr($bin, 0, 8);
- $symbol = strrev($symbol);
- $bin = substr($bin, 8);
- $pdu .= binhex(substr($symbol,0,4)).binhex(substr($symbol,4));
- }
- return $pdu;
- }
- function pdu2str($pduanswer)
- {
- $pdu = pack("H*", $pduanswer);
- $bin = "";
- for($i = 0; $i < strlen($pdu); $i++)
- $bin .= strrev(sprintf("%08b", ord($pdu[$i])));
- $hex = "";
- while(strlen($bin)>=7)
- {
- $symbol = substr($bin, 0, 7);
- $bin = substr($bin, 7);
- $symbol = "0".strrev($symbol);
- $hex .= binhex(substr($symbol,0,4)).binhex(substr($symbol,4));
- }
- return pack("H*", $hex);
- }
- function binhex($string)
- {
- return strtoupper(dechex(bindec($string)));
- }
- // $hex contains 746573742073656e74656e63652e2e2e
- //echo str2pdu("*131#");
- //print Hex2String($hex);
- // outputs: test sentence...from=[from]&message=[message-text]&gate=[gateway]
- if ( stripos($_GET[message], " ") !== false )
- {
- $from=mysql_escape_string(stripslashes($_GET[from]));
- $get=mysql_escape_string(stripslashes($_GET[message])); }else{
- $from=pdu2str($_GET[from]);
- $get=mysql_escape_string(stripslashes(pdu2str($_GET[message])));}
- $timex=date("d-m-Y h:ia");
- $somk=date("l d-m-y h:ia");
- $bird=strtolower($_GET[gate]);
- $t5=5*60;
- $tnow=time();
- if($bird=="com173"){
- if($lowx!=""){
- // echo "update reload set amount='$lowx' where part2='com173' ";
- $hsh=mysql_query("update reload set amount='$lowx',message='$lowx',times='$somk',used='' where part2='com173' ");
- }else{}
- }else{}
- if ( (stripos($king2, "have") !== false ) && ($low=="")){$low="0";}else{}
- if($low!=""){
- // echo ("update reload set amount='$low',times='$somk',used='' where (part2='$bird' )and (timex +$t5<=$tnow )");exit;
- $hsh=mysql_query("update reload set amount='$low',times='$somk',used='',timex='$tnow' where (part2='$bird' )and (timex +$t5<=$tnow )");
- $matu++;
- }else{}
- $gf=mysql_query("insert into messages (phones,message,datex,portused) values('$from','$get','$timex','$_GET[gate]') ") or die (mysql_error());
- echo "ok";
- //$rowmat=mysql_fetch_array($gf);
- //echo"<b>$rowmat[number]</b> select * from reload where (timex+$timp <=$timex) limit 1";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement