Beispiel #1
0
function ParseArray($myarray, $indent)
{
    foreach ($myarray as $item_key => $item_value) {
        if ($item_key == "GLOBALS") {
            continue;
        }
        for ($i = 0; $i < $indent; $i++) {
            echo "&nbsp;";
        }
        if (is_array($item_value)) {
            echo "<br/>\n<br/>\n" . $item_key . " : ARRAY<br/>\n-------------------------------------------<br/>\n";
            ParseArray($item_value, $indent + 0);
        } else {
            echo $item_key . " : " . $item_value . "<br/>\n";
        }
    }
}
function page_proc(){
	$sock=new sockets();
	$tpl=new templates();
	
	$sock->getfile('TaskManager');
	include_once("ressources/psps.inc");
	
	
	
	
	$html="
	<center><input type='button' OnClick=\"javascript:ReloadTaskManager();\" value='&laquo;&nbsp;{reload}&nbsp;&raquo;'></center>
	<table style='width:100%;border:1px solid #CCCCCC;padding:3px'>
	 	<tr style='background-color:#CCCCCC'>
	 	<td valign='middle' class='bottom' style='font-size:10px;font-weight:bold'>&nbsp;</td>
	 	<td valign='top' class='bottom' style='font-size:10px;font-weight:bold'>&nbsp;{process_name}</td>
	 	<td valign='top' class='bottom' style='font-size:10px;font-weight:bold'>&nbsp;PID</td>
	 	<td valign='top' class='bottom'  style='font-size:10px;font-weight:bold'>&nbsp;{memory}</td>
	 	</tr>
	 	";
	
	 while (list ($num, $ds) = each ($processes) ){
	 	
	 	$tools=ParseArray($ds['status']);
	 	$tooltip=CellRollOver("ProcessTaskEdit('{$num}')",$tools);
	 	$html=$html . "
	 	<tr $tooltip>
	 	<td valign='middle' class='bottom' style='font-size:10px'><img src='img/fw-vert-s.gif'></td>
	 	<td valign='top' class='bottom' style='font-size:10px'>{$ds['status']["name"]}</td>
	 	<td valign='top' class='bottom' style='font-size:10px'>{$num}</td>
	    <td valign='top' class='bottom'  style='font-size:10px'>". FormatBytes($ds['memory'])."</td>
	 	</tr>
	 	";}
	 	
	 
	
	$html=$html . "
	</table>
	";
	return  $tpl->_ENGINE_parse_body($html);
	
}
Beispiel #3
0
/**
 * Returns the formated date of the
 * revision of the workspace.
 * @param SwcConfig $config SWC config for the operation.
 * @return string Date of webspace revision.
 *
 * @since v1.0.0
 */
function GetWebspaceRevisionDate($config)
{
    $info = GetWebspaceInfo($config);
    $timestamp = ParseArray($info[IDX_STDOUT], '<date>', '</date>');
    $timestamp = strtotime($timestamp);
    return GetLocalizedTimestamp($timestamp);
}
function ParseFile($servername, $fullpath)
{
    events("[{$servername}]: Parsing {$fullpath}", __FUNCTION__, __LINE__);
    $unix = new unix();
    $size = @filesize($fullpath);
    events("[{$servername}]: open {$fullpath} {$size} bytes", __FUNCTION__, __LINE__);
    $handle = @fopen($fullpath, "r");
    if (!$handle) {
        events("[{$servername}]: open {$fullpath} fatal, unable to open ", __FUNCTION__, __LINE__);
        return;
    }
    $c = 0;
    $d = 0;
    $t = time();
    $WORKARRAY = array();
    while (!feof($handle)) {
        $d++;
        $line = trim(fgets($handle, 4096));
        if ($line == null) {
            continue;
        }
        if (!preg_match('#(.*?)\\s+(.*?)\\s+(.*?)\\s+\\[(.*?)\\]\\s+([A-Z]+)\\s+(.*?)\\s+HTTP.*?\\/.*?"([0-9]+)"\\s+([0-9]+)\\s+"(.*?)"\\s+"(.*?)"\\s+"(.*?)"#', $line, $re)) {
            events("[{$servername}]: {{$line}} unable to parse...", __FUNCTION__, __LINE__);
            continue;
        }
        while (list($a, $b) = each($re)) {
            $re[$a] = mysql_escape_string2($b);
        }
        $c++;
        $md5 = md5($re[0]);
        $ipaddr = $re[1];
        $time = strtotime($re[4]);
        $proto = $re[5];
        $uri = $re[6];
        $code = $re[7];
        $size = $re[8];
        $UserAgent = $re[10];
        $Country = mysql_escape_string2(GeoLoc($ipaddr));
        $currDate = date("Y-m-d H:i:s");
        $linesql = "('{$md5}','{$currDate}','{$ipaddr}','{$proto}','{$uri}','{$code}','{$size}','{$UserAgent}','{$Country}')";
        $table = "hour_" . date("YmdH", $time);
        $WORKARRAY[$table][] = $linesql;
        if ($c > 500) {
            if (!ParseArray($servername, $WORKARRAY)) {
                return;
            }
            $WORKARRAY = array();
            $c = 0;
        }
    }
    if (count($WORKARRAY) > 0) {
        if (!ParseArray($servername, $WORKARRAY)) {
            return;
        }
    }
    $timeTOScan = $unix->distanceOfTimeInWords($t, time(), true);
    events("[{$servername}]: {$fullpath} {$timeTOScan} {$d} lines", __FUNCTION__, __LINE__);
    if ($d == 0) {
        @unlink($fullpath);
    }
    $sys = new mysql_storelogs();
    $filedate = date('Y-m-d H:i:s', filemtime($fullpath));
    $sys->ROTATE_TOMYSQL($fullpath, $filedate);
}