Can PHP do this???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
noahl
Forum Newbie
Posts: 2
Joined: Tue Aug 19, 2003 9:19 am
Contact:

Can PHP do this???

Post by noahl »

I have a question. Can .php be used in this situation:

I have several directories that have tons of reports being placed there every night. I want a way to dynamically generate a report listing. I know I can just list the reports by allowing the directory to list contents. What I am wanting to do is allow the users to search the directories for specific reports, list most recent reports, and do it all in a way that is easier than scrolling thru hundreds of reports looking for dates and report names.

Can this be done? If so do you have any suggestions how...

Any comments would be greatly appreciated.

Thank you,

noahl
Last edited by noahl on Tue Aug 19, 2003 10:34 am, edited 1 time in total.
User avatar
greenhorn666
Forum Commoner
Posts: 87
Joined: Thu Aug 14, 2003 7:14 am
Location: Brussels, Belgium

Post by greenhorn666 »

I would say yes...

Simply add an entry to the crontab that indexes the directories based on what you want (let say name and ts; cause content would require to code a parser, which again is possible).
Then code a page that let the user query that index based on fields you decide... Here "name" and "last modifed" for example.
Then display the result to the user...

Again that indexing isn't mandatory, but if you have really many files and really many queries on these files, indexing would be nice for your users.

The question is Can you do this?

php can do about everything. And should you miss a thing, you could easely code your extension in C doing whatever you think is missing...
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Great post green....
noahl
Forum Newbie
Posts: 2
Joined: Tue Aug 19, 2003 9:19 am
Contact:

Post by noahl »

hmmm,

I may need to clarify a few things.

1. I'm a n00b at .php <-- REALLY big n00b
2. I am using .php with IIS 4.0
3. The files are in an NT 4.0 directory and are generated by a reporting system and sent to the server.

That being said :D Is this still possible?

noahl
User avatar
greenhorn666
Forum Commoner
Posts: 87
Joined: Thu Aug 14, 2003 7:14 am
Location: Brussels, Belgium

Post by greenhorn666 »

I'll sound like a real a**hole, but the answer to the question:
"Can php do this" is always yes I'm afraid...
But you have to get it done, php won't do it for you (and me neither, sorry)...
But I might be of some help... again, I hate m$, and am bad at its FS. But functions should be about the same.
So I believe I could help you a bit at least.

That being said ;) you don't give me much info...
- On what the user should query the server?
- How many files per dir, and how many dir are to be scanned for results?
- How many queries is the server to handle per minutes?
- And what is the HD system on which these files are on (RAID, ATA33, SCSI)?
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Green is correct for the most part. PHP isn't going to do it for you.

Howevever, the manaual has tons of examples. Check the file and directory functions. Those should give you some ideas.

I'll give you a possible place to start from.

1) open the directory (The dir class is a good place to start. Look at it in the manual).
2) While reading through each file in the directory, perform some indexing of some sort on the file.
3) close the directory

That's all there really is to it. But, as with everything, there is a learning curve that you as an individual has to fight through.

Cheers,
BDKR
User avatar
greenhorn666
Forum Commoner
Posts: 87
Joined: Thu Aug 14, 2003 7:14 am
Location: Brussels, Belgium

Post by greenhorn666 »

BDKR wrote:Green is correct for the most part
Do you mean I am wrong on the
- I might be of some help
or
- that I sound like an a**hole

part? lol ;)
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

you eed to open the directore, go through everything you can find, figure out if you want it, get the info that you want, ptu that in an array, do the sort you want, and then return it. i happen to have a script that goes through directories, after checking to see how to get the last access time, here is the section you want with a slight modification.

before using it you should make sure you understand what's happening by going to htttp://php.net and looking upt he following: opendir readdir is_file filemtime

when you read up on those this should make perfect sense

Code: Select all

$foundFiles=array();
$dir=some lower directory
$d=opendir($dir) or die($php_errormsg);
while(false !==($f=readdir($d))){
  $here=getcwd(); $posfile=$here . '/' . $dir . $f;
  if(is_file($posfile)){
    $foundFiles[]=array(filemtime($f), $f);
  }
}
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

greenhorn666 wrote:
BDKR wrote:Green is correct for the most part
Do you mean I am wrong on the
- I might be of some help
or
- that I sound like an a**hole

part? lol ;)
Well, err...., yes, you can be of some help, and since I didn't hear any gas or farting sounds, you don't sound like an a**hole.

:twisted:

Cheers,
BDKR
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

BDKR wrote:
greenhorn666 wrote:
BDKR wrote:Green is correct for the most part
Do you mean I am wrong on the
- I might be of some help
or
- that I sound like an a**hole

part? lol ;)
Well, err...., yes, you can be of some help, and since I didn't hear any gas or farting sounds, you don't sound like an a**hole.

:twisted:

Cheers,
BDKR
well ofcourse he can be of help. he uses posix. his scripts are more stable than anything that can be constructed on winblows
Post Reply