/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
- * Copyright (c) 2001-2014 *
+ * Copyright (c) 2001-2016 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Il s'agit de la partie logique, c'est a dire que cette fonction
* realise la copie.
*
- * http://doc.spip.org/@action_copier_local_dist
+ * http://code.spip.net/@action_copier_local_dist
*
* @param null $id_document
* @return bool|mixed|string
}
/**
- * http://doc.spip.org/@action_copier_local_post
+ * http://code.spip.net/@action_copier_local_post
*
* @param $id_document
* @return bool|mixed|string
$row = sql_fetsel("mode,fichier, descriptif, credits", "spip_documents", "id_document=$id_document");
$source = $row['fichier'];
- include_spip('inc/distant'); // pour 'copie_locale'
- $fichier = copie_locale($source);
- if ($fichier) {
- $fichier = _DIR_RACINE . $fichier;
- $files[] = array('tmp_name'=>$fichier,'name'=>basename($fichier));
- $ajouter_documents = charger_fonction('ajouter_documents','action');
- spip_log("convertit doc $id_document en local: $source => $fichier");
- $liste = array();
- $ajouter_documents($id_document,$files,'',0,$row['mode'],$liste);
-
- spip_unlink($fichier);
-
- // ajouter l'origine du document aux credits
- include_spip('action/editer_document');
- document_modifier($id_document,array('credits'=>($row['credits']?$row['credits'].', ':'').$source));
- return true;
-
+ // si la source est bien un fichier distant
+ // sinon c'est une donnee moisie, on ne fait rien
+ if (tester_url_absolue($source)){
+
+ include_spip('inc/distant'); // pour 'copie_locale'
+ $fichier = copie_locale($source);
+ if ($fichier) {
+ $fichier = _DIR_RACINE . $fichier;
+ $files[] = array('tmp_name'=>$fichier,'name'=>basename($fichier));
+ $ajouter_documents = charger_fonction('ajouter_documents','action');
+ spip_log("convertit doc $id_document en local: $source => $fichier");
+ $liste = array();
+ $ajouter_documents($id_document,$files,'',0,$row['mode'],$liste);
+
+ spip_unlink($fichier);
+
+ // ajouter l'origine du document aux credits
+ include_spip('action/editer_document');
+ document_modifier($id_document,array('credits'=>($row['credits']?$row['credits'].', ':'').$source));
+ return true;
+
+ } else {
+ spip_log("echec copie locale $source");
+ }
} else {
- spip_log("echec copie locale $source");
+ spip_log("echec copie locale $source n'est pas une URL distante", "medias" . _LOG_ERREUR);
}
+
return _T('medias:erreur_copie_fichier',array('nom'=>$source));
}