function exec_ogp_module() { global $db; $isAdmin = $db->isAdmin($_SESSION['user_id']); require_once 'includes/lib_remote.php'; if (isset($_GET['home_id']) and $_GET['home_id'] != "total") { if ($isAdmin) { $game_home = $db->getGameHome($_GET['home_id']); } else { $game_home = $db->getUserGameHome($_SESSION['user_id'], $_GET['home_id']); } if (!$game_home and !$isAdmin) { return; } $remote = new OGPRemoteLibrary($game_home['agent_ip'], $game_home['agent_port'], $game_home['encryption_key']); $r = $remote->rfile_exists($game_home['home_path']); if ($r == 1) { $du = $remote->exec("du -sb " . $game_home['home_path']); list($size, $path) = explode("\t", $du); if (isset($_GET['bytes'])) { echo $size; } else { echo numbersFormatting($size); } } else { echo get_lang("does_not_exist_yet"); } } elseif ($isAdmin) { $game_homes = $db->getGameHomes(); $total_size = 0; foreach ($game_homes as $game_home) { $remote = new OGPRemoteLibrary($game_home['agent_ip'], $game_home['agent_port'], $game_home['encryption_key']); $r = $remote->rfile_exists($game_home['home_path']); if ($r == 1) { $du = $remote->exec("du -sb " . $game_home['home_path']); list($kilobytes, $path) = explode("\t", $du); $kilobytes = intval(preg_replace('/\\D/', '', $kilobytes)); $total_size += $kilobytes; } } echo numbersFormatting($total_size); } }
require_once 'includes/lib_remote.php'; global $db; $rhost_id = $_GET['remote_server_id']; $remote_server = $db->getRemoteServer($rhost_id); $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key']); $mem = $remote->exec('cat /proc/meminfo'); } else { $mem = file_get_contents("/proc/meminfo"); } if (preg_match('/MemTotal\\:\\s+(\\d+) kB/', $mem, $matches)) { $total = $matches[1]; } if (preg_match('/Buffers\\:\\s+(\\d+) kB/', $mem, $matches)) { $buffers = $matches[1]; } if (preg_match('/Cached\\:\\s+(\\d+) kB/', $mem, $matches)) { $cached = $matches[1]; } unset($matches); if (preg_match('/MemFree\\:\\s+(\\d+) kB/', $mem, $matches)) { $free = $matches[1]; } $Used = $total - $free - @$cached - @$buffers; // Added at(@) to avoid errors on some virtual machines that are not using pagefile or using the host OS pagefile. $percentage_used = 100 * $Used / $total; $ramusage = numbersFormatting($Used * 1024) . " of " . numbersFormatting($total * 1024); $rampercent = round($percentage_used, "2"); } else { $ramusage = "Unable to Detect"; $rampercent = "100"; }
$disk_info = $remote->exec('df -lP|grep "^.:\\s"|awk \'{size+=$2}{used+=$3}{avail+=$4} END {print size, used, avail}\''); } else { $disk_info = $remote->exec('df -lP|grep "^/dev/.*"|awk \'{size+=$2}{used+=$3}{avail+=$4} END {print size, used, avail}\''); } list($insgesamtKB, $belegtKB, $freiKB) = explode(" ", $disk_info); $frei = 1024 * $freiKB; $belegt = 1024 * $belegtKB; $insgesamt = 1024 * $insgesamtKB; } else { if ($os == "windows") { $insgesamt = disk_total_space("./"); $frei = disk_free_space("./"); $belegt = $insgesamt - $frei; } else { if ($cygwin) { $disk_info = shell_exec('df -lP|grep "^.:\\s"|awk \'{size+=$2}{used+=$3}{avail+=$4} END {print size, used, avail}\''); } else { $disk_info = shell_exec('df -lP|grep "^/dev/.*"|awk \'{size+=$2}{used+=$3}{avail+=$4} END {print size, used, avail}\''); } list($insgesamtKB, $belegtKB, $freiKB) = explode(" ", $disk_info); $frei = 1024 * $freiKB; $belegt = 1024 * $belegtKB; $insgesamt = 1024 * $insgesamtKB; } } $prozent_belegt = 100 * $belegt / $insgesamt; $diskspace = numbersFormatting($insgesamt); $diskinuse = numbersFormatting($belegt) . ' (' . round($prozent_belegt, "2") . '%)'; $hddbarusage = round($prozent_belegt, "2"); $hddfreespace = numbersFormatting($frei);