Results 1 to 5 of 5

Thread: am new here i need help plz

  1. #1
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default am new here i need help plz

    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

    PHP Code:
    <?

        $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
    Last edited by jscheuer1; 06-11-2012 at 12:57 AM. Reason: Format

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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 ..

    PHP Code:
    $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

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank you

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •