"; //Création de l'utilisateur pour l'accès à la base. $sql = "GRANT ALL PRIVILEGES ON $nameDB.* TO $userDB@localhost IDENTIFIED BY '$passwdDB' "; if (@mysql_query($sql, $link)) { $buffer = 1; } else { $buffer = "Create ACCESS DATABASE FROM $userDB [FAILED] :" . mysql_error() ; return $buffer ; } mysql_close(); $link = @mysql_connect($hostDB, $userDB, $passwdDB); if (!$link) { $buffer = "Connexion [FAILED]: " . mysql_error() ; return $buffer; }else{ $db_selected = @mysql_select_db($nameDB, $link); if (!$db_selected) { $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); } } //Create Table USER $sql = "CREATE TABLE IF NOT EXISTS USER ( idUser VARCHAR(50) NOT NULL, passwdUser VARCHAR(100) NOT NULL, PRIMARY KEY (idUser) );"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "Create Table USER: [FAILED] : " . mysql_error(); return $buffer ; }else{ $buffer = 1; } //Create Table SERVICE $sql = "CREATE TABLE IF NOT EXISTS SERVICE ( idService VARCHAR(50) NOT NULL, PRIMARY KEY (idService) );"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "Create Table SERVICE: [FAILED] : " . mysql_error(); }else{ $buffer = 1; } //Create Table SERVICEUSER $sql = "CREATE TABLE IF NOT EXISTS SERVICEUSER ( idUser VARCHAR(50) NOT NULL, idService VARCHAR(50) NOT NULL, PRIMARY KEY (idUser, idService) );"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "CREATE TABLE SERVICEUSER: [FAILED] : " . mysql_error(); return $buffer ; }else{ $buffer = 1; } // Create Table POWER /*$sql = "CREATE TABLE IF NOT EXISTS Power ( idPower VARCHAR(50) NOT NULL, descPower VARCHAR(50) NOT NULL;)";*/ $sql = "CREATE TABLE IF NOT EXISTS POWER ( idPower VARCHAR(50) NOT NULL, descPower VARCHAR(200), PRIMARY KEY (idPower) );"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "Create Table POWER: [FAILED] : " . mysql_error(); return $buffer ; }else{ $buffer = 1; } //Create Table CMDUSER $sql = "CREATE TABLE IF NOT EXISTS CMDUSER ( idPower VARCHAR(50) NOT NULL, idUser VARCHAR(50) NOT NULL, PRIMARY KEY (idPower, idUser));"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "Create Table CMDUSER: [FAILED] : " . mysql_error(); }else{ $buffer = 1; } //Create Table CMDSERVICE $sql = "CREATE TABLE IF NOT EXISTS CMDSERVICE ( idPower VARCHAR(50) NOT NULL, idService VARCHAR(50) NOT NULL, PRIMARY KEY (idPower, idService))"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "Create Table CMDSERVICE: [FAILED] : " . mysql_error(); return $buffer ; }else{ $buffer = 1; } //Create Table SWITCH $sql = "CREATE TABLE IF NOT EXISTS SWITCH ( idSwitch VARCHAR(50) NOT NULL, location VARCHAR(200), level INT(2), portignore VARCHAR(50) , PRIMARY KEY (idSwitch) );"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "Create Table SWITCH: [FAILED] : " . mysql_error(); return $buffer ; }else{ $buffer = 1; } //Create Table CMDSWITCH $sql = "CREATE TABLE IF NOT EXISTS CMDSWITCH ( idPower VARCHAR(50) NOT NULL, idSwitch VARCHAR(50) NOT NULL, idUser VARCHAR(50) NOT NULL, PRIMARY KEY (idPower, idSwitch, idUser) );"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "Create Table CMDSWITCH: [FAILED] : " . mysql_error(); return $buffer; }else{ $buffer = 1; } //Create Table SERVICESWITCH $sql = "CREATE TABLE IF NOT EXISTS SERVICESWITCH ( idService VARCHAR(50) NOT NULL, idSwitch VARCHAR(50) NOT NULL, PRIMARY KEY (idService, idSwitch) );"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "CREATE TABLE SERVICESWITCH: [FAILED] : " . mysql_error(); return $buffer ; }else{ $buffer = 1; } //CREATE Table RESEAU $sql = "CREATE TABLE IF NOT EXISTS NETWORK ( idNetwork VARCHAR(50) NOT NULL, nameNetwork VARCHAR(50) NOT NULL, interface VARCHAR(8) NOT NULL, mainRouter VARCHAR(50) NOT NULL, PRIMARY KEY (idNetwork) );"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "CREATE TABLE NETWORK: [FAILED] : " . mysql_error(); return $buffer ; }else{ $buffer = 1; } //CREATE Table DEVICE $sql = "CREATE TABLE IF NOT EXISTS DEVICE ( mac VARCHAR(20) NOT NULL, hostname VARCHAR(50) NOT NULL, ip VARCHAR(50) NOT NULL, type VARCHAR(20), PRIMARY KEY (hostname) );"; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "CREATE TABLE DEVICE: [FAILED] : " . mysql_error(); return $buffer ; }else{ $buffer = 1; } //init table POWER $power = array("addUser", "delUser", "updateUser", "addService", "delService", "updateService", "addServiceUser", "delServiceUser", "addSwitch", "delSwitch", "updateSwitch", "addServiceSwitch", "delServiceSwitch", "addRight", "delRight", "addNetwork", "delNetwork", "addDevice", "delDevice", "disablePort", "enablePort", "genFileKlaskConf", "klaskupdatesw", "klaskupdatedb", "klaskexportdb", "klaskgenmap", "klasksearch" ); foreach( $power as $idPower) { $sql = "INSERT INTO POWER VALUE('$idPower', '') "; @mysql_query($sql,$link); if (mysql_error()){ $buffer = "INSERT POWER $idPower IN TABLE SERVICESWITCH: [FAILED] : " . mysql_error(); return $buffer; }else{ $buffer = 1; } } //init table user, insert adminApp account $passwdAdminApp= md5($passwdAdminApp); $sql= "INSERT INTO USER VALUE('$adminApp', '$passwdAdminApp');"; @mysql_query($sql,$link); if (mysql_error()){ $buffer .= "INSERT USER ADMIN $adminApp IN TABLE USER: [FAILED] : " . mysql_error(); return $buffer; }else{ $buffer = 1; } //init table CMSUSER for adminApp account foreach( $power as $idPower) { $sql = "INSERT INTO CMDUSER VALUE('$idPower', '$adminApp') "; @mysql_query($sql,$link); if (mysql_error()){ $buffer .= "INSERT CMDUSER $idPower FOR USER $adminApp: [FAILED] : " . mysql_error(); return $buffer; }else{ $buffer = 1; } } return $buffer; } function createFileConfig($hostDB, $nameDB, $userDB, $passwdDB, $adminApp) { //Create file config.php $fileConfig="./conf/config.php"; $content = ""; if (!$handle=fopen($fileConfig, "w+")) { $buffer = "Open file $fileConfig: [FAILED]"; return $buffer; } if (!fwrite($handle, $content)) { $buffer = "Write in file $fileConfig: [FAILED]"; return $buffer; } return 1; } function displaySaisieDB() { $buffer = "

Installation Etape 1

"; $buffer .= "
"; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= "
Paramètres pour la création de la base de données
Nom de la machine :
Nom de la base de données:
Utilisateur (autorisé à créer une base de données, exemple root):
Mot de passe de l'utilisateur (autorisé à créer une base de donnée):
Utilisateur (pour l'accès de l'application à la base):
Mot de passe de l'utilisateur (pour l'accès à la base):
Compte administrateur de l'application:
Mot de passe du compte administrateur de l'application:
"; return $buffer; } function displayChooseAuth() { $buffer = "

Installation Etape 2: Choix d'authentification

"; $buffer .= "
"; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= "
Quel mode d'authentification souhaitez-vous ?
ClassiqueLDAP
"; return $buffer ; } function displaySaisieLDAP() { $buffer = "

Installation Etape 3: Paramètres LDAP

"; $buffer .= "
"; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .= ""; $buffer .=""; $buffer .= "
Nom du serveur LDAP
Bind des Utilisateurs (exemple: ou=people, dc=ens, dc=fr)
Champs du service d'affectation de l'utilisateur
"; return $buffer ; } function createFileLDAP($hostLDAP, $bindUser, $bindService) { //Create file auth_ldap.php $fileAuthLDAP="./ldap/auth_ldap.php"; $content = ""; if (!$handle=fopen($fileAuthLDAP, "w+")) { $buffer = "Open file $fileAuthLDAP: [FAILED]"; return $buffer; } if (!fwrite($handle, $content)) { $buffer = "Write in file $fileAuthLDAP: [FAILED]"; return $buffer; } //READ config.php $fileConfig="./conf/config.php"; $contentToWrite= ""; $handle = @fopen($fileConfig, "r"); if ($handle) { while (!feof($handle)) { $contentFile = fgets($handle, 4096); if ( !( ereg ("\?>", $contentFile) ) && (!ereg("GLOBALS\['auth'\]", $contentFile) ) ) { $contentToWrite .= $contentFile; } } } fclose($handle); $contentToWrite .= "\$GLOBALS['auth']=\"ldap\";\n"; $contentToWrite .= "?>\n"; //REWRITE config.php if (!$handle=fopen($fileConfig, "w+")) { $buffer = "Open file $fileConfig: [FAILED]"; return $buffer; } if (!fwrite($handle, $contentToWrite)) { $buffer = "Write in file $fileConfig: [FAILED]"; return $buffer; } return 1; } ?>