Jump to content

Possible to have script check to see if certain files exist (dynamically)


ghurty

Recommended Posts

Is this possible with php:

 

I have a script that every time it runs it generates 5 files with time stamps in the name starting and one point and working its way up it five minute increments. For example 2035.***.txtand 2040.***.txt, etc...

 

This script generates the time stamps beginning at the current time.

 

What I would want it to do, is to prompt the user for a starting time. This is not hard to do, what the hard part is that after prompting the user for the start time, it will check to make sure that that the start time(and end time 25 minutes later) does not overlap with any existing files. It would have to do this by reading part of the file name. It has to be only the first part of the file, because the second part (the ***) is different each time the script is run.

 

Is this doable?

 

Thanks

Link to comment
Share on other sites

I need some clarification. Is this what you wanna do?

 

User access at..

 

1:00 pm

and it will generate... simething like: just consider this as timestamp

(1:00)_file.txt

(1:05)_file.txt

(1:10)_file.txt

(1:15)_file.txt

(1:20)_file.txt

 

 

is there a possibility that the user will access it again on 1:03 and the script will process? or there will be only a process if the current time is already after 1:20.

Link to comment
Share on other sites

Yes it is possible that someone will access the script at 1:03, so instead of it generating it from that point forward, it would realise that there already is files in use all the way up to 1:20, so it would start from 1:25.

 

An idea that I am kicking around(but not sure exactly how to implement it), is that instead of having the php script try to read the file names, I can have a sql database/table that when the script generates the files, it somehow blocks of those area in the table, so all the script has to do is check the table.

 

However I can't have it that it automatically sees the last time, because, I am changing the script to prompt the user what time to start. So for example, at 2:00 a user can schedule it to run at 4:00. And at 2:30 a user can try to schedule it at 3:50, I would want it that it checks and realizes that if it starts at 3:50, it will overlap into the 4:00 zone.

 

Thanks

Link to comment
Share on other sites

At the mean time this is the only help i can give, co'z i am already going home. later i can attend to you or the other guys can give more help.

 

Just a suggestion.. It would be better if you will inform the user that he/she cant have the schedule at 3:50 and at the same time you need to tell that the available schedule would only be at 4:30 and onwards.

 

;D

Link to comment
Share on other sites

What is the need for this, and are you sure you cannot use a database or a single file to log all entries? You can check of the file exists with glob but you will need to iterate through EVERY possible file, which I don't see a point in even attempting to write unless you have a better explaination on what you're trying to accomplish.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.