View Full Version : am new here i need help plz
wtl-php
06-10-2012, 06:31 PM
hi..
I'm glad that i join you guys ..
am not so good in PHP but i know much better even i have coded two script befor
i used this script on my own appserv
and got the all wordpress contents
<?
$path = "wordpress";
$dir_handle = @opendir($path) or die("Unable to open $path");
while ($file = readdir($dir_handle)) {
if($file == "." || $file == ".." || $file == "index.php" )
continue;
echo "<a href=\"$file\">$file</a><br />";
}
closedir($dir_handle);
?>
now my question for i.e www.site.com
how to get this i.e contents
thank you
djr33
06-10-2012, 06:38 PM
Your current script is designed to get a listing of the contents of a local directory? And now you want to do that with a remote website? You can't. You can't ask a remote server for all of the contents. You could attempt to build a sitemap for that website, but it wouldn't be guaranteed to be complete (it would be accurate but it might be missing many unknown files) and it wouldn't be easy.
Why do you want to do this?
Note that using a remote file is easy in PHP. You need to allow remote files in the PHP configuration (this may be disabled by default), but otherwise just use a URL instead of a local path. The problem is that it won't work with opendir() for example. For other things like include() or file_get_contents(), etc., it would work.
wtl-php
06-10-2012, 07:20 PM
i want to do it just for learning purpose
what is wrong on this code now :(
for example i want to get all dir and files ..
$url = "http://www.site.com";
$contz = file_get_contents($url);
function get_url_contents($url){
$wlt = curl_init();
curl_setopt ($wlt,CURLOPT_URL,$url);
curl_setopt ($wlt,CURLOPT_RETURNTRANSFER,1);
curl_setopt ($wlt,CURLOPT_CONNECTTIMEOUT,$timeout);
$ret = curl_exec($wlt);
curl_close($wlt);
return $ret;
}
echo $url;
and thanks for replaying :)
djr33
06-10-2012, 07:36 PM
As I said:
You can't ask a remote server for all of the contents.
You can do other things, but you can't get the contents of a directory. The remote server doesn't allow it.
You could do this using FTP if you have access to both servers, though.
wtl-php
06-10-2012, 07:39 PM
thank you :)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.