CVS: phpweather/config index.php,1.3,1.4
Brought to you by:
iridium
|
From: Martin G. <gim...@us...> - 2002-04-12 22:04:45
|
Update of /cvsroot/phpweather/phpweather/config
In directory usw-pr-cvs1:/tmp/cvs-serv16352
Modified Files:
index.php
Log Message:
Two new options were added: cache_timeout and offset. I've also
reindented the code.
Index: index.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/config/index.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- index.php 9 Apr 2002 23:21:37 -0000 1.3
+++ index.php 12 Apr 2002 22:04:43 -0000 1.4
@@ -13,6 +13,7 @@
require_once('pw_option_select.php');
require_once('pw_option_multi_select.php');
require_once('pw_option_boolean.php');
+require_once('pw_option_integer.php');
/* We want to group the options: */
require_once('pw_optiongroup.php');
@@ -50,9 +51,13 @@
$dba_dep = new pw_dependency('db_type', 'dba');
$proxy_dep = new pw_dependency('use_proxy', 'true');
- $port_validator =
- new pw_validator_range("Sorry, '%s' is not a valid port-number because " .
- "is't outside the range 1-65536", 1, 65536, true);
+ $port_validator = new pw_validator_range("Sorry, '%s' is not a valid port-number " .
+ "because is't outside the range 1-65536",
+ 1, 65536);
+ $port_validator_empty = new pw_validator_range("Sorry, '%s' is not a valid port-number " .
+ "because is't outside the range 1-65536",
+ 1, 65536, true);
+
/* This just catches the most obvious errors. */
$table_validator = new pw_validator_ereg("Sorry, '%s' is not a valid name.",
'^[^./]+$');
@@ -67,187 +72,206 @@
$options['verbosity'] =
new pw_option_select('verbosity',
- "The setting of this variable controls the amount of " .
- "errors, warnings, and debug-information PHP Weather " .
- "will print. It is suggested that you always include " .
- "errors in the output and perhaps also warnings.",
- array(),
- array('1' => 'Errors only',
- '2' => 'Warnings only',
- '4' => 'Debug information only',
- '3' => 'Errors + warnings',
- '5' => 'Errors + debug information',
- '6' => 'Warnings + debug information',
- '7' => 'Everything')
- );
-
+ "The setting of this variable controls the amount of " .
+ "errors, warnings, and debug-information PHP Weather " .
+ "will print. It is suggested that you always include " .
+ "errors in the output and perhaps also warnings.",
+ array(),
+ array('1' => 'Errors only',
+ '2' => 'Warnings only',
+ '4' => 'Debug information only',
+ '3' => 'Errors + warnings',
+ '5' => 'Errors + debug information',
+ '6' => 'Warnings + debug information',
+ '7' => 'Everything'));
+
$options['icao'] =
new pw_option_text('icao',
- 'This will be the default station used by PHP Weather. ' .
- 'You should enter a valid four-letter ICAO.',
- array(), $icao_validator, 'EKYT'
- );
-
+ 'This will be the default station used by PHP Weather. ' .
+ 'You should enter a valid four-letter ICAO.',
+ array(), $icao_validator, 'EKYT');
+
$options['pref_units'] =
new pw_option_select('pref_units',
- 'You may choose to display the data in several ' .
- 'formats. Please choose one that fits your need.',
- array(),
- array('both_metric' => 'Metric first, then imperial',
- 'both_imperial' => 'Imperial first, then metric',
- 'only_metric' => 'Only metric',
- 'only_imperial' => 'Only imperial'));
+ 'You may choose to display the data in several ' .
+ 'formats. Please choose one that fits your need.',
+ array(),
+ array('both_metric' => 'Metric first, then imperial',
+ 'both_imperial' => 'Imperial first, then metric',
+ 'only_metric' => 'Only metric',
+ 'only_imperial' => 'Only imperial'));
$options['language'] =
new pw_option_select('language',
- 'PHP Weather can produce output in several languages ' .
- '- please select your default from the list.',
- array(),
- array('en' => 'English',
- 'da' => 'Danish',
- 'hu' => 'Hungarian',
- 'no' => 'Norwegian'));
-
+ 'PHP Weather can produce output in several languages ' .
+ '- please select your default from the list.',
+ array(),
+ array('en' => 'English',
+ 'da' => 'Danish',
+ 'hu' => 'Hungarian',
+ 'no' => 'Norwegian'));
+
+ $options['offset'] =
+ new pw_option_integer('offset',
+ "Due to a bug in PHP, on some systems the time reported may " .
+ "be incorrect. If you experience this, you specify the " .
+ "offset here. For example, if your times generated are 1 " .
+ "hour too early (so METARs appear an hour older than they " .
+ "are), set this option to be +1.",
+ array(), false, 0);
+
$options['use_proxy'] =
new pw_option_boolean('use_proxy',
- "Set this option to 'Yes' to enable support for a " .
- "proxy server.",
- array(),
- array('false' => 'No',
- 'true' => 'Yes'));
+ "Set this option to 'Yes' to enable support for a " .
+ "proxy server.",
+ array(),
+ array('false' => 'No',
+ 'true' => 'Yes'));
$options['proxy_host'] =
new pw_option_text('proxy_host',
- "This is the hostname of the proxy server.",
- array($proxy_dep), $host_validator);
-
+ "This is the hostname of the proxy server.",
+ array($proxy_dep), $host_validator);
+
$options['proxy_port'] =
- new pw_option_text('proxy_port',
- "This is the port number of the proxy server. The " .
- "default is what is used by the Squid proxy server. " .
- "Another common port number is '8080'",
- array($proxy_dep), $port_validator, '3128');
-
+ new pw_option_integer('proxy_port',
+ "This is the port number of the proxy server. The " .
+ "default is what is used by the Squid proxy server. " .
+ "Another common port number is '8080'",
+ array($proxy_dep), $port_validator, 3128);
+
$options['db_type'] =
new pw_option_select('db_type',
- 'PHP Weather can use several kinds of databases.',
- array(),
- array('null' => 'No database at all',
- 'mysql' => 'A MySQL database',
- 'pgsql' => 'A PostgreSQL database',
- 'dba' => 'A DBA database'));
+ 'PHP Weather can use several kinds of databases.',
+ array(),
+ array('null' => 'No database at all',
+ 'mysql' => 'A MySQL database',
+ 'pgsql' => 'A PostgreSQL database',
+ 'dba' => 'A DBA database'));
$options['db_handler'] =
new pw_option_select('db_handler',
- "If you've chosen to use a Berkeley DB style database " .
- "through the PHP database abstraction layer (DBA), then " .
- "please select the handler you would like to use.",
- array($dba_dep),
- array('dbm' => 'dbm - The oldest (original) type of ' .
- 'Berkeley DB style databases',
- 'ndbm' => 'ndbm - a newer and more flexible type.',
- 'gdbm' => 'gdbm - The GNU database manager',
- 'db2' => 'db2 - Sleepycat Softwares DB2',
- 'db3' => 'db3 - Sleepycat Softwares DB3'));
-
+ "If you've chosen to use a Berkeley DB style database " .
+ "through the PHP database abstraction layer (DBA), then " .
+ "please select the handler you would like to use.",
+ array($dba_dep),
+ array('dbm' => 'dbm - The oldest (original) type of ' .
+ 'Berkeley DB style databases',
+ 'ndbm' => 'ndbm - a newer and more flexible type.',
+ 'gdbm' => 'gdbm - The GNU database manager',
+ 'db2' => 'db2 - Sleepycat Softwares DB2',
+ 'db3' => 'db3 - Sleepycat Softwares DB3'));
+
$options['always_use_db'] =
new pw_option_boolean('always_use_db',
- "If you set this option to 'Yes', then PHP Weather " .
- "will always use the data it finds in the database, " .
- "even if it's too old. But if the data isn't there, " .
- "it will still fetch new data from the Internet.",
- array($db_dep),
- array('false' => 'No', 'true' => 'Yes'));
+ "If you set this option to 'Yes', then PHP Weather " .
+ "will always use the data it finds in the database, " .
+ "even if it's too old. But if the data isn't there, " .
+ "it will still fetch new data from the Internet.",
+ array($db_dep),
+ array('false' => 'No', 'true' => 'Yes'));
+
+ $options['cache_timeout'] =
+ new pw_option_integer('cache_timeout',
+ "This specifies when a METAR in the cache is " .
+ "considered to be old. If a METAR is older than this " .
+ "number of seconds, then an attempt is made to fetch " .
+ "a new METAR from the web. The default value is 3600 " .
+ "seconds (1 hour), but some stations make two " .
+ "reports each hour, so you might want to lower this " .
+ "number to perhaps 2400 or even 1800.",
+ array(new pw_dependency('always_use_db', 'false'), $db_dep),
+ false, '3600');
$options['db_pconnect'] =
new pw_option_boolean('db_pconnect',
- "If you want to make a persistent connection to the " .
- "database, then set this option to 'Yes'.",
- array($sql_dep),
- array('false' => 'No', 'true' => 'Yes'));
-
+ "If you want to make a persistent connection to the " .
+ "database, then set this option to 'Yes'.",
+ array($sql_dep),
+ array('false' => 'No', 'true' => 'Yes'));
+
$options['db_port'] =
- new pw_option_text('db_port',
- 'If you have to use a non-standard port when ' .
- 'connecting to the database, then please specify it ' .
- 'here. If not, then just leave this field blank.',
- array($sql_dep), $port_validator);
+ new pw_option_integer('db_port',
+ 'If you have to use a non-standard port when ' .
+ 'connecting to the database, then please specify it ' .
+ 'here. If not, then just leave this field blank.',
+ array($sql_dep), $port_validator_empty);
$options['db_hostname'] =
new pw_option_text('db_hostname',
- 'This is the hostname that PHP Weather will use, ' .
- 'if you choose to use a database-backend, that ' .
- 'supports network connections.',
- array($sql_dep), $host_validator);
+ 'This is the hostname that PHP Weather will use, ' .
+ 'if you choose to use a database-backend, that ' .
+ 'supports network connections.',
+ array($sql_dep), $host_validator);
$options['db_database'] =
new pw_option_text('db_database',
- 'This is the name of the database that PHP Weather ' .
- 'should use.',
- array($sql_dep), $table_validator);
+ 'This is the name of the database that PHP Weather ' .
+ 'should use.',
+ array($sql_dep), $table_validator);
$options['db_username'] =
new pw_option_text('db_username',
- 'This is the username that PHP Weather will use ' .
- 'for accessing the database.',
- array($sql_dep));
+ 'This is the username that PHP Weather will use ' .
+ 'for accessing the database.',
+ array($sql_dep));
$options['db_password'] =
new pw_option_text('db_password',
- 'This is the password that PHP Weather will use when ' .
- 'trying to make a connection to the database. Please ' .
- "remember to protect the file after you've stored the " .
- "password in it.",
- array($sql_dep));
-
+ 'This is the password that PHP Weather will use when ' .
+ 'trying to make a connection to the database. Please ' .
+ "remember to protect the file after you've stored the " .
+ "password in it.",
+ array($sql_dep));
+
$options['db_metars'] =
new pw_option_text('db_metars',
- 'This is the name of the table that is used ' .
- 'to cache the METARs.',
- array($db_dep), $table_validator, 'pw_metars');
+ 'This is the name of the table that is used ' .
+ 'to cache the METARs.',
+ array($db_dep), $table_validator, 'pw_metars');
$options['db_stations'] =
new pw_option_text('db_stations',
- 'This is the name of the database/table that is used ' .
- 'to store the names of the stations.',
- array($db_dep), $table_validator, 'pw_stations');
+ 'This is the name of the database/table that is used ' .
+ 'to store the names of the stations.',
+ array($db_dep), $table_validator, 'pw_stations');
$options['db_countries'] =
new pw_option_text('db_countries',
- 'This is the name of the database that is used to ' .
- 'store the names of the countries together with ' .
- 'country-codes.',
- array($dba_dep), $table_validator, 'pw_countries');
-
-
+ 'This is the name of the database that is used to ' .
+ 'store the names of the countries together with ' .
+ 'country-codes.',
+ array($dba_dep), $table_validator, 'pw_countries');
+
+
$options['mark_begin'] =
new pw_option_text('mark_begin',
- 'This string will be placed in front of all the ' .
- "changable parts of the output. If you don't want " .
- 'this to happen, then just use an empty string. ' .
- "Other good choices include <code><i></code>, <code><font " .
- 'color="red"></code>, etc.',
- array(), false, '<b>');
-
+ 'This string will be placed in front of all the ' .
+ "changable parts of the output. If you don't want " .
+ 'this to happen, then just use an empty string. ' .
+ "Other good choices include <code><i></code>, <code><font " .
+ 'color="red"></code>, etc.',
+ array(), false, '<b>');
+
$options['mark_end'] =
new pw_option_text('mark_end',
- 'This string is placed after all the changable parts. ' .
- 'You should make sure that it closes any tags ' .
- "you've opened in <code>mark_begin</code>.",
- array(), false, '</b>');
-
+ 'This string is placed after all the changable parts. ' .
+ 'You should make sure that it closes any tags ' .
+ "you've opened in <code>mark_begin</code>.",
+ array(), false, '</b>');
+
$options['exclude'] =
new pw_option_multi_select('exclude',
- 'You can disable some of the output produced. If ' .
- "you're not interested in information about " .
- 'runways-visibility, then select it in this list. ' .
- 'You can select several options at once in Netscape ' .
- 'by holding down Ctrl while clicking on the option.',
- array(),
- array('time' => 'Leave out the time part',
- 'wind' => 'Leave out the wind part',
- 'runway' => 'Leave out information about runways'));
-
+ 'You can disable some of the output produced. If ' .
+ "you're not interested in information about " .
+ 'runways-visibility, then select it in this list. ' .
+ 'You can select several options at once in Netscape ' .
+ 'by holding down Ctrl while clicking on the option.',
+ array(),
+ array('time' => 'Leave out the time part',
+ 'wind' => 'Leave out the wind part',
+ 'runway' => 'Leave out information about runways'));
+
/* Finally - we register all the options with the session. */
session_register('options');
@@ -268,7 +292,7 @@
$general_group =
new pw_optiongroup('General Options',
'This is some general options for PHP Weather.',
- array('verbosity', 'icao', 'pref_units', 'language',
+ array('verbosity', 'icao', 'pref_units', 'language', 'offset',
'use_proxy', 'proxy_host', 'proxy_port'));
$db_group =
@@ -279,8 +303,8 @@
'least a second or two to fetch a METAR from the ' .
'National Weather Service.',
array('db_type', 'db_handler', 'db_pconnect', 'always_use_db',
- 'db_hostname', 'db_port', 'db_database',
- 'db_username', 'db_password',
+ 'cache_timeout', 'db_hostname', 'db_port',
+ 'db_username', 'db_password', 'db_database',
'db_metars', 'db_stations', 'db_countries'));
$rendering_group =
|