1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
| <?php
session_start();
if(isset($_POST["chapca"])) {
if(($_SESSION['captcha_code'] == $_POST['chapca']) && (!empty($_SESSION['captcha_code'])) ) {
//Passed!
$captcha_msg="Thank you";
}else{
// Not passed 8-(
$captcha_msg="invalid code";
if(isset($_POST["MM_insert"])){
unset($_POST["MM_insert"]);
}
if(isset($_POST["MM_update"])){
unset($_POST["MM_update"]);
}
}
}
class CaptchaImage {
var $font = "verdana.ttf";
function hex_to_dec($hexcolor){
//convert hex hex values to decimal ones
$dec_color=array('r'=>hexdec(substr($hexcolor,0,2)),'g'=>hexdec(substr($hexcolor,2,2)),'b'=>hexdec(substr($hexcolor,4,2)));
return $dec_color;
}
function generateCode($characters) {
/* list all possible characters, similar looking characters and vowels have been removed */
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}
return $code;
}
function CaptchaImage($width='120',$height='30',$characters='6',$hex_bg_color='FFFFFF',$hex_text_color="FF0000",$hex_noise_color="CC0000", $img_file='captcha.jpg') {
$rgb_bg_color=$this->hex_to_dec($hex_bg_color);
$rgb_text_color=$this->hex_to_dec($hex_text_color);
$rgb_noise_color=$this->hex_to_dec($hex_noise_color);
$code = $this->generateCode($characters);
/* font size will be 60% of the image height */
$font_size = $height * 0.60;
$image = @imagecreate($width, $height) or die('Cannot Initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, $rgb_bg_color['r'], $rgb_bg_color['g'],$rgb_bg_color['b']);
$text_color = imagecolorallocate($image, $rgb_text_color['r'], $rgb_text_color['g'],$rgb_text_color['b']);
$noise_color = imagecolorallocate($image, $rgb_noise_color['r'], $rgb_noise_color['g'],$rgb_noise_color['b']);
/* generate random dots in background */
for( $i=0; $i<($width*$height)/3; $i++ ) {
imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
}
/* generate random lines in background */
for( $i=0; $i<($width*$height)/150; $i++ ) {
imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
}
/* create textbox and add text */
$textbox = imagettfbbox($font_size, 0, $this->font, $code);
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code);
/* save the image */
imagejpeg($image,$img_file);
imagedestroy($image);
echo "<img src=\"$img_file?".time()."\" width=\"$width\" height=\"$height\" alt=\"security code\" id=\"captchaImg\">";
$_SESSION['captcha_code'] = $code;
}
}
?>
<?php require_once('../Connections/mb.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['pseudo'])) {
$loginUsername=$_POST['pseudo'];
$password=$_POST['motpasse'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "espace-membre.php";
$MM_redirectLoginFailed = "acces-errone.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_mb, $mb);
$LoginRS__query=sprintf("SELECT username, password FROM site_user WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $mb) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
?>
<?php
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "membre")) {
$insertSQL = sprintf("INSERT INTO site_user (prenom1, prenom2, nom1, nom2, email, password, username, sexe, jour, mois, annee, rue, numrue, ville, cp, province, pays, telephone) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['prenom1mem'], "text"),
GetSQLValueString($_POST['prenom2mem'], "text"),
GetSQLValueString($_POST['nom1mem'], "text"),
GetSQLValueString($_POST['nom2mem'], "text"),
GetSQLValueString($_POST['mailmembre'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['sexe'], "text"),
GetSQLValueString($_POST['jourmem'], "text"),
GetSQLValueString($_POST['moismem'], "text"),
GetSQLValueString($_POST['anneemem'], "text"),
GetSQLValueString($_POST['rue'], "text"),
GetSQLValueString($_POST['numrue'], "text"),
GetSQLValueString($_POST['ville'], "text"),
GetSQLValueString($_POST['cp'], "text"),
GetSQLValueString($_POST['province'], "text"),
GetSQLValueString($_POST['pays'], "text"),
GetSQLValueString($_POST['telephone'], "text"));
mysql_select_db($database_mb, $mb);
$Result1 = mysql_query($insertSQL, $mb) or die(mysql_error());
$insertGoTo = "paiement-abonnement.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "membre")) {
$insertSQL = sprintf("INSERT INTO site_session (sid, prenom) VALUES (%s, %s)",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['prenom1mem'], "text"));
mysql_select_db($database_mb, $mb);
$Result1 = mysql_query($insertSQL, $mb) or die(mysql_error());
$insertGoTo = "paiement-abonnement.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?> |
Partager