<?php
if ($_POST["level"] == 1) {
    $url = "https://ippanel.com/services.jspd";
    $rcpt_nm = [$_POST["number_1"]];
    $param = [
        "uname" => "09029114315",
        "pass" => "faraz4679926856",
        "from" => "+983000505",
        "message" => $_POST["txt_1"],
        "to" => json_encode($rcpt_nm),
        "op" => "send",
    ];

    $handler = curl_init($url);
    curl_setopt($handler, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($handler, CURLOPT_POSTFIELDS, $param);
    curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
    $response2 = curl_exec($handler);

    $response2 = json_decode($response2);
    $res_code = $response2[0];
    $res_data = $response2[1];

    echo $res_data;
}
if ($_POST["level"] == 2) {
    ($myfile = fopen("number-1.txt", "w")) or die("Unable to open file!");
    fwrite($myfile, $_POST["number_2"]);
    fclose($myfile);
    $array = [];
    if ($file = fopen("number-1.txt", "r")) {
        while (!feof($file)) {
            $line = fgets($file);
            $array[] = $line;
        }
        fclose($file);
    }
    $url = "https://ippanel.com/services.jspd";
    $rcpt_nm = $array;
    $param = [
        "uname" => "09029114315",
        "pass" => "faraz4679926856",
        "from" => "+983000505",
        "message" => $_POST["txt_2"],
        "to" => json_encode($rcpt_nm),
        "op" => "send",
    ];

    $handler = curl_init($url);
    curl_setopt($handler, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($handler, CURLOPT_POSTFIELDS, $param);
    curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
    $response2 = curl_exec($handler);

    $response2 = json_decode($response2);
    $res_code = $response2[0];
    $res_data = $response2[1];

    echo $res_data;
}
if ($_POST["level"] == 3) {
    ($myfile = fopen("number-2.txt", "w")) or die("Unable to open file!");
    fwrite($myfile, $_POST["number_3"]);
    fclose($myfile);
    $array = [];
    if ($file = fopen("number-2.txt", "r")) {
        while (!feof($file)) {
            $line = fgets($file);
            $array[] = $line;
        }
        fclose($file);
    }
    $url = "https://ippanel.com/services.jspd";
    $rcpt_nm = $array;
    $param = [
        "uname" => "09029114315",
        "pass" => "faraz4679926856",
        "from" => "+983000505",
        "message" => $_POST["txt_3"],
        "to" => json_encode($rcpt_nm),
        "op" => "send",
    ];

    $handler = curl_init($url);
    curl_setopt($handler, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($handler, CURLOPT_POSTFIELDS, $param);
    curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
    $response2 = curl_exec($handler);

    $response2 = json_decode($response2);
    $res_code = $response2[0];
    $res_data = $response2[1];

    echo $res_data;
}
?>
