Skip to content
Extraits de code Groupes Projets
Valider 880eb19b rédigé par cerdic's avatar cerdic
Parcourir les fichiers

le @unlink n'evite pas le fatal error si le fichier n'existe pas chez free, on...

le @unlink n'evite pas le fatal error si le fichier n'existe pas chez free, on remplace par spip_unlink qui  teste la presence du fichier par un file_exists
parent 743bec09
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 37 ajouts et 37 suppressions
...@@ -96,7 +96,7 @@ function action_charger_plugin_dist() { ...@@ -96,7 +96,7 @@ function action_charger_plugin_dist() {
) )
); );
if (_request('extract')) { if (_request('extract')) {
@unlink($fichier); spip_unlink($fichier);
} }
} }
......
...@@ -339,7 +339,7 @@ function analyser_site($url) { ...@@ -339,7 +339,7 @@ function analyser_site($url) {
$result['logo'] = $image['fichier']; $result['logo'] = $image['fichier'];
} }
else if ($image['fichier']) { else if ($image['fichier']) {
@unlink($image['fichier']); spip_unlink($image['fichier']);
} }
} }
} }
......
...@@ -38,7 +38,7 @@ function action_iconifier_dist() ...@@ -38,7 +38,7 @@ function action_iconifier_dist()
function action_spip_image_effacer_dist($arg) { function action_spip_image_effacer_dist($arg) {
if (!strstr($arg, "..")) if (!strstr($arg, ".."))
@unlink(_DIR_LOGOS . $arg); spip_unlink(_DIR_LOGOS . $arg);
} }
// //
...@@ -83,7 +83,7 @@ function action_spip_image_ajouter_dist($arg,$sousaction2,$source) { ...@@ -83,7 +83,7 @@ function action_spip_image_ajouter_dist($arg,$sousaction2,$source) {
if (_LOGO_MAX_SIZE > 0 if (_LOGO_MAX_SIZE > 0
AND $poids > _LOGO_MAX_SIZE*1024) { AND $poids > _LOGO_MAX_SIZE*1024) {
@unlink ($f); spip_unlink ($f);
check_upload_error(6, check_upload_error(6,
_T('info_logo_max_poids', _T('info_logo_max_poids',
array('maxi' => taille_en_octets(_LOGO_MAX_SIZE*1024), array('maxi' => taille_en_octets(_LOGO_MAX_SIZE*1024),
...@@ -93,7 +93,7 @@ function action_spip_image_ajouter_dist($arg,$sousaction2,$source) { ...@@ -93,7 +93,7 @@ function action_spip_image_ajouter_dist($arg,$sousaction2,$source) {
if (_LOGO_MAX_WIDTH * _LOGO_MAX_HEIGHT if (_LOGO_MAX_WIDTH * _LOGO_MAX_HEIGHT
AND ($size[0] > _LOGO_MAX_WIDTH AND ($size[0] > _LOGO_MAX_WIDTH
OR $size[1] > _LOGO_MAX_HEIGHT)) { OR $size[1] > _LOGO_MAX_HEIGHT)) {
@unlink ($f); spip_unlink ($f);
check_upload_error(6, check_upload_error(6,
_T('info_logo_max_taille', _T('info_logo_max_taille',
array( array(
...@@ -110,7 +110,7 @@ function action_spip_image_ajouter_dist($arg,$sousaction2,$source) { ...@@ -110,7 +110,7 @@ function action_spip_image_ajouter_dist($arg,$sousaction2,$source) {
@rename ($f, _DIR_LOGOS . $arg . ".$type"); @rename ($f, _DIR_LOGOS . $arg . ".$type");
} }
else { else {
@unlink ($f); spip_unlink ($f);
check_upload_error(6,_T('info_logo_format_interdit', check_upload_error(6,_T('info_logo_format_interdit',
array('formats' => join(', ', $formats_logos)))); array('formats' => join(', ', $formats_logos))));
} }
......
...@@ -223,7 +223,7 @@ function inc_joindre6_dist($path, $mode, $type, $id, $id_document,$hash, $redire ...@@ -223,7 +223,7 @@ function inc_joindre6_dist($path, $mode, $type, $id, $id_document,$hash, $redire
{ {
$x = joindre_deballes($path, $mode, $type, $id, $id_document,$hash, $redirect, $actifs); $x = joindre_deballes($path, $mode, $type, $id, $id_document,$hash, $redirect, $actifs);
// suppression de l'archive en zip // suppression de l'archive en zip
@unlink($path); spip_unlink($path);
return $x; return $x;
} }
......
...@@ -32,7 +32,7 @@ function action_purger_dist() ...@@ -32,7 +32,7 @@ function action_purger_dist()
case 'cache': case 'cache':
supprime_invalideurs(); supprime_invalideurs();
@unlink(_CACHE_RUBRIQUES); spip_unlink(_CACHE_RUBRIQUES);
purger_repertoire(_DIR_CACHE); purger_repertoire(_DIR_CACHE);
break; break;
......
...@@ -78,7 +78,7 @@ function supprimer_document_et_vignette($arg) ...@@ -78,7 +78,7 @@ function supprimer_document_et_vignette($arg)
{ {
$result = spip_query("SELECT id_vignette, fichier FROM spip_documents WHERE id_document=$arg"); $result = spip_query("SELECT id_vignette, fichier FROM spip_documents WHERE id_document=$arg");
if ($row = spip_abstract_fetch($result)) { if ($row = spip_abstract_fetch($result)) {
@unlink(get_spip_doc($row['fichier'])); spip_unlink(get_spip_doc($row['fichier']));
spip_query("DELETE FROM spip_documents WHERE id_document=$arg"); spip_query("DELETE FROM spip_documents WHERE id_document=$arg");
spip_query("UPDATE spip_documents SET id_vignette=0 WHERE id_vignette=$arg"); spip_query("UPDATE spip_documents SET id_vignette=0 WHERE id_vignette=$arg");
spip_query("DELETE FROM spip_documents_articles WHERE id_document=$arg"); spip_query("DELETE FROM spip_documents_articles WHERE id_document=$arg");
...@@ -89,7 +89,7 @@ function supprimer_document_et_vignette($arg) ...@@ -89,7 +89,7 @@ function supprimer_document_et_vignette($arg)
$result = spip_query("SELECT fichier FROM spip_documents WHERE id_document=$id_vignette"); $result = spip_query("SELECT fichier FROM spip_documents WHERE id_document=$id_vignette");
if ($row = spip_abstract_fetch($result)) { if ($row = spip_abstract_fetch($result)) {
@unlink(get_spip_doc($row['fichier'])); spip_unlink(get_spip_doc($row['fichier']));
} }
spip_query("DELETE FROM spip_documents WHERE id_document=$id_vignette"); spip_query("DELETE FROM spip_documents WHERE id_document=$id_vignette");
spip_query("DELETE FROM spip_documents_articles WHERE id_document=$id_vignette"); spip_query("DELETE FROM spip_documents_articles WHERE id_document=$id_vignette");
......
...@@ -67,7 +67,7 @@ function action_tester_taille_dist() { ...@@ -67,7 +67,7 @@ function action_tester_taille_dist() {
if ($src) { if ($src) {
ecrire_meta('max_taille_vignettes',$taille*$taille,'non'); ecrire_meta('max_taille_vignettes',$taille*$taille,'non');
ecrire_metas(); ecrire_metas();
@unlink($src); spip_unlink($src);
} }
else { else {
if (!$max_size_echec OR $s < $max_size_echec) if (!$max_size_echec OR $s < $max_size_echec)
......
...@@ -96,7 +96,7 @@ function action_tourner_post($r) ...@@ -96,7 +96,7 @@ function action_tourner_post($r)
spip_query("UPDATE spip_documents SET fichier=$f, largeur=$largeur, hauteur=$hauteur WHERE id_document=$arg"); spip_query("UPDATE spip_documents SET fichier=$f, largeur=$largeur, hauteur=$hauteur WHERE id_document=$arg");
if ($effacer) { if ($effacer) {
spip_log("j'efface $effacer"); spip_log("j'efface $effacer");
@unlink($effacer); spip_unlink($effacer);
} }
} }
......
...@@ -301,7 +301,7 @@ function forum_fichier_tmp($arg) ...@@ -301,7 +301,7 @@ function forum_fichier_tmp($arg)
while (($file = @readdir($dh)) !== false) while (($file = @readdir($dh)) !== false)
if (preg_match('/^forum_([0-9]+)\.lck$/', $file) if (preg_match('/^forum_([0-9]+)\.lck$/', $file)
AND (time()-@filemtime(_DIR_TMP.$file) > 4*3600)) AND (time()-@filemtime(_DIR_TMP.$file) > 4*3600))
@unlink(_DIR_TMP.$file); spip_unlink(_DIR_TMP.$file);
return $alea; return $alea;
} }
?> ?>
...@@ -24,7 +24,7 @@ function convert_utf8_init($tables_a_convertir) ...@@ -24,7 +24,7 @@ function convert_utf8_init($tables_a_convertir)
spip_query("UPDATE $table SET $champ = CONCAT('<CONVERT ".$charset_source.">', $champ) WHERE $champ NOT LIKE '<CONVERT %'"); spip_query("UPDATE $table SET $champ = CONCAT('<CONVERT ".$charset_source.">', $champ) WHERE $champ NOT LIKE '<CONVERT %'");
} }
@unlink(_DIR_TMP.'convert_utf8_backup.sql'); spip_unlink(_DIR_TMP.'convert_utf8_backup.sql');
// convertir spip_meta // convertir spip_meta
......
...@@ -68,8 +68,8 @@ function base_delete_all_dist($titre) ...@@ -68,8 +68,8 @@ function base_delete_all_dist($titre)
// un pipeline pour detruire les tables installees par les plugins // un pipeline pour detruire les tables installees par les plugins
pipeline('delete_tables', ''); pipeline('delete_tables', '');
@unlink(_ACCESS_FILE_NAME); spip_unlink(_ACCESS_FILE_NAME);
@unlink(_FILE_CONNECT); spip_unlink(_FILE_CONNECT);
spip_log("destruction operee redirige vers " . _request('redirect')); spip_log("destruction operee redirige vers " . _request('redirect'));
} }
?> ?>
...@@ -676,9 +676,9 @@ function maj_base($version_cible = 0) { ...@@ -676,9 +676,9 @@ function maj_base($version_cible = 0) {
if (upgrade_vers(1.603, $version_installee, $version_cible)) { if (upgrade_vers(1.603, $version_installee, $version_cible)) {
// supprimer les fichiers deplaces // supprimer les fichiers deplaces
@unlink('inc_meta_cache.php'); spip_unlink('inc_meta_cache.php');
@unlink('inc_meta_cache.php3'); spip_unlink('inc_meta_cache.php3');
@unlink('data/engines-list.ini'); spip_unlink('data/engines-list.ini');
maj_version (1.603); maj_version (1.603);
} }
......
...@@ -77,7 +77,7 @@ function calculer_visites($t) { ...@@ -77,7 +77,7 @@ function calculer_visites($t) {
spip_log("traite la session $item"); spip_log("traite la session $item");
compte_fichier_visite($item, compte_fichier_visite($item,
$visites, $visites_a, $referers, $referers_a, $articles); $visites, $visites_a, $referers, $referers_a, $articles);
@unlink($item); spip_unlink($item);
if (--$compteur <= 0) if (--$compteur <= 0)
break; break;
} }
......
...@@ -55,7 +55,7 @@ function exec_export_all_dist() ...@@ -55,7 +55,7 @@ function exec_export_all_dist()
$l = preg_files($file . ".part_[0-9]+_[0-9]+"); $l = preg_files($file . ".part_[0-9]+_[0-9]+");
if ($l) { if ($l) {
spip_log("menage d'une sauvegarde inachevee: " . join(',', $l)); spip_log("menage d'une sauvegarde inachevee: " . join(',', $l));
foreach($l as $dummy)@unlink($dummy); foreach($l as $dummy)spip_unlink($dummy);
} }
$start = true; // utilise pour faire un premier hit moitie moins long $start = true; // utilise pour faire un premier hit moitie moins long
$tables_sauvegardees = array(); $tables_sauvegardees = array();
......
...@@ -28,7 +28,7 @@ function exec_install_dist() ...@@ -28,7 +28,7 @@ function exec_install_dist()
// On va supprimer les eventuelles vieilles valeurs de meta, // On va supprimer les eventuelles vieilles valeurs de meta,
// on perd l'init des langues, mais elle est refaite par menu_langue // on perd l'init des langues, mais elle est refaite par menu_langue
@unlink(_FILE_META); spip_unlink(_FILE_META);
$GLOBALS['meta'] = array(); $GLOBALS['meta'] = array();
include_spip('base/create'); include_spip('base/create');
$fonc = charger_fonction("etape_$etape", 'install'); $fonc = charger_fonction("etape_$etape", 'install');
......
...@@ -142,8 +142,8 @@ function ecrire_acces() { ...@@ -142,8 +142,8 @@ function ecrire_acces() {
// si .htaccess existe, outrepasser spip_meta // si .htaccess existe, outrepasser spip_meta
if (($GLOBALS['meta']['creer_htpasswd'] != 'oui') if (($GLOBALS['meta']['creer_htpasswd'] != 'oui')
AND !@file_exists($htaccess)) { AND !@file_exists($htaccess)) {
@unlink($htpasswd); spip_unlink($htpasswd);
@unlink($htpasswd."-admin"); spip_unlink($htpasswd."-admin");
return; return;
} }
...@@ -214,7 +214,7 @@ function gerer_htaccess() { ...@@ -214,7 +214,7 @@ function gerer_htaccess() {
if (is_dir($dir = _DIR_IMG . $e['extension'])) { if (is_dir($dir = _DIR_IMG . $e['extension'])) {
if ($GLOBALS['meta']['creer_htaccess'] == 'oui') if ($GLOBALS['meta']['creer_htaccess'] == 'oui')
verifier_htaccess($dir); verifier_htaccess($dir);
else @unlink("$dir/" . _ACCESS_FILE_NAME); else spip_unlink("$dir/" . _ACCESS_FILE_NAME);
} }
} }
return $GLOBALS['meta']['creer_htaccess']; return $GLOBALS['meta']['creer_htaccess'];
......
...@@ -34,7 +34,7 @@ function inc_admin_dist($script, $titre, $comment='', $retour='') ...@@ -34,7 +34,7 @@ function inc_admin_dist($script, $titre, $comment='', $retour='')
$base($titre,$reprise); $base($titre,$reprise);
effacer_meta($script); effacer_meta($script);
ecrire_metas(); ecrire_metas();
@unlink(_FILE_META); spip_unlink(_FILE_META);
fin_admin($script); fin_admin($script);
spip_log("efface meta: $script " . ($retour ? $retour : '')); spip_log("efface meta: $script " . ($retour ? $retour : ''));
if ($retour) redirige_par_entete($retour); if ($retour) redirige_par_entete($retour);
...@@ -123,7 +123,7 @@ function debut_admin($script, $action='', $commentaire='') { ...@@ -123,7 +123,7 @@ function debut_admin($script, $action='', $commentaire='') {
// http://doc.spip.org/@fin_admin // http://doc.spip.org/@fin_admin
function fin_admin($action) { function fin_admin($action) {
$signal = dir_admin() . fichier_admin($action); $signal = dir_admin() . fichier_admin($action);
@unlink($signal); spip_unlink($signal);
@rmdir($signal); @rmdir($signal);
} }
......
...@@ -102,7 +102,7 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode, ...@@ -102,7 +102,7 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode,
return; return;
} }
if (!$tmp_dir = tempnam(_DIR_TMP, 'tmp_upload')) return; if (!$tmp_dir = tempnam(_DIR_TMP, 'tmp_upload')) return;
@unlink($tmp_dir); @mkdir($tmp_dir); spip_unlink($tmp_dir); @mkdir($tmp_dir);
$tmp = $tmp_dir.'/'.translitteration($nom_envoye); $tmp = $tmp_dir.'/'.translitteration($nom_envoye);
$nom_envoye .= '.zip'; # conserver l'extension dans le nom de fichier, par exemple toto.js => toto.js.zip $nom_envoye .= '.zip'; # conserver l'extension dans le nom de fichier, par exemple toto.js => toto.js.zip
deplacer_fichier_upload($source, $tmp); deplacer_fichier_upload($source, $tmp);
...@@ -118,7 +118,7 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode, ...@@ -118,7 +118,7 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode,
return; return;
} }
$fichier = copier_document($ext, $nom_envoye, $source); $fichier = copier_document($ext, $nom_envoye, $source);
@unlink($source); spip_unlink($source);
} else $fichier = copier_document($ext, $nom_envoye, $source); } else $fichier = copier_document($ext, $nom_envoye, $source);
...@@ -157,7 +157,7 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode, ...@@ -157,7 +157,7 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode,
if (!$type_image) { if (!$type_image) {
if (_DOC_MAX_SIZE > 0 if (_DOC_MAX_SIZE > 0
AND $taille > _DOC_MAX_SIZE*1024) { AND $taille > _DOC_MAX_SIZE*1024) {
@unlink ($fichier); spip_unlink ($fichier);
check_upload_error(6, check_upload_error(6,
_T('info_logo_max_poids', _T('info_logo_max_poids',
array('maxi' => taille_en_octets(_DOC_MAX_SIZE*1024), array('maxi' => taille_en_octets(_DOC_MAX_SIZE*1024),
...@@ -167,7 +167,7 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode, ...@@ -167,7 +167,7 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode,
else { // image else { // image
if (_IMG_MAX_SIZE > 0 if (_IMG_MAX_SIZE > 0
AND $taille > _IMG_MAX_SIZE*1024) { AND $taille > _IMG_MAX_SIZE*1024) {
@unlink ($fichier); spip_unlink ($fichier);
check_upload_error(6, check_upload_error(6,
_T('info_logo_max_poids', _T('info_logo_max_poids',
array('maxi' => taille_en_octets(_IMG_MAX_SIZE*1024), array('maxi' => taille_en_octets(_IMG_MAX_SIZE*1024),
...@@ -177,7 +177,7 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode, ...@@ -177,7 +177,7 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode,
if (_IMG_MAX_WIDTH * _IMG_MAX_HEIGHT if (_IMG_MAX_WIDTH * _IMG_MAX_HEIGHT
AND ($size_image[0] > _IMG_MAX_WIDTH AND ($size_image[0] > _IMG_MAX_WIDTH
OR $size_image[1] > _IMG_MAX_HEIGHT)) { OR $size_image[1] > _IMG_MAX_HEIGHT)) {
@unlink ($fichier); spip_unlink ($fichier);
check_upload_error(6, check_upload_error(6,
_T('info_logo_max_taille', _T('info_logo_max_taille',
array( array(
...@@ -197,13 +197,13 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode, ...@@ -197,13 +197,13 @@ function ajouter_un_document($source, $nom_envoye, $type_lien, $id_lien, $mode,
if ($mode == 'vignette') { if ($mode == 'vignette') {
if (!$type_inclus_image) { if (!$type_inclus_image) {
spip_log ("le format de $fichier ne convient pas pour une image"); # SVG spip_log ("le format de $fichier ne convient pas pour une image"); # SVG
@unlink($fichier); spip_unlink($fichier);
return; return;
} }
if (!($largeur * $hauteur)) { if (!($largeur * $hauteur)) {
spip_log('erreur upload vignette '.$fichier); spip_log('erreur upload vignette '.$fichier);
@unlink($fichier); spip_unlink($fichier);
return; return;
} }
} }
......
...@@ -163,7 +163,7 @@ function appliquer_modifs_config() { ...@@ -163,7 +163,7 @@ function appliquer_modifs_config() {
// provoquer l'envoi des nouveautes en supprimant le fichier lock // provoquer l'envoi des nouveautes en supprimant le fichier lock
if (_request('envoi_now')) { if (_request('envoi_now')) {
@unlink(_DIR_TMP . 'mail.lock'); spip_unlink(_DIR_TMP . 'mail.lock');
} }
// Purger les squelettes si un changement de meta les affecte // Purger les squelettes si un changement de meta les affecte
......
...@@ -132,7 +132,7 @@ function ramasse_parties($dir, $archive) ...@@ -132,7 +132,7 @@ function ramasse_parties($dir, $archive)
if (!ecrire_fichier($but,$contenu,false,false)) if (!ecrire_fichier($but,$contenu,false,false))
{ $ok = false; break;} { $ok = false; break;}
} }
@unlink($f); spip_unlink($f);
$files_o[]=$f; $files_o[]=$f;
} }
return $ok ? $files_o : false; return $ok ? $files_o : false;
...@@ -177,7 +177,7 @@ function export_objets($table, $etape, $cpt, $dir, $archive, $gz, $total, $les_r ...@@ -177,7 +177,7 @@ function export_objets($table, $etape, $cpt, $dir, $archive, $gz, $total, $les_r
ecrire_fichier ($temp = $filetable . '.temp' . _EXTENSION_PARTIES, $string); ecrire_fichier ($temp = $filetable . '.temp' . _EXTENSION_PARTIES, $string);
// le fichier destination peut deja exister // le fichier destination peut deja exister
// si on sort d'un timeout entre le rename et le ecrire_meta // si on sort d'un timeout entre le rename et le ecrire_meta
if (file_exists($f = $filetable . sprintf('_%04d',$cpt) . _EXTENSION_PARTIES)) @unlink($f); if (file_exists($f = $filetable . sprintf('_%04d',$cpt) . _EXTENSION_PARTIES)) spip_unlink($f);
rename($temp, $f); rename($temp, $f);
} }
// on se contente d'une ecriture en base pour aller plus vite // on se contente d'une ecriture en base pour aller plus vite
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter