Re: cvs: php4 /ext/standard file.c file.h

From: Date: Mon, 12 Feb 2001 03:51:59 +0000
Subject: Re: cvs: php4 /ext/standard file.c file.h
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-3981@lists.php.net to get a copy of this message
[Sun, 11 Feb 2001] Sterling Hughes said: > > > elixer Sat Feb 10 18:38:40 2001 EDT > > > > Modified files: > > /php4/ext/standard file.c file.h > > Log: > > Fix for bug #4556 > > # This is pretty much a total rewrite of get_meta_tags using a simple > > # handwritten tokenizer. It might be overkill, but it works. > > I'd say this is news worthy... > > Can you add an entry into the NEWS file. I agree. However, on first glance, it only seems to grab the meta-tags that have the NAME/CONTENT attributes, not the HTTP-EQUIV/CONTENT attributes. This was a major drawback of the original code (IMHO). I wrote my own get_metatags function in PHP. Find the code below. If someone likes this and wants to convert it into C ... <?php function get_metatags($url) { if (substr($url,0,7)=='http://') { $url = substr($url,7); } if( !($fp = fopen('http://'.$url, 'r')) ) { return false; } else { $file = ''; while (!feof($fp) && !stristr($file,'</head>') ) { $file.= fgets($fp, 80); } fclose($fp); $file = str_replace("\r", '', $file); $file = str_replace("\n", '', $file); $result = array(); preg_match_all('/<meta(.+?)>/i', $file, $temp); if (is_array($temp[1])) { foreach($temp[1] as $key=>$match) { $t = $n = $c = ''; if (preg_match('/name=("|\')(.*?)\\1/i', $match, $b)) { $t = 'NAME'; $n = $b[2]; } else if (preg_match('/http-equiv=("|\')(.*?)\\1/i', $match, $b)) { $t = 'HTTP-EQUIV'; $n = $b[2]; } if (preg_match('/content=("|\')(.*?)\\1/i', $match, $b)) { $c = $b[2]; } if ($t && $n && $c) { $result[] = array( 'type' => $t, 'meta_name' => $n, 'meta_content' => $c ); } } } return $result; } } ?> - Colin

« previous php.cvs (#3981) next »