<?



ob_start("ob_gzhandler");

require "include/bittorrent.php";
hit_start();

dbconn(true);

loggedinorreturn();
function bark($text = "Du willst hier ohne einloggen hin???")
{
  stderr("Atschibätsch", $text);
}
if (!$CURUSER)
bark("Was willst du denn hier ???");

//neue anzeige
function _server_stats_network()
{
    $results = array();

    $bufr = _server_stats_rfts('/proc/net/dev');

    if ($bufr != "ERROR")
    {
        $bufe = explode("\n", $bufr);

        foreach ($bufe as $buf)
        {
            $buf = trim($buf);

            if (preg_match('/:/', $buf))
            {
                list($dev_name, $stats_list) = preg_split('/:/', $buf, 2);

                $stats = preg_split('/\s+/', trim($stats_list));
                $results[$dev_name] = array();

                $results[$dev_name]['rx_bytes'] = $stats[0];
                $results[$dev_name]['rx_packets'] = $stats[1];
                $results[$dev_name]['rx_errs'] = $stats[2];
                $results[$dev_name]['rx_drop'] = $stats[3];

                $results[$dev_name]['tx_bytes'] = $stats[8];
                $results[$dev_name]['tx_packets'] = $stats[9];
                $results[$dev_name]['tx_errs'] = $stats[10];
                $results[$dev_name]['tx_drop'] = $stats[11];

                $results[$dev_name]['errs'] = $stats[2] + $stats[10];
                $results[$dev_name]['drop'] = $stats[3] + $stats[11];
            }
        }
    }

    return $results;
}

function _server_stats($process='*')
{
    $results = array();

    $cpu_perc = 0;
    $proc_active = 0;
    $proc_total = 0;
    $mem_size = 0;
    $vmem_size = 0;

    if ($process == '*')
    {
        $cmd = 'ps --no-header -o pcpu,size,vsize,state,args -A';
    }
    else
    {
        $cmd = 'ps --no-header -o pcpu,size,vsize,state,args -C ' . $process;
    }

    $cmd .= '|awk \'BEGIN{c=cu=m=vm=0}{c+=1;cu+=$1;m+=$2;vm+=$3}END{print c ";" cu ";" m ";" vm ";" vm+m}\'';

    $data = explode(';', exec($cmd));

    $proc_total =& $data[0];
    $cpu_perc =& $data[1];
    $mem_size =& $data[2];
    $vmem_size =& $data[3];

    $results['cpu_perc'] = $cpu_perc;
    $results['mem_size'] = $mem_size;
    $results['mem_vsize'] = $vmem_size;

    $results['proc_total'] = $proc_total;
    $results['proc_active'] = $proc_active;

    return $results;
}

function _server_stats_rfts($strFileName, $intLines=0, $intBytes=4096)
{
    $strFile = "";
    $intCurLine = 1;

    if ($fd = @fopen($strFileName, 'r'))
    {
        while (!feof($fd))
        {
             $strFile .= fgets($fd, $intBytes);

            if ($intLines <= $intCurLine && $intLines != 0)
            {
                break;
            }
            else
            {
                $intCurLine++;
            }
        }

        fclose($fd);
    }
    else
    {
        return "ERROR";
    }


    return $strFile;
}
//stdhead();

$dt24 = gmtime() - 86400;
$arr = mysql_fetch_assoc(mysql_query("SELECT * FROM avps WHERE arg='last24'")) or $no24=true;
$res=mysql_query("SELECT * FROM users WHERE last_access >= '". get_date_time($dt24). "' ORDER BY username") or sqlerr(__FILE__, __LINE__);
$totalonline24 = mysql_num_rows($res);

$_ss24 = ($totalonline24 != 1) ? 'er':'';


$last24record = get_date_time($arr["value_u"]);
$last24 = $arr["value_i"];
if ($no24 || $totalonline24 > $last24 )
{
$last24 = $totalonline24;

$period = strtotime(gmdate("Y-m-d H:i:s"));
mysql_query(($no24 ? 'INSERT':'UPDATE'). " avps SET value_i = $last24 , value_u = $period ". ($no24 ? ", arg='last24'":"WHERE arg='last24'")) or sqlerr();
}

while ($arr = mysql_fetch_assoc($res))
{
if ($activeusers24) $activeusers24 .= ",\n";

if($arr['class'] != '1')
   $arr["username"] = "<font class=".get_class_color($arr["class"]).">" . $arr["username"] . "</font>";

if($donator = $arr["donor"] === "yes");
$activeusers24 .= "<nobr>";
if ($warned = $arr["warned"] === "yes")
$activeusers24 .= "<nobr>";
if ($CURUSER)
$activeusers24 .= "<a href=userdetails.php?id=" . $arr["id"] . "><b>" . $arr["username"] . "</b></a>";
else
$activeusers24 .= "<b>{$arr["username"]}</b>";
if ($donator)
$activeusers24 .= "<img src={$pic_base_url}/pic/star.gif alt='Donated {$$arr["donor"]}'></nobr>";
if ($warned)
$activeusers24 .= "<img src={$pic_base_url}/pic/warned.gif alt='Warned {$$arr["warned"]}'></nobr>";
}
if (!$activeusers24)
$activeusers24 = "Es waren die letzten 24H keine Mitglieder aktiv auf dem Tracker.";$registered = number_format(get_row_count("users"));

function linuxUptime() {
  $ut = strtok( exec( "cat /proc/uptime" ), "." );
  $days = sprintf( "%2d", ($ut/(3600*24)) );
  $hours = sprintf( "%2d", ( ($ut % (3600*24)) / 3600) );
  $min = sprintf( "%2d", ($ut % (3600*24) % 3600)/60  );
  $sec = sprintf( "%2d", ($ut % (3600*24) % 3600)%60  );
  return array( $days, $hours, $min, $sec );
}

$ut = linuxUptime();
// ende neue anzeige

$registered = number_format(get_row_count("users"));
$inactive = number_format(get_row_count("users", "WHERE enabled='no'"));
$warned = number_format(get_row_count("users", "WHERE warned='yes'"));
$verwarnt = number_format(get_row_count("users", "WHERE warned='yes'"));
$user = number_format(get_row_count("users", "WHERE class='0'"));
$uploader = number_format(get_row_count("users", "WHERE class='15'"));
$coadmin = number_format(get_row_count("users", "WHERE class='26'"));
$power = number_format(get_row_count("users", "WHERE class='1'"));
$extremeuser = number_format(get_row_count("users", "WHERE class='4'"));
$donor = number_format(get_row_count("users", "WHERE donor='yes'"));
$promoter = number_format(get_row_count("users", "WHERE class='20'"));
$vip = number_format(get_row_count("users", "WHERE class='5'"));
$partvip = number_format(get_row_count("users", "WHERE class='10'"));

$mod = number_format(get_row_count("users", "WHERE class='25'"));
$admin = number_format(get_row_count("users", "WHERE class='51'"));
$teamleitung = number_format(get_row_count("users", "WHERE class='52'"));
$cosys = number_format(get_row_count("users", "WHERE class='80'"));
$sys = number_format(get_row_count("users", "WHERE class='100'"));
$owner = number_format(get_row_count("users", "WHERE class='103'"));
$tech = number_format(get_row_count("users", "WHERE class='200'"));
$unverified = number_format(get_row_count("users", "WHERE status='pending'"));
$torrents = number_format(get_row_count("torrents"));
$dead = number_format(get_row_count("torrents", "WHERE visible='no'"));
$active = number_format(get_row_count("torrents", "WHERE visible='yes'"));
$free = number_format(get_row_count("torrents", "WHERE free='yes'"));
$peers = number_format(get_row_count("peers"));
$seeder = get_row_count("peers", "WHERE seeder='yes'");
$leecher = get_row_count("peers", "WHERE seeder='no'");
$webseed = number_format(get_row_count("users", "WHERE webseed='yes'"));
$dsl1 = number_format(get_row_count("users", "WHERE dsl_speed='1000'"));
$dsl2 = number_format(get_row_count("users", "WHERE dsl_speed='2000'"));
$dsl3 = number_format(get_row_count("users", "WHERE dsl_speed='3000'"));
$dsl4 = number_format(get_row_count("users", "WHERE dsl_speed='4000'"));
$dsl6 = number_format(get_row_count("users", "WHERE dsl_speed='6000'"));
$dsl166 = number_format(get_row_count("users", "WHERE dsl_speed='10000'"));
$dsl16 = number_format(get_row_count("users", "WHERE dsl_speed='16000'"));
$dsl17 = number_format(get_row_count("users", "WHERE dsl_speed='20000'"));
$dsl18 = number_format(get_row_count("users", "WHERE dsl_speed='root'"));
if($leecher != 0){
	$pratio = ($seeder / $leecher) * 100;
}
else {
	$pratio = ($seeder * 100);
}

$seeder = number_format(get_row_count("peers", "WHERE seeder='yes'"));
$leecher = number_format(get_row_count("peers", "WHERE seeder='no'"));
$class =

// Totalspeed mod
       $resSpeed = mysql_query("SELECT seeders,leechers,id FROM torrents WHERE visible='yes' ORDER BY added DESC") or sqlerr(__FILE__, __LINE__);
       while ($rowTmp = mysql_fetch_array ($resSpeed)) {
 $seedersTmp = $rowTmp['seeders'];
 $leechersTmp = $rowTmp['leechers'];
 $torrentId = $rowTmp['id'];
 if ($seedersTmp >= 1 && $leechersTmp >= 1){
         $spd = mysql_query("SELECT (t.size * t.times_completed + SUM(p.downloaded)) / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(added)) AS totalspeed FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent AND p.torrent = '$torrentId' WHERE p.seeder = 'no' GROUP BY t.id ORDER BY added ASC") or sqlerr(__FILE__, __LINE__);
         $a = mysql_fetch_assoc($spd);
         $tmpSpeed += $a["totalspeed"];

}
}
$result = mysql_query("SELECT SUM(downloaded) AS totaldl, SUM(uploaded) AS totalul FROM users") or sqlerr(__FILE__, __LINE__);

$row = mysql_fetch_assoc($result);
$totaldl = $row[totaldl];
$totalup = $row[totalul];
$totalg = ($totalup + $totaldl);
$totalr = (($totalup / $totaldl));
$dt = time() - 200;
$dt = sqlesc(get_date_time($dt));
$maxdt = get_date_time(time() - 21600*28);
$res = mysql_query("SELECT id, username, class, donor, warned, added, enabled FROM users WHERE last_access >= $dt AND last_access <= NOW() ORDER BY class DESC,username") or print(mysql_error());
$activeusers_no = mysql_num_rows($res);

// last warned user
$res7 = mysql_query("SELECT id, username FROM users WHERE warned = 'yes'") or

print(mysql_error());

while ($arr7 = mysql_fetch_assoc($res7))
{

if ($warned2) $warned2 .= ",\n";
    //$ers["username"] = "<font class=".get_class_color($ers["class"]).">" . $ers["username"] . "</font>";
    if ($CURUSER)
        $warned2 .= "<a href=userdetails.php?id=" . $arr7["id"] . "><b>" . $arr7["username"] . "</b></a>";
    else
        $warned2 .= "<b>$arr7[username]</b>";
}

if ($warned) $warned .= ",\n";
    //$ers["username"] = "<font class=".get_class_color($ers["class"]).">" . $ers["username"] . "</font>";
    if ($CURUSER)
        $warned .= "<a href=userdetails.php?id=" . $arr7["id"] . "><b>" . $arr7["username"] . "</b></a>";
    else
        $warned .= "<b>$arr7[username]</b>";



if (!$warned)
    $warned= "Momentan gibt es keine verwarnten User auf diesem Tracker.";
 // last warned user ende
// webseeder user
$res7 = mysql_query("SELECT id, username FROM users WHERE webseed = 'yes'") or

print(mysql_error());

while ($arr7 = mysql_fetch_assoc($res7))
{


if ($webseeder) $webseeder .= ",\n";
    //$ers["username"] = "<font class=".get_class_color($ers["class"]).">" . $ers["username"] . "</font>";
    if ($CURUSER)
        $webseeder .= "<a href=userdetails.php?id=" . $arr7["id"] . "><b>" . $arr7["username"] . "</b></a>";
    else
        $webseeder .= "<b>$arr7[username]</b>";

    }

if (!$webseeder)
    $webseeder= "Momentan gibt es keine Webseeder User auf diesem Tracker.";
 // last webseeder user ende

while ($arr = mysql_fetch_assoc($res))
{
    if ($activeusers) $activeusers .= ",\n";
    $arr["username"] = "<font class=".get_class_color($arr["class"]).">" . $arr["username"] . "</font>";
    if ($CURUSER)
        $activeusers .= "<a href=userdetails.php?id=" . $arr["id"] . "><b>" . $arr["username"] . "</b></a>";
    else
        $activeusers .= "<b>$arr[username]</b>";

    $activeusers .= "&nbsp;".get_user_icons($arr);
}

if (!$activeusers)
    $activeusers = "Keine aktiven Mitglieder in den letzten 15 Minuten.";
stdhead();

?>
<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
 <tr class="tabletitle" width="80%">
  <td colspan="10" width="80%"><span class="normalfont"><center><b> Tracker Statistik </b></center></span></td>
 </tr><tr><td width="80%" class="tablea">
<center>



<?
?>



<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
 		<tr class="tabletitle" width="100%">
  			<td colspan="10" width="100%"><span class="normalfont"><center><b>Alle Trackerinformationen</b></center></span></td>
		</tr>
		<tr>
			<td width="33%" class="tablea" valign="top">
				<!-- Torrentinfos -->
				<table border="0" cellspacing="1" align="center" valign="top" cellpadding="5" class="tableinborder">
					<tr class="tabletitle" width="100%">
						<td colspan="10" width="100%"><!--<span class="tableb">--><center><b>Torrents und Verbindungen</b></center><!--</span>--></td>
					</tr>

					<tr><td class="tableb" align="left"><a href=/browse.php><b>Torrents</b></td><td align="right" class="tablea"><?=$torrents?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/browse.php?showsearch=1&search=&incldead=0&orderby=added&sort=desc>Aktive Torrents</td><td align="right" class="tablea"><?=$active?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/browse.php?showsearch=1&search=&incldead=2&orderby=added&sort=desc>Inaktive Torrents</td><td align="right" class="tablea"><?=$dead?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;Only Upload Torrents</td><td align="right" class="tablea"><?=$free?></td></tr>

					<tr><td class="tableb" align="left"><b>Peers</b></td><td align="right" class="tablea"><?=$peers?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;Seeders</td><td align="right" class="tablea"><?=$seeder?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;Leechers</td><td align="right" class="tablea"><?=$leecher?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;Seeder/Leecher Ratio (%)</td><td align="right" class="tablea"><?=number_format(($pratio),0)?></td></tr>

					<tr><td class="tableb" align="left"><b>Traffic Gesamt:</b></td><td align="right" class="tablea"><?=mksize($totalg)?></td></tr>

					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;Verteilungs speed</td><td align="right" class="tablea"><?=mksize($tmpSpeed ) . "/s"; ?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;Gesamt Download</td><td align="right" class="tablea"><?=mksize($totaldl)?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;Gesamt Upload</td><td align="right" class="tablea"><?=mksize($totalup)?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;Total Ratio</td><td align="right" class="tablea"><?=number_format(($totalr),3)?></td></tr>
				</table>
				<!-- ende Torrentinfos-->
			</td>
			<td width="34%" class="tablea" valign="top">
				<?if($CURUSER){?>
                                 <table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
			 		<tr class="tabletitle" width="100%">
			  			<td colspan="10" width="100%"><span class="normalfont"><center><b> Durchschnittliche DSL Geschwindigkeit </b></center></span></td>
					</tr>

					<tr>
						<td class="tableb" align="left">DSL 1000</td><td class="tableb" align="left">DSL 2000</td>  <td class="tableb" align="left">DSL 3000</td><td class="tableb" align="left">DSL 4000</td><td class="tableb" align="left">DSL 6000</td><td class="tableb" align="left">&gt; DSL 16000</td>
					</tr>

                                         <tr>
                                          <td class="tableb" align="left"><?=$dsl1?></td>
					 <td class="tableb" align="left"><?=$dsl2?></td>
					 <td class="tableb" align="left"><?=$dsl3?></td>
					 <td class="tableb" align="left"><?=$dsl4?></td>
      					 <td class="tableb" align="left"><?=$dsl6?></td>
   					 <td class="tableb" align="left"><?=$dsl16?></td>
                                         </tr>
					<?}?>
				</table>
                                 <br>
				<table border="0" cellspacing="1" align="center" cellpadding="5" class="tableinborder">
			 		<tr class="tabletitle" width="100%">
			  			<td colspan="10" width="100%"><span class="normalfont"><center><b>Monatliche Userregistrierungen</b></center></span></td>
			 		</tr>
					<tr>
						<td class="tableb" align="left">Monat</td><td class="tableb" align="left">User</td>
					</tr>
					<?php
					$res = mysql_query('SELECT RPAD(added,'.(isset($month) ? '10':'7').',"") AS date,COUNT(RPAD(added,'.(isset($month) ? '10':'7').',"")) AS count FROM users '.(isset($month) ? 'WHERE status = confirmed AND added LIKE "'.$month.'-%" ':'').' GROUP BY date ORDER BY date DESC');
					while($users = mysql_fetch_assoc($res))
					{?>
					<tr>
						<td class="tablea" align="left"><?php echo($users['date']) ?><td class="tablea" align="left"><?php echo($users['count'])?> ( <? echo(number_format(($users['count'] / 30),1))?> am tag)</td>
					</tr>
					<?}?>
				</table>

                       </td>
			<td width="33%" class="tablea" valign="top">

				<!-- ab hier die Infos ueber die einzlenen Usergruppen -->
				<table border="0" cellspacing="1" align="center" valign="top" cellpadding="5" class="tableinborder">
					<tr class="tabletitle" width="100%">
						<td colspan="10" width="100%"><center><b>User Statistiken</b></center></td>
					</tr>
					<tr><td class="tableb" align="left">Max. Mitgliederzahl</td><td align="right" class="tablea"><?=$GLOBALS["MAX_USERS"]?></td></tr>

                                  <tr><td class="tableb" align="left">Max. INVITE-Mitglieder</td><td align="right" class="tablea"><?=$GLOBALS["MAX_INVITES"]?></td></tr>

					<tr><td class="tableb" align="left"><b>Registrierte Mitglieder</b></td><td align="right" class="tablea"><?=$registered?></td></tr>
                                                                                 <tr><td class="tableb" align="left">&nbsp;&nbsp;Gemeldete Webseeder</td><td align="right" class="tablea"><font color=red><?=$webseed?></font></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;Spender <img src=/pic/star.png alt=\"Spender!\" border=0></td><td align="right" class="tablea"><?=$donor?></td></tr>

					<tr><td class="tableb" align="left">&nbsp;&nbsp;Unbest&auml;tigt </td><td align="right" class="tablea"><?=$unverified?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;Verwarnt <a href=rules.php class=altlink><img src=/pic/warned.gif alt=\"Verwarnt!\" border=0></a></td><td align="right" class="tablea"><?=$verwarnt?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;Deaktiviert <a href=rules.php class=altlink><img src=/pic/disabled.gif alt=\"Gebannt!\" border=0></a></td><td align="right" class="tablea"><?=$inactive?></td></tr>


					<tr><td class="tableb" align="left"><b>Userklassen</b></td><td align="right" class="tablea">14</td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=0><font class="ucuser">User</font></td><td align="right" class="tablea"><?=$user?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=1><font class="ucpoweruser">Power User</font></td><td align="right" class="tablea"><?=$power?></td></tr>
				       <tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=4><font class="ucxtremeuser">Extreme User</font></td><td align="right" class="tablea"><?=$extremeuser?></td></tr>
                                  <tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=10><font class="ucpartnervip">Partner VIP</font></td><td align="right" class="tablea"><?=$partvip?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=5><font class="ucvip">VIP</font></td><td align="right" class="tablea"><?=$vip?></td></tr>
				<!--	<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=7><font class="ucsvip">Special VIP</font></td><td align="right" class="tablea"><?=$svip?></td></tr>
-->
                                
                                  <tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=20><font class="ucpromoter">Promoter</font></td><td align="right" class="tablea"><?=$promoter?></td></tr>
				       <tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=15><font class="ucuploader">Uploader</font></td><td align="right" class="tablea"><?=$uploader?></td></tr>
			<!--		<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=16><font class="ucsvuploader">Special VIP Uploader</font></td><td align="right" class="tablea"><?=$svuploader?></td></tr>

                                        	<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=20>HighSpeed Uploader</td><td align="right" class="tablea"><?=$highspeeduploader?></td></tr>
                                         -->
                                         <tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=25><font class="ucmoderator">Moderatoren</font></td><td align="right" class="tablea"><?=$mod?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=26><font class="uccoadministrator">Co-Administratoren</font></td><td align="right" class="tablea"><?=$coadmin?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=51><font class="ucadministrator">Administratoren</font></td><td align="right" class="tablea"><?=$admin?></td></tr>
                                         <tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=52><font class="ucteamleitung">Teamleitung</font></td><td align="right" class="tablea"><?=$teamleitung?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=90><font class="uccosysop">CoSysop</font></td><td align="right" class="tablea"><?=$cosys?></td></tr>
					<tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=100><font class="ucsysop">SysOp</font></td><td align="right" class="tablea"><?=$sys?></td></tr>
          <tr><td class="tableb" align="left">&nbsp;&nbsp;&nbsp;<a href=/users.php?search=&class=103><font class="ucowner">Owner</font></td><td align="right" class="tablea"><?=$owner?></td></tr>

				</table>
				<!-- ende Usergruppeninfo -->
			</td>
			</td>
		</tr>
	</table>

<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
 <tr class="tabletitle" width="100%">
        <td colspan="10" width="100%"><span class="normalfont"><center><b>Tracker Speed <?=mksize($tmpSpeed ) . "/s";?>)</b></center></span></td>
</tr><tr></td></tr></table>

<table cellpadding="4" cellspacing="1" border="0" style="width:75%" class="tableinborder">
 <tr width="100%"  class="tabletitle" >
        <td colspan="10" width="100%"><span class="normalfont"><center><b>Browser und Zugriffe der letzten 24 Stunden</b></center></span></td>
 </tr><tr><td width="100%"  class="tablea""><img src="trackerUsage.php"><center><hr /><? include ("bstats.php"); ?><hr /></center></td></tr></table>
<br>
<table cellpadding="4" cellspacing="1" border="0" style="width:75%" class="tableinborder">
 <tr width="100%"  class="tabletitle" >
        <td colspan="10" width="100%"><span class="normalfont"><center><b>Webseeder Mitglieder</b></center></span></td>
 </tr><tr><td width="100%"  class="tablea""><hr /><?=$webseeder?><hr /></td></tr></table>
<br>
<table cellpadding="4" cellspacing="1" border="0" style="width:75%" class="tableinborder">
 <tr width="100%"  class="tabletitle" >
        <td colspan="10" width="100%"><span class="normalfont"><center><b>Verwarnte Mitglieder</b></center></span></td>
 </tr><tr><td width="100%"  class="tablea""><hr /><?=$warned2?><hr /></td></tr></table>
<br>

<!--neu anzeige-->
<table cellpadding="4" cellspacing="1" border="0" style="width:75%" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="10" width="100%"><span class="normalfont"><center><b> Serverauslastung </b></center></span></td>
 </tr><tr><td width="100%" class="tablea">
 <center>
 <p>Webserver-Prozesse:</p>
 <table class="tableinborder" border="0" cellpadding="0" cellspacing="1" width="402">
   <tr>
        <td align="left" style="padding: 0px; background-image: url('<?=$GLOBALS["PIC_BASE_URL"]?>loadbarbg.gif'); background-repeat: repeat-x">

<?

    $percent = min(100, round(exec('ps ax | grep -c apache2') / 150 * 100));
    if ($percent <= 70) $pic = "loadbargreen.gif";
    elseif ($percent <= 90) $pic = "loadbaryellow.gif";
    else $pic = "loadbarred.gif";
    $width = $percent * 4;
    print("<img height=15 width=$width src=\"".$GLOBALS["PIC_BASE_URL"].$pic."\" alt='$percent%'>");


?>
      </td>
    </tr>
  </table>
  <p>Serverauslastung (Durchschnittswerte): <?php
  $loadavg = explode(" ", exec("cat /proc/loadavg"));
  echo $loadavg[0]*100, "% (1min) - ", $loadavg[1]*100, "% (5min) - ", $loadavg[2]*100, "% (15min)";

  ?></p>
   </center>
</td></tr></table><br>

<table cellpadding="4" cellspacing="1" border="0" style="width:75%" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="10" width="100%"><span class="normalfont"><center><b> Systemauslastung </b></center></span></td>
 </tr><tr><td width="100%" class="tablea">
 <center>
<p>System-Prozesse:</p>
 <table class="tableinborder" border="0" cellpadding="0" cellspacing="1" width="402">
   <tr>
        <td align="left" style="padding: 0px; background-image: url('<?=$GLOBALS["PIC_BASE_URL"]?>loadbarbg.gif'); background-repeat: repeat-x">

<?php
    $_stats = _server_stats();

    $percent =& $_stats['cpu_perc'];

    if ($percent <= 70) $pic = "loadbargreen.gif";
    elseif ($percent <= 90) $pic = "loadbaryellow.gif";
    else $pic = "loadbarred.gif";
    $width = $percent * 4;
    print("<img height=15 width=$width src=\"".$GLOBALS["PIC_BASE_URL"].$pic."\" alt='$percent%'>");
?>
      </td>
    </tr>
    <tr>

        </td>
    </tr>
  </table>
<p>Systemauslastung (Durchschnittswerte): <?=$_stats['cpu_perc']?>% CPU usage, <?=mksize(1024*($_stats['mem_size']))?> memory used </p>
  </center>
</td></tr></table>
  <br>
  <table cellpadding="4" cellspacing="1" border="0" style="width:75%" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="10" width="100%"><span class="normalfont"><center><b> MySQL Auslastung </b></center></span></td>
 </tr><tr><td width="100%" class="tablea">
 <center>
 <p>MySQL-Prozesse:</p>
 <table class="tableinborder" border="0" cellpadding="0" cellspacing="1" width="402">
   <tr>
        <td align="left" style="padding: 0px; background-image: url('<?=$GLOBALS["PIC_BASE_URL"]?>loadbarbg.gif'); background-repeat: repeat-x">

<?php
    $_stats = _server_stats('mysqld');

    $percent =& $_stats['cpu_perc'];

    if ($percent <= 70) $pic = "loadbargreen.gif";
    elseif ($percent <= 90) $pic = "loadbaryellow.gif";
    else $pic = "loadbarred.gif";
    $width = $percent * 4;
    print("<img height=15 width=$width src=\"".$GLOBALS["PIC_BASE_URL"].$pic."\" alt='$percent%'>");
?>
      </td>
    </tr>
    <tr>

        </td>
    </tr>
  </table>
  <p>SQL Auslastung (Durchschnittswerte): <?=$_stats['cpu_perc']?>% CPU usage, <?=mksize(1024*($_stats['mem_size']))?> memory used </p>
</center>
</td></tr></table>
<br>

  <table cellpadding="4" cellspacing="1" border="0" style="width:75%" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="10" width="100%"><span class="normalfont"><center><b> Webserver Prozesse </b></center></span></td>
 </tr><tr><td width="100%" class="tablea">
<center>
<?php

/*
  get data from /proc system
  LINE 1, UPTIME: DAY:HOUR:MINUTE
  LINE 2, LOAD: USER, NICE, SYSTEM, IDLE
 */

define('T_DAY', 86400);
define('T_HOUR', 3600);
define('T_MINUTE', 60);


define('USE_OPEN', false); //put to false to make shell calls and avoid base dirs, else true is for opening files

/* start -- uptime */

if (USE_OPEN)
    $data = file("/proc/uptime");
else
{
    ob_start();
    system("cat /proc/uptime");
    $data = ob_get_contents();
    ob_end_clean();

    $data = explode("\n", $data);
}

$data = $data[0];
$data = explode(" ", $data);
$uptime = $data[0];

$day = floor($uptime / T_DAY);
$uptime = $uptime - ($day * T_DAY);

$hour = floor($uptime / T_HOUR);
$uptime = $uptime - ($hour * T_HOUR);

$minute = floor($uptime / T_MINUTE);
// print sprintf("%02d:%02d:%02d\n", $day, $hour, $minute);

/* end -- uptime */


/* start -- load */
if (USE_OPEN)
    $data = file("/proc/stat");
else
{
    ob_start();
    system("cat /proc/stat");
    $data = ob_get_contents();
    ob_end_clean();

    $data = explode("\n", $data);
}

$data = $data[0];
$data = explode(" ", $data);

$user = $data[2];
$nice = $data[3];
$system = $data[4];
$idle = $data[5];
$total = $user + $nice + $system + $idle;

$user = ($user * 100.0)/$total;
$nice = ($nice * 100.0)/$total;
$system = ($system * 100.0)/$total;
$idle  = ($idle  * 100.0)/$total;

/* end -- load */

?>
 <table class="tableinborder" border="0" cellpadding="0" cellspacing="1" width="402">
   <tr><td style="padding: 0px; background-image: url('<?=$GLOBALS["PIC_BASE_URL"]?>loadbarbg.gif'); background-repeat: repeat-x"><div style="padding:0px;width:300px;height:15px;"><div style="border:none;width:<?=300 * $user / 100?>px;height:15px;background-image:url(<?=$GLOBALS["PIC_BASE_URL"]?>ryg-verlauf.jpg);background-repeat:no-repeat;"></div></div></td>
<?php
    print sprintf("<td class=tableb width=90>User: %.3f</td></tr>", $user);
?>
    <tr><td style="padding: 0px; background-image: url('<?=$GLOBALS["PIC_BASE_URL"]?>loadbarbg.gif'); background-repeat: repeat-x"><div style="padding:0px;width:300px;height:15px;"><div style="border:none;width:<?=300 * $system / 100?>px;height:15px;background-image:url(<?=$GLOBALS["PIC_BASE_URL"]?>ryg-verlauf.jpg);background-repeat:no-repeat;"></div></div></td>
<?php
    print sprintf("<td class=tableb width=90>System: %.3f</td></tr>", $system);
    $total = $system + $user + $nice;
?>
    <tr><td style="padding: 0px; background-image: url('<?=$GLOBALS["PIC_BASE_URL"]?>loadbarbg.gif'); background-repeat: repeat-x"><div style="padding:0px;width:300px;height:15px;"><div style="border:none;width:<?=300 * $total / 100?>px;height:15px;background-image:url(<?=$GLOBALS["PIC_BASE_URL"]?>ryg-verlauf.jpg);background-repeat:no-repeat;"></div></div></td>
<?php
    print sprintf("<td class=tableb width=90>Total: %.3f</td></tr>", $total);
    $apache = min(100, round(exec('ps ax | grep -c apache2') / 150 * 100));
?>
    <tr><td style="padding: 0px; background-image: url('<?=$GLOBALS["PIC_BASE_URL"]?>loadbarbg.gif'); background-repeat: repeat-x"><div style="padding:0px;width:300px;height:15px;"><div style="border:none;width:<?=300 * $apache / 100?>px;height:15px;background-image:url(<?=$GLOBALS["PIC_BASE_URL"]?>ryg-verlauf.jpg);background-repeat:no-repeat;"></div></div></td>
<?php
    print sprintf("<td class=tableb width=90>Apache: %.3f</td></tr>", $apache);
?>
      </td>
    </tr>
</center>
</tr><tr></td></tr></table><br></p>
</table>
<br>

<table cellpadding="4" cellspacing="1" border="0" style="width:75%" class="tableinborder">
 <tr class="tabletitle" width="80%">
  <td colspan="10" width="80%"><span class="normalfont"><center><b> Statistik </b></center></span></td>
 </tr><tr><td width="80%" class="tablea">
 <b><center>

Die letzten 24 Stunden waren <?=$totalonline24?> Mitglieder online

<p>

<?
$ut = linuxUptime();
// If you would like to show the seconds as well just add [ , $ut[3] seconds ] after minutes.
echo "Letzter Server Neustart vor: $ut[0] Tage, $ut[1] Stunden, $ut[2] Minuten";
?>

<p>

 Diese Seite wurde in <?
    $now = gettimeofday();
    $runtime = ($now["sec"] - $RUNTIME_START["sec"]) + ($now["usec"] - $RUNTIME_START["usec"]) / 1000000;
    echo $runtime;

  ?>
  Sekunden erstellt.</p>

</center></b>
</tr></td></table>
 </center>


<?
// stdfoot();

hit_end();
?>