<?php

$name = $_POST["name"];

$nummer = $_POST["number"];


$code = $_POST["draper"];


// The message
$message = "სახელი: ".$name."\r\nტელეფონი:".$nummer."\r\n META ინფორმაცია: ".$code;

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70, "\r\n");




$mesCl;
$mesUs;
// Send

$arr = explode(' ',trim($code));



if (strcmp($arr[0], "notshared") == 0 ) {
    $mesCl = file_get_contents("https://api.clicksend.com/http/v2/send.php?method=http&username=soloacc&key=D8F1D8EB-74E1-C659-D07A-5AC835D2CCE9&to=%2B995".$nummer."
&message=".urlencode($name).",".urlencode(" madloba dainteresebistvis \n
tqveni fasdaklebis kodia: ".$arr[1].", 
kodis gamoyeneba shegidziat 6 aprilis chatvlit.
misamarti: saburtalos (chabukianis) qucha #7
T: 2 18 41 32, mob: 593 18 33 11
saloni \"Exclusive\"")."&senderid=Exclusive");
/*
 $mesUs = file_get_contents("https://api.clicksend.com/http/v2/send.php?method=http&username=soloacc&key=D8F1D8EB-74E1-C659-D07A-5AC835D2CCE9&to=%2B995593183311
&message=".urlencode("axali pacienti: ".$name.", 
nomeri: ".$nummer." kodi: ".$arr[1]." ".$arr[2])."&senderid=Exclusive");  */
} else {

$mesCl =  file_get_contents("https://api.clicksend.com/http/v2/send.php?method=http&username=soloacc&key=D8F1D8EB-74E1-C659-D07A-5AC835D2CCE9&to=%2B995".$nummer."
&message=".urlencode($name).",".urlencode(" madloba dainteresebistvis \n
tqveni fasdaklebis kodia:".$arr[1].", 
kodis gamoyeneba shegidziat 6 aprilis chatvlit.
misamarti: saburtalos (chabukianis) qucha #7
T: 2 18 41 32, mob: 593 18 33 11
saloni \"Exclusive\"")."&senderid=Exclusive");
/*
$mesUs = file_get_contents("https://api.clicksend.com/http/v2/send.php?method=http&username=soloacc&key=D8F1D8EB-74E1-C659-D07A-5AC835D2CCE9&to=%2B995593183311
&message=".urlencode("axali pacienti: ".$name.", 
nomeri: ".$nummer." kodi: ".$arr[1]." ".$arr[2])."&senderid=Exclusive"); 
*/

}


/*

$file = "clients.txt";
$myString = "New Client: \r\nსახელი: ".$name."\r\nტელეფონი:".$nummer."\r\nდაშეარებული კოდი: ".$code." \r\nlog: message to client: \r\n".$mesCl."\r\n log: message to us: \r\n".$mesUs."\r\n \r\n\r\n ";
file_put_contents($file, $myString, FILE_APPEND);

*/

$file = "clients.txt";
$arraydumping = print_r($arr);
$myString = "\r\n\r\n New Client: \r\nსახელი: ".$name."\r\nტელეფონი:".$nummer."\r\nდაშეარებული კოდი: ".$arr[1]."\r\დაშეარდა თუ არა?: ".$arr[0];
file_put_contents($file, $myString, FILE_APPEND);



mail('shotaosephashvili@gmail.com', 'ახალი კლიენტი - '.date('l \t\h\e jS'), $message);
mail('mikheilkhvedelidze@gmail.com', 'ახალი კლიენტი - '.date('l \t\h\e jS'), $message);
?>