Browse Source

Greatly improved installer with more detailed error reports and memory of input elements.

pull/5/head
Etenil 14 years ago
parent
commit
9f188e7084
  1. 2
      index.php
  2. 307
      install/index.php
  3. 190
      install/part1.php
  4. 181
      install/part2.php

2
index.php

@ -46,7 +46,7 @@ ini_set('error_reporting', E_ALL ^ E_DEPRECATED ^ E_NOTICE);
// If the configuration doesn't exist, run the installer.
if(!file_exists("config/conf.xml")) {
header('Location:install/part1.php'); exit;
header('Location: install/'); exit;
} else {
// Run
require('init.php');

307
install/index.php

@ -0,0 +1,307 @@
<?php
require_once('../system/Lang/i18n.php');
require_once('../system/Lang/languages.php');
function get_mysql_port() {
$port = ini_get('mysql.default_port');
if($port == "")
$port = ini_get('mysqli.default_port');
if($port == "")
$port = 3306;
return $port;
}
$err = array();
function set_error($error_name, $error_message)
{
global $err;
$err[$error_name] = $error_message;
}
function err($error_name)
{
global $err;
if(isset($err[$error_name])) {
return $err[$error_name];
} else {
return false;
}
}
function has_errors()
{
global $err;
return count($err);
}
function test_dir($dir)
{
return (file_exists($dir) && is_dir($dir) && is_writable($dir));
}
function list_themes()
{
$dir = opendir('../themes');
$themes = array();
while($theme = readdir($dir)) {
if(preg_match('/^\.+$/', $theme)
|| !is_dir('../themes/'.$theme)) {
continue;
}
$themes[$theme] = $theme;
}
return $themes;
}
function list_lang()
{
$dir = opendir('../i18n');
$langs = array('en' => 'English');
$languages = get_lang_list();
while($lang = readdir($dir)) {
if(!preg_match('/\.po$/', $lang)) {
continue;
}
$lang = substr($lang, 0, strlen($lang) - 3);
$langs[$lang] = $languages[$lang];
}
return $langs;
}
function test_requirements()
{
$errors = array();
if(!(version_compare(PHP_VERSION, '5.3.0') >= 0)) {
$errors[] = t("PHP version mismatch. Movim requires PHP 5.3 minimum.")." ".t("Actual version : "). PHP_VERSION .
'<div class="guidance">'.t("Update your PHP version or contact your server administrator").'</div>';
}
if(!extension_loaded('curl')) {
$errors[] = t("Movim requires the %s extension.", 'PHP Curl') .
'<div class="guidance">'.t("Install %s and %s packages", 'php5-curl', 'curl').'</div>';
}
if(!extension_loaded('gd')) {
$errors[] = t("Movim requires the %s extension.", 'PHP GD') .
'<div class="guidance">'.t("Install the %s package", 'php5-gd').'</div>';
}
if(!extension_loaded('SimpleXML')) {
$errors[] = t("Movim requires the %s extension.", 'SimpleXML') .
'<div class="guidance">'.t("Install the %s package", 'php5-cli').'</div>';
}
if(!test_dir('../')) {
$errors[] = t("Movim's folder must be writable.") .
'<div class="guidance">'.t("Enable read and write rights on Movim's root folder").'</div>';
}
/*if(!test_dir('user')) {
$errors[] = t("The <em>%s</em> folder must exist and be writable.", 'user');
}
if(!test_dir('log')) {
$errors[] = t("The <em>%s</em> folder must exist and be writable.", 'log');
}*/
// Must have sqlite or mysql (so far...)
if(!extension_loaded('mysql') && !class_exists('SQLite3')) {
$exts = array('MySQL', 'SQLite');
$exts_txt = implode(t("or"), $exts);
$errors[] = t("Movim requires the %s extension.", $exts_txt);
}
global $databases;
if(extension_loaded('mysql'))
$databases['mysql'] = 'MySQL';
if(class_exists('SQLite3'))
$databases['sqlite'] = 'SQLite';
return (count($errors) > 0)? $errors : false;
}
function get_checkbox($name, $if = 'true', $else = 'false')
{
return (isset($_POST[$name])? $if : $else);
}
function test_bosh($boshhost, $port, $suffix, $host)
{
$url = (get_checkbox('boshCookieHTTPS') == "true")? 'https://' : 'http://';
$url .= $boshhost.":".$port.'/'.$suffix;
$headers = array('Accept-Encoding: gzip, deflate', 'Content-Type: text/xml; charset=utf-8');
$data = "
<body content='text/xml; charset=utf-8'
hold='1'
rid='1573741820'
to='".$host."'
secure='true'
wait='60'
xml:lang='en'
xmpp:version='1.0'
xmlns='http://jabber.org/protocol/httpbind'
xmlns:xmpp='urn:xmpp:xbosh'/>";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$rs = array();
$rs['content'] = curl_exec($ch);
$rs['errno'] = curl_errno($ch);
$rs['errmsg'] = curl_error($ch);
$rs['header'] = curl_getinfo($ch);
if($rs['errno']) {
set_error('bosh', t("Bosh connection failed with error `%s'", $rs['errmsg']));
return false;
}
curl_close($ch);
$arr = simplexml_load_string($rs["content"]);
if(is_object($arr))
$att = $arr->attributes();
if($att['type'] == 'terminate') {
set_error('bosh', t("XMPP connection through Bosh failed with error `%s'", $att['condition']));
}
else if(isset($att['sid'])) {
return true;
}
else {
return false;
}
}
function make_xml($stuff)
{
static $level = 0;
$buffer = "";
// Putting the XML declaration
if($level == 0) {
$buffer = '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
}
// Indentation
$indent = "";
for($i = 0; $i < $level; $i++) {
$indent.= " ";
}
// Doing the job
foreach($stuff as $tag => $value) {
if(is_array($value)) {
$buffer.= $indent.'<'.$tag.'>'.PHP_EOL;
$level++;
$buffer.= make_xml($value);
$buffer.= $indent.'</'.$tag.'>'.PHP_EOL;
} else {
$buffer.= "$indent<$tag>$value</$tag>".PHP_EOL;
}
}
$level--;
return $buffer;
}
function perform_install()
{
// Creating the folders.
if(!test_dir('../user') && !@mkdir('../user')) {
echo t("Couldn't create directory '%s'.", 'user');
return false;
}
if(!test_dir('../log') && !@mkdir('../log')) {
echo t("Couldn't create directory '%s'.", 'log');
return false;
}
if(!test_dir('../config') && !@mkdir('../config')) {
echo t("Couldn't create directory '%s'.", 'config');
return false;
}
// Creating the configuration file.
$conf = array(
'config' => array(
'theme' => $_POST['theme'],
'defLang' => $_POST['language'],
'boshCookieTTL' => $_POST['boshCookieTTL'],
'boshCookiePath' => $_POST['boshCookiePath'],
'boshCookieDomain' => get_checkbox('boshCookieDomain'),
'boshCookieHTTPS' => get_checkbox('boshCookieHTTPS'),
'boshCookieHTTPOnly' => get_checkbox('boshCookieHTTPOnly'),
'logLevel' => $_POST['verbosity'],
'accountCreation' => get_checkbox('accountCreation', 1, 0),
'host' => $_POST['host'],
'domain' => $_POST['domain'],
'defBoshHost' => $_POST['defBoshHost'],
'defBoshSuffix' => $_POST['defBoshSuffix'],
'defBoshPort' => $_POST['defBoshPort'],
'storageDriver' => $_POST['storage'],
'storageConnection' => $_POST['database'],
'proxyEnabled' => get_checkbox('proxyEnabled'),
'proxyURL' => $_POST['proxyURL'],
'proxyPort' => $_POST['proxyPort'],
),
);
if(!@file_put_contents('../config/conf.xml', make_xml($conf))) {
echo t("Couldn't create configuration file '%s'.", 'config/conf.xml');
return false;
}
return true;
}
$step = 'part1.php';
if(isset($_POST['install'])) {
// We test the Bosh configuration
if(!test_bosh($_POST['defBoshHost'], $_POST['defBoshPort'], $_POST['defBoshSuffix'], $_POST['host'])) {
goto loadpage;
}
// We create the configuration file
perform_install();
// We try to connect to the database
try {
include('../init.php');
} catch (Exception $e) {
set_error('bdd', t("Database connection failed with error `%s'", $e->getMessage()));
goto loadpage;
}
// We create correctly the tables
global $sdb;
$contact = new Contact();
$sdb->create($contact);
$conf = new ConfVar();
$sdb->create($conf);
$message = new Message();
$sdb->create($message);
$presence = new Presence();
$sdb->create($presence);
$attachment = new Attachment();
$sdb->create($attachment);
$step = 'part2.php';
}
loadpage:
require($step);
?>

190
install/part1.php

@ -1,105 +1,3 @@
<?php
require_once('../system/Lang/i18n.php');
require_once('../system/Lang/languages.php');
function get_mysql_port() {
$port = ini_get('mysql.default_port');
if($port == "")
$port = ini_get('mysqli.default_port');
if($port == "")
$port = 3306;
return $port;
}
function test_dir($dir)
{
return (file_exists($dir) && is_dir($dir) && is_writable($dir));
}
function list_themes()
{
$dir = opendir('../themes');
$themes = array();
while($theme = readdir($dir)) {
if(preg_match('/^\.+$/', $theme)
|| !is_dir('../themes/'.$theme)) {
continue;
}
$themes[$theme] = $theme;
}
return $themes;
}
function list_lang()
{
$dir = opendir('../i18n');
$langs = array('en' => 'English');
$languages = get_lang_list();
while($lang = readdir($dir)) {
if(!preg_match('/\.po$/', $lang)) {
continue;
}
$lang = substr($lang, 0, strlen($lang) - 3);
$langs[$lang] = $languages[$lang];
}
return $langs;
}
function test_requirements()
{
$errors = array();
if(!(version_compare(PHP_VERSION, '5.3.0') >= 0)) {
$errors[] = t("PHP version mismatch. Movim requires PHP 5.3 minimum.")." ".t("Actual version : "). PHP_VERSION .
'<div class="guidance">'.t("Update your PHP version or contact your server administrator").'</div>';
}
if(!extension_loaded('curl')) {
$errors[] = t("Movim requires the %s extension.", 'PHP Curl') .
'<div class="guidance">'.t("Install %s and %s packages", 'php5-curl', 'curl').'</div>';
}
if(!extension_loaded('gd')) {
$errors[] = t("Movim requires the %s extension.", 'PHP GD') .
'<div class="guidance">'.t("Install the %s package", 'php5-gd').'</div>';
}
if(!extension_loaded('SimpleXML')) {
$errors[] = t("Movim requires the %s extension.", 'SimpleXML') .
'<div class="guidance">'.t("Install the %s package", 'php5-cli').'</div>';
}
if(!test_dir('../')) {
$errors[] = t("Movim's folder must be writable.") .
'<div class="guidance">'.t("Enable read and write rights on Movim's root folder").'</div>';
}
/*if(!test_dir('user')) {
$errors[] = t("The <em>%s</em> folder must exist and be writable.", 'user');
}
if(!test_dir('log')) {
$errors[] = t("The <em>%s</em> folder must exist and be writable.", 'log');
}*/
// Must have sqlite or mysql (so far...)
if(!extension_loaded('mysql') && !class_exists('SQLite3')) {
$exts = array('MySQL', 'SQLite');
$exts_txt = implode(t("or"), $exts);
$errors[] = t("Movim requires the %s extension.", $exts_txt);
}
global $databases;
if(extension_loaded('mysql'))
$databases['mysql'] = 'MySQL';
if(class_exists('SQLite3'))
$databases['sqlite'] = 'SQLite';
return (count($errors) > 0)? $errors : false;
}
?>
<!DOCTYPE html>
<html>
<head>
@ -126,9 +24,10 @@ function test_requirements()
</head>
<body>
<div class="warning right">
<p><?php echo('Thank you for downloading Movim ! But before you\'ll enjoy it, a few adjustements are required.'); ?></p>
<p><?php echo('Keep in mind that Movim is still under development and will handle many personal details. Its use can potentially endanger your data. Always pay attention to information that you submit.'); ?></p>
<div style="margin: 0; position: fixed; top: 5px; right: 5px;" class="warning right">
<p><?php echo t('Thank you for downloading Movim!');?></p>
<p><?php echo t('before you enjoy your social network, a few adjustements are required.'); ?></p>
<p><?php echo t('Keep in mind that Movim is still under development and will handle many personal details. Its use can potentially endanger your data. Always pay attention to information that you submit.'); ?></p>
</div>
<div id="content" style="width: 800px; margin: 0 auto;">
<?php
@ -137,7 +36,7 @@ function test_requirements()
if($errors) {
// Ah ah, there are some errors.
?>
<h1><?php echo t('Movim Installer')." - ".t('Compatibility Test'); ?></h1>
<h1><?php echo t('Movim Installer')." - ".t('Compatibility Test'); ?></h1>
<p class="center"><?php echo t('The following requirements were not met. Please make sure they are all satisfied in order to install Movim.'); ?></p><br />
<?php
foreach($errors as $error) {
@ -146,10 +45,15 @@ function test_requirements()
<?php
}
} else {
?>
if(has_errors()):?>
<div class="error">
<?php echo t('Some errors were detected. Please correct them for the installation to proceed.');?>
</div>
<?php endif;?>
<h1><?php echo t('Movim Installer'); ?></h1>
<br />
<form method="post" action="part2.php">
<form method="post" action="index.php">
<fieldset>
<legend>General</legend>
<p>
@ -158,7 +62,7 @@ function test_requirements()
<select id="theme" name="theme">
<?php
foreach(list_themes() as $key=>$value)
echo '<option value="'.$key.'">'.$value.'</option>';
echo '<option value="'.$key.'"'.(($_POST['theme'] == $value)? ' selected="selected"': '').'>'.$value.'</option>';
?>
</select>
</p>
@ -168,7 +72,7 @@ function test_requirements()
<select id="language" name="language">
<?php
foreach(list_lang() as $key=>$value)
echo '<option value="'.$key.'">'.$value.'</option>';
echo '<option value="'.$key.'"'.(($_POST['theme'] == $value)? ' selected="selected"': '').'>'.$value.'</option>';
?>
</select>
@ -176,42 +80,60 @@ function test_requirements()
<p>
<label for="boshCookieTTL">Bosh cookie's expiration (s)</label>
<input type="text" id="boshCookieTTL" name="boshCookieTTL" value="3600"/>
<input type="text" id="boshCookieTTL" name="boshCookieTTL" value="<?php echo (isset($_POST['boshCookieTTL'])? $_POST['boshCookieTTL'] : 3600);?>"/>
</p>
<p>
<label for="boshCookiePath">Bosh cookie's path</label>
<input type="text" id="boshCookiePath" name="boshCookiePath" value="/"/>
<input type="text" id="boshCookiePath" name="boshCookiePath" value="<?php echo (isset($_POST['boshCookiePath'])? $_POST['boshCookiePath'] : '/');?>"/>
</p>
<p>
<label for="boshCookieDomain">Bosh cookie's domain</label>
<input type="checkbox" name="boshCookieDomain" id="boshCookieDomain" />
<input type="checkbox" name="boshCookieDomain" id="boshCookieDomain" <?php if(isset($_POST['boshCookieFomain'])) echo 'checked="checked"';?>/>
</p>
<p>
<label for="boshCookieHTTPS">Use HTTPS for Bosh</label>
<input type="checkbox" name="boshCookieHTTPS" id="boshCookieHTTPS" />
<input type="checkbox" name="boshCookieHTTPS" id="boshCookieHTTPS" <?php if(isset($_POST['boshCookieHTTPS'])) echo 'checked="checked"';?>/>
</p>
<p>
<label for="boshCookieHTTPOnly">Use only HTTP for Bosh</label>
<input type="checkbox" checked="checked" name="boshCookieHTTPOnly" id="boshCookieHTTPOnly" />
<input type="checkbox" checked="checked" name="boshCookieHTTPOnly" id="boshCookieHTTPOnly" <?php if(isset($_POST['boshCookieHTTPOnly'])) echo 'checked="checked"';?>/>
</p>
<?php
$logopts = array(
0 => t('empty'),
2 => t('terse'),
4 => t('normal'),
6 => t('talkative'),
7 => t('ultimate'),
);
$default_log = 4;
?>
<p>
<label for="7">Log verbosity</label>
<select id="verbosity" name="verbosity"><option value="0">empty</option>
<option value="2">terse</option>
<option selected="selected" value="4">normal</option>
<option value="6">talkative</option>
<option value="7">ultimate</option>
<select id="verbosity" name="verbosity">
<?php foreach($logopts as $lognum => $text):?>
<option value="<?php echo $lognum;?>"
<?php if(isset($_POST['verbosity'])):?>
<?php if($_POST['verbosity'] == $lognum):?>
selected="selected"
<?php endif;?>
<?php elseif($lognum == $default_log):?>
selected="selected"
<?php endif;?>>
<?php echo $text;?>
</option>
<?php endforeach;?>
</select>
</p>
<p>
<label for="accountCreation">Allow account creation</label>
<input type="checkbox" name="accountCreation" id="accountCreation" />
<input type="checkbox" name="accountCreation" id="accountCreation" <?php if(!isset($_POST['accountCreation']) || !$_POST['accountCreation']) echo 'checked="checked"';?>/>
</p>
</fieldset>
@ -220,11 +142,11 @@ function test_requirements()
<legend><?php echo t('XMPP Connection Preferences'); ?></legend>
<p>
<label for="host">XMPP Host</label>
<input type="text" id="host" name="host" value="movim.eu"/>
<input type="text" id="host" name="host" value="<?php echo (isset($_POST['host'])? $_POST['host'] : 'movim.eu');?>"/>
</p>
<p>
<label for="domain">XMPP Domain</label>
<input type="text" id="domain" name="domain" value="etenil.thruhere.net"/>
<input type="text" id="domain" name="domain" value="<?php echo (isset($_POST['domain'])? $_POST['domain'] : 'etenil.thruhere.net');?>"/>
</p>
</fieldset>
@ -232,25 +154,25 @@ function test_requirements()
<fieldset>
<legend><?php echo t('BOSH Connection Preferences'); ?></legend>
<?php if(isset($_GET['err']) && $_GET['err']=='bosh') { ?>
<?php if(err('bosh')) { ?>
<div class="error">
<?php echo t('The Bosh configuration is invalid'); ?>
<?php echo err('bosh'); ?>
</div>
<?php } ?>
<p>
<label for="defBoshHost">Bosh Host</label>
<input type="text" id="defBoshHost" name="defBoshHost" value="bosh.etenil.thruhere.net"/>
<input type="text" id="defBoshHost" name="defBoshHost" value="<?php echo (isset($_POST['defBoshHost'])? $_POST['defBoshHost'] : 'bosh.etenil.thruhere.net');?>"/>
</p>
<p>
<label for="defBoshSuffix">Bosh Suffix</label>
<input type="text" id="defBoshSuffix" name="defBoshSuffix" value=""/>
<input type="text" id="defBoshSuffix" name="defBoshSuffix" value="<?php echo (isset($_POST['defBoshSuffix'])? $_POST['defBoshSuffix'] : '');?>"/>
</p>
<p>
<label for="defBoshPort">Bosh Port</label>
<input style="width: 50px" type="text" id="defBoshPort" name="defBoshPort" value="80"/>
<input style="width: 50px" type="text" id="defBoshPort" name="defBoshPort" value="<?php echo (isset($_POST['defBoshPort'])? $_POST['defBoshPort'] : '80');?>"/>
</p>
</fieldset>
@ -260,17 +182,17 @@ function test_requirements()
<p>
<label for="proxyEnabled">Proxy server enabled</label>
<input type="checkbox" name="proxyEnabled" id="proxyEnabled" />
<input type="checkbox" name="proxyEnabled" id="proxyEnabled" <?php if(isset($_POST['proxyEnabled'])) echo 'checked="checked"';?>/>
</p>
<p>
<label for="proxyURL">Proxy URL (without http(s)://)</label>
<input style="width: 300px" type="text" id="proxyURL" name="proxyURL" value=""/>
<input style="width: 300px" type="text" id="proxyURL" name="proxyURL" value="<?php echo (isset($_POST['proxyURL'])? $_POST['proxyURL'] : '');?>"/>
</p>
<p>
<label for="proxyPort">Proxy Port</label>
<input style="width: 50px" type="text" id="proxyPort" name="proxyPort" value=""/>
<input style="width: 50px" type="text" id="proxyPort" name="proxyPort" value="<?php echo (isset($_POST['proxyPort'])? $_POST['proxyPort'] : '');?>"/>
</p>
</fieldset>
@ -278,10 +200,10 @@ function test_requirements()
<fieldset>
<legend>Storage</legend>
<?php if(isset($_GET['err']) && $_GET['err']=='bdd') { ?>
<?php if(err('bdd')) { ?>
<div class="error">
<?php echo t('The Database configuration is invalid'); ?>
<?php echo err('bdd'); ?>
</div>
<?php } ?>
@ -296,7 +218,7 @@ function test_requirements()
<p>
<label for="database">Database</label>
<input style="width: 400px" type="text" id="database" name="database" value="mysql://username:password@host:<?php echo get_mysql_port(); ?>/database"/>
<input style="width: 400px" type="text" id="database" name="database" value="<?php echo (isset($_POST['database'])? $_POST['database'] : 'mysql://username:password@host:'.get_mysql_port().'/database');?>"/>
</p>
</fieldset>

181
install/part2.php

@ -1,180 +1,3 @@
<?php
require_once('../system/Lang/i18n.php');
require_once('../system/Lang/languages.php');
function get_checkbox($name, $if = 'true', $else = 'false')
{
return (isset($_POST[$name])? $if : $else);
}
function test_bosh($boshhost, $port, $suffix, $host)
{
$url = (get_checkbox('boshCookieHTTPS') == "true")? 'https://' : 'http://';
$url .= $boshhost.":".$port.'/'.$suffix;
$headers = array('Accept-Encoding: gzip, deflate', 'Content-Type: text/xml; charset=utf-8');
$data = "
<body content='text/xml; charset=utf-8'
hold='1'
rid='1573741820'
to='".$host."'
secure='true'
wait='60'
xml:lang='en'
xmpp:version='1.0'
xmlns='http://jabber.org/protocol/httpbind'
xmlns:xmpp='urn:xmpp:xbosh'/>";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$rs = array();
$rs['content'] = curl_exec($ch);
$rs['errno'] = curl_errno($ch);
$rs['errmsg'] = curl_error($ch);
$rs['header'] = curl_getinfo($ch);
printf($rs['errmsg']);
curl_close($ch);
$arr = simplexml_load_string($rs["content"]);
if(is_object($arr))
$att = $arr->attributes();
if(isset($att['sid']))
return true;
else
return false;
}
function test_dir($dir)
{
return (file_exists($dir) && is_dir($dir) && is_writable($dir));
}
function make_xml($stuff)
{
static $level = 0;
$buffer = "";
// Putting the XML declaration
if($level == 0) {
$buffer = '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
}
// Indentation
$indent = "";
for($i = 0; $i < $level; $i++) {
$indent.= " ";
}
// Doing the job
foreach($stuff as $tag => $value) {
if(is_array($value)) {
$buffer.= $indent.'<'.$tag.'>'.PHP_EOL;
$level++;
$buffer.= make_xml($value);
$buffer.= $indent.'</'.$tag.'>'.PHP_EOL;
} else {
$buffer.= "$indent<$tag>$value</$tag>".PHP_EOL;
}
}
$level--;
return $buffer;
}
function perform_install()
{
// Creating the folders.
if(!test_dir('../user') && !@mkdir('../user')) {
echo t("Couldn't create directory '%s'.", 'user');
return false;
}
if(!test_dir('../log') && !@mkdir('../log')) {
echo t("Couldn't create directory '%s'.", 'log');
return false;
}
if(!test_dir('../config') && !@mkdir('../config')) {
echo t("Couldn't create directory '%s'.", 'config');
return false;
}
// Creating the configuration file.
$conf = array(
'config' => array(
'theme' => $_POST['theme'],
'defLang' => $_POST['language'],
'boshCookieTTL' => $_POST['boshCookieTTL'],
'boshCookiePath' => $_POST['boshCookiePath'],
'boshCookieDomain' => get_checkbox('boshCookieDomain'),
'boshCookieHTTPS' => get_checkbox('boshCookieHTTPS'),
'boshCookieHTTPOnly' => get_checkbox('boshCookieHTTPOnly'),
'logLevel' => $_POST['verbosity'],
'accountCreation' => get_checkbox('accountCreation', 1, 0),
'host' => $_POST['host'],
'domain' => $_POST['domain'],
'defBoshHost' => $_POST['defBoshHost'],
'defBoshSuffix' => $_POST['defBoshSuffix'],
'defBoshPort' => $_POST['defBoshPort'],
'storageDriver' => $_POST['storage'],
'storageConnection' => $_POST['database'],
'proxyEnabled' => get_checkbox('proxyEnabled'),
'proxyURL' => $_POST['proxyURL'],
'proxyPort' => $_POST['proxyPort'],
),
);
if(!@file_put_contents('../config/conf.xml', make_xml($conf))) {
echo t("Couldn't create configuration file '%s'.", 'config/conf.xml');
return false;
}
return true;
}
if(isset($_POST['install'])) {
// We test the Bosh configuration
if(!test_bosh($_POST['defBoshHost'], $_POST['defBoshPort'], $_POST['defBoshSuffix'], $_POST['host'])) {
header('Location:part1.php?err=bosh'); exit;
}
// We create the configuration file
perform_install();
// We try to connect to the database
try {
include('../init.php');
} catch (Exception $e) {
header('Location:part1.php?err=bdd');
}
// We create correctly the tables
global $sdb;
$contact = new Contact();
$sdb->create($contact);
$conf = new ConfVar();
$sdb->create($conf);
$message = new Message();
$sdb->create($message);
$presence = new Presence();
$sdb->create($presence);
$attachment = new Attachment();
$sdb->create($attachment);
}
?>
<!DOCTYPE html>
<html>
<head>
@ -184,7 +7,7 @@ if(isset($_POST['install'])) {
<link rel="stylesheet" href="../themes/movim/css/style2.css" type="text/css" />
</head>
<body>
<div id="content">
<div id="content" style="width: 400px; margin: auto;">
<h1><?php echo t('Movim Installer')." - ".t('Success !'); ?></h1>
<div class="valid">
@ -193,7 +16,7 @@ if(isset($_POST['install'])) {
- <?php echo t('Database Movim schema installed'); ?><br />
</div>
<div class="warning">
<?php echo t('You can now access your shiny Movim instance %sJump In !%s', '<a class="button tiny" style="float: right;" href="../index.php">', '</a>');?><br /><br />
<?php echo t('You can now access your shiny Movim instance %sJump In !%s', '<a class="button tiny" style="float: right;" href="../index.php">', '</a>');?><br /><br /><br />
- <?php echo t('Please remove the %s folder in order to complete the installation', 'install/'); ?>
</div>
</div>

Loading…
Cancel
Save