Exemplo n.º 1
0
 public function createFile($name, $data = null)
 {
     global $charset, $base_path, $id_rep;
     if ($this->check_write_permission()) {
         if ($charset !== 'utf-8') {
             $name = utf8_decode($name);
         }
         $filename = realpath($base_path . "/temp/") . "/webdav_" . md5($name . time()) . "." . extension_fichier($name);
         $fp = fopen($filename, "w");
         if (!$fp) {
             //on a pas le droit d'écriture
             throw new DAV\Exception\Forbidden('Permission denied to create file (filename ' . $filename . ')');
         }
         while ($buf = fread($data, 1024)) {
             fwrite($fp, $buf);
         }
         fclose($fp);
         $notice_id = $this->notice_id;
         $bulletin_id = 0;
         $query = "SELECT CONCAT(niveau_biblio, niveau_hierar) AS niveau FROM notices WHERE notice_id = " . $this->notice_id;
         $result = pmb_mysql_query($query);
         if (pmb_mysql_num_rows($result)) {
             $row = pmb_mysql_fetch_object($result);
             if ($row->niveau == "b2") {
                 $query = "SELECT bulletin_id FROM bulletins WHERE num_notice = " . $this->notice_id;
                 $result = pmb_mysql_query($query);
                 if (pmb_mysql_num_rows($result)) {
                     $row = pmb_mysql_fetch_object($result);
                     $notice_id = 0;
                     $bulletin_id = $row->bulletin_id;
                 }
             }
         }
         $explnum = new \explnum(0, $notice_id, $bulletin_id);
         $id_rep = $this->parentNode->config['upload_rep'];
         $explnum->get_file_from_temp($filename, $name, $this->parentNode->config['up_place']);
         $explnum->params['explnum_statut'] = $this->config['default_docnum_statut'];
         $explnum->update();
         $this->update_notice($this->notice_id);
         if (file_exists($filename)) {
             unlink($filename);
         }
     } else {
         //on a pas le droit d'écriture
         throw new DAV\Exception\Forbidden('Permission denied to create file (filename ' . $name . ')');
         return false;
     }
 }
Exemplo n.º 2
0
 function put($data)
 {
     global $base_path;
     global $id_rep;
     if ($this->check_write_permission()) {
         $filename = tempnam($base_path . "/temp/", "webdav_");
         $fp = fopen($filename, "w");
         while ($buf = fread($data, 1024)) {
             fwrite($fp, $buf);
         }
         $explnum = new \explnum($this->explnum_id);
         fclose($fp);
         $id_rep = $this->config['upload_rep'];
         $explnum->get_file_from_temp($filename, $explnum->explnum_nomfichier, $this->config['up_place']);
         $explnum->update();
         unlink($filename);
     } else {
         //on a pas le droit d'écriture
         throw new DAV\Exception\Forbidden('Permission denied to modify file (filename ' . $this->getName() . ')');
     }
 }
Exemplo n.º 3
0
 public function createFile($name, $data = null)
 {
     global $charset, $base_path, $id_rep;
     if ($charset !== 'utf-8') {
         $name = utf8_decode($name);
     }
     $filename = tempnam($base_path . "/temp/", "webdav_");
     $fp = fopen($filename, "w");
     while ($buf = fread($data, 1024)) {
         fwrite($fp, $buf);
     }
     fclose($fp);
     $explnum = new \explnum(0, $this->notice_id);
     $id_rep = $this->parentNode->config['upload_rep'];
     $explnum->get_file_from_temp($filename, $name, $this->parentNode->config['up_place']);
     $explnum->update();
     $this->update_notice($this->notice_id);
     if (file_exists($filename)) {
         unlink($filename);
     }
 }
Exemplo n.º 4
0
 function createFile($name, $data = null)
 {
     if ($this->check_write_permission()) {
         global $base_path;
         global $id_rep;
         global $charset;
         if ($charset !== 'utf-8') {
             $name = utf8_decode($name);
         }
         $filename = realpath($base_path . "/temp/") . "/webdav_" . md5($name . time()) . "." . extension_fichier($name);
         $fp = fopen($filename, "w");
         if (!$fp) {
             //on a pas le droit d'écriture
             throw new DAV\Exception\Forbidden('Permission denied to create file (filename ' . $filename . ')');
         }
         while ($buf = fread($data, 1024)) {
             fwrite($fp, $buf);
         }
         fclose($fp);
         if (!filesize($filename)) {
             //Erreur de copie du fichier
             //unlink($filename);
             //throw new Sabre_DAV_Exception_FileNotFound('Empty file (filename ' . $filename . ')');
         }
         $notice_id = $this->get_notice_by_meta($name, $filename);
         $this->update_notice($notice_id);
         $explnum = new \explnum(0, $notice_id);
         $id_rep = $this->config['upload_rep'];
         $explnum->get_file_from_temp($filename, $name, $this->config['up_place']);
         $explnum->update();
         if (file_exists($filename)) {
             unlink($filename);
         }
     } else {
         //on a pas le droit d'écriture
         throw new DAV\Exception\Forbidden('Permission denied to create file (filename ' . $name . ')');
     }
 }