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
| <?php
function mp($nb) {
$alpha = array('b', 'k', 'd', 'f', 'g', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'x', 'z');
$voyelles = array('a', 'e', 'i', 'o', 'u', 'y');
for($i = 0;$i < count($alpha);$i++) {
for($j = 0;$j < count($voyelles);$j++) {
$lexique[] = $alpha[$i] . $voyelles[$j];
$lexique[] = $voyelles[$j] . $alpha[$i];
}
}
mt_srand((float) microtime() * 1000000);
$mp = "";
$num = mt_rand(1, floor($nb / 2)-1);
$deja = array();
for($i = 0;$i < floor($nb / 2) ;$i++) {
mt_srand((float) microtime() * 1000000);
if ($num == $i) {
if (floor($nb / 2) != ($nb / 2))
$mp .= mt_rand(100, 999); //+ 1 char
else $mp .= mt_rand(10, 99);
} else {
$ok = false;
while (!$ok) {
$dejala = false;
mt_srand((float) microtime() * 1000000);
$n = mt_rand(0, count($lexique)-1);
for($j = 0;$j < count($deja);$j++) {
if ($deja[$j] == $n) {
$dejala = true;
}
}
if (!$dejala)break;
}
$deja[] = $n;
$mp .= $lexique[$n];
}
}
return $mp;
}
require('include/header.inc.php');
if(!empty($_GET['logout'])) {
unset($_SESSION['id_album']);
}
$classPage = "album";
$menu = 'album';
// $titreBandeau = 'Mon album';
if(empty($_POST) || !empty($_POST['nbparpageAvecPhoto']) || !empty($_POST['nbparpageSansPhoto'])) {
if(empty($_SESSION['id_album']))
$col2 = 'include/album.inc.php';
else include('include/albumview.inc.php');
} else if(!empty($_POST['mail']) && !$fram->utile->checkMail($_POST['mail'])) {
$alerte = 'Votre adresse mél est invalide';
$col2 = 'include/album.inc.php';
} else if(empty($_POST['mail'])) {
$alerte = 'Saisissez votre adresse mél';
$col2 = 'include/album.inc.php';
} else if(empty($_POST['pass'])) {
$sql->query("select pass from album where mail != '' and pass != '' and mail = '" . addslashes(stripslashes($_POST['mail'])) . "'");
if($sql->num()) {
$alerte = 'Votre mot de passe vous a été envoyé par mail';
$mp = $sql->res(0);
} else {
$alerte = 'Vous avez été inscrit et vos identifiants vous ont été envoyés par mail';
$mp = mp(10);
$query = "insert into album (`mail`,`pass`,`date`) values ('" . addslashes(stripslashes($_POST['mail'])) . "','" . $mp . "',NOW()) ";
$sql->query($query);
}
$sujet = 'Vos identifiants <a href="http://www.monsite.org';" target="_blank">www.monsite.org';</a>
$message = 'Voici vos identifiants afin vous connecter à l\'album' . $s_eol . $s_eol . 'Adresse mél : ' . stripslashes($_POST['mail']) . $s_eol . 'Mot de passe : ' . $mp . $s_eol;
$header = "MIME-Version: 1.0$s_eol";
$header .= "Content-type: text/plain; charset=iso-8859-1$s_eol";
$header .= "From: <a href="mailto:monmail@monmail.org">monmail@monmail.org</a>$s_eol";
$header .= "Reply-To: <a href="mailto:monmail@monmail.org">monmail@monmail.org</a>$s_eol";
$header .= "Return-path: <a href="mailto:monmail@monmail.org">monmail@monmail.org</a>$s_eol";
$header .= "Message-Id: " . uniqid('') . $s_eol;
mail($mail, $sujet, $message , $header);
$col2 = 'include/album.inc.php';
} else if(!empty($_POST['pass'])) {
$sql->query("select pass,id_album from album where mail != '' and pass != '' and mail = '" . addslashes(stripslashes($_POST['mail'])) . "'");
if($sql->num() && ($sql->res(0)) == stripslashes($_POST['pass'])) {
// suite
$_SESSION['id_album'] = $sql->res(1);
$_SESSION['mail'] = stripslashes($_POST['mail']);
include('include/albumview.inc.php');
} else {
$mp = $sql->res(0);
$sujet = 'Vos identifiants <a href="http://www.monsite.org';" target="_blank">www.monsite.org';</a>
$message = 'Voici vos identifiants afin vous connecter à l\'album' . $s_eol . $s_eol . 'Adresse mél : ' . stripslashes($_POST['mail']) . $s_eol . 'Mot de passe : ' . $mp . $s_eol;
$header = "MIME-Version: 1.0$s_eol";
$header .= "Content-type: text/plain; charset=iso-8859-1$s_eol";
$header .= "From: <a href="mailto:monmail@monmail.org">monmail@monmail.org</a>$s_eol";
$header .= "Reply-To: <a href="mailto:monmail@monmail.org">monmail@monmail.org</a>$s_eol";
$header .= "Return-path: <a href="mailto:monmail@monmail.org">monmail@monmail.org</a>$s_eol";
$header .= "Message-Id: " . uniqid('') . $s_eol;
mail($mail, $sujet, $message , $header);
$alerte = 'Votre mot de passe est incorrect, l\'original vous a été envoyé par mail';
$col2 = 'include/album.inc.php';
}
}
require('include/type.inc.php');
?> |
Partager