From ed17b2e344779177bddb9983d0889dd64657b411 Mon Sep 17 00:00:00 2001 From: markseu Date: Fri, 17 Nov 2017 11:51:09 +0100 Subject: [PATCH] Check web server rewrite --- system/plugins/update.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/system/plugins/update.php b/system/plugins/update.php index f451837..ad16a9c 100644 --- a/system/plugins/update.php +++ b/system/plugins/update.php @@ -5,7 +5,7 @@ class YellowUpdate { - const VERSION = "0.7.6"; + const VERSION = "0.7.7"; var $yellow; //access to API var $updates; //number of updates @@ -596,7 +596,11 @@ class YellowUpdate $status = trim($_REQUEST["status"]); if($status=="install") { - $status = "ok"; + $status = $this->checkServerRewrite($scheme, $address, $base, $location, $fileName) ? "ok" : "error"; + if($status=="error") $this->yellow->page->error(500, "Rewrite module not working on this server!"); + } + if($status=="ok") + { if(!empty($email) && !empty($password) && $this->yellow->plugins->isExisting("edit")) { $fileNameUser = $this->yellow->config->get("configDir").$this->yellow->config->get("editUserFile"); @@ -642,6 +646,27 @@ class YellowUpdate return $statusCode; } + // Check web server rewrite + function checkServerRewrite($scheme, $address, $base, $location, $fileName) + { + $ok = true; + if(extension_loaded("curl")) + { + $curlHandle = curl_init(); + $location = $this->yellow->config->get("assetLocation").$this->yellow->page->get("theme").".css"; + $url = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location); + curl_setopt($curlHandle, CURLOPT_URL, $url); + curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowCore/".YellowCore::VERSION).")"; + curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30); + $rawData = curl_exec($curlHandle); + $statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE); + curl_close($curlHandle); + if(empty($rawData) || $statusCode!=200) $ok = false; + } + return $ok; + } + // Return raw data for installation page function getRawDataInstallation() {