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']),
'/');
93 $this->serverSupportsRemoteRead = ($this->fetchUrl(
$url) ===
'success');
104 return (
bool)$this->fetchUrl(
$url);
114 private function fetchUrl(
$url) {
117 if (ini_get(
'allow_url_fopen')) {
118 $ctx = stream_context_create(array(
120 'follow_location' => 0,
124 $response = @file_get_contents(
$url, null, $ctx);
127 if (!$response && function_exists(
'curl_init')) {
129 curl_setopt($ch, CURLOPT_URL,
$url);
130 curl_setopt($ch, CURLOPT_RETURNTRANSFER,
true);
131 curl_setopt($ch, CURLOPT_TIMEOUT, 5);
132 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
false);
133 $response = curl_exec($ch);
137 return (
string)$response;
153 if (
$data === FALSE) {
155 $this->htaccessIssue =
'read_permission';
158 if (strpos(
$data,
'Elgg') === FALSE) {
159 $this->htaccessIssue =
'non_elgg_htaccess';
163 if (strpos(
$data,
'RewriteRule ^rewrite.php$ install.php') == FALSE) {
164 $this->htaccessIssue =
'old_elgg_htaccess';
171 if (!is_writable(
$path)) {
172 $this->htaccessIssue =
'write_permission';
179 $this->htaccessIssue =
'cannot_copy';
188 $contents = preg_replace(
"/#RewriteBase \/(\r?\n)/",
"RewriteBase $subdir\$1",
$contents);
206 if ($this->rewriteTestPassed) {
208 'severity' =>
'pass',
209 'message' =>
_elgg_services()->translator->translate(
'install:check:rewrite:success'),
213 if ($this->serverSupportsRemoteRead == FALSE) {
214 $msg =
_elgg_services()->translator->translate(
'install:warning:rewrite:unknown', array(
$url));
215 $msg .=
elgg_view(
'install/js_rewrite_check', array(
'url' =>
$url));
218 'severity' =>
'warning',
223 if ($this->webserver ==
'apache') {
224 $serverString =
_elgg_services()->translator->translate(
'install:error:rewrite:apache');
225 $msg =
"$serverString\n\n";
226 if (!isset($this->htaccessIssue)) {
227 $msg .=
_elgg_services()->translator->translate(
'install:error:rewrite:allowoverride');
228 $msg .=
elgg_view(
'install/js_rewrite_check', array(
'url' =>
$url));
231 'severity' =>
'failure',
235 $msg .=
_elgg_services()->translator->translate(
"install:error:rewrite:htaccess:{$this->htaccessIssue}");
237 'severity' =>
'failure',
242 if ($this->webserver !=
'unknown') {
243 $serverString =
_elgg_services()->translator->translate(
"install:error:rewrite:{$this->webserver}");
244 $msg =
"$serverString\n\n";
245 $msg .=
_elgg_services()->translator->translate(
"install:error:rewrite:altserver");
247 'severity' =>
'failure',
253 'severity' =>
'failure',
254 'message' =>
_elgg_services()->translator->translate(
'install:error:rewrite:unknown'),
runLocalhostAccessTest()
Check whether the site homepage can be fetched via curl.
$serverSupportsRemoteRead
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.