/program/init.php - setup database connection, sessions, configuration, etc.
This file is included from one of the main entry points. The following subsystems and global variables are initialised:
Note that this file is _the_ place to defined truly global constants because it is always include()'d.
This global constant defines the maximum number of iterations in database loops (prevent circular reference)
This global constant is used to specify thumbnail files to be ignored in directory listings
This global constant replaces a similar built-in constant LOG_ALERT which is defined as 1 in win32.h
This global constant replaces a similar built-in constant LOG_CRIT which is erroneously defined as 1 in win32.h
This global constant replaces a similar built-in constant LOG_DEBUG which is erroneously defined as 6 in win32.h
This global constant replaces a similar built-in constant LOG_EMERG which is erroneously defined as 1 in win32.h
This global constant replaces a similar built-in constant LOG_ERR which is erroneously defined as 4 in win32.h
This global constant replaces a similar built-in constant LOG_INFO which is defined as 6 in win32.h
This global constant replaces a similar built-in constant LOG_NOTICE which is erroneously defined as 6 in win32.h
This global constant replaces a similar built-in constant LOG_WARNING which is erroneously defined as 5 in win32.h
Calculate the difference between two microtimes
emergency exit of program in case there is something really, really wrong
This routine outputs a short message and a 'cryptic' condition code and exits the program. It is called when something goes horribly wrong during the early stages of running the program, e.g. the database cannot be opened or there is a version mismatch between the program code (the .php-files) and the database. The complete condition code is the WAS release number followed by a slash followed by the WAS version number followed by a slash and the bare condition code. The message ends with a link to about.html with 'Powered by' or 'Based on', depending on the WAS original flag. Note that we try to show graphics (including logo) but that we switch back to text-only if it is too early, ie. before waslib.php is included.
Here is an overview of meaning of the condition codes used.
If the user was logged inwhen this fatal error happens, e.g. she requested a protected area, logged in but access was denied anyway, a small postfix is added to the condition code: an asterisk. This indicates that the logged in user was logged out as part of this error exit. This way (hopefully) the session will no longer be available after this error exit.
initialise the program, setup database, read configuration, etc.
determine the name of the executing script (the entry point)
this routine tries to reach consensus about the name of the script that was the entry point. This is not as easy as it sounds.
See install_script_name() for an exhausing discussion of the issues.
check version of PHP-files against version stored in database
this checks the main WAS_VERSION (of files) against $CFG->version (database). if all is well, we return TRUE indicating both version numbers match. If there is a discrepancy it is logged and depending on parameter $exit_on_error we either exit alltogether OR we return FALSE to indicate the version mismatch.
Typical use is to call this routine near the start as follows (e.g. in main_index.php or main_file.php):
This forces an exit for the interfaces at the 'visitor' side. For the webmaster it is different: even if the versions do not match, we want to be able to login and do something about it via some sort of upgrade routine, e.g:
Documentation generated on Tue, 28 Jun 2016 19:09:52 +0200 by phpDocumentor 1.4.0