madmaxy Posted October 16, 2008 Share Posted October 16, 2008 I'm doing my own project for my own website, and I want to run a sports handicapping contest. I have this problem to solve: I would need that participants to be able to input data in the database just in some preset time intervals. These would be between 11 AM EST -18.30 PM EST on weekdays (Monday-Friday) and between 8.30 AM EST - 11.30 EST on weekends (Saturday - Sunday). It's very important that these times must be is EST (New York's time). There is any solution to this? Something applying the if, else and elseif statements? I'm hosted on Linux server. Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/ Share on other sites More sharing options...
fenway Posted October 16, 2008 Share Posted October 16, 2008 Then only make you page available during these dates.. .this isn't a mysql issue. Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-667139 Share on other sites More sharing options...
madmaxy Posted October 16, 2008 Author Share Posted October 16, 2008 Then only make you page available during these dates.. .this isn't a mysql issue. I can't do that, because every contestant has a separate input page (accessible with username and password) and a separate output page from the DB. And anyways how to make a page available only during some times, if I'm not accessing the page to make it go off-line (how something like you said could be automated?) Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-667350 Share on other sites More sharing options...
fenway Posted October 16, 2008 Share Posted October 16, 2008 A separate input page -- you mean like with htaccess? That must be PITA to maintain. I was simply assuming you had some php code checking credentials. Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-667364 Share on other sites More sharing options...
madmaxy Posted October 16, 2008 Author Share Posted October 16, 2008 A separate input page -- you mean like with htaccess? That must be PITA to maintain. I was simply assuming you had some php code checking credentials. It's not PITA to maintan, because only needs to be given once at any contestant (and the number is limited to 50). All these pages are the same, only the database name + contestant's name differs in all of them. After I setup 1 person, there is no maintenance at all. And the same goes for the output pages. Takes 3 minutes to setup 1 person... Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-667386 Share on other sites More sharing options...
madmaxy Posted October 16, 2008 Author Share Posted October 16, 2008 Though I'm thinking now that if one single page can be blocked between some time limits than nobody can input sport picks, because that page contains all the possible choices. But I was looking all over the place, and I can't find any script that would do that: to be automated and able to be set to some times, and also would not block based on IP, but all users! Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-667422 Share on other sites More sharing options...
CroNiX Posted October 16, 2008 Share Posted October 16, 2008 Are these pages static or dynamically created? Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-667427 Share on other sites More sharing options...
madmaxy Posted October 16, 2008 Author Share Posted October 16, 2008 Are these pages static or dynamically created? The page with the possible choices is static (I will change content every day), and every other page in the process is dynamic. Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-667468 Share on other sites More sharing options...
CroNiX Posted October 16, 2008 Share Posted October 16, 2008 couldn't you: 1) get current date/time 2) check if it is within your valid time range 3) if yes, display page, if not don't? Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-667491 Share on other sites More sharing options...
madmaxy Posted October 17, 2008 Author Share Posted October 17, 2008 couldn't you: 1) get current date/time 2) check if it is within your valid time range 3) if yes, display page, if not don't? How can that be done? With PHP or Javascript? I have no idea. And to do that you need to be probably advanced in these languages, and I'm not. But all this solution to block this page is just some kind of half solution, because nothing prevents anyone to look at the page in the time when it's up, but then make his inputs a long time after the page is hidden- which in my case means he can input well after the games begun, or even ended, cheating this way the system (= cheating the contest itself). So really the real solution is just to block all the input pages between the wanted time intervals. If this can't be solved, than it's a big PITA, because everything needs to be totally re-thought and redesigned just because of this detail. Maybe this could be done just with some sort of programming resembling to what only sportsbooks have, and all those are multi-thousand $ softwares. :-\ __________________ Since there were so many views for this thread, but no solution given it looks that's impossible to make msql to connect just in some preset time intervals. Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-668016 Share on other sites More sharing options...
madmaxy Posted October 17, 2008 Author Share Posted October 17, 2008 Or maybe it's some code that can be added directly to the DB, only to prevent data input between some time intervals? I have phpMyAdmin... Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-668025 Share on other sites More sharing options...
fenway Posted October 17, 2008 Share Posted October 17, 2008 I will say again -- a few lines of php to check the current time both on display of the page and on POST will solve your problem. Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-668121 Share on other sites More sharing options...
CroNiX Posted October 17, 2008 Share Posted October 17, 2008 Something like this at the very top of your page with the form. I didn't spend a lot of time on it, but I believe it will do basically what you want... <?php //these are set to the current server time...if your server is in //a different time zone, these need to be adjusted accordingly $weekday_times=array("open_time"=>1100, "close_time"=>1830); //set in 24 hour format $weekend_times=array("open_time"=>830, "close_time"=>1130); $closed_message = "We are currently closed."; $cur_day = date("N"); //current day of week: 1=mon, 7=sun $cur_time = date("G") . date("i"); //current hour/minute in 24 hour format if($cur_day < 6){ //check weekdays if($cur_time < $weekday_times['open_time'] || $cur_time > $weekday_times['close_time']) die($closed_message); } else { //check weekends if($cur_time < $weekend_times['open_time'] || $cur_time > $weekend_times['close_time']) die($closed_message); } Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-668150 Share on other sites More sharing options...
CroNiX Posted October 17, 2008 Share Posted October 17, 2008 It should also be placed at the top of the page where you are processing the form data. Quote Link to comment https://forums.phpfreaks.com/topic/128711-how-to-have-msql-connect-just-in-some-preset-time-intervals/#findComment-668160 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.