예제 #1
0
function awstats()
{
    $sock = new sockets();
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($unix->file_time_min($pidTime) < 60) {
        return;
    }
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        return;
    }
    @file_put_contents($pidfile, getmypid());
    @unlink($pidTime);
    @file_put_contents($pidTime, time());
    $sock = new sockets();
    $EnableNginxStats = $sock->GET_INFO("EnableNginxStats");
    if (!is_numeric($EnableNginxStats)) {
        $EnableNginxStats = 0;
    }
    if ($EnableNginxStats == 1) {
        return;
    }
    include_once dirname(__FILE__) . "/ressources/class.awstats.inc";
    include_once dirname(__FILE__) . "/ressources/class.mysql.syslogs.inc";
    $awstats_bin = $unix->LOCATE_AWSTATS_BIN();
    $nice = EXEC_NICE();
    $perl = $unix->find_program("perl");
    $awstats_buildstaticpages = $unix->LOCATE_AWSTATS_BUILDSTATICPAGES_BIN();
    if ($GLOBALS["VERBOSE"]) {
        echo "awstats......: {$awstats_bin}\n";
        echo "statics Pages: {$awstats_buildstaticpages}\n";
        echo "Nice.........: {$nice}\n";
        echo "perl.........: {$perl}\n";
    }
    if (!is_file($awstats_buildstaticpages)) {
        echo "buildstaticpages no such binary...\n";
        return;
    }
    $sock = new sockets();
    $kill = $unix->find_program("kill");
    $NginxWorkLogsDir = $sock->GET_INFO("NginxWorkLogsDir");
    if ($NginxWorkLogsDir == null) {
        $NginxWorkLogsDir = "/home/nginx/logsWork";
    }
    $sys = new mysql_storelogs();
    $files = $unix->DirFiles($NginxWorkLogsDir, "-([0-9\\-]+)\\.log");
    while (list($filename, $line) = each($files)) {
        if (!preg_match("#^(.+?)-[0-9]+-[0-9]+-[0-9]+-[0-9]+\\.log\$#", $filename, $re)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$filename}, skip\n";
            }
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$filename}, domain:{$re[1]}\n";
        }
        $servername = $re[1];
        $GLOBALS["nice"] = $nice;
        $aw = new awstats($servername);
        $aw->set_LogFile("{$NginxWorkLogsDir}/{$filename}");
        $aw->set_LogType("W");
        $aw->set_LogFormat(1);
        $config = $aw->buildconf();
        $SOURCE_FILE_PATH = "{$NginxWorkLogsDir}/{$filename}";
        $configlength = strlen($config);
        if ($configlength < 10) {
            if ($GLOBALS["VERBOSE"]) {
                echo "configuration file lenght failed {$configlength} bytes, aborting {$servername}\n";
            }
            return;
        }
        @file_put_contents("/etc/awstats/awstats.{$servername}.conf", $config);
        @chmod("/etc/awstats/awstats.{$servername}.conf", 644);
        $Lang = $aw->GET("Lang");
        if ($Lang == null) {
            $Lang = "auto";
        }
        @mkdir("/var/tmp/awstats/{$servername}", 666, true);
        $t1 = time();
        $cmd = "{$nice}{$perl} {$awstats_buildstaticpages} -config={$servername} -update -lang={$Lang} -awstatsprog={$awstats_bin} -dir=/var/tmp/awstats/{$servername} -LogFile=\"{$SOURCE_FILE_PATH}\" 2>&1";
        if ($GLOBALS["VERBOSE"]) {
            echo $cmd . "\n";
        }
        shell_exec($cmd);
        $filedate = date('Y-m-d H:i:s', filemtime($SOURCE_FILE_PATH));
        if (!awstats_import_sql($servername)) {
            continue;
        }
        $sys->ROTATE_TOMYSQL($SOURCE_FILE_PATH, $filedate);
    }
}
예제 #2
0
파일: freeweb.php 프로젝트: rsd/artica-1.5
function listwebs_search(){
	include_once(dirname(__FILE__).'/ressources/class.apache.inc');
	$vhosts=new vhosts();
	$search=$_GET["search"];
	$page=CurrentPageName();
	$users=new usersMenus();
	$where=null;
	if(!$users->AsSystemAdministrator){
		$whereOU="  AND ou='{$_SESSION["ou"]}'";$ou="&nbsp;&raquo;&nbsp;{$_SESSION["ou"]}";
	}
	
	if(strlen($search)>1){
		$search="*$search*";
		$search=str_replace("*","%",$search);
		$search=str_replace("%%","%",$search);
		$whereOU="AND (servername LIKE '$search' $whereOU) OR (domainname LIKE '$search' $whereOU)";
	}
	
	
	
	
	$tpl=new templates();	
	$sock=new sockets();	
	
	$delete_freeweb_text=$tpl->javascript_parse_text("{delete_freeweb_text}");
	$sql="SELECT * FROM freeweb WHERE 1 $whereOU ORDER BY servername";
	$q=new mysql();
	if(!isset($_SESSION["CheckTableWebsites"])){$q->BuildTables();$_SESSION["CheckTableWebsites"]=true;}
	
	$results=$q->QUERY_SQL($sql,'artica_backup');
	if(!$q->ok){echo "<H2>$q->mysql_error</H2><code>$sql</code>";}
	$vgservices=unserialize(base64_decode($sock->GET_INFO("vgservices")));
	$html="
<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>
<thead class='thead'>
	<tr>
	<th colspan=2>{joomlaservername}:$ou</th>
	<th>{ssl}</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>{member}</th>
	<th>&nbsp;</th>
	</tr>
</thead>
<tbody class='tbody'>";			
	
	while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
		if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";}
		if($ligne["useSSL"]==1){$ssl="check2.gif";}else{$ssl="check1.gif";}
		$statistics="&nbsp;";
		$exec_statistics="&nbsp;";
		$groupware=null;
		$forward_text=null;
		
		$added_port=null;
		$icon="free-web-32.png";
		$aw=new awstats($ligne["servername"]);
		if($aw->getCountDePages()>0){
			$statistics= imgtootltip("status_statistics-22.png","{statistics}","Loadjs('awstats.view.php?servername={$ligne["servername"]}')");
		}
		
		if($aw->GET("AwstatsEnabled")){
			$exec_statistics=imgtootltip("22-recycle.png","{build_awstats_statistics}","Loadjs('awstats.php?servername={$ligne["servername"]}&execute=yes')");
		}
		
		if($vgservices["freewebs"]<>null){
			if($ligne["lvm_size"]>0){
				$ligne["lvm_size"]=$ligne["lvm_size"]*1024;
				$sizevg="&nbsp;<i style='font-size:11px'>(".FormatBytes($ligne["lvm_size"]).")</i>";
				
			}
		}
		$ServerPort=$ligne["ServerPort"];
		if($ServerPort>0){$added_port=":$ServerPort";}
		if($ligne["UseReverseProxy"]){$icon="Firewall-Move-Right-32.png";}
		
		if($ligne["groupware"]<>null){
			$groupware="<span style='text-align:right;font-size:11px;font-weight:bold;font-style:italic;color:#B64B13;float:right'>&nbsp;({{$vhosts->TEXT_ARRAY[$ligne["groupware"]]["TITLE"]}})</span>";
		}
		
		if($ligne["Forwarder"]==1){$forward_text="<span style='text-align:right;font-size:11px;font-weight:bold;font-style:italic;color:#B64B13;float:right'>{www_forward} <b>{$ligne["ForwardTo"]}</b></span>";}
		$edit=imgtootltip($icon,"{$ligne["resolved_ipaddr"]}<br>{edit}","Loadjs('freeweb.edit.php?hostname={$ligne["servername"]}')");
		
		
		$servername_text=$ligne["servername"];
		if($servername_text=="_default_"){
			$servername_text="{all}";
			$groupware="<span style='text-align:right;font-size:11px;font-weight:bold;font-style:italic;color:#B64B13;float:right'>&nbsp;({default_website})</span><br>";
		}else{
			if(trim($ligne["resolved_ipaddr"])==null){
				$edit=imgtootltip("warning-panneau-32.png","{could_not_find_iphost}<br>{click_to_edit}","Loadjs('freeweb.edit.php?hostname={$ligne["servername"]}')");
			}
				
		}
		
		$href="<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('freeweb.edit.php?hostname={$ligne["servername"]}')\"
		style='font-size:13px;text-decoration:underline;font-weight:bold'>";
		
		$html=$html."
			<tr class=$classtr>
			<td width=1%>$edit</td>
			<td nowrap>$groupware$forward_text<span style='float:left'><strong style='font-size:13px'>$href$servername_text</a>$added_port$sizevg</strong></span></td>
			<td width=1%><img src='img/$ssl'></td>
			<td width=1%>$statistics</td>
			<td width=1%>$exec_statistics</td>
			<td nowrap><strong style='font-size:13px'>{$ligne["uid"]}$ipDetect</strong></td>
			<td width=1%>". imgtootltip("delete-24.png","{delete}","FreeWebDelete('{$ligne["servername"]}')")."</td>
			</tr>
			";
		
	}	
	
	$html=$html."
	</tbody>
	</table>
	<div style='text-align:right;margin-top:8px'>". button("{recheck_net_items}","FreeWeCheckVirtualHost()")."&nbsp;&nbsp;|&nbsp;&nbsp;". button("{add_default_www}","FreeWebAddDefaultVirtualHost()")."</div>
	<script>
	var x_FreeWebDelete=function (obj) {
			var results=obj.responseText;
			if(results.length>10){alert(results);}	
			if(document.getElementById('main_config_freeweb')){	RefreshTab('main_config_freeweb');}
			if(document.getElementById('container-www-tabs')){	RefreshTab('container-www-tabs');}
		}	
		
		function FreeWebDelete(server){
			if(confirm('$delete_freeweb_text')){
				var XHR = new XHRConnection();
				XHR.appendData('delete-servername',server);
				AnimateDiv('freewebs_list');
    			XHR.sendAndLoad('$page', 'GET',x_FreeWebDelete);
			}
		}	
		
		function FreeWebAddDefaultVirtualHost(){
			var XHR = new XHRConnection();
			XHR.appendData('AddDefaultOne','yes');
			AnimateDiv('freewebs_list');
    		XHR.sendAndLoad('$page', 'POST',x_FreeWebDelete);		
		}
		
		function FreeWeCheckVirtualHost(){
			var XHR = new XHRConnection();
			XHR.appendData('CheckAVailable','yes');
			AnimateDiv('freewebs_list');
    		XHR.sendAndLoad('$page', 'POST',x_FreeWebDelete);			
		}
		
	</script>	
	
	";
	
	echo $tpl->_ENGINE_parse_body($html);
	
	
}
예제 #3
0
function listwebs_search()
{
    include_once dirname(__FILE__) . '/ressources/class.apache.inc';
    $vhosts = new vhosts();
    $search = $_GET["search"];
    $page = CurrentPageName();
    $users = new usersMenus();
    $DNS_INSTALLED = false;
    $where = null;
    $query_groupware = null;
    $addg = imgtootltip("plus-24.png", "{add} {joomlaservername}", "Loadjs('freeweb.edit.php?hostname=&force-groupware={$_GET["force-groupware"]}')");
    if ($_GET["force-groupware"] != null) {
        if ($_GET["force-groupware"] == "ZARAFA-WEBS") {
            if ($_GET["ForceInstanceZarafaID"] > 0) {
                $ForceInstanceZarafaIDQ = " AND ForceInstanceZarafaID={$_GET["ForceInstanceZarafaID"]}";
            }
            $query_groupware = " AND ((groupware='ZARAFA'{$ForceInstanceZarafaIDQ}) OR (groupware='ZARAFA_MOBILE'{$ForceInstanceZarafaIDQ}) OR (groupware='Z-PUSH'{$ForceInstanceZarafaIDQ}))";
            $addg = "&nbsp;";
        }
        if ($query_groupware == null) {
            $query_groupware = " AND groupware='{$_GET["force-groupware"]}'";
        }
    }
    if (!$users->AsSystemAdministrator) {
        $whereOU = "  AND ou='{$_SESSION["ou"]}'";
        $ou = "&nbsp;&raquo;&nbsp;{$_SESSION["ou"]}";
    }
    if (strlen($search) > 1) {
        $search = "*{$search}*";
        $search = str_replace("*", "%", $search);
        $search = str_replace("%%", "%", $search);
        $whereOU = "AND (servername LIKE '{$search}' {$whereOU}{$query_groupware}) OR (domainname LIKE '{$search}' {$whereOU}{$query_groupware})";
    } else {
        $query_groupware_single = $query_groupware;
    }
    if ($users->dnsmasq_installed) {
        $DNS_INSTALLED = true;
    }
    if ($users->POWER_DNS_INSTALLED) {
        $DNS_INSTALLED = true;
    }
    if (strlen($search) < 2) {
        $sock = new sockets();
        $EnableWebDavPerUser = $sock->GET_INFO("EnableWebDavPerUser");
        if (!is_numeric($EnableWebDavPerUser)) {
            $EnableWebDavPerUser = 0;
        }
        $WebDavPerUserSets = unserialize(base64_decode($sock->GET_INFO("WebDavPerUserSets")));
        if ($EnableWebDavPerUser == 1) {
            $icon = "webdav-32.png";
            $groupware = "<span style='text-align:right;font-size:11px;font-weight:bold;font-style:italic;color:#B64B13;float:right'>&nbsp;WebDav</span>";
            $href = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('freeweb.webdavusr.php')\" style='font-size:13px;text-decoration:underline;font-weight:bold'>";
            $edit = imgtootltip($icon, "{apply} *.{$WebDavPerUserSets["WebDavSuffix"]}", "Loadjs('freeweb.webdavusr.php')");
            if ($WebDavPerUserSets["EnableSSL"] == 1) {
                $ssl = "20-check.png";
            } else {
                $ssl = "none-20.png";
            }
            $WebdavTR = "\n\t\t\t<tr class={$classtr}>\n\t\t\t<td width=1%>{$edit}</td>\n\t\t\t<td nowrap style='color:{$color}'><span style='float:left'>\n\t\t\t<strong style='font-size:13px;style='color:{$color}'>{$href}*.{$WebDavPerUserSets["WebDavSuffix"]}</a></strong></span>\n\t\t\t</td>\n\t\t\t\n\t\t\t<td width=1% style='font-size:11px;font-weight:bold;color:#5F5656;'>&nbsp;</td>\n\t\t\t<td width=1% style='font-size:11px;font-weight:bold;color:#5F5656;'>&nbsp;</td>\n\t\t\t<td width=1%><img src='img/{$ssl}'></td>\n\t\t\t<td width=1% align='center'>&nbsp;</td>\n\t\t\t<td width=1% align='center'>&nbsp;</td>\n\t\t\t<td width=1% align='center'>&nbsp;</td>\n\t\t\t<td width=1% align='center'>&nbsp;</td>\n\t\t\t<td width=1% align='center'>&nbsp;</td>\n\t\t\t<td width=1%>&nbsp;</td>\n\t\t\t</tr>\n\t\t\t";
        }
    }
    $tpl = new templates();
    $sock = new sockets();
    $delete_freeweb_text = $tpl->javascript_parse_text("{delete_freeweb_text}");
    $delete_freeweb_dnstext = $tpl->javascript_parse_text("{delete_freeweb_dnstext}");
    $sql = "SELECT * FROM freeweb WHERE 1 {$whereOU}{$query_groupware_single} ORDER BY servername";
    $q = new mysql();
    if (!isset($_SESSION["CheckTableWebsites"])) {
        $q->BuildTables();
        $_SESSION["CheckTableWebsites"] = true;
    }
    $results = $q->QUERY_SQL($sql, 'artica_backup');
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><code>{$sql}</code>";
    }
    $vgservices = unserialize(base64_decode($sock->GET_INFO("vgservices")));
    $html = "\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t<th width=1%>{$addg}</th>\n\t<th>{joomlaservername}:{$ou}</th>\n\t<th>{memory}</th>\n\t<th>{requests}</th>\n\t<th>SSL</th>\n\t<th>RESOLV</th>\n\t<th>DNS</th>\n\t<th>{member}</th>\n\t<th>&nbsp;</th>\n\t<th>&nbsp;</th>\n\t\n\t<th>&nbsp;</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>{$WebdavTR}";
    $pdns = new pdns();
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        if ($ligne["useSSL"] == 1) {
            $ssl = "20-check.png";
        } else {
            $ssl = "none-20.png";
        }
        $statistics = "&nbsp;";
        $exec_statistics = "&nbsp;";
        $groupware = null;
        $forward_text = null;
        $checkDNS = "&nbsp;";
        $checkMember = "&nbsp;";
        $JSDNS = 0;
        if ($DNS_INSTALLED) {
            $ip = $pdns->GetIpDN($ligne["servername"]);
            if ($ip != null) {
                $checkDNS = imgtootltip("20-check.png", "<span style=font-size:16px>{$ligne["servername"]}<hr>{dns}: {$ip}</span>");
                $JSDNS = 1;
            }
        }
        $ServerAlias = null;
        $Params = @unserialize(base64_decode($ligne["Params"]));
        $f = array();
        if (isset($Params["ServerAlias"])) {
            while (list($host, $num) = each($Params["ServerAlias"])) {
                $f[] = $host;
            }
            $ServerAlias = "<hr style='border: 1px'><div style='font-size:11px'><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('freeweb.edit.ServerAlias.php?servername={$ligne["servername"]}')\" style='text-decoration:underline'><i>" . @implode(", ", $f) . "</i></div>";
        }
        if ($ligne["uid"] != null) {
            $checkMember = imgtootltip("20-check.png", "<span style=font-size:16px>{$ligne["servername"]}<hr>{member}: {$ligne["uid"]}</span>");
        }
        $added_port = null;
        $icon = "free-web-32.png";
        $aw = new awstats($ligne["servername"]);
        if ($aw->getCountDePages() > 0) {
            $statistics = imgtootltip("status_statistics-22.png", "{statistics}", "Loadjs('awstats.view.php?servername={$ligne["servername"]}')");
        }
        if ($aw->GET("AwstatsEnabled")) {
            $exec_statistics = imgtootltip("22-recycle.png", "{build_awstats_statistics}", "Loadjs('awstats.php?servername={$ligne["servername"]}&execute=yes')");
        }
        if ($vgservices["freewebs"] != null) {
            if ($ligne["lvm_size"] > 0) {
                $ligne["lvm_size"] = $ligne["lvm_size"] * 1024;
                $sizevg = "&nbsp;<i style='font-size:11px'>(" . FormatBytes($ligne["lvm_size"]) . ")</i>";
            }
        }
        $ServerPort = $ligne["ServerPort"];
        if ($ServerPort > 0) {
            $added_port = ":{$ServerPort}";
        }
        if ($ligne["UseReverseProxy"]) {
            $icon = "Firewall-Move-Right-32.png";
        }
        if ($ligne["groupware"] != null) {
            $groupware = "<span style='text-align:right;font-size:11px;font-weight:bold;font-style:italic;color:#B64B13;float:right'>&nbsp;({{$vhosts->TEXT_ARRAY[$ligne["groupware"]]["TITLE"]}})</span>";
        }
        if ($ligne["Forwarder"] == 1) {
            $forward_text = "<span style='text-align:right;font-size:11px;font-weight:bold;font-style:italic;color:#B64B13;float:right'>{www_forward} <b>{$ligne["ForwardTo"]}</b></span>";
        }
        $edit = imgtootltip($icon, "{$ligne["resolved_ipaddr"]}<br>{apply}", "Loadjs('freeweb.edit.php?hostname={$ligne["servername"]}')");
        $servername_text = $ligne["servername"];
        if ($servername_text == "_default_") {
            $servername_text = "{all}";
            $groupware = "<span style='text-align:right;font-size:11px;font-weight:bold;font-style:italic;color:#B64B13;float:right'>&nbsp;({default_website})</span><br>";
        } else {
            $checkResolv = imgtootltip("20-check.png", "<span style=font-size:16px>{$ligne["servername"]}<hr>{dns}: {$ligne["resolved_ipaddr"]}</span>");
            if (trim($ligne["resolved_ipaddr"]) == null) {
                $edit = imgtootltip("warning-panneau-32.png", "{could_not_find_iphost}<br>{click_to_edit}", "Loadjs('freeweb.edit.php?hostname={$ligne["servername"]}')");
                $checkResolv = "&nbsp;";
            }
        }
        $href = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('freeweb.edit.php?hostname={$ligne["servername"]}')\"\n\t\tstyle='font-size:13px;text-decoration:underline;font-weight:bold'>";
        $color = "black";
        $delete = imgtootltip("delete-24.png", "{delete}", "FreeWebDelete('{$ligne["servername"]}',{$JSDNS})");
        $sql = "SELECT ID FROM drupal_queue_orders WHERE `ORDER`='DELETE_FREEWEB' AND `servername`='{$ligne["servername"]}'";
        $ligneDrup = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
        if ($ligne["ID"] > 0) {
            $edit = imgtootltip("folder-tasks-32.png", "{delete}");
            $color = "#8a8a8a";
            $delete = imgtootltip("delete-32-grey.png", "{delete} {scheduled}");
        }
        $sql = "SELECT ID FROM drupal_queue_orders WHERE `ORDER`='INSTALL_GROUPWARE' AND `servername`='{$ligne["servername"]}'";
        if ($ligne["ID"] > 0) {
            $edit = imgtootltip("folder-tasks-32.png", "{installing}", "Loadjs('freeweb.edit.php?hostname={$ligne["servername"]}')");
            $color = "#8a8a8a";
            $delete = imgtootltip("delete-32-grey.png", "{installing}");
            $groupware = "<span style='text-align:right;font-size:11px;font-weight:bold;font-style:italic;color:#B64B13;float:right'>&nbsp;({installing} {{$vhosts->TEXT_ARRAY[$ligne["groupware"]]["TITLE"]}})</span>";
        }
        $memory = "-";
        $requests_second = "-";
        $traffic_second = "-";
        $uptime = null;
        $table_name_stats = "apache_stats_" . date('Ym');
        $sql = "SELECT * FROM {$table_name_stats} WHERE servername='{$ligne["servername"]}' ORDER by zDate DESC LIMIT 0,1";
        $ligneStats = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events"));
        if ($ligneStats["total_memory"] > 0) {
            $memory = FormatBytes($ligneStats["total_memory"] / 1024);
            $requests_second = "{$ligneStats["requests_second"]}/s";
            $traffic_second = FormatBytes($ligneStats["traffic_second"] / 1024) . "/s";
            $uptime = "<hr style='border:0px'><div style='text-align:left;font-size:11px;font-style:italic;color:#5F5656;float:clear'>{uptime}:{$ligneStats["UPTIME"]}</div>";
        }
        $html = $html . "\n\t\t\t<tr class={$classtr}>\n\t\t\t<td width=1%>{$edit}</td>\n\t\t\t<td nowrap style='color:{$color}'>{$groupware}{$forward_text}<span style='float:left'>\n\t\t\t<strong style='font-size:13px;style='color:{$color}'>{$href}{$servername_text}</a>{$added_port}{$sizevg}</strong></span>{$ServerAlias}\n\t\t\t{$uptime}\n\t\t\t</td>\n\t\t\t\n\t\t\t<td width=1% style='font-size:11px;font-weight:bold;color:#5F5656;'>{$memory}</td>\n\t\t\t<td width=1% style='font-size:11px;font-weight:bold;color:#5F5656;'>{$requests_second}&nbsp;|&nbsp;{$traffic_second}</td>\n\t\t\t<td width=1%><img src='img/{$ssl}'></td>\n\t\t\t<td width=1% align='center'>{$checkResolv}</td>\n\t\t\t<td width=1% align='center'>{$checkDNS}</td>\n\t\t\t<td width=1% align='center'>{$checkMember}</td>\n\t\t\t<td width=1% align='center'>{$statistics}</td>\n\t\t\t<td width=1% align='center'>{$exec_statistics}</td>\n\t\t\t<td width=1%>{$delete}</td>\n\t\t\t</tr>\n\t\t\t";
    }
    $default_www = "&nbsp;&nbsp;|&nbsp;&nbsp;" . button("{add_default_www}", "FreeWebAddDefaultVirtualHost()");
    if ($_GET["force-groupware"] != null) {
        $default_www = null;
    }
    $html = $html . "\n\t</tbody>\n\t</table>\n\t<div style='text-align:right;margin-top:8px'>" . button("{recheck_net_items}", "FreeWeCheckVirtualHost()") . "{$default_www}</div>\n\t<script>\n\tvar x_FreeWebDelete=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>10){alert(results);}\t\n\t\t\tif(document.getElementById('main_config_freeweb')){\tRefreshTab('main_config_freeweb');}\n\t\t\tif(document.getElementById('container-www-tabs')){\tRefreshTab('container-www-tabs');}\n\t\t}\t\n\t\t\n\t\tfunction FreeWebDelete(server,dns){\n\t\t\tif(confirm('{$delete_freeweb_text}')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tif(dns==1){if(confirm('{$delete_freeweb_dnstext}')){XHR.appendData('delete-dns',1);}else{XHR.appendData('delete-dns',0);}}\n\t\t\t\tXHR.appendData('delete-servername',server);\n\t\t\t\tAnimateDiv('freewebs_list');\n    \t\t\tXHR.sendAndLoad('{$page}', 'GET',x_FreeWebDelete);\n\t\t\t}\n\t\t}\t\n\t\t\n\t\tfunction FreeWebAddDefaultVirtualHost(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('AddDefaultOne','yes');\n\t\t\tAnimateDiv('freewebs_list');\n    \t\tXHR.sendAndLoad('{$page}', 'POST',x_FreeWebDelete);\t\t\n\t\t}\n\t\t\n\t\tfunction FreeWeCheckVirtualHost(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('CheckAVailable','yes');\n\t\t\tAnimateDiv('freewebs_list');\n    \t\tXHR.sendAndLoad('{$page}', 'POST',x_FreeWebDelete);\t\t\t\n\t\t}\n\t\t\n\t</script>\t\n\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
예제 #4
0
function exectute_awstats($servername, $articameta = false)
{
    $unix = new unix();
    $perl = $unix->find_program("perl");
    $awstats = $unix->LOCATE_AWSTATS_BIN();
    $GLOBALS["ARTICAMETA"] = $articameta;
    $awstats_buildstaticpages = $unix->LOCATE_AWSTATS_BUILDSTATICPAGES_BIN();
    $q = new mysql();
    $nice = EXEC_NICE();
    $GLOBALS["nice"] = $nice;
    $aw = new awstats($servername);
    $config = $aw->buildconf();
    $configlength = strlen($config);
    if ($configlength < 10) {
        if ($GLOBALS["VERBOSE"]) {
            echo "configuration file lenght failed {$configlength} bytes, aborting {$servername}\n";
        }
        return;
    }
    @file_put_contents("/etc/awstats/awstats.{$servername}.conf", $config);
    @chmod("/etc/awstats/awstats.{$servername}.conf", 644);
    $Lang = $aw->GET("Lang");
    if ($Lang == null) {
        $Lang = "auto";
    }
    @mkdir("/var/tmp/awstats/{$servername}", 666, true);
    $t1 = time();
    $cmd = "{$nice}{$perl} {$awstats_buildstaticpages} -config={$servername} -update -lang={$Lang} -awstatsprog={$awstats} -dir=/var/tmp/awstats/{$servername} 2>&1";
    if ($GLOBALS["VERBOSE"]) {
        echo $cmd . "\n";
    }
    exec($cmd, $results);
    if ($GLOBALS["VERBOSE"]) {
        echo @implode("\n", $results) . "\n";
    }
    $t2 = time();
    awstats_import_sql($servername, $articameta);
    $time_duration = distanceOfTimeInWords($t1, $t2);
    if ($GLOBALS["VERBOSE"]) {
        echo "{$time_duration}\n";
    }
    $unix->send_email_events("generating awstats statistics for {$servername} success {$time_duration}", @implode("\n", $results), "system");
}
예제 #5
0
function index()
{
    $page = CurrentPageName();
    $aw = new awstats($_GET["servername"]);
    $LogTypeAR = array("W" => "{LogTypeW}", "M" => "{LogTypeM}", "F" => "{LogTypeF}");
    $LangAR = array("auto" => "auto", "Albanian" => "al", "Bosnian" => "ba", "Bulgarian" => "bg", "Catalan" => "ca", "Chinese(Taiwan)" => "tw", "Chinese(Simpliefied)" => "cn", "Croatian" => "hr", "Czech" => "cz", "Danish" => "dk", "Dutch" => "nl", "English" => "en", "Estonian" => "et", "Euskara" => "eu", "Finnish" => "fi", "French" => "fr", "Galician" => "gl", "German" => "de", "Greek" => "gr", "Hebrew" => "he", "Hungarian" => "hu", "Icelandic" => "is", "Indonesian" => "id", "Italian" => "it", "Japanese" => "jp", "Korean" => "ko", "Latvian" => "lv", "Norwegian(Nynorsk)" => "nn", "Norwegian(Bokmal)" => "nb", "Polish" => "pl", "Portuguese" => "pt", "Portuguese(Brazilian)" => "br", "Romanian" => "ro", "Russian" => "ru", "Serbian" => "sr", "Slovak" => "sk", "Slovenian" => "si", "Spanish" => "es", "Swedish" => "se", "Turkish" => "tr", "Ukrainian" => "ua", "Welsh" => "cy");
    krsort($LangAR);
    while (list($num, $ligne) = each($LangAR)) {
        $LangAR2[$ligne] = $num;
    }
    $LogFormatAR = array(1 => "Apache", 2 => "IIS {or} ISA", 3 => "Webstar", 4 => "Apache {or} Squid");
    $LogType_field = Field_array_Hash($LogTypeAR, "LogType", $aw->GET("LogType"), "style:font-size:13px;padding:3px");
    $LogFormat_field = Field_array_Hash($LogFormatAR, "LogFormat", $aw->GET("LogFormat"), "style:font-size:13px;padding:3px");
    $LogFile_field = Field_text("LogFile", $aw->GET("LogFile"), "font-size:13px;padding:3px;width:220px");
    $LogSeparator_field = Field_text("LogSeparator", $aw->GET("LogSeparator"), "font-size:13px;padding:3px;width:220px");
    $SiteDomain_field = Field_text("SiteDomain", $aw->GET("SiteDomain"), "font-size:13px;padding:3px;width:220px");
    if ($_GET["freewebs"] == 1) {
        $aw->SET("LogFile", "/var/www/{$_GET["servername"]}/www_logs/access.log");
        $aw->SET("LogType", "W");
        $aw->SET("LogFormat", "1");
        $aw->SET("LogSeparator", " ");
        $aw->SET("SiteDomain", "{$_GET["servername"]}");
        $LogFile_field = "<input type='hidden' id='LogFile' value='{$aw->GET("LogFile")}'>{$aw->GET("LogFile")}";
        $LogType_field = "<input type='hidden' id='LogType' value='{$aw->GET("LogType")}'>{LogType{$aw->GET("LogType")}}";
        $LogFormat_field = "<input type='hidden' id='LogFormat' value='{$aw->GET("LogFormat")}'>{$LogFormatAR[$aw->GET("LogFormat")]}";
        $LogSeparator_field = "<input type='hidden' id='LogSeparator' value='{$aw->GET("LogSeparator")}'>&laquo;{$aw->GET("LogSeparator")}&raquo;";
        $SiteDomain_field = "<input type='hidden' id='SiteDomain' value='{$aw->GET("SiteDomain")}'>{$aw->GET("SiteDomain")}";
    }
    $aw->SET("DNSLookup", 2);
    $html = "\n\t<div id='awstats_parms1'>\n\t<table style='width:99%' class=form>\n\t<tr>\n\t\t<td class=legend>{enable}:</td>\n\t\t<td style='font-size:13px;font-weight:bold'>" . Field_checkbox("AwstatsEnabled", 1, $aw->GET("AwstatsEnabled")) . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend>{SiteDomain}:</td>\n\t\t<td style='font-size:13px;font-weight:bold'>{$SiteDomain_field}</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend>{language}:</td>\n\t\t<td style='font-size:13px;font-weight:bold'>" . Field_array_Hash($LangAR2, "Lang", $aw->GET("Lang"), "style:font-size:13px;padding:3px") . "</td>\n\t</tr>\t\t\t\n\t<tr>\n\t\t<td class=legend>{logfile}:</td>\n\t\t<td style='font-size:13px;font-weight:bold'>{$LogFile_field}</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend>{LogType}:</td>\n\t\t<td style='font-size:13px;font-weight:bold'>{$LogType_field}</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend>{LogFormat}:</td>\n\t\t<td style='font-size:13px;font-weight:bold'>{$LogFormat_field}</td>\n\t</tr>\t\t\n\t<tr>\n\t\t<td class=legend>{LogSeparator}:</td>\n\t\t<td style='font-size:13px;font-weight:bold'>{$LogSeparator_field}</td>\n\t</tr>\t\n\t<tr>\n\t\t<td colspan=2 align='right'>" . button("{apply}", "SaveAwstats()") . "</td>\n\t</tr>\n\t</table>\n\t\n\t<script>\n\t\tvar x_SaveAwstats=function (obj) {\n\t\t\tvar results=trim(obj.responseText);\n\t\t\tif(results.length>2){alert(results);}\t\t\t\n\t\t\tRefreshTab('main_config_awstats');\n\t\t\t}\t\n\t\n\t\n\t\tfunction SaveAwstats(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tif(document.getElementById('AwstatsEnabled').checked){XHR.appendData('AwstatsEnabled',1);}else{XHR.appendData('AwstatsEnabled',0);}\n\t\t\tXHR.appendData('servername','{$_GET["servername"]}');\n    \t\tXHR.appendData('LogFile',document.getElementById('LogFile').value);\n    \t\tXHR.appendData('LogType',document.getElementById('LogType').value);\n    \t\tXHR.appendData('LogFormat',document.getElementById('LogFormat').value);\n    \t\tXHR.appendData('LogSeparator',document.getElementById('LogSeparator').value);\n \t\t\tdocument.getElementById('awstats_parms1').innerHTML='<center><img src=img/wait_verybig.gif></center>';\n    \t\tXHR.sendAndLoad('{$page}', 'GET',x_SaveAwstats);\n\t\t\t\n\t\t}\t\n\t\t\n</script>\t\n";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}