77 lines
2.8 KiB
PHP
Executable File
77 lines
2.8 KiB
PHP
Executable File
<?php
|
|
/*
|
|
Copyright (C) 2007 Mercier Benjamin
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
// Librairie d'ajout de base de donnée
|
|
|
|
if ( VerifPOST("Nom", "#^[a-z0-9]+$#", 3, 6) == "ChaineValide" )
|
|
{
|
|
if ( VerifPOST("MotDePasse", "#^[a-z0-9]+$#", 3, 9) == "ChaineValide" )
|
|
{
|
|
if ( ( VerifPOST("Commentaire", "#^[a-z0-9 ]+$#i", 0, 50) == "ChaineValide") or ( VerifPOST("Commentaire", "#^[a-z0-9]+$#i", 0, 50) == "ChaineVide"))
|
|
{
|
|
$NomBase = str_replace('_','',$_POST['Nom']);
|
|
$NomBase = str_replace(' ','',$NomBase);
|
|
|
|
$MdpBase = str_replace('_','',$_POST['MotDePasse']);
|
|
$MdpBase = str_replace(' ','',$MdpBase);
|
|
|
|
$VerificationExistance = $MySql->Select ("*", "basededonnee", "Nom='".$_SESSION['Utilisateur']."_".$NomBase."'", "", "", "", "");
|
|
if ( $VerificationExistance == FALSE )
|
|
{
|
|
$CountDB = $MySql->Count('id', 'basededonnee', "Utilisateur='{$_SESSION['Utilisateur']}'");
|
|
if ( ($CountDB >= $_SESSION['Offre']['BaseDeDonnees']) and ($_SESSION['Offre']['BaseDeDonnees'] != '-1')) {
|
|
$_SESSION['Resultat'] = "Désolé, votre offre ne vous permet pas d'ajouter plus de base(s) de données.";
|
|
$_SESSION['Lien'] = "Page-MySql-SuppressionBdd.html";
|
|
Redirect ('resultat.html');
|
|
} else {
|
|
$Conteneur = "Utilisateur, Nom, Password, Commentaire, DateDeCreation";
|
|
$Contenu = "'".$_SESSION['Utilisateur']."', '".$_SESSION['Utilisateur']."_".$NomBase."', '".$MdpBase."', '".$_POST['Commentaire']."', '".time()."'";
|
|
$MySql->Insert ($Conteneur,$Contenu, "basededonnee");
|
|
Redirect ('Page-MySql-Recapitulatif.html');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$_SESSION['Resultat'] = "Cette base de données existe deja";
|
|
$_SESSION['Lien'] = "Page-MySql-AjoutBdd.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$_SESSION['Resultat'] = "Le commentaire est incorrect";
|
|
$_SESSION['Lien'] = "Page-MySql-AjoutBdd.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$_SESSION['Resultat'] = "Le mot de passe est incorrect";
|
|
$_SESSION['Lien'] = "Page-MySql-AjoutBdd.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$_SESSION['Resultat'] = "Le nom de la base de données est incorrect";
|
|
$_SESSION['Lien'] = "Page-MySql-AjoutBdd.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
?>
|