1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2007 Fabian Hickert
Copyright (C) 2011-2013 FusionDirectory
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Step_Finish extends setup_step
{
var $cfg_file_written = FALSE;
var $header_image = 'geticon.php?context=devices&icon=server&size=48';
function __construct()
{
$this->update_strings();
}
function update_strings()
{
$this->s_title = _("Finish");
$this->s_info = _("Write configuration file");
$this->s_title_long = _("Finish - write the configuration file");
}
function get_conf_data()
{
$smarty = get_smarty();
$smarty->assign("cv", xmlentities($this->parent->captured_values));
$smarty->assign("config_checksum", md5(file_get_contents(CONFIG_TEMPLATE_DIR.CONFIG_FILE)));
return $smarty->fetch(CONFIG_TEMPLATE_DIR.CONFIG_FILE);
}
function insertConfigDefaults()
{
/* Insert default config values, even for installed plugin */
global $config, $ui, $plist, $BASE_DIR;
$cv = $this->parent->captured_values;
/* Create config object */
$config = new config(CONFIG_DIR."/".CONFIG_FILE, $BASE_DIR);
$config->set_current($config->data['MAIN']['DEFAULT']);
/* Create ui object */
/* got user dn, fill acl's */
$ui = new userinfo($config, $cv['valid_admin']);
$ui->username = 'fd-admin';
/* Username is set, load subtreeACL's now */
$ui->loadACL();
/* We need the pluglist object */
load_all_classes();
$plist = new pluglist($config, $ui);
/* Now we can save LDAP config */
$config->loadPlist($plist);
$config->checkLdapConfig();
}
function execute()
{
global $BASE_DIR;
if (!function_exists("posix_getgrgid")) {
$webgroup = "";
} else {
$info = posix_getgrgid(posix_getgid());
$webgroup = $info['name'];
}
/* Check if there is currently an active fusiondirectory.conf
*/
$exists = file_exists(CONFIG_DIR."/".CONFIG_FILE);
/* Redirect to FusionDirectory login, if :
* - fusiondirectory.conf exists
* - Permisssion are set correctly
*/
if (isset($_POST['next']) && $exists && !$this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)) {
$this->insertConfigDefaults();
session::destroy();
header("Location: index.php");
exit();
}
/* Download config */
if (isset($_POST['getconf'])) {
send_binary_content($this->get_conf_data(), CONFIG_FILE, "text/plain");
}
$err_msg = "";
if ($exists && $this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)) {
$err_msg = _("Your configuration file is currently world readable. Please update the file permissions!");
} elseif (!$exists) {
$err_msg = _("The configuration is currently not readable or it does not exists.");
}
$smarty = get_smarty();
$smarty->assign("err_msg", $err_msg);
$smarty->assign("msg2", sprintf(_("After downloading and placing the file under %s, please make sure that the user the webserver is running with is able to read %s, while other users shouldn't."), CONFIG_DIR, CONFIG_FILE));
$smarty->assign("cv", $this->parent->captured_values);
return $smarty->fetch("$BASE_DIR/setup/setup_finish.tpl");
}
/* check if given file is world readable */
function is_world_readable($file)
{
clearstatcache();
$p = fileperms($file);
return (decbin($p & 4) == TRUE);
}
function save_object()
{
if (isset($_POST['step8_posted'])) {
/* Get attributes */
foreach ($this->attributes as $attr) {
if (isset($_POST[$attr])) {
$this->$attr = validate($_POST[$attr]);
}
}
}
}
}
?>
|