PDA

View Full Version : [PHP] Help ;)



Dentafrice1
23-04-2007, 09:20 PM
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? :P

Mentor
24-04-2007, 12:29 AM
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

Dentafrice1
24-04-2007, 12:30 AM
Its not on my server though... unless this can read a remote dir?

Mentor
24-04-2007, 12:34 AM
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 "/

Dentafrice1
24-04-2007, 12:50 AM
I am looking through the badge directory of Habbo :P

I wanted to start with aaa and end with zzz.

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

QuickScriptz
24-04-2007, 01:11 AM
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
$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

Tomm
24-04-2007, 07:02 AM
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.

QuickScriptz
24-04-2007, 11:19 AM
@Tomm - Way to state the obvious dude :P But you got any better ideas ;)

Blinger1
24-04-2007, 11:24 AM
you will need the numbers 0-9 aswell ;)

Splinter
25-04-2007, 05:06 PM
Well I dont really understand you but to find a file in a dir use something like this....



<?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";
}
}
}
?>

Tomm
25-04-2007, 05:25 PM
There are 42,840 possible combinations (Using 0-9, a-z).

It would be very complicated, and I think its beyond the scope of PHP.

Splinter
25-04-2007, 05:35 PM
Yup unless you do it on your own server and set the max execution time to like an hour or more then it might work........

Luckyrare
25-04-2007, 05:43 PM
Well, you could break it down. Do each starting letter every hour.

Tomm
25-04-2007, 05:49 PM
Ok, I am generating the combinations in excel as we speak.. may take some time. Then ill do a bit of thinking and I am sure ill be able to find a way to export into into a format PHP will read :)

Tomm
25-04-2007, 08:23 PM
Sorry mods - I can't edit my post.

I have made a VB.net 2005 application that does what you want (Looks in the badge directory).

You just need the .net framework version two for it to work.

Send me a PM if you want it ^^

Be warned: It takes a LONG time (46656 combinations to search) but takes under a second for each one.

Ini
25-04-2007, 08:49 PM
I have the badge dir on my comp..

I dont no if it is every single badge but there are alot..

Want to hide these adverts? Register an account for free!