dual_alliance Posted September 27, 2006 Share Posted September 27, 2006 Hello,I'm not sure if its called dummy or robot code but it sounds like what l need. What l need is a code that once a day "-1" from the database, this is so when the user is banned for x number of days each day the number reduces. I would be very grateful if you could help me.Thankyou,dual_alliance Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 27, 2006 Share Posted September 27, 2006 what you need to do is set up a PHP script to do what you're after (the query only), and then, you just set up a CRON job to run it for you. if you have shell access to your server, just type "crontab -e" from your command line, then hit "i" to enter insert mode and enter the following job:[code]0 0 * * * php /path/to/file/myFile.php[/code]basically, that tells the script to run at midnight every day, so if your script is updating your database correctly, you're good to go. obviously "/path/to/file" needs to be the path on your server to the correct location.hope this helps Quote Link to comment Share on other sites More sharing options...
dual_alliance Posted September 27, 2006 Author Share Posted September 27, 2006 Thanks that helped allot, l just have one small problem in that l dont have shell access to my server as l am developing it on a cheap shared server is their any other alternative? Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 27, 2006 Share Posted September 27, 2006 do you have CPanel or another way to access CRON jobs through a web interface? if so, just set it up through there. Quote Link to comment Share on other sites More sharing options...
acdx Posted September 27, 2006 Share Posted September 27, 2006 On a side note, there are much easier ways of doing this. You could write the ban ending date into the database in a DATE field and later compare it with the current time. If the ban ending date is in the future, the user is still banned. Quote Link to comment Share on other sites More sharing options...
dual_alliance Posted September 27, 2006 Author Share Posted September 27, 2006 Sorry for replying so late. Well l do have a type of cPanel but it is just a basic one. True that is an easier alternative but l am making a game and l need it to give resources to player every 15 minutes so having a date would not be very efficient but it could work for the ban system but l would rather have it to display how many days they are banned for if l can help it.dual_alliance Quote Link to comment Share on other sites More sharing options...
dual_alliance Posted September 27, 2006 Author Share Posted September 27, 2006 Anyone? Quote Link to comment Share on other sites More sharing options...
acdx Posted September 27, 2006 Share Posted September 27, 2006 [quote]it could work for the ban system but l would rather have it to display how many days they are banned for[/quote]Assuming you have a table called "bans" with columns (INT id,) INT user and DATE ban_ends, this query returns the remaining ban days as "days_left":[code]SELECT DATEDIFF(ban_ends, CURDATE()) days_left FROM bans WHERE user = xx;[/code] Quote Link to comment Share on other sites More sharing options...
dual_alliance Posted September 27, 2006 Author Share Posted September 27, 2006 Thanks acdx it looks like a good idea l'll give it a go. Still it leaves me with the problem of how to get a piece of code running every 10 - 15 minutes without using a CRON job. If anyone has any ideas please let me know.Thanksdual_alliance Quote Link to comment Share on other sites More sharing options...
Fehnris Posted September 27, 2006 Share Posted September 27, 2006 Rather than having a cron job could you not just check the ban date of the user trying to login and if the ban date is in the future you know not to let the user login. Quote Link to comment 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.