function show_all($flags_) { $display = $_SESSION['service']->log_preview(); if (is_null($display)) { $display = array(); } if (array_key_exists('servers', $display)) { $display2 = $display['servers']; unset($display['servers']); } page_header(); echo '<h1>' . _('Logs') . '</h1>'; echo '<div>'; echo '<div class="section">'; echo '<h1>' . _('Session Manager') . '</h1>'; foreach ($display as $name => $lines) { if ($name == 'servers') { continue; } echo '<h3>' . $name; echo ' <a href="?show=1&where=sm&name=' . $name . '"><img src="media/image/view.png" width="22" height="22" alt="view" onmouseover="showInfoBulle(\'' . _('View full log file online') . '\'); return false;" onmouseout="hideInfoBulle(); return false;" /></a>'; echo ' <a href="?download=1&where=sm&name=' . $name . '"><img src="media/image/download.png" width="22" height="22" alt="download" onmouseover="showInfoBulle(\'' . _('Download full log file') . '\'); return false;" onmouseout="hideInfoBulle(); return false;" /></a>'; echo '</h3>'; echo '<div style="border: 1px solid #ccc; background: #fff; padding: 5px; text-align: left;" class="section">'; foreach ($lines as $line) { $type = parse_linux($line); echo '<span class="' . $type . '">' . trim($line) . '</span>' . "<br />\n"; } echo '</div>'; } echo '</div>'; echo '<div class="section">'; echo '<h1>' . _('Slave Servers') . '</h1>'; foreach ($display2 as $server_id => $logs) { $server = $_SESSION['service']->server_info($server_id); if (is_null($server)) { continue; } echo '<h2><img src="media/image/server-' . $server->stringType() . '.png" alt="' . $server->stringType() . '" title="' . $server->stringType() . '" /> <a href="servers.php?action=manage&id=' . $server_id . '">' . $server->getDisplayName() . '</a></h2>'; echo '<div class="section">'; echo '<h4>' . _('Log'); echo ' <a href="?show=1&where=aps&server=' . $server_id . '"><img src="media/image/view.png" width="22" height="22" alt="view" onmouseover="showInfoBulle(\'' . _('View full log file online') . '\'); return false;" onmouseout="hideInfoBulle(); return false;" /></a>'; echo ' <a href="?download=1&where=aps&server=' . $server_id . '"><img src="media/image/download.png" width="22" height="22" alt="download" onmouseover="showInfoBulle(\'' . _('Download full log file') . '\'); return false;" onmouseout="hideInfoBulle(); return false;" /></a>'; echo '</h4>'; echo '<div style="border: 1px solid #ccc; background: #fff; padding: 5px; text-align: left;" class="section">'; foreach ($logs as $line) { $type = parse_ovdserver($line); echo '<span class="' . $type . '">' . trim($line) . '</span>' . "<br />\n"; } echo '</div>'; echo '</div>'; } echo '</div>'; echo '</div>'; page_footer(); die; }
function get_lines_from_file($file_, $nb_lines, $allowed_types) { // Add false to the array to get mismatch log lines // $allowed_types[]= false; $lines = array(); $obj = new FileTailer($file_); $qty = 0; while ($obj->hasLines()) { $ret = $obj->tail(1); $line = $ret[0]; $type = parse_linux($line); if (!in_array($type, $allowed_types)) { continue; } array_unshift($lines, '<span class="' . $type . '">' . trim($line) . '</span>'); $qty++; if ($qty >= $nb_lines) { break; } } return $lines; }