26 use Elgg\Traits\Loggable;
 
   28 use Symfony\Component\Console\Input\ArgvInput;
 
   29 use Symfony\Component\Console\Input\ArrayInput;
 
   30 use Symfony\Component\Console\Input\InputInterface;
 
   31 use Symfony\Component\Console\Output\ConsoleOutput;
 
   32 use Symfony\Component\Console\Output\NullOutput;
 
   33 use Symfony\Component\Console\Output\OutputInterface;
 
   34 use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirect;
 
   35 use Symfony\Component\HttpFoundation\Response;
 
   79     protected $boot_status = [
 
   80         'application_boot_completed' => 
false,
 
   81         'full_boot_completed' => 
false,
 
   82         'plugins_boot_completed' => 
false,
 
   83         'service_boot_completed' => 
false,
 
   92         if (self::$_instance === 
null) {
 
   93             self::$_instance = self::factory();
 
   94             self::setGlobalConfig(self::$_instance);
 
   97         return self::$_instance;
 
  108         self::$_instance = $application;
 
  119         $this->internal_services = $internal_services;
 
  120         $this->public_services = PublicContainer::factory();
 
  138         foreach (self::getEngineLibs() as $file) {
 
  140                 Includer::requireFileOnce(
"$path/$file");
 
  141             } 
catch (\Error $e) {
 
  153         $app = self::getInstance();
 
  165         return function_exists(
'elgg');
 
  214         $this->boot_status[
$type] = $status;
 
  227         return $this->internal_services->publicDb;
 
  239         $CONFIG = $application->internal_services->config;
 
  255     public static function factory(array $spec = []) {
 
  259             'handle_exceptions' => 
true,
 
  260             'handle_shutdown' => 
true,
 
  262             'internal_services' => 
null,
 
  263             'set_start_time' => 
true,
 
  264             'settings_path' => 
'',
 
  268         if ($spec[
'set_start_time']) {
 
  270             if (!isset($GLOBALS[
'START_MICROTIME'])) {
 
  271                 $GLOBALS[
'START_MICROTIME'] = microtime(
true);
 
  275         if ($spec[
'handle_exceptions']) {
 
  282         if (!$spec[
'internal_services']) {
 
  283             if (!$spec[
'config']) {
 
  284                 $spec[
'config'] = Config::factory($spec[
'settings_path']);
 
  287             $spec[
'internal_services'] = InternalContainer::factory([
'config' => $spec[
'config']]);
 
  290         if ($spec[
'request']) {
 
  291             if (!$spec[
'request'] instanceof HttpRequest) {
 
  295             $spec[
'request']->initializeTrustedProxyConfiguration($spec[
'internal_services']->config);
 
  296             $spec[
'request']->correctBaseURL($spec[
'internal_services']->config);
 
  297             $spec[
'internal_services']->set(
'request', $spec[
'request']);
 
  300         $app = 
new self($spec[
'internal_services']);
 
  302         if ($spec[
'handle_shutdown']) {
 
  324         if (self::$_instance) {
 
  325             $app = self::$_instance;
 
  326             $app->internal_services->set(
'request', 
$request);
 
  329                 $app = self::factory([
 
  333                 self::setGlobalConfig($app);
 
  334                 self::setInstance($app);
 
  336                 return self::install();
 
  354         if (self::$_instance) {
 
  355             self::$_instance->internal_services->responseFactory->respond($builder);
 
  357             return self::$_instance->internal_services->responseFactory->getSentResponse();
 
  362             $status = $builder->getStatusCode();
 
  365             if ($builder->isRedirection()) {
 
  371         } 
catch (\Exception $ex) {
 
  372             $response = 
new Response($ex->getMessage(), 500);
 
  375         $response->headers->set(
'Pragma', 
'public');
 
  376         $response->headers->set(
'Cache-Control', 
'no-store, must-revalidate');
 
  377         $response->headers->set(
'Expires', 
'Fri, 05 Feb 1982 00:00:00 -0500');
 
  379         self::getResponseTransport()->send(
$response);
 
  390         return self::route(self::getRequest());
 
  399         $config = $this->internal_services->config;
 
  400         $request = $this->internal_services->request;
 
  409                 $www_root = rtrim(
$request->getSchemeAndHttpHost() . 
$request->getBaseUrl(), 
'/') . 
'/';
 
  411                 $config->wwwroot_cli_server = $www_root;
 
  414             if (str_starts_with(
$request->getElggPath(), 
'/cache/')) {
 
  415                 $config->_disable_session_save = 
true;
 
  417                 self::getResponseTransport()->send(
$response);
 
  422             if (
$request->getElggPath() === 
'/refresh_token') {
 
  423                 $config->_disable_session_save = 
true;
 
  424                 $token = new \Elgg\Controllers\RefreshCsrfToken();
 
  426                 self::getResponseTransport()->send(
$response);
 
  431             if (str_starts_with(
$request->getElggPath(), 
'/serve-file/')) {
 
  432                 $config->_disable_session_save = 
true;
 
  434                 self::getResponseTransport()->send(
$response);
 
  439             if ($this->isCli()) {
 
  440                 $config->_disable_session_save = 
true;
 
  446             $request = $this->internal_services->request;
 
  448             if (!$this->internal_services->router->route(
$request)) {
 
  456                 } 
else if (
$request->getFirstUrlSegment() == 
'action') {
 
  461             $forward_url = (string) $this->internal_services->events->triggerResults(
'forward', $ex->getCode(), [
'exception' => $ex], 
$forward_url);
 
  464                 if ($ex->getMessage()) {
 
  465                     $this->internal_services->system_messages->addErrorMessage($ex->getMessage());
 
  478         return $this->internal_services->responseFactory->getSentResponse();
 
  487         ini_set(
'display_errors', 1);
 
  490             $installer = new \ElggInstaller();
 
  492         } 
catch (\Exception $ex) {
 
  519             $request = self::$_instance->internal_services->request;
 
  520             $signer = self::$_instance->internal_services->urlSigner;
 
  527             if (isset(
$mac) && !$signer->isValid(
$url)) {
 
  531             unset(
$query[UrlSigner::KEY_MAC]);
 
  537                 $url = self::$_instance->internal_services->urlSigner->sign(
$url);
 
  541         } 
catch (\Exception $ex) {
 
  556         $constants = 
Paths::elgg() . 
'engine/lib/constants.php';
 
  557         Includer::requireFileOnce($constants);
 
  559         $conf = 
Paths::elgg() . 
'engine/schema/migrations.php';
 
  567         $app = new \Phinx\Console\PhinxApplication();
 
  569             'configuration' => $conf,
 
  571         $wrapper->getMigrate();
 
  573         return empty($wrapper->getExitCode());
 
  584         $db_config = DbConfig::fromElggConfig(
$config);
 
  586         if ($db_config->isDatabaseSplit()) {
 
  587             $conn = $db_config->getConnectionConfig(DbConfig::WRITE);
 
  589             $conn = $db_config->getConnectionConfig();
 
  594                 'migrations' => 
Paths::elgg() . 
'engine/schema/migrations/',
 
  597                 'default_migration_table' => 
"{$conn['prefix']}migrations",
 
  598                 'default_environment' => 
'prod',
 
  600                     'adapter' => 
'mysql',
 
  601                     'host' => $conn[
'host'],
 
  602                     'port' => $conn[
'port'],
 
  603                     'name' => $conn[
'database'],
 
  604                     'user' => $conn[
'user'],
 
  605                     'pass' => $conn[
'password'],
 
  606                     'charset' => $conn[
'encoding'],
 
  607                     'table_prefix' => $conn[
'prefix'],
 
  620         $request = $this->internal_services->request;
 
  621         $new = $this->internal_services->router->allowRewrite(
$request);
 
  626         $this->internal_services->set(
'request', $new);
 
  651         if (self::$_instance) {
 
  652             return self::$_instance->internal_services->request;
 
  655         return HttpRequest::createFromGlobals();
 
  666             $argv = 
$request->server->get(
'argv') ?: [];
 
  667             return new ArgvInput($argv);
 
  670         return new ArrayInput([]);
 
  680             return new ConsoleOutput();
 
  682             return new NullOutput();
 
  692         $std_out = self::getStdOut();
 
  693         if (is_callable([$std_out, 
'getErrorOutput'])) {
 
  694             return $std_out->getErrorOutput();
 
  707             return new \Elgg\Http\OutputBufferTransport();
 
  710         return new \Elgg\Http\HttpProtocolTransport();
 
  720     private static function getEngineLibs() {
 
  733             'deprecated-6.1.php',
 
  734             'deprecated-6.3.php',
 
  736             'external_files.php',
 
$content
Set robots.txt action.
if(! $entity->delete(true, true)) $forward_url
return[ 'admin/delete_admin_notices'=>['access'=> 'admin'], 'admin/menu/save'=>['access'=> 'admin'], 'admin/plugins/activate'=>['access'=> 'admin'], 'admin/plugins/activate_all'=>['access'=> 'admin'], 'admin/plugins/deactivate'=>['access'=> 'admin'], 'admin/plugins/deactivate_all'=>['access'=> 'admin'], 'admin/plugins/set_priority'=>['access'=> 'admin'], 'admin/security/security_txt'=>['access'=> 'admin'], 'admin/security/settings'=>['access'=> 'admin'], 'admin/security/regenerate_site_secret'=>['access'=> 'admin'], 'admin/site/cache/invalidate'=>['access'=> 'admin'], 'admin/site/flush_cache'=>['access'=> 'admin'], 'admin/site/icons'=>['access'=> 'admin'], 'admin/site/set_maintenance_mode'=>['access'=> 'admin'], 'admin/site/set_robots'=>['access'=> 'admin'], 'admin/site/theme'=>['access'=> 'admin'], 'admin/site/unlock_upgrade'=>['access'=> 'admin'], 'admin/site/settings'=>['access'=> 'admin'], 'admin/upgrade'=>['access'=> 'admin'], 'admin/upgrade/reset'=>['access'=> 'admin'], 'admin/user/ban'=>['access'=> 'admin'], 'admin/user/bulk/ban'=>['access'=> 'admin'], 'admin/user/bulk/delete'=>['access'=> 'admin'], 'admin/user/bulk/unban'=>['access'=> 'admin'], 'admin/user/bulk/validate'=>['access'=> 'admin'], 'admin/user/change_email'=>['access'=> 'admin'], 'admin/user/delete'=>['access'=> 'admin'], 'admin/user/login_as'=>['access'=> 'admin'], 'admin/user/logout_as'=>[], 'admin/user/makeadmin'=>['access'=> 'admin'], 'admin/user/resetpassword'=>['access'=> 'admin'], 'admin/user/removeadmin'=>['access'=> 'admin'], 'admin/user/unban'=>['access'=> 'admin'], 'admin/user/validate'=>['access'=> 'admin'], 'annotation/delete'=>[], 'avatar/upload'=>[], 'comment/save'=>[], 'diagnostics/download'=>['access'=> 'admin'], 'entity/chooserestoredestination'=>[], 'entity/delete'=>[], 'entity/mute'=>[], 'entity/restore'=>[], 'entity/subscribe'=>[], 'entity/trash'=>[], 'entity/unmute'=>[], 'entity/unsubscribe'=>[], 'login'=>['access'=> 'logged_out'], 'logout'=>[], 'notifications/mute'=>['access'=> 'public'], 'plugins/settings/remove'=>['access'=> 'admin'], 'plugins/settings/save'=>['access'=> 'admin'], 'plugins/usersettings/save'=>[], 'register'=>['access'=> 'logged_out', 'middleware'=>[\Elgg\Router\Middleware\RegistrationAllowedGatekeeper::class,],], 'river/delete'=>[], 'settings/notifications'=>[], 'settings/notifications/subscriptions'=>[], 'user/changepassword'=>['access'=> 'public'], 'user/requestnewpassword'=>['access'=> 'public'], 'useradd'=>['access'=> 'admin'], 'usersettings/save'=>[], 'widgets/add'=>[], 'widgets/delete'=>[], 'widgets/move'=>[], 'widgets/save'=>[],]
Handles application boot sequence.
Handle system and PHP errors.
Handler for uncaught exceptions.
Load, boot, and implement a front controller for an Elgg application.
static isCoreLoaded()
Are Elgg's global functions loaded?
bootCore()
Bootstrap the Elgg engine, loads plugins, and calls initial system events.
static upgrade()
Elgg upgrade script.
static index()
Elgg's front controller.
static getStdErr()
Load console error output interface.
static migrate()
Runs database migrations.
static getStdOut()
Load console output interface.
static respond(ResponseBuilder $builder)
Build and send a response.
static getMigrationSettings()
Returns configuration array for database migrations.
static getResponseTransport()
Build a transport for sending responses.
static setInstance(?Application $application=null)
Set the global Application instance.
static factory(array $spec=[])
Create a new application.
static getInstance()
Get the global Application instance.
static getRequest()
Build request object.
run()
Routes the request, booting core if not yet booted.
setBootStatus(string $type, bool $status)
Sets the boot status.
static start()
Start and boot the core.
static $_instance
Reference to the loaded Application.
allowPathRewrite()
Allow plugins to rewrite the path.
static getStdIn()
Load console input interface.
getBootStatus(string $type)
Retrieve the boot status of the application.
getDb()
Get a Database wrapper for performing queries without booting Elgg.
static isCli()
Is application running in CLI.
static install()
Renders a web UI for installing Elgg.
static route(HttpRequest $request)
Route a request.
__construct(InternalContainer $internal_services)
Constructor.
static loadCore()
Define all Elgg global functions and constants, wire up boot events, but don't boot.
static setGlobalConfig(Application $application)
Make the global $CONFIG a reference to this application's config service.
Database configuration service.
A generic parent class for Configuration exceptions.
Thrown when there is a major problem with the installation.
getRedirectUrl()
Get preferred redirect URL.
Thrown when one of the gatekeepers prevents access.
Thrown when page is not accessible.
Exception thrown if an argument is not of the expected type.
Redirect response builder.
Find Elgg and project paths.
Component for creating signed URLs.
Elgg implementation of the Phinx Text Wrapper to ensure the correct OutputInterface.
const ELGG_HTTP_INTERNAL_SERVER_ERROR
const ELGG_HTTP_PERMANENTLY_REDIRECT
const ELGG_HTTP_FORBIDDEN
const REFERRER
Used in calls to forward() to specify the browser should be redirected to the referring page.
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
$config
Advanced site settings, debugging section.
if(! $pagination && $limit !==false &&!empty($items) &&count($items) >=$limit) $base_url
elgg()
Bootstrapping and helper procedural code available for use in Elgg core and plugins.
elgg_http_add_url_query_elements(string $url, array $elements)
Sets elements in a URL's query string.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_get_login_url(array $query=[], string $fragment='')
Returns site's login URL Triggers a 'login_url', 'site' event that can be used by plugins to alter th...
HTTP response builder interface.
HTTP response transport interface.
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
elgg_normalize_site_url(string $unsafe_url)
From untrusted input, get a site URL safe for forwarding.
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
elgg_is_logged_in()
Returns whether or not the user is currently logged in.