User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

en:php [2015/06/05 09:01] (current)
Line 1: Line 1:
 +===== You have to read (understand) this before adapting the scripts =====
 +==== Where are all your settings stored ​ ====
 +  * All settings, including your changes, are stored in one table  with the name **$SITE[]** ​
 +  * Every setting has its own name in the table: ​  ​$SITE[**'​name'​**]
 +  * en it has a value $SITE['​name'​] = **'​value'​**
 +  * In PHP such a "​instruction"​ line is closed with a  **;** 
 +So it should look like this:
 +<​code>​$SITE['​region'​] = '​europe';</​code>​
 +  * The **name** of the setting in this example is  **'​region'​**
 +  * The **=** character tells the script to fill the  setting with the value after the **=**
 +  * The **value** of the setting with the name **'​region'​** ​ thus become **'​europe'​**
 +  * In PHP this value stays the same until some other instruction-line changes the value.
 +==== A little more complex example ====
 +<​code>​$SITE['​region'​] = '​america'; ​   // #####
 +#​$SITE['​region'​] = '​canada';​ // #####
 +$SITE['​region'​] = '​europe';​ //​ #####
 +#​$SITE['​region'​] = '​other'; ​     // #####</​code>​
 +==== What does that # do?  ====
 +The # character, is often found on the first position of a line. It is a comment character.\\ ​
 +All remaining characters on the line are discarded / not parsed / used as comment.
 +  * The first line in this example sets the value of the setting region to '​america'​
 +  * All text on the second line is discarded as it starts with a **#**
 +  * The third line sets the value of the setting region to '​europe'​
 +  * En that value is the final value as the fourth line has a **#** 
 +==== Why do we use the # character ​ ====
 +Often there are long lists of possible values for one setting. The '​region'​ setting has only 4, 
 +but the weatherprogram setting has already 11.
 +When we should type those values ourselves, ​ typing errors would be generating lots of errors.  ​
 +Those "​stupid"​ computers do not understand that when we type '​Europe' ​ or '​europa'​ that value should be interpreted as '​europe'​. ​
 +Thats why every "​supported"​ value is written on its own line, and you only have to 
 +make sure that your value has NO # and all other values are commented out.
 +<WRAP important>​Only change a text when you are asked to do so. \\ 
 +Most of the times it is perfectly clear that you only have to remove / set a comment mark
 +**Never ever** change something you do not like or which looks like a typo without instructed to 
 +change the **value** .  So do not change '​europe'​ into '​Europe'​ in the example. ​
 +You will be faced  with numerous error messages as a result of this improvement.
 +==== yes / no values ====
 +Most values of a setting are in the form of **'​value'​**,​ so with single quotes. (apostrophe'​s in some languages).  ​
 +The yes/no values are specified with the words **true** or  **false**  ​
 +but without single quotes, without any type of quotes at all.
 +<​code>​$SITE['​wsDebug'​] ​               = true;         // ##### 
 +#​$SITE['​wsDebug'​] ​              = false; ​       // remove comment mark at position 1 when you are fully satisfied with your site.
 +The first line in this example sets the value of the setting **wsDebug** ​ to **true**
 +The second line in the example does nothing as it has a comment character on the first position. ​
 +So all text after the # is discarded for now.\\ ​
 +If we are ready with the implementation of the template we will remove that comment mark so that debugging mode is switched of.
 +We could do that with one line only and **type** false where now it reads true, 
 +but you understand now that typing can result in typing errors and that we want to avoid that.
 +==== Typing your own values ====
 +$SITE['​organ'​] = 'your station';​ //​ #####  short name used a.o. in heading, forecast pages 
 +$SITE['​yourArea'​] = 'your area';​ //​ #####  the area your city is in
 +$SITE['​contactName'​] = 'your name';​ //​ #####  Webmaster naam or simply webmaster
 +$SITE['​contactEmail'​] = '​';​ //​ #####  Webmaster E-mail from
 +$SITE['​contactEmailTo'​] = '​'; ​  // #####  contact E-mail goes to  THIS email adress, so it MUST be a real one
 +Another part of the settings.\\ ​
 +With the excveption of the **true** and **false** setting we encourage you to type 
 +all settings between single quotes. If you type and do not encloses the values **between** those single quotes, ​
 +you will be astonished by the number and tha ambiguity of the resulting messages.
 +<WRAP important>​Another reason to test often. ​
 +A typo of one minute ago when you only changed a few lines is "​easily"​ found. ​
 +If you first test after half an hour adapting setting, you will face an enormousd task.</​WRAP>​
 +Please remeber:
 +  - If a value itself contains a single quote, you have to type that quote as **&#​39;​** Example the dutch city name **'t Zandt** should be typed as <​code>​$SITE['​organ'​] = '​Weatherstation &#39;t Zandt';</​code>​
 +  - If you do not want to use a setting you should leave the name of the setting as is, and set the value to an empty string. Also do not comment the line with the setting. So this is NOT a good solution:<​code>​
 +#​$SITE['​contactName'​] = 'your name';​ </​code>​This is<​code>​
 +$SITE['​contactName'​] = '';​ </​code>​
 +====  if () {} ====
 +if ($SITE['​region'​] == '​america'​) {
 +#       here we define specific settings for  the          U S A   
 +#       ALL existing values are example and must be checked for your place
 + $SITE['​latitude'​] = '​41.30068'; ​     // #####    North=positive,​ South=negative decimal degrees
 + $SITE['​longitude'​] = '​-72.793671';​ // #####    East=positive,​ West=negative decimal degrees
 +... a lot of settings
 + $SITE['​select_lat_lon'​] = '​_my_texts/​lat_lon_us.txt';​
 +} elseif ($SITE['​region'​] == '​canada'​) {
 +#       here we define specific settings for             C A N A D A
 +#       ALL existing values are example and must be checked for your place
 + $SITE['​latitude'​] = '​51.112243'; ​     // #####    North=positive,​ South=negative decimal degrees
 +... a lot of settings
 +        $SITE['​select_ec'​] ​     = '​_my_texts/​ec_area.txt'; ​                                       //​ '​_my_texts/​ec_area.txt'​
 +} elseif ($SITE['​region'​] == '​europe'​) {
 +#       here we define specific settings for             E U R O P E
 + $SITE['​latitude'​] = '​50.85000'; ​     // #####    North=positive,​ South=negative decimal degrees
 +... and so on
 +There are a lot of settings dependent on the region you are in.  ​
 +Thsoe settings are grouped together and preceded by a so called **if** statement and some comments ​
 +to make clear where the lines for your region start and end.  ​
 +Do not modify any lines outside the part for your region. ​
 +Do not mark them as comment. Leave them as is.
 +You only have to change the lines when there is a group of comment characters #####  at the line.
 +If your station is in the region '​canada'​ you start changing at the line with
 +<​code> ​  ​$SITE['​latitude'​] ​     = '​51.112243';​ </​code>​ and you stop at
 +<​code> ​  ​$SITE['​select_ec'​] ​    = '​_my_texts/​ec_area.txt';​ </​code>​
 +and you skip all other regional lines, carefully checking the comment lines.
en/php.txt · Last modified: 2015/06/05 09:01 (external edit)