Exemplo n.º 1
0
function websites_popup()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $servername = $_GET["servername"];
    $rv = new squid_reverse();
    $q = new mysql_squid_builder();
    $sock = new sockets();
    $title = "{new_webserver}";
    $bt = "{add}";
    $boot = new boostrap_form();
    $q = new mysql_squid_builder();
    $squid_reverse = new squid_reverse();
    $tpl = new templates();
    $sslcertificates = $squid_reverse->ssl_certificates_list();
    $sources_list = $squid_reverse->sources_list();
    $array = $sources_list[0];
    $array2 = $sources_list[1];
    $CountDeSources = $sources_list[2];
    $nginx_caches = $squid_reverse->caches_list();
    $nginx_pools = $squid_reverse->pool_list();
    $nginx_replaces = $squid_reverse->replace_list();
    $AsFReeWeb = false;
    $EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb");
    if ($servername != null) {
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM reverse_www WHERE servername='{$servername}'"));
        $title = $tpl->_ENGINE_parse_body("{port}:{$ligne["port"]} «{$servername}»");
        $bt = "{apply}";
        $boot->set_hidden("servername-edit", $servername);
    } else {
        $ligne["enabled"] = 1;
        $boot->set_field("servername-edit", "{website}", null, array("MANDATORY" => true));
    }
    if (!is_numeric($ligne["port"])) {
        $ligne["port"] = 80;
    }
    if (!is_numeric($ligne["ArticaErrors"])) {
        $ligne["ArticaErrors"] = 1;
    }
    if ($servername == null) {
        $ligne["cache_peer_id"] = -1;
    }
    if (!is_numeric($EnableFreeWeb)) {
        $EnableFreeWeb = 0;
    }
    if ($ligne["cache_peer_id"] == 0) {
        if ($EnableFreeWeb == 1) {
            $q2 = new mysql();
            $ligne2 = mysql_fetch_array($q2->QUERY_SQL("SELECT `useSSL`,`sslcertificate` FROM `freeweb` WHERE `servername`='{$servername}'", "artica_backup"));
            $ligne["certificate"] = $ligne2["sslcertificate"];
            $AsFReeWeb = true;
            $title = $tpl->_ENGINE_parse_body("FreeWeb «{$servername}»");
        } else {
            $ligne["cache_peer_id"] = -1;
        }
    }
    $boot->set_formtitle($title);
    if (!$AsFReeWeb) {
        $boot->set_field("port", "{inbound_port}", $ligne["port"]);
    }
    $boot->set_checkbox("enabled", "{enabled}", $ligne["enabled"], array("DISABLEALL" => true));
    $boot->set_checkbox("default_server", "{default_server}", $ligne["default_server"], array("TOOLTIP" => "{NGINX_DEFAULT_SERVER}"));
    $boot->set_checkbox("owa", "{protect_owa}", $ligne["owa"]);
    $boot->set_checkbox("debug", "{debug}", $ligne["debug"]);
    $boot->set_list("cacheid", "{cache}", $nginx_caches, $ligne["cacheid"]);
    $boot->set_list("replaceid", "{replace_rule}", $nginx_replaces, $ligne["replaceid"]);
    if ($servername != null) {
        if ($ligne["certificate"] != null) {
            $boot->set_formdescription("{certificate}: {$ligne["certificate"]}");
        }
    }
    if ($ligne["cache_peer_id"] == 0) {
        $boot->set_hidden("cache_peer_id", 0);
        $boot->set_hidden("enabled", 1);
        $boot->set_hidden("certificate", $ligne["certificate"]);
    } else {
        if (!AdminPrivs()) {
            $boot->set_hidden("cache_peer_id", $ligne["cache_peer_id"]);
            $boot->set_hidden("start_directory", $ligne["start_directory"]);
        } else {
            $boot->set_list("cache_peer_id", "{destination}", $array, $ligne["cache_peer_id"]);
            $boot->set_field("start_directory", "{start_path}", $ligne["start_directory"]);
        }
        $boot->set_list("poolid", "{pool}", $nginx_pools, $ligne["poolid"]);
        $boot->set_field("RedirectQueries", "{RedirectQueries}", $ligne["RedirectQueries"]);
        $boot->set_checkbox("ArticaErrors", "{enable_template_errors}", $ligne["ArticaErrors"]);
        $boot->set_checkbox("ssl", "{UseSSL}", $ligne["ssl"], array("TOOLTIP" => "{NGINX_USE_SSL_EXPLAIN}"));
        $boot->set_list("certificate", "{certificate}", $sslcertificates, $ligne["certificate"], array());
        if ($CountDeSources == 0) {
            $boot->set_form_error("{you_need_to_define_sources_first}");
            $boot->set_form_locked();
        }
    }
    $boot->set_button($bt);
    if ($servername == null) {
        $boot->set_CloseYahoo("YahooWin");
    }
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
Exemplo n.º 2
0
function main()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $servername = $_GET["servername"];
    $rv = new squid_reverse();
    $q = new mysql_squid_builder();
    $sock = new sockets();
    $title = "{new_webserver}";
    $bt = "{add}";
    $t = time();
    FORM_START();
    $q = new mysql_squid_builder();
    $squid_reverse = new squid_reverse();
    $tpl = new templates();
    $sslcertificates = $squid_reverse->ssl_certificates_list();
    $sources_list = $squid_reverse->sources_list();
    $array = $sources_list[0];
    $array2 = $sources_list[1];
    $CountDeSources = $sources_list[2];
    $nginx_caches = $squid_reverse->caches_list();
    $nginx_pools = $squid_reverse->pool_list();
    $nginx_replaces = $squid_reverse->replace_list();
    $AsFReeWeb = false;
    $EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb");
    if ($servername != null) {
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM reverse_www WHERE servername='{$servername}'"));
        $title = $tpl->_ENGINE_parse_body("{port}:{$ligne["port"]} «{$servername}»");
        $bt = "{apply}";
        $Hidden = Field_hidden("servername-edit-{$t}", $servername) . $servername;
    } else {
        $ligne["enabled"] = 1;
        $Hidden = Field_text("servername-edit-{$t}", null, "font-size:18px;width:300px");
        FORM_CLOSE("YahooWin");
    }
    if (!is_numeric($ligne["port"])) {
        $ligne["port"] = 80;
    }
    if (!is_numeric($ligne["ArticaErrors"])) {
        $ligne["ArticaErrors"] = 1;
    }
    if ($servername == null) {
        $ligne["cache_peer_id"] = -1;
    }
    if (!is_numeric($EnableFreeWeb)) {
        $EnableFreeWeb = 0;
    }
    if ($ligne["cache_peer_id"] == 0) {
        if ($EnableFreeWeb == 1) {
            $q2 = new mysql();
            $ligne2 = mysql_fetch_array($q2->QUERY_SQL("SELECT `useSSL`,`sslcertificate` FROM `freeweb` WHERE `servername`='{$servername}'", "artica_backup"));
            $ligne["certificate"] = $ligne2["sslcertificate"];
            $AsFReeWeb = true;
            $title = $tpl->_ENGINE_parse_body("FreeWeb «{$servername}»");
        } else {
            $ligne["cache_peer_id"] = -1;
        }
    }
    $html[] = "<div style='width:98%' class=form>";
    $html[] = "<table style='width:100%'>";
    $html[] = "<tr><td colspan=2 style='font-size:22px'>{reverse_proxy}:</td></tr>";
    $html[] = "<tr><td class=legend style='font-size:18px'>{webserver}:</td>";
    $html[] = "<td style='font-size:18px'>{$Hidden}</td></tr>";
    $html[] = Field_checkbox_table("owa-{$t}", "{protect_owa}", $ligne["owa"], 18);
    $html[] = Field_checkbox_table("debug-{$t}", "{debug}", $ligne["debug"], 18);
    $html[] = Field_list_table("cacheid-{$t}", "{cache}", $ligne["cacheid"], 18, $nginx_caches);
    $html[] = Field_list_table("replaceid-{$t}", "{replace_rule}", $ligne["replaceid"], 18, $nginx_replaces);
    if ($ligne["cache_peer_id"] == 0) {
        $html[] = Field_hidden("cache_peer_id-{$t}", 0);
        $html[] = Field_hidden("enabled-{$t}", 1);
        $html[] = Field_hidden("certificate-{$t}", $ligne["certificate"]);
    } else {
        if (!AdminPrivs()) {
            $html[] = Field_hidden("cache_peer_id-{$t}", $ligne["cache_peer_id"]);
            $html[] = Field_hidden("start_directory-{$t}", $ligne["start_directory"]);
        } else {
            $html[] = Field_list_table("cache_peer_id-{$t}", "{destination}", $ligne["cache_peer_id"], 18, $array);
            $html[] = Field_text_table("start_directory-{$t}", "{start_path}", $ligne["start_directory"], 18, null, 300);
        }
        $html[] = Field_list_table("poolid-{$t}", "{pool}", $ligne["poolid"], 18, $nginx_pools);
        $html[] = Field_text_table("RedirectQueries-{$t}", "{RedirectQueries}", $ligne["RedirectQueries"], 18, null, 300);
        $html[] = Field_checkbox_table("ArticaErrors-{$t}", "{enable_template_errors}", $ligne["ArticaErrors"], 18);
        if ($CountDeSources == 0) {
            $html[] = "<tr><td colspan=2><p class=text-error>{you_need_to_define_sources_first}</p></td></tr>";
            FORM_LOCK();
        }
    }
    $html[] = Field_button_table($bt);
    echo $tpl->_ENGINE_parse_body(FORM_END(CurrentPageName(), $html));
}