[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-backup/var/www/se3/sauvegarde/supports/ -> saveNAS.php (source)

   1  <?php
   2  
   3  
   4  
   5   /**
   6  
   7     * Permet configurer la sauvegarde sur NAS (Backuppc)
   8     * @Version $Id: saveNAS.php 8590 2015-03-16 07:08:10Z plouf $
   9  
  10     * @Projet LCS / SambaEdu
  11  
  12     * @auteurs
  13  
  14     * @Licence Distribue selon les termes de la licence GPL
  15  
  16     * @note
  17  
  18     */
  19  
  20     /**
  21  
  22     * @Repertoire: sauvegarde/supports
  23     * file: saveNAS.php
  24  
  25    */
  26  
  27  // HTMLPurifier
  28  require_once  ("traitement_data.inc.php");
  29  
  30  require ("config.inc.php");
  31         require_once  ("functions.inc.php");
  32      require  ("ldap.inc.php");
  33      require  ("ihm.inc.php");
  34      include ("fonction_backup.inc.php");
  35  
  36      require_once ("lang.inc.php");
  37      bindtextdomain('sauvegarde',"/var/www/se3/locale");
  38      textdomain ('sauvegarde');
  39          
  40         
  41  
  42  
  43      // Verifie les droits
  44      $login =isauth();
  45      if (ldap_get_right("system_is_admin",$login)!="Y")
  46             die (gettext("Vous n'avez pas les droits suffisants pour acc&#233;der &#224; cette fonction")."</BODY></HTML>");
  47      
  48      $NAS_mntsuffix = $_GET['NAS_mntsuffix'];
  49      
  50      if ($NAS_mntsuffix == 'rien')
  51          $NAS_mntsuffix ='';
  52      
  53      if ( ($NAS_mntsuffix != 'pc') && ($NAS_mntsuffix != '') )
  54          die("Il faut choisir /var/lib/backuppc ou /var/lib/backuppc/pc comme point de montage");
  55      $sql= "SELECT * FROM `params` WHERE name = 'NAS_mntsuffix';";
  56      $c = mysql_query($sql) or die("ERREUR: $sql");
  57      if (mysql_num_rows($c) == 0 ) {
  58          $sql2 = "INSERT INTO `params` ( `id` , `name` , `value` , `srv_id` , `descr` , `cat` )"
  59               ."VALUES (NULL , 'NAS_mntsuffix', '$NAS_mntsuffix', '0', 'suffixe de montage NAS', '5');";
  60          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
  61  
  62      } else {
  63          $sql2 = "UPDATE `params` SET `value` =  '$NAS_mntsuffix', `cat` = 5  WHERE `params`.`name` ='NAS_mntsuffix' ;";
  64          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
  65      }
  66  
  67      
  68      ###################################################################################
  69  
  70      
  71      $NAS_protocol = $_GET['NAS_protocol'];
  72      
  73      if ( ($NAS_protocol != 'cifs') && ($NAS_protocol != 'nfs') )
  74          die("Il faut choisir cifs ou nfs comme protocole");
  75      $sql= "SELECT * FROM `params` WHERE name = 'NAS_protocol';";
  76      $c = mysql_query($sql) or die("ERREUR: $sql");
  77      if (mysql_num_rows($c) == 0 ) {
  78          $sql2 = "INSERT INTO `params` ( `id` , `name` , `value` , `srv_id` , `descr` , `cat` )"
  79               ."VALUES (NULL , 'NAS_protocol', '$NAS_protocol', '0', 'protocole NAS cifs ou nfs', '5');";
  80          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
  81  
  82      } else {
  83          $sql2 = "UPDATE `params` SET `value` = '$NAS_protocol' , `cat` = 5 WHERE `params`.`name` ='NAS_protocol' ;";
  84          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
  85      }
  86  
  87  
  88      ###################################################################################
  89      $NAS_ip = $_GET['NAS_ip'];
  90      $test = explode('.',$NAS_ip);
  91      if  (count($test) != 4)
  92          die("Votre adresse IP est invalide exemple: x.x.x.x !");
  93      $sql= "SELECT * FROM `params` WHERE name = 'NAS_ip';";
  94      $c= mysql_query($sql) or die("ERREUR: $sql");
  95      if (mysql_num_rows($c) == 0 ) {
  96          $sql2 = "INSERT INTO `params` ( `id` , `name` , `value` , `srv_id` , `descr` , `cat` )"
  97               ."VALUES (NULL , 'NAS_ip', '$NAS_ip', '0', 'adresse IP du NAS', '5');";
  98          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
  99  
 100      } else {
 101          $sql2 = "UPDATE `params` SET `value` = '$NAS_ip' , `cat` = 5  WHERE `params`.`name` ='NAS_ip' ;";
 102          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
 103      }
 104  
 105      ###################################################################################
 106      $NAS_share = $_GET['NAS_share'];
 107      if (trim($NAS_share) == '')
 108          die("Le nom de partage est invalide!");
 109      $sql= "SELECT * FROM `params` WHERE name = 'NAS_share';";
 110      $c= mysql_query($sql) or die("ERREUR: $sql");
 111      if (mysql_num_rows($c) == 0 ) {
 112          $sql2 = "INSERT INTO `params` ( `id` , `name` , `value` , `srv_id` , `descr` , `cat` )"
 113               ."VALUES (NULL , 'NAS_share', '$NAS_share', '0', 'nom de partage du NAS', '5');";
 114          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
 115  
 116      } else {
 117          $sql2 = "UPDATE `params` SET `value` = '$NAS_share' , `cat` = 5  WHERE `params`.`name` ='NAS_share' ;";
 118          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
 119      }
 120  
 121  
 122      ###################################################################################
 123      if ($NAS_protocol == 'nfs') {
 124          $NAS_login = '';
 125      } 
 126      else
 127          $NAS_login = $_GET['NAS_login'];
 128      
 129  
 130      $sql= "SELECT * FROM `params` WHERE name = 'NAS_login';";
 131      $c= mysql_query($sql) or die("ERREUR: $sql");
 132      if (mysql_num_rows($c) == 0 ) {
 133          $sql2 = "INSERT INTO `params` ( `id` , `name` , `value` , `srv_id` , `descr` , `cat` )"
 134               ."VALUES (NULL , 'NAS_login', '$NAS_login', '0', 'login de connexion au NAS', '5');";
 135          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
 136  
 137      } else {
 138          $sql2 = "UPDATE `params` SET `value` = '$NAS_login' , `cat` = 5 WHERE `params`.`name` ='NAS_login' ;";
 139          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
 140      }
 141  
 142  
 143      ###################################################################################
 144      if ($NAS_protocol == 'nfs') {
 145          $NAS_pass = '';
 146      } 
 147      else
 148          $NAS_pass = $_GET['NAS_pass'];
 149      
 150  
 151      $sql= "SELECT * FROM `params` WHERE name = 'NAS_pass';";
 152      $c= mysql_query($sql) or die("ERREUR: $sql");
 153      if (mysql_num_rows($c) == 0 ) {
 154          $sql2 = "INSERT INTO `params` ( `id` , `name` , `value` , `srv_id` , `descr` , `cat` )"
 155               ."VALUES (NULL , 'NAS_pass', '$NAS_pass', '0', 'mot de passe du NAS', '5');";
 156          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
 157  
 158      } else {
 159          $sql2 = "UPDATE `params` SET `value` = '$NAS_pass' , `cat` = 5 WHERE `params`.`name` ='NAS_pass' ;";
 160          $c2 = mysql_query($sql2) or die("ERREUR: $sql2");
 161      }
 162  
 163  
 164      die("Modifications r�alis�es avec succes !");
 165  
 166  ?>


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1