2002-12-07 03:12:15 +01:00
|
|
|
<?php
|
2008-10-02 17:30:44 +02:00
|
|
|
/**
|
2016-05-01 17:56:49 +02:00
|
|
|
* EGroupware Setup
|
2008-10-02 17:30:44 +02:00
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @package setup
|
|
|
|
* @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$
|
|
|
|
*/
|
2002-12-07 03:12:15 +01:00
|
|
|
|
2016-05-01 17:56:49 +02:00
|
|
|
use EGroupware\Api;
|
|
|
|
|
2008-10-02 17:30:44 +02:00
|
|
|
/**
|
|
|
|
* Get the options for vfs_storage_mode, select the right one depending on vfs_fstab
|
|
|
|
*
|
|
|
|
* @param array $config
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function vfs_storage_mode_options($config)
|
|
|
|
{
|
2014-06-27 09:48:44 +02:00
|
|
|
if (!isset($config['vfs_fstab']) || $config['vfs_fstab'] == json_encode($default=array(
|
2008-10-02 17:30:44 +02:00
|
|
|
'/' => 'sqlfs://$host/',
|
|
|
|
'/apps' => 'links://$host/apps',
|
2014-06-27 09:48:44 +02:00
|
|
|
)) || $config['vfs_fstab'] == serialize($default)) // detect old serialized value too
|
2008-10-02 17:30:44 +02:00
|
|
|
{
|
|
|
|
$config['vfs_storage_mode'] = 'fs';
|
|
|
|
}
|
2014-06-27 09:48:44 +02:00
|
|
|
elseif($config['vfs_fstab'] == json_encode($default_db=array(
|
2008-10-02 17:30:44 +02:00
|
|
|
'/' => 'sqlfs://$host/?storage=db',
|
|
|
|
'/apps' => 'links://$host/apps?storage=db',
|
2014-06-27 09:48:44 +02:00
|
|
|
)) || $config['vfs_fstab'] == serialize($default_db)) // detect old serialized value too
|
2008-10-02 17:30:44 +02:00
|
|
|
{
|
|
|
|
$config['vfs_storage_mode'] = 'db';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$config['vfs_storage_mode'] = 'custom';
|
|
|
|
}
|
|
|
|
//_debug_array(array_intersect_key($config,array('vfs_fstab'=>1,'vfs_storage_mode'=>1)));
|
|
|
|
foreach(array(
|
|
|
|
'fs' => lang('Filesystem (default)'),
|
|
|
|
'db' => lang('Database').' (problems with files > 1MB)',
|
|
|
|
'custom' => lang('Custom set via %1','filemanager/cli.php mount'),
|
|
|
|
) as $name => $label)
|
|
|
|
{
|
2011-03-07 15:15:44 +01:00
|
|
|
if ($name != 'custom' || $name === $config['vfs_storage_mode']) // dont show custom, if not custom
|
|
|
|
{
|
|
|
|
$options .= '<option value="'.$name.($name === $config['vfs_storage_mode'] ? '" selected="selected' : '').
|
|
|
|
'">'.htmlspecialchars($label)."</options>\n";
|
|
|
|
}
|
2008-10-02 17:30:44 +02:00
|
|
|
}
|
|
|
|
//echo "<pre>".htmlspecialchars($options)."</pre>\n";
|
|
|
|
return $options;
|
|
|
|
}
|
2002-12-07 03:12:15 +01:00
|
|
|
|
2008-10-02 17:30:44 +02:00
|
|
|
function encryptalgo($config)
|
|
|
|
{
|
|
|
|
if(@function_exists('mcrypt_list_algorithms'))
|
2002-12-07 03:12:15 +01:00
|
|
|
{
|
2008-10-02 17:30:44 +02:00
|
|
|
$listed = array();
|
|
|
|
if(!isset($config['mcrypt_algo']))
|
2002-12-07 03:12:15 +01:00
|
|
|
{
|
2008-10-02 17:30:44 +02:00
|
|
|
$config['mcrypt_algo'] = 'tripledes'; /* MCRYPT_TRIPLEDES */
|
|
|
|
}
|
|
|
|
$algos = @mcrypt_list_algorithms();
|
|
|
|
$found = False;
|
2002-12-07 03:12:15 +01:00
|
|
|
|
2008-10-02 17:30:44 +02:00
|
|
|
$out = '';
|
2019-02-12 22:13:45 +01:00
|
|
|
foreach($algos as $key => $value)
|
2008-10-02 17:30:44 +02:00
|
|
|
{
|
|
|
|
$found = True;
|
|
|
|
/* Only show each once - seems this is a problem in some installs */
|
|
|
|
if(!in_array($value,$listed))
|
2002-12-07 03:12:15 +01:00
|
|
|
{
|
2008-10-02 17:30:44 +02:00
|
|
|
if($config['mcrypt_algo'] == $value)
|
2002-12-07 03:12:15 +01:00
|
|
|
{
|
2008-10-02 17:30:44 +02:00
|
|
|
$selected = ' selected="selected"';
|
2002-12-07 03:12:15 +01:00
|
|
|
}
|
2008-10-02 17:30:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$selected = '';
|
|
|
|
}
|
|
|
|
$descr = strtoupper($value);
|
|
|
|
|
|
|
|
$out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n";
|
|
|
|
$listed[] = $value;
|
2002-12-07 03:12:15 +01:00
|
|
|
}
|
|
|
|
}
|
2008-10-02 17:30:44 +02:00
|
|
|
if(!$found)
|
2002-12-07 03:12:15 +01:00
|
|
|
{
|
2008-10-02 17:30:44 +02:00
|
|
|
/* Something is wrong with their mcrypt install or php.ini */
|
2014-06-27 09:48:44 +02:00
|
|
|
$out = '<option value="">' . lang('no algorithms available') . '</option>' . "\n";
|
2002-12-07 03:12:15 +01:00
|
|
|
}
|
|
|
|
}
|
2008-10-02 17:30:44 +02:00
|
|
|
else
|
|
|
|
{
|
2014-06-27 09:48:44 +02:00
|
|
|
$out = '<option value="tripledes">TRIPLEDES</option>' . "\n";
|
2008-10-02 17:30:44 +02:00
|
|
|
}
|
|
|
|
return $out;
|
|
|
|
}
|
2002-12-07 03:12:15 +01:00
|
|
|
|
2008-10-02 17:30:44 +02:00
|
|
|
function encryptmode($config)
|
|
|
|
{
|
|
|
|
if(@function_exists('mcrypt_list_modes'))
|
2002-12-07 03:12:15 +01:00
|
|
|
{
|
2008-10-02 17:30:44 +02:00
|
|
|
$listed = array();
|
|
|
|
if(!isset($config['mcrypt_mode']))
|
2002-12-07 03:12:15 +01:00
|
|
|
{
|
2008-10-02 17:30:44 +02:00
|
|
|
$config['mcrypt_mode'] = 'cbc'; /* MCRYPT_MODE_CBC */
|
|
|
|
}
|
|
|
|
$modes = @mcrypt_list_modes();
|
|
|
|
$found = False;
|
2002-12-07 03:12:15 +01:00
|
|
|
|
2008-10-02 17:30:44 +02:00
|
|
|
$out = '';
|
2019-02-12 22:13:45 +01:00
|
|
|
foreach($modes as $key => $value)
|
2008-10-02 17:30:44 +02:00
|
|
|
{
|
|
|
|
$found = True;
|
|
|
|
/* Only show each once - seems this is a problem in some installs */
|
|
|
|
if(!in_array($value,$listed))
|
2002-12-07 03:12:15 +01:00
|
|
|
{
|
2008-10-02 17:30:44 +02:00
|
|
|
if($config['mcrypt_mode'] == $value)
|
2002-12-07 03:12:15 +01:00
|
|
|
{
|
2008-10-02 17:30:44 +02:00
|
|
|
$selected = ' selected="selected"';
|
2002-12-07 03:12:15 +01:00
|
|
|
}
|
2008-10-02 17:30:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$selected = '';
|
|
|
|
}
|
|
|
|
$descr = strtoupper($value);
|
|
|
|
|
|
|
|
$out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n";
|
|
|
|
$listed[] = $value;
|
2002-12-07 03:12:15 +01:00
|
|
|
}
|
|
|
|
}
|
2008-10-02 17:30:44 +02:00
|
|
|
if(!$found)
|
2002-12-07 03:12:15 +01:00
|
|
|
{
|
2008-10-02 17:30:44 +02:00
|
|
|
/* Something is wrong with their mcrypt install or php.ini */
|
|
|
|
$out = '<option value="" selected="selected">' . lang('no modes available') . '</option>' . "\n";
|
2002-12-07 03:12:15 +01:00
|
|
|
}
|
|
|
|
}
|
2008-10-02 17:30:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$out = '<option value="cbc" selected="selected">CBC</option>' . "\n";
|
|
|
|
}
|
|
|
|
return $out;
|
|
|
|
}
|
2002-12-07 03:12:15 +01:00
|
|
|
|
2011-04-01 16:00:25 +02:00
|
|
|
function passwdhashes($config,$return_hashes=false)
|
2008-10-02 17:30:44 +02:00
|
|
|
{
|
2011-06-06 01:22:51 +02:00
|
|
|
$hashes = sql_passwdhashes($config,true);
|
|
|
|
if (isset($hashes['crypt']))
|
2008-10-02 17:30:44 +02:00
|
|
|
{
|
2011-06-06 01:22:51 +02:00
|
|
|
$hashes['des'] = 'des (=crypt)'; // old LDAP name for crypt
|
2008-10-02 17:30:44 +02:00
|
|
|
}
|
2011-05-04 22:19:59 +02:00
|
|
|
return $return_hashes ? $hashes : _options_from($hashes, $config['ldap_encryption_type'] ? $config['ldap_encryption_type'] : 'des');
|
2008-10-02 17:30:44 +02:00
|
|
|
}
|
2002-12-07 03:12:15 +01:00
|
|
|
|
2011-06-06 01:22:51 +02:00
|
|
|
function sql_passwdhashes($config, $return_hashes=false, &$securest=null)
|
2008-10-02 17:30:44 +02:00
|
|
|
{
|
2016-05-01 17:56:49 +02:00
|
|
|
$hashes = Api\Auth::passwdhashes($securest);
|
2011-06-06 01:22:51 +02:00
|
|
|
|
2011-05-04 19:57:12 +02:00
|
|
|
return $return_hashes ? $hashes : _options_from($hashes, $config['sql_encryption_type'] ? $config['sql_encryption_type'] : 'md5');
|
2008-10-02 17:30:44 +02:00
|
|
|
}
|
2010-08-31 12:13:28 +02:00
|
|
|
|
2010-09-10 11:26:17 +02:00
|
|
|
/**
|
|
|
|
* Make auth-types from setup_cmd_config available
|
2011-03-07 15:15:44 +01:00
|
|
|
*
|
2010-09-10 11:26:17 +02:00
|
|
|
* @param array $config
|
|
|
|
* @return string
|
|
|
|
*/
|
2014-07-03 14:46:08 +02:00
|
|
|
function auth_types($config)
|
2010-09-10 11:26:17 +02:00
|
|
|
{
|
|
|
|
return _options_from(setup_cmd_config::auth_types(),$config['auth_type']);
|
|
|
|
}
|
|
|
|
function auth_type_groupdav($config)
|
|
|
|
{
|
|
|
|
return _options_from(setup_cmd_config::auth_types(),$config['auth_type_groupdav']);
|
|
|
|
}
|
2011-03-28 19:29:07 +02:00
|
|
|
function auth_type_activesync($config)
|
|
|
|
{
|
|
|
|
return _options_from(setup_cmd_config::auth_types(),$config['auth_type_activesync']);
|
|
|
|
}
|
2020-05-28 23:23:54 +02:00
|
|
|
function auth_type_host($config)
|
|
|
|
{
|
|
|
|
return _options_from(setup_cmd_config::auth_types(),$config['auth_type_host']);
|
|
|
|
}
|
2010-09-10 11:26:17 +02:00
|
|
|
|
2014-11-05 21:27:52 +01:00
|
|
|
/**
|
|
|
|
* Make account-repository-types from setup_cmd_config available
|
|
|
|
*
|
|
|
|
* @param array $config
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function account_repository($config)
|
|
|
|
{
|
2014-11-06 20:21:56 +01:00
|
|
|
return _options_from(setup_cmd_config::account_repositories($config['account_repository']), $config['account_repository']);
|
2014-11-05 21:27:52 +01:00
|
|
|
}
|
|
|
|
|
2010-09-10 11:26:17 +02:00
|
|
|
/**
|
|
|
|
* Returns options string
|
2011-03-07 15:15:44 +01:00
|
|
|
*
|
2010-09-10 11:26:17 +02:00
|
|
|
* @param array $options value => label pairs
|
|
|
|
* @param string $selected value of selected optino
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function _options_from(array $options,$selected)
|
|
|
|
{
|
|
|
|
foreach($options as $value => $label)
|
2010-08-31 12:13:28 +02:00
|
|
|
{
|
2011-03-07 15:15:44 +01:00
|
|
|
$out .= '<option value="' . htmlspecialchars($value) . '"' .
|
2010-09-10 11:26:17 +02:00
|
|
|
($selected == $value ? ' selected="selected"' : '') . '>' . $label . '</option>' . "\n";
|
2010-08-31 12:13:28 +02:00
|
|
|
}
|
|
|
|
return $out;
|
|
|
|
}
|