cURL returned wrong HTTP code ā' . $aCurlInfo['http_code'] . 'ā, aborting.'; } return false; } return $aCurlInfo; } /** * @param string $sUrl The URL to the image to download. * @param int $cId The cast ID of the actor. * * @return string Local path. */ public static function saveImageCast($sUrl, $cId) { if ( ! preg_match('~http~', $sUrl)) { return 'cast/not-found.jpg'; } $sFilename = dirname(__FILE__) . '/cast/' . $cId . '.jpg'; if (file_exists($sFilename)) { return 'cast/' . $cId . '.jpg'; } $aCurlInfo = self::runCurl($sUrl, true); $sData = $aCurlInfo['contents']; if (false === $sData) { return 'cast/not-found.jpg'; } $oFile = fopen($sFilename, 'x'); fwrite($oFile, $sData); fclose($oFile); return 'cast/' . $cId . '.jpg'; } }