View Single Post
Old 06-07-2012, 06:55 AM   PM User | #10
dan-dan
Regular Coder

 
dan-dan's Avatar
 
Join Date: Aug 2009
Location: England
Posts: 483
Thanks: 22
Thanked 79 Times in 78 Posts
dan-dan is on a distinguished road
The page will accept 'any' value in the url variable at the moment. You need to validate your data first. For instance, you might use file_exists() to check whether the page exists in your directory, and if not refer to the default page.
The title works for me. Are you sure that your pages actually contain titles?
PHP Code:
<?php
$url 
= (isset ($_GET['url']) && file_exists($_GET['url'])) ? strtolower($_GET['url']) : "http://www.codingforums.com/showthread.php?t=263790";

$file file($url);
$file implode(""$file);

if (
preg_match("/<title>(.+)<\/title>/i"$file$m))
   
$title $m[1];
else
   
$title "someDefaultTitle";
?>
dan-dan is offline   Reply With Quote
Users who have thanked dan-dan for this post:
Mooseman (06-07-2012)