Changeset 3024

Show
Ignore:
Timestamp:
11/07/06 11:55:15 (7 years ago)
Author:
gregmac
Message:

Rename get_headers to get_headers_assoc (#1286)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/amp_conf/htdocs/admin/functions.inc.php

    r2991 r3024  
    895895} 
    896896 
    897 // get_headers() for php4 (built in for php5) 
    898 if (!function_exists('get_headers')) { 
    899   function get_headers($url ) { 
    900     $url_info=parse_url($url); 
    901     if (isset($url_info['scheme']) && $url_info['scheme'] == 'https') { 
    902       $port = isset($url_info['port']) ? $url_info['port'] : 443; 
    903       @$fp=fsockopen('ssl://'.$url_info['host'], $port, $errno, $errstr, 10); 
    904     } else { 
    905       $port = isset($url_info['port']) ? $url_info['port'] : 80; 
    906       @$fp=fsockopen($url_info['host'], $port, $errno, $errstr, 10); 
    907     } 
    908     if ($fp) { 
    909       stream_set_timeout($fp, 10); 
    910       $head = "HEAD ".@$url_info['path']."?".@$url_info['query']; 
    911       $head .= " HTTP/1.0\r\nHost: ".@$url_info['host']."\r\n\r\n"; 
    912       fputs($fp, $head); 
    913       while(!feof($fp)) { 
    914         if($header=trim(fgets($fp, 1024))) { 
    915           $sc_pos = strpos($header, ':'); 
    916           if ($sc_pos === false) { 
    917             $headers['status'] = $header; 
    918           } else { 
    919             $label = substr( $header, 0, $sc_pos ); 
    920             $value = substr( $header, $sc_pos+1 ); 
    921             $headers[strtolower($label)] = trim($value); 
    922           } 
    923         } 
    924       } 
    925       return $headers; 
    926     } else { 
    927       return false; 
    928     } 
    929   } 
    930 
     897function get_headers_assoc($url ) { 
     898  $url_info=parse_url($url); 
     899  if (isset($url_info['scheme']) && $url_info['scheme'] == 'https') { 
     900    $port = isset($url_info['port']) ? $url_info['port'] : 443; 
     901    @$fp=fsockopen('ssl://'.$url_info['host'], $port, $errno, $errstr, 10); 
     902  } else { 
     903    $port = isset($url_info['port']) ? $url_info['port'] : 80; 
     904    @$fp=fsockopen($url_info['host'], $port, $errno, $errstr, 10); 
     905  } 
     906  if ($fp) { 
     907    stream_set_timeout($fp, 10); 
     908    $head = "HEAD ".@$url_info['path']."?".@$url_info['query']; 
     909    $head .= " HTTP/1.0\r\nHost: ".@$url_info['host']."\r\n\r\n"; 
     910    fputs($fp, $head); 
     911    while(!feof($fp)) { 
     912      if($header=trim(fgets($fp, 1024))) { 
     913        $sc_pos = strpos($header, ':'); 
     914        if ($sc_pos === false) { 
     915          $headers['status'] = $header; 
     916        } else { 
     917          $label = substr( $header, 0, $sc_pos ); 
     918          $value = substr( $header, $sc_pos+1 ); 
     919          $headers[strtolower($label)] = trim($value); 
     920        } 
     921      } 
     922    } 
     923    return $headers; 
     924  } else { 
     925    return false; 
     926  } 
     927
     928 
    931929    
    932930 
     
    15401538  } 
    15411539   
    1542   $headers = get_headers($url); 
     1540  $headers = get_headers_assoc($url); 
    15431541   
    15441542  $totalread = 0;