<?php
/**
* @Author Tarchini Maurizio
* @Version 1.0
* @AuthorEmail Maurizio Tarchini<hide@address.com>
* @AuthorSite http://www.mtxweb.ch
* @DocumentDate 25-2-2008
* @License FREE
* @LicenseDetail GUN General Public License
* @LicenseSite http://www.gnu.org/copyleft/gpl.html
* @PHPCompatibility 4.2 or later
* @DevelopmentStatus DIST - beta
*/
include_once "./lib/function_page.php";
if ($_POST['set'] != "ck")
{
PageIn();
if ($_GET['alert'] == 1)
{
echo '<script type="text/javascript">
alert("Le due password inserite non corrispondono!")
</script>';
}
if ($_GET['alert'] == 2)
{
echo '<script type="text/javascript">
alert("Tutti i campi devono essere completati!")
</script>';
}
if ($_GET['alert'] == 3)
{
echo '<script type="text/javascript">
alert("Il nome utente scelto o l\'email sono già presenti nel database!")
</script>';
}
if ($_GET['alert'] == 4)
{
echo '<script type="text/javascript">
alert("il carattere (:) non è accettato")
</script>';
}
echo '<h1>Area utenti: REGISTRAZIONE NUOVO UTENTE</h1>
<br><br>
';
BoxIn(500);
echo '<form action="new_user.php" method="POST">
<table border="0" cellpadding="10" cellspacing="0">
<tr>
<td>nome utente:<br><input type="text" name="username" class="search" maxlength="20"/></td>
<td>email:<br><input type="text" name="email" class="search" maxlength="50"/></td>
<td rowspan="3"><img src="./images/Floppy.png" border="0"</td>
</tr>
<tr>
<td>password:<br><input type="password" name="password" class="search" maxlength="10"/></td>
<td>riscrivi password:<br><input type="password" name="password2" class="search" maxlength="10"/></td>
</tr>
<tr>
<td><input type="hidden" value="ck" name="set" /><input type="submit" value="registrati" class="but"/></td>
<td></td>
</tr>
</table>
</form>';
BoxOut();
PageOut();
}
else
{
if ($_POST['password'] != $_POST['password2'])
{
header("Location: new_user.php?alert=1");
exit;
}
if ($_POST['password'] == "" OR $_POST['password2'] == "" OR $_POST['username'] == "" OR $_POST['email'] == "")
{
header("Location: new_user.php?alert=2");
exit;
}
include_once "./lib/function_db.php";
$sql = "SELECT * FROM users WHERE username='$_POST[username]' OR email='$_POST[email]'";
$res = GetRes($sql);
if ($row = mysql_fetch_array($res))
{
header("Location: new_user.php?alert=3");
exit;
}
if (strstr($_POST['username'], ":") != FALSE)
{
header("Location: new_user.php?alert=4");
exit;
}
require "./lib/function_rand_alphanumeric.php";
$code = casuale(29);
include "config.php";
$query = "INSERT INTO users (username,email,password,code,imm,nome,cognome) VALUES ('$_POST[username]','$_POST[email]','$_POST[password]','$code','nn.gif','nome','cognome')";
QueryExec($query);
include_once "./class/PHPMailer/class.phpmailer.php";
$mail = new PHPMailer();
$mail->From = $frommail;
$mail->FromName = $from;
$mail->Subject = $register_sub;
$mail->Body = $register_message;
$mail->Sender = $sender;
$mail->AddAddress ("$_POST[email]");
if($mail->Send())
{
PageIn();
echo '<h1>Area utenti: REGISTRAZIONE NUOVO UTENTE</h1>
<br><br>
'; BoxIn(450);
echo "Benvenuto <b>$_POST[username]</b>,<br>La tua registrazione è andata a buon fine. Nei prossimi minuti riceverai un email all'indirizzo <b>$_POST[email]</b> con un link su quale dovrai cliccare per attivare il tuo profilo<br><br><br><img src=\"./images/help.png\" border=\"0\" align=\"left\"><b>Perchè questa procedura?</b><br>Questa procedura è necessaria per vari motivi:<br><br>1. Per verificare che l'email inserito esista davvero.<br>2. Per evitare che qualcuno possa usare il tuo email senza autorizzazione.<br>3. Per evitare che con dei processi automatici, qualcuno possa attaccare il sito eseguendo numerose iscrizioni.";
BoxOut();
PageOut();
}
else
{
echo $mail->ErrorInfo;
}
}
?>