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;
132 if (ini_get(
'allow_url_fopen')) {
133 $ctx = stream_context_create(array(
135 'follow_location' => 0,
139 $response = file_get_contents(
$url, null, $ctx);
140 } elseif (function_exists(
'curl_init')) {
143 curl_setopt($ch, CURLOPT_URL,
$url);
144 curl_setopt($ch, CURLOPT_TIMEOUT, 5);
145 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
false);
146 $response = curl_exec($ch);
150 return $response !==
false;
166 if (
$data === FALSE) {
168 $this->htaccessIssue =
'read_permission';
171 if (strpos(
$data,
'Elgg') === FALSE) {
172 $this->htaccessIssue =
'non_elgg_htaccess';
176 if (strpos(
$data,
'RewriteRule ^rewrite.php$ install.php') == FALSE) {
177 $this->htaccessIssue =
'old_elgg_htaccess';
184 if (!is_writable(
$path)) {
185 $this->htaccessIssue =
'write_permission';
192 $this->htaccessIssue =
'cannot_copy';
201 $contents = preg_replace(
"/#RewriteBase \/(\r?\n)/",
"RewriteBase $subdir\$1",
$contents);
219 if ($this->rewriteTestPassed) {
221 'severity' =>
'pass',
222 'message' =>
_elgg_services()->translator->translate(
'install:check:rewrite:success'),
226 if ($this->serverSupportsRemoteRead == FALSE) {
227 $msg =
_elgg_services()->translator->translate(
'install:warning:rewrite:unknown', array(
$url));
228 $msg .=
elgg_view(
'install/js_rewrite_check', array(
'url' =>
$url));
231 'severity' =>
'warning',
236 if ($this->webserver ==
'apache') {
237 $serverString =
_elgg_services()->translator->translate(
'install:error:rewrite:apache');
238 $msg =
"$serverString\n\n";
239 if (!isset($this->htaccessIssue)) {
240 $msg .=
_elgg_services()->translator->translate(
'install:error:rewrite:allowoverride');
241 $msg .=
elgg_view(
'install/js_rewrite_check', array(
'url' =>
$url));
244 'severity' =>
'failure',
248 $msg .=
_elgg_services()->translator->translate(
"install:error:rewrite:htaccess:{$this->htaccessIssue}");
250 'severity' =>
'failure',
255 if ($this->webserver !=
'unknown') {
256 $serverString =
_elgg_services()->translator->translate(
"install:error:rewrite:{$this->webserver}");
257 $msg =
"$serverString\n\n";
258 $msg .=
_elgg_services()->translator->translate(
"install:error:rewrite:altserver");
260 'severity' =>
'failure',
266 'severity' =>
'failure',
267 'message' =>
_elgg_services()->translator->translate(
'install:error:rewrite:unknown'),
runLocalhostAccessTest()
Check whether the site homepage can be fetched via curl.
$serverSupportsRemoteRead
if(!$autoload_available) _elgg_services()
elgg parse_url
Parse a URL into its parts.
run($url, $path)
Run the rewrite test and return a status array.
returnStatus($url)
Create the status array required by the ElggInstaller.
guessSubdirectory($url)
Guess if url contains subdirectory or not.
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.