22 if (!isset($CONFIG->libraries)) {
23 $CONFIG->libraries = array();
26 $CONFIG->libraries[
$name] = $location;
41 static $loaded_libraries = array();
43 if (in_array(
$name, $loaded_libraries)) {
47 if (!isset($CONFIG->libraries)) {
48 $CONFIG->libraries = array();
51 if (!isset($CONFIG->libraries[
$name])) {
56 if (!include_once($CONFIG->libraries[
$name])) {
57 $error =
"Could not load the " .
$name .
" library from " . $CONFIG->libraries[
$name];
61 $loaded_libraries[] =
$name;
79 function forward($location =
"", $reason =
'system') {
80 if (!headers_sent($file, $line)) {
93 header(
"Location: {$location}");
95 }
else if ($location ===
'') {
99 throw new SecurityException(
"Redirect could not be issued due to headers already being sent. Halting execution for security. " 100 .
"Output started in file $file at line $line. Search http://learn.elgg.org/ for more information.");
162 if (isset($config[
'deps']) || isset($config[
'exports'])) {
310 $item->location = $location;
313 if ($CONFIG->externals[
$type]->contains(
$item)) {
314 $priority = $CONFIG->externals[
$type]->move(
$item, $priority);
316 $priority = $CONFIG->externals[
$type]->add(
$item, $priority);
319 $item =
new stdClass();
320 $item->loaded =
false;
322 $item->location = $location;
324 $priority = $CONFIG->externals[
$type]->add(
$item, $priority);
329 return $priority !==
false;
351 return $CONFIG->externals[
$type]->remove(
$item);
377 $item->loaded =
true;
379 $item =
new stdClass();
380 $item->loaded =
true;
382 $item->location =
'';
404 $callback =
"return \$v->loaded == true && \$v->location == '$location';";
405 $items = array_filter(
$items, create_function(
'$v', $callback));
407 array_walk(
$items, create_function(
'&$v,$k',
'$v = $v->url;'));
423 if (!isset($CONFIG->externals)) {
424 $CONFIG->externals = array();
431 if (!isset($CONFIG->externals_map)) {
432 $CONFIG->externals_map = array();
435 if (!isset($CONFIG->externals_map[
$type])) {
436 $CONFIG->externals_map[
$type] = array();
456 if ($handle = opendir($directory)) {
457 while (($file = readdir($handle)) !==
false) {
458 if (!is_file($directory . $file) || in_array($file, $exceptions)) {
464 $list[] = $directory . $file;
467 $list[] = $directory . $file;
489 $path = preg_replace(
"/([^:])\/\//",
"$1/",
$path);
535 if (!isset(
$messages[$register]) && !empty($register)) {
547 if ($register !=
"") {
548 $returnarray = array();
549 $returnarray[$register] =
$messages[$register];
559 if (!empty($register)) {
564 $count +=
sizeof($submessages);
684 return _elgg_services()->events->unregisterHandler($event, $object_type, $callback);
868 _elgg_services()->hooks->unregisterHandler($hook, $entity_type, $callback);
948 error_log(
"Exception #$timestamp: $exception");
954 header(
"Cache-Control: no-cache, must-revalidate",
true);
955 header(
'Expires: Fri, 05 Feb 1982 00:00:00 -0500',
true);
960 $CONFIG->pagesetupdone =
true;
966 if (!empty($CONFIG->exception_include) && is_file($CONFIG->exception_include)) {
968 include $CONFIG->exception_include;
969 $exception_output = ob_get_clean();
973 if (!empty($exception_output)) {
974 echo $exception_output;
1001 }
catch (Exception
$e) {
1004 echo "Fatal error in exception handler. Check log for Exception #$timestamp";
1005 error_log(
"Exception #$timestamp : fatal error in exception handler : $message");
1034 $error = date(
"Y-m-d H:i:s (T)") .
": \"$errmsg\" in file $filename (line $linenum)";
1038 error_log(
"PHP ERROR: $error");
1042 throw new Exception(
$error);
1046 case E_USER_WARNING :
1047 case E_RECOVERABLE_ERROR:
1050 if (error_reporting()) {
1051 error_log(
"PHP WARNING: $error");
1057 if (isset($CONFIG->debug) && $CONFIG->debug ===
'NOTICE') {
1058 error_log(
"PHP NOTICE: $error");
1084 static $levels = array(
1092 if ($level ==
'DEBUG') {
1096 $level = $levels[$level];
1131 if (isset($CONFIG->path)) {
1132 if (!isset(
$version) || !isset($release)) {
1133 if (!include($CONFIG->path .
"version.php")) {
1137 return $human_readable ? $release :
$version;
1177 if (!$dep_version) {
1182 $elgg_version_arr = explode(
'.', $elgg_version);
1183 $elgg_major_version = (int)$elgg_version_arr[0];
1184 $elgg_minor_version = (int)$elgg_version_arr[1];
1186 $dep_major_version = (int)$dep_version;
1187 $dep_minor_version = 10 * ($dep_version - $dep_major_version);
1191 if (($dep_major_version < $elgg_major_version) ||
1192 ($dep_minor_version < $elgg_minor_version)) {
1196 $msg =
"Deprecated in $dep_major_version.$dep_minor_version: $msg";
1205 $msg .=
" Called from ";
1207 $backtrace = debug_backtrace();
1209 array_shift($backtrace);
1210 $i = count($backtrace);
1212 foreach ($backtrace as $trace) {
1213 $stack[] =
"[#$i] {$trace['file']}:{$trace['line']}";
1216 if ($backtrace_level > 0) {
1217 if ($backtrace_level <= 1) {
1224 $msg .= implode(
"<br /> -> ", $stack);
1244 $scheme = isset($parts[
'scheme']) ?
"{$parts['scheme']}://" :
'';
1245 $host = isset($parts[
'host']) ?
"{$parts['host']}" :
'';
1246 $port = isset($parts[
'port']) ?
":{$parts['port']}" :
'';
1247 $path = isset($parts[
'path']) ?
"{$parts['path']}" :
'';
1248 $query = isset($parts[
'query']) ?
"?{$parts['query']}" :
'';
1249 $fragment = isset($parts[
'fragment']) ?
"#{$parts['fragment']}" :
'';
1251 $string = $scheme . $host . $port .
$path . $query . $fragment;
1281 if (isset($components[
'query'])) {
1287 if (isset($query[
'__elgg_ts']) && isset($query[
'__elgg_token'])) {
1292 $query[
'__elgg_ts'] = time();
1294 $components[
'query'] = http_build_query($query);
1328 if (isset($url_array[
'query'])) {
1334 foreach ($elements as $k => $v) {
1345 if ($query || empty($url_array[
'path'])) {
1346 $url_array[
'query'] = http_build_query($query);
1348 unset($url_array[
'query']);
1375 if ($url1 == $url2) {
1382 if (isset($url1_info[
'path'])) {
1383 $url1_info[
'path'] = trim($url1_info[
'path'],
'/');
1385 if (isset($url2_info[
'path'])) {
1386 $url2_info[
'path'] = trim($url2_info[
'path'],
'/');
1390 $parts = array(
'scheme',
'host',
'path');
1392 foreach ($parts as $part) {
1393 if ((isset($url1_info[$part]) && isset($url2_info[$part]))
1394 && $url1_info[$part] != $url2_info[$part]) {
1396 } elseif (isset($url1_info[$part]) && !isset($url2_info[$part])) {
1398 } elseif (!isset($url1_info[$part]) && isset($url2_info[$part])) {
1404 if (isset($url1_info[
'query']) && isset($url2_info[
'query'])
1405 && $url1_info[
'query'] == $url2_info[
'query']) {
1410 $url1_params = array();
1411 $url2_params = array();
1413 if (isset($url1_info[
'query'])) {
1414 if ($url1_info[
'query'] = html_entity_decode($url1_info[
'query'])) {
1419 if (isset($url2_info[
'query'])) {
1420 if ($url2_info[
'query'] = html_entity_decode($url2_info[
'query'])) {
1426 foreach ($ignore_params as $param) {
1427 if (isset($url1_params[$param])) {
1428 unset($url1_params[$param]);
1430 if (isset($url2_params[$param])) {
1431 unset($url2_params[$param]);
1440 $diff_count = count(array_diff_assoc($url1_params, $url2_params));
1441 $diff_count += count(array_diff_assoc($url2_params, $url1_params));
1442 if ($diff_count > 0) {
1465 if (!is_array($array)) {
1472 return (isset($array[
$key]) && !empty($array[$key])) ? $array[
$key] :
$default;
1497 $sort_type = SORT_LOCALE_STRING) {
1501 foreach ($array as $v) {
1502 if (isset($v[$element])) {
1503 $sort[] = strtolower($v[$element]);
1509 return array_multisort(
$sort, $sort_order, $sort_type, $array);
1523 $temp = strtolower(ini_get($ini_get_arg));
1525 if ($temp ==
'1' || $temp ==
'on' || $temp ==
'true') {
1544 $val = ini_get($setting);
1547 $last = strtolower($val[strlen($val) - 1]);
1595 foreach ($singulars as $singular) {
1596 $plural = $singular .
's';
1598 if (array_key_exists($singular,
$options)) {
1603 if (!is_array(
$options[$singular])) {
1639 $uri =
_elgg_services()->request->server->get(
'REQUEST_URI',
'CLI');
1641 elgg_log(
"Page {$uri} generated in $time seconds",
'INFO');
1642 }
catch (Exception
$e) {
1643 $message =
'Error: ' . get_class($e) .
' thrown within the shutdown handler. ';
1644 $message .=
"Message: '{$e->getMessage()}' in file {$e->getFile()} (line {$e->getLine()})";
1646 error_log(
"Exception trace stack: {$e->getTraceAsString()}");
1650 session_write_close();
1682 if (is_array($page) &&
sizeof($page)) {
1685 $view = implode(
'/', $page);
1688 if (!array_key_exists(
$view, $allowed_views)) {
1689 header(
'HTTP/1.1 403 Forbidden');
1699 if (isset(
$vars[
'guid'])) {
1706 header(
"Content-Type: text/javascript");
1709 header(
"Content-Type: text/css");
1731 if (!isset($page[0])) {
1754 $content_type =
'text/javascript';
1758 $content_type =
'text/css';
1773 $page = implode(
'/', $page);
1774 $regex =
'|(.+?)\.\w+$|';
1775 if (!preg_match($regex, $page, $matches)) {
1778 $view =
"$type/{$matches[1]}";
1784 header(
"Content-type: $content_type");
1810 $order_by = strtolower($order_by);
1812 if (strpos($order_by,
' asc') !==
false) {
1813 $return = str_replace(
' asc',
' desc', $order_by);
1814 } elseif (strpos($order_by,
' desc') !==
false) {
1815 $return = str_replace(
' desc',
' asc', $order_by);
1818 $return = $order_by .
' desc';
1837 return $object->enable() ?
true :
false;
1851 return $object->disable() ?
true :
false;
1865 return $object->delete() ?
true :
false;
1890 $metadata_required = array(
1891 'metadata_owner_guid',
'metadata_owner_guids',
1892 'metadata_name',
'metadata_names',
1893 'metadata_value',
'metadata_values' 1896 $required = array_merge($required, $metadata_required);
1901 $annotations_required = array(
1902 'annotation_owner_guid',
'annotation_owner_guids',
1903 'annotation_name',
'annotation_names',
1904 'annotation_value',
'annotation_values' 1907 $required = array_merge($required, $annotations_required);
1914 foreach ($required as
$key) {
1939 'class' =>
'elgg-walledgarden-double',
1940 'id' =>
'elgg-walledgarden-login',
1959 'content' =>
elgg_view(
"core/walled_garden/$view"),
1960 'class' =>
'elgg-walledgarden-single hidden',
1961 'id' => str_replace(
'_',
'-',
"elgg-walledgarden-$view"),
1989 if (isset($CONFIG->site) && $CONFIG->site instanceof
ElggSite) {
1990 $CONFIG->site->checkWalledGarden();
2005 unset($accesses[ACCESS_PUBLIC]);
2025 set_error_handler(
'_elgg_php_error_handler');
2026 set_exception_handler(
'_elgg_php_exception_handler');
2065 elgg_register_js(
'jquery.ui.autocomplete.html',
'vendors/jquery/jquery.ui.autocomplete.html.js');
2071 elgg_register_js(
'jquery.imgareaselect',
'vendors/jquery/jquery.imgareaselect/scripts/jquery.imgareaselect.min.js');
2074 elgg_register_css(
'jquery.imgareaselect',
'vendors/jquery/jquery.imgareaselect/css/imgareaselect-deprecated.css');
2077 register_shutdown_function(
'_elgg_shutdown_hook');
2082 $CONFIG->wordblacklist = array();
2085 foreach (
$list as $l) {
2086 $CONFIG->wordblacklist[] = trim($l);
2105 $value[] = $CONFIG->path .
'engine/tests/ElggTravisInstallTest.php';
2106 $value[] = $CONFIG->path .
'engine/tests/ElggCoreHelpersTest.php';
2107 $value[] = $CONFIG->path .
'engine/tests/ElggCoreRegressionBugsTest.php';
2108 $value[] = $CONFIG->path .
'engine/tests/ElggBatchTest.php';
2120 define(
'ACCESS_DEFAULT', -1);
2121 define(
'ACCESS_PRIVATE', 0);
2122 define(
'ACCESS_LOGGED_IN', 1);
2123 define(
'ACCESS_PUBLIC', 2);
2124 define(
'ACCESS_FRIENDS', -2);
2134 define(
'ELGG_ENTITIES_ANY_VALUE', null);
2143 define(
'ELGG_ENTITIES_NO_VALUE', 0);
2152 define(
'REFERRER', -1);
2162 define(
'REFERER', -1);
_elgg_load_autoload_cache()
Load cached data into the autoload system.
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL's query string.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
elgg_get_loaded_css()
Get the loaded CSS URLs.
if(!$owner||!($owner instanceof ElggUser)||!$owner->canEdit()) $error
elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback)
Unregister a callback as a plugin hook.
elgg_add_action_tokens_to_url($url, $html_encode=false)
Adds action tokens to URL.
_elgg_css_page_handler($page)
Serve CSS.
_elgg_is_valid_options_for_batch_operation($options, $type)
Checks if there are some constraints on the options array for potentially dangerous operations...
elgg_register_external_file($type, $name, $url, $location, $priority=500)
Core registration function for external files.
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
if($guid==elgg_get_logged_in_user_guid()) $name
elgg_define_js($name, $config)
Defines a JS lib as an AMD module.
elgg_sort_3d_array_by_value(&$array, $element, $sort_order=SORT_ASC, $sort_type=SORT_LOCALE_STRING)
Sorts a 3d array by specific element.
elgg_http_url_is_identical($url1, $url2, $ignore_params=array('offset', 'limit'))
Test if two URLs are functionally identical.
elgg_unregister_external_file($type, $name)
Unregister an external file.
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
if(is_callable('mb_internal_encoding')) elgg_parse_str($str)
Parses a string using mb_parse_str() if available.
elgg_register_external_view($view, $cacheable=false)
Registers a view as being available externally (i.e.
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
elgg_register_css($name, $url, $priority=null)
Register a CSS file for inclusion in the HTML head.
elgg_load_library($name)
Load a php library.
elgg parse_url
Parse a URL into its parts.
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
_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.
_elgg_sql_reverse_order_by_clause($order_by)
Reverses the ordering in an ORDER BY clause.
_elgg_ajax_page_handler($page)
Serve individual views for Ajax.
_elgg_load_translations()
private
elgg_trigger_before_event($event, $object_type, $object=null)
Trigger a "Before event" indicating a process is about to begin.
_elgg_shutdown_hook()
Emits a shutdown:system event upon PHP shutdown, but before database connections are dropped...
_elgg_php_exception_handler($exception)
Intercepts, logs, and displays uncaught exceptions.
register_error($error)
Display an error on next page load.
elgg_get_loaded_external_files($type, $location)
Get external resource descriptors.
is_not_null($string)
Returns true is string is not empty, false, or null.
elgg_batch_delete_callback($object)
Delete objects with a delete() method.
_elgg_js_page_handler($page)
Serve javascript pages.
_elgg_bootstrap_externals_data_structure($type)
Bootstraps the externals data structure in $CONFIG.
elgg_unregister_css($name)
Unregister a CSS file.
elgg ElggPriorityList
Priority lists allow you to create an indexed list that can be iterated through in a specific order...
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
elgg_get_file_list($directory, $exceptions=array(), $list=array(), $extensions=null)
Returns a list of files in $directory.
elgg_get_ini_setting_in_bytes($setting)
Returns a PHP INI setting in bytes.
const OPTION_DEPRECATION_MESSAGE
_elgg_api_test($hook, $type, $value, $params)
Adds unit tests for the general API.
elgg_load_css($name)
Load a CSS file for this page.
elgg_register_js($name, $url, $location= 'head', $priority=null)
Register a JavaScript file for inclusion.
generate_action_token($timestamp)
Generate an action token.
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
elgg_get_simplecache_url($type, $view)
elgg_http_remove_url_query_element($url, $element)
Removes an element from a URL's query string.
_elgg_load_cache()
Loads the system cache during engine boot.
elgg_trigger_deprecated_event($event, $object_type, $object=null, $message, $version)
Trigger an event normally, but send a notice about deprecated use if any handlers are registered...
elgg_load_external_file($type, $name)
Load an external resource for use on this page.
_elgg_engine_boot()
Boots the engine.
_elgg_walled_garden_index()
Intercepts the index page when Walled Garden mode is enabled.
_elgg_cacheable_view_page_handler($page, $type)
Serves a JS or CSS view with headers for caching.
ini_get_bool($ini_get_arg)
Return the state of a php.ini setting as a bool.
elgg_dump($value, $to_screen=true)
Logs or displays $value.
const ELGG_ENTITIES_ANY_VALUE
elgg echo
Translates a string.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
_elgg_walled_garden_ajax_handler($page)
Serve walled garden sections.
global $START_MICROTIME
The time with microseconds when the Elgg engine was started.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
elgg_register_library($name, $location)
Register a php library.
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
system_messages($message=null, $register="success", $count=false)
Queues a message to be displayed.
elgg_view_layout($layout_name, $vars=array())
Displays a layout with optional parameters.
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
elgg_log($message, $level= 'NOTICE')
Display or log a message.
_elgg_walled_garden_remove_public_access($hook, $type, $accesses)
Remove public access for walled gardens.
forward($location="", $reason= 'system')
Forward to $location.
elgg_get_version($human_readable=false)
Get the current Elgg version information.
elgg_load_js($name)
Load a JavaScript resource on this page.
elgg_http_build_url(array $parts, $html_encode=true)
Builds a URL from the a parts array like one returned by parse_url().
$content
Set robots.txt action.
elgg_batch_disable_callback($object)
Disable objects with a disable() method.
elgg_format_url($url)
Handles formatting of ampersands in urls.
elgg_trigger_after_event($event, $object_type, $object=null)
Trigger an "After event" indicating a process has finished.
_elgg_init()
Elgg's main init.
elgg_view_page($title, $body, $page_shell= 'default', $vars=array())
Assembles and outputs a full page.
clearfix elgg elgg elgg elgg page header
elgg_register_action($action, $filename="", $access= 'logged_in')
Registers an action.
_elgg_session_boot()
Initializes the session and checks for the remember me cookie.
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
elgg_trigger_event($event, $object_type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event...
_elgg_walled_garden_init()
Checks the status of the Walled Garden and forwards to a login page if required.
_elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars)
Intercepts catchable PHP errors.
_elgg_load_application_config()
Loads configuration related to Elgg as an application.
const OPTION_DEPRECATION_VERSION
system_message($message)
Display a system message on next page load.
elgg_get_loaded_js($location= 'head')
Get the JavaScript URLs that are loaded.
elgg_batch_enable_callback($object)
Enable objects with an enable() method.
elgg_unregister_event_handler($event, $object_type, $callback)
Unregisters a callback for an event.
elgg_unregister_js($name)
Unregister a JavaScript file.
count_messages($register="")
Counts the number of messages, either globally or in a particular register.
if($composer===null) if(!isset($composer->version)) $release
get_entity($guid)
Loads and returns an entity object from a guid.
if(file_exists($welcome)) $vars