Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: [PHP] Help ;)

  1. #1
    Join Date
    Apr 2005
    Location
    North Carolina, USA
    Posts
    4,535
    Tokens
    0

    Latest Awards:

    Default [PHP] Help ;)

    Ok,

    What I need is to check and see if files exists.

    I know how to use file_exist.

    But all the filenames have three characters.

    I want to scan a specific directory for files.

    AAA.gif
    AAB.gif
    AAC.gif

    I need it to go all the way to ZZZ.gif

    Any ideas on how to do it?

  2. #2
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Im to lazy to actualy write a script but the two functions you'll wana make use of are:

    readdir()
    preg_match()

    Look em up on php.net and it will tell you all u need to know

  3. #3
    Join Date
    Apr 2005
    Location
    North Carolina, USA
    Posts
    4,535
    Tokens
    0

    Latest Awards:

    Default

    Its not on my server though... unless this can read a remote dir?

  4. #4
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    Its not on my server though... unless this can read a remote dir?
    You cant do a directory scan of someone elses server o.0 you could possibly write a loop of all the possible file addresses and check them but that would be a painfuly slow script to run "/

  5. #5
    Join Date
    Apr 2005
    Location
    North Carolina, USA
    Posts
    4,535
    Tokens
    0

    Latest Awards:

    Default

    I am looking through the badge directory of Habbo

    I wanted to start with aaa and end with zzz.

    But I don't know how to do all the possible filenames

  6. #6
    Join Date
    Jan 2007
    Location
    Canada eh?
    Posts
    766
    Tokens
    75

    Default

    You could try an array and write it all out but that isn't what your looking for right....?

    Um... when it comes to scanning remote dir's you have to also consider server load on your server and theirs as if their servers get too many simultaneous requests from your site they might see it as spamming or hacking of some sort.

    So my best suggestion would be to try something similar to the swear filter on forums... like how they make * represent anything.... here's some pseudocode to ponder:

    PHP Code:
    <?php
    $scandir 
    website_to_scan
    function.scan {
    where * = anything
    check directory 
    for ***
    }
    loop scan(scandir);
    if 
    match is found{
    echo 
    result
    }
    ?>
    I also found something similar to what you want but using ftp.... not sure how it works...?

    http://www.go4expert.com/forums/showthread.php?t=2348

  7. #7
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    That would take a painfully long time and if you run it on shared hosting you'll probially get a error about max exection time.

  8. #8
    Join Date
    Jan 2007
    Location
    Canada eh?
    Posts
    766
    Tokens
    75

    Default

    @Tomm - Way to state the obvious dude But you got any better ideas

  9. #9
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    you will need the numbers 0-9 aswell

  10. #10
    Join Date
    Nov 2005
    Posts
    807
    Tokens
    1,335

    Latest Awards:

    Default

    Well I dont really understand you but to find a file in a dir use something like this....

    PHP Code:
    <?php

    function findfile($var) {

    $path "/path/to/dir";
    $handle opendir($path);
    $check readdir($path.$var);

    foreach(
    $check) {
    if(
    strstr($check$var) {
    echo 
    "File exists";
    } else  {
    return 
    "File dosent exist";
    }
    }
    }
    ?>

Page 1 of 2 12 LastLast

Posting Permissions

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