<?php


ini_set('session.gc_maxlifetime', 30*60);

session_start();

include '../../../includes/config.php';



$TU_ID = $_GET['TU_ID'];
$Trip_ID = $_GET['Trip_ID'];
$Driver_ID = $_GET['Driver_ID'];
$U_ID = $_GET['U_ID'];
$Total_Riders = $_GET['Total_Riders'];
$Spot_Number = $_GET['Spot_Number'];



$sql1 = mysqli_query($dbConn,"update trips_users set Status='Pickedup' WHERE ID='$TU_ID'");
$sql2 = mysqli_query($dbConn,"select * from trips where ID='$Trip_ID'");
$row2 = mysqli_fetch_array($sql2);
$Max_Limit_Riders = $row2['Max_Limit_Riders'];
$New_Current_Total_Riders = $Max_Limit_Riders;
$sql3 = mysqli_query($dbConn,"update trips set Current_Total_Riders='$New_Current_Total_Riders' WHERE ID='$Trip_ID'");








if ($Driver_Phone_Type=='Android'){
	
	
	function sendMessage($DU_ID){
        
    
        $content = array(
            "en" => 'تم تحميل راكب الرحلة !'
            );
        
        $fields = array(
            'app_id' => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            'include_player_ids' => array($DU_ID),
            'data' => array("foo" => "bar"),
            'contents' => $content
        );
        
        $fields = json_encode($fields);
       // print("\nJSON sent:\n");
       // print($fields);
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

        $response = curl_exec($ch);
        curl_close($ch);
        
        return $response;
    }
    
    $response = sendMessage($DU_ID);
    $return["allresponses"] = $response;
    $return = json_encode( $return);
    
   // print("\n\nJSON received:\n");
   //    print($return);
   // print("\n");
	
	
	
	
}else{
	
	
	
	 function sendMessage($DU_ID){
        
        
        
        
        
        $content = array(
            "en" => 'تم تحميل راكب الرحلة !'
            );
        
        $fields = array(
            'app_id' => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            'include_player_ids' => array($DU_ID),
            'data' => array("foo" => "bar"),
            'contents' => $content
        );
        
        $fields = json_encode($fields);
       // print("\nJSON sent:\n");
       // print($fields);
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

        $response = curl_exec($ch);
        curl_close($ch);
        
        return $response;
    }
    
    $response = sendMessage($DU_ID);
    $return["allresponses"] = $response;
    $return = json_encode( $return);
    
   // print("\n\nJSON received:\n");
   //    print($return);
   // print("\n");	
   
   
	
	
	
}


















	echo '<script language="JavaScript">
 document.location="shared-mix-gender-77.php?Spot_Number='.$Spot_Number.'&TU_ID='.$TU_ID.'&Driver_ID='.$Driver_ID.'&U_ID='.$U_ID.'&Trip_ID='.$Trip_ID.'";
</script>';




?>
