Tuesday, December 9, 2008

Php - How to find a file existing in remote FTP server

How to find a file existing in remote FTP server
/**********************************************************************

Name :- checklink.php

Description :- This code check that the File is On the FTP or Not..

Example :- Change the $url variable as per your requrement u can
Post that variable from any other Page From Pages

***********************************************************************/


function get_h1($file){

$h1tags = preg_match_all("/()(\w.*)(<\/h1>)/isxmU",$file,$patterns);
$res = array();
array_push($res,$patterns[2]);
array_push($res,count($patterns[2]));
return
$res;
}

$url ="http://www.hardikbhavsar.com/index.php";
$ch = curl_init() or die(curl_error());
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$data1=curl_exec($ch) or die(curl_error());

$result = get_h1($data1);

if(
$result[0][0]=='Not Found')
{
echo
"OOps..Link is Not found on this Url...!";
}
else
{
echo
"Link is Found on this Url";
}
curl_error($ch);
curl_close($ch);
?>

No comments: