20 $this->webserver =
'unknown';
37 if ($this->rewriteTestPassed == FALSE) {
38 if ($this->webserver ==
'apache' || $this->webserver ==
'unknown') {
54 $serverString = strtolower($_SERVER[
'SERVER_SOFTWARE']);
55 $possibleServers = array(
'apache',
'nginx',
'lighttpd',
'iis');
56 foreach ($possibleServers as $server) {
57 if (strpos($serverString, $server) !== FALSE) {
74 if (!$elements || !isset($elements[
'path'])) {
77 $subdir = trim(dirname($elements[
'path']),
'/');
94 $this->serverSupportsRemoteRead =
true;
96 if (ini_get(
'allow_url_fopen')) {
97 $ctx = stream_context_create(array(
99 'follow_location' => 0,
103 $response = file_get_contents(
$url, null, $ctx);
104 } elseif (function_exists(
'curl_init')) {
107 curl_setopt($ch, CURLOPT_URL,
$url);
108 curl_setopt($ch, CURLOPT_RETURNTRANSFER,
true);
109 curl_setopt($ch, CURLOPT_TIMEOUT, 5);
110 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
false);
111 $response = curl_exec($ch);
117 if ($response !==
'success') {
118 $this->serverSupportsRemoteRead =
false;
127 if (ini_get(
'allow_url_fopen')) {
128 $ctx = stream_context_create(array(
130 'follow_location' => 0,
134 $response = file_get_contents(
$url, null, $ctx);
135 } elseif (function_exists(
'curl_init')) {
138 curl_setopt($ch, CURLOPT_URL,
$url);
139 curl_setopt($ch, CURLOPT_TIMEOUT, 5);
140 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
false);
141 $response = curl_exec($ch);
145 return $response !==
false;
161 if (
$data === FALSE) {
163 $this->htaccessIssue =
'read_permission';
166 if (strpos(
$data,
'Elgg') === FALSE) {
167 $this->htaccessIssue =
'non_elgg_htaccess';
171 if (strpos(
$data,
'RewriteRule ^rewrite.php$ install.php') == FALSE) {
172 $this->htaccessIssue =
'old_elgg_htaccess';
179 if (!is_writable(
$path)) {
180 $this->htaccessIssue =
'write_permission';
187 $this->htaccessIssue =
'cannot_copy';
196 $contents = preg_replace(
"/#RewriteBase \/(\r?\n)/",
"RewriteBase $subdir\$1",
$contents);
214 if ($this->rewriteTestPassed) {
216 'severity' =>
'pass',
217 'message' =>
elgg_echo(
'install:check:rewrite:success'),
221 if ($this->serverSupportsRemoteRead == FALSE) {
222 $msg =
elgg_echo(
'install:warning:rewrite:unknown', array(
$url));
223 $msg .=
elgg_view(
'install/js_rewrite_check', array(
'url' =>
$url));
226 'severity' =>
'warning',
231 if ($this->webserver ==
'apache') {
232 $serverString =
elgg_echo(
'install:error:rewrite:apache');
233 $msg =
"$serverString\n\n";
234 if (!isset($this->htaccessIssue)) {
235 $msg .=
elgg_echo(
'install:error:rewrite:allowoverride');
236 $msg .=
elgg_view(
'install/js_rewrite_check', array(
'url' =>
$url));
239 'severity' =>
'failure',
243 $msg .=
elgg_echo(
"install:error:rewrite:htaccess:{$this->htaccessIssue}");
245 'severity' =>
'failure',
250 if ($this->webserver !=
'unknown') {
251 $serverString =
elgg_echo(
"install:error:rewrite:{$this->webserver}");
252 $msg =
"$serverString\n\n";
253 $msg .=
elgg_echo(
"install:error:rewrite:altserver");
255 'severity' =>
'failure',
261 'severity' =>
'failure',
262 'message' =>
elgg_echo(
'install:error:rewrite:unknown'),
$serverSupportsRemoteRead
elgg parse_url
Parse a URL into its parts.
run($url, $path)
Run the rewrite test and return a status array.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
returnStatus($url)
Create the status array required by the ElggInstaller.
guessSubdirectory($url)
Guess if url contains subdirectory or not.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
createHtaccess($url, $path)
Create Elgg's .htaccess file or confirm that it exists.
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a copy
__construct()
Set the webserver as unknown.
static guessWebServer()
Guess the web server from $_SERVER['SERVER_SOFTWARE'].
runRewriteTest($url)
Hit the rewrite test URL to determine if the rewrite rules are working.