file01.php to HTML

index

USE AT OWN RISK

Generated: Tue Jul 31 15:21:59 2007 from file01.php 2005/11/22 3.1 KB bytes.


<?php
$meor = "\r\n";
// Get a file into an array. In this example we'll go through HTTP to get 
// the HTML source of a URL.
$url = 'http://geoffmclane.com/home2.htm';
//print_r(get_headers($url));
//var_dump(get_headers($url));
//print $meor . "End of list 1" . $meor;
//print_r(get_headers($url, 1));
$lines = file($url);
// $lines = file('http://geoffmclane.com/totalused.php');
//$lines = file('temp1.htm');
// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
 echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />$meor";
}

// Another example, let's get a web page into a string. See also file_get_contents().
// $html = implode('', file('http://www.geoffmclane.com/home2.htm'));
// $html = implode('', file('http://www.geoffmclane.com/totalused.php'));
// print $html;

function generic_search($searchable, $search_term, $search_type)
{
 if ($search_type == "phrase")
 {
 return eregi($search_term, $searchable);
 }
 elseif ($search_type == "all words")
 {
 $search_term = split(" ", $search_term);
 foreach ($search_term as $term)
 {
 if (!eregi($term, $searchable)) { return FALSE; }
 }
 return TRUE;
 }
 elseif ($search_type == "any words")
 {
 $search_term = split(" ", $search_term);
 foreach ($search_term as $term)
 {
 if (eregi($term, $searchable)) { return TRUE; }
 }
 return FALSE;
 }
   else
   {
   return FALSE;
   }
}

function get_headers2($url,$format=0) {
 $url_info=parse_url($url);
 $port = isset($url_info['port']) ? $url_info['port'] : 80;
 $fp=fsockopen($url_info['host'], $port, $errno, $errstr, 30);
 if($fp) {
   if(!$url_info['path']){
   $url_info['path'] = "/";
   }
   if($url_info['path'] && !$url_info['host']){
   $url_info['host'] = $url_info['path'];
   $url_info['path'] = "/";
   }
   if( $url_info['host'][(strlen($url_info['host'])-1)] == "/" ){
   $url_info['host'][(strlen($url_info['host'])-1)] = "";
   }
   if(!$url_array[scheme]){
   $url_array[scheme] = "http"; //we always use http links
   }
   $head = "HEAD ".@$url_info['path'];
   if( $url_info['query'] ){
   $head .= "?".@$url_info['query'];
   }
   print_r($url_info);
   $head .= " HTTP/1.0\r\nHost: ".@$url_info['host']."\r\n\r\n";
   echo $head;
   fputs($fp, $head);
   while(!feof($fp)) {
   if($header=trim(fgets($fp, 1024))) {
   if($format == 1) {
   $h2 = explode(':',$header);
   // the first element is the http header type, such as HTTP/1.1 200 OK,
   // it doesn't have a separate name, so we have to check for it.
   if($h2[0] == $header) {
   $headers['status'] = $header;
   }
   else {
   $headers[strtolower($h2[0])] = trim($h2[1]);
   }
   }
   else {
   $headers[] = $header;
   }
   }
   }
   return $headers;
 }
 else {
   return false;
 }
}

?>
 

index

Valid HTML 4.01 Transitional