29 if ($site_guid == 0) {
31 return $CONFIG->wwwroot;
52 return $CONFIG->pluginspath;
63 return $CONFIG->dataroot;
92 if (($site_guid === 0 || $site_guid === null || $site_guid == $CONFIG->site_guid) && isset($CONFIG->$name)) {
93 return $CONFIG->$name;
96 if ($site_guid === null) {
100 if ($site_guid == 0) {
101 $site_guid = (int) $CONFIG->site_guid;
105 if (!isset($CONFIG->site_config_loaded) || $site_guid != $CONFIG->site_guid) {
118 if ($site_guid == $CONFIG->site_guid || $site_guid === null) {
159 if (strlen(
$name) > 255) {
160 elgg_log(
"The name length for configuration variables cannot be greater than 255",
"ERROR");
164 if ($site_guid === null) {
170 if ($site_guid == 0) {
171 $site_guid = (int) $CONFIG->site_guid;
176 if ($site_guid === null || $site_guid == $CONFIG->site_guid) {
213 elgg_log(
"The name length for configuration variables cannot be greater than 255",
"ERROR");
217 if (isset($DATALIST_CACHE[
$name])) {
218 return $DATALIST_CACHE[
$name];
223 static $datalist_memcache = null;
225 $datalist_memcache =
new ElggMemcache(
'datalist_memcache');
227 if ($datalist_memcache) {
228 $value = $datalist_memcache->load($name);
237 $result =
get_data_row(
"SELECT * FROM {$CONFIG->dbprefix}datalists WHERE name = '$escaped_name'");
242 if ($datalist_memcache) {
276 elgg_log(
"The name length for configuration variables cannot be greater than 255",
"ERROR");
281 static $datalist_memcache = null;
283 $datalist_memcache =
new ElggMemcache(
'datalist_memcache');
286 if ($datalist_memcache) {
287 $datalist_memcache->delete(
$name);
293 .
" SET name = '$escaped_name', value = '$escaped_value'" 294 .
" ON DUPLICATE KEY UPDATE value = '$escaped_value'");
334 $lastupdated = (int) $lastupdated;
335 } elseif ($lastupdated !==
false) {
341 if (is_callable($functionname) && $lastupdated <= $timelastupdatedcheck) {
369 $site_guid = (int) $site_guid;
370 if ($site_guid == 0) {
371 $site_guid = (int) $CONFIG->site_guid;
374 if ($site_guid == $CONFIG->site_guid && isset($CONFIG->$name)) {
375 unset($CONFIG->$name);
379 $query =
"DELETE FROM {$CONFIG->dbprefix}config WHERE name = '$escaped_name' AND site_guid = $site_guid";
415 elgg_log(
"The name length for configuration variables cannot be greater than 255",
"ERROR");
419 $site_guid = (int) $site_guid;
420 if ($site_guid == 0) {
421 $site_guid = (int) $CONFIG->site_guid;
424 if ($site_guid == $CONFIG->site_guid) {
431 SET name = '$escaped_name', value = '$escaped_value', site_guid = $site_guid 432 ON DUPLICATE KEY UPDATE value = '$escaped_value'");
458 $site_guid = (int) $site_guid;
465 $new_name =
'view_path';
469 $new_name =
'plugins_path';
473 $new_name =
'site_name';
485 if ($site_guid == 0) {
486 $site_guid = (int) $CONFIG->site_guid;
490 if ($site_guid == $CONFIG->site_guid && isset($CONFIG->$name)) {
491 return $CONFIG->$name;
496 WHERE name = '$escaped_name' AND site_guid = $site_guid");
501 if ($site_guid == $CONFIG->site_guid) {
522 $site_guid = (int) $site_guid;
524 if ($site_guid == 0) {
525 $site_guid = (int) $CONFIG->site_guid;
528 if (
$result =
get_data(
"SELECT * FROM {$CONFIG->dbprefix}config WHERE site_guid = $site_guid")) {
532 $CONFIG->$name = unserialize(
$value);
554 $CONFIG->site_guid = (int)
datalist_get(
'default_site');
555 $CONFIG->site_id = $CONFIG->site_guid;
556 $CONFIG->site =
get_entity($CONFIG->site_guid);
557 if (!$CONFIG->site) {
558 throw new InstallationException(
"Unable to handle this request. This site is not configured or the database is down.");
561 $CONFIG->wwwroot = $CONFIG->site->url;
562 $CONFIG->sitename = $CONFIG->site->name;
563 $CONFIG->sitedescription = $CONFIG->site->description;
564 $CONFIG->siteemail = $CONFIG->site->email;
565 $CONFIG->url = $CONFIG->wwwroot;
569 $CONFIG->site_config_loaded =
true;
571 if (!empty($CONFIG->debug)) {
589 $install_root = str_replace(
"\\",
"/", dirname(dirname(dirname(__FILE__))));
591 'path' =>
"$install_root/",
592 'view_path' =>
"$install_root/views/",
593 'plugins_path' =>
"$install_root/mod/",
597 'viewpath' =>
"$install_root/views/",
598 'pluginspath' =>
"$install_root/mod/",
602 if (empty($CONFIG->$name)) {
608 if (!isset($CONFIG->cookies)) {
609 $CONFIG->cookies = array();
611 if (!isset($CONFIG->cookies[
'session'])) {
612 $CONFIG->cookies[
'session'] = array();
614 $session_defaults = session_get_cookie_params();
615 $session_defaults[
'name'] =
'Elgg';
616 $CONFIG->cookies[
'session'] = array_merge($session_defaults, $CONFIG->cookies[
'session']);
617 if (!isset($CONFIG->cookies[
'remember_me'])) {
618 $CONFIG->cookies[
'remember_me'] = array();
620 $session_defaults[
'name'] =
'elggperm';
621 $session_defaults[
'expire'] = strtotime(
"+30 days");
622 $CONFIG->cookies[
'remember_me'] = array_merge($session_defaults, $CONFIG->cookies[
'remember_me']);
631 $DATALIST_CACHE[$row->name] = $row->value;
638 $CONFIG->path =
$path;
642 if (isset($CONFIG->dataroot)) {
644 $CONFIG->dataroot_in_settings =
true;
647 if (!empty($dataroot)) {
648 $CONFIG->dataroot = $dataroot;
650 $CONFIG->dataroot_in_settings =
false;
652 if (isset($CONFIG->simplecache_enabled)) {
653 $CONFIG->simplecache_enabled_in_settings =
true;
655 $simplecache_enabled =
datalist_get(
'simplecache_enabled');
656 if ($simplecache_enabled !==
false) {
657 $CONFIG->simplecache_enabled = $simplecache_enabled;
659 $CONFIG->simplecache_enabled = 1;
661 $CONFIG->simplecache_enabled_in_settings =
false;
664 $system_cache_enabled =
datalist_get(
'system_cache_enabled');
665 if ($system_cache_enabled !==
false) {
666 $CONFIG->system_cache_enabled = $system_cache_enabled;
668 $CONFIG->system_cache_enabled = 1;
672 $CONFIG->context = array();
675 $CONFIG->lastcache = (int)
datalist_get(
"simplecache_lastupdate");
677 $CONFIG->i18n_loaded_from_cache =
false;
680 $CONFIG->entity_types = array(
'group',
'object',
'site',
'user');
688 $tests[] =
"{$CONFIG->path}engine/tests/ElggCoreConfigTest.php";
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
get_data_row($query, $callback="")
Retrieve a single row from the database.
if($guid==elgg_get_logged_in_user_guid()) $name
unset_config($name, $site_guid=0)
Removes a config setting.
elgg_save_config($name, $value, $site_guid=0)
Save a configuration setting.
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
get_config($name, $site_guid=0)
Gets a configuration value.
_elgg_config_test($hook, $type, $tests)
private
_elgg_load_site_config()
Loads configuration related to this site.
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Register a callback as a plugin hook handler.
delete_data($query)
Remove a row from the database.
sanitize_string($string)
Sanitize a string for database use.
insert_data($query)
Insert a row into the database.
elgg_strlen()
Wrapper function for mb_strlen().
datalist_get($name)
Get the value of a datalist element.
elgg_set_config($name, $value)
Set an Elgg configuration value.
datalist_set($name, $value)
Set the value for a datalist element.
elgg_get_root_path()
Get the root directory path for this installation.
elgg global
Pointer to the global context.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
run_function_once($functionname, $timelastupdatedcheck=0)
Run a function one time per installation.
elgg_log($message, $level= 'NOTICE')
Display or log a message.
get_data($query, $callback="")
Retrieve rows from the database.
global $DATALIST_CACHE
An array of key value pairs from the datalists table.
_elgg_get_all_config($site_guid=0)
Loads all configuration values from the dbprefix_config table into $CONFIG.
elgg_get_plugins_path()
Get the plugin path for this installation.
is_memcache_available()
Return true if memcache is available and configured.
elgg_get_data_path()
Get the data directory path for this installation.
_elgg_load_application_config()
Loads configuration related to Elgg as an application.
get_entity($guid)
Loads and returns an entity object from a guid.
set_config($name, $value, $site_guid=0)
Add or update a config setting.