<?php // $Revision: 1.31.2.2 $
/* vim: set expandtab ts=4 sw=4 sts=4: */
/**
* $Id: setup.php,v 1.31.2.2 2010/01/20 14:48:20 luiswang Exp $
*
* Copyright (c) 2009 by the netOffice Dwins developers
*
* 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.
*/
require_once('../languages/lang_en.php');
$version = 'Dwins-1.4';
$dateheure = date("Y-m-d H:i");
$dateheures = date("Y-m-d H:i:s");
$step = isset($_REQUEST['step'])?$_REQUEST['step']:'1';
$dbTypList = array("pg","my");
$checkList = array(
"/administration/systeminfo.php" => "File",
"/administration/updatesettings.php" => "File",
"/installation/db_var.inc.php" => "File",
"/installation/setup_db.php" => "File",
"/installation/setup_settings.php" => "File",
"/includes/library.php" => "File",
"/includes/request.class.php" => "File",
"/includes/settings.php" => "File",
"/includes/jpgraph" => "Directory",
"/includes/phpmailer" => "Directory",
"/files" => "Directory",
"/logos_clients" => "Directory");
$setDoctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
$setCopyright = '<!-- Powered by netOffice Dwins v1.4 -->';
$setCharset = 'utf-8';
$setTitle = "netOffice Dwins Web-Based Installer";
$setDescription = 'Groupware module. Manage web projects with team collaboration, users management, tasks and projects tracking, files approval tracking, project sites clients access, customer relationship management.';
$setKeywords = 'management, web, projects, tasks, organizations, reports, application, module, file management, project site, team collaboration, crm, CRM, cutomer relationship management, workflow, workgroup, timesheet';
$lang = 'en';
$includeJSColor = '';
$enableTinyMCE = '';
$headBonus = '';
$bodyCommand = '';
$clientHeader->org_extension_logo[0] = '';
$notLogged = '';
$error = '';
define('THEME', 'default');
$blank = "true";
require_once("../themes/" . THEME . "/block.class.php");
require_once("../themes/" . THEME . "/header.php");
$block1 = new block();
$block1->form = "setup";
$block1->openForm("../installation/setup.php?#" . $block1->form . "Anchor");
switch ($step) {
case "1":
$block1->openBreadcrumbs();
$block1->itemBreadcrumbs($block1->buildLink('../installation/upgrade.php?', 'Upgrade an existing netOffice Dwins v1.3.2 installation', 'in'));
$block1->closeBreadcrumbs();
$block1->heading("License");
$block1->openLongList();
$block1->openContent();
$block1->contentTitle(" ");
$copying = file_get_contents("../docs/copying.txt");
$block1->contentRow("", "<pre>$copying</pre>");
echo "<input type=\"hidden\" name=\"step\" value=\"2\">";
$submitName = "check file permissions";
break;
case "2":
$error = false;
foreach ($checkList as $fileChk => $fileTyp) {
if (is_writable(".." . $fileChk) == false) {
$error = true;
break;
}
}
if ($error) {
$block1->errorBox("In order for the package to work correctly, the following files must be writeable by the server. Please change the permission setting for these files. (i.e. 'chmod 666 file_name' and 'chmod 777 dir_name' on a UNIX/LINUX server, or check the properties of the file and make sure the read-only flag is not set on a Windows server)");
echo "<input type=\"hidden\" name=\"step\" value=\"2\">";
$submitName = "Reload";
} else {
echo "<input type=\"hidden\" name=\"step\" value=\"3\">";
$submitName = "Settings";
}
$block1->openLongList();
$block1->heading("Check File Permissions");
$block1->openContent();
$block1->contentTitle(" ");
foreach($checkList as $fileChk => $fileTyp) {
if (is_writable(".." . $fileChk)) {
$block1->contentRow("<img src=\"ok.gif\"/>", "$fileTyp $fileChk is writable.", "false", "");
} else {
$block1->contentRow("<img src=\"wrong.gif\"/>", "<b>$fileTyp $fileChk is NOT writable.</b>", "false", "");
}
}
if (!$error) {
$block1->contentRow("", "");
$block1->contentRow("", "No errors detected.");
}
break;
case "3":
$connexion = isset($_REQUEST['connexion'])?$_REQUEST['connexion']:'online';
$action = isset($_REQUEST['action'])?$_REQUEST['action']:'';
$updatechecker = isset($_REQUEST['updatechecker'])?$_REQUEST['updatechecker']:'';
$installationType = isset($_REQUEST['installationType'])?$_REQUEST['installationType']:'';
$dbtype = isset($_REQUEST['dbtype'])?$_REQUEST['dbtype']:'pg';
$dbserver = isset($_REQUEST['dbserver'])?$_REQUEST['dbserver']:'';
$dblogin = isset($_REQUEST['dblogin'])?$_REQUEST['dblogin']:'';
$dbpasswd = isset($_REQUEST['dbpasswd'])?$_REQUEST['dbpasswd']:'';
$dbname = isset($_REQUEST['dbname'])?$_REQUEST['dbname']:'';
$tbprefix = isset($_REQUEST['tbprefix'])?$_REQUEST['tbprefix']:chr(rand(97,122)).chr(rand(65,90)).chr(rand(48,57));
$mkdirMethod = isset($_REQUEST['mkdirMethod'])?$_REQUEST['mkdirMethod']:'';
$notifications = isset($_REQUEST['notifications'])?$_REQUEST['notifications']:'';
$notificationMethod = isset($_REQUEST['notificationMethod'])?$_REQUEST['notificationMethod']:'';
$smtpserver = isset($_REQUEST['smtpserver'])?$_REQUEST['smtpserver']:'';
$smtplogin = isset($_REQUEST['smtplogin'])?$_REQUEST['smtplogin']:'';
$smtppassword = isset($_REQUEST['smtppassword'])?$_REQUEST['smtppassword']:'';
$ftpserver = isset($_REQUEST['ftpserver'])?$_REQUEST['ftpserver']:'';
$ftplogin = isset($_REQUEST['ftplogin'])?$_REQUEST['ftplogin']:'';
$ftppassword = isset($_REQUEST['ftppassword'])?$_REQUEST['ftppassword']:'';
$ftpRoot = isset($_REQUEST['ftpRoot'])?$_REQUEST['ftpRoot']:'';
$forcedLogin = isset($_REQUEST['forcedLogin'])?$_REQUEST['forcedLogin']:'';
$langdefault = isset($_REQUEST['langdefault'])?$_REQUEST['langdefault']:'';
$root = isset($_REQUEST['root'])?$_REQUEST['root']:'';
$loginMethod = isset($_REQUEST['loginMethod'])?$_REQUEST['loginMethod']:'';
$adminLogin = isset($_REQUEST['adminLogin'])?$_REQUEST['adminLogin']:'';
$adminPwd = isset($_REQUEST['adminPwd'])?$_REQUEST['adminPwd']:'';
$adminPwa = isset($_REQUEST['adminPwa'])?$_REQUEST['adminPwa']:'';
$sitePublish = isset($_REQUEST['sitePublish'])?$_REQUEST['sitePublish']:'true';
$enablePE = isset($_REQUEST['enablePE'])?$_REQUEST['enablePE']:'true';
$enableTimesheet = isset($_REQUEST['enableTimesheet'])?$_REQUEST['enableTimesheet']:'true';
$autoCreateDir = isset($_REQUEST['autoCreateDir'])?$_REQUEST['autoCreateDir']:'';
$periodUnit = isset($_REQUEST['periodUnit'])?$_REQUEST['periodUnit']:'month';
$autoLockPeriod = isset($_REQUEST['autoLockPeriod'])?$_REQUEST['autoLockPeriod']:'0';
$defaultCurrency = isset($_REQUEST['defaultCurrency'])?$_REQUEST['defaultCurrency']:'USD';
$currencyOnRight = isset($_REQUEST['currencyOnRight'])?$_REQUEST['currencyOnRight']:'';
$hourAccuracy = isset($_REQUEST['hourAccuracy'])?$_REQUEST['hourAccuracy']:'1';
$rateAccuracy = isset($_REQUEST['rateAccuracy'])?$_REQUEST['rateAccuracy']:'2';
$costAccuracy = isset($_REQUEST['costAccuracy'])?$_REQUEST['costAccuracy']:'2';
$timeFormat = isset($_REQUEST['timeFormat'])?$_REQUEST['timeFormat']:'24H';
$cryptKey = get_crypt_key();
$basedir = preg_replace('/installation$/i', '', str_replace('\\', '/', dirname(__FILE__)), 1);
if (substr($root, -1) == "/") {
$root = substr($root, 0, -1);
}
if (substr($ftpRoot, -1) == "/") {
$ftpRoot = substr($ftpRoot, 0, -1);
}
if ($action == "save") {
if ($dbserver == '') {
$error = 'Must be insert the database Server';
} else if ($dblogin == '') {
$error = 'Must be insert the database Login';
} else if ($dbname == '') {
$error = 'Must be insert the database Name';
} else if ($tbprefix == '') {
$error = 'Must be insert the Table prefix';
} else if ($root == '') {
$error = 'Must be insert the Root path';
} else if ($adminLogin == '') {
$error = 'Must be insert the Admin login name';
} else if ($adminPwd == '') {
$error = 'Must be insert the Admin password';
} else if ($adminPwd != $adminPwa) {
$error = 'The two passwords you entered did not match';
} else if ($mkdirMethod == 'FTP') {
if ($ftpserver == '') {
$error = 'Must be insert the Ftp server';
} else if ($ftplogin == '') {
$error = 'Must be insert the Ftp login';
} else if ($ftppassword == '') {
$error = 'Must be insert the Ftp password';
} else if ($ftpRoot == '') {
$error = 'Must be insert the Ftp root';
}
} else if ($installationType == "offline") {
$updatechecker = "false";
}
}
if ($error != '') {
$block1->errorBox($error);
$action = "";
}
if ($action != "save") {
$block1->openLongList();
$block1->heading("Settings");
$block1->openContent();
$block1->contentTitle("General");
if ($connexion == "off") {
echo "<input value=\"false\" name=\"updatechecker\" type=\"hidden\">";
} else if (@join('', file("http://netofficedwins.sourceforge.net/version.txt"))) {
echo "<input value=\"true\" name=\"updatechecker\" type=\"hidden\">";
} else {
echo "<input value=\"false\" name=\"updatechecker\" type=\"hidden\">";
}
if ($connexion == "offline") {
$installCheckOffline = "checked";
$installCheckOnline = '';
} else {
$installCheckOffline = '';
$installCheckOnline = "checked";
}
$block1->contentRow("* Installation type", "<input type=\"radio\" name=\"installationType\" value=\"offline\" $installCheckOffline> Offline (firewall/intranet, no update checker) <input type=\"radio\" name=\"installationType\" value=\"online\" $installCheckOnline> Online");
$block1->contentRow("* Database type", "<input type=\"radio\" name=\"dbtype\" value=\"$dbtype\" checked> PostgreSQL <input type=\"radio\" name=\"dbtype\" value=\"my\"> MySQL");
$block1->contentRow("* Database server", "<input size=\"44\" value=\"$dbserver\" style=\"width: 200px\" name=\"dbserver\" maxlength=\"100\" type=\"text\">");
$block1->contentRow("* Database login", "<input size=\"44\" value=\"$dblogin\" style=\"width: 200px\" name=\"dblogin\" maxlength=\"100\" type=\"text\">");
$block1->contentRow("Database password", "<input size=\"44\" value=\"$dbpasswd\" style=\"width: 200px\" name=\"dbpasswd\" maxlength=\"100\" type=\"password\">");
$block1->contentRow("* Database name", "<input size=\"44\" value=\"$dbname\" style=\"width: 200px\" name=\"dbname\" maxlength=\"100\" type=\"text\">");
$block1->contentRow("* Table prefix [<a href=\"javascript:void(0);\" onmouseover=\"return overlib('" . addslashes($strings["setup_dbprefix"]) . "',TEXTSIZE,'small',BGCOLOR,'#5B7F93',FGCOLOR,'#C4D3DB');\" onmouseout=\"return nd();\">Help</a>]", "<input size=\"44\" value=\"$tbprefix\" style=\"width: 200px\" name=\"tbprefix\" maxlength=\"100\" type=\"text\">");
$safemodeTest = ini_get("safe_mode");
if ($safemodeTest == "1") {
$checked1_a = '';
$checked2_a = "checked"; //true
$safemode = "on";
} else {
$checked1_a = "checked"; //false
$checked2_a = '';
$safemode = "off";
}
$notificationsTest = function_exists('mail');
if ($notificationsTest == "true") {
$checked1_b = '';
$checked2_b = "checked"; //false
$maillibrary = "on";
} else {
$checked1_b = "checked"; //true
$checked2_b = '';
$maillibrary = "off";
}
$block1->contentRow("* Create folder method [<a href=\"javascript:void(0);\" onmouseover=\"return overlib('" . addslashes($strings["setup_mkdirMethod"]) . "',TEXTSIZE,'small',BGCOLOR,'#5B7F93',FGCOLOR,'#C4D3DB');\" onmouseout=\"return nd();\">Help</a>]", "<table cellpadding=0 cellspacing=0><tr><td valign=top><input type=\"radio\" name=\"mkdirMethod\" value=\"PHP\" $checked1_a> PHP <input type=\"radio\" name=\"mkdirMethod\" value=\"FTP\" $checked2_a> FTP<br>[Safe-mode $safemode]</td><td align=right>Ftp server <input size=\"44\" value=\"$ftpserver\" style=\"width: 200px\" name=\"ftpserver\" maxlength=\"100\" type=\"text\"><br>
Ftp login <input size=\"44\" value=\"$ftplogin\" style=\"width: 200px\" name=\"ftplogin\" maxlength=\"100\" type=\"text\"><br>
Ftp password <input size=\"44\" value=\"$ftppassword\" style=\"width: 200px\" name=\"ftppassword\" maxlength=\"100\" type=\"password\"><br>
Ftp root <input size=\"44\" value=\"$ftpRoot\" style=\"width: 200px\" name=\"ftpRoot\" maxlength=\"100\" type=\"text\"></td></tr></table>");
$block1->contentRow("* Notifications [<a href=\"javascript:void(0);\" onmouseover=\"return overlib('" . addslashes($strings["setup_notifications"]) . "',TEXTSIZE,'small',BGCOLOR,'#5B7F93',FGCOLOR,'#C4D3DB');\" onmouseout=\"return nd();\">Help</a>]", "<table cellpadding=0 cellspacing=0><tr><td valign=top><input type=\"radio\" name=\"notifications\" value=\"false\" $checked1_b> False</td><td><input type=\"radio\" name=\"notifications\" value=\"true\" $checked2_b> True</td></tr><tr><td></td><td>[Mail $maillibrary]</td></tr></table>");
$block1->contentRow("Notification method [<a href=\"javascript:void(0);\" onmouseover=\"return overlib('" . addslashes($strings["setup_notificationMethod"]) . "',TEXTSIZE,'small',BGCOLOR,'#5B7F93',FGCOLOR,'#C4D3DB');\" onmouseout=\"return nd();\">Help</a>]", "<table cellpadding=\"0\" cellspacing=\"0\" width=\"500\"> <tr> <td valign=\"top\"> <input type=\"radio\" name=\"notificationMethod\" value=\"mail\" checked> PHP mail function <input type=\"radio\" name=\"notificationMethod\" value=\"smtp\"> SMTP</td> <td align=\"right\"> Smtp server <input size=\"44\" value=\"\" style=\"width: 200px\" name=\"smtpserver\" maxlength=\"100\" type=\"text\"><br> Smtp login <input size=\"44\" value=\"\" style=\"width: 200px\" name=\"smtplogin\" maxlength=\"100\" type=\"text\"><br> Smtp password <input size=\"44\" value=\"\" style=\"width: 200px\" name=\"smtppassword\" maxlength=\"100\" type=\"password\"> </td> </tr> </table>");
$block1->contentRow("* Forced login [<a href=\"javascript:void(0);\" onmouseover=\"return overlib('" . addslashes($strings["setup_forcedlogin"]) . "',TEXTSIZE,'small',BGCOLOR,'#5B7F93',FGCOLOR,'#C4D3DB');\" onmouseout=\"return nd();\">Help</a>]", "<input type=\"radio\" name=\"forcedLogin\" value=\"false\" checked> False <input type=\"radio\" name=\"forcedLogin\" value=\"true\"> True");
require_once('../languages/languages.inc.php');
// build lang drop list
array_multisort($langValue, SORT_ASC, SORT_STRING);
$selectLanguage = '<select name="langdefault"><option value=""></option>';
foreach ($langValue as $key => $value) {
if (file_exists('../languages/lang_' . $key . '.php')) {
$selectLanguage .= '<option value="' . $key . '">' . $value . '</option>';
}
}
$selectLanguage .= '</select>';
$block1->contentRow("Default language [<a href=\"javascript:void(0);\" onmouseover=\"return overlib('" . addslashes($strings["setup_langdefault"]) . "',TEXTSIZE,'small',BGCOLOR,'#5B7F93',FGCOLOR,'#C4D3DB');\" onmouseout=\"return nd();\">Help</a>]", $selectLanguage);
$currencyStr = '<select name="defaultCurrency">';
require_once('../includes/currency.inc.php');
$helpStr = '<table>';
foreach ($CurrencyMatrix['name'] as $currCode => $currName) {
$helpStr .= '<tr><th>' . $currCode . '</th><td>' . $currName . '</td></tr>';
$currencyStr .= '<option value="' . $currCode . '"';
if ($currCode == $defaultCurrency) $currencyStr .= ' selected';
$currencyStr .= '>' . $currCode . '</option>';
}
$currencyStr .= '</select>';
$helpStr .= '</table>';
$block1->contentRow("* Default currency [<a href=\"javascript:void(0);\" onmouseover=\"return overlib('" . addslashes($helpStr) . "',TEXTSIZE,'small',BGCOLOR,'#5B7F93',FGCOLOR,'#C4D3DB');\" onmouseout=\"return nd();\">Help</a>]", $currencyStr);
if ($sitePublish == "true") {
$checked1_d = "checked"; //true
$checked2_d = '';
} else {
$checked1_d = '';
$checked2_d = "checked"; //false
}
$block1->contentRow("Client Collaboration", "<input type=\"radio\" name=\"sitePublish\" value=\"true\" $checked1_d> True <input type=\"radio\" name=\"sitePublish\" value=\"false\" $checked2_d> False");
if ($enablePE == "true") {
$checked1_e = "checked"; //true
$checked2_e = '';
} else {
$checked1_e = '';
$checked2_e = "checked"; //false
}
$block1->contentRow("Enable Person Evaluation", "<input type=\"radio\" name=\"enablePE\" value=\"true\" $checked1_e> True <input type=\"radio\" name=\"enablePE\" value=\"false\" $checked2_e> False");
if ($enableTimesheet == "true") {
$checked1_f = "checked"; //true
$checked2_f = '';
} else {
$checked1_f = '';
$checked2_f = "checked"; //false
}
$block1->contentRow("Enable Timesheet", "<input type=\"radio\" name=\"enableTimesheet\" value=\"true\" $checked1_f> True <input type=\"radio\" name=\"enableTimesheet\" value=\"false\" $checked2_f> False");
if ($autoCreateDir == "true") {
$checked1_h = "checked"; //true
$checked2_h = '';
} else {
$checked1_h = '';
$checked2_h = "checked"; //false
}
$block1->contentRow("Auto Create Project Folder", "<input type=\"radio\" name=\"autoCreateDir\" value=\"true\" $checked1_h> True <input type=\"radio\" name=\"autoCreateDir\" value=\"false\" $checked2_h> False");
if ($periodUnit == 'month') {
$checked1_g = 'checked'; //month
$checked2_g = '';
} else {
$checked1_g = '';
$checked2_g = 'checked'; //week
}
$block1->contentRow('Unit of Period', '<input type="radio" name="periodUnit" value="month" ' . $checked1_g . '> Month <input type="radio" name="periodUnit" value="week" ' . $checked2_g . '> Week');
$autoLockStr = '<select name="autoLockPeriod">';
foreach (array('0', '1', '2', '3', '5', '7', '14', '21', '28') as $d) {
if ($d == $autoLockPeriod) {
$autoLockStr .= '<option value="' . $d . '" selected>' . $d . '</option>';
} else {
$autoLockStr .= '<option value="' . $d . '">' . $d . '</option>';
}
}
$autoLockStr .= '</select>';
$block1->contentRow("Auto Lock Period [<a href=\"javascript:void(0);\" onmouseover=\"return overlib('" . addslashes($strings["setup_autolockperiod"]) . "',TEXTSIZE,'small',BGCOLOR,'#5B7F93',FGCOLOR,'#C4D3DB');\" onmouseout=\"return nd();\">Help</a>]", $autoLockStr);
$url = $_SERVER['SERVER_NAME'];
if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
$url .= ":" . $_SERVER['SERVER_PORT'];
}
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
$protocol = "https://";
} else {
$protocol = "http://";
}
$root = $protocol . $url . dirname($_SERVER['PHP_SELF']);
$root = str_replace("installation", "", $root);
$block1->contentRow("* Root", "<input size=\"44\" value=\"$root\" style=\"width: 200px\" name=\"root\" maxlength=\"100\" type=\"text\">");
$block1->contentRow("* Login method [<a href=\"javascript:void(0);\" onmouseover=\"return overlib('" . addslashes($strings["setup_loginmethod"]) . "',TEXTSIZE,'small',BGCOLOR,'#5B7F93',FGCOLOR,'#C4D3DB');\" onmouseout=\"return nd();\">Help</a>]", "<input type=\"radio\" name=\"loginMethod\" value=\"PLAIN\"> Plain <input type=\"radio\" name=\"loginMethod\" value=\"MD5\"> Md5 <input type=\"radio\" name=\"loginMethod\" value=\"CRYPT\" checked> Crypt");
$block1->contentRow("* Admin login", "<input size=\"44\" value=\"$adminLogin\" style=\"width: 200px\" name=\"adminLogin\" maxlength=\"100\" type=\"text\">");
$block1->contentRow("* Admin password", "<input size=\"44\" value=\"$adminPwd\" style=\"width: 200px\" name=\"adminPwd\" maxlength=\"100\" type=\"password\">");
$block1->contentRow("* Confirm password", "<input size=\"44\" value=\"$adminPwa\" style=\"width: 200px\" name=\"adminPwa\" maxlength=\"100\" type=\"password\">");
$block1->contentTitle("Display");
$hourAccuracySel = '<select name="hourAccuracy">';
for ($i=0; $i<=6; $i++) {
if ($i == $hourAccuracy) {
$hourAccuracySel .= '<option value="' . $i . '" selected>' . $i . '</option>';
} else {
$hourAccuracySel .= '<option value="' . $i . '">' . $i . '</option>';
}
}
$hourAccuracySel .= '</select>';
$block1->contentRow("Decimal Place for Log Hours", $hourAccuracySel);
$rateAccuracySel = '<select name="rateAccuracy">';
for ($i=0; $i<=6; $i++) {
if ($i == $rateAccuracy) {
$rateAccuracySel .= '<option value="' . $i . '" selected>' . $i . '</option>';
} else {
$rateAccuracySel .= '<option value="' . $i . '">' . $i . '</option>';
}
}
$rateAccuracySel .= '</select>';
$block1->contentRow("Decimal Place for Service Rate", $rateAccuracySel);
$costAccuracySel = '<select name="costAccuracy">';
for ($i=0; $i<=6; $i++) {
if ($i == $costAccuracy) {
$costAccuracySel .= '<option value="' . $i . '" selected>' . $i . '</option>';
} else {
$costAccuracySel .= '<option value="' . $i . '">' . $i . '</option>';
}
}
$costAccuracySel .= '</select>';
$block1->contentRow("Decimal Place for Project Cost/Expense", $costAccuracySel);
$timeFormatSel = '<select name="timeFormat">';
$timeFormats = array('12H', '24H');
foreach ($timeFormats as $i) {
if ($i == $timeFormat) {
$timeFormatSel .= '<option value="' . $i . '" selected>' . $i . '</option>';
} else {
$timeFormatSel .= '<option value="' . $i . '">' . $i . '</option>';
}
}
$timeFormatSel .= '</select>';
$block1->contentRow("Time Format", $timeFormatSel);
if ($currencyOnRight == "true") {
$checked1_c = "checked"; //true
$checked2_c = '';
} else {
$checked1_c = '';
$checked2_c = "checked"; //false
}
$block1->contentRow("Display Currency on the Right", "<input type=\"radio\" name=\"currencyOnRight\" value=\"true\" $checked1_c> True <input type=\"radio\" name=\"currencyOnRight\" value=\"false\" $checked2_c> False");
echo "<input type=\"hidden\" name=\"step\" value=\"3\">";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">";
$submitName = "Save";
break;
}
case "4":
$error = false;
$block1->openLongList();
$block1->heading("Save settings");
$block1->openContent();
$block1->contentTitle(" ");
$gmtTimezone = 'false';
$enable_cvs = 'false';
$cvs_protected = 'false';
$cvs_root = 'D:\cvs';
$cvs_owner = 'apache';
$cvs_co = '/usr/bin/co';
$cvs_rlog = '/usr/bin/rlog';
$cvs_cmd = '/usr/bin/cvs';
$pathToOpenssl = '/usr/bin/openssl';
$useLDAP = 'false';
$ldapserver = 'your.ldap.server.address';
$searchroot = 'ou=People, ou=Intranet, dc=YourCompany, dc=com';
$htaccessAuth = 'false';
$fullPath = '/var/www/html/netoffice/files';
$fileManagement = 'true';
$allowPhp = 'false';
$peerReview = 'true';
$activeJpgraph = 'true';
$footerDev = 'false';
$clientsFilter = 'false';
$projectsFilter = 'true';
$enableHelpSupport = 'true';
$supportEmail = 'hide@address.com';
$supportType = 'team';
$siteOff = 'false';
$upload_max_filesize = strtoupper((ini_get('upload_max_filesize')=='')?'2097152':ini_get('upload_max_filesize'));
$m = strtok($upload_max_filesize, 'M');
$k = strtok($upload_max_filesize, 'K');
if ($m !== false && is_numeric($m)) {
$upload_max_filesize = $m * 1048576;
} else if ($k !== false && is_numeric($k)) {
$upload_max_filesize = $k * 1024;
} else if (!is_numeric($upload_max_filesize)) {
$upload_max_filesize = '2097152';
}
foreach ($checkList as $fileChk => $fileTyp) {
if ($fileTyp == "File" && $fileChk != "/includes/settings.php") {
$content = file_get_contents(".." . $fileChk . "." . $dbtype);
if (write_file($content, ".." . $fileChk)) {
$block1->contentRow("<img src=\"ok.gif\"/>", "$fileTyp $fileChk copied.", "false", "");
} else {
$block1->contentRow("<img src=\"wrong.gif\"/>", "<b>$fileTyp $fileChk DID NOT copy.</b>", "false", "");
$error = true;
}
}
}
if (!$error) {
$htmlEntityCharset = version_compare(phpversion(), "5", ">=") == 1 ? 'UTF-8' : 'ISO-8859-1';
require_once('./setup_settings.php');
if (write_file($content, "../includes/settings.php")) {
$block1->contentRow("<img src=\"ok.gif\"/>", "File /includes/settings.php created.", "false", "");
} else {
$block1->contentRow("<img src=\"wrong.gif\"/>", "<b>File /includes/settings.php DID NOT create.</b>", "false", "");
$error = true;
}
}
if (!$error) {
if (version_compare(phpversion(), "5", ">=") == 1) {
$dirCpy = "/includes/jpgraph-2.3.3";
} else {
$dirCpy = "/includes/jpgraph-1.19";
}
if (dircpy(".." . $dirCpy, "../includes/jpgraph")) {
$block1->contentRow("<img src=\"ok.gif\"/>", "Files in /includes/jpgraph created.", "false", "");
} else {
$block1->contentRow("<img src=\"wrong.gif\"/>", "<b>Files in /includes/jpgraph DID NOT create.</b>", "false", "");
$error = true;
}
}
if (!$error) {
if (version_compare(phpversion(), "5", ">=") == 1) {
$dirCpy = "/includes/PHPMailer_v5.1";
} else {
$dirCpy = "/includes/PHPMailer_v2.0.4";
}
if (dircpy(".." . $dirCpy, "../includes/phpmailer")) {
$block1->contentRow("<img src=\"ok.gif\"/>", "Files in /includes/phpmailer created.", "false", "");
} else {
$block1->contentRow("<img src=\"wrong.gif\"/>", "<b>Files in /includes/phpmailer DID NOT create.</b>", "false", "");
$error = true;
}
}
if (!$error) {
$block1->contentRow("", "");
$block1->contentRow("", "Configuration data has been saved successfully.");
$submitName = "Create default upload folder";
echo "<input type=\"hidden\" name=\"root\" value=\"$root\">";
echo "<input type=\"hidden\" name=\"dbserver\" value=\"$dbserver\">";
echo "<input type=\"hidden\" name=\"dblogin\" value=\"$dblogin\">";
echo "<input type=\"hidden\" name=\"dbpasswd\" value=\"$dbpasswd\">";
echo "<input type=\"hidden\" name=\"dbname\" value=\"$dbname\">";
echo "<input type=\"hidden\" name=\"tbprefix\" value=\"$tbprefix\">";
echo "<input type=\"hidden\" name=\"adminLogin\" value=\"$adminLogin\">";
echo "<input type=\"hidden\" name=\"adminPwd\" value=\"$adminPwd\">";
echo "<input type=\"hidden\" name=\"loginMethod\" value=\"$loginMethod\">";
echo "<input type=\"hidden\" name=\"mkdirMethod\" value=\"$mkdirMethod\">";
echo "<input type=\"hidden\" name=\"ftpserver\" value=\"$ftpserver\">";
echo "<input type=\"hidden\" name=\"ftplogin\" value=\"$ftplogin\">";
echo "<input type=\"hidden\" name=\"ftppassword\" value=\"$ftppassword\">";
echo "<input type=\"hidden\" name=\"ftpRoot\" value=\"$ftpRoot\">";
echo "<input type=\"hidden\" name=\"step\" value=\"5\">";
} else {
$submitName = "Restart from the beginning";
echo "<input type=\"hidden\" name=\"step\" value=\"\">";
}
break;
case "5":
$root = $_REQUEST['root'];
$dbserver = $_REQUEST['dbserver'];
$dblogin = $_REQUEST['dblogin'];
$dbpasswd = $_REQUEST['dbpasswd'];
$dbname = $_REQUEST['dbname'];
$tbprefix = $_REQUEST['tbprefix'];
$adminLogin = $_REQUEST['adminLogin'];
$adminPwd = $_REQUEST['adminPwd'];
$loginMethod = $_REQUEST['loginMethod'];
$mkdirMethod = $_REQUEST['mkdirMethod'];
$ftpserver = $_REQUEST['ftpserver'];
$ftplogin = $_REQUEST['ftplogin'];
$ftppassword = $_REQUEST['ftppassword'];
$ftpRoot = $_REQUEST['ftpRoot'];
$block1->openLongList();
$block1->heading("Create default upload folder");
$block1->openContent();
$block1->contentTitle(" ");
if ($mkdirMethod == 'FTP') {
$ftp = ftp_connect($ftpserver);
if (!$ftp) {
$block1->contentRow("<img src=\"wrong.gif\"/>", "<b>Unable to connect to ftp server $ftpserver.</b>", "false", "");
$error = true;
} else {
$login_result = ftp_login($ftp, $ftplogin, $ftppassword);
if (!$login_result) {
$block1->contentRow("<img src=\"wrong.gif\"/>", "<b>Unable to logs in to ftp server $ftpserver.</b>", "false", "");
$error = true;
} else {
if (!@ftp_chdir($ftp, $ftpRoot . '/Default')) {
if (ftp_mkdir($ftp, $ftpRoot . '/Default')) {
$block1->contentRow("<img src=\"ok.gif\"/>", "Default upload folder created.", "false", "");
} else {
$block1->contentRow("<img src=\"wrong.gif\"/>", "<b>Default upload folder DID NOT create.</b>", "false", "");
$error = true;
}
}
}
ftp_close($ftp);
}
} else {
if (!is_dir('../files/Default')) {
if (!mkdir('../files/Default')) {
$block1->contentRow("<img src=\"wrong.gif\"/>", "<b>Default upload folder DID NOT create.</b>", "false", "");
$error = true;
} else {
$block1->contentRow("<img src=\"ok.gif\"/>", "Default upload folder created.", "false", "");
}
}
}
$block1->contentRow("", "");
echo "<input type=\"hidden\" name=\"root\" value=\"$root\">";
echo "<input type=\"hidden\" name=\"dbserver\" value=\"$dbserver\">";
echo "<input type=\"hidden\" name=\"dblogin\" value=\"$dblogin\">";
echo "<input type=\"hidden\" name=\"dbpasswd\" value=\"$dbpasswd\">";
echo "<input type=\"hidden\" name=\"dbname\" value=\"$dbname\">";
echo "<input type=\"hidden\" name=\"tbprefix\" value=\"$tbprefix\">";
echo "<input type=\"hidden\" name=\"adminLogin\" value=\"$adminLogin\">";
echo "<input type=\"hidden\" name=\"adminPwd\" value=\"$adminPwd\">";
echo "<input type=\"hidden\" name=\"loginMethod\" value=\"$loginMethod\">";
echo "<input type=\"hidden\" name=\"mkdirMethod\" value=\"$mkdirMethod\">";
echo "<input type=\"hidden\" name=\"ftpserver\" value=\"$ftpserver\">";
echo "<input type=\"hidden\" name=\"ftplogin\" value=\"$ftplogin\">";
echo "<input type=\"hidden\" name=\"ftppassword\" value=\"$ftppassword\">";
echo "<input type=\"hidden\" name=\"ftpRoot\" value=\"$ftpRoot\">";
if (!$error) {
$block1->contentRow("", "");
$block1->contentRow("", "Default upload folder has been created successfully.");
$submitName = "Check database";
echo "<input type=\"hidden\" name=\"step\" value=\"6\">";
} else {
$block1->contentRow("", "Please check the create folder method configuration.");
$submitName = "Reload";
echo "<input type=\"hidden\" name=\"step\" value=\"5\">";
}
break;
case "6":
$root = $_REQUEST['root'];
$dbserver = $_REQUEST['dbserver'];
$dblogin = $_REQUEST['dblogin'];
$dbpasswd = $_REQUEST['dbpasswd'];
$dbname = $_REQUEST['dbname'];
$tbprefix = $_REQUEST['tbprefix'];
$adminLogin = $_REQUEST['adminLogin'];
$adminPwd = $_REQUEST['adminPwd'];
$loginMethod = $_REQUEST['loginMethod'];
$block1->openLongList();
$block1->heading("Check database");
$block1->openContent();
$block1->contentTitle(" ");
require_once("./setup_db.php");
check_database();
$block1->contentRow("", "");
echo "<input type=\"hidden\" name=\"root\" value=\"$root\">";
echo "<input type=\"hidden\" name=\"dbserver\" value=\"$dbserver\">";
echo "<input type=\"hidden\" name=\"dblogin\" value=\"$dblogin\">";
echo "<input type=\"hidden\" name=\"dbpasswd\" value=\"$dbpasswd\">";
echo "<input type=\"hidden\" name=\"dbname\" value=\"$dbname\">";
echo "<input type=\"hidden\" name=\"tbprefix\" value=\"$tbprefix\">";
echo "<input type=\"hidden\" name=\"adminLogin\" value=\"$adminLogin\">";
echo "<input type=\"hidden\" name=\"adminPwd\" value=\"$adminPwd\">";
echo "<input type=\"hidden\" name=\"loginMethod\" value=\"$loginMethod\">";
if ($error) {
$block1->contentRow("", "Please check the database server and its configuration.");
$submitName = "Reload";
echo "<input type=\"hidden\" name=\"step\" value=\"6\">";
} else {
$block1->contentRow("", "No errors detected.");
$block1->contentRow("<input value=\"dump\" name=\"dump\" type=\"checkbox\" checked>", "Dump SQLs", "false", "");
$submitName = "Create tables";
echo "<input type=\"hidden\" name=\"step\" value=\"7\">";
}
break;
case "7":
$dump = isset($_REQUEST['dump'])?$_REQUEST['dump']:'';
$root = $_REQUEST['root'];
$dbserver = $_REQUEST['dbserver'];
$dblogin = $_REQUEST['dblogin'];
$dbpasswd = $_REQUEST['dbpasswd'];
$dbname = $_REQUEST['dbname'];
$tbprefix = $_REQUEST['tbprefix'];
$adminLogin = $_REQUEST['adminLogin'];
$adminPwdPlain = $_REQUEST['adminPwd'];
$loginMethod = $_REQUEST['loginMethod'];
$block1->openLongList();
$block1->heading("Create tables");
$block1->openContent();
$block1->contentTitle(" ");
$error = false;
// crypt admin password
$adminPwd = get_password($adminPwdPlain);
require_once("./setup_db.php");
create_tables();
if ($error) {
$submitName = "Check database again";
echo "<input type=\"hidden\" name=\"step\" value=\"6\">";
echo "<input type=\"hidden\" name=\"root\" value=\"$root\">";
echo "<input type=\"hidden\" name=\"dbserver\" value=\"$dbserver\">";
echo "<input type=\"hidden\" name=\"dblogin\" value=\"$dblogin\">";
echo "<input type=\"hidden\" name=\"dbpasswd\" value=\"$dbpasswd\">";
echo "<input type=\"hidden\" name=\"dbname\" value=\"$dbname\">";
echo "<input type=\"hidden\" name=\"tbprefix\" value=\"$tbprefix\">";
echo "<input type=\"hidden\" name=\"adminLogin\" value=\"$adminLogin\">";
echo "<input type=\"hidden\" name=\"adminPwd\" value=\"$adminPwdPlain\">";
echo "<input type=\"hidden\" name=\"loginMethod\" value=\"$loginMethod\">";
} else {
$block1->contentRow("", "");
$block1->contentRow("", "Database tables created.");
$submitName = "Finish";
echo "<input type=\"hidden\" name=\"root\" value=\"$root\">";
echo "<input type=\"hidden\" name=\"step\" value=\"8\">";
}
break;
case "8":
foreach ($dbTypList as $dbTyp) {
foreach ($checkList as $fileChk => $fileTyp) {
$pathName = ".." . $fileChk . "." . $dbTyp;
if ($fileTyp == "File" && $fileChk != "/includes/settings.php" && file_exists($pathName)) {
@unlink($pathName);
}
}
}
rmdirr('../includes/jpgraph-1.19');
rmdirr('../includes/jpgraph-2.3.3');
rmdirr('../includes/PHPMailer_v2.0.4');
rmdirr('../includes/PHPMailer_v5.1');
$root = $_REQUEST['root'];
$block1->openLongList();
$block1->heading("Installation Complete");
$block1->openContent();
$block1->contentTitle(" ");
$block1->contentRow("Your site", $block1->buildLink($root, "Click HERE to see the home page of your site.", "in"));
$block1->contentRow("Support", $block1->buildLink("http://netofficedwins.sourceforge.net", "Visit netOffice Dwins", "in"));
break;
}
if ($step != "8") {
$block1->contentRow("", "<input type=\"SUBMIT\" name=\"save\" value=\"$submitName\">");
}
$block1->closeContent();
$block1->closeForm();
$block1->closeLongList();
$footerDev = false;
require_once("../themes/" . THEME . "/footer.php");
function lang_strings($str)
{
return $str;
}
// Write file
function write_file($content, $dest)
{
$fp = @fopen($dest, 'wb+');
$fw = fwrite($fp, $content);
fclose($fp);
return $fw;
}
// Generates the unique [en|de]cryption key for your installation
function get_crypt_key()
{
srand((double)microtime()*1000000);
return(md5(uniqid(rand(),1)));
}
// return a password using the globally specified method
function get_password($newPassword)
{
global $loginMethod;
switch ($loginMethod) {
case "MD5":
return md5($newPassword);
case "CRYPT":
$salt = substr($newPassword, 0, 2);
return crypt($newPassword, $salt);
case "PLAIN":
return $newPassword;
default:
return $newPassword;
}
}
// copy a directory and all subdirectories and files (recursive)
// void dircpy( str 'source directory', str 'destination directory' [, bool 'overwrite existing files'] )
function dircpy($source, $dest, $overwrite = false){
if ($handle = opendir($source)) { // if the folder exploration is sucsessful, continue
while (false !== ($file = readdir($handle))) { // as long as storing the next file to $file is successful, continue
if ($file != '.' && $file != '..') {
$path = $source . '/' . $file;
if (is_file($path)) {
if (!is_file($dest . '/' . $file) || $overwrite)
if (!@copy($path, $dest . '/' . $file)) {
return false;
}
} elseif (is_dir($path)) {
if (!is_dir($dest . '/' . $file))
mkdir($dest . '/' . $file); // make subdirectory before subdirectory is copied
dircpy($path, $dest . '/' . $file, $overwrite); //recurse!
}
}
}
closedir($handle);
}
return true;
} // end of dircpy()
/**
* Delete a file, or a folder and its contents
*
* @author Aidan Lister <hide@address.com>
* @version 1.0.2
* @param string $dirname Directory to delete
* @return bool Returns TRUE on success, FALSE on failure
*/
function rmdirr($dirname)
{
// Sanity check
if (!file_exists($dirname)) {
return false;
}
// Simple delete for a file
if (is_file($dirname)) {
usleep(10);
return unlink($dirname);
}
// Loop through the folder
$dir = dir($dirname);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Recurse
rmdirr("$dirname/$entry");
}
// Clean up
$dir->close();
usleep(10);
return rmdir($dirname);
}
?>