1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-06-27 16:36:00 +00:00

Modif sur la fonction get_external_file

- Intégration du timeout dans la fonction, je ne pense pas qu'elle ai
besoin d'être changer lors de l'appel a la fonction.
- petit nettoyage de commentaire.
This commit is contained in:
PeaceCopathe 2013-04-15 22:42:04 +02:00
parent f44adcc4e4
commit aceab4dc3d

View file

@ -16,8 +16,9 @@ function get_poche_url()
} }
// function define to retrieve url content // function define to retrieve url content
function get_external_file($url, $timeout) function get_external_file($url)
{ {
$timeout=15; // Timeout : time until we stop waiting for the response.
// spoofing FireFox 18.0 // spoofing FireFox 18.0
$useragent="Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"; $useragent="Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0";
@ -45,10 +46,7 @@ function get_external_file($url, $timeout)
} else { } else {
// create http context and add timeout and user-agent // create http context and add timeout and user-agent
$context = stream_context_create(array('http'=>array('timeout' => $timeout, // Timeout : time until we stop waiting for the response. $context = stream_context_create(array('http'=>array('timeout' => $timeout,'header'=> "User-Agent: ".$useragent,/*spoot Mozilla Firefox*/'follow_location' => true)));
'header'=> "User-Agent: ".$useragent, // spoot Mozilla Firefox
'follow_location' => true
)));
// only download page lesser than 4MB // only download page lesser than 4MB
$data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source. $data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source.