Can PHP do this???
Moderator: General Moderators
Can PHP do this???
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
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.
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
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...
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...
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
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)?
"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
- 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)?
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
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
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
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
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);
}
}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.greenhorn666 wrote:Do you mean I am wrong on theBDKR wrote:Green is correct for the most part
- I might be of some help
or
- that I sound like an a**hole
part? lol
Cheers,
BDKR
well ofcourse he can be of help. he uses posix. his scripts are more stable than anything that can be constructed on winblowsBDKR wrote: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.greenhorn666 wrote:Do you mean I am wrong on theBDKR wrote:Green is correct for the most part
- I might be of some help
or
- that I sound like an a**hole
part? lol
Cheers,
BDKR