80
function test_requirements()
84
if(!(version_compare(PHP_VERSION, '5.3.0') >= 0)) {
85
$errors[] = t("PHP version mismatch. Movim requires PHP 5.3 minimum.")." ".t("Actual version : "). PHP_VERSION .
86
'<div class="guidance">'.t("Update your PHP version or contact your server administrator").'</div>';
88
if(!extension_loaded('curl')) {
89
$errors[] = t("Movim requires the %s extension.", 'PHP Curl') .
90
'<div class="guidance">'.t("Install %s and %s packages", 'php5-curl', 'curl').'</div>';
92
if(!extension_loaded('gd')) {
93
$errors[] = t("Movim requires the %s extension.", 'PHP GD') .
94
'<div class="guidance">'.t("Install the %s package", 'php5-gd').'</div>';
96
if(!extension_loaded('SimpleXML')) {
97
$errors[] = t("Movim requires the %s extension.", 'SimpleXML') .
98
'<div class="guidance">'.t("Install the %s package", 'php5-cli').'</div>';
100
if(!test_dir('../')) {
101
$errors[] = t("Movim's folder must be writable.") .
102
'<div class="guidance">'.t("Enable read and write rights on Movim's root folder").'</div>';
104
/*if(!test_dir('user')) {
105
$errors[] = t("The <em>%s</em> folder must exist and be writable.", 'user');
107
if(!test_dir('log')) {
108
$errors[] = t("The <em>%s</em> folder must exist and be writable.", 'log');
111
// Must have sqlite or mysql (so far...)
112
if(!extension_loaded('mysql') && !class_exists('SQLite3')) {
113
$exts = array('MySQL', 'SQLite');
114
$exts_txt = implode(t("or"), $exts);
115
$errors[] = t("Movim requires the %s extension.", $exts_txt);
119
if(extension_loaded('mysql'))
120
$databases['mysql'] = 'MySQL';
121
if(class_exists('SQLite3'))
122
$databases['sqlite'] = 'SQLite';
124
return (count($errors) > 0)? $errors : false;
127
80
function get_checkbox($name, $if = 'true', $else = 'false')
129
82
return (isset($_POST[$name])? $if : $else);
146
function test_dir($dir){
147
return (file_exists($dir) && is_dir($dir) && is_writable($dir));
153
function create_dirs(){
155
if(!test_dir('../cache') && !@mkdir('../cache')) {
156
echo t("Couldn't create directory '%s'.", 'cache');
159
if(!test_dir('../log') && !@mkdir('../log')) {
160
echo t("Couldn't create directory '%s'.", 'log');
163
if(!test_dir('../config') && !@mkdir('../config')) {
164
echo t("Couldn't create directory '%s'.", 'config');
169
//Returns the content of the post, of the xml, or a placeholder string
170
function get_entry($post){
172
if(isset($_POST[$post])){
173
return $_POST[$post];
174
}elseif(isset($xml->$post)){
181
//Checks if movim already knows the user choice, or it returns a preset for the given form data
182
function get_preset_value($post, $preset){
183
if(get_entry($post) == "n/a" || get_entry($post) == ""){
186
return get_entry($post);
190
function make_config(){
194
'theme' => get_entry('theme'),
195
'defLang' => get_entry('defLang'),
196
// 'boshCookieTTL' => $_POST['boshCookieTTL'],
197
// 'boshCookiePath' => $_POST['boshCookiePath'],
198
// 'boshCookieDomain' => get_checkbox('boshCookieDomain'),
199
// 'boshCookieHTTPS' => get_checkbox('boshCookieHTTPS'),
200
// 'boshCookieHTTPOnly' => get_checkbox('boshCookieHTTPOnly'),
201
'logLevel' => get_entry('logLevel'),
202
//you should be able to do something with new pods, so:
203
'accountCreation' => True,
204
// 'host' => $_POST['host'],
205
// 'domain' => $_POST['domain'],
206
// 'defBoshHost' => $_POST['defBoshHost'],
207
// 'defBoshSuffix' => $_POST['defBoshSuffix'],
208
// 'defBoshPort' => $_POST['defBoshPort'],
209
// 'storageDriver' => $_POST['datajar'],
210
// 'storageConnection' => $_POST['database'],
211
// 'proxyEnabled' => get_checkbox('proxyEnabled'),
212
// 'proxyURL' => $_POST['proxyURL'],
213
// 'proxyPort' => $_POST['proxyPort'],
214
'maxUsers' => get_entry('maxUsers'),
217
if(!@file_put_contents('../config/conf.xml.temp', make_xml($conf))) {
218
echo t("Couldn't create configuration file '%s'.", 'config/conf.xml.temp');
193
226
function make_xml($stuff)
195
228
static $level = 0;
225
function perform_install()
227
// Creating the folders.
228
if(!test_dir('../cache') && !@mkdir('../cache')) {
229
echo t("Couldn't create directory '%s'.", 'cache');
232
if(!test_dir('../log') && !@mkdir('../log')) {
233
echo t("Couldn't create directory '%s'.", 'log');
236
if(!test_dir('../config') && !@mkdir('../config')) {
237
echo t("Couldn't create directory '%s'.", 'config');
241
// Creating the configuration file.
244
'theme' => $_POST['theme'],
245
'defLang' => $_POST['language'],
246
'boshCookieTTL' => $_POST['boshCookieTTL'],
247
'boshCookiePath' => $_POST['boshCookiePath'],
248
'boshCookieDomain' => get_checkbox('boshCookieDomain'),
249
'boshCookieHTTPS' => get_checkbox('boshCookieHTTPS'),
250
'boshCookieHTTPOnly' => get_checkbox('boshCookieHTTPOnly'),
251
'logLevel' => $_POST['verbosity'],
252
'accountCreation' => get_checkbox('accountCreation', 1, 0),
253
'host' => $_POST['host'],
254
'domain' => $_POST['domain'],
255
'defBoshHost' => $_POST['defBoshHost'],
256
'defBoshSuffix' => $_POST['defBoshSuffix'],
257
'defBoshPort' => $_POST['defBoshPort'],
258
'storageDriver' => $_POST['datajar'],
259
'storageConnection' => $_POST['database'],
260
'proxyEnabled' => get_checkbox('proxyEnabled'),
261
'proxyURL' => $_POST['proxyURL'],
262
'proxyPort' => $_POST['proxyPort'],
263
'maxUsers' => $_POST['maxUsers'],
266
if(!@file_put_contents('../config/conf.xml', make_xml($conf))) {
267
echo t("Couldn't create configuration file '%s'.", 'config/conf.xml');
276
if(isset($_POST['install'])) {
277
// We test the Bosh configuration
278
if(!test_bosh($_POST['defBoshHost'], $_POST['defBoshPort'], $_POST['defBoshSuffix'], $_POST['host'])) {
282
// We create the configuration file
285
// We try to connect to the database
287
include('../init.php');
288
} catch (Exception $e) {
289
set_error('bdd', t("Database connection failed with error '%s'", $e->getMessage()));
293
// We create correctly the tables
295
$contact = new Contact();
296
$sdb->create($contact);
298
$conf = new ConfVar();
301
$message = new Message();
302
$sdb->create($message);
304
$presence = new Presence();
305
$sdb->create($presence);
313
$attachment = new Attachment();
314
$sdb->create($attachment);
260
function generate_Tooltip($text, $background=True){
261
$html = 'onmouseover=" elmnt = document.getElementById(\'leftside\'); elmnt.innerHTML=\''.$text.'\'; ';
263
$html .= 'this.style.background = \'#F8F8F8\';" onmouseout="this.style.background=\'white\';"';
273
t("Compatibility Check"),
274
t("General Settings"),
275
t("Database Settings"),
276
t("Bosh Configuration"),
286
if(isset($_POST['back'])){
289
//When the tests do not fail, we just create some directories and succeed to the next step
290
if(isset($_POST['step'])) {
291
switch($_POST['step']){
296
$xml = simplexml_load_file($tmpfile);
301
//Store the basic settings
304
$xml = simplexml_load_file($tmpfile);
309
//Store the DB settings
310
#TODO: Verify the SQL Settings
313
$xml = simplexml_load_file($tmpfile);
318
#TODO: Check if bosh settings are right and whether open Bosh (e.g. connect to random xmpp); when bosh closed warn the user
323
#TODO: Display all Settings again
327
#TOTO: Write Database; Rename conf.xml.part
330
//If the user goes back to the checks:
335
}default: die("Something went wrong");
342
require('template.php');