]> git.agnieray.net Git - galette.git/blob - galette/install/steps/check.php
63a52de83a85b7b2dec6d1b697aeb1b4697d8524
[galette.git] / galette / install / steps / check.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Galette installation, check step
7 *
8 * PHP version 5
9 *
10 * Copyright © 2013-2014 The Galette Team
11 *
12 * This file is part of Galette (http://galette.tuxfamily.org).
13 *
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
26 *
27 * @category Core
28 * @package Galette
29 *
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2013-2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @version SVN: $Id$
34 * @link http://galette.tuxfamily.org
35 * @since Available since 0.8 - 2013-01-09
36 */
37 ?>
38 <h2><?php echo _T("Welcome to the Galette Install!"); ?></h2>
39 <?php
40 $php_ok = true;
41 $class = 'install-';
42 $php_modules_class = '';
43 $files_perms_class = '';
44
45 // check required PHP version...
46 if (version_compare(PHP_VERSION, GALETTE_PHP_MIN, '<')) {
47 $php_ok = false;
48 }
49
50 // check date settings
51 $date_ok = false;
52 if (!version_compare(PHP_VERSION, '5.2.0', '<')) {
53 try {
54 $test_date = new DateTime();
55 $date_ok = true;
56 } catch (Exception $e) {
57 //do nothing
58 }
59 }
60
61 // check PHP modules
62 $cm = new Galette\Core\CheckModules();
63 $modules_ok = $cm->isValid();
64
65 // check file permissions
66 $perms_ok = true;
67 $files_need_rw = array(
68 _T("Compilation") => GALETTE_COMPILE_DIR,
69 _T("Photos") => GALETTE_PHOTOS_PATH,
70 _T("Cache") => GALETTE_CACHE_DIR,
71 _T("Temporary images") => GALETTE_TEMPIMAGES_PATH,
72 _T("Configuration") => GALETTE_CONFIG_PATH,
73 _T("Exports") => GALETTE_EXPORTS_PATH,
74 _T("Imports") => GALETTE_IMPORTS_PATH,
75 _T("Logs") => GALETTE_LOGS_PATH,
76 _T("Attachments") => GALETTE_ATTACHMENTS_PATH,
77 _T("Files") => GALETTE_FILES_PATH
78 );
79
80 $files_perms_class = $class . 'ok';
81
82 foreach ($files_need_rw as $label=>$file) {
83 $writable = is_writable($file);
84 if (!$writable) {
85 $perms_ok = false;
86 }
87 }
88
89 if ($perms_ok && $modules_ok && $php_ok && $date_ok) {
90 echo '<p id="infobox">' . _T("Galette requirements are met :)") . '</p>';
91 }
92
93 if (!$date_ok) {
94 echo '<p class="error">' . _T("Your PHP date settings are not correct. Maybe you've missed the timezone settings that is mandatory since PHP 5.3?") . '</p>';
95 }
96 ?>
97 <ul class="leaders">
98 <li>
99 <span><?php echo _T("PHP version"); ?> (<?php echo PHP_VERSION . ' >= ' . GALETTE_PHP_MIN; ?>)</span>
100 <span><?php echo $install->getValidationImage($php_ok == true); ?></span>
101 </li>
102 <li>
103 <span><?php echo _T("Date settings"); ?></span>
104 <span><?php echo $install->getValidationImage($date_ok == true); ?></span>
105 </li>
106 </ul>
107
108 <h3><?php echo _T("PHP Modules"); ?></h3>
109 <?php
110 if (!$modules_ok) {
111 echo '<p class="error">' . _T("Some PHP modules are missing. Please install them or contact your support.<br/>More information on required modules may be found in the documentation.") . '</p>';
112 }
113 ?>
114 <ul class="leaders">
115 <?php echo $cm->toHtml(); ?>
116 </ul>
117
118 <h3><?php echo _T("Files permissions"); ?></h3>
119 <ul class="leaders">
120 <?php
121 foreach ($files_need_rw as $label=>$file) {
122 $writable = is_writable($file);
123 ?>
124 <li>
125 <span><?php echo $label ?></span>
126 <span><?php echo $install->getValidationImage(is_writable($file)); ?></span>
127 </li>
128 <?php
129 }
130 ?>
131 </ul>
132 <?php
133 if (!$perms_ok) {
134 ?>
135 <article id="files_perms" class="<?php echo $files_perms_class; ?>">
136 <div>
137 <h4 class="error"><?php echo _T("Files permissions are not OK!"); ?></h4>
138 <p><?php
139 if ($install->isInstall()) {
140 echo _T("To work as excpected, Galette needs write permission on files listed above.");
141 } else if ($install->isUpgrade()) {
142 echo _T("In order to be updated, Galette needs write permission on files listed above.");
143 }
144 ?></p>
145 <p><?php echo _T("Under UNIX/Linux, you can give the permissions using those commands"); ?><br />
146 <code>chown <em><?php echo _T("apache_user"); ?></em> <em><?php echo _T("file_name"); ?></em><br />chmod 700 <em><?php echo _T("directory_name"); ?></em></code>
147 </p>
148 <p><?php echo _T("Under Windows, check these directories are not in Read-Only mode in their property panel."); ?></p>
149 </div>
150 </article>
151 <?php
152 }
153
154 if (!$perms_ok || !$modules_ok || !$php_ok || !$date_ok) {
155 ?>
156 <form action="installer.php" method="post">
157 <p id="btn_box">
158 <input type="submit" id="retry_btn" value="<?php echo _T("Retry"); ?>"/>
159 </p>
160 </form>
161 <?php
162 } else {
163 ?>
164 <form action="installer.php" method="POST">
165 <p id="btn_box">
166 <input id="next_btn" type="submit" value="<?php echo _T("Next step"); ?>"/>
167 <input type="hidden" name="install_permsok" value="1"/>
168 </p>
169 </form>
170 <?php
171 }