<?php
require_once('session/start.php');
require_once('vhosts.php');
require_once('inc/security.php');
require_once('class/domain.php');
require_role(ROLE_SYSTEMUSER);
require_once("inc/debug.php");
global $debugmode;
if ($_GET['action'] == 'edit')
{
check_form_token('vhosts_edit_vhost');
$id = (int) $_GET['vhost'];
$vhost = empty_vhost();
if ($id != 0)
$vhost = get_vhost_details( $id );
DEBUG($vhost);
$hostname = filter_input_hostname($_POST['hostname'], true);
$domain_id = (int) $_POST['domain'];
if ($domain_id != -1) {
$domain = new Domain( (int) $_POST['domain'] );
$domain->ensure_userdomain();
$domain_id = $domain->id;
}
if (! (isset($_POST['options']) && is_array($_POST['options'])))
$_POST['options'] = array();
$aliaswww = in_array('aliaswww', $_POST['options']);
$docroot = '';
if ($_POST['vhost_type'] == 'regular' || $_POST['vhost_type'] == 'dav')
{
$defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domain->fqdn).'/htdocs';
$docroot = '';
if (isset($_POST['docroot']))
{
if (! check_path( $_POST['docroot'] ))
system_failure("Eingegebener Pfad enthält ungültige Angaben");
$docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
}
if ((isset($_POST['use_default_docroot']) && $_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
$docroot = '';