Example #1
0
include "../inc/config.php";
include "class/user.class.php";
//create connection object
@($db = new mysqli($host, $user, $pass, $db));
if (mysqli_connect_errno()) {
    echo 'Error  : could not connect to database. Try again';
    exit;
}
//create Annuaire object
$annuaire = new User();
require_once 'recaptchalib.php';
$privatekey = "6LdNdwwAAAAAAE8Ebj1P7odiKZyRjJXQyeLESwfN";
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
    //log connection sucess message
    $annuaire->_LOG($db, 'captchafail', $user_id, $username);
    die("L'image n'a pas été décodé correctement. Revenez en arrière et recommencez.\n Sinon envoyez votre nom de connexion par email avec un petit message à {$masteremail} pour que l'administrateur crée manuellement votre compte.<a href=\"register.php\">Go back and retry</a> " . "(reCAPTCHA said: " . $resp->error . ")");
}
//configure SMTP
ini_set('SMTP', 'smtp.free.fr');
ini_set('smtp_port', '25');
$to = '';
$subject = 'Activez votre compte';
//the important part The Headers
//this enable the email in HTML type
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: {$iTitle} <{$masteremail}>" . "\r\n";
//get the POST variables
$username = strtolower($_POST['username']);
//test if username contains other than digits and letters