auto update content script
Please credit Muse and Icera if you decide to use this script or use this script as a basis for your own.Disclaimer I am not a professional or a versed PHP scripter. This was done in my free time as fun and I do not claim that this is the best script ever written for the purpose nor am I responsible for any alterations you decide to do with it.
- Server Requirements PHP4 (PHP5 is needed for your timezone set)
- User Knowledge Somewhat familiar with basic PHP...but you should be fine too by following the tutorial.
- Note that for Weekly/Biweekly the page will update on Monday only, because it is set to the universal standard time, where the week begins on Mondays. For Monthly, the page will update on the 1st of the month, regardless of day of the week.
- This script is universally written for whether you want to update a page Monthly, Biweekly, Weekly, Daily. However, if you're unfamiliar with PHP switches, just download the appropriate file(s) below to suit your need. A general tutorial below is available.
Download
edits//July 29, 2008 - re-uploaded files in case there were any errors.
October 12, 2008 - fixed a few minor errors and no more .zip files
Tutorial
Note that you must put this on a file that ends in .php. For convenience I will be using the Monthly code as an example:
<?php
date_default_timezone_set("UTC");
$month = date("F");
switch($month){
case "January": require_once "1.php"; break;
case "February": require_once "2.php"; break;
case "March": require_once "3.php"; break;
case "April": require_once "4.php"; break;
case "May": require_once "5.php"; break;
case "June": require_once "6.php"; break;
case "July": require_once "7.php"; break;
case "August": require_once "8.php"; break;
case "September": require_once "9.php"; break;
case "October": require_once "10.php"; break;
case "November": require_once "11.php"; break;
case "December": require_once "12.php"; break;
}
?>
Timezone
date_default_timezone_set("UTC");
This section of the script will ONLY work with PHP 5.1+ if you do NOT have PHP 5.1 on your server delete this entire line. By deleting this section of the script your page will update via your server time.
If you have PHP5.1 you are able to set the time zone to where you specifically live. For example, if you lived in New York you would put America/New_York in place of UTC. UTC indicates Coordinated Universal Time, which is the official measure of time in the earth, independent of time zones. For a full list of of valid time zones you can put in place of UTC visit here.
Changing the auto date/time
$month = date("F");
switch($month){
Where it indicates $month for both parts of this section of the code...you can name it anything you want i.e. week, biweek, month etc. It's only for your reference of what you're working with.
Where it says F is the important part! The F indicates that you want the page to switch every month and that under the case section, which I will explain below, that you type out the entire month name i.e. January, February instead of just Jan, Feb or 01, 02. For more information on all the types of date functions you can use visit here.
Case
case "January":
As noted about what you put in the date(*) i.e. F will depend on what you put in the quotes after case. Note for weekly and biweekly I have defaulted to go by the UTC week number i.e. 15 would be the 15th week of the year. To figure out what Week it is right now visit here. Note that you will follow the Europe and ISO standard section of the form NOT US. For example, 02/15/2008 would be Week 7.
1.php, 2.php etc.
require_once "1.php"; break;
Where it says 1.php is the page you wish to rotate for that month (or week, day, etc.). You're free to name the file anything you want i.e. cow.php, chicken.php etc.
That's it! And for a quickie note!
I know the weekly, biweekly scripts might be overwhelming since there are 52 rows for you to fill out since there are 52 weeks in a year. No worries! You don't need to fill out all 52 lines if you don't want to. Simply delete whatever week numbers that aren't coming up soon or have already passed. A short example of what I mean is below (since I know it's a bit confusing on what I'm trying to explain ^^)
A shorter version of week...only put the week numbers that are currently coming up...
<?php
date_default_timezone_set("UTC");
$week = date("W");
switch($week){
case "16": require_once "cow.php"; break;
case "17": require_once "dog.php"; break;
case "18": require_once "rabbit.php"; break;
case "19": require_once "chicken.php"; break;
case "20": require_once "rat.php"; break;
}
?>
The above script will work just as well as if you decided to prepare all 52 weeks. Cheers!
Works With
This script has been tested and works with the following...- In the Cards Password Gates
- In the Cards Randomizer
- PHP Includes
A word to TCG owners
I specifically made this script for online Trading Card Games as an easy way for owners to update their games. However as a warning note that that this is not a crutch tool. My main purpose for this script was to help busy TCG owners who had to go on vacation or a brief hiatus of sorts to keep the game running. I do not recommend someone who already has little time on their hands to think that they can open up a TCG and use this script as a way to auto-run their site. A TCG takes time to maintain. This script is useful, but an owner should not open up a TCG based off this script.
Ending...
Feel free to alter/edit the script to your desire. You always learn more if you try things out yourself! All I ask if that you use this script as a basis that you give credit where it's due. This script is pretty much limitless with how many date/time choices you wish that I have not included i.e. changing daily 1-31 of the month, changing every 12 hours, changing every year, etc.I decided to create a PHP version of this script (versus the AJAX/javascript, which is also available) because there's always a small population that turns off their javascript or computer is not up to date with javascript. It's much more efficient using PHP relying on the server then on a single person's computer =)
If you need help...
- I can help you install the scripts up to a certain degree. I will only do it once for you, hogging me is selfish =P
- If you need Live Support please feel free to IM me via MSN (my screenname is the same as my email) I find it a lot easier doing live support then having go through 20 emails trying to figure out what's wrong. Please state who you are instead of just saying Hi! (I get confused a lot ^^). Or you can use the Contact form.
- If you decide to go through email please put in the Subject something related to Muse/or this script and put in detail what you're having trouble with i.e. please give me the exact page you decided to put the script on etc. If all you put is "Help! I'm lost!" it doesn't really help you or me ^^; and unfortunately, I will have to ignore those emails.
- I also will not be able to give any support at this time on scripts I did not write, but are compatible with Muse's scripts.
© 2003-2008 Icera. A flavor of Digital-wing.com. This is only a site expressing fandom. Origins of information/images are owned by their respected authors/artists. †