* required : boolean
* help : string optional
*/
-function check_add(&$checks, $title, $status, $required, $help) {
+function check_add(&$checks, $title, $status, $required, $help, $error_msg = "") {
$checks[] = [
'title' => $title,
'status' => $status,
'required' => $required,
'help' => $help,
+ 'error_msg' => $error_msg,
];
}
function check_htaccess(&$checks) {
$status = true;
$help = "";
+ $error_msg = "";
if (function_exists('curl_init')) {
- $test = Network::fetchUrl(System::baseUrl()."/install/testrewrite");
+ $test = Network::fetchUrlFull(System::baseUrl()."/install/testrewrite");
- if ($test != "ok") {
- $test = Network::fetchUrl(normalise_link(System::baseUrl()."/install/testrewrite"));
+ $url = normalise_link(System::baseUrl()."/install/testrewrite");
+ if ($test['body'] != "ok") {
+ $test = Network::fetchUrlFull($url);
}
- if ($test != "ok") {
+ if ($test['body'] != "ok") {
$status = false;
$help = L10n::t('Url rewrite in .htaccess is not working. Check your server configuration.');
+ $error_msg = [];
+ $error_msg['head'] = L10n::t('Error message from Curl when fetching');
+ $error_msg['url'] = $test['redirect_url'];
+ $error_msg['msg'] = $test['error'];
}
- check_add($checks, L10n::t('Url rewrite is working'), $status, true, $help);
+ check_add($checks, L10n::t('Url rewrite is working'), $status, true, $help, $error_msg);
} else {
// cannot check modrewrite if libcurl is not installed
/// @TODO Maybe issue warning here?
*/
public static function fetchUrl($url, $binary = false, &$redirects = 0, $timeout = 0, $accept_content = null, $cookiejar = 0)
{
- $ret = self::curl(
+ $ret = fetchUrlFull($url, $binary, $redirects, $timeout, $accept_content, $cookiejar);
+
+ return($ret['body']);
+ }
+ public static function fetchUrlFull($url, $binary = false, &$redirects = 0, $timeout = 0, $accept_content = null, $cookiejar = 0)
+ {
+ return self::curl(
$url,
$binary,
$redirects,
'cookiejar'=>$cookiejar
]
);
-
- return($ret['body']);
}
/**
{{/if}}
</td><td>{{if $check.required}}(required){{/if}}</td></tr>
{{if $check.help}}
- <tr><td class="help" colspan="3"><blockquote>{{$check.help}}</blockquote></td></tr>
+ <tr><td class="help" colspan="3">
+ <blockquote>{{$check.help}}</blockquote>
+ {{if $check.error_msg}}
+ <div class="error_header"><b>{{$check.error_msg.head}}</br><a href="{{$check.error_msg.url}}">{{$check.error_msg.url}}</a></b></div>
+ <blockquote>{{$check.error_msg.msg}}</blockquote>
+ {{/if}}
+ </td></tr>
{{/if}}
{{/foreach}}
</table>