<?php
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zroot = $_SESSION["zdir"];
$zdb = $_SESSION["zdbyear_" . $dbname];
$compcd = $_SESSION["comp_" . $dbname];
$username = $_SESSION["username_" . $dbname];
mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];

$success = false;

if (isset($_REQUEST["stamp1"])) {
//    $mofd1 = $_REQUEST['mofd1'];
    $mobile = $_REQUEST['mobile'];
    $pass1 = $_REQUEST['pass1'];
    $paxname = $_REQUEST['pax1'];
//    $mofano = $_REQUEST['mof1'];
    $stamp1 = $_REQUEST['stamp1'];

    if ($mobile) {
        $mobnum = $mobile;
    } else {
        $mobnum = "7718888446";
    }

//    $mobnum = '8108364186';
    $msgtech = "Your Stamping is done successfully on date $stamp1 for Passport No $pass1 Name $paxname IMRAN INTERNATIONAL";


    $user = "IMRINT";
    $password = "ImrInt@2022";
    $senderid = "IMRINT";
//    $url = "144.76.39.175/api.php?";
    $url = "http://vas.mobilogi.com/api.php?";



    $mobilenumbers = $mobnum;
    $messagetech = urlencode($msgtech);
    $chtech = curl_init();
    if (!$chtech) {
        die("Couldn't initialize a cURL handle");
    }
    $rettech = curl_setopt($chtech, CURLOPT_URL, $url);
    curl_setopt($chtech, CURLOPT_POST, 1);
    curl_setopt($chtech, CURLOPT_POSTFIELDS, "username=$user&password=$password&route=1&sender=$senderid&mobile[]=$mobilenumbers&message[]=$messagetech&templateid=1207165245714592466");
    $rettech = curl_setopt($chtech, CURLOPT_RETURNTRANSFER, true);
    $curlresponsetech = curl_exec($chtech);
    if (curl_errno($chtech)) {
//        echo 'curl error : ' . curl_error($chtech);
    }
    if (empty($rettech)) {

        die(curl_error($chtech));
        curl_close($chtech);
    } else {
        $infotech = curl_getinfo($chtech);
        curl_close($chtech);
//        echo $curlresponsetech;
    }


//    if ($curlresponsetech != '') {
    $rows = array();
    $ctr = 0;
    $r = mysqli_fetch_assoc($result);
    $rows = array('success' => true);
    header("Content-type: application\json");
    echo json_encode($rows);
//    }
}

