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); |
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 |
} |
} |
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 |
|
|
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 |
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 |
} |
} |