Skip to content

Commit

Permalink
Install process, add htaccess allow check
Browse files Browse the repository at this point in the history
  • Loading branch information
felixgilles committed Jan 23, 2014
1 parent 12eb2a0 commit 6aef2cc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .htaccess.shared-hosting
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Options +FollowSymLinks -Indexes
# Replace novius-os-install-dir by the real Novius OS installed directory
ErrorDocument 404 /novius-os-install-dir/public/htdocs/novius-os/404.php

SetEnv HTACCESSALLOW true

<IfModule mod_version.c>
<IfVersion >= 2.4>
DirectoryIndex disabled
Expand Down
23 changes: 17 additions & 6 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,23 @@

$htaccess = str_replace('novius-os-install-dir/', str_replace('\\', '/', $nos_dir), $content);

$file = $document_root.$nos_dir.'.htaccess';
if (is_writable($document_root.$nos_dir)) {
$handle = fopen($file, 'w');
if (file_exists($document_root.$nos_dir.'.htaccess')) {
$file = $document_root.$nos_dir.'.htaccess';
$handle = fopen($file, 'r');
if ($handle) {
$htaccess_save = fwrite($handle, $htaccess);
$content = fread($handle, filesize($file));
fclose($handle);

$htaccess_save = trim($htaccess) == trim($content);
}
} else {
$file = $document_root.$nos_dir.'.htaccess';
if (is_writable($document_root.$nos_dir)) {
$handle = fopen($file, 'w');
if ($handle) {
$htaccess_save = fwrite($handle, $htaccess);
fclose($handle);
}
}
}
}
Expand Down Expand Up @@ -198,13 +209,13 @@

echo '<p>Create a file name <code>.htaccess</code> and write this code in it :</p>';
echo '<pre><code style="width:800px;">', htmlspecialchars($htaccess), '</code></pre>';
echo '<p>Upload this file in the Novius OS\'s directory of your hosting server (<code>', $nos_dir, '</code>).</p>';
echo '<p>Upload this file in the Novius OS\'s directory of your hosting server (<code>', $nos_dir, '</code>, beside CHANGELOG.md file).</p>';
}

if (!$htaccess_move) {

echo '<h2>Rename invalid .htaccess file in the Novius OS\'s public directory</h2>';
echo '<p>Rename <code>', $nos_dir, 'public'.DIRECTORY_SEPARATOR.'.htaccess</code> file by <code>', $nos_dir, 'public'.DIRECTORY_SEPARATOR.'.htaccess.old</code>.</p>';
echo '<p>Rename <code>', 'public'.DIRECTORY_SEPARATOR.'.htaccess</code> file by <code>', 'public'.DIRECTORY_SEPARATOR.'.htaccess.old</code>.</p>';
}
?>
<p><a href="install.php"><button>It's done, refresh this page</button></a></p>
Expand Down
14 changes: 12 additions & 2 deletions public/htdocs/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,17 @@ public static function recap($command_line = true)
$session_save_path = \Arr::get(\Config::load('session', true), 'file.path');

Test::register(array(
'directive.htaccess_allow' => array(
'title' => 'Your server not allow .htaccess file',
'passed' => empty($base_url) || !empty($_SERVER['HTACCESSALLOW']),
'description' => 'If your server uses Apache, check that configuration have '.
'<code>AllowOverride All</code> for the Novius-OS directory.',
),
'directive.rewrite_module' => array(
'title' => 'Server ‘rewrite_module’ must be enabled',
'passed' => $base_url == '',
'description' => 'Enable ‘rewrite_module’ in your server configuration (probably Apache).',
'run_only_if' => empty($base_url) || !empty($_SERVER['HTACCESSALLOW']),
),
'requirements.gd_is_installed' => array(
'title' => 'GD is required',
Expand All @@ -456,13 +463,15 @@ public static function recap($command_line = true)
'title' => 'PHP configuration directive ‘short_open_tag’ must be on',
'passed' => ini_get('short_open_tag') != false,
'description' => 'Set <code>short_open_tag = On</code> in <code>'.php_ini_loaded_file().
'</code>.<br /><em>Why? Because <a href="http://php.net/manual/en/ini.core.php#ini.short-open-tag">since PHP 5.4 short_open_tag is always on</a>.</em>',
'</code>.<br /><em>Why? Because <a href="http://php.net/manual/en/ini.core.php#ini.short-open-tag">'.
'since PHP 5.4 short_open_tag is always on</a>.</em>',
'run_only_if' => version_compare(PHP_VERSION, '5.4.0', '<'),
),
'directive.magic_quotes_gpc' => array(
'title' => 'PHP configuration directive ‘magic_quotes_gpc’ must be off',
'passed' => ini_get('magic_quotes_gpc') == false,
'description' => 'Set <code>magic_quotes_gpc = Off</code> in <code>'.php_ini_loaded_file().'</code>.<br /><em>Why? Because <a href="http://php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc">magic_quotes_gpc is deprecated in PHP 5.3 and removed in PHP 5.4</a>.</em>',
'description' => 'Set <code>magic_quotes_gpc = Off</code> in <code>'.php_ini_loaded_file().'</code>.'.
'<br /><em>Why? Because <a href="http://php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc">magic_quotes_gpc is deprecated in PHP 5.3 and removed in PHP 5.4</a>.</em>',
'run_only_if' => version_compare(PHP_VERSION, '5.4.0', '<'),
),
'folder.config.writeable' => array(
Expand Down Expand Up @@ -669,6 +678,7 @@ public static function recap($command_line = true)

Test::reset();

Test::run('directive.htaccess_allow');
Test::run('directive.rewrite_module');

Test::separator();
Expand Down

0 comments on commit 6aef2cc

Please sign in to comment.