Exemple #1
0
function alias_add()
{
    $free = new freeweb($_POST["servername"]);
    writelogs("Add ServerAlias {$_POST["AddAlias"]} -> {$_POST["servername"]}", __FUNCTION__, __FILE__, __LINE__);
    $free->Params["ServerAlias"][$_POST["AddAlias"]] = true;
    $free->SaveParams();
}
Exemple #2
0
function SaveWebCache()
{
    $freeweb = new freeweb($_POST["servername"]);
    while (list($num, $ligne) = each($_POST)) {
        $freeweb->Params["MOD_CACHE"][$num] = $ligne;
    }
    $freeweb->SaveParams();
}
Exemple #3
0
function save()
{
    $free = new freeweb($_POST["servername"]);
    $CONF = $free->Params["PageSpeedParams"];
    while (list($num, $ligne) = each($_POST)) {
        $free->Params["PageSpeedParams"][$num] = $ligne;
    }
    $free->SaveParams();
}
function alias_popup()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $free = new freeweb($_GET["servername"]);
    $t = $_GET["t"];
    $free->CheckWorkingDirectory();
    $direnc = urlencode(base64_encode($free->WORKING_DIRECTORY));
    $users = new usersMenus();
    $html = "\n\n\t<div id='alias-animate-{$t}'></div>\n\t<div class=text-info style='font-size:14px'>{freeweb_openbasedir_explain}</div>\n\t\n\t<table style='width:99%' class=form>\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{directory}:</td>\n\t\t<td>" . Field_text("alias_dir-{$t}", null, "font-size:16px;padding:3px;width:320px", null, null, null, false, "FreeWebAddAliasCheck{$t}(event)") . "&nbsp;<input type='button' OnClick=\"javascript:Loadjs('browse-disk.php?start-root=/&field=alias_dir-{$t}');\" style='font-size:16px' value='{browse}...'></td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=2 align='right'><hr>" . button("{add} {directory}", "FreeWebAddAlias{$t}()", "18px") . "</td>\n\t</tr>\n\t</table>\n\t\n\t<script>\n\t\tvar x_FreeWebAddAlias{$t}=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tdocument.getElementById('alias-animate-{$t}').innerHTML='';\n\t\t\tif(results.length>3){alert(results);return;}\t\n\t\t\t\n\t\t\t\$('#flexRT{$t}').flexReload();\n\t\t}\n\n\t\tfunction FreeWebAddAliasCheck{$t}(e){\n\t\t\tif(checkEnter(e)){FreeWebAddAlias{$t}();}\n\t\t\n\t\t}\n\t\t\n\n\t\tfunction FreeWebAddAlias{$t}(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tvar directory=document.getElementById('alias_dir-{$t}').value;\n\t\t\tif(directory.length<2){return;}\t\t\n\t\t\tXHR.appendData('directory',directory);\n\t\t\tXHR.appendData('servername','{$_GET["servername"]}');\n\t\t\tAnimateDiv('alias-animate-{$t}');\n    \t\tXHR.sendAndLoad('{$page}', 'POST',x_FreeWebAddAlias{$t});\t\t\t\n\t\t}\n\t</script>\t\n\t\n\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Exemple #5
0
function page()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $free = new freeweb($_GET["servername"]);
    if ($free->groupware != null) {
        echo $tpl->_ENGINE_parse_body("<div class=explain>{freeweb_is_groupware_feature_disabled}</div>");
        return;
    }
    $free->CheckWorkingDirectory();
    $direnc = urlencode(base64_encode($free->WORKING_DIRECTORY));
    $html = "<div class=explain>{freeweb_alias_explain}</div>\n\t\n\t<table style='width:100%' class=form>\n\t<tr>\n\t\t<td class=legend>{alias}:</td>\n\t\t<td>" . Field_text("alias_freeweb", null, "font-size:16px;padding:3px;width:220px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend>{directory}:</td>\n\t\t<td>" . Field_text("alias_dir", null, "font-size:16px;padding:3px;width:320px", null, null, null, false, "FreeWebAddAliasCheck(event)") . "&nbsp;<input type='button' OnClick=\"javascript:Loadjs('browse-disk.php?start-root={$direnc}&field=alias_dir&replace-start-root=1');\" value='{browse}...'></td>\n\t</tr>\t\n\t<tr>\n\t\t<td colspan=2 align='right'><hr>" . button("{add} {alias}", "FreeWebAddAlias()") . "</td>\n\t</tr>\n\t</table>\n\t<p>&nbsp;</p>\n\t<div id='freeweb-aliases-list' style='width:100%;heigth:350px;overflow:auto'></div>\n\t\n\t\n\t\n\t<script>\n\t\tvar x_FreeWebAddAlias=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);}\t\n\t\t\tFreeWebAliasList();\t\n\t\t}\t\t\t\n\t\t\n\t\tfunction FreeWebAddAliasCheck(e){\n\t\t\tif(checkEnter(e)){FreeWebAddAlias();}\n\t\t}\n\t\t\n\t\tfunction FreeWebAddAlias(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tvar Alias=document.getElementById('alias_freeweb').value;\n\t\t\tif(Alias.length<2){return;}\n\t\t\tvar directory=document.getElementById('alias_dir').value;\n\t\t\tif(directory.length<2){return;}\t\t\t\n\t\t\tXHR.appendData('Alias',document.getElementById('alias_freeweb').value);\n\t\t\tXHR.appendData('directory',document.getElementById('alias_dir').value);\n\t\t\tXHR.appendData('servername','{$_GET["servername"]}');\n\t\t\tAnimateDiv('freeweb-aliases-list');\n    \t\tXHR.sendAndLoad('{$page}', 'POST',x_FreeWebAddAlias);\t\t\t\n\t\t}\n\t\t\n\t\tfunction FreeWebDelAlias(id){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('DelAlias',id);\n\t\t\tXHR.appendData('servername','{$_GET["servername"]}');\n\t\t\tAnimateDiv('freeweb-aliases-list');\n    \t\tXHR.sendAndLoad('{$page}', 'POST',x_FreeWebAddAlias);\t\t\t\n\t\t}\t\t\n\t\t\n\t\tfunction FreeWebAliasList(){\n\t\t\tLoadAjax('freeweb-aliases-list','{$page}?freeweb-aliases-list=yes&servername={$_GET["servername"]}');\n\t\t}\n\tFreeWebAliasList();\n\t</script>\n\t\n\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
function Save()
{
    $free = new freeweb($_POST["servername"]);
    $_POST["BandwidthAll"] = intval($_POST["BandwidthAll"]) * 1024;
    while (list($num, $ligne) = each($_POST)) {
        $free->Params["ModeBw"][$num] = $ligne;
    }
    $q = new mysql();
    $q->QUERY_SQL("UPDATE freeweb SET `bandlimit`='{$_POST["bandlimit"]}' WHERE servername='{$_POST["servername"]}'", "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $free->SaveParams();
}
function authip_enable()
{
    $freeweb = new freeweb($_POST["servername"]);
    $freeweb->Params["LimitByIp"]["enabled"] = $_POST["LimitByIp"];
    $freeweb->SaveParams();
}
function DosEngineSave()
{
    $freeweb = new freeweb($_POST["servername"]);
    while (list($num, $ligne) = each($_POST)) {
        $freeweb->Params["mod_evasive"][$num] = $ligne;
    }
    $freeweb->SaveParams();
}
function SaveWebQOS()
{
    $sql = "SELECT * FROM freeweb WHERE servername='{$_GET["servername"]}'";
    $page = CurrentPageName();
    $tpl = new templates();
    $free = new freeweb($_GET["servername"]);
    while (list($num, $ligne) = each($_GET)) {
        $free->Params["QOS"][$num] = $ligne;
    }
    $free->SaveParams();
}
function create_groupwares()
{
    include_once dirname(__FILE__) . "/ressources/class.freeweb.inc";
    $ldap = new clladp();
    $tpl = new templates();
    $sock = new sockets();
    $page = CurrentPageName();
    $q = new mysql();
    $EnableVirtualDomainsInMailBoxes = $sock->GET_INFO("EnableVirtualDomainsInMailBoxes");
    $sql = "SELECT * FROM register_orgs WHERE `zmd5`='{$_GET["key"]}'";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    $ou = $ligne["ou"];
    if ($ligne["ou"] == null) {
        echo $tpl->_ENGINE_parse_body("{please_register_first}");
        return;
    }
    $domain = $ligne["domain"];
    $user = $ligne["username"];
    $uid = $user;
    if ($EnableVirtualDomainsInMailBoxes == 1) {
        $uid = "{$user}@{$domain}";
    }
    $password = $ligne["password"];
    $freeweb = new freeweb();
    $freeweb->servername = "admin.{$domain}";
    $freeweb->ou = $ou;
    $freeweb->uid = $uid;
    $freeweb->groupware = "ARTICA_MINIADM";
    if ($freeweb->CreateSite()) {
        $html = "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/42-green.png'></td>\n\t\t\t<td valign='top' style='font-size:16px'>{website}: admin.{$domain} {ARTICA_MINIADM} {success}</td>\n\t\t</tr>\n\t\t</table>\n\t\t";
    } else {
        $html = "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/42-red.png'></td>\n\t\t\t<td valign='top' style='font-size:16px'>{website}: admin.{$domain} {ARTICA_MINIADM} {failed}</td>\n\t\t</tr>\n\t\t</table>\n\t\t";
    }
    $users = new usersMenus();
    if ($users->ZARAFA_INSTALLED) {
        $freeweb = new freeweb();
        $freeweb->servername = "webmail.{$domain}";
        $freeweb->ou = $ou;
        $freeweb->uid = $uid;
        $freeweb->groupware = "ZARAFA";
        if ($freeweb->CreateSite()) {
            $html = $html . "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/42-green.png'></td>\n\t\t\t<td valign='top' style='font-size:16px'>{webmail}: webmail.{$domain} {APP_ZARAFA} {success}</td>\n\t\t</tr>\n\t\t</table>\n\t\t";
        } else {
            $html = $html . "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/42-red.png'></td>\n\t\t\t<td valign='top' style='font-size:16px'>{website}: webmail.{$domain} {APP_ZARAFA} {failed}</td>\n\t\t</tr>\n\t\t</table>\n\t\t";
        }
    }
    $html = $html . "\n\t<script>\n\tLoadAjax('conclusion','{$page}?create-conclusion=yes&key={$_GET["key"]}');\n\t</script>";
    echo $tpl->_ENGINE_parse_body($html);
}
Exemple #11
0
function configure_single_freeweb($servername)
{
    $q = new mysql();
    $unix = new unix();
    $php = $unix->LOCATE_PHP5_BIN();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * from freeweb WHERE servername='{$servername}'", "artica_backup"));
    $free = new freeweb($servername);
    $NginxFrontEnd = $free->NginxFrontEnd;
    $groupware = $free->groupware;
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, {$servername} [{$groupware}]\n";
    }
    $NOPROXY["SARG"] = true;
    $NOPROXY["ARTICA_MINIADM"] = true;
    $NOPROXY["WORDPRESS"] = true;
    $NOPROXY[null] = true;
    $q2 = new mysql_squid_builder();
    $ligne2 = mysql_fetch_array($q2->QUERY_SQL("SELECT cacheid FROM reverse_www WHERE servername='{$ligne["servername"]}'"));
    $host = new nginx($servername);
    if (isset($NOPROXY[$groupware])) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, {$servername} compile as FRONT-END\n";
        }
        $free->CheckWorkingDirectory();
        $host->set_proxy_disabled();
        $host->set_DocumentRoot($free->WORKING_DIRECTORY);
        if ($groupware == "SARG") {
            $host->SargDir();
        }
        if ($groupware == "WORDPRESS") {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx,{$php} /usr/share/artica-postfix/exec.wordpress.php \"{$servername}\"\n";
            }
            system("{$php} /usr/share/artica-postfix/exec.wordpress.php \"{$servername}\"");
            $host->WORDPRESS = true;
            $host->set_index_file("index.php");
        }
    } else {
        $host->set_freeweb();
        $host->set_storeid($ligne2["cacheid"]);
    }
    if ($free->groupware == "Z-PUSH") {
        $host->NoErrorPages = true;
    }
    if ($free->groupware == "WORDPRESS") {
        $host->WORDPRESS = true;
    }
    $host->set_servers_aliases($free->Params["ServerAlias"]);
    if ($groupware == "ZARAFA") {
        if ($free->NginxFrontEnd == 1) {
            $host->groupware_zarafa_Frontend();
            configure_single_website_rebuild();
            configure_single_website_reload();
            return;
        }
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, {$servername} building configuration...\n";
    }
    $host->build_proxy();
    configure_single_website_rebuild();
    configure_single_website_reload();
}
Exemple #12
0
function add_default_site(){
	$free=new freeweb();
	$free->AddDefaultSite();
}
Exemple #13
0
function add_wordpress()
{
    $servername = trim(strtolower($_POST["servername"]));
    $domainname = trim(strtolower($_POST["domainname"]));
    if ($servername == null) {
        if ($domainname != null) {
            $domainname = $servername;
            $domainname = null;
        }
    }
    if ($domainname != null) {
        if ($servername != null) {
            $servername = "{$servername}.{$domainname}";
        } else {
            $servername = $domainname;
        }
    }
    $servername = str_replace('..', '.', $servername);
    $servername = str_replace('/', '.', $servername);
    $servername = str_replace('\\', '.', $servername);
    $servername = str_replace(' ', '.', $servername);
    $servername = str_replace('$', '.', $servername);
    $servername = str_replace('#', '.', $servername);
    $servername = str_replace('%', '.', $servername);
    $servername = str_replace('*', '.', $servername);
    $servername = str_replace('..', '.', $servername);
    $_POST["administrator"] = url_decode_special_tool($_POST["administrator"]);
    $_POST["password"] = url_decode_special_tool($_POST["password"]);
    $_POST["directory"] = url_decode_special_tool($_POST["directory"]);
    if (substr($servername, strlen($servername) - 1, 1) == '.') {
        $servername = substr($servername, 0, strlen($servername) - 1);
    }
    if (substr($servername, 0, 1) == '.') {
        $servername = substr($servername, 1, strlen($servername));
    }
    $free = new freeweb();
    $free->servername = $servername;
    $free->groupware = "WORDPRESS";
    $free->groupware_admin = $_POST["administrator"];
    $free->groupware_password = $_POST["password"];
    $free->groupware_duplicate = $_POST["duplicate-from"];
    $free->www_dir = $_POST["directory"];
    if (!$free->CreateSite(true)) {
        echo $free->error;
    }
}
function replication_save()
{
    $free = new freeweb($_POST["servername"]);
    $_POST["ARTICA_PASSWORD"] = url_decode_special_tool($_POST["ARTICA_PASSWORD"]);
    $free->Params["ROUNDCUBE"]["ARTICA_PORT"] = $_POST["ARTICA_PORT"];
    $free->Params["ROUNDCUBE"]["ARTICA_ADMIN"] = $_POST["ARTICA_ADMIN"];
    $free->Params["ROUNDCUBE"]["ARTICA_PASSWORD"] = $_POST["ARTICA_PASSWORD"];
    $free->Params["ROUNDCUBE"]["ARTICA_HOST"] = $_POST["ARTICA_HOST"];
    $free->Params["ROUNDCUBE"]["ARTICA_RMWEB"] = $_POST["ARTICA_RMWEB"];
    $free->Params["ROUNDCUBE"]["ENABLE_REPLIC"] = $_POST["ENABLE_REPLIC"];
    $free->SaveParams();
    $sock = new sockets();
    $sock->getFrameWork("freeweb.php?roudce-replic-host=yes&servername={$_POST["servername"]}");
}
function webservice()
{
    $sql = "SELECT * FROM freeweb WHERE servername='{$_GET["servername"]}'";
    $page = CurrentPageName();
    $users = new usersMenus();
    $tpl = new templates();
    $q = new mysql();
    $sock = new sockets();
    $APACHE_PROXY_MODE = 0;
    $DNS_INSTALLED = false;
    $remove_sql = false;
    $OnlyWebSite = false;
    $countloops = countloops();
    $no_usersameftpuser = $tpl->javascript_parse_text("{no_usersameftpuser}");
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    if (!is_numeric($_GET["t"])) {
        $_GET["t"] = 0;
    }
    $error_field_max_length = $tpl->javascript_parse_text("{error_field_max_length}");
    $error_please_fill_field = $tpl->javascript_parse_text("{error_please_fill_field}");
    $acl_dstdomain = $tpl->javascript_parse_text("{acl_dstdomain}");
    $mysql_database = $tpl->javascript_parse_text("{mysql_database}");
    $username = $tpl->javascript_parse_text("{username}");
    $password = $tpl->javascript_parse_text("{password}");
    $vgservices = unserialize(base64_decode($sock->GET_INFO("vgservices")));
    $checkboxes = 1;
    $ButtonName = "{apply}";
    if ($ligne["groupware"] == "cachemgr") {
        $checkboxes = 0;
    }
    $users = new usersMenus();
    $PUREFTP_INSTALLED = 1;
    if (!$users->PUREFTP_INSTALLED) {
        $PUREFTP_INSTALLED = 0;
    }
    $ServerIPVAL = trim($ligne["ServerIP"]);
    $ServerPort = trim($ligne["ServerPort"]);
    $sslcertificate = $ligne["sslcertificate"];
    $UseDefaultPort = 0;
    if ($users->APACHE_PROXY_MODE) {
        $APACHE_PROXY_MODE = 1;
    }
    $parcourir_domaines = button("{browse}...", "Loadjs('browse.domains.php?field=domainname')", 12);
    if ($users->dnsmasq_installed) {
        $DNS_INSTALLED = true;
    }
    if ($users->POWER_DNS_INSTALLED) {
        $DNS_INSTALLED = true;
    }
    $FreeWebDisableSSL = trim($sock->GET_INFO("FreeWebDisableSSL"));
    if (!is_numeric($FreeWebDisableSSL)) {
        $FreeWebDisableSSL = 0;
    }
    $check_configuration = $tpl->_ENGINE_parse_body("{check_configuration}");
    $webservice = $tpl->_ENGINE_parse_body("{webservice}");
    $ServerIPVAL = "{$ServerIPVAL}:{$ServerPort}";
    $freeweb = new freeweb($_GET["servername"]);
    $acl_dstdomain_label = $tpl->_ENGINE_parse_body("{acl_dstdomain}");
    //HTTTRACK ---------------------------------------------------------
    $WebCopyCount = $q->COUNT_ROWS("httrack_sites", "artica_backup");
    if ($WebCopyCount > 0) {
        $sql = "SELECT ID,sitename FROM httrack_sites";
        $results_webcopy = $q->QUERY_SQL($sql, "artica_backup");
        $WebCopyHash[0] = "{none}";
        while ($ligneWebCopy = mysql_fetch_assoc($results_webcopy)) {
            $WebCopyHash[$ligneWebCopy["ID"]] = $ligneWebCopy["sitename"];
        }
        $WebCopyTR = "<tr>\n\t\t\t\t<td class=legend nowrap style='font-size:18px;vertical-align:middle'>WebCopy:</td>\n\t\t\t\t<td>" . Field_array_Hash($WebCopyHash, "WebCopyID", $freeweb->WebCopyID, "style:font-size:18px") . "</td>\n\t\t\t\t<td>" . help_icon("freeweb_WebCopy_explain") . "</td>\n\t\t\t</tr>";
    }
    if ($ligne["groupware"] == "SUGAR") {
        $additional_infos = sugard_additional_infos();
    }
    if ($vgservices["freewebs"] != null) {
        if (!is_numeric($ligne["lvm_size"])) {
            $ligne["lvm_size"] = 5000;
        }
        if ($ligne["lvm_vg"] == null) {
            $ligne["lvm_vg"] = $vgservices["freewebs"];
        }
        $sizelimit = "\n\t\t<tr>\n\t\t<td class=legend style='font-size:18px;vertical-align:middle'>{size}:</td>\n\t\t<td style='font-size:14px;'>" . Field_text("vg_size", $ligne["lvm_size"], "font-size:18px;padding:3px;width:60px") . "&nbsp;MB</td>\n\t\t<td>&nbsp;</td>\n\t\t</tr>";
    }
    $groupwarelink = $freeweb->groupwares_InstallLink();
    $groupwares_textintro = $freeweb->groupwares_textintro();
    if ($groupwarelink != null) {
        $explain = "\n\t\t<div class=explain>{$groupwares_textintro}:<br><strong style='font-size:14px'>\n\t\t\t<a href=\"javascript:blur()\" OnClick=\"javascript:s_PopUpFull('{$groupwarelink}',1024,768)\" style='text-decoration:underline;font-weight:bold;color:#969696'>{$groupwarelink}</a></strong></div>\t\t\n\t\t";
    }
    $img = "website-64.png";
    if ($_GET["force-groupware"] != null) {
        $vhosts = new vhosts();
        $img = $vhosts->IMG_ARRAY_64[$_GET["force-groupware"]];
        $imgtitle = "<div style='font-size:18px;font-weight:bold'>{" . $vhosts->TEXT_ARRAY[$_GET["force-groupware"]]["TITLE"] . "}</div>";
        if ($_GET["force-groupware"] == "ZARAFA") {
            $remove_sql = true;
            $OnlyWebSite = true;
        }
        if ($_GET["force-groupware"] == "Z-PUSH") {
            $remove_sql = true;
            $OnlyWebSite = true;
        }
        if ($_GET["force-groupware"] == "ZARAFA_MOBILE") {
            $remove_sql = true;
            $OnlyWebSite = true;
        }
        if ($_GET["force-groupware"] == "ROUNDCUBE") {
            $OnlyWebSite = true;
        }
        if ($_GET["force-groupware"] == "KLMS") {
            $OnlyWebSite = true;
            $remove_sql = true;
        }
    }
    $servernameenc = urlencode($_GET["servername"]);
    $configure = "&nbsp;|&nbsp;" . button("{reconfigure}", "SaveFreeWebMain();Loadjs('freeweb.rebuild.progress.php?servername={$servernameenc}')", 26);
    if ($_GET["servername"] == null) {
        $ButtonName = "{add}";
        $configure = null;
    }
    if ($ligne["domainname"] == null) {
        $dda = explode(".", $ligne["servername"]);
        $hostname = $dda[0];
        unset($dda[0]);
        $domainname = @implode(".", $dda);
    } else {
        $ff = explode(".", $ligne["servername"]);
        if (count($ff) > 2) {
            $hostname = str_replace(".{$ligne["domainname"]}", "", $ligne["servername"]);
        } else {
            $hostname = null;
        }
        $domainname = $ligne["domainname"];
        $parcourir_domaines = null;
    }
    if ($hostname == "_default_") {
        $parcourir_domaines = null;
    }
    if ($DNS_INSTALLED) {
        include_once dirname(__FILE__) . "/ressources/class.system.network.inc";
        include_once dirname(__FILE__) . "/ressources/class.pdns.inc";
        $pdns = new pdns();
        if ($ligne["servername"] == null) {
            $ip = new networking();
            $ips = $ip->ALL_IPS_GET_ARRAY();
            $ips[null] = "{none}";
            $dns_field = "<tr>\n\t\t\t\t<td class=legend nowrap style='font-size:18px;vertical-align:middle'>{dns_entry}:</td>\n\t\t\t\t<td>" . Field_array_Hash($ips, "ADD_DNS_ENTRY", null, "style:font-size:18px") . "</td>\n\t\t\t\t<td>" . help_icon("freeweb_add_dns_entry_explain") . "</td>\n\t\t\t</tr>";
        } else {
            $hostip = $pdns->GetIp($ligne["servername"]);
            if ($hostip != null) {
                $dns_field = "<tr>\n\t\t\t\t<td class=legend nowrap style='font-size:18px;vertical-align:middle'>{dns_entry}:</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'>{$hostip}</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>";
            } else {
                $ip = new networking();
                $ips = $ip->ALL_IPS_GET_ARRAY();
                $ips[null] = "{none}";
                $dns_field = "<tr>\n\t\t\t\t<td class=legend nowrap style='font-size:18px;vertical-align:middle'>{dns_entry}:</td>\n\t\t\t\t<td>" . Field_array_Hash($ips, "ADD_DNS_ENTRY", null, "style:font-size:18px") . "</td>\n\t\t\t\t<td>" . help_icon("freeweb_add_dns_entry_explain") . "</td>\n\t\t\t</tr>";
            }
        }
    }
    $domain = "<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td>" . Field_text("servername", $hostname, "font-size:18px;padding:3px;font-weight:bold;width:90px") . "</td>\n\t\t\t<td style='font-size:18px' align='center' width=1%>&nbsp;.&nbsp;</td>\n\t\t\t<td>" . Field_text("domainname", $domainname, "font-size:18px;padding:3px;width:220px;font-weight:bold") . "</td>\n\t\t\t<td>{$parcourir_domaines}</td>\n\t\t</tr>\n\t\t</table>";
    if (!$users->AsSystemAdministrator) {
        if ($ligne["domainname"] == null) {
            $dd = explode(".", $ligne["servername"]);
            $hostname = $dd[0];
            unset($dd[0]);
            $domainname = @implode(".", $dd);
        } else {
            $ff = explode(".", $ligne["servername"]);
            if (count($ff) > 2) {
                $hostname = str_replace(".{$ligne["domainname"]}", "", $ligne["servername"]);
            } else {
                $hostname = null;
            }
            $domainname = $ligne["domainname"];
        }
        $ldap = new clladp();
        $domains = $ldap->Hash_domains_table($_SESSION["ou"]);
        while (list($a, $b) = each($domains)) {
            $c[$a] = $a;
        }
        $domain = "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td>" . Field_text("servername", $hostname, "font-size:18px;padding:3px;font-weight:bold;width:90px") . "</td>\n\t\t\t<td style='font-size:18px' align='center' width=1%>&nbsp;.&nbsp;</td>\n\t\t\t<td>" . Field_array_Hash($c, "domainname", $domainname, "style:font-size:18px;padding:3px;font-weight:bold;width:220px;") . "</td>\n\t\t</tr>\n\t\t</table>";
    }
    $NewServer = 0;
    if (trim($ligne["servername"] == null)) {
        $NewServer = 1;
    }
    if ($NewServer == 0) {
        $domain = "<div style='font-size:22px'>{$ligne["servername"]}</div>\n\t\t\t<input type='hidden' value='{$ligne["servername"]}' id='servername'>\n\t\t\t<input type='hidden' value='{$ligne["domainname"]}' id='domainname'>";
    }
    if ($ligne["groupware"] != null) {
        $apache = new vhosts();
        $img = $apache->IMG_ARRAY_64[$ligne["groupware"]];
        if ($ligne["groupware"] == "ROUNDCUBE") {
            $OnlyWebSite = true;
        }
        if ($ligne["ForceInstanceZarafaID"] > 0) {
            $_GET["ForceInstanceZarafaID"] = $ligne["ForceInstanceZarafaID"];
        }
    }
    if ($OnlyWebSite) {
        $js_OnlyWebSite = "OnlyWebsite()";
    }
    $uid_uri = urlencode(base64_encode($ligne["uid"]));
    $nets = unserialize(base64_decode($sock->GET_INFO("FreeWebsApacheListenTable")));
    $znets[null] = "{default}";
    while (list($num, $ip) = each($nets)) {
        $znets[$num] = $num;
    }
    $ServerIP = Field_array_Hash($znets, 'ServerIP', $ServerIPVAL, null, null, 0, 'font-size:18px;');
    $q = new mysql();
    include_once dirname(__FILE__) . "/ressources/class.squid.reverse.inc";
    $squid_reverse = new squid_reverse();
    $sslcertificates = $squid_reverse->ssl_certificates_list();
    $sslcertificateF = Field_array_Hash($sslcertificates, "sslcertificate", $sslcertificate, "style:font-size:18px");
    $t = time();
    $html = "\n\t<div id='freewebdiv-{$t}'></div>\n\t<input type='hidden' id='force-groupware' name ='force-groupware' value='{$_GET["force-groupware"]}'>\n\t<table style='width:100%' class=TableRemove>\n\t<tr>\n\t\t<td valign='top' width=1%>\n\t\t\t<center>\n\t\t\t\t<img src='img/{$img}'>{$imgtitle}\n\t\t\t</center><br>\n\t\t\t<div style='width:190px'>\n\t\t\t\n\t\t\t</div>\n\t\t</td>\n\t\t<td valign='top' width=99%>\n\t{$explain}\n\t<div id='freewebdiv'>\n\t\t<div id='block1' style='display:block;'>\n\t\t\t<div style='width:98%' class=form>\n\t\t\t<table>\n\t\t\t<tr> \n\t\t\t\t<td class=legend nowrap style='font-size:18px;vertical-align:middle'>{$acl_dstdomain_label}:</td>\n\t\t\t\t<td colspan=2>{$domain}</td>\n\t\t\t</tr>\n\t\t\t<tr> \n\t\t\t\t<td class=legend nowrap style='font-size:18px;vertical-align:middle'>{listen_address}:</td>\n\t\t\t\t<td colspan=2>{$ServerIP}</td>\n\t\t\t</tr>\t\t\t\t\t\n\t\t\t{$dns_field}\n\t\t\t{$WebCopyTR}\t\n\t\t\t\n\t\t\t\n\t\t\t<tr> \n\t\t\t\t<td class=legend nowrap style='font-size:18px;vertical-align:middle'>{directory}:</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'>" . Field_text("www_dir", $ligne["www_dir"], "font-size:18px;padding:3px;") . "</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'>" . button_browse("www_dir") . "</td>\n\t\t\t</tr>\t\t\t\n\t\t\t<tr> \n\t\t\t\t<td class=legend nowrap style='font-size:18px;vertical-align:middle'>{reverse_proxy}:</td>\n\t\t\t\t<td width=1% style='font-size:18px;vertical-align:middle'>" . Field_checkbox_design("UseReverseProxy", 1, $ligne["UseReverseProxy"], "CheckUseReverseProxy()") . "</td>\n\t\t\t</tr>\t\t\n\t\t\t\n\t\t\t{$sizelimit}\n\t\t\t<tr>\n\t\t\t\t<td class=legend nowrap style='font-size:18px;vertical-align:middle'>{UseLoopDisk}:</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'>" . Field_checkbox_design("UseLoopDisk", 1, $ligne["UseLoopDisk"], "CheckLoops()") . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\n\t\t\t<tr style='height:auto'>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'>&nbsp;</td>\n\t\t\t\t<td colspan=2 style='height:auto'><span id='loops-list'></span></td></tr>\t\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:18px;vertical-align:middle'>{member}:</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'>" . Field_text("www_uid", $ligne["uid"], "font-size:18px;padding:3px;") . "</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'><span id='bb_button'>" . button("{browse}...", "Loadjs('user.browse.php?field=www_uid&YahooWin=6')", 12) . "</span>\n\t\t\t\t<span id='status-uid-www' style='float:right'></span></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:18px;vertical-align:middle'>{group}:</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'>" . Field_text("www_group", $ligne["gpid"], "font-size:18px;padding:3px;") . "</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'><span id='bb_button1'>" . button("{browse}...", "Loadjs('MembersBrowse.php?field-user=www_group&OnlyGroups=1&OnlyGUID=1')", 12) . "</span>\n\t\t\t\t\t<span id='status-gpid-www' style='float:right'></span>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:18px;vertical-align:middle'>{ssl}:</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'>" . Field_checkbox_design("useSSL", 1, $ligne["useSSL"], "useSSLCheckCOnf()") . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:18px;vertical-align:middle'>{certificate}:</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'>{$sslcertificateF}</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\t\t\t\n\t\t\t\n\t\t\t<tr> \n\t\t\t\t<td class=legend nowrap style='font-size:18px;vertical-align:middle'>{www_forward}:</td>\n\t\t\t\t<td width=1% style='font-size:18px;vertical-align:middle'>" . Field_checkbox_design("Forwarder", 1, $ligne["Forwarder"], "CheckForwarder()") . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:18px;vertical-align:middle'>{www_ForwardTo}:</td>\n\t\t\t\t<td style='font-size:18px;vertical-align:middle'>" . Field_text("ForwardTo", $ligne["ForwardTo"], "width:270px;font-size:18px;padding:3px") . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</div>\n\t\t</div>\t\n\t</div>\t\n\t</div>\n\t\n\t<div style='width:100%;text-align:right;font-size:26px'><hr>" . button("{$ButtonName}", "SaveFreeWebMain()", 30) . "{$configure}</div>\n\n\n\n\t\n\t\n\t</td>\n\t</tr>\n\t</table>\n\t\n\t{$additional_infos}\n<script>\n\n\tfunction CheckDatas(){\n\t\tvar APACHE_PROXY_MODE={$APACHE_PROXY_MODE};\n\t\tvar FreeWebDisableSSL={$FreeWebDisableSSL};\n\t\t \n\t\t\n\t\tif(APACHE_PROXY_MODE==0){\n\t\t\tdocument.getElementById('UseReverseProxy').checked=false;\n\t\t\tdocument.getElementById('UseReverseProxy').disabled=true;\n\t\t}\n\t\t\n\t\tvar x=document.getElementById('servername').value;\n\t\tvar z=document.getElementById('domainname').value;\n\t\tvar w=x.length+z.length;\n\t\tif(w>0){\n\t\t\tdocument.getElementById('servername').disabled=true;\n\t\t\tdocument.getElementById('domainname').disabled=true;\n\t\t\t}\n\t\t\n\t\tif(FreeWebDisableSSL==1){\n\t\t\tdocument.getElementById('useSSL').disabled=true;\n\t\t}\n\t\t\n\t}\n\t\n\n\t\n\n\t\n\tfunction CheckForwarder(){\n\t\tif(document.getElementById('Forwarder').checked){\n\t\t\tdocument.getElementById('UseReverseProxy').disabled=true;\n\t\t\tdocument.getElementById('UseLoopDisk').disabled=true;\n\t\t\tdocument.getElementById('ForwardTo').disabled=false;\n\t\t\t\n\t\t\t\n\t\t}else{\n\t\t\tdocument.getElementById('UseReverseProxy').disabled=false;\n\t\t\tdocument.getElementById('UseLoopDisk').disabled=false;\n\t\t\tdocument.getElementById('ForwardTo').disabled=true;\n\t\t\tCheckLoops();\n\t\t}\n\t\n\t}\n\t\t\n\tfunction FreeWebsRebuildvHosts(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('FreeWebsRebuildvHosts','{$_GET["servername"]}');\n\t\tAnimateDiv('freewebdiv');\n\t\tXHR.sendAndLoad('freeweb.edit.php', 'POST',x_SaveFreeWebMain{$t});\n\t}\n\t\n\tfunction FreeWebsRebuildGroupware(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('FreeWebsRebuildGroupware','{$_GET["servername"]}');\n\t\tAnimateDiv('freewebdiv');\n\t\tXHR.sendAndLoad('freeweb.edit.php', 'POST',x_SaveFreeWebMain{$t});\n\t}\t\t\t\n\n\n\tvar x_SaveFreeWebMain{$t}=function (obj) {\n\t\t    var NewServer={$NewServer};\n\t\t\tvar results=obj.responseText;\n\t\t\tdocument.getElementById('freewebdiv-{$t}').innerHTML='';\n\t\t\tif(results.length>0){alert(results);return;}\n\t\t\tvar t={$_GET["t"]};\t\n\t\t\tif(t>0){\n\t\t\t\t\$('#freewebs-table-{$_GET["t"]}').flexReload();\n\t\t\t}else{\n\t\t\t\tif(document.getElementById('container-www-tabs')){RefreshTab('container-www-tabs');}\n\t\t\t\tif(document.getElementById('main_config_freeweb')){FreeWebsRefreshWebServersList();}\n\t\t\t}\n\t\t\tif(NewServer==1){\n\t\t\t\tYahooWin5Hide();\n\t\t\t\tExecuteByClassName('SearchFunction');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(document.getElementById('main_config_freewebMains')){RefreshTab('main_config_freewebMains');}\n\t\t\tExecuteByClassName('SearchFunction');\n\t\t}\t\n\t\t\n\t\tfunction SaveFreeWebMain(){\n\t\t\tvar NewServer={$NewServer};\n\t\t\t\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('SAVE_FREEWEB_MAIN','yes');\n\t\t\t\n\t\t\tif(NewServer==1){\n\t\t\t\tvar sitename=document.getElementById('servername').value;\n\t\t\t\tvar www_a=document.getElementById('domainname').value;\n\t\t\t\tvar www_b=document.getElementById('servername').value;\n\t\t\t\tvar www_t=www_a.length+www_b.length;\n\t\t\t\tif(www_t<2){\n\t\t\t\t\talert('{$error_please_fill_field}:{$acl_dstdomain}'); \n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\n\t\t\t\tif(sitename!=='_default_'){\n\t\t\t\t\tvar x=document.getElementById('domainname').value;\n\t\t\t\t\tif(x.length==0){alert('{$error_please_fill_field}:{$acl_dstdomain}');return;}\n\t\t\t\t}else{\n\t\t\t\t\tdocument.getElementById('domainname').value='';\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(document.getElementById('ADD_DNS_ENTRY')){\n\t\t\t\tXHR.appendData('ADD_DNS_ENTRY',document.getElementById('ADD_DNS_ENTRY').value);\n\t\t\t}\n\t\t\t\n\t\t\tif(document.getElementById('useSSL').checked){XHR.appendData('useSSL',1);}else{XHR.appendData('useSSL',0);}\n\t\t\t\n\t\t\tif(document.getElementById('WebCopyID')){\n\t\t\t\tXHR.appendData('WebCopyID',document.getElementById('WebCopyID').value);\n\t\t\t}\n\t\t\tif(document.getElementById('www_dir')){\n\t\t\t\tXHR.appendData('www_dir',document.getElementById('www_dir').value);\n\t\t\t}\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tXHR.appendData('UseDefaultPort',0)\n\t\t\tif(document.getElementById('UseReverseProxy').checked){XHR.appendData('UseReverseProxy',1);}else{XHR.appendData('UseReverseProxy',0);}\n\t\t\tif(document.getElementById('Forwarder').checked){XHR.appendData('Forwarder',1);}else{XHR.appendData('Forwarder',0);}\n\t\t\tXHR.appendData('ForceInstanceZarafaID','{$_GET["ForceInstanceZarafaID"]}');\n\t\t\t\n\t\t\t\n\t\t\tif(document.getElementById('LoopMounts')){\n\t\t\t\tvar LoopMounts=document.getElementById('LoopMounts').value;\n\t\t\t\tif(LoopMounts.length>3){\n\t\t\t\t\tif(document.getElementById('UseLoopDisk').checked){XHR.appendData('UseLoopDisk',1);}else{XHR.appendData('UseLoopDisk',0);}\n\t\t\t\t\tXHR.appendData('LoopMounts',LoopMounts);\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tvar uid=trim(document.getElementById('www_uid').value);\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tif(document.getElementById('vg_size')){XHR.appendData('vg_size',document.getElementById('vg_size').value);}\n\t\t\tXHR.appendData('lvm_vg','{$ligne["lvm_vg"]}');\n\t\t\tif(NewServer==1){\n\t\t\t\tif(sitename!=='_default_'){\n\t\t\t\t\tvar www_b=document.getElementById('domainname').value;\n\t\t\t\t\tvar www_a=document.getElementById('servername').value;\n\t\t\t\t\tif(www_a.length>0){XHR.appendData('servername',www_a+'.'+www_b);}else{XHR.appendData('servername',www_b);}\n    \t\t\t\t}else{\n    \t\t\t\tXHR.appendData('servername','_default_');\n    \t\t\t}\n    \t\t}\n    \t\tif(NewServer==0){XHR.appendData('servername',document.getElementById('servername').value);}\n    \t\tXHR.appendData('domainname',document.getElementById('domainname').value);\n    \t\tXHR.appendData('uid',uid);\n    \t\tXHR.appendData('gpid',document.getElementById('www_group').value);\n    \t\tXHR.appendData('ForwardTo',document.getElementById('ForwardTo').value);\n    \t\tXHR.appendData('force-groupware',document.getElementById('force-groupware').value);\n    \t\tXHR.appendData('ServerIP',document.getElementById('ServerIP').value);\n    \t\tXHR.appendData('sslcertificate',document.getElementById('sslcertificate').value);\n    \t\t\n    \t\t\n    \t\t\n    \t\tAnimateDiv('freewebdiv-{$t}');\n    \t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveFreeWebMain{$t});\n\t\t\t\n\t\t}\t\n\t\t\n\tfunction CheckLoops(){\n\t\tvar countloops={$countloops};\n\t\tdocument.getElementById('UseLoopDisk').disabled=true;\n\t\tif(countloops>0){\n\t\t\tdocument.getElementById('UseLoopDisk').disabled=false;\n\t\t}\n\t\tdocument.getElementById('loops-list').innerHTML='';\n\t\t\n\t\tif(document.getElementById('UseLoopDisk').checked){\n\t\t\tif(document.getElementById('vg_size')){\n\t\t\t\tdocument.getElementById('vg_size').disabled=true;\n\t\t\t}\n\t\t\tLoadAjax('loops-list','{$page}?loops-list=yes&servername={$ligne["servername"]}');\n\t\t}\n\t}\n\t\n\t\n\n\t\n\t\t\n\tfunction CheckLoops(){\n\t\tvar countloops={$countloops};\n\t\tdocument.getElementById('UseLoopDisk').disabled=true;\n\t\tif(countloops>0){document.getElementById('UseLoopDisk').disabled=false;}\n\t\tdocument.getElementById('loops-list').innerHTML='';\n\t\t\n\t\tif(document.getElementById('UseLoopDisk').checked){\n\t\t\tif(document.getElementById('vg_size')){\n\t\t\t\tdocument.getElementById('vg_size').disabled=true;\n\t\t\t}\n\t\t\tLoadAjax('loops-list','{$page}?loops-list=yes&servername={$ligne["servername"]}');\n\t\t}\n\t}\n\t\n\tfunction CheckUseReverseProxy(){\n\t\tCheckDatas();\n\t\tuseMysqlCheck();\n\t\tCheckLoops();\n\t\t{$js_removesql};\n\t\t{$js_OnlyWebSite};\n\t}\n\t\n\n\t\n\tfunction OnlyWebsite(){\n\t\tif(document.getElementById('Forwarder')){document.getElementById('Forwarder').disabled=true;}\n\t\tif(document.getElementById('UseReverseProxy')){document.getElementById('UseReverseProxy').disabled=true;}\n\t\tif(document.getElementById('useFTP')){document.getElementById('useFTP').disabled=true;}\n\t}\n\t\n\tfunction CheckUId(){\n\t\tLoadAjaxTiny('status-uid-www','freeweb.edit.php?uid-check={$uid_uri}');\n\t}\n\t\n\n\t\n\tfunction useSSLCheckCOnf(){\n\t\tdocument.getElementById('sslcertificate').disabled=true;\n\t\t\tif(document.getElementById('useSSL').checked){\n\t\t\t\tdocument.getElementById('sslcertificate').disabled=false;\n\t\t\t}\n\t}\n\t\n\tCheckDatas();\n\tCheckLoops();\n\tCheckForwarder();\n\tCheckUId();\n\t{$js_removesql};\n\t{$js_OnlyWebSite};\n\tuseSSLCheckCOnf();\n\t\n\t</script>\t\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
function build()
{
    $unix = new unix();
    $sock = new sockets();
    $users = new usersMenus();
    $APACHE_MODULES_PATH = $users->APACHE_MODULES_PATH;
    if ($GLOBALS["OUTPUT"]) {
        echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Apache modules in \"{$APACHE_MODULES_PATH}\"\n";
    }
    $ZarafaApachePort = $sock->GET_INFO("ZarafaApachePort");
    $ZarafaApacheSSL = $sock->GET_INFO("ZarafaApacheSSL");
    $LighttpdArticaDisableSSLv2 = $sock->GET_INFO("LighttpdArticaDisableSSLv2");
    $ZarafaWebNTLM = $sock->GET_INFO("ZarafaWebNTLM");
    $ZarafaApacheServerName = $sock->GET_INFO("ZarafaApacheServerName");
    if (!is_numeric($ZarafaWebNTLM)) {
        $ZarafaWebNTLM = 0;
    }
    if (!is_numeric($LighttpdArticaDisableSSLv2)) {
        $LighttpdArticaDisableSSLv2 = 0;
    }
    if (!is_numeric($ZarafaApacheSSL)) {
        $ZarafaApacheSSL = 0;
    }
    if (!is_numeric($ZarafaApachePort)) {
        $ZarafaApachePort = 9010;
    }
    $ZarafaApachePHPFPMEnable = $sock->GET_INFO("ZarafaApachePHPFPMEnable");
    if (!is_numeric($ZarafaApachePHPFPMEnable)) {
        $ZarafaApachePHPFPMEnable = 0;
    }
    if ($ZarafaApacheServerName == null) {
        $ZarafaApacheServerName = $unix->hostname_g();
    }
    if (!is_dir('/usr/share/php/mapi')) {
        if (is_dir('/usr/local/share/php/mapi')) {
            @mkdir("/usr/share/php", 0755, true);
            shell_exec('/bin/ln -s /usr/local/share/php/mapi /usr/share/php/mapi');
        }
    }
    $username = $unix->APACHE_SRC_ACCOUNT();
    $group = $unix->APACHE_SRC_GROUP();
    if ($GLOBALS["OUTPUT"]) {
        echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} logs access: /var/log/apache-zarafa/access.log\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} logs error : /var/log/apache-zarafa/error.log\n";
    }
    @unlink("/var/log/apache-zarafa/access.log");
    @unlink("/var/log/apache-zarafa/error.log");
    @touch("/var/log/apache-zarafa/access.log");
    @touch("/var/log/apache-zarafa/access.log");
    @mkdir("/var/run/apache2", 0755, true);
    @mkdir("/var/run/artica-apache", 0755, true);
    @mkdir('/var/run/zarafa-web', 0755, true);
    @mkdir('/var/log/apache-zarafa', 0755, true);
    @mkdir('/var/lib/zarafa-webaccess/tmp', 0755, true);
    $unix->chown_func($username, $group, "/var/log/apache-zarafa/access.log");
    $unix->chown_func($username, $group, "/var/log/apache-zarafa/error.log");
    $unix->chown_func($username, $group, "/var/run/apache2");
    $unix->chown_func($username, $group, "/var/run/artica-apache");
    $unix->chown_func($username, $group, "/var/run/zarafa-web");
    $unix->chown_func($username, $group, "/var/log/apache-zarafa");
    $unix->chown_func($username, $group, "/var/lib/zarafa-webaccess");
    $unix->chmod_func(0777, "/var/lib/zarafa-webaccess/tmp");
    $unix->chown_func($username, $group, "/usr/share/zarafa-webaccess/plugins/*");
    if ($ZarafaApacheSSL == 1) {
        if (is_file("{$APACHE_MODULES_PATH}/mod_ssl.so")) {
            if (!is_file("/etc/ssl/certs/zarafa/apache.crt.nopass.cert")) {
                shell_exec("/usr/share/artica-postfix/bin/artica-install --zarafa-apache-certificates");
            }
            $f[] = "LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so";
            $f[] = "SSLEngine on";
            $f[] = "SSLCertificateFile /etc/ssl/certs/zarafa/apache.crt.nopass.cert";
            $f[] = "SSLCertificateKeyFile /etc/ssl/certs/zarafa/apache-ca.key.nopass.key";
            if ($LighttpdArticaDisableSSLv2 == 1) {
                $f[] = "SSLProtocol -ALL +SSLv3 +TLSv1";
                $f[] = "SSLCipherSuite ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM";
            }
            $f[] = "SSLRandomSeed connect builtin";
            $f[] = "SSLRandomSeed startup file:/dev/urandom  256";
            $f[] = "SSLRandomSeed connect file:/dev/urandom 256";
            $f[] = "AddType application/x-x509-ca-cert .crt";
            $f[] = "AddType application/x-pkcs7-crl    .crl";
            $f[] = "SSLPassPhraseDialog  builtin";
            $f[] = "SSLSessionCache        shmcb:/var/run/apache2/ssl_scache-zarafa(512000)";
            $f[] = "SSLSessionCacheTimeout  300";
            $f[] = "SSLVerifyClient none";
            $f[] = "ServerSignature Off";
        }
    }
    $SET_MODULES = SET_MODULES();
    $FreeWebPerformances = unserialize(base64_decode($sock->GET_INFO("ZarafaApachePerformances")));
    if (!is_numeric($FreeWebPerformances["Timeout"])) {
        $FreeWebPerformances["Timeout"] = 300;
    }
    if (!is_numeric($FreeWebPerformances["KeepAlive"])) {
        $FreeWebPerformances["KeepAlive"] = 0;
    }
    if (!is_numeric($FreeWebPerformances["MaxKeepAliveRequests"])) {
        $FreeWebPerformances["MaxKeepAliveRequests"] = 100;
    }
    if (!is_numeric($FreeWebPerformances["KeepAliveTimeout"])) {
        $FreeWebPerformances["KeepAliveTimeout"] = 15;
    }
    if (!is_numeric($FreeWebPerformances["MinSpareServers"])) {
        $FreeWebPerformances["MinSpareServers"] = 5;
    }
    if (!is_numeric($FreeWebPerformances["MaxSpareServers"])) {
        $FreeWebPerformances["MaxSpareServers"] = 10;
    }
    if (!is_numeric($FreeWebPerformances["StartServers"])) {
        $FreeWebPerformances["StartServers"] = 5;
    }
    if (!is_numeric($FreeWebPerformances["MaxClients"])) {
        $FreeWebPerformances["MaxClients"] = 50;
    }
    if (!is_numeric($FreeWebPerformances["MaxRequestsPerChild"])) {
        $FreeWebPerformances["MaxRequestsPerChild"] = 10000;
    }
    $f[] = "Timeout              {$FreeWebPerformances["Timeout"]}";
    $f[] = "KeepAlive            {$FreeWebPerformances["KeepAlive"]}";
    $f[] = "KeepAliveTimeout     {$FreeWebPerformances["KeepAliveTimeout"]}";
    $f[] = "StartServers         {$FreeWebPerformances["StartServers"]}";
    $f[] = "MaxClients           {$FreeWebPerformances["MaxClients"]}";
    $f[] = "MinSpareServers      {$FreeWebPerformances["MinSpareServers"]}";
    $f[] = "MaxSpareServers      {$FreeWebPerformances["MaxSpareServers"]}";
    $f[] = "MaxRequestsPerChild  {$FreeWebPerformances["MaxRequestsPerChild"]}";
    $f[] = "MaxKeepAliveRequests {$FreeWebPerformances["MaxKeepAliveRequests"]}";
    $f[] = "ServerLimit\t\t   {$FreeWebPerformances["MaxClients"]}";
    $f[] = "AcceptMutex \t\t  flock";
    $ZarafaApacheWebMailType = $sock->GET_INFO("ZarafaApacheWebMailType");
    //$ZarafaApacheWebMailTypeA["APP_ZARAFA"]="{APP_ZARAFA}";
    //$ZarafaApacheWebMailTypeA["APP_ZARAFA_WEBAPP"]="{APP_ZARAFA_WEBAPP}";
    if ($ZarafaApacheWebMailType == null) {
        $ZarafaApacheWebMailType = "APP_ZARAFA";
    }
    $f[] = $SET_MODULES;
    $f[] = "<IfModule !mpm_netware_module>";
    $f[] = "          <IfModule !mpm_winnt_module>";
    $f[] = "             User {$username}";
    $f[] = "             Group {$group}";
    $f[] = "          </IfModule>";
    $f[] = "</IfModule>";
    $f[] = "ServerAdmin you@example.com";
    $f[] = "ServerName {$ZarafaApacheServerName}";
    if ($ZarafaApacheWebMailType == "APP_ZARAFA_WEBAPP") {
        if (!is_dir("/usr/share/zarafa-webapp")) {
            $ZarafaApacheWebMailType = "APP_ZARAFA";
        }
    }
    if ($ZarafaApacheWebMailType == "APP_ZARAFA") {
        $DocumentRoot = "/usr/share/zarafa-webaccess";
    }
    if ($ZarafaApacheWebMailType == "APP_ZARAFA_WEBAPP") {
        $free = new freeweb();
        $free->InstallZarafaConfigWebAPP("/usr/share/zarafa-webapp");
        $DocumentRoot = "/usr/share/zarafa-webapp";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} WebMail \"{$ZarafaApacheWebMailType}\"\n";
    }
    $f[] = "ServerRoot \"{$DocumentRoot}\"";
    $f[] = "Listen {$ZarafaApachePort}";
    $f[] = "User {$username}";
    $f[] = "Group {$group}";
    $f[] = "PidFile /var/run/zarafa-web/httpd.pid";
    $f[] = "DocumentRoot \"{$DocumentRoot}\"";
    $f[] = "<Directory {$DocumentRoot}/>";
    if ($ZarafaWebNTLM == 1) {
        $ldap = new clladp();
        $f[] = "    AuthName \"Zarafa logon..\"";
        $f[] = "    AuthType Basic";
        $f[] = "    AuthLDAPURL ldap://{$ldap->ldap_host}:{$ldap->ldap_port}/dc=organizations,{$ldap->suffix}?uid";
        $f[] = "    AuthLDAPBindDN cn={$ldap->ldap_admin},{$ldap->suffix}";
        $f[] = "    AuthLDAPBindPassword {$ldap->ldap_password}";
        $f[] = "    AuthLDAPGroupAttribute memberUid";
        $f[] = "    AuthBasicProvider ldap";
        $f[] = "    AuthzLDAPAuthoritative off";
        $f[] = "    require valid-user";
    }
    if ($ZarafaApachePHPFPMEnable == 0) {
        $f[] = "    php_value magic_quotes_gpc 0";
        $f[] = "    php_value register_globals 0";
        $f[] = "    php_value magic_quotes_runtime 0";
        $f[] = "    php_value post_max_size 31M";
        $f[] = "    php_value include_path  \".:/usr/share/php:/usr/share/php5:/usr/local/share/php\"";
        $f[] = "    php_value upload_max_filesize 30M";
        $f[] = "    php_value short_open_tag 1";
        $f[] = "    php_flag log_errors on";
        $f[] = "    php_value safe_mode 0";
        $f[] = "    php_flag log_errors on";
        $f[] = "    php_value  error_log  \"/var/log/apache-zarafa/php.log\"";
    }
    $f[] = "    DirectoryIndex index.php";
    $f[] = "    Options -Indexes +FollowSymLinks";
    $f[] = "    AllowOverride Options";
    $f[] = "    Order allow,deny";
    $f[] = "    Allow from all";
    $f[] = "</Directory>";
    if ($ZarafaApachePHPFPMEnable == 1) {
        $php = $unix->LOCATE_PHP5_BIN();
        if (!$unix->is_socket("/var/run/php-fpm-zarafa.sock")) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: /var/run/php-fpm-zarafa.sock no such socket\n";
            }
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Activate PHP5-FPM\n";
            }
            shell_exec("{$php} /usr/share/artica-postfix/exec.initslapd.php --phppfm");
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Restarting PHP5-FPM\n";
            }
            shell_exec("/etc/init.d/php5-fpm restart");
        }
        $f[] = "\tAlias /php5.fastcgi /var/run/artica-apache/php5.fastcgi";
        $f[] = "\tAddHandler php-script .php";
        $f[] = "\tFastCGIExternalServer /var/run/artica-apache/php5.fastcgi -socket /var/run/php-fpm-zarafa.sock -idle-timeout 610";
        $f[] = "\tAction php-script /php5.fastcgi virtual";
        $f[] = "\t<Directory /var/run/artica-apache>";
        $f[] = "\t\t<Files php5.fastcgi>";
        $f[] = "\t\tOrder deny,allow";
        $f[] = "\t\tAllow from all";
        $f[] = "\t\t</Files>";
        $f[] = "\t</Directory>";
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Configuring...: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP5-FPM is disabled\n";
        }
    }
    $f[] = "<IfModule dir_module>";
    $f[] = "    DirectoryIndex index.php";
    $f[] = "</IfModule>";
    $f[] = "";
    $f[] = "";
    $f[] = "<FilesMatch \"^\\.ht\">";
    $f[] = "    Order allow,deny";
    $f[] = "    Deny from all";
    $f[] = "    Satisfy All";
    $f[] = "</FilesMatch>";
    $f[] = "<IfModule mod_php5.c>";
    $f[] = "    <FilesMatch \"\\.ph(p3?|tml)\$\">";
    $f[] = "\tSetHandler application/x-httpd-php";
    $f[] = "    </FilesMatch>";
    $f[] = "    <FilesMatch \"\\.phps\$\">";
    $f[] = "\tSetHandler application/x-httpd-php-source";
    $f[] = "    </FilesMatch>";
    $f[] = "    # To re-enable php in user directories comment the following lines";
    $f[] = "    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it";
    $f[] = "    # prevents .htaccess files from disabling it.";
    $f[] = "    <IfModule mod_userdir.c>";
    $f[] = "        <Directory /home/*/public_html>";
    $f[] = "            php_admin_value engine Off";
    $f[] = "        </Directory>";
    $f[] = "    </IfModule>";
    $f[] = "</IfModule>";
    $f[] = "";
    $f[] = "";
    $f[] = "ErrorLog \"/var/log/apache-zarafa/error.log\"";
    $f[] = "LogLevel warn";
    $f[] = "";
    $f[] = "<IfModule log_config_module>";
    $f[] = "    LogFormat \"%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\" %V\\\" combinedv";
    $f[] = "    LogFormat \"%h %l %u %t \\\"%r\\\" %>s %b\" common";
    $f[] = "";
    $f[] = "    <IfModule logio_module>";
    $f[] = "      LogFormat \"%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\" %I %O\" combinedio";
    $f[] = "    </IfModule>";
    $f[] = "";
    $f[] = "    CustomLog \"/var/log/apache-zarafa/access.log\" combinedv";
    $f[] = "</IfModule>";
    $f[] = "";
    $f[] = "<IfModule alias_module>";
    $f[] = "    ScriptAlias /cgi-bin/ \"/usr/local/apache-groupware/data/cgi-bin/\"";
    $f[] = "    Alias /images /usr/share/obm2/resources";
    $f[] = "";
    $f[] = "</IfModule>";
    $f[] = "";
    $f[] = "<IfModule cgid_module>";
    $f[] = "";
    $f[] = "</IfModule>";
    $f[] = "";
    $f[] = "";
    $f[] = "<Directory \"/usr/local/apache-groupware/data/cgi-bin\">";
    $f[] = "    AllowOverride None";
    $f[] = "    Options None";
    $f[] = "    Order allow,deny";
    $f[] = "    Allow from all";
    $f[] = "</Directory>";
    $f[] = "";
    $f[] = "";
    $f[] = "DefaultType text/plain";
    $f[] = "";
    $f[] = "<IfModule mime_module>";
    $f[] = "   ";
    $f[] = "    TypesConfig /etc/mime.types";
    $f[] = "    #AddType application/x-gzip .tgz";
    $f[] = "    AddType application/x-compress .Z";
    $f[] = "    AddType application/x-gzip .gz .tgz";
    $f[] = "    AddType application/x-httpd-php .php .phtml";
    $f[] = "    #AddHandler cgi-script .cgi";
    $f[] = "    #AddHandler type-map var";
    $f[] = "    #AddType text/html .shtml";
    $f[] = "    #AddOutputFilter INCLUDES .shtml";
    $f[] = "</IfModule>";
    @file_put_contents('/etc/zarafa/httpd.conf', @implode("\n", $f) . "\n");
    if ($GLOBALS["OUTPUT"]) {
        echo "Configuring...: " . date("H:i:s") . " /etc/zarafa/httpd.conf done\n";
    }
}
function buildUsers()
{
    $users = new usersMenus();
    $unix = new unix();
    $sock = new sockets();
    $q = new mysql();
    $sql = "SELECT * FROM webdavusers";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        die($q->mysql_error);
    }
    $c = 0;
    $APACHE_DIR_SITES_ENABLED = $users->APACHE_DIR_SITES_ENABLED;
    if ($GLOBALS["VERBOSE"]) {
        echo "APACHE_DIR_SITES_ENABLED.....: {$APACHE_DIR_SITES_ENABLED}\n";
    }
    foreach (glob("{$APACHE_DIR_SITES_ENABLED}/webdav.*.apache") as $filename) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Unlink: {$filename}\n";
        }
        @unlink($filename);
        $c++;
    }
    $EnableWebDavPerUser = $sock->GET_INFO("EnableWebDavPerUser");
    $WebDavPerUserSets = unserialize(base64_decode($sock->GET_INFO("WebDavPerUserSets")));
    if (!is_numeric($EnableWebDavPerUser)) {
        $EnableWebDavPerUser = 0;
    }
    $EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb");
    if (!is_numeric($EnableFreeWeb)) {
        $EnableFreeWeb = 0;
    }
    if ($EnableFreeWeb == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "FreeWebs is not enabled\n";
        }
        return;
    }
    if ($EnableWebDavPerUser == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "EnableWebDavPerUser is not enabled\n";
        }
        return;
    }
    $WebDavSuffix = $WebDavPerUserSets["WebDavSuffix"];
    if ($WebDavSuffix == null) {
        if ($GLOBALS["VERBOSE"]) {
            echo "WebDavSuffix is not set\n";
        }
        return;
    }
    $FreeWebListen = $unix->APACHE_ListenDefaultAddress();
    $FreeWebListenPort = $sock->GET_INFO("FreeWebListenPort");
    $FreeWebListenSSLPort = $sock->GET_INFO("FreeWebListenSSLPort");
    $FreeWebsDisableSSLv2 = $sock->GET_INFO("FreeWebsDisableSSLv2");
    if ($FreeWebListen == null) {
        $FreeWebListen = "*";
    }
    if ($FreeWebListen != "*") {
        $FreeWebListenApache = "{$FreeWebListen}";
    }
    if ($FreeWebListenSSLPort == null) {
        $FreeWebListenSSLPort = 443;
    }
    if (!is_numeric($FreeWebListenSSLPort)) {
        $FreeWebListenSSLPort = 443;
    }
    if (!is_numeric($FreeWebListenPort)) {
        $FreeWebListenPort = 80;
    }
    if (!is_numeric($FreeWebsDisableSSLv2)) {
        $FreeWebsDisableSSLv2 = 0;
    }
    if ($unix->IsSquidReverse()) {
        $FreeWebListenPort = 82;
        $FreeWebListenPort = 447;
        $FreeWebListen = "127.0.0.1";
    }
    if ($unix->isNGnx()) {
        $FreeWebListenPort = 82;
        $FreeWebListenPort = 447;
        $FreeWebListen = "127.0.0.1";
    }
    $port = $FreeWebListen;
    $SSL = $WebDavPerUserSets["EnableSSL"];
    if (!is_numeric($SSL)) {
        $SSL = 0;
    }
    echo "Starting......: " . date("H:i:s") . " Apache Listen {$FreeWebListen}:{$FreeWebListenPort}, SSL enabled={$SSL} SSL Port:{$FreeWebListenSSLPort} SSLv2={$FreeWebsDisableSSLv2}\n";
    $ldap = new clladp();
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $uid = $ligne["uid"];
        $usr = new user($uid);
        $HomeDirectory = $usr->homeDirectory;
        if (trim($HomeDirectory) == null) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$uid}: Home Directory is not set !\n";
                continue;
            }
        }
        if (!is_numeric($usr->group_id)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Search group of {$uid}...\n";
            }
            $usr->group_id = getentGroup($uid);
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "servername will be {$uid}.{$WebDavSuffix} usergroup = `{$usr->group_id}`\n";
        }
        $group = new groups($usr->group_id);
        if ($group->groupName == null) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Cannot find group name for {$uid}\n";
            }
            continue;
        }
        $servername = "{$uid}.{$WebDavSuffix}";
        @mkdir("{$usr->homeDirectory}/.dav", 0755, true);
        $f = array();
        if ($SSL == 1) {
            $GLOBALS["CLASS_UNIX"]->vhosts_BuildCertificate($servername);
            $port = $FreeWebListenSSLPort;
            $f[] = "<VirtualHost {$FreeWebListen}:{$FreeWebListenPort}>";
            $f[] = "\tRewriteEngine On";
            $f[] = "\tRewriteCond %{HTTPS} off";
            $f[] = "\tRewriteRule (.*) https://%{HTTP_HOST}:{$FreeWebListenSSLPort}";
            $f[] = "</VirtualHost>";
            $f[] = "";
            $FreeWebListenPort = $FreeWebListenSSLPort;
        }
        $f[] = "<VirtualHost {$FreeWebListen}:{$FreeWebListenPort}>";
        if ($SSL == 1) {
            $f[] = "\tSetEnvIf User-Agent \".*MSIE.*\" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0";
            $f[] = "\tSSLEngine on";
            $f[] = "\tSSLCertificateFile {$GLOBALS["SSLKEY_PATH"]}/{$servername}.crt";
            $f[] = "\tSSLCertificateKeyFile {$GLOBALS["SSLKEY_PATH"]}/{$servername}.key";
            if ($FreeWebsDisableSSLv2 == 1) {
                $f[] = "\tSSLProtocol -ALL +SSLv3 +TLSv1";
                $f[] = "\tSSLCipherSuite ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM";
            }
        }
        $f[] = "\tServerName {$servername}";
        $f[] = "\tServerAdmin {$usr->mail}";
        $f[] = "\tDocumentRoot {$usr->homeDirectory}";
        //$f[]="        ServerAlias hostname.domaine.tld";
        $f[] = "\t<IfModule mpm_itk_module>";
        $f[] = "\t\tAssignUserId {$usr->uid} {$group->groupName}";
        $f[] = "\t</IfModule>";
        $f[] = "#WEBDAV";
        $f[] = "\tDavLockDB \"{$usr->homeDirectory}/.dav/DavLock\"";
        include_once dirname(__FILE__) . "/ressources/class.freeweb.inc";
        $freeweb = new freeweb();
        $conf[] = $freeweb->WebDavBrowserMatches();
        $f[] = "\t<Directory {$usr->homeDirectory}>";
        $f[] = "\t\tOptions Indexes FollowSymLinks MultiViews";
        $f[] = "\t\tAllowOverride None";
        $f[] = "\t\tOrder allow,deny";
        $f[] = "\t\tallow from all";
        $f[] = "\tDAV On";
        $f[] = "\tDAVMinTimeout 600";
        $f[] = "\tAuthType Basic";
        $f[] = "\tAuthBasicProvider ldap";
        $f[] = "\tAuthName \"{$servername} {$uid} Only\"";
        $f[] = "\tAuthLDAPURL ldap://{$ldap->ldap_host}:{$ldap->ldap_port}/dc=organizations,{$ldap->suffix}?uid?sub";
        $f[] = "\tAuthLDAPBindDN cn={$ldap->ldap_admin},{$ldap->suffix}";
        $f[] = "\tAuthLDAPBindPassword {$ldap->ldap_password}";
        $f[] = "\tAuthLDAPGroupAttribute memberUid";
        $f[] = "\tRequire user {$uid}";
        $f[] = "\tRequire valid-user";
        $f[] = "\t</Directory>";
        $f[] = "";
        $f[] = "\tLogFormat \"%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\" %V\" combinedv";
        $f[] = "\tCustomLog {$usr->homeDirectory}/webdav_access.log combinedv";
        $f[] = "\tErrorLog {$usr->homeDirectory}/webdav_error.log";
        $f[] = "\tLogLevel warn";
        $f[] = "";
        $f[] = "</VirtualHost>";
        if ($GLOBALS["VERBOSE"]) {
            echo "{$uid} saving {$APACHE_DIR_SITES_ENABLED}/webdav.{$uid}.apache\n";
        }
        @file_put_contents("{$APACHE_DIR_SITES_ENABLED}/webdav.{$uid}.apache", @implode("\n", $f));
        $c++;
    }
    if ($c > 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$GLOBALS["APACHECTL"]} -k restart 2>&1\n";
        }
        exec("{$GLOBALS["APACHECTL"]} -k restart 2>&1", $results);
    }
}
function vhosts_users_ou($array)
{
    $unix = new unix();
    $ldap = new clladp();
    $sock = new sockets();
    $ApacheGroupWarePort = $sock->GET_INFO("ApacheGroupWarePort");
    $SSLStrictSNIVHostCheck = $sock->GET_INFO("SSLStrictSNIVHostCheck");
    $ou = $array["OU"][0];
    $apacheservername = trim($array["apacheservername"][0]);
    $wwwservertype = trim($array["wwwservertype"][0]);
    $wwwsslmode = $array["wwwsslmode"][0];
    $root = $array["apachedocumentroot"][0];
    $index_cgi = $unix->BACKUPPC_GET_CGIBIN_PATH();
    $img_dir = $unix->BACKUPPC_GET_IMG_DIR();
    if ($index_cgi == null) {
        echo "Starting Apache..............: BackupPC Unable to stat index.cgi\n";
        return;
    }
    if ($img_dir == null) {
        echo "Starting Apache..............: BackupPC Unable to images path\n";
        return;
    }
    @mkdir($root, 0755, true);
    shell_exec("/bin/cp {$index_cgi} {$root}/index.cgi");
    shell_exec("/bin/ln -s {$img_dir} {$root}/image >/dev/null 2>&1");
    shell_exec("chmod 4755 {$root}/index.cgi");
    patchIndex($root);
    $apacheuser = $unix->APACHE_GROUPWARE_ACCOUNT();
    if (preg_match("#(.+?):#", $apacheuser, $re)) {
        $apacheuser = $re[1];
    }
    shell_exec("chown -R backuppc:{$apacheuser} {$root}");
    system("chmod 4755 {$root}/index.cgi");
    $ApacheGroupWarePort_WRITE = $ApacheGroupWarePort;
    echo "Starting Apache..............: BackupPC checking host {$apacheservername} in {$root} for {$apacheuser}:backuppc\n";
    if ($wwwsslmode == "TRUE") {
        $ssl[] = "\tSSLEngine on";
        $ssl[] = "\tSSLCertificateFile {$GLOBALS["SSLKEY_PATH"]}/{$apacheservername}.crt";
        $ssl[] = "\tSSLCertificateKeyFile {$GLOBALS["SSLKEY_PATH"]}/{$apacheservername}.key";
        $unix->vhosts_BuildCertificate($apacheservername);
        $ApacheGroupWarePort_WRITE = "443";
        $SSLMODE = true;
        $conf[] = "\n<VirtualHost *:{$ApacheGroupWarePort}>";
        $conf[] = "\tServerName {$apacheservername}";
        $conf[] = "\tRedirect / https://{$apacheservername}";
        $conf[] = "</VirtualHost>\n";
    }
    echo "Starting Apache..............: BackupPC \"{$apacheservername}:{$ApacheGroupWarePort_WRITE}\"\n";
    $conf[] = "\n<VirtualHost *:{$ApacheGroupWarePort_WRITE}>";
    $conf[] = "\tServerName {$apacheservername}";
    //$conf[]="\tSuexecUserGroup backuppc backuppc";
    $conf[] = "\tServerAdmin webmaster@{$apacheservername}";
    $conf[] = "\tDocumentRoot {$root}";
    $conf[] = @implode("\n", $ssl);
    include_once dirname(__FILE__) . "/ressources/class.freeweb.inc";
    $freeweb = new freeweb();
    $conf[] = $freeweb->WebDavBrowserMatches();
    $conf[] = "\tAlias /backuppc {$root}";
    $conf[] = "\t<Directory \"{$root}\">";
    $conf[] = "\tAllowOverride None";
    $conf[] = "\tAllow from all";
    $conf[] = "\tOptions ExecCGI FollowSymlinks";
    $conf[] = "\tAddHandler cgi-script .cgi";
    $conf[] = "\tDirectoryIndex index.cgi";
    $conf[] = "\t\tAuthType Basic";
    $conf[] = "\t\tAuthBasicProvider ldap";
    $conf[] = "\t\tAuthzLDAPAuthoritative off";
    $conf[] = "\t\tAuthUserFile /dev/null";
    $conf[] = "\t\tAuthLDAPBindDN \"cn={$ldap->ldap_admin},{$ldap->suffix}\"";
    $conf[] = "\t\tAuthLDAPBindPassword {$ldap->ldap_password}";
    $conf[] = "\t\tAuthLDAPUrl ldap://{$ldap->ldap_host}:{$ldap->ldap_port}/ou={$ou},dc=organizations,{$ldap->suffix}?uid";
    $conf[] = "\t\tAuthName \"Authorization required\"";
    $conf[] = "\t\trequire ldap-filter &(uid=*)";
    $conf[] = "\t\trequire valid-user";
    $conf[] = "\t</Directory>";
    $conf[] = "</VirtualHost>\n";
    return @implode("\n", $conf);
}
function FREEWEB_CONTENT_SAVE()
{
    $FREEWEB_CONTENT = url_decode_special_tool($_POST["FREEWEB_CONTENT"]);
    $free = new freeweb($_POST["servername"]);
    $free->SaveContentPlus($FREEWEB_CONTENT);
}
function FREEWEB_DELETE($value)
{
    $hostname = base64_decode($value);
    $EXEC_NICE = EXEC_NICE();
    if (is_file("/usr/bin/nohup")) {
        $nohup = "/usr/bin/nohup ";
    }
    $reload_datas = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-freewebs >/dev/null 2>&1 &";
    include_once dirname(__FILE__) . '/ressources/class.freeweb.inc';
    $freeweb = new freeweb($hostname);
    $freeweb->delete();
    send_email_events("Success deleting {$hostname} web site", null, "CLOUD");
    shell_exec($reload_datas);
    return true;
}
Exemple #21
0
function duplicate_wordpress($servername)
{
    $unix = new unix();
    $q = new mysql();
    $free = new freeweb($servername);
    $WORKING_DIRECTORY = $free->www_dir;
    if ($free->groupware_duplicate == null) {
        build_progress("{$servername}: {duplicate} {$servername} no duplicate set...", 42);
        sleep(2);
        return false;
    }
    $free2 = new freeweb($free->groupware_duplicate);
    if ($free2->mysql_database == null) {
        echo "Fatal: {$free->groupware_duplicate} did not have any such DB set, try to find it..\n";
        $free2->mysql_database = $free2->CreateDatabaseName();
        echo "Fatal: {$free->groupware_duplicate} = {$free2->mysql_database}\n";
    }
    if (!$q->DATABASE_EXISTS($free2->mysql_database, true)) {
        build_progress("{$servername}: {duplicate} {$free->groupware_duplicate} did not have any database...", 42);
        sleep(2);
        return false;
    }
    $srcdir = $free2->www_dir;
    $Mysqlpassword = null;
    $cp = $unix->find_program("cp");
    $rm = $unix->find_program("rm");
    if (@is_link($WORKING_DIRECTORY)) {
        $WORKING_DIRECTORY = @readlink($WORKING_DIRECTORY);
    }
    if (is_dir($WORKING_DIRECTORY)) {
        build_progress("{$servername}: {removing} {$WORKING_DIRECTORY}...", 42);
        sleep(2);
        shell_exec("{$rm} -rf {$WORKING_DIRECTORY}/*");
    }
    @mkdir($WORKING_DIRECTORY, 0755, true);
    build_progress("{$servername}: {installing} {from} {$srcdir}...", 42);
    shell_exec("{$cp} -rf {$srcdir}/* {$WORKING_DIRECTORY}/");
    $wordpressDB = $free->mysql_database;
    if ($wordpressDB == null) {
        $wordpressDB = $free->CreateDatabaseName();
    }
    if ($q->DATABASE_EXISTS($wordpressDB)) {
        build_progress("{$servername}: {remove_database} {$wordpressDB}...", 42);
        sleep(2);
        if (!$q->DELETE_DATABASE($wordpressDB)) {
            build_progress("{$servername}: {remove_database} {$wordpressDB} {failed}...", 42);
            return false;
        }
        if (!$q->CREATE_DATABASE($wordpressDB, true)) {
            build_progress("{$servername}: {create_database} {$wordpressDB} {failed}...", 42);
            return false;
        }
    }
    if (!$q->DATABASE_EXISTS($wordpressDB)) {
        if (!$q->CREATE_DATABASE($wordpressDB, true)) {
            build_progress("{$servername}: {create_database} {$wordpressDB} {failed}...", 42);
            return false;
        }
    }
    build_progress("{$servername}: {backup_database} {from} {$free2->mysql_database}...", 42);
    $mysqldump = $unix->find_program("mysqldump");
    $q = new mysql();
    if ($q->mysql_password != null) {
        $Mysqlpassword = "******" . $unix->shellEscapeChars($q->mysql_password);
    }
    $t = time();
    $TMP_FILE = $unix->FILE_TEMP();
    $cmdline = trim("{$mysqldump} --add-drop-table --single-transaction --force --insert-ignore -S /var/run/mysqld/mysqld.sock -u {$q->mysql_admin}{$Mysqlpassword} {$free2->mysql_database} >{$TMP_FILE} 2>&1");
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmdline}\n";
    }
    $results = array();
    exec($cmdline, $results);
    while (list($num, $ligne) = each($results)) {
        echo "{$ligne}\n";
        if (preg_match("#ERROR\\s+([0-9]+)#", $ligne)) {
            build_progress("{$servername}: {restore_database} {to} {$wordpressDB} {failed}..", 42);
            sleep(3);
            return false;
        }
    }
    build_progress("{$servername}: {restore_database} {to} {$wordpressDB}..", 42);
    $mysqlbin = $unix->find_program("mysql");
    $cmd = "{$mysqlbin} --batch --force -S /var/run/mysqld/mysqld.sock -u {$q->mysql_admin}{$Mysqlpassword} --database={$wordpressDB} <{$TMP_FILE} 2>&1";
    if ($GLOBALS["VERBOSE"]) {
        echo "{$cmd}\n";
    }
    exec($cmd, $results);
    while (list($num, $ligne) = each($results)) {
        echo "{$ligne}\n";
        if (preg_match("#ERROR\\s+([0-9]+)#", $ligne)) {
            build_progress("{$servername}: {restore_database} {to} {$wordpressDB} {failed}..", 42);
            sleep(3);
            return false;
        }
    }
    build_progress("{$servername}: {restore_database} {to} {$wordpressDB}..{done}", 42);
    @unlink($TMP_FILE);
    if (!scan($WORKING_DIRECTORY)) {
        build_progress("{$servername}: {install} {failed}", 42);
        sleep(3);
        return false;
    }
    $proto = "http";
    if ($free->useSSL == 1) {
        $proto = "https";
    }
    $sql = "UPDATE `wp_options` SET `option_value`='{$proto}://{$servername}' WHERE `option_name`='siteurl'";
    $q->QUERY_SQL($sql, $wordpressDB);
    if (!$q->ok) {
        echo $q->mysql_error;
        build_progress("{$servername}: {install} {failed}", 42);
        sleep(3);
        return false;
    }
    $sql = "UPDATE `wp_options` SET `option_value`='{$proto}://{$servername}' WHERE `option_name`='home'";
    $q->QUERY_SQL($sql, $wordpressDB);
    if (!$q->ok) {
        echo $q->mysql_error;
        build_progress("{$servername}: {install} {failed}", 42);
        sleep(3);
        return false;
    }
    $free->groupware_duplicate = null;
    $free->CreateSite(true);
    return true;
}
Exemple #22
0
function Save()
{
    $free = new freeweb($_POST["servername"]);
    if (isset($_POST["LDAP_PASSWORD"])) {
        $_POST["LDAP_PASSWORD"] = url_decode_special_tool($_POST["LDAP_PASSWORD"]);
    }
    if (isset($_POST["LDAP_FILTER"])) {
        $_POST["LDAP_FILTER"] = url_decode_special_tool($_POST["LDAP_FILTER"]);
    }
    $t = time();
    while (list($num, $line) = each($_POST)) {
        $free->Params["FILEZ"][$num] = $line;
    }
    $free->SaveParams();
}
Exemple #23
0
function adv_form_save()
{
    $f = new freeweb($_POST["servername"]);
    while (list($key, $line) = each($_POST)) {
        $f->Params["Proxy"][$key] = $line;
    }
    $f->SaveParams();
}
Exemple #24
0
function save()
{
    $free = new freeweb($_POST["servername"]);
    $GEOIP = $free->Params["GEOIP"];
    if ($_POST["value"] == 0) {
        unset($free->Params["GEOIP"][$_POST["country"]]);
    } else {
        $free->Params["GEOIP"][$_POST["country"]] = 1;
    }
    $free->SaveParams();
}
function browseWebserversdirs()
{
    $q = new mysql();
    $H[null] = "{none}";
    $sql = "SELECT servername FROM freeweb ORDER BY servername";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        $free = new freeweb($ligne["servername"]);
        $free->CheckWorkingDirectory();
        $H[$free->WORKING_DIRECTORY] = $ligne["servername"];
    }
    return $H;
}
function SaveConfig()
{
    $free = new freeweb($_POST["servername"]);
    $page = CurrentPageName();
    $tpl = new templates();
    $free->Params["NTLM"]["enabled"] = $_POST["enable_ntlm_authentication"];
    $free->Params["LDAP"]["enabled"] = $_POST["enable_ldap_authentication"];
    $free->Params["LDAP"]["authentication_banner"] = base64_encode($_POST["authentication_banner"]);
    $free->Params["LDAP"]["EnableLDAPAllSubDirectories"] = $_POST["EnableLDAPAllSubDirectories"];
    $free->SaveParams();
}
function create_articaweb($websitename)
{
    if ($websitename == null) {
        return;
    }
    $sock = new sockets();
    $sock->SET_INFO("EnableFreeWeb", 1);
    restart_artica_status();
    restart_apache_src();
    include_once dirname(__FILE__) . "/ressources/class.freeweb.inc";
    $free = new freeweb($websitename);
    $free->servername = $websitename;
    $free->groupware = "ARTICA_ADM";
    $free->CreateSite();
    rebuild_vhost($websitename);
}
Exemple #28
0
function popup()
{
    $t = time();
    $html = "<div id='{$t}'></div>\n\t<script>\n\t\tLoadAjax('{$t}','freeweb.edit.main.php?servername={$_GET["servername"]}&force-groupware={$_GET["force-groupware"]}&t={$_GET["t"]}');\n\t</script>\n\t\n\t\n\t";
    echo $html;
    return;
    $sql = "SELECT * FROM freeweb WHERE servername='{$_GET["servername"]}'";
    $page = CurrentPageName();
    $users = new usersMenus();
    $tpl = new templates();
    $q = new mysql();
    $sock = new sockets();
    $APACHE_PROXY_MODE = 0;
    $DNS_INSTALLED = false;
    $remove_sql = false;
    $OnlyWebSite = false;
    $countloops = countloops();
    $no_usersameftpuser = $tpl->javascript_parse_text("{no_usersameftpuser}");
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    $error_field_max_length = $tpl->javascript_parse_text("{error_field_max_length}");
    $error_please_fill_field = $tpl->javascript_parse_text("{error_please_fill_field}");
    $acl_dstdomain = $tpl->javascript_parse_text("{acl_dstdomain}");
    $mysql_database = $tpl->javascript_parse_text("{mysql_database}");
    $username = $tpl->javascript_parse_text("{username}");
    $password = $tpl->javascript_parse_text("{password}");
    $vgservices = unserialize(base64_decode($sock->GET_INFO("vgservices")));
    $checkboxes = 1;
    $ButtonName = "{apply}";
    if ($ligne["groupware"] == "cachemgr") {
        $checkboxes = 0;
    }
    $users = new usersMenus();
    $PUREFTP_INSTALLED = 1;
    if (!$users->PUREFTP_INSTALLED) {
        $PUREFTP_INSTALLED = 0;
    }
    $ServerIPVAL = trim($ligne["ServerIP"]);
    $ServerPort = trim($ligne["ServerPort"]);
    $UseDefaultPort = 0;
    if ($users->APACHE_PROXY_MODE) {
        $APACHE_PROXY_MODE = 1;
    }
    $parcourir_domaines = "<input type='button' OnClick=\"javascript:Loadjs('browse.domains.php?field=domainname')\" value='{browse}...'>";
    if ($users->dnsmasq_installed) {
        $DNS_INSTALLED = true;
    }
    if ($users->POWER_DNS_INSTALLED) {
        $DNS_INSTALLED = true;
    }
    $FreeWebDisableSSL = trim($sock->GET_INFO("FreeWebDisableSSL"));
    if (!is_numeric($FreeWebDisableSSL)) {
        $FreeWebDisableSSL = 0;
    }
    $check_configuration = $tpl->_ENGINE_parse_body("{check_configuration}");
    $webservice = $tpl->_ENGINE_parse_body("{webservice}");
    $ServerIPVAL = "{$ServerIPVAL}:{$ServerPort}";
    if ($vgservices["freewebs"] != null) {
        if (!is_numeric($ligne["lvm_size"])) {
            $ligne["lvm_size"] = 5000;
        }
        if ($ligne["lvm_vg"] == null) {
            $ligne["lvm_vg"] = $vgservices["freewebs"];
        }
        $sizelimit = "\n\t\t<tr>\n\t\t<td class=legend>{size}:</td>\n\t\t<td style='font-size:13px;'>" . Field_text("vg_size", $ligne["lvm_size"], "font-size:13px;padding:3px;width:60px") . "&nbsp;MB</td>\n\t\t<td>&nbsp;</td>\n\t\t</tr>";
    }
    $freeweb = new freeweb($_GET["servername"]);
    $groupwarelink = $freeweb->groupwares_InstallLink();
    $groupwares_textintro = $freeweb->groupwares_textintro();
    if ($groupwarelink != null) {
        $explain = "\n\t\t<div class=explain>{$groupwares_textintro}:<br><strong style='font-size:14px'>\n\t\t\t<a href=\"javascript:blur()\" OnClick=\"javascript:s_PopUpFull('{$groupwarelink}',1024,768)\" style='text-decoration:underline;font-weight:bold;color:#969696'>{$groupwarelink}</a></strong></div>\t\t\n\t\t";
    }
    $img = "website-64.png";
    if ($_GET["force-groupware"] != null) {
        $vhosts = new vhosts();
        $img = $vhosts->IMG_ARRAY_64[$_GET["force-groupware"]];
        $imgtitle = "<div style='font-size:14px;font-weight:bold'>{" . $vhosts->TEXT_ARRAY[$_GET["force-groupware"]]["TITLE"] . "}</div>";
        if ($_GET["force-groupware"] == "ZARAFA") {
            $remove_sql = true;
            $OnlyWebSite = true;
        }
        if ($_GET["force-groupware"] == "Z-PUSH") {
            $remove_sql = true;
            $OnlyWebSite = true;
        }
        if ($_GET["force-groupware"] == "ZARAFA_MOBILE") {
            $remove_sql = true;
            $OnlyWebSite = true;
        }
        if ($_GET["force-groupware"] == "ROUNDCUBE") {
            $OnlyWebSite = true;
        }
    }
    if ($_GET["servername"] == null) {
        $ButtonName = "{add}";
    }
    $freeweb = new freeweb($_GET["servername"]);
    if ($ligne["domainname"] == null) {
        $dda = explode(".", $ligne["servername"]);
        $hostname = $dda[0];
        unset($dda[0]);
        $domainname = @implode(".", $dda);
    } else {
        $ff = explode(".", $ligne["servername"]);
        if (count($ff) > 2) {
            $hostname = str_replace(".{$ligne["domainname"]}", "", $ligne["servername"]);
        } else {
            $hostname = null;
        }
        $domainname = $ligne["domainname"];
        $parcourir_domaines = null;
    }
    if ($hostname == "_default_") {
        $parcourir_domaines = null;
    }
    if ($DNS_INSTALLED) {
        include_once dirname(__FILE__) . "/ressources/class.system.network.inc";
        include_once dirname(__FILE__) . "/ressources/class.pdns.inc";
        $pdns = new pdns();
        if ($ligne["servername"] == null) {
            $ip = new networking();
            $ips = $ip->ALL_IPS_GET_ARRAY();
            $ips[null] = "{none}";
            $dns_field = "<tr>\n\t\t\t\t<td class=legend nowrap>{dns_entry}:</td>\n\t\t\t\t<td>" . Field_array_Hash($ips, "ADD_DNS_ENTRY", null, "style:font-size:14px") . "</td>\n\t\t\t\t<td>" . help_icon("freeweb_add_dns_entry_explain") . "</td>\n\t\t\t</tr>";
        } else {
            $hostip = $pdns->GetIp($ligne["servername"]);
            if ($hostip != null) {
                $dns_field = "<tr>\n\t\t\t\t<td class=legend nowrap>{dns_entry}:</td>\n\t\t\t\t<td style='font-size:14px'>{$hostip}</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>";
            } else {
                $ip = new networking();
                $ips = $ip->ALL_IPS_GET_ARRAY();
                $ips[null] = "{none}";
                $dns_field = "<tr>\n\t\t\t\t<td class=legend nowrap>{dns_entry}:</td>\n\t\t\t\t<td>" . Field_array_Hash($ips, "ADD_DNS_ENTRY", null, "style:font-size:14px") . "</td>\n\t\t\t\t<td>" . help_icon("freeweb_add_dns_entry_explain") . "</td>\n\t\t\t</tr>";
            }
        }
    }
    $domain = "<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td>" . Field_text("servername", $hostname, "font-size:15px;padding:3px;font-weight:bold;width:90px") . "</td>\n\t\t\t<td style='font-size:14px' align='center' width=1%>&nbsp;.&nbsp;</td>\n\t\t\t<td>" . Field_text("domainname", $domainname, "font-size:15px;padding:3px;width:220px;font-weight:bold") . "</td>\n\t\t\t<td>{$parcourir_domaines}</td>\n\t\t</tr>\n\t\t</table>";
    if (!$users->AsSystemAdministrator) {
        if ($ligne["domainname"] == null) {
            $dd = explode(".", $ligne["servername"]);
            $hostname = $dd[0];
            unset($dd[0]);
            $domainname = @implode(".", $dd);
        } else {
            $ff = explode(".", $ligne["servername"]);
            if (count($ff) > 2) {
                $hostname = str_replace(".{$ligne["domainname"]}", "", $ligne["servername"]);
            } else {
                $hostname = null;
            }
            $domainname = $ligne["domainname"];
        }
        $ldap = new clladp();
        $domains = $ldap->Hash_domains_table($_SESSION["ou"]);
        while (list($a, $b) = each($domains)) {
            $c[$a] = $a;
        }
        $domain = "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td>" . Field_text("servername", $hostname, "font-size:15px;padding:3px;font-weight:bold;width:90px") . "</td>\n\t\t\t<td style='font-size:14px' align='center' width=1%>&nbsp;.&nbsp;</td>\n\t\t\t<td>" . Field_array_Hash($c, "domainname", $domainname, "style:font-size:15px;padding:3px;font-weight:bold;width:220px;") . "</td>\n\t\t</tr>\n\t\t</table>";
    }
    $NewServer = 0;
    $reconfigure = ParagrapheTEXT("48-settings-refresh.png", "{rebuild}", "{rebuild_apache_text}", "javascript:FreeWebsRebuildvHosts()");
    if (trim($ligne["servername"] == null)) {
        $reconfigure = ParagrapheTEXT_disabled("48-settings-refresh.png", "{rebuild}", "{rebuild_apache_text}");
        $NewServer = 1;
    }
    if ($NewServer == 0) {
        $domain = "<div style='font-size:16px'>{$ligne["servername"]}</div>\n\t\t\t<input type='hidden' value='{$ligne["servername"]}' id='servername'>\n\t\t\t<input type='hidden' value='{$ligne["domainname"]}' id='domainname'>";
    }
    if ($ligne["groupware"] != null) {
        $apache = new vhosts();
        $img = $apache->IMG_ARRAY_64[$ligne["groupware"]];
        $rebuild_groupware = ParagrapheTEXT("setup-icon-48.png", "{software}", "{rebuild_apache_groupware_text}", "javascript:FreeWebsRebuildGroupware()");
        $sql = "SELECT ID FROM drupal_queue_orders WHERE `ORDER`='REBUILD_GROUPWARE' AND `servername`='{$servername}'";
        $ligneDrup = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
        if (!is_numeric($ligneDrup["ID"])) {
            $ligneDrup["ID"] = 0;
        }
        if ($ligneDrup["ID"] > 0) {
            $rebuild_groupware = ParagrapheTEXT_disabled("setup-icon-48.png", "{software}", "{rebuild_apache_groupware_text}");
        }
        if ($ligne["groupware"] == "ZARAFA") {
            $remove_sql = true;
            $OnlyWebSite = true;
        }
        if ($ligne["groupware"] == "Z-PUSH") {
            $remove_sql = true;
            $OnlyWebSite = true;
        }
        if ($ligne["groupware"] == "ZARAFA_MOBILE") {
            $remove_sql = true;
            $OnlyWebSite = true;
        }
        if ($ligne["groupware"] == "ROUNDCUBE") {
            $OnlyWebSite = true;
        }
        if ($ligne["ForceInstanceZarafaID"] > 0) {
            $_GET["ForceInstanceZarafaID"] = $ligne["ForceInstanceZarafaID"];
        }
    }
    $checksDebug = ParagrapheTEXT("setup-check-icon-48.png", "{check_configuration}", "{check_configuration_text}", "javascript:FreeWebsCheckGroupware()");
    if ($remove_sql) {
        $js_removesql = "HideMysql()";
    }
    if ($OnlyWebSite) {
        $js_OnlyWebSite = "OnlyWebsite()";
    }
    $uid_uri = urlencode(base64_encode($ligne["uid"]));
    $nets = unserialize(base64_decode($sock->GET_INFO("FreeWebsApacheListenTable")));
    $znets[null] = "{default}";
    while (list($num, $ip) = each($nets)) {
        $znets[$num] = $num;
    }
    $ServerIP = Field_array_Hash($znets, 'ServerIP', $ServerIPVAL, null, null, 0, 'font-size:14px;');
    $q = new mysql();
    include_once dirname(__FILE__) . "/ressources/class.squid.reverse.inc";
    $squid_reverse = new squid_reverse();
    $sslcertificates = $squid_reverse->ssl_certificates_list();
    $sslcertificate = Field_array_Hash($sslcertificates, $ligne["sslcertificate"], "style:font-size:14px");
    $html = "\n\t<input type='hidden' id='force-groupware' name ='force-groupware' value='{$_GET["force-groupware"]}'>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top' width=1%>\n\t\t\t<center>\n\t\t\t\t<img src='img/{$img}'>{$imgtitle}\n\t\t\t</center><br>\n\t\t\t<div style='width:190px'>\n\t\t\t{$reconfigure}{$rebuild_groupware}{$checksDebug}{$see_config}\n\t\t\t</div>\n\t\t</td>\n\t\t<td valign='top' width=99%>\n\t{$explain}\n\t<div style='font-size:16px'><a href=\"javascript:blur();\" style='font-size:18px;text-decoration:underline;margin-bottom:5px' \n\tOnClick=\"javascript:document.getElementById('block2').style.display='none';document.getElementById('block1').style.display='block';\">{$webservice}:</a></div>\n\t\n\t<div id='freewebdiv'>\n\t\t<div id='block1' style='display:block;'>\n\t\t\t<table style='width:99%' class=form>\n\t\t\t<tr> \n\t\t\t\t<td class=legend nowrap>{acl_dstdomain}:</td>\n\t\t\t\t<td colspan=2>{$domain}</td>\n\t\t\t</tr>\n\t\t\t<tr> \n\t\t\t\t<td class=legend nowrap>{listen_address}:</td>\n\t\t\t\t<td colspan=2>{$ServerIP}</td>\n\t\t\t</tr>\t\t\t\t\t\n\t\t\t{$dns_field}\n\t\t\t<tr> \n\t\t\t\t<td class=legend nowrap>{www_forward}:</td>\n\t\t\t\t<td width=1%>" . Field_checkbox("Forwarder", 1, $ligne["Forwarder"], "CheckForwarder()") . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\t\t\t\t\n\t\t\t<tr> \n\t\t\t\t<td class=legend nowrap>{reverse_proxy}:</td>\n\t\t\t\t<td width=1%>" . Field_checkbox("UseReverseProxy", 1, $ligne["UseReverseProxy"], "CheckUseReverseProxy()") . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\t\t\n\t\t\t\n\t\t\t<tr> \n\t\t\t\t<td class=legend nowrap>{directory}:</td>\n\t\t\t\t<td>" . Field_text("www_dir", $ligne["www_dir"], "font-size:13px;padding:3px;") . "</td>\n\t\t\t\t<td>" . button_browse("www_dir") . "</td>\n\t\t\t</tr>\t\t\t\n\t\t\t\n\t\t\t{$sizelimit}\n\t\t\t<tr>\n\t\t\t\t<td class=legend nowrap>{UseLoopDisk}:</td>\n\t\t\t\t<td>" . Field_checkbox("UseLoopDisk", 1, $ligne["UseLoopDisk"], "CheckLoops()") . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\n\t\t\t<tr style='height:auto'>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t<td colspan=2 style='height:auto'><span id='loops-list'></span></td></tr>\t\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend>{member}:</td>\n\t\t\t\t<td>" . Field_text("www_uid", $ligne["uid"], "font-size:13px;padding:3px;") . "</td>\n\t\t\t\t<td><span id='bb_button'><input type='button' OnClick=\"javascript:Loadjs('user.browse.php?field=www_uid&YahooWin=6')\" value='{browse}...'></span>\n\t\t\t\t<span id='status-uid-www' style='float:right'></span></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend>{group}:</td>\n\t\t\t\t<td>" . Field_text("www_group", $ligne["gpid"], "font-size:13px;padding:3px;") . "</td>\n\t\t\t\t<td><span id='bb_button1'><input type='button' OnClick=\"javascript:Loadjs('MembersBrowse.php?field-user=www_group&OnlyGroups=1&OnlyGUID=1');\" value='{browse}...'></span>\n\t\t\t\t<span id='status-gpid-www' style='float:right'></span></td>\n\t\t\t</tr>\t\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend>{ssl}:</td>\n\t\t\t\t<td>" . Field_checkbox("useSSL", 1, $ligne["useSSL"]) . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend>{certificate}:</td>\n\t\t\t\t<td>{$sslcertificate}</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\t\t\t\n\t\t\t</table>\n\t</div>\n\n\t<div style='font-size:16px'><a href=\"javascript:blur();\" style='font-size:18px;text-decoration:underline;margin-bottom:5px' OnClick=\"javascript:document.getElementById('block2').style.display='block';document.getElementById('block1').style.display='none';\">{mysql_database}:</a></div>\n\t<div id='block2' style='display:none;'>\n\t<table style='width:99%' class=form>\n\t<tr>\n\t\t<td class=legend>{useMySQL}:</td>\n\t\t<td>" . Field_checkbox("useMysql", 1, $ligne["useMysql"], "useMysqlCheck()") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend>{mysql_instance}:</td>\n\t\t<td><div id='freeweb-mysql-instances'></div></td>\n\t\t<td align='left'>" . imgtootltip("plus-24.png", "{add}:{mysql_instance}", "Loadjs('mysql.multi.php?mysql-server-js=yes&ID=');") . "</td>\n\t</tr>\t\n\t\n\t<tr>\n\t\t<td class=legend>{mysql_database}:</td>\n\t\t<td>" . Field_text("mysql_database", $ligne["mysql_database"], "width:150px;font-size:13px;padding:3px") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend>{mysql_username}:</td>\n\t\t<td>" . Field_text("mysql_username", $ligne["mysql_username"], "width:120px;font-size:13px;padding:3px") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend>{password}:</td>\n\t\t<td>" . Field_password("mysql_password", $ligne["mysql_password"], "width:90px;font-size:13px;padding:3px") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=3><span style='font-size:16px'>{ftp_access}<hr style='border-color:005447'></td>\n\t</tr>\t\n\t\n\t\n\t<tr>\n\t\t<td class=legend>{allowftp_access}:</td>\n\t\t<td>" . Field_checkbox("useFTP", 1, $ligne["useFTP"], "useMysqlCheck()") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t\n\t<tr>\n\t\t<td class=legend>{ftp_user}:</td>\n\t\t<td>" . Field_text("ftpuser", $ligne["ftpuser"], "width:120px;font-size:13px;padding:3px") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend>{password}:</td>\n\t\t<td>" . Field_password("ftppassword", $ligne["ftppassword"], "width:90px;font-size:13px;padding:3px") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t</table>\n\t\n\n\t\n\t<div id='block3' style='display:none'>\n\t\t<table style='width:99%' class=form>\n\t\t<tr>\n\t\t\t<td class=legend>{www_ForwardTo}:</td>\n\t\t\t<td>" . Field_text("ForwardTo", $ligne["ForwardTo"], "width:270px;font-size:14px;padding:3px") . "</td>\n\t\t\t<td>&nbsp;</td>\n\t\t</tr>\n\t\t</table>\t\n\t</div>\t\n\t</div>\n\t\n\t<div style='width:100%;text-align:right'><hr>" . button("{$ButtonName}", "SaveFreeWebMain()", 18) . "</div>\n\n\n\n\t\n\t\n\t</td>\n\t</tr>\n\t</table>\n<script>\n\n\tfunction CheckDatas(){\n\t\tvar APACHE_PROXY_MODE={$APACHE_PROXY_MODE};\n\t\tvar FreeWebDisableSSL={$FreeWebDisableSSL};\n\t\t \n\t\t\n\t\tif(APACHE_PROXY_MODE==0){\n\t\t\tdocument.getElementById('UseReverseProxy').checked=false;\n\t\t\tdocument.getElementById('UseReverseProxy').disabled=true;\n\t\t}\n\t\t\n\t\tvar x=document.getElementById('servername').value;\n\t\tvar z=document.getElementById('domainname').value;\n\t\tvar w=x.length+z.length;\n\t\tif(w>0){\n\t\t\tdocument.getElementById('servername').disabled=true;\n\t\t\tdocument.getElementById('domainname').disabled=true;\n\t\t\t}\n\t\tvar x=document.getElementById('mysql_database').value;\n\t\tif(x.length>0){document.getElementById('mysql_database').disabled=true;}\t\n\n\t\tif(FreeWebDisableSSL==1){\n\t\t\tdocument.getElementById('useSSL').disabled=true;\n\t\t}\n\t\t\n\t}\n\t\n\n\t\n\tfunction useMysqlCheck(){\n\t\tvar mysql_instance_id=0;\n\t\tvar checkboxes={$checkboxes};\n\t\tvar PUREFTP_INSTALLED={$PUREFTP_INSTALLED};\n\t\tif(document.getElementById('mysql_instance_id')){mysql_instance_id=document.getElementById('mysql_instance_id').value;}\n\t\tdocument.getElementById('useFTP').disabled=true;\n\t\tdocument.getElementById('useMysql').disabled=true;\n\t\t\n\t\tif(checkboxes==1){\n\t\t\tif(PUREFTP_INSTALLED==1){document.getElementById('useFTP').disabled=false;}\n\t\t\tif(mysql_instance_id==0){document.getElementById('useMysql').disabled=false;}\t\n\t\t}\n\t\tif(PUREFTP_INSTALLED==1){\n\t\t\tdocument.getElementById('useFTP').disabled=false;\n\t\t}else{\n\t\t\tdocument.getElementById('useFTP').disabled=true;\n\t\t\tdocument.getElementById('useFTP').checked=false;\n\t\t}\n\t\t\n\t\tdocument.getElementById('mysql_database').disabled=true;\n\t\tdocument.getElementById('mysql_username').disabled=true;\n\t\tdocument.getElementById('mysql_password').disabled=true;\n\t\tdocument.getElementById('ftpuser').disabled=true;\n\t\tdocument.getElementById('ftppassword').disabled=true;\n\t\tif(mysql_instance_id==0){\n\t\t\tif(document.getElementById('useMysql').checked){\n\t\t\t\tvar mysql_database=document.getElementById('mysql_database').value;\n\t\t\t\tif(mysql_database.length==0){document.getElementById('mysql_database').disabled=false;}\n\t\t\t\tdocument.getElementById('mysql_username').disabled=false;\n\t\t\t\tdocument.getElementById('mysql_password').disabled=false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(mysql_instance_id==1){\n\t\t\tdocument.getElementById('mysql_database').disabled=false;\n\t\t}\n\t\t\n\t\tif(!document.getElementById('useFTP').checked){return;}\n\t\tdocument.getElementById('ftpuser').disabled=false;\n\t\tdocument.getElementById('ftppassword').disabled=false;\t\t\n\t\t\n\t\t\n\t}\n\t\n\tfunction CheckForwarder(){\n\t\tif(document.getElementById('Forwarder').checked){\n\t\t\tdocument.getElementById('block2').style.display='none';\n\t\t\tdocument.getElementById('block3').style.display='block';\n\t\t\tdocument.getElementById('UseReverseProxy').disabled=true;\n\t\t\tdocument.getElementById('UseLoopDisk').disabled=true;\n\t\t}else{\n//\t\t\tdocument.getElementById('block2').style.display='block';\n\t\t\tdocument.getElementById('block3').style.display='none';\n\t\t\tdocument.getElementById('UseReverseProxy').disabled=false;\n\t\t\tdocument.getElementById('UseLoopDisk').disabled=false;\n\t\t\tCheckLoops();\n\t\t}\n\t\n\t}\n\t\t\n\tfunction FreeWebsRebuildvHosts(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('FreeWebsRebuildvHosts','{$_GET["servername"]}');\n\t\tAnimateDiv('freewebdiv');\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveFreeWebMain);\n\t}\n\t\n\tfunction FreeWebsRebuildGroupware(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('FreeWebsRebuildGroupware','{$_GET["servername"]}');\n\t\tAnimateDiv('freewebdiv');\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveFreeWebMain);\n\t}\t\t\t\n\n\n\tvar x_SaveFreeWebMain=function (obj) {\n\t\t    var NewServer={$NewServer};\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);}\t\t\t\n\t\t\tRefreshTab('main_config_freewebedit');\n\t\t\tif(document.getElementById('container-www-tabs')){RefreshTab('container-www-tabs');}\n\t\t\tif(document.getElementById('main_config_freeweb')){RefreshTab('main_config_freeweb');}\n\t\t\tif(document.getElementById('sarg_tabs')){RefreshTab('sarg_tabs');}\n\t\t\t\n\t\t\tif(NewServer==1){YahooWin5Hide();}\n\t\t\t\n\t\t}\t\n\t\t\n\t\tfunction SaveFreeWebMain(){\n\t\t\tvar NewServer={$NewServer};\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tif(NewServer==1){\n\t\t\t\tvar sitename=document.getElementById('servername').value;\n\t\t\t\tvar www_a=document.getElementById('domainname').value;\n\t\t\t\tvar www_b=document.getElementById('servername').value;\n\t\t\t\tvar www_t=www_a.length+www_b.length;\n\t\t\t\tif(www_t<2){\n\t\t\t\t\talert('{$error_please_fill_field}:{$acl_dstdomain}'); \n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\n\t\t\t\tif(sitename!=='_default_'){\n\t\t\t\t\tvar x=document.getElementById('domainname').value;\n\t\t\t\t\tif(x.length==0){alert('{$error_please_fill_field}:{$acl_dstdomain}');return;}\n\t\t\t\t}else{\n\t\t\t\t\tdocument.getElementById('domainname').value='';\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(document.getElementById('ADD_DNS_ENTRY')){\n\t\t\t\tXHR.appendData('ADD_DNS_ENTRY',document.getElementById('ADD_DNS_ENTRY').value);\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tif(document.getElementById('useMysql').checked){\n\t\t\t\tvar mysql_database=document.getElementById('mysql_database').value;\n\t\t\t\tif(mysql_database.length==0){\n\t\t\t\t\talert('{$error_please_fill_field}:{$mysql_database}');\n\t\t\t\t\treturn;\t\t\t\t\t\t\n\t\t\t\t}\t\n\t\t\t\tvar x=document.getElementById('mysql_password').value;\n\t\t\t\tif(x.length==0){\n\t\t\t\t\talert('{$error_please_fill_field}:{$mysql_database}/{$password}');\n\t\t\t\t\treturn;\n\t\t\t\t}\t\n\t\t\t\tvar x=document.getElementById('mysql_username').value;\n\t\t\t\tif(x.length==0){\n\t\t\t\t\talert('{$error_please_fill_field}:{$mysql_database}/{$username}');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(mysql_database.length>16){\n\t\t\t\t\talert('mysql_database:{$error_field_max_length}: 16');\n\t\t\t\t\tdocument.getElementById('mysql_database').disabled=false;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(document.getElementById('useSSL').checked){XHR.appendData('useSSL',1);}else{XHR.appendData('useSSL',0);}\n\t\t\tif(document.getElementById('useMysql').checked){XHR.appendData('useMysql',1);}else{XHR.appendData('useMysql',0);}\n\t\t\tif(document.getElementById('useFTP').checked){XHR.appendData('useFTP',1);}else{XHR.appendData('useFTP',0);}\n\t\t\tXHR.appendData('UseDefaultPort',0)\n\t\t\tif(document.getElementById('UseReverseProxy').checked){XHR.appendData('UseReverseProxy',1);}else{XHR.appendData('UseReverseProxy',0);}\n\t\t\tif(document.getElementById('Forwarder').checked){XHR.appendData('Forwarder',1);}else{XHR.appendData('Forwarder',0);}\n\t\t\tXHR.appendData('ForceInstanceZarafaID','{$_GET["ForceInstanceZarafaID"]}');\n\t\t\t\n\t\t\tif(document.getElementById('www_dir')){\n\t\t\t\tXHR.appendData('www_dir',document.getElementById('www_dir').value);\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tif(document.getElementById('LoopMounts')){\n\t\t\t\tvar LoopMounts=document.getElementById('LoopMounts').value;\n\t\t\t\tif(LoopMounts.length>3){\n\t\t\t\t\tif(document.getElementById('UseLoopDisk').checked){XHR.appendData('UseLoopDisk',1);}else{XHR.appendData('UseLoopDisk',0);}\n\t\t\t\t\tXHR.appendData('LoopMounts',LoopMounts);\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\tvar ftpuser=trim(document.getElementById('ftpuser').value);\n\t\t\tvar uid=trim(document.getElementById('www_uid').value);\n\t\t\tif(document.getElementById('useFTP').checked){\t\n\t\t\t\tif(uid==ftpuser){\n\t\t\t\t\talert('{$no_usersameftpuser}');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(document.getElementById('vg_size')){XHR.appendData('vg_size',document.getElementById('vg_size').value);}\n\t\t\tXHR.appendData('lvm_vg','{$ligne["lvm_vg"]}');\n\t\t\tif(NewServer==1){\n\t\t\t\tif(sitename!=='_default_'){\n\t\t\t\t\tvar www_b=document.getElementById('domainname').value;\n\t\t\t\t\tvar www_a=document.getElementById('servername').value;\n\t\t\t\t\tif(www_a.length>0){XHR.appendData('servername',www_a+'.'+www_b);}else{XHR.appendData('servername',www_b);}\n    \t\t\t\t}else{\n    \t\t\t\tXHR.appendData('servername','_default_');\n    \t\t\t}\n    \t\t}\n    \t\tif(NewServer==0){XHR.appendData('servername',document.getElementById('servername').value);}\n    \t\tXHR.appendData('domainname',document.getElementById('domainname').value);\n    \t\tXHR.appendData('uid',uid);\n    \t\tXHR.appendData('gpid',document.getElementById('www_group').value);\n    \t\tXHR.appendData('mysql_instance_id',document.getElementById('mysql_instance_id').value);\n    \t\tXHR.appendData('mysql_database',document.getElementById('mysql_database').value);\n    \t\tXHR.appendData('mysql_password',document.getElementById('mysql_password').value);\n    \t\tXHR.appendData('mysql_username',document.getElementById('mysql_username').value);\n    \t\tXHR.appendData('ftpuser',ftpuser);\n    \t\tXHR.appendData('ftppassword',document.getElementById('ftppassword').value);\n    \t\tXHR.appendData('ForwardTo',document.getElementById('ForwardTo').value);\n    \t\tXHR.appendData('force-groupware',document.getElementById('force-groupware').value);\n    \t\tXHR.appendData('mysql_instance_id',document.getElementById('mysql_instance_id').value);\n    \t\tXHR.appendData('ServerIP',document.getElementById('ServerIP').value);\n    \t\tXHR.appendData('sslcertificate',document.getElementById('sslcertificate').value);\n    \t\t\n    \t\t\n    \t\t\n    \t\tAnimateDiv('freewebdiv');\n    \t\tXHR.sendAndLoad('{$page}', 'GET',x_SaveFreeWebMain);\n\t\t\t\n\t\t}\t\n\t\t\n\tfunction CheckLoops(){\n\t\tvar countloops={$countloops};\n\t\tdocument.getElementById('UseLoopDisk').disabled=true;\n\t\tif(countloops>0){\n\t\t\tdocument.getElementById('UseLoopDisk').disabled=false;\n\t\t}\n\t\tdocument.getElementById('loops-list').innerHTML='';\n\t\t\n\t\tif(document.getElementById('UseLoopDisk').checked){\n\t\t\tif(document.getElementById('vg_size')){\n\t\t\t\tdocument.getElementById('vg_size').disabled=true;\n\t\t\t}\n\t\t\tLoadAjax('loops-list','{$page}?loops-list=yes&servername={$ligne["servername"]}');\n\t\t}\n\t}\n\t\n\t\n\tfunction FreeWebsCheckGroupware(){\n\t\tLoadWinORG2('850','{$page}?FreeWebsCheck=yes&servername={$ligne["servername"]}','{$check_configuration}::{$ligne["servername"]}');\n\t\n\t}\n\t\n\t\t\n\tfunction CheckLoops(){\n\t\tvar countloops={$countloops};\n\t\tdocument.getElementById('UseLoopDisk').disabled=true;\n\t\tif(countloops>0){document.getElementById('UseLoopDisk').disabled=false;}\n\t\tdocument.getElementById('loops-list').innerHTML='';\n\t\t\n\t\tif(document.getElementById('UseLoopDisk').checked){\n\t\t\tif(document.getElementById('vg_size')){\n\t\t\t\tdocument.getElementById('vg_size').disabled=true;\n\t\t\t}\n\t\t\tLoadAjax('loops-list','{$page}?loops-list=yes&servername={$ligne["servername"]}');\n\t\t}\n\t}\n\t\n\tfunction CheckUseReverseProxy(){\n\t\tCheckDatas();\n\t\tuseMysqlCheck();\n\t\tCheckLoops();\n\t\t{$js_removesql};\n\t\t{$js_OnlyWebSite};\n\t}\n\t\n\tfunction HideMysql(){\n\t\tdocument.getElementById('useMysql').disabled=true;\n\t}\n\t\n\tfunction OnlyWebsite(){\n\t\tif(document.getElementById('Forwarder')){document.getElementById('Forwarder').disabled=true;}\n\t\tif(document.getElementById('UseReverseProxy')){document.getElementById('UseReverseProxy').disabled=true;}\n\t\tif(document.getElementById('useFTP')){document.getElementById('useFTP').disabled=true;}\n\t}\n\t\n\tfunction CheckUId(){\n\t\tLoadAjaxTiny('status-uid-www','{$page}?uid-check={$uid_uri}');\n\t}\n\n\t\n\tfunction freeweb_mysql_instances(){\n\t\tLoadAjaxTiny('freeweb-mysql-instances','{$page}?freeweb-mysql-instances-field=yes&servername={$ligne["servername"]}');\n\t\n\t}\n\t\n\tfunction mysql_instance_id_check(){\n\t\t\t\n\t\t\tvar mysql_instance_id=document.getElementById('mysql_instance_id').value;\n\t\t\t\n\t\t\tif(mysql_instance_id>0){\n\t\t\t\tdocument.getElementById('useMysql').disabled=true;\n\t\t\t\tuseMysqlCheck();\n\t\t\t}else{\n\t\t\t\tdocument.getElementById('useMysql').disabled=false;\n\t\t\t\tuseMysqlCheck();\n\t\t\t}\n\t\t}\n\t\t\n\n\t\n\tCheckDatas();\n\tuseMysqlCheck();\n\tCheckLoops();\n\tCheckForwarder();\n\tCheckUId();\n\t{$js_removesql};\n\t{$js_OnlyWebSite};\n\t\n\tfreeweb_mysql_instances();\n\t\n\t</script>\t\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Exemple #29
0
function FreeWebsEnableSite()
{
    $servername = $_POST["FreeWebsEnableSite"];
    $frr = new freeweb($servername);
    $frr->EnableDisableSwitch();
}
function execute_autconfig()
{
    $sock = new sockets();
    build_progress("Execute....", 5);
    build_progress("Loading settings....", 5);
    $SquidAutoconfWizard = unserialize($sock->GET_INFO("SquidAutoconfWizard"));
    $DOMAIN = $SquidAutoconfWizard["DOMAIN"];
    $LOCALNET = $SquidAutoconfWizard["LOCALNET"];
    $PROXY = $SquidAutoconfWizard["PROXY"];
    $PORT = $SquidAutoconfWizard["PORT"];
    echo "DOMAIN.........: {$DOMAIN}\n";
    echo "LOCALNET.......: {$LOCALNET}\n";
    echo "PROXY..........: {$PROXY}:{$PORT}\n";
    if ($DOMAIN == null) {
        build_progress("Missing domain....", 110);
        return;
    }
    if ($LOCALNET == null) {
        build_progress("Missing LOCALNET....", 110);
        return;
    }
    if ($PROXY == null) {
        build_progress("Missing PROXY....", 110);
        return;
    }
    if (!is_numeric($PORT)) {
        build_progress("Missing PROXY PORT....", 110);
        return;
    }
    build_progress("Creating wpad.{$DOMAIN}....", 10);
    $webserver = "wpad.{$DOMAIN}";
    $sock->SET_INFO("EnableFreeWeb", 1);
    build_progress("Creating wpad.{$DOMAIN} (loading class)", 11);
    $free = new freeweb($webserver);
    $free->servername = $webserver;
    $free->groupware = "WPADDYN";
    $free->Params["ServerAlias"]["wpad"] = true;
    $free->CreateSite();
    build_progress("Building wpad.{$DOMAIN} and alias wpad", 15);
    build_progress("Creating wpad.{$DOMAIN} (saving configuration)", 12);
    build_progress("Creating wpad.{$DOMAIN} (reloading configuration)", 13);
    rebuild_vhost($webserver);
    build_progress("Creating wpad.{$DOMAIN} (reloading configuration {done})", 14);
    build_progress("Building first rule...", 15);
    $rulnename = mysql_escape_string2("Wizard - all to {$PROXY}:{$PORT}");
    $sql = "INSERT IGNORE INTO `wpad_rules` (`rulename`,`enabled`,`zorder`,`dntlhstname`) VALUES ('{$rulnename}',1,0,1)";
    $q = new mysql_squid_builder();
    if (!$q->FIELD_EXISTS("wpad_rules", "zorder")) {
        $q->QUERY_SQL("ALTER TABLE `wpad_rules` ADD `zorder`  smallint( 2 ) DEFAULT '0',ADD INDEX (`zorder`)");
    }
    if (!$q->FIELD_EXISTS("wpad_sources_link", "zorder")) {
        $q->QUERY_SQL("ALTER TABLE `wpad_sources_link` ADD `zorder`  smallint( 2 ) DEFAULT '0',ADD INDEX (`zorder`)");
    }
    if (!$q->FIELD_EXISTS("wpad_rules", "dntlhstname")) {
        $q->QUERY_SQL("ALTER TABLE `wpad_rules` ADD `dntlhstname`  smallint( 1 ) DEFAULT '0'");
    }
    if (!$q->FIELD_EXISTS("wpad_destination_rules", "rulename")) {
        $q->QUERY_SQL("ALTER TABLE `wpad_destination_rules` ADD `rulename` VARCHAR(255) NOT NULL, ADD INDEX (`rulename`)");
        build_progress("Building first rule...MySQL error", 110);
        if (!$q->ok) {
            echo $q->mysql_error . "\n";
        }
        return;
    }
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        build_progress("Building first rule...MySQL error", 110);
        return;
    }
    $MAIN_RULE_ID = intval($q->last_id);
    if ($MAIN_RULE_ID == 0) {
        build_progress("Building first rule...MAIN_RULE_ID = 0!", 110);
        return;
    }
    $zmd5 = md5("{$MAIN_RULE_ID}{$PROXY}{$PORT}");
    build_progress("Add destination {$PROXY}:{$PORT}", 20);
    $q->QUERY_SQL("INSERT IGNORE INTO wpad_destination (zmd5,aclid,proxyserver,proxyport,zorder)\n\t\t\tVALUES ('{$zmd5}','{$MAIN_RULE_ID}','{$PROXY}','{$PORT}',0)");
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        build_progress("Add destination {$PROXY}:{$PORT} MySQL error", 110);
        return;
    }
    build_progress("Creating Proxy object `Everyone`", 25);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT ID FROM webfilters_sqgroups WHERE `GroupType`='all'"));
    $SourceGroupID = intval($ligne["ID"]);
    if ($SourceGroupID == 0) {
        $sql = "INSERT IGNORE INTO webfilters_sqgroups (GroupName,GroupType,enabled,`acltpl`,`params`) VALUES ('Everyone','all','1','','');";
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            echo $q->mysql_error . "\n";
            build_progress("Creating Proxy object `Everyone` MySQL error", 110);
            return;
        }
        $SourceGroupID = intval($q->last_id);
    }
    if ($SourceGroupID == 0) {
        build_progress("Creating Proxy object `Everyone` SourceGroupID = 0!", 110);
        return;
    }
    build_progress("Creating Proxy object `WPAD - Local networks`", 25);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT ID FROM webfilters_sqgroups WHERE `GroupName`='WPAD - Local networks'"));
    $NetWorkGroupID = intval($ligne["ID"]);
    if ($NetWorkGroupID == 0) {
        $sql = "INSERT IGNORE INTO webfilters_sqgroups (GroupName,GroupType,enabled,`acltpl`,`params`) \n\t\t\t\tVALUES ('WPAD - Local networks','src','1','','');";
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            echo $q->mysql_error . "\n";
            build_progress("Creating Proxy object `WPAD - Local networks` MySQL error", 110);
            return;
        }
        $NetWorkGroupID = intval($q->last_id);
    }
    if ($NetWorkGroupID == 0) {
        build_progress("Creating Proxy object `WPAD - Local networks` NetWorkGroupID = 0!", 110);
        return;
    }
    $IP = new IP();
    $LOCALNET_ARRAY = array();
    if (strpos($LOCALNET, ",") > 0) {
        $LOCALNET_ARRAY_TEMP = explode(",", $LOCALNET);
        while (list($none, $line) = each($LOCALNET_ARRAY_TEMP)) {
            $line = trim($line);
            if (!$IP->isIPAddressOrRange($line)) {
                continue;
            }
            $LOCALNET_ARRAY[] = "('{$line}','{$NetWorkGroupID}','1','')";
        }
    } else {
        if ($IP->isIPAddressOrRange(trim($LOCALNET))) {
            $LOCALNET_ARRAY[] = "('{$LOCALNET}','{$NetWorkGroupID}','1','')";
        }
    }
    build_progress("Filling Proxy object `WPAD - Local networks`", 30);
    $q->QUERY_SQL("DELETE FROM webfilters_sqitems WHERE gpid={$NetWorkGroupID}");
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        build_progress("Filling Proxy object `WPAD - Local networks` MySQL error", 110);
        return;
    }
    $sql = "INSERT INTO webfilters_sqitems (pattern,gpid,enabled,other)\n\tVALUES " . @implode(",", $LOCALNET_ARRAY);
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        build_progress("Filling Proxy object `WPAD - Local networks` MySQL error", 110);
        return;
    }
    build_progress("Linking Everyone - {$SourceGroupID} - to rule {$MAIN_RULE_ID}", 30);
    $zmd5 = md5("{$MAIN_RULE_ID}{$SourceGroupID}");
    $q->QUERY_SQL("INSERT INTO wpad_sources_link (zmd5,aclid,negation,gpid,zorder) VALUES ('{$zmd5}','{$MAIN_RULE_ID}','0','{$SourceGroupID}',1)");
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        build_progress("MySQL error", 110);
        return;
    }
    $zmd5 = md5("{$MAIN_RULE_ID}{$NetWorkGroupID}");
    build_progress("Linking WPAD - Local networks - {$NetWorkGroupID} - to rule {$MAIN_RULE_ID}", 50);
    $q->QUERY_SQL("INSERT INTO wpad_white_link (zmd5,aclid,negation,gpid,zorder) VALUES ('{$zmd5}','{$MAIN_RULE_ID}','0','{$NetWorkGroupID}',1)");
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        build_progress("MySQL error", 110);
        return;
    }
    build_progress("{success}", 100);
}