2001-07-30 17:59:25 +02:00
|
|
|
<?php
|
2006-05-29 04:56:16 +02:00
|
|
|
/**
|
|
|
|
* Setup
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @package setup
|
|
|
|
* @author Joseph Engo <jengo@phpgroupware.org>
|
|
|
|
* @author Dan Kuykendall <seek3r@phpgroupware.org>
|
|
|
|
* @author Mark Peters <skeeter@phpgroupware.org>
|
|
|
|
* @author Miles Lott <milos@groupwhere.org>
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
2001-07-30 17:59:25 +02:00
|
|
|
|
2004-03-09 22:05:28 +01:00
|
|
|
error_reporting(error_reporting() & ~E_NOTICE);
|
2005-03-04 15:44:21 +01:00
|
|
|
|
|
|
|
// for an old header, we need to setup the reference before including it
|
2005-03-25 10:21:23 +01:00
|
|
|
$GLOBALS['phpgw_info'] =& $GLOBALS['egw_info'];
|
|
|
|
|
2001-07-30 17:59:25 +02:00
|
|
|
if(file_exists('../header.inc.php'))
|
|
|
|
{
|
|
|
|
include('../header.inc.php');
|
|
|
|
}
|
2005-03-04 15:44:21 +01:00
|
|
|
// for an old header we need to setup a reference for the domains
|
|
|
|
if (!is_array($GLOBALS['egw_domain'])) $GLOBALS['egw_domain'] =& $GLOBALS['phpgw_domain'];
|
2003-08-28 16:31:11 +02:00
|
|
|
|
|
|
|
if (!function_exists('version_compare'))//version_compare() is only available in PHP4.1+
|
|
|
|
{
|
2003-10-10 01:08:04 +02:00
|
|
|
echo 'eGroupWare now requires PHP 4.1 or greater.<br>';
|
2003-08-28 16:31:11 +02:00
|
|
|
echo 'Please contact your System Administrator';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2002-03-03 22:53:00 +01:00
|
|
|
/* If we included the header.inc.php, but it is somehow broken, cover ourselves... */
|
2005-03-04 13:40:28 +01:00
|
|
|
if(!defined('EGW_SERVER_ROOT') && !defined('EGW_INCLUDE_ROOT'))
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2006-06-03 16:45:49 +02:00
|
|
|
if (defined('PHPGW_SERVER_ROOT') && defined('PHPGW_INCLUDE_ROOT')) // pre 1.2 install
|
|
|
|
{
|
|
|
|
define('EGW_SERVER_ROOT',PHPGW_SERVER_ROOT);
|
|
|
|
define('EGW_INCLUDE_ROOT',PHPGW_INCLUDE_ROOT);
|
|
|
|
}
|
|
|
|
else // no install
|
|
|
|
{
|
|
|
|
define('EGW_SERVER_ROOT','..');
|
|
|
|
define('EGW_INCLUDE_ROOT','..');
|
|
|
|
define('PHPGW_SERVER_ROOT','..');
|
|
|
|
define('PHPGW_INCLUDE_ROOT','..');
|
|
|
|
}
|
2006-05-31 03:55:13 +02:00
|
|
|
define('EGW_API_INC',EGW_SERVER_ROOT.'/phpgwapi/inc');
|
2001-07-30 17:59:25 +02:00
|
|
|
}
|
|
|
|
|
2005-09-01 19:10:09 +02:00
|
|
|
require(EGW_INCLUDE_ROOT . '/phpgwapi/inc/common_functions.inc.php');
|
2001-07-30 17:59:25 +02:00
|
|
|
|
|
|
|
define('SEP',filesystem_separator());
|
|
|
|
|
2005-11-14 15:51:58 +01:00
|
|
|
/**
|
|
|
|
* Checks if a directory exists, is writable by the webserver and optionaly is in the docroot
|
|
|
|
*
|
|
|
|
* @param string $dir path
|
|
|
|
* @param string &$msg error-msg: 'does not exist', 'is not writeable by the webserver' or 'is in the webservers docroot' (run through lang)
|
|
|
|
* @param boolean $check_in_docroot=false run an optional in docroot check
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
function check_dir($dir,&$msg,$check_in_docroot=false)
|
|
|
|
{
|
2006-07-09 19:24:43 +02:00
|
|
|
if (!@is_dir($dir) && !@mkdir($dir,0700,true))
|
2005-11-14 15:51:58 +01:00
|
|
|
{
|
|
|
|
$msg = lang('does not exist');
|
|
|
|
return false;
|
|
|
|
}
|
2006-05-29 04:56:16 +02:00
|
|
|
if (!@is_writeable($dir) && $_SERVER['HTTP_HOST']) // only do the check if we run by the webserver
|
2005-11-14 15:51:58 +01:00
|
|
|
{
|
|
|
|
$msg = lang('is not writeable by the webserver');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ($check_in_docroot)
|
|
|
|
{
|
2007-02-11 13:04:15 +01:00
|
|
|
$docroots = array(realpath(EGW_SERVER_ROOT),realpath($_SERVER['DOCUMENT_ROOT']));
|
2005-11-14 15:51:58 +01:00
|
|
|
$dir = realpath($dir);
|
|
|
|
|
|
|
|
foreach ($docroots as $docroot)
|
|
|
|
{
|
|
|
|
$len = strlen($docroot);
|
|
|
|
|
2007-09-19 14:23:07 +02:00
|
|
|
if ($docroot == substr($dir,0,$len) && $len>0)
|
2005-11-14 15:51:58 +01:00
|
|
|
{
|
|
|
|
$rest = substr($dir,$len);
|
|
|
|
|
|
|
|
if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR)
|
|
|
|
{
|
|
|
|
$msg = lang('is in the webservers docroot');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-03-24 14:15:12 +01:00
|
|
|
/**
|
2006-02-24 04:06:40 +01:00
|
|
|
* function to handle multilanguage support
|
|
|
|
*
|
2005-03-24 14:15:12 +01:00
|
|
|
*/
|
2006-02-24 04:06:40 +01:00
|
|
|
function lang($key,$vars=null)
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2006-02-24 04:06:40 +01:00
|
|
|
if(!is_array($vars))
|
2001-09-17 04:10:34 +02:00
|
|
|
{
|
2006-02-24 04:06:40 +01:00
|
|
|
$vars = func_get_args();
|
|
|
|
array_shift($vars); // remove $key
|
2001-09-17 04:10:34 +02:00
|
|
|
}
|
2006-02-24 04:06:40 +01:00
|
|
|
return $GLOBALS['egw_setup']->translation->translate("$key", $vars);
|
2001-07-30 17:59:25 +02:00
|
|
|
}
|
|
|
|
|
2005-03-24 14:15:12 +01:00
|
|
|
/**
|
|
|
|
* returns array of languages we support, with enabled set to True if the lang file exists
|
|
|
|
*/
|
2001-07-30 17:59:25 +02:00
|
|
|
function get_langs()
|
|
|
|
{
|
2002-03-03 22:53:00 +01:00
|
|
|
$f = fopen('./lang/languages','rb');
|
|
|
|
while($line = fgets($f,200))
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
|
|
|
list($x,$y) = split("\t",$line);
|
|
|
|
$languages[$x]['lang'] = trim($x);
|
|
|
|
$languages[$x]['descr'] = trim($y);
|
|
|
|
$languages[$x]['available'] = False;
|
|
|
|
}
|
|
|
|
fclose($f);
|
|
|
|
|
|
|
|
$d = dir('./lang');
|
2004-07-10 12:59:37 +02:00
|
|
|
while($file=$d->read())
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2004-07-10 12:59:37 +02:00
|
|
|
if(preg_match('/^phpgw_([-a-z]+).lang$/i',$file,$matches))
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2004-07-10 12:59:37 +02:00
|
|
|
$languages[$matches[1]]['available'] = True;
|
2001-07-30 17:59:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$d->close();
|
|
|
|
|
|
|
|
//print_r($languages);
|
|
|
|
return $languages;
|
|
|
|
}
|
|
|
|
|
2003-09-23 15:08:40 +02:00
|
|
|
function lang_select($onChange=False,$ConfigLang='')
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2003-09-23 15:08:40 +02:00
|
|
|
if (!$ConfigLang)
|
|
|
|
{
|
|
|
|
$ConfigLang = get_var('ConfigLang',Array('POST','COOKIE'));
|
|
|
|
}
|
2005-07-11 20:02:19 +02:00
|
|
|
$select = '<select name="ConfigLang"'.($onChange ? ' onchange="this.form.submit();"' : '').'>' . "\n";
|
2001-07-30 17:59:25 +02:00
|
|
|
$languages = get_langs();
|
2004-07-10 11:25:53 +02:00
|
|
|
usort($languages,create_function('$a,$b','return strcmp(@$a[\'descr\'],@$b[\'descr\']);'));
|
2003-09-23 15:08:40 +02:00
|
|
|
foreach($languages as $data)
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
if($data['available'] && !empty($data['lang']))
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
|
|
|
$short = substr($data['lang'],0,2);
|
2007-03-19 10:53:03 +01:00
|
|
|
if ($short == $ConfigLang || $data['lang'] == $ConfigLang || empty($ConfigLang) && $short == substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2))
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2007-03-19 10:53:03 +01:00
|
|
|
$selected = ' selected';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$selected = '';
|
2001-07-30 17:59:25 +02:00
|
|
|
}
|
|
|
|
$select .= '<option value="' . $data['lang'] . '"' . $selected . '>' . $data['descr'] . '</option>' . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$select .= '</select>' . "\n";
|
|
|
|
|
|
|
|
return $select;
|
|
|
|
}
|
|
|
|
|
2005-03-04 13:40:28 +01:00
|
|
|
if(file_exists(EGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'))
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
include(EGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'); /* To set the current core version */
|
2001-09-17 04:10:34 +02:00
|
|
|
/* This will change to just use setup_info */
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['server']['versions']['current_header'] = $setup_info['phpgwapi']['versions']['current_header'];
|
2001-07-30 17:59:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['server']['versions']['phpgwapi'] = 'Undetected';
|
2001-07-30 17:59:25 +02:00
|
|
|
}
|
|
|
|
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info']['server']['app_images'] = 'templates/default/images';
|
2001-07-30 17:59:25 +02:00
|
|
|
|
2005-12-01 16:23:49 +01:00
|
|
|
CreateObject('setup.setup',True,True); // setup constuctor assigns itself to $GLOBALS['egw_setup'], doing it twice fails on some php4
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['phpgw_setup'] =& $GLOBALS['egw_setup'];
|