Including lib-common.php

From GeeklogWiki
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.
require_once '/path/to/your/lib-common.php';
  • or use a relative path, i.e.
require_once '../../lib-common.php';
  • never(!) use a variable in the path, i.e. something like
require_once $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.