Accueil

Keywords cloud

jquery ebx prototype getelementbyid math time put_line cout jmp drupal mainloop luhn linq cbind ivalueconverter ada.text_io sorted mysql_select_db xor md5 sql cat mysql_connect environment given nserror mail singleton filesystemobject xaml regex design window preg_replace eax preg_match tuple tkinter stringbuilder mysql_error readystate nslog email regexp map session_start shift innerhtml curl nsarray sed float chomp mysql_fetch_assoc nsdictionary media background push pop split je grep color file_get_contents mysql_query setsockopt prawn unless socket theme defun cursor createobject function_exists rem registry collect perform dbms_output wpf done strtolower onreadystatechange ecx substr urllib raw_input rm text-align random mov quicksort list wordpress dict edx display tolowercase boost mysql_fetch_array

Languages

PHPPHP :: WebGet Remote Filesize

Blank Source Code Snippet

Posted by viper212 - 2010-07-13 09:50:12 (35 views)
function remote_filesize($url, $user = "", $pw = "")
{
    ob_start();
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_NOBODY, 1);

    if(!empty($user) && !empty($pw))
    {
        $headers = array('Authorization: Basic ' .  base64_encode("$user:$pw"));
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    }

    $ok = curl_exec($ch);
    curl_close($ch);
    $head = ob_get_contents();
    ob_end_clean();

    $regex = '/Content-Length:\s([0-9].+?)\s/';
    $count = preg_match($regex, $head, $matches);

    return isset($matches[1]) ? $matches[1] : "unknown";
}

Comments

Related Source Code Snippets