From 4a1f360d396e08ce914bf5a5f7e90060d60eaf3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Mon, 22 Aug 2016 23:39:40 +0200 Subject: [PATCH] [bridges] use BridgeAbstract::getContents instead of file_get_contents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use of the proxy feature when enabled Signed-off-by: Pierre Mazière --- bridges/AnimeUltimeBridge.php | 2 +- bridges/Arte7Bridge.php | 2 +- bridges/FacebookBridge.php | 4 ++-- bridges/FlickrExploreBridge.php | 2 +- bridges/MangareaderBridge.php | 2 +- bridges/Releases3DSBridge.php | 2 +- bridges/Rue89Bridge.php | 2 +- bridges/SoundcloudBridge.php | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bridges/AnimeUltimeBridge.php b/bridges/AnimeUltimeBridge.php index 8289165f..c84ae09f 100644 --- a/bridges/AnimeUltimeBridge.php +++ b/bridges/AnimeUltimeBridge.php @@ -74,7 +74,7 @@ class AnimeUltimeBridge extends BridgeAbstract { if (!empty($item_uri)) { //Retrieve description from description page and convert relative image src info absolute image src - $html_item = file_get_contents($item_uri) or $this->returnServerError('Could not request Anime-Ultime: '.$item_uri); + $html_item = $this->getContents($item_uri) or $this->returnServerError('Could not request Anime-Ultime: '.$item_uri); $item_description = substr($html_item, strpos($html_item, 'class="principal_contain" align="center">') + 41); $item_description = substr($item_description, 0, strpos($item_description, '
')); $item_description = str_replace('src="images', 'src="'.$website.'images', $item_description); diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index 35df0a2d..70c04e4a 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -51,7 +51,7 @@ class Arte7Bridge extends BridgeAbstract{ function extractVideoset($category='toutes-les-videos', $lang='fr') { $url = 'http://www.arte.tv/guide/'.$lang.'/plus7/'.$category; - $input = file_get_contents($url) or die('Could not request ARTE.'); + $input = $this->getContents($url) or die('Could not request ARTE.'); if(strpos($input, 'categoryVideoSet') !== FALSE) { $input = explode('categoryVideoSet: ', $input); diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index c04ca9d8..efa49f0f 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -93,7 +93,7 @@ class FacebookBridge extends BridgeAbstract{ ), ); $context = stream_context_create($http_options); - $html = file_get_contents($captcha_action, false, $context); + $html = $this->getContents($captcha_action, false, $context); if ($html === FALSE) { $this->returnServerError('Failed to submit captcha response back to Facebook'); } unset($_SESSION['captcha_fields']); $html = str_get_html($html); @@ -129,7 +129,7 @@ class FacebookBridge extends BridgeAbstract{ $_SESSION['captcha_action'] = 'https://www.facebook.com'.$captcha->find('form', 0)->action; //Show captcha filling form to the viewer, proxying the captcha image - $img = base64_encode(file_get_contents($captcha->find('img', 0)->src)); + $img = base64_encode($this->getContents($captcha->find('img', 0)->src)); header('HTTP/1.1 500 '.Http::getMessageForCode(500)); header('Content-Type: text/html'); die('
' diff --git a/bridges/FlickrExploreBridge.php b/bridges/FlickrExploreBridge.php index a8b75694..25760fd9 100644 --- a/bridges/FlickrExploreBridge.php +++ b/bridges/FlickrExploreBridge.php @@ -25,7 +25,7 @@ class FlickrExploreBridge extends BridgeAbstract{ $imageID = reset($imageURIs); // Get the image JSON via Flickr API - $imageJSON = json_decode(file_get_contents('https://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=103b574d49bd51f0e18bfe907da44a0f&photo_id='.$imageID.'&format=json&nojsoncallback=1')) or $this->returnServerError('Could not request Flickr.'); // FIXME: Request time too long... + $imageJSON = json_decode($this->getContents('https://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=103b574d49bd51f0e18bfe907da44a0f&photo_id='.$imageID.'&format=json&nojsoncallback=1')) or $this->returnServerError('Could not request Flickr.'); // FIXME: Request time too long... $item = array(); $item['uri'] = 'https://flickr.com/photo.gne?id='.$imageID; diff --git a/bridges/MangareaderBridge.php b/bridges/MangareaderBridge.php index 06f05249..b2b5902a 100644 --- a/bridges/MangareaderBridge.php +++ b/bridges/MangareaderBridge.php @@ -102,7 +102,7 @@ class MangareaderBridge extends BridgeAbstract{ } // We'll use the DOM parser for this as it makes navigation easier - $html = file_get_contents("http://www.mangareader.net/" . $path); + $html = $this->getContents("http://www.mangareader.net/" . $path); if(!$html){ $this->returnClientError('Could not receive data for ' . $path . '!'); } diff --git a/bridges/Releases3DSBridge.php b/bridges/Releases3DSBridge.php index 2242e92b..2cff757b 100644 --- a/bridges/Releases3DSBridge.php +++ b/bridges/Releases3DSBridge.php @@ -37,7 +37,7 @@ class Releases3DSBridge extends BridgeAbstract { } $dataUrl = 'http://3dsdb.com/xml.php'; - $xml = file_get_contents($dataUrl) or $this->returnServerError('Could not request 3dsdb: '.$dataUrl); + $xml = $this->getContents($dataUrl) or $this->returnServerError('Could not request 3dsdb: '.$dataUrl); $limit = 0; foreach (array_reverse(explode('', $xml)) as $element) { diff --git a/bridges/Rue89Bridge.php b/bridges/Rue89Bridge.php index dcf405e1..76da28e9 100644 --- a/bridges/Rue89Bridge.php +++ b/bridges/Rue89Bridge.php @@ -13,7 +13,7 @@ class Rue89Bridge extends BridgeAbstract{ private function rue89getDatas($url){ $url = "http://api.rue89.nouvelobs.com/export/mobile2/node/" . str_replace(" ", "", substr($url, -8)) . "/full"; - $datas = json_decode(file_get_contents($url), true); + $datas = json_decode($this->getContents($url), true); return $datas["node"]; diff --git a/bridges/SoundcloudBridge.php b/bridges/SoundcloudBridge.php index 7950cef4..50758b11 100644 --- a/bridges/SoundcloudBridge.php +++ b/bridges/SoundcloudBridge.php @@ -28,8 +28,8 @@ class SoundCloudBridge extends BridgeAbstract{ { $this->request = $param['u']; - $res = json_decode(file_get_contents('https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/'. urlencode($this->request) .'&client_id=' . self::CLIENT_ID)) or $this->returnServerError('No results for this query'); - $tracks = json_decode(file_get_contents('https://api.soundcloud.com/users/'. urlencode($res->id) .'/tracks?client_id=' . self::CLIENT_ID)) or $this->returnServerError('No results for this user'); + $res = json_decode($this->getContents('https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/'. urlencode($this->request) .'&client_id=' . self::CLIENT_ID)) or $this->returnServerError('No results for this query'); + $tracks = json_decode($this->getContents('https://api.soundcloud.com/users/'. urlencode($res->id) .'/tracks?client_id=' . self::CLIENT_ID)) or $this->returnServerError('No results for this user'); } else {