ghurty Posted January 15, 2010 Share Posted January 15, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/188548-possible-to-have-script-check-to-see-if-certain-files-exist-dynamically/ Share on other sites More sharing options...
x_filed2k Posted January 15, 2010 Share Posted January 15, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/188548-possible-to-have-script-check-to-see-if-certain-files-exist-dynamically/#findComment-995419 Share on other sites More sharing options...
ghurty Posted January 15, 2010 Author Share Posted January 15, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/188548-possible-to-have-script-check-to-see-if-certain-files-exist-dynamically/#findComment-995421 Share on other sites More sharing options...
x_filed2k Posted January 15, 2010 Share Posted January 15, 2010 it is depend to the condition of the problem. If the user's gonna schedule at 3:50 will you let it to overlap at 4:00? and also to overwrite the 4:00? Quote Link to comment https://forums.phpfreaks.com/topic/188548-possible-to-have-script-check-to-see-if-certain-files-exist-dynamically/#findComment-995422 Share on other sites More sharing options...
ghurty Posted January 15, 2010 Author Share Posted January 15, 2010 I would not want it to overlap or overwrite. I would want it that it detects that the last one is 4:25, and it would schedule it to start at 4:30. Thank You Quote Link to comment https://forums.phpfreaks.com/topic/188548-possible-to-have-script-check-to-see-if-certain-files-exist-dynamically/#findComment-995426 Share on other sites More sharing options...
x_filed2k Posted January 15, 2010 Share Posted January 15, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/188548-possible-to-have-script-check-to-see-if-certain-files-exist-dynamically/#findComment-995428 Share on other sites More sharing options...
oni-kun Posted January 15, 2010 Share Posted January 15, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/188548-possible-to-have-script-check-to-see-if-certain-files-exist-dynamically/#findComment-995435 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.