Kaynağa Gözat

Change how config directory is checked, no more writable check but error if writing fails.

ohartl 9 yıl önce
ebeveyn
işleme
dfccdcc218
2 değiştirilmiş dosya ile 10 ekleme ve 12 silme
  1. 6 6
      installer/step0.php
  2. 4 6
      installer/step7.php

+ 6 - 6
installer/step0.php

@@ -21,10 +21,10 @@ if(function_exists('mysqli_connect')){
 if(session_status() != PHP_SESSION_DISABLED){
 	$requirements[] = 'php_session_enabled';
 }
-if(file_exists('config') && is_writable('config') && !file_exists('config/config.php')){
-	$requirements[] = 'config_path_writable';
+if(file_exists('config') && is_dir('config')){
+	$requirements[] = 'config_directory';
 }
-if(file_exists('config') && file_exists('config/config.php.example')){
+if(file_exists('config/config.php.example')){
 	$requirements[] = 'config_example';
 }
 
@@ -81,10 +81,10 @@ if(isset($_GET['go']) && $_GET['go'] == 'next'){
 
 <strong>Directories and files</strong>
 <ul>
-<?php if(in_array('config_path_writable', $requirements)): ?>
-	<li class="text-success">"config/": <strong>writable &#x2713;</strong></li>
+<?php if(in_array('config_directory', $requirements)): ?>
+	<li class="text-success">"config/": <strong>exists &#x2713;</strong></li>
 <?php else: ?>
-	<li class="text-fail">"config/": <strong>not writable &#x274c;</strong></li>
+	<li class="text-fail">"config/": <strong>is missing &#x274c;</strong></li>
 <?php endif; ?>
 <?php if(in_array('config_example', $requirements)): ?>
 	<li class="text-success">"config/config.php.example": <strong>exists &#x2713;</strong></li>

+ 4 - 6
installer/step7.php

@@ -35,16 +35,14 @@ if(isset($_GET['go'])){
 					throw new Exception('The file "'.$configPath.'"" already exists, if you\'ve already written the config manually then complete manually.');
 				}
 
-				if(!file_exists(dirname($configPath))){
+				if(!file_exists(dirname($configPath)) || !is_dir(dirname($configPath))){
 					throw new Exception('The directory "'.dirname($configPath).'"" is missing.');
 				}
 
-				if(!is_writable(dirname($configPath))){
-					throw new Exception('The directory "'.dirname($configPath).'"" isn\'t writable.');
-				}
-
 				// Write config
-				file_put_contents($configPath, $configString);
+				if(file_put_contents($configPath, $configString) === false){
+					throw new Exception('Couldn\'t automatically write config to "'.$configPath.'", please write the config on your own.');
+				}
 
 				$_SESSION['installer']['finished'] = true;
 			}