[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-clamav-2/www/ -> clamav-status.php (source)

   1  <?php
   2  
   3  /**
   4     
   5     * Page clamv
   6     * @Version $Id: clamav-status.php 8567 2015-03-15 14:27:22Z plouf $ 
   7     
   8     * @Projet LCS / SambaEdu 
   9     
  10     * @auteurs 
  11  
  12     * @Licence Distribue selon les termes de la licence GPL
  13     
  14     * @note 
  15     
  16     */
  17  
  18     /**
  19  
  20     * @Repertoire: /se3-clamav
  21     * file: clamav-status.php
  22     */
  23  
  24  
  25  
  26  require("entete.inc.php");
  27  require  ("ihm.inc.php");
  28  
  29  
  30  
  31  $action=$_POST[action];
  32  $mailing=$_POST[mailing];
  33  $address=$_POST[address];
  34  
  35  
  36  if ( is_admin("se3_is_admin",$login)!="Y")  if ( ($uid != $login) || (($uid == $login)&&((!preg_match("//home/$login/", $wrep))&&($consul!=1))))  die (gettext("Vous n'avez pas les droits suffisants pour acc�der � cette fonction")."</BODY></HTML>");
  37  
  38  //
  39  // Fichier de paquets apt - date de mise a jour.
  40  //
  41  
  42  $now = getdate();
  43  $updatetime = filemtime("/var/cache/apt/pkgcache.bin");
  44  $update_days = floor(($now[0]-$updatetime)/(3600*24));
  45  
  46  //
  47  // Base des signatures antivirales
  48  //
  49  $dailycvd = '/var/lib/clamav/daily.cvd';
  50  $dailycld = '/var/lib/clamav/daily.cld';
  51  
  52  if (file_exists($dailycvd)) {
  53      $update_virus_time = filemtime($dailycvd);
  54  }else{
  55      $update_virus_time = filemtime($dailycld);
  56  }
  57  
  58  //
  59  // Statut du paquet CLAMAV
  60  //
  61  
  62  $status = fopen("/var/lib/dpkg/status","r");
  63  $parse_state = "begin";
  64  while (!feof ($status)) {
  65    if ($parse_state == "begin") {
  66      $buffer = fgets($status,1024);
  67      if (preg_match ("/^Package\s*\:\s*clamav\s*/",$buffer)) {
  68        $parse_state="version";
  69      }
  70      continue;
  71    }
  72    if ($parse_state == "version") {
  73      $buffer = fgets($status,1024);
  74      if (preg_match ("/^Version/",$buffer)) {
  75        $line_pieces = explode(":",$buffer);
  76        $status_version = $line_pieces[1];
  77        $status_version = preg_replace("/^\s*/","",$status_version);
  78        $status_version = preg_replace("/\s*\b/","",$status_version);
  79        break;
  80      }
  81    }
  82  }
  83  fclose($status);
  84  
  85  $avail = fopen("/var/lib/dpkg/available","r");
  86  
  87  $parse_state = "begin";
  88  while (!feof ($avail)) {
  89    if ($parse_state == "begin") {
  90      $buffer = fgets($avail,1024);
  91      if (preg_match ("/^Package\s*\:\s*clamav\s*/",$buffer)) {
  92        $parse_state="version";
  93      }
  94      continue;
  95    }
  96    if ($parse_state == "version") {
  97      $buffer = fgets($avail,1024);
  98      if (preg_match ("/^Version/",$buffer)) {
  99        $line_pieces = explode(":",$buffer);
 100        $avail_version = $line_pieces[1];
 101        $avail_version = preg_replace("/^\s*/","",$avail_version);
 102        $avail_version = preg_replace("/\s*\b/","",$avail_version);
 103        break;
 104      }
 105    }
 106  }
 107  fclose($avail);
 108  ?>
 109  <h1> Solution antivirus serveur</h1>
 110  <h2> Mise &agrave; jour des informations sur les paquets </h2>
 111  La liste des paquets disponibles a &eacute;t&eacute; mise &agrave; jour le
 112  <? setlocale (LC_TIME, "fr_FR");
 113  echo strftime ("%A %d %B %Y",$updatetime); ?>
 114  <br/>
 115  <? if ($update_days > 0) {
 116    print "La mise &agrave; jour de la liste des paquets date de $update_days jours.\n";
 117    if ($update_days > 7) {
 118      print "vous devriez <a href=\"../action.php\"> mettre &agrave jour </a>";
 119    }
 120  } else {print "Il est inutile de mettre &agrave; jour";}
 121  ?>
 122  
 123  <h2> Installation de Clamav </h2>
 124  <table>
 125  <tr>
 126  <td class="menuheader">la version install&eacute;e de clamav est</td>
 127  <td class="menuheader">la version disponible de clamav est </td>
 128  </tr>
 129  <tr>
 130  <td class="menucell"><? echo $status_version; ?> </td>
 131  <td class="menucell"><? echo $avail_version; ?></td>
 132  </tr>
 133  </table>
 134  
 135  
 136  <?php
 137  
 138  if ($status_version == $avail_version) {
 139    print "vous n'avez pas besoin de faire de mise &agrave; jour";
 140  } else {
 141     print "vous devriez <a href=\"../action.php\"> mettre &agrave; jour</a>";
 142  }
 143  ?>
 144  
 145  <h2> Base des signatures virales </h2>
 146  La base des signatures virales a &eacute;t&eacute; mise &agrave; jour le :
 147  <? setlocale (LC_TIME, "fr_FR");
 148  echo strftime ("%A %d %B %Y",$update_virus_time); ?>
 149  
 150  <?php
 151  if ($action == "mailing") {
 152    //inscription des parametres dans la base SQL
 153    $mailing_boolean = "0"; 
 154    if (isset ($mailing)) {
 155      $mailing_boolean = "1"; 
 156    }
 157    $update_query = "UPDATE params SET value='$mailing_boolean' WHERE name='clamavmail'";
 158    mysql_query($update_query);
 159  
 160    $mailing_address = $address;
 161    $update_query = "UPDATE params SET value='$mailing_address' WHERE name='clamavadm'";
 162    mysql_query($update_query);
 163  
 164  } else {
 165    // Courriel 
 166    $query = "SELECT value from params where name='clamavmail'";
 167    $result = mysql_query($query);
 168    $r=mysql_fetch_array($result); 
 169    $mailing_boolean = $r["value"];
 170    //adresse 
 171    $query = "SELECT value from params where name='clamavadm'";
 172    $result = mysql_query($query);
 173    $r=mysql_fetch_array($result);
 174    $mailing_address = $r["value"];
 175  }
 176  ?>
 177  
 178  <h2> Rapport par courriel </h2>
 179  Le syst&egrave;me antivirus peut vous envoyer un rapport du scan par courriel &agrave; votre demande.
 180  <br/>
 181  <form action="clamav-status.php" method="post">
 182  <?php 
 183  if ($mailing_boolean == 0 ) { $selected=""; } else {$selected ="checked";}
 184  echo "<input type=\"checkbox\" name=\"mailing\" value=\"mailing\" $selected />\n"; 
 185  ?> Envoyer un courriel en cas de virus trouv&eacute;.
 186  <br>
 187  <input type="text" name="address" value="<?php echo "$mailing_address"; ?>"/> Adresse mail d'envoi du courriel.
 188  <br/>
 189  <input type="hidden" name="action" value="mailing">
 190  <input type="submit" value="Valider">
 191  </form>
 192  
 193  <?
 194  
 195  require ("pdp.inc.php");
 196  
 197  ?>


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