24     $libraries = $config->get(
'libraries');
 
   25     if ($libraries === 
null) {
 
   28     $libraries[
$name] = $location;
 
   29     $config->set(
'libraries', $libraries);
 
   44     static $loaded_libraries = array();
 
   46     if (in_array(
$name, $loaded_libraries)) {
 
   52     if (!isset($libraries[
$name])) {
 
   53         $error = 
"$name is not a registered library";
 
   54         throw new \InvalidParameterException(
$error);
 
   57     if (!include_once($libraries[
$name])) {
 
   58         $error = 
"Could not load the $name library from {$libraries[$name]}";
 
   59         throw new \InvalidParameterException(
$error);
 
   62     $loaded_libraries[] = 
$name;
 
   80 function forward($location = 
"", $reason = 
'system') {
 
   81     if (!headers_sent($file, $line)) {
 
   88             if ($safe_url !== 
false) {
 
   95         if (!preg_match(
'/^(http|https|ftp|sftp|ftps):\/\//', 
$forward_url)) {
 
  103             'location' => $location,
 
  108             header(
"Location: {$forward_url}");
 
  112         throw new \SecurityException(
"Redirect could not be issued due to headers already being sent. Halting execution for security. " 
  113             . 
"Output started in file $file at line $line. Search http://learn.elgg.org/ for more information.");
 
  175     if (isset($config[
'deps']) || isset($config[
'exports'])) {
 
  354     if ($handle = opendir($directory)) {
 
  355         while (($file = readdir($handle)) !== 
false) {
 
  356             if (!is_file($directory . $file) || in_array($file, $exceptions)) {
 
  362                     $list[] = $directory . $file;
 
  365                 $list[] = $directory . $file;
 
  387     $path = preg_replace(
"/([^:])\/\//", 
"$1/", 
$path);
 
  548     return _elgg_services()->events->unregisterHandler($event, $object_type, $callback);
 
  626         \
Elgg\EventsService::OPTION_STOPPABLE => 
false,
 
  646         \
Elgg\EventsService::OPTION_DEPRECATION_MESSAGE => 
$message,
 
  647         \
Elgg\EventsService::OPTION_DEPRECATION_VERSION => 
$version,
 
  733     _elgg_services()->hooks->unregisterHandler($hook, $entity_type, $callback);
 
  813     error_log(
"Exception at time $timestamp: $exception");
 
  819     header(
"Cache-Control: no-cache, must-revalidate", 
true);
 
  820     header(
'Expires: Fri, 05 Feb 1982 00:00:00 -0500', 
true);
 
  830         if (!empty(
$CONFIG->exception_include) && is_file(
$CONFIG->exception_include)) {
 
  832             include 
$CONFIG->exception_include;
 
  833             $exception_output = ob_get_clean();
 
  837             if (!empty($exception_output)) {
 
  838                 echo $exception_output;
 
  845             $response = new \Symfony\Component\HttpFoundation\JsonResponse(
null, 500);
 
  848             $response = new \Symfony\Component\HttpFoundation\Response(
'', 500);
 
  865     } 
catch (Exception 
$e) {
 
  868         http_response_code(500);
 
  869         echo 
"Fatal error in exception handler. Check log for Exception at time $timestamp";
 
  870         error_log(
"Exception at time $timestamp : fatal error in exception handler : $message");
 
  902     if (0 === strpos($errmsg, 
"mysql_connect(): The mysql extension is deprecated")) {
 
  904         if (preg_match(
'~/classes/Elgg/Database\.php$~', strtr(
$filename, 
'\\', 
'/'))) {
 
  909     $error = date(
"Y-m-d H:i:s (T)") . 
": \"$errmsg\" in file $filename (line $linenum)";
 
  913             error_log(
"PHP ERROR: $error");
 
  917             throw new \Exception(
$error);
 
  921         case E_USER_WARNING :
 
  922         case E_RECOVERABLE_ERROR: 
 
  925             if (error_reporting()) {
 
  926                 error_log(
"PHP WARNING: $error");
 
  933                 error_log(
"PHP NOTICE: $error");
 
  959     static $levels = array(
 
  967     if ($level == 
'DEBUG') {
 
  971     $level = $levels[$level];
 
 1008             if (!include(
$CONFIG->path . 
"version.php")) {
 
 1032     $backtrace_level += 1;
 
 1033     return _elgg_services()->deprecation->sendNotice($msg, $dep_version, $backtrace_level);
 
 1051     $scheme = isset($parts[
'scheme']) ? 
"{$parts['scheme']}://" : 
'';
 
 1052     $host = isset($parts[
'host']) ? 
"{$parts['host']}" : 
'';
 
 1053     $port = isset($parts[
'port']) ? 
":{$parts['port']}" : 
'';
 
 1054     $path = isset($parts[
'path']) ? 
"{$parts['path']}" : 
'';
 
 1055     $query = isset($parts[
'query']) ? 
"?{$parts['query']}" : 
'';
 
 1056     $fragment = isset($parts[
'fragment']) ? 
"#{$parts['fragment']}" : 
'';
 
 1058     $string = $scheme . $host . $port . 
$path . $query . $fragment;
 
 1086     $components = parse_url(
$url);
 
 1088     if (isset($components[
'query'])) {
 
 1094     if (isset($query[
'__elgg_ts']) && isset($query[
'__elgg_token'])) {
 
 1099     $query[
'__elgg_ts'] = time();
 
 1101     $components[
'query'] = http_build_query($query);
 
 1133     $url_array = parse_url(
$url);
 
 1135     if (isset($url_array[
'query'])) {
 
 1141     foreach ($elements as $k => $v) {
 
 1152     if ($query || empty($url_array[
'path'])) {
 
 1153         $url_array[
'query'] = http_build_query($query);
 
 1155         unset($url_array[
'query']);
 
 1182     if ($url1 == $url2) {
 
 1186     $url1_info = parse_url($url1);
 
 1187     $url2_info = parse_url($url2);
 
 1189     if (isset($url1_info[
'path'])) {
 
 1190         $url1_info[
'path'] = trim($url1_info[
'path'], 
'/');
 
 1192     if (isset($url2_info[
'path'])) {
 
 1193         $url2_info[
'path'] = trim($url2_info[
'path'], 
'/');
 
 1197     $parts = array(
'scheme', 
'host', 
'path');
 
 1199     foreach ($parts as $part) {
 
 1200         if ((isset($url1_info[$part]) && isset($url2_info[$part]))
 
 1201         && $url1_info[$part] != $url2_info[$part]) {
 
 1203         } elseif (isset($url1_info[$part]) && !isset($url2_info[$part])) {
 
 1205         } elseif (!isset($url1_info[$part]) && isset($url2_info[$part])) {
 
 1211     if (isset($url1_info[
'query']) && isset($url2_info[
'query'])
 
 1212     && $url1_info[
'query'] == $url2_info[
'query']) {
 
 1217     $url1_params = array();
 
 1218     $url2_params = array();
 
 1220     if (isset($url1_info[
'query'])) {
 
 1221         if ($url1_info[
'query'] = html_entity_decode($url1_info[
'query'])) {
 
 1226     if (isset($url2_info[
'query'])) {
 
 1227         if ($url2_info[
'query'] = html_entity_decode($url2_info[
'query'])) {
 
 1233     foreach ($ignore_params as $param) {
 
 1234         if (isset($url1_params[$param])) {
 
 1235             unset($url1_params[$param]);
 
 1237         if (isset($url2_params[$param])) {
 
 1238             unset($url2_params[$param]);
 
 1247     $diff_count = count(array_diff_assoc($url1_params, $url2_params));
 
 1248     $diff_count += count(array_diff_assoc($url2_params, $url1_params));
 
 1249     if ($diff_count > 0) {
 
 1272     if (!is_array($array)) {
 
 1304 $sort_type = SORT_LOCALE_STRING) {
 
 1308     foreach ($array as $v) {
 
 1309         if (isset($v[$element])) {
 
 1310             $sort[] = strtolower($v[$element]);
 
 1316     return array_multisort(
$sort, $sort_order, $sort_type, $array);
 
 1330     $temp = strtolower(ini_get($ini_get_arg));
 
 1332     if ($temp == 
'1' || $temp == 
'on' || $temp == 
'true') {
 
 1351     $val = ini_get($setting);
 
 1354     $last = strtolower($val[strlen($val) - 1]);
 
 1402     foreach ($singulars as $singular) {
 
 1403         $plural = $singular . 
's';
 
 1405         if (array_key_exists($singular, 
$options)) {
 
 1410                 if (!is_array(
$options[$singular])) {
 
 1449         $uri = 
_elgg_services()->request->server->get(
'REQUEST_URI', 
'CLI');
 
 1451         elgg_log(
"Page {$uri} generated in $time seconds", 
'INFO');
 
 1452     } 
catch (Exception 
$e) {
 
 1453         $message = 
'Error: ' . get_class(
$e) . 
' thrown within the shutdown handler. ';
 
 1454         $message .= 
"Message: '{$e->getMessage()}' in file {$e->getFile()} (line {$e->getLine()})";
 
 1456         error_log(
"Exception trace stack: {$e->getTraceAsString()}");
 
 1460     session_write_close();
 
 1495     if (count($segments) < 2) {
 
 1499     if ($segments[0] === 
'view' || $segments[0] === 
'form') {
 
 1500         if ($segments[0] === 
'view') {
 
 1502             $view = implode(
'/', array_slice($segments, 1));
 
 1505             $view = 
'forms/' . implode(
'/', array_slice($segments, 1));
 
 1509         if (!array_key_exists(
$view, $allowed_views)) {
 
 1510             header(
'HTTP/1.1 403 Forbidden');
 
 1520         if (isset(
$vars[
'guid'])) {
 
 1524         if ($segments[0] === 
'view') {
 
 1526             switch ($segments[1]) {
 
 1528                     header(
"Content-Type: text/javascript;charset=utf-8");
 
 1531                     header(
"Content-Type: text/css;charset=utf-8");
 
 1537             $action = implode(
'/', array_slice($segments, 1));
 
 1558     if (!isset($page[0])) {
 
 1575     header(
"HTTP/1.1 404 Not Found", 
true, 404);
 
 1577     header(
'Expires: ' . gmdate(
'D, d M Y H:i:s \G\M\T', strtotime(
"+1 week")), 
true);
 
 1578     header(
"Pragma: public", 
true);
 
 1579     header(
"Cache-Control: public", 
true);
 
 1603             $content_type = 
'text/javascript';
 
 1607             $content_type = 
'text/css';
 
 1622         $page = implode(
'/', $page);
 
 1623         $regex = 
'|(.+?)\.\w+$|';
 
 1624         if (!preg_match($regex, $page, $matches)) {
 
 1627         $view = 
"$type/{$matches[1]}";
 
 1633         header(
"Content-type: $content_type;charset=utf-8");
 
 1659     $order_by = strtolower($order_by);
 
 1661     if (strpos($order_by, 
' asc') !== 
false) {
 
 1662         $return = str_replace(
' asc', 
' desc', $order_by);
 
 1663     } elseif (strpos($order_by, 
' desc') !== 
false) {
 
 1664         $return = str_replace(
' desc', 
' asc', $order_by);
 
 1667         $return = $order_by . 
' desc';
 
 1686     return $object->enable() ? true : 
false;
 
 1700     return $object->disable() ? true : 
false;
 
 1714     return $object->delete() ? true : 
false;
 
 1739             $metadata_required = array(
 
 1740                 'metadata_owner_guid', 
'metadata_owner_guids',
 
 1741                 'metadata_name', 
'metadata_names',
 
 1742                 'metadata_value', 
'metadata_values' 
 1745             $required = array_merge($required, $metadata_required);
 
 1750             $annotations_required = array(
 
 1751                 'annotation_owner_guid', 
'annotation_owner_guids',
 
 1752                 'annotation_name', 
'annotation_names',
 
 1753                 'annotation_value', 
'annotation_values' 
 1756             $required = array_merge($required, $annotations_required);
 
 1763     foreach ($required as 
$key) {
 
 1788         'class' => 
'elgg-walledgarden-double',
 
 1789         'id' => 
'elgg-walledgarden-login',
 
 1811         'content' => 
elgg_view(
"core/walled_garden/$view"),
 
 1812         'class' => 
'elgg-walledgarden-single hidden',
 
 1813         'id' => str_replace(
'_', 
'-', 
"elgg-walledgarden-$view"),
 
 1842         $CONFIG->site->checkWalledGarden();
 
 1877     set_error_handler(
'_elgg_php_error_handler');
 
 1878     set_exception_handler(
'_elgg_php_exception_handler');
 
 1919         $resource = new \Elgg\Http\WebAppManifestResource(
$site);
 
 1920         header(
'Content-Type: application/json;charset=utf-8');
 
 1921         echo json_encode($resource->get());
 
 1926         $result[
'links'][
'manifest'] = [
 
 1927             'rel' => 
'manifest',
 
 1935     elgg_register_js(
'jquery.ui.autocomplete.html', 
'vendors/jquery/jquery.ui.autocomplete.html.js');
 
 1938         'src' => 
'/vendors/jquery/jquery.ui.autocomplete.html.js',
 
 1939         'deps' => array(
'jquery.ui')
 
 1946     elgg_register_js(
'jquery.imgareaselect', 
'vendors/jquery/jquery.imgareaselect/scripts/jquery.imgareaselect.min.js');
 
 1949     elgg_register_css(
'jquery.imgareaselect', 
'vendors/jquery/jquery.imgareaselect/css/imgareaselect-deprecated.css');
 
 1954     $CONFIG->wordblacklist = array();
 
 1957         foreach (
$list as $l) {
 
 1958             $CONFIG->wordblacklist[] = trim($l);
 
 1977     $value[] = 
$CONFIG->path . 
'engine/tests/ElggTravisInstallTest.php';
 
 1978     $value[] = 
$CONFIG->path . 
'engine/tests/ElggCoreHelpersTest.php';
 
 1979     $value[] = 
$CONFIG->path . 
'engine/tests/ElggCoreRegressionBugsTest.php';
 
 1980     $value[] = 
$CONFIG->path . 
'engine/tests/ElggBatchTest.php';
 
 1992 define(
'ACCESS_DEFAULT', -1);
 
 1993 define(
'ACCESS_PRIVATE', 0);
 
 1994 define(
'ACCESS_LOGGED_IN', 1);
 
 1995 define(
'ACCESS_PUBLIC', 2);
 
 1996 define(
'ACCESS_FRIENDS', -2);
 
 2006 define(
'ELGG_ENTITIES_ANY_VALUE', 
null);
 
 2015 define(
'ELGG_ENTITIES_NO_VALUE', 0);
 
 2024 define(
'REFERRER', -1);
 
 2034 define(
'REFERER', -1);
 
 2037     $events->registerHandler(
'init', 
'system', 
'_elgg_init');
 
 2038     $events->registerHandler(
'boot', 
'system', 
'_elgg_engine_boot', 1);
 
 2039     $hooks->registerHandler(
'unit_test', 
'system', 
'_elgg_api_test');
 
 2041     $events->registerHandler(
'init', 
'system', 
'_elgg_walled_garden_init', 1000);
 
$content
Set robots.txt action.
 
if(! $owner||!($owner instanceof ElggUser)||! $owner->canEdit()) $error
 
generate_action_token($timestamp)
Generate an action token.
 
elgg_is_xhr()
Checks whether the request was requested via ajax.
 
elgg_register_action($action, $filename="", $access='logged_in')
Registers an action.
 
if($guid==elgg_get_logged_in_user_guid()) $name
 
_elgg_load_autoload_cache()
Load cached data into the autoload system.
 
elgg_get_simplecache_url($type, $view)
 
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
 
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
 
_elgg_load_site_config()
Loads configuration related to this site.
 
_elgg_load_application_config()
Loads configuration related to Elgg as an application.
 
elgg_http_remove_url_query_element($url, $element)
Removes an element from a URL's query string.
 
const ELGG_ENTITIES_ANY_VALUE
 
register_error($error)
Display an error on next page load.
 
elgg_trigger_event($event, $object_type, $object=null)
 
_elgg_cacheable_view_page_handler($page, $type)
Serves a JS or CSS view with headers for caching.
 
elgg_http_url_is_identical($url1, $url2, $ignore_params=array('offset', 'limit'))
Test if two URLs are functionally identical.
 
elgg_define_js($name, $config)
Defines a JS lib as an AMD module.
 
_elgg_ajax_page_handler($segments)
Serve individual views for Ajax.
 
elgg_log($message, $level='NOTICE')
Display or log a message.
 
_elgg_php_exception_handler($exception)
Intercepts, logs, and displays uncaught exceptions.
 
elgg_register_css($name, $url, $priority=null)
Register a CSS file for inclusion in the HTML head.
 
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
 
elgg_register_library($name, $location)
Register a PHP file as a library.
 
_elgg_init()
Elgg's main init.
 
_elgg_css_page_handler($page)
Serve CSS.
 
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
 
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
 
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
 
_elgg_sql_reverse_order_by_clause($order_by)
Reverses the ordering in an ORDER BY clause.
 
elgg_load_css($name)
Load a CSS file for this page.
 
_elgg_walled_garden_remove_public_access($hook, $type, $accesses)
Remove public access for walled gardens.
 
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
 
elgg_get_file_list($directory, $exceptions=array(), $list=array(), $extensions=null)
Returns a list of files in $directory.
 
elgg_unregister_js($name)
Unregister a JavaScript file.
 
elgg_get_ini_setting_in_bytes($setting)
Returns a PHP INI setting in bytes.
 
elgg_register_js($name, $url, $location='head', $priority=null)
Register a JavaScript file for inclusion.
 
elgg_trigger_after_event($event, $object_type, $object=null)
Trigger an "After event" indicating a process has finished.
 
elgg_get_loaded_js($location='head')
Get the JavaScript URLs that are loaded.
 
system_message($message)
Display a system message on next page load.
 
elgg_http_build_url(array $parts, $html_encode=true)
Builds a URL from the a parts array like one returned by parse_url().
 
system_messages($message=null, $register="success", $count=false)
Queues a message to be displayed.
 
elgg_get_version($human_readable=false)
Get the current Elgg version information.
 
_elgg_walled_garden_init()
Checks the status of the Walled Garden and forwards to a login page if required.
 
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL's query string.
 
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_register_external_file($type, $name, $url, $location, $priority=500)
Core registration function for external files.
 
_elgg_js_page_handler($page)
Serve javascript pages.
 
is_not_null($string)
Returns true is string is not empty, false, or null.
 
elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback)
Unregister a callback as a plugin hook.
 
elgg_unregister_event_handler($event, $object_type, $callback)
Unregisters a callback for an event.
 
elgg_load_external_file($type, $name)
Load an external resource for use on this page.
 
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
 
_elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars)
Intercepts catchable PHP errors.
 
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_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
 
_elgg_is_valid_options_for_batch_operation($options, $type)
Checks if there are some constraints on the options array for potentially dangerous operations.
 
elgg_trigger_before_event($event, $object_type, $object=null)
Trigger a "Before event" indicating a process is about to begin.
 
ini_get_bool($ini_get_arg)
Return the state of a php.ini setting as a bool.
 
count_messages($register="")
Counts the number of messages, either globally or in a particular register.
 
elgg_get_loaded_external_files($type, $location)
Get external resource descriptors.
 
_elgg_shutdown_hook()
Emits a shutdown:system event upon PHP shutdown, but before database connections are dropped.
 
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
 
_elgg_walled_garden_ajax_handler($page)
Serve walled garden sections.
 
elgg_unregister_external_file($type, $name)
Unregister an external file.
 
_elgg_engine_boot()
Boots the engine.
 
elgg_load_library($name)
Load a PHP library.
 
elgg_dump($value, $to_screen=true)
Logs or displays $value.
 
elgg_batch_enable_callback($object)
Enable objects with an enable() method.
 
elgg_unregister_css($name)
Unregister a CSS file.
 
elgg_batch_delete_callback($object)
Delete objects with a delete() method.
 
elgg_load_js($name)
Load a JavaScript resource on this page.
 
_elgg_walled_garden_index()
Intercepts the index page when Walled Garden mode is enabled.
 
forward($location="", $reason='system')
Forward to $location.
 
elgg_get_loaded_css()
Get the loaded CSS URLs.
 
_elgg_favicon_page_handler($segments)
Handle requests for /favicon.ico.
 
elgg_batch_disable_callback($object)
Disable objects with a disable() method.
 
elgg_add_action_tokens_to_url($url, $html_encode=false)
Adds action tokens to URL.
 
_elgg_api_test($hook, $type, $value, $params)
Adds unit tests for the general API.
 
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
 
global $START_MICROTIME
The time with microseconds when the Elgg engine was started.
 
get_entity($guid)
Loads and returns an entity object from a guid.
 
elgg_parse_str($str)
Parses a string using mb_parse_str() if available.
 
elgg_normalize_site_url($unsafe_url)
From untrusted input, get a site URL safe for forwarding.
 
elgg_format_url($url)
Handles formatting of ampersands in urls.
 
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
 
elgg_ajax_gatekeeper()
Require that the current request be an XHR.
 
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
 
_elgg_session_boot()
Initializes the session and checks for the remember me cookie.
 
elgg_get_site_entity($site_guid=0)
Get an \ElggSite entity (default is current site)
 
if(file_exists($welcome)) $vars
 
if($composer===null) if(!isset($composer->version)) $release
 
clearfix elgg elgg elgg elgg page header
 
elgg_view_layout($layout_name, $vars=array())
Displays a layout with optional parameters.
 
elgg_view_page($title, $body, $page_shell='default', $vars=array())
Assembles and outputs a full page.
 
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype='')
Return a parsed view.
 
elgg_view_form($action, $form_vars=array(), $body_vars=array())
 
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
 
elgg_view_exists($view, $viewtype='', $recurse=true)
Returns whether the specified view exists.
 
elgg_register_external_view($view, $cacheable=false)
Registers a view as being available externally (i.e.