Ejemplo n.º 1
0
 /**
  * Метод для получения текущего экземпляра.
  *
  * @param array $wdcs_prms конфигурация серверов WebDAV (см. конструктор)
  *
  * @return webdav_proxy
  */
 public static function getInst($wdcs_prms = null)
 {
     if (!self::$_inst) {
         self::$_inst = new self($wdcs_prms);
     }
     return self::$_inst;
 }
Ejemplo n.º 2
0
 /**
  * Метод для получения текущего экземпляра.
  *
  * @param array $wdcs_prms   конфигурация серверов WebDAV (см. конструктор)
  * @return webdav_proxy
  */
 static function getInst($wdcs_prms = NULL)
 {
     if (!self::$_inst) {
         self::$_inst = new webdav_proxy($wdcs_prms);
     }
     return self::$_inst;
 }
Ejemplo n.º 3
0
 /**
  * Проверяет файл антивирусом (drweb)
  * 
  * @param  boolean  $delete  Если TRUE, то удалит зараженный файл
  * @return integer           Код проверки (см. self::$virus) или FALSE в случае ошибки
  */
 public function antivirus($delete = TRUE)
 {
     global $DB;
     if (!defined('DRWEB_DEAMON') && !defined('DRWEB_DUMMY')) {
         return FALSE;
     }
     $path = pathinfo($this->name);
     if (in_array(strtolower($path['extension']), $this->antivirusSkip)) {
         $DB->update('file', array('virus' => '1000'), 'id = ?', $this->id);
         return 8;
     }
     $name = '';
     if (defined('DRWEB_DEAMON')) {
         $file = DRWEB_STORE . '/' . $this->path . $this->name;
         exec(DRWEB_DEAMON . ' -n' . DRWEB_HOST . ' -p' . DRWEB_PORT . ' -rv -f"' . $file . '"', $shellText, $res);
         if ($res > 0) {
             $code = 0;
             $code += $res & 1;
             $code += $res & 6 ? 2 : 0;
             $code += $res > 7 ? 4 : 0;
             if ($code == 1) {
                 if (preg_match('/Known virus/', $shellText[1])) {
                     $name = trim($shellText[2]);
                 }
                 if ($delete) {
                     $r = $DB->row("SELECT fname, path FROM {$this->table} WHERE id = ?", $this->id);
                     if ($r['fname']) {
                         $this->_wdp->delete('/' . $r['path'] . $r['fname']);
                     }
                 }
             }
         }
     }
     $this->virus = $code;
     $this->virusName = $name;
     $DB->update($this->table, array('virus' => sprintf("%04b", $code), 'virus_name' => $name), 'id = ?', $this->id);
     return $code;
 }