/[openfoncier]/trunk/obj/utils.class.php
ViewVC logotype

Diff of /trunk/obj/utils.class.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 637 by nhaye, Thu Nov 8 17:48:54 2012 UTC revision 638 by nhaye, Fri Nov 9 10:14:19 2012 UTC
# Line 449  class utils extends application { Line 449  class utils extends application {
449          }*/          }*/
450          // if a dirextory by that name exists, make sure it does          // if a dirextory by that name exists, make sure it does
451          // not already contain an avis de consultation, MAYBE WE DON'T NEED THIS          // not already contain an avis de consultation, MAYBE WE DON'T NEED THIS
452          if (file_exists($dir) && is_dir($dir)) {          if (file_exists($dir) AND is_dir($dir)) {
453              $dir_contents = trim(shell_exec('ls '.$dir));              $dir_contents = trim(shell_exec('ls '.$dir));
454              if (strpos($dir_contents, ' ') != false) {              if (strpos($dir_contents, ' ') != false) {
455                  $dir_contents = explode(' ', $dir_contents);                  $dir_contents = explode(' ', $dir_contents);
# Line 458  class utils extends application { Line 458  class utils extends application {
458              }              }
459              foreach ($dir_contents as $basefname) { // very useful for consultation              foreach ($dir_contents as $basefname) { // very useful for consultation
460                  if (strpos($basefname, $prefix)!==false) {                  if (strpos($basefname, $prefix)!==false) {
461                      $this -> addToMessage("error", _("Un retour d'avis existe deja."));                      return _("Un retour d'avis existe deja.");
462                      return false;                      
463                  }                  }
464              }              }
465          }          }
# Line 467  class utils extends application { Line 467  class utils extends application {
467                    
468          if (!file_exists($dir)) {          if (!file_exists($dir)) {
469              if (!mkdir($dir, 0775)) {              if (!mkdir($dir, 0775)) {
470                  $this -> addToMessage("error", _("Erreur dans la création de répertoire."));                  return _("Erreur dans la création de répertoire.");
                 return false;  
471              }              }
472          }          }
473                    
# Line 481  class utils extends application { Line 480  class utils extends application {
480    
481          $file = fopen($filename, 'w');          $file = fopen($filename, 'w');
482          if (!$file) {          if (!$file) {
483              $this -> addToMessage("error", _("Echec a la creation du fichier."));              return _("Echec a la creation du fichier.");
             return false;  
484          }          }
485          // check that the number of bytes written is equal to the length          // check that the number of bytes written is equal to the length
486          // of the data received          // of the data received
487          $num_written = fwrite($file, $fichier_base64, $file_len);          $num_written = fwrite($file, $fichier_base64, $file_len);
488                    
489          if (!$num_written) {          if (!$num_written) {
             $this -> addToMessage("error", _("La sauvegarde du fichier a echoue"));  
490              // remove the file              // remove the file
491              // the return value from shell can't be used for checking since              // the return value from shell can't be used for checking since
492              // one can not know if the NULL returned is because there was no              // one can not know if the NULL returned is because there was no
# Line 497  class utils extends application { Line 494  class utils extends application {
494              $ret = shell_exec("rm -f $filename 2>&1");              $ret = shell_exec("rm -f $filename 2>&1");
495              //if ($ret == NULL) { // an error occured while deleting the file              //if ($ret == NULL) { // an error occured while deleting the file
496              //}              //}
497              return false;              return _("La sauvegarde du fichier a echoue");
498          }          }
499          fclose($file);          fclose($file);
         $this -> addToMessage("ok",_("Fichier enregistre"));  
500          return true;          return true;
501      }      }
502  }  }

Legend:
Removed from v.637  
changed lines
  Added in v.638

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26