Jump to content

Upload a file using cron and php


ukscotth

Recommended Posts

Hi,

 

I run a social network and it has a shoutbox on it. At 9pm each night i would like to remove the bad word filter on the shoutbox and then at say 5am put it back on.  The shoutbox has a config file which contains the set bad words so I thought the best way to achieve what I want would be to use cron jobs and some kind of simple php upload and replace script.

 

Any ideas on how i can code the php file to upload and replace the shoutbox config file ?

 

Or maybe it would be better to have 2 config files and rename them at set times, im not sure.

 

Thanks,

 

Scott.

Link to comment
https://forums.phpfreaks.com/topic/146843-upload-a-file-using-cron-and-php/
Share on other sites

Question?

Does the shoutcast config file run everytime a user enters a message?

 

If so just set the timezone to what ever you like in this file and use php to check the time and if it falls between x & x use this config info, if it falls between y & y use this config info.

 

I agree it would be easier to do a time check at runtime, if there are a lot of users, would a small conditional statement like that create much overhead ? [i dont think it would, but I dont know hahahah..]

 

Anyways heres a useful link to a cronjob resource if your using cpanel to configure your cron job: http://www.siteground.com/tutorials/cpanel/cron_jobs.htm

 

You can get some good results from google, or is it some php specific question you still have?

<?php
$format = 'G';			//G is the 0-24 hour format for date()
$mytime = date($format);//Returns a number from 0-24 0-midnight
if($mytime < 5 || $mytime > 21){
require_once('/path/to/your/config.php');
}
else{
require_once('/path/to/your/configAdult.php');
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.