Including lib-common.php

From GeeklogWiki
Revision as of 10:20, 10 March 2006 by Dirk (talk | contribs) (Short article on how to properly include lib-common.php and why)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

lib-common.php is Geeklog's repository of commonly used functions (those that start with COM_). It also pulls in other libraries, e.g. for the session handling, and ensures that all currently active plugins are loaded.

It is also an important part of Geeklog's security.

Among the files that lib-common.php loads is Geeklog's central configuration file, config.php. By loading this file, it's ensured that all the global $_CONF variables are set and can not be overridden by URL parameters (assuming register_globals is "on").

It is therefore important to properly include lib-common.php, which means

  • always use either the complete, absolute path to your lib-common.php, i.e.
/path/to/your/lib-common.php
  • or use a relative path, i.e.
../../lib-common.php
  • never(!) use a variable in the path, i.e.
$somepath . 'lib-common.php'

An older version of the Geeklog/Gallery integration had exactly that problem.

lib-common.php should also always be the first file you include in your script. Actually, it should be the first line of code in your script.