PHP Global Environment - jcobban/Genealogy GitHub Wiki
The PHP scripts running on the Web Server have access to a set of services specific to the implementation:
common.inc
The code in all of the class implementations, and in the PHP scripts that implement the user interface, depends upon common functionality that is implemented in the include file /Genealogy/common.inc. This is included in every script that provides services. Note, however, that this script uses the services provided by several of the class definitions, so it must be included after the includes for all of the classes that are referenced by the script. This include file takes care of the following functionality:
- Obtains a PDO connection resource to the database server in the global variable
$connection
. This resource is initialized such as to deliver consistent behavior, and the only feature that is typically altered by individual scripts is whether fetch and fetchAll return an ordered or associative array. The parameters for initializing this connection are obtained from the include file /Genealogy/configDb.inc and selected based upon the domain name. - Initializes the variable
$userid
with the user name of the current user from the session information. If this is not an empty string the variable$user
is initialized to an instance of the class User. - Initializes the variable
$browser
as an associative array of information about the user's browser. Only the keys: 'browser', 'version', 'majorver', and 'minorver' are guaranteed to be present. - Defines a global variable
$msg
which is used to collect serious error messages that prevent the current script from performing its function. If this variable is not empty its contents are displayed in a paragraph withclass='message'
so that the text is displayed in red. - Defines a global variable
$warn
which is used to collect diagnostic information including messages indicating that non-terminal errors, such as ignoring an invalid parameter, have been detected. Each message that is added to this variable should be enclosed in an HTML <p> tag so that it will appear properly when displayed to the user. The accumulated contents of this string value are displayed as part of a Webpage by the global function showTrace. - Initializes the variable
$authorized
with the set of authorizations of the current user. To avoid documenting the internal content of this variable, which may change in the future, thefunction canUser
should be used to determine whether the current user can perform a particular function. - Defines a global variable
$debug
which is set to true if a parameter 'debug=Y' or 'debug=Yes' is passed either by method='get'or method='post' and the current user is authorized to enable debugging output, that iscanUser('debug')
is true. Almost all scripts check for this global setting and add additional messages to$warn
if it is true. In particular the method dump of each of the database record classes adds an HTML table displaying the contents of the current record to$warn
if$debug
istrue
. Normally only an administrator can set this option.
Defines a set of global functions in the namespace Genealogy which provide common services: