2012-06-04 16:58:40 +02:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
|
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
James Rose <james.o.rose@gmail.com>
|
|
|
|
|
*/
|
|
|
|
|
include "root.php";
|
2013-07-06 08:03:27 +02:00
|
|
|
require_once "resources/require.php";
|
2013-07-06 07:50:55 +02:00
|
|
|
require_once "resources/check_auth.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
if (permission_exists('log_view')) {
|
|
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-24 23:06:11 +01:00
|
|
|
//add multi-lingual support
|
2015-01-18 11:06:08 +01:00
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
2012-11-24 23:06:11 +01:00
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//define variables
|
|
|
|
|
$c = 0;
|
|
|
|
|
$row_style["0"] = "row_style0";
|
|
|
|
|
$row_style["1"] = "row_style1";
|
|
|
|
|
|
2012-07-18 19:00:59 +02:00
|
|
|
//set a default line number value (off)
|
2016-12-20 21:26:42 +01:00
|
|
|
if (!isset($_POST['ln']) || $_POST['ln'] == '') { $_POST['ln'] = 0; }
|
2012-07-18 19:00:59 +02:00
|
|
|
|
|
|
|
|
//set a default ordinal (descending)
|
2016-12-20 21:26:42 +01:00
|
|
|
if (!isset($_POST['ord']) || $_POST['ord'] == '') { $_POST['ord'] = "asc"; }
|
2012-07-18 19:00:59 +02:00
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//set a default file size
|
2016-12-20 21:26:42 +01:00
|
|
|
if (!isset($_POST['fs']) || strlen($_POST['fs']) == 0) { $_POST['fs'] = "32"; }
|
|
|
|
|
|
|
|
|
|
//set a default filter
|
|
|
|
|
if (!isset($_POST['filter'])) { $_POST['filter'] = ""; }
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
if (permission_exists('log_download')) {
|
2016-12-20 21:26:42 +01:00
|
|
|
if (isset($_GET['a']) && $_GET['a'] == "download") {
|
|
|
|
|
if (isset($_GET['t']) && $_GET['t'] == "logs") {
|
2012-06-04 16:58:40 +02:00
|
|
|
$tmp = $_SESSION['switch']['log']['dir'].'/';
|
|
|
|
|
$filename = 'freeswitch.log';
|
|
|
|
|
}
|
|
|
|
|
session_cache_limiter('public');
|
|
|
|
|
$fd = fopen($tmp.$filename, "rb");
|
|
|
|
|
header("Content-Type: binary/octet-stream");
|
|
|
|
|
header("Content-Length: " . filesize($tmp.$filename));
|
|
|
|
|
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
|
|
|
|
fpassthru($fd);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/header.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
|
|
|
|
|
echo " <tr>\n";
|
2016-04-13 21:23:07 +02:00
|
|
|
echo " <td align='left' valign='top' width='100%' style='padding-right: 15px;' nowrap>\n";
|
2012-11-24 23:06:11 +01:00
|
|
|
echo " <b>".$text['label-log-viewer']."</b><br />\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo " </td>\n";
|
2012-07-18 19:00:59 +02:00
|
|
|
echo " <td align='right' valign='middle' nowrap>\n";
|
2016-04-13 21:23:07 +02:00
|
|
|
echo " <form action='log_viewer.php' method='POST'>\n";
|
|
|
|
|
echo " ".$text['label-filter']." <input type='text' name='filter' class='formfld' style='width: 150px; text-align: center; margin-right: 20px;' value=\"".$_POST['filter']."\" onclick='this.select();'>";
|
|
|
|
|
echo " <label style='margin-right: 20px; margin-top: 4px;'><input type='checkbox' name='ln' id='ln' value='1' ".(($_POST['ln'] == 1) ? 'checked' : null)."> ".$text['label-line-num']."</label>";
|
|
|
|
|
echo " <label style='margin-right: 20px; margin-top: 4px;'><input type='checkbox' name='ord' id='ord' value='desc' ".(($_POST['ord'] == 'desc') ? 'checked' : null)."> ".$text['label-sort']."</label>";
|
|
|
|
|
echo " Display <input type='text' class='formfld' style='width: 50px; text-align: center;' name='fs' value=\"".$_POST['fs']."\" onclick='this.select();'> ".$text['label-kb']."";
|
|
|
|
|
echo " <input type='submit' class='btn' style='margin-left: 20px;' name='submit' value=\"".$text['button-reload']."\">";
|
2012-06-04 16:58:40 +02:00
|
|
|
if (permission_exists('log_download')) {
|
2014-02-26 07:07:13 +01:00
|
|
|
echo " <input type='button' class='btn' value='".$text['button-download']."' onclick=\"document.location.href='log_viewer.php?a=download&t=logs';\" />\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2014-02-26 07:07:13 +01:00
|
|
|
echo " </form>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
2014-07-30 00:39:30 +02:00
|
|
|
echo " <tr><td colspan='2'> </td></tr>";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo " <tr>\n";
|
2014-07-30 01:04:36 +02:00
|
|
|
echo " <td colspan='2' style='background-color: #1c1c1c; padding: 8px; text-align: left;'>";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
if (permission_exists('log_view')) {
|
|
|
|
|
|
|
|
|
|
$MAXEL = 3; //pattern2, pattern3|color2, color3 etc...
|
|
|
|
|
|
|
|
|
|
$user_filesize = '0';
|
2014-07-30 01:04:36 +02:00
|
|
|
$default_color = '#fff';
|
2012-06-04 16:58:40 +02:00
|
|
|
$default_type = 'normal';
|
|
|
|
|
$default_font = 'monospace';
|
|
|
|
|
$default_fsize = '512000';
|
|
|
|
|
$log_file = $_SESSION['switch']['log']['dir']."/freeswitch.log";
|
|
|
|
|
|
|
|
|
|
//put the color matches here...
|
|
|
|
|
$arr_filter[0]['pattern'] = '[NOTICE]';
|
|
|
|
|
$arr_filter[0]['color'] = 'cyan';
|
|
|
|
|
$arr_filter[0]['type'] = 'normal';
|
|
|
|
|
$arr_filter[0]['font'] = 'monospace';
|
|
|
|
|
|
|
|
|
|
$arr_filter[1]['pattern'] = '[INFO]';
|
|
|
|
|
$arr_filter[1]['color'] = 'chartreuse';
|
|
|
|
|
$arr_filter[1]['type'] = 'normal';
|
|
|
|
|
$arr_filter[1]['font'] = 'monospace';
|
|
|
|
|
|
|
|
|
|
$arr_filter[2]['pattern'] = 'Dialplan:';
|
|
|
|
|
$arr_filter[2]['color'] = 'burlywood';
|
|
|
|
|
$arr_filter[2]['type'] = 'normal';
|
|
|
|
|
$arr_filter[2]['font'] = 'monospace';
|
|
|
|
|
$arr_filter[2]['pattern2'] = 'Regex (PASS)';
|
|
|
|
|
$arr_filter[2]['color2'] = 'chartreuse';
|
|
|
|
|
$arr_filter[2]['pattern3'] = 'Regex (FAIL)';
|
|
|
|
|
$arr_filter[2]['color3'] = 'red';
|
|
|
|
|
|
|
|
|
|
$arr_filter[3]['pattern'] = '[WARNING]';
|
|
|
|
|
$arr_filter[3]['color'] = 'fuchsia';
|
|
|
|
|
$arr_filter[3]['type'] = 'normal';
|
|
|
|
|
$arr_filter[3]['font'] = 'monospace';
|
|
|
|
|
|
|
|
|
|
$arr_filter[4]['pattern'] = '[ERR]';
|
|
|
|
|
$arr_filter[4]['color'] = 'red';
|
|
|
|
|
$arr_filter[4]['type'] = 'bold';
|
|
|
|
|
$arr_filter[4]['font'] = 'monospace';
|
|
|
|
|
|
|
|
|
|
$arr_filter[5]['pattern'] = '[DEBUG]';
|
|
|
|
|
$arr_filter[5]['color'] = 'gold';
|
|
|
|
|
$arr_filter[5]['type'] = 'bold';
|
|
|
|
|
$arr_filter[5]['font'] = 'monospace';
|
|
|
|
|
|
|
|
|
|
$file_size = filesize($log_file);
|
|
|
|
|
|
2012-07-18 19:00:59 +02:00
|
|
|
/*
|
|
|
|
|
// removed: duplicate of above
|
2012-06-04 16:58:40 +02:00
|
|
|
if (isset($_POST['submit'])) {
|
|
|
|
|
if (strlen($_POST['fs']) == 0) { $_POST['fs'] = "32"; }
|
|
|
|
|
}
|
2012-07-18 19:00:59 +02:00
|
|
|
*/
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2014-07-30 01:04:36 +02:00
|
|
|
echo " <table cellpadding='0' cellspacing='0' border='0' width='100%'>";
|
|
|
|
|
echo " <tr>";
|
2012-07-18 19:00:59 +02:00
|
|
|
$user_filesize = '32768';
|
2012-06-04 16:58:40 +02:00
|
|
|
if (isset($_POST['submit'])) {
|
|
|
|
|
if (!is_numeric($_POST['fs'])){
|
|
|
|
|
//should generate log warning here...
|
2012-09-14 21:02:55 +02:00
|
|
|
$user_filesize=1024 * 32;
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2012-07-18 19:00:59 +02:00
|
|
|
$user_filesize = $_POST['fs'] * 1024;
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2013-07-05 05:48:40 +02:00
|
|
|
if (strlen($_REQUEST['filter']) > 0){
|
|
|
|
|
$uuid_filter = $_REQUEST['filter'];
|
2016-04-13 21:23:07 +02:00
|
|
|
echo " <td style='text-align: left; color: #FFFFFF;'>".$text['description-filter']." ".$uuid_filter."</td>";
|
2013-07-05 05:48:40 +02:00
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//echo "Log File Size: " . $file_size . " bytes. <br />";
|
2016-04-13 21:23:07 +02:00
|
|
|
echo " <td style='text-align: right;color: #FFFFFF;'>".$text['label-displaying']." ".number_format($user_filesize,0,'.',',')." of ".number_format($file_size,0,'.',',')." ".$text['label-bytes'].". </td>";
|
2014-07-30 01:04:36 +02:00
|
|
|
echo " </tr>";
|
|
|
|
|
echo " </table>";
|
|
|
|
|
echo " <hr size='1' style='color: #fff;'>";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2013-07-05 05:48:40 +02:00
|
|
|
$file = fopen($log_file, "r") or exit($text['error-open-file']);
|
2012-06-04 16:58:40 +02:00
|
|
|
|
|
|
|
|
//set pointer in file
|
|
|
|
|
if ($user_filesize >= '0') {
|
|
|
|
|
if ($user_filesize == '0'){
|
|
|
|
|
$user_filesize = $default_fsize;
|
|
|
|
|
}
|
|
|
|
|
if ( $file_size >= $user_filesize ){
|
|
|
|
|
//set an offset on fopen
|
|
|
|
|
$bytecount=$file_size-$user_filesize;
|
|
|
|
|
fseek($file, $bytecount);
|
|
|
|
|
//echo "opening at " . $bytecount . " bytes<br>";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if ( $file_size >= $default_fsize ){
|
|
|
|
|
//set an offset on fopen
|
|
|
|
|
$bytecount=$file_size-$default_fsize;
|
|
|
|
|
fseek($file, $bytecount);
|
2012-11-24 23:06:11 +01:00
|
|
|
echo $text['label-open-at']." " . $bytecount . " ".$text['label-bytes']."<br>";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
//open the file
|
|
|
|
|
$bytecount='0';
|
|
|
|
|
fseek($file, 0);
|
2012-11-24 23:06:11 +01:00
|
|
|
echo "<br>".$text['label-open-file']."<br>";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if ( $file_size >= $default_fsize ){
|
|
|
|
|
//set an offset on fopen
|
|
|
|
|
$bytecount=$file_size-$default_fsize;
|
|
|
|
|
fseek($file, $bytecount);
|
2012-11-24 23:06:11 +01:00
|
|
|
echo $text['label-open-at']." " . $bytecount . " ".$text['label-bytes']."<br>";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
//open the file
|
|
|
|
|
$bytecount='0';
|
|
|
|
|
fseek($file, 0);
|
2012-11-24 23:06:11 +01:00
|
|
|
echo "<br>".$text['label-open-file']."<br>";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//start processing
|
2016-12-20 21:26:42 +01:00
|
|
|
$byte_count = 0;
|
2012-06-04 16:58:40 +02:00
|
|
|
while(!feof($file))
|
|
|
|
|
{
|
|
|
|
|
$log_line = fgets($file);
|
|
|
|
|
$byte_count++;
|
|
|
|
|
$noprint = false;
|
|
|
|
|
|
2013-07-05 05:48:40 +02:00
|
|
|
$skip_line = false;
|
|
|
|
|
if (!empty($uuid_filter) ) {
|
|
|
|
|
$uuid_match = strpos($log_line, $uuid_filter);
|
|
|
|
|
if ($uuid_match === false) {
|
|
|
|
|
$skip_line = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$skip_line = false;
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-07-18 19:00:59 +02:00
|
|
|
|
2013-07-05 05:48:40 +02:00
|
|
|
if ($skip_line === false) {
|
|
|
|
|
foreach ($arr_filter as $v1) {
|
|
|
|
|
$pos = strpos($log_line, $v1['pattern']);
|
|
|
|
|
//echo "</br> POS is: '$pos'</br>";
|
|
|
|
|
if ($pos !== false){
|
|
|
|
|
//color adjustments on words in log line
|
|
|
|
|
for ($i=2; $i<=$MAXEL; $i++){
|
2014-07-30 00:39:30 +02:00
|
|
|
if (isset ($v1["pattern".$i])) {
|
|
|
|
|
$log_line = str_replace($v1["pattern".$i], "<span style='color: ".$v1["color".$i].";'>".$v1["pattern".$i]."</span>", $log_line);
|
2013-07-05 05:48:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
2016-12-20 21:26:42 +01:00
|
|
|
$ary_output[] = "<span style='color: ".$v1['color']."; font-family: ".$v1['font'].";'>".$log_line."</span><br>";
|
2013-07-05 05:48:40 +02:00
|
|
|
$noprint = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-18 19:00:59 +02:00
|
|
|
|
2013-07-05 05:48:40 +02:00
|
|
|
if ($noprint !== true){
|
2014-07-30 00:39:30 +02:00
|
|
|
$ary_output[] = "<span style='color: ".$default_color."; font-family: ".$default_font.";'>".htmlentities($log_line)."</span><br>";
|
2013-07-05 05:48:40 +02:00
|
|
|
}
|
2012-07-18 19:00:59 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// output according to ordinal selected
|
|
|
|
|
if ($_POST['ord'] == 'desc') {
|
|
|
|
|
$ary_output = array_reverse($ary_output);
|
|
|
|
|
$adj_index = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$adj_index = 1;
|
|
|
|
|
}
|
|
|
|
|
foreach ($ary_output as $index => $line) {
|
2016-12-20 21:26:42 +01:00
|
|
|
$line_num = "";
|
2014-07-30 00:39:30 +02:00
|
|
|
if ($line != "<span style='color: #fff; font-family: monospace;'></span><br>") {
|
2012-07-18 19:00:59 +02:00
|
|
|
if ($_POST['ln']) {
|
|
|
|
|
$line_num = "<span style='font-family: courier; color: #aaa; font-size: 10px;'>".($index + $adj_index)." </span>";
|
|
|
|
|
}
|
|
|
|
|
echo $line_num." ".$line;
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose($file);
|
2014-07-30 01:04:36 +02:00
|
|
|
|
|
|
|
|
echo " </div>";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2014-07-30 00:39:30 +02:00
|
|
|
echo " </td>";
|
|
|
|
|
echo " </tr>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
echo "</table>\n";
|
|
|
|
|
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/footer.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
?>
|