steviez Posted September 13, 2008 Share Posted September 13, 2008 Hi, I am making a new file hosting script for my site and need to reset my users bandwidth every 15-30 days. I store the last reset time in the database using php time() but im not sure how to make the code work to reset at the time i say. Any help would be great. Thanks Quote Link to comment Share on other sites More sharing options...
dapaintballer331 Posted September 13, 2008 Share Posted September 13, 2008 Make a cron job via cpanel or command line, to execute php /path/to/your/phpfile.php at a certain date/time every x days Quote Link to comment Share on other sites More sharing options...
steviez Posted September 13, 2008 Author Share Posted September 13, 2008 im not using cron due to me not having access to it, i want to do it via php but im not sure how to make the code. Quote Link to comment Share on other sites More sharing options...
pugboy Posted September 13, 2008 Share Posted September 13, 2008 Try: http://onlinecronjobs.com/ Quote Link to comment Share on other sites More sharing options...
steviez Posted September 13, 2008 Author Share Posted September 13, 2008 i dont want to use cron, just php. Quote Link to comment Share on other sites More sharing options...
pugboy Posted September 13, 2008 Share Posted September 13, 2008 The problem is, if you don't run it with a program, you have to visit it manually or include a reset function on some pages. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 13, 2008 Share Posted September 13, 2008 cron doesn't actually do anything for this, steviez, it just allows you to execute the PHP code at certain intervals. It's still PHP. Quote Link to comment Share on other sites More sharing options...
steviez Posted September 13, 2008 Author Share Posted September 13, 2008 I am wanting to include the code in the overall header of the script Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 13, 2008 Share Posted September 13, 2008 So you are basically want to delete files older than 30 days? Quote Link to comment Share on other sites More sharing options...
steviez Posted September 13, 2008 Author Share Posted September 13, 2008 no, i want to reset users bandwidth after say 30 days Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 13, 2008 Share Posted September 13, 2008 Okay, so wait. You just want to give them more bandwidth but leave their files on the server? Quote Link to comment Share on other sites More sharing options...
steviez Posted September 13, 2008 Author Share Posted September 13, 2008 Hi, I am making a new file hosting script for my site and need to reset my users bandwidth every 15-30 days. I store the last reset time in the database using php time() but im not sure how to make the code work to reset at the time i say. Any help would be great. Thanks As i say here i want to reset the bandwidth of each user after 30 days and everything else stays as is. Quote Link to comment Share on other sites More sharing options...
networkthis Posted September 13, 2008 Share Posted September 13, 2008 are you only allowing them so much "bandwidth" every 30 days..... example 50 Mb per 30 days and you simply want to reset that every 30 days???? Quote Link to comment Share on other sites More sharing options...
steviez Posted September 13, 2008 Author Share Posted September 13, 2008 Yes thats 100% correct. sorry for all the confusion Quote Link to comment Share on other sites More sharing options...
steviez Posted September 13, 2008 Author Share Posted September 13, 2008 anyone know how to do this? Quote Link to comment Share on other sites More sharing options...
steviez Posted September 13, 2008 Author Share Posted September 13, 2008 Would this do it? <?php $member = sql_row("SELECT * FROM members"); $resetTime = strtotime('-30 days'); $nowtime = time(); $lastReset = $member['bandwidth_last_reset']; if (($nowtime - $lastReset) > $resetTime) { echo $member['username']; } ?> Quote Link to comment Share on other sites More sharing options...
seany123 Posted September 13, 2008 Share Posted September 13, 2008 how do you stop people using bandwidth? using database? Quote Link to comment Share on other sites More sharing options...
steviez Posted September 13, 2008 Author Share Posted September 13, 2008 their bandwidth is stored in the database and when they are over the set limit they cant use anymore until its reset. 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.