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 #2
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);
}
Exemple #3
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();
}
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;
}
Exemple #5
0
function install_EYEOS($hostname){
	echo "Starting......: Apache \"$hostname\" Checking eyeOS installation....\n";
	
	$freeweb=new freeweb($hostname);
	$freeweb->CheckWorkingDirectory();
	
	
	echo "Starting......: Apache \"$hostname\" Checking eyeOS installation....\n";
	if(!is_file(dirname(__FILE__)."/ressources/class.eyeos.inc")){echo "Fatal ".dirname(__FILE__)."/ressources/class.eyeos.inc no such file\n";}
	include_once(dirname(__FILE__)."/ressources/class.eyeos.inc");
	$eye=new eyeos($hostname);

	if($eye->ValidateInstallation25()){
		echo "Starting......: Apache \"$hostname\" Installing EyeOS (already installed)\n";
		$eye->Build_SettingsPHP();
		return;
	}
	echo "Starting......: Apache \"$hostname\" Installing EyeOS in $freeweb->WORKING_DIRECTORY\n";
	$unix=new unix();
	$cp=$unix->find_program("cp");
	shell_exec("$cp -rf /usr/local/share/artica/eyeos_src/* $freeweb->WORKING_DIRECTORY/");
	if($eye->ValidateInstallation25($freeweb->WORKING_DIRECTORY)){
		echo "Starting......: Apache \"$hostname\" Installing EyeOS (FAILED)\n";
	}	
	
}
Exemple #6
0
function ScanSize()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $timefile = "/etc/artica-postfix/pids/tests." . __FUNCTION__ . ".time";
    $pid = @file_get_contents("{$pidfile}");
    if ($unix->process_exists($pid, basename(__FILE__))) {
        system_admin_events("Already executed PID {$pid}", __FUNCTION__, __FILE__, __LINE__, "freewebs");
        die;
    }
    @file_put_contents($pidfile, getmypid());
    $time = $unix->file_time_min($timefile);
    if ($time < 15) {
        system_admin_events("No less than 15mn or delete {$timefile} file", __FUNCTION__, __FILE__, __LINE__, "freewebs");
        die;
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    $t = time();
    $q = new mysql();
    $sql = "SELECT servername FROM freeweb";
    $results = $q->QUERY_SQL($sql, 'artica_backup');
    $GLobalSize = 0;
    if (mysql_num_rows($results) == 0) {
        return;
    }
    $sitesNumber = mysql_num_rows($results);
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $free = new freeweb($ligne["servername"]);
        if ($free->IsGroupWareFromArtica()) {
            $q->QUERY_SQL("UPDATE freeweb SET DirectorySize=0 WHERE servername='{$ligne["servername"]}'", "artica_backup");
            continue;
        }
        $free->CheckWorkingDirectory();
        if (is_link($free->WORKING_DIRECTORY)) {
            $free->WORKING_DIRECTORY = @readlink($free->WORKING_DIRECTORY);
        }
        if (!is_dir($free->WORKING_DIRECTORY)) {
            $q->QUERY_SQL("UPDATE freeweb SET DirectorySize=0 WHERE servername='{$ligne["servername"]}'", "artica_backup");
            if (!$q->ok) {
                system_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "freewebs");
            }
            continue;
        }
        $size = $unix->DIRSIZE_BYTES($free->WORKING_DIRECTORY);
        $GLobalSize = $GLobalSize + $size;
        if ($GLOBALS["VERBOSE"]) {
            echo "{$ligne["servername"]} {$size} Bytes\n";
        }
        $q->QUERY_SQL("UPDATE freeweb SET DirectorySize={$size} WHERE servername='{$ligne["servername"]}'", "artica_backup");
        if (!$q->ok) {
            system_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "freewebs");
        }
    }
    if ($GLobalSize > 0) {
        $took = $unix->distanceOfTimeInWords($t, time(), true);
        $GLobalSize = round($GLobalSize / 1024, 2);
        $GLobalSize = $GLobalSize / 1000;
        system_admin_events("{$sitesNumber} web site(s) scanned {$GLobalSize}M took:{$took}", __FUNCTION__, __FILE__, __LINE__, "freewebs");
    }
}