144 lines
5.6 KiB
PHP
Executable File
144 lines
5.6 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 contenant l'ajout de sous-zone DNS
|
|
|
|
if ( VerifPOST('Donnee', '#^[a-z0-9.-]+$#', 1, 50) != 'ChaineValide' ){
|
|
$_SESSION['Resultat'] = "La syntaxe du sous domaine est invalide";
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
if ( VerifPOST('Domaine', "#kelio\.org#", 5, 120) == 'ChaineValide') {
|
|
$_SESSION['Resultat'] = "Vous ne pouvez ajouter de sous domaine kelio.org";
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
$Commentaire = htmlspecialchars($_POST['Commentaire']);
|
|
|
|
// Un sous domaine peut-il être ajouté
|
|
$CountDns = $MySql->Count('id', 'sousdomainedns', "Utilisateur='{$_SESSION['Utilisateur']}'");
|
|
if ( ($_SESSION['Offre']['SousDomaineDns'] != '-1') and ($CountDns >= $_SESSION['Offre']['SousDomaineDns']) ) {
|
|
$_SESSION['Resultat'] = "Votre offre ne vous permet pas d'ajouter plus de sous domaines";
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
// Le domaine appartient-il à quelqu'un d'autre
|
|
$VerifExistence = $MySql->Count('id', 'domaineinterdit', "Adresse='{$_POST['Domaine']}'", '', '', '', '');
|
|
if ($VerifExistence >= 1) {
|
|
$_SESSION['Resultat'] = "Ce nom de domaine ne vous appartient pas !";
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
$VerifExistence = $MySql->Count('id', 'domaineinterdit', "Adresse='{$_POST['Donnee']}.{$_POST['Domaine']}'", '', '', '', '');
|
|
if ($VerifExistence >= 1) {
|
|
$_SESSION['Resultat'] = "Ce nom de domaine ne vous appartient pas !";
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
// Le nom de domaine existe-t-il
|
|
$VerifZone = $MySql->Count('id', 'domainedns', "Utilisateur='{$_SESSION['Utilisateur']}' AND Domaine='{$_POST['Domaine']}' AND Status!='3'");
|
|
if ($VerifZone == 0) {
|
|
$_SESSION['Resultat'] = "Ce nom de domaine n'existe pas sur Kelio ou est en cours de suppression";
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
// Le sous domaine existe déjà
|
|
$VerifExistence = $MySql->Count('id', 'sousdomainedns', "Type='{$_POST['Type']}' AND Donnee='{$_POST['Donnee']}' AND Domaine='{$_POST['Domaine']}'");
|
|
if ($VerifExistence > 0) {
|
|
$_SESSION['Resultat'] = "Ce sous domaine existe deja sur Kelio";
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
// Domaine pointant sur les serveurs Kerio
|
|
if($_POST['Type'] == 1)
|
|
{
|
|
// Test de la racine
|
|
if ( (VerifPOST("Racine", "#^/[.a-z0-9/_-]+/$#", 1, 120) != "ChaineValide") and (VerifPOST("Racine", "#^/$#", 1, 120) != "ChaineValide") ) {
|
|
$_SESSION['Resultat'] = "La racine du sous domaine est invalide";
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
// Test de l'Open Basedir
|
|
if ( (VerifPOST("OpenBasedir", "#^/[.a-z0-9/_-]+/$#", 1, 120) != "ChaineValide") and (VerifPOST("OpenBasedir", "#^/$#", 1, 120) != "ChaineValide") ) {
|
|
$_SESSION['Resultat'] = "L'Open Basedir du sous domaine est invalide";
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
// Construction des données SQL
|
|
$Racine = $_POST['Racine'];
|
|
$OpenBasedir = $_POST['OpenBasedir'];
|
|
$Type = 1;
|
|
$Pointage = "";
|
|
}
|
|
// Domaine pointant à l'extérieur (de type CNAME, A ou AAAA)
|
|
elseif(($_POST['Type'] == 2) && ($_POST['TypePointage'] > 0) && ($_POST['TypePointage'] < 4))
|
|
{
|
|
// Vérification pour un CNAME
|
|
if(($_POST['TypePointage'] == 2) && (VerifPOST('Pointage', '#^[a-z0-9.-]+\.[a-z]+$#', 3, 50) == 'ChaineValide'))
|
|
{
|
|
// Construction des données SQL
|
|
$Pointage = $_POST['Pointage'];
|
|
}
|
|
// Vérification pour A
|
|
elseif(($_POST['TypePointage'] == 3) && (VerifPOST('Pointage', '#^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$#', 7, 15) == 'ChaineValide'))
|
|
{
|
|
// Construction des données SQL
|
|
$Pointage = $_POST['Pointage'];
|
|
}
|
|
// Vérification pour AAAA
|
|
/*elseif(($_POST['TypePointage'] == 4) && (VerifPOST('Pointage', '#^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$#', 7, 15) == 'ChaineValide'))
|
|
{
|
|
// Construction des données SQL
|
|
$Pointage = $_POST['Pointage'];
|
|
}*/
|
|
else
|
|
{
|
|
$_SESSION['Resultat'] = "Impossible de déterminer le pointage de ce sous domaine ".$POST['TypePointage'];
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
// Construction des données SQL
|
|
$Racine = "";
|
|
$OpenBasedir = "";
|
|
$Type = $_POST['TypePointage'];
|
|
}
|
|
else
|
|
{
|
|
$_SESSION['Resultat'] = "Impossible de déterminer le pointage de ce sous domaine";
|
|
$_SESSION['Lien'] = "Page-DNS-AjoutSousDomaine.html";
|
|
Redirect ('resultat.html');
|
|
}
|
|
|
|
$conteneur = 'Domaine, Donnee, Utilisateur, Racine, OpenBasedir, Type, Pointage, Commentaire, DateDeCreation, Status';
|
|
$contenu = "'{$_POST['Domaine']}', '{$_POST['Donnee']}', '{$_SESSION['Utilisateur']}', '{$Racine}', '{$OpenBasedir}', '{$Type}', '{$_POST['Pointage']}', '{$Commentaire}', '".time()."', 1";
|
|
$MySql->Insert ($conteneur,$contenu, "sousdomainedns");
|
|
Redirect ('Page-DNS-Recapitulatif.html');
|
|
|
|
?>
|