[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

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

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


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