<?php
/**************************************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
@Authors: Ryan Thompson(hide@address.com)
***************************************************************************/
//Need a way to stop users
$service['no_session'] = TRUE;
include('../config.inc.php');
if(isset($_POST['create_tables']) || isset($_POST['recreate_tables']))
{
$link = 'install_tables.php';
if(isset($_POST['recreate_tables']))
{
$link .= "?table_list={$_POST['table_list']}";
}
header("Location: $link");
} elseif(isset($_POST['upgrade_tables']))
{
header('Location: upgrade_config.php');
} elseif(isset($_POST['add_languages']))
{
$languages = rawurlencode(serialize($_POST['available_languages']));
header("Location: install_languages.php?langs=$languages");
} elseif(isset($_POST['delete_languages']))
{
$languages = rawurlencode(serialize($_POST['installed_languages']));
header("Location: delete_languages.php?langs=$languages");
} elseif(isset($_POST['install_data']))
{
header("Location: install_data.php");
} elseif(isset($_POST['create_admin']))
{
header("Location: root_setup.php");
} elseif(isset($_POST['install_services']))
{
header("Location: install_services.php");
} elseif(isset($_POST['upgrade']))
{
//This is moving
header("Location: upgrade_tables.php");
} elseif(isset($_POST['complete']))
{
header("Location: ../login.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>OpenSource GroupWare Setup</title>
<link rel="stylesheet" type="text/css" href="config.css">
<script type="text/javascript">
function openhelp(popurl){
winpops=window.open(popurl,"","width=400,height=338,resizable,")
}
</script>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table width="700" cellpadding="1" cellspacing="0" style="border: 1px solid #FFFFFF; background: #336699;" align="center">
<tr>
<td>
<table width="700" align="center" style="border: 1px solid #FFFFFF; background: #336699;">
<tr>
<td class="header" style="text-align:right;padding:0px" valign="top" colspan="3">
<?php echo OSGW_NAME?> Setup <a href="<?php echo HOME?>">
<img src="../osgw/graphics/o.png" border="0" align="top"></a>
</td>
</tr>
<tr>
<td class="caption" style="width: 200px">Checking for tables:</td>
<td class="input" style="width: 500px">
<?php
if(!$table_list = $db->tables())
{
$table_count = 0;
echo "There are no tables belonging to O";
} else {
$table_count = count($table_list);
echo "$table_count tables belonging to O have been installed.";
}
?>
</td>
</tr>
<tr>
<td class="caption">Re-create Tables:</td>
<td class="input">
<?php
//Do we already have tables?
if($table_count == 0)
{
echo "<input type=\"submit\" name=\"create_tables\" value=\"Create Tables\" style=\"border: 1px solid black\">";
} else {
echo "<input type=\"hidden\" name=\"table_list\" value=\"". rawurlencode(serialize($table_list)) ."\">";
echo "<input type=\"submit\" name=\"recreate_tables\" value=\"Re-Create Tables\" style=\"border: 1px solid black\">***DANGEROUS";
}
?>
</td>
</tr>
<?php
if($table_count != 0)
{
$db->query("SELECT value FROM o_info WHERE name='version'");
$db->fetch_results();
if($db->record['value'] < VERSION && isset($db->record['value']))
{
echo '<tr><td class="caption">Upgrade</td>';
echo '<td class="input">';
echo '<input type="submit" name="upgrade" value="Upgrade" style="border: 1px solid black">';
echo '</td></tr>';
} else {
?>
<tr>
<td class="caption">
Install Services
</td>
<td class="input">
<?php
$db->query("SELECT code FROM o_services");
if($db->num_rows != 0)
{
echo "Services Installed";
} else {
?>
<input type="submit" name="install_services" value="Install Services" style="border: 1px solid black">
<?PHP
}
?>
</td>
</tr>
<tr>
<td class="caption">
Add data
</td>
<td class="input">
<?php
$db->query("SELECT user_id FROM o_users");
if($db->num_rows == 0)
{
?>
<input type="submit" name="install_data" value="Install Data" style="border: 1px solid black"> Please be patient this may take a while.
<?php
} else {
echo "Data Installed";
}
?>
</td>
</tr>
<?php
$db->query("SELECT lg_id FROM o_languages");
if($db->num_rows != 0)
{
?>
<tr>
<td class="caption">Language Support:</td>
<td class="input">
<table>
<tr>
<td><?php echo $setup->get_language_support(0)?></td>
<td style="text-align:center">
<input type="submit" name="add_languages" value="Add Language" class="button">
<br />
<br />
<input type="submit" name="delete_languages" value="Delete Language" class="button">
</td>
<td><?php echo $setup->get_language_support(1)?></td>
</tr>
</table>
</td>
</tr>
<?php
}
$db->query("SELECT * FROM o_languages WHERE enabled='1'");
$language_count = $db->num_rows;
$db->query("SELECT username FROM o_users WHERE user_id != '1'");
$root_exists = $db->num_rows;
if($language_count == 0)
{
} elseif($root_exists != 1)
{
?>
<tr>
<td class="caption">Create Administrator:</td>
<td class="input"><input type="submit" name="create_admin" value="Create Admin" class="button"></td>
</tr>
<?php
} else {
?>
<tr>
<td class="caption">Create Administrator:</td>
<td class="input">Administrator Account Created</td>
</tr>
<?php
$db->query("SELECT value FROM o_info WHERE name='version'");
$db->fetch_results();
if($db->record['value'] == VERSION)
{
echo '<tr>';
echo '<td class="caption">Setup Complete</td>';
echo '<td class="input">';
echo "You have finished installing ". OSGW_NAME ." {$db->record['value']}<br />";
echo 'Enjoy. If you have any comments or question go to the <a href="'. HOME .'">OSGW Homepage</a><br />';
echo '<input type="submit" name="complete" value="Login" class="button">';
echo '</td>';
echo '</tr>';
}
}
}
}
?>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>