Back to PhocaGalleryPicasa class

Method loadDataByAddress

public static
loadDataByAddress
(mixed $address, mixed $type, mixed &$errorMsg)

Method loadDataByAddress - Source code

public static function loadDataByAddress($address, $type, &$errorMsg)
{
    $curl = $fopen = 1;
    $data = '';
    if (!function_exists("curl_init")) {
        $errorMsg .= Text::_('COM_PHOCAGALLERY_PICASA_NOT_LOADED_CURL');
        $curl = 0;
    }
    if (!PhocaGalleryUtils::iniGetBool('allow_url_fopen')) {
        if ($errorMsg != '') {
            $errorMsg .= '<br />';
        }
        $errorMsg .= Text::_('COM_PHOCAGALLERY_PICASA_NOT_LOADED_FOPEN');
        $fopen = 0;
    }
    if ($fopen == 0 && $curl == 0) {
        return false;
    }
    if ($curl == 1) {
        $init = curl_init();
        curl_setopt($init, CURLOPT_URL, $address);
        curl_setopt($init, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
        // Experimental
        curl_setopt($init, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($init, CURLOPT_CONNECTTIMEOUT, 10);
        $data = curl_exec($init);
        curl_close($init);
    } else {
        $data = @file_get_contents($address);
    }
    if ($data == '') {
        if ($errorMsg != '') {
            $errorMsg .= '<br />';
        }
        switch ($type) {
            case 'album':
                $errorMsg = Text::_('COM_PHOCAGALLERY_PICASA_NOT_LOADED_IMAGE');
                break;
            case 'user':
            default:
                $errorMsg .= Text::_('COM_PHOCAGALLERY_PICASA_NOT_LOADED_USER');
                break;
        }
        return false;
    }
    return $data;
}