27 $this->webserver =
'unknown';
43 if ($this->rewriteTestPassed ===
false) {
44 if ($this->webserver ==
'apache' || $this->webserver ==
'unknown') {
60 if (empty($_SERVER[
'SERVER_SOFTWARE'])) {
64 $serverString = strtolower($_SERVER[
'SERVER_SOFTWARE']);
65 $possibleServers = [
'apache',
'nginx',
'lighttpd',
'iis'];
66 foreach ($possibleServers as $server) {
67 if (
elgg_strpos($serverString, $server) !==
false) {
84 $elements = parse_url(
$url);
85 if (!is_array($elements) || !isset($elements[
'path'])) {
89 $subdir = trim(dirname($elements[
'path']),
'/');
105 $this->serverSupportsRemoteRead = ($this->fetchUrl(
$url) ===
Request::REWRITE_TEST_OUTPUT);
106 return $this->serverSupportsRemoteRead;
125 private function fetchUrl(
string $url): string {
128 if (ini_get(
'allow_url_fopen')) {
129 $ctx = stream_context_create([
131 'follow_location' => 0,
138 if (!
$response && function_exists(
'curl_init')) {
140 curl_setopt($ch, CURLOPT_URL,
$url);
141 curl_setopt($ch, CURLOPT_RETURNTRANSFER,
true);
142 curl_setopt($ch, CURLOPT_TIMEOUT, 5);
143 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
false);
161 if (file_exists($htaccess)) {
163 $data = file_get_contents($htaccess);
166 $this->htaccessIssue =
'read_permission';
171 $this->htaccessIssue =
'non_elgg_htaccess';
176 if (
elgg_strpos(
$data,
'RewriteRule ^rewrite.php$ install.php') ===
false) {
177 $this->htaccessIssue =
'old_elgg_htaccess';
185 $this->htaccessIssue =
'write_permission';
192 $this->htaccessIssue =
'cannot_copy';
197 if (!$this->runRewriteTest(
$url)) {
199 $subdir = $this->guessSubdirectory(
$url);
200 if (!empty($subdir)) {
201 $contents = file_get_contents($htaccess);
202 $contents = preg_replace(
"/#RewriteBase \/(\r?\n)/",
"RewriteBase $subdir\$1",
$contents);
220 if ($this->rewriteTestPassed) {
222 'severity' =>
'success',
223 'message' =>
_elgg_services()->translator->translate(
'install:check:rewrite:success'),
227 if ($this->serverSupportsRemoteRead ===
false) {
228 $msg =
_elgg_services()->translator->translate(
'install:warning:rewrite:unknown', [
$url]);
229 $msg .=
elgg_view(
'install/js_rewrite_check', [
'url' =>
$url]);
232 'severity' =>
'warning',
237 if ($this->webserver ===
'apache') {
238 $msg =
_elgg_services()->translator->translate(
'install:error:rewrite:apache');
239 $msg .= PHP_EOL . PHP_EOL;
240 if (!isset($this->htaccessIssue)) {
241 $msg .=
_elgg_services()->translator->translate(
'install:error:rewrite:allowoverride');
242 $msg .=
elgg_view(
'install/js_rewrite_check', [
'url' =>
$url]);
245 'severity' =>
'warning',
250 $msg .=
_elgg_services()->translator->translate(
"install:error:rewrite:htaccess:{$this->htaccessIssue}");
252 'severity' =>
'warning',
257 if ($this->webserver !==
'unknown') {
258 $msg =
_elgg_services()->translator->translate(
"install:error:rewrite:{$this->webserver}");
259 $msg .= PHP_EOL . PHP_EOL;
260 $msg .=
_elgg_services()->translator->translate(
'install:error:rewrite:altserver');
262 'severity' =>
'warning',
268 'severity' =>
'warning',
269 'message' =>
_elgg_services()->translator->translate(
'install:error:rewrite:unknown'),
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'=>[],]
if(! $entity instanceof \ElggUser) $data
Find Elgg and project paths.
Test if URL rewriting is working.
guessWebServer()
Guess the web server from $_SERVER['SERVER_SOFTWARE'].
runLocalhostAccessTest()
Check whether the site homepage can be fetched via curl.
bool $serverSupportsRemoteRead
createHtaccess(string $url)
Create Elgg's .htaccess file or confirm that it exists.
__construct()
Set the webserver as unknown.
guessSubdirectory(string $url)
Guess if url contains subdirectory or not.
run(string $url)
Run the rewrite test and return a status array.
runRewriteTest(string $url)
Hit the rewrite test URL to determine if the rewrite rules are working.
returnStatus(string $url)
Create the status array required by the ElggInstaller.
Delegates requests to controllers based on the registered configuration.
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
elgg()
Bootstrapping and helper procedural code available for use in Elgg core and plugins.
_elgg_services()
Get the global service provider.
elgg_view(string $view, array $vars=[], string $viewtype='')
Return a parsed view.
elgg_strpos()
Wrapper function for mb_strpos().
if(!empty($title) &&!empty($icon_name)) if(!empty($title)) if(!empty($menu)) if(!empty($header)) if(!empty($body)) $contents
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.
$CONFIG wwwroot
The installation root URL of the site.