I'm just starting out with PHP so I thought I'd do something simple.
I modified an existing bit of code but it doesn't seem to work:
<?php
$url = $_GET['DLURL'];
// Fetch page
$string = FetchPage($url);
// Regex that extracts the urls from links
$links_regex = '/<a[^/>]*'.
'href=["|\']([^javascript:].*)["|\']/Ui';
preg_match_all($links_regex, $string, $out, PREG_PATTERN_ORDER);
echo "<pre>"; print_r($out); echo "</pre>";
function FetchPage($path)
{
$file = fopen($path, "r");
if (!$file)
{
exit("The was a connection error!");
}
$data = '';
while (!feof($file))
{
// Extract the data from the file / url
$data .= fgets($file, 1024);
}
return $data;
}
?>
I'd expect it to print all the links in a page but it doesn't (gives the !file case). It's hosted on t35.com. I'm passing an additional '?DLURL="google.com"' in the URL.
If this is solved I'll get to what I'm actually trying to do :) Thanks.