79 lines
3.0 KiB
PHP
79 lines
3.0 KiB
PHP
<?php
|
|
// Parse with sections
|
|
$ini = parse_ini_file("conf.ini", true);
|
|
|
|
if ($ini['db']['log']=="1"){
|
|
$arrival_time=microtime(true);
|
|
$filename=basename(__FILE__);
|
|
$filename="log_".$filename.".txt";
|
|
$chunck=strval($arrival_time)." ".$_SERVER['REQUEST_URI']."\r\n";
|
|
file_put_contents($filename,$chunck,FILE_APPEND);
|
|
}
|
|
|
|
$user_id=$_REQUEST['user_id'];
|
|
$language=$_REQUEST['language'];
|
|
$address=$_REQUEST['address'];
|
|
$radius=$_REQUEST['radius'];
|
|
|
|
|
|
if ($user_id<>0)
|
|
{
|
|
mysql_connect($ini['db']['host'],$ini['db']['user'],$ini['db']['pass']);
|
|
mysql_select_db($ini['db']['db']);
|
|
|
|
mysql_set_charset("utf8");
|
|
|
|
$randcode=mt_rand(0,10000);
|
|
$verified=0;
|
|
|
|
|
|
$sql=mysql_query("select ID,user_id from mailservice where user_id=$user_id");
|
|
if (mysql_num_rows($sql))
|
|
{
|
|
$id=mysql_result($sql,0,"ID");
|
|
$add=0;
|
|
}
|
|
else
|
|
{
|
|
$add=1;
|
|
}
|
|
|
|
if ($add==1){
|
|
$sql=mysql_query("insert into mailservice (user_id,address,ver_code,verified,language,radius) values ($user_id,'$address',$randcode,$verified,$language,$radius)");
|
|
}
|
|
else{
|
|
$sql=mysql_query("update mailservice set verified=$verified,address='$address',ver_code=$randcode,language=$language,radius=$radius where ID=$id");
|
|
}
|
|
|
|
$output[]="ok";
|
|
print(json_encode($output));
|
|
|
|
mysql_close();
|
|
|
|
if($language==0){
|
|
$message = "Hai ricevuto questa mail per aver richiesto l'attivazione del servizio di notifica di Earthquake Network di segnalazione dei terremoti segnalati dagli altri utenti. Il tuo codice di verifica è ".$randcode.". Inseriscilo nell'applicazione Android per confermare il servizio richiesto.";
|
|
$subject = "Codice di verifica di Earthquake Network";
|
|
}
|
|
if($language==1){
|
|
$message = "You received this e-mail as you request to be notified when a user report an earthquake through the Earthquake Network android application. Your activation code is ".$randcode.". Insert the code in the application in order to confirm the service.";
|
|
$subject = "Verification code of Earthquake Network";
|
|
}
|
|
if($language==2){
|
|
$message = "Ha recibido este e-mail como usted pide que se le notifique cuando un usuario informar de un terremoto a través de la Red Sísmica aplicación android. El código de verificación es ".$randcode.". Introducir en la aplicación Android para confirmar el servicio solicitado.";
|
|
$subject = "Código de verificación de Earthquake Network";
|
|
}
|
|
|
|
$message = wordwrap($message, 120, "\r\n");
|
|
|
|
$headers = 'From: Earthquake Network <alert@earthquakenetwork.it>'."\r\n".
|
|
'Reply-To: noreply@earthquakenetwork.it'."\r\n".
|
|
'X-Mailer: PHP/' . phpversion();
|
|
mail($address, $subject, $message,$headers);
|
|
|
|
}
|
|
else{
|
|
$output[]="nok";
|
|
print(json_encode($output));
|
|
}
|
|
?>
|