Use is_array before foreach
This commit is contained in:
parent
0fce8ac1a5
commit
be257eeb03
|
|
@ -66,12 +66,14 @@
|
|||
//set default default log file
|
||||
if (isset($_POST['log_file'])) {
|
||||
$approved_files = glob($_SESSION['switch']['log']['dir'].'/freeswitch.log*');
|
||||
if (is_array($approved_files)) {
|
||||
foreach($approved_files as $approved_file) {
|
||||
if ($approved_file == $_SESSION['switch']['log']['dir'].'/'.$_POST['log_file']) {
|
||||
$log_file = $approved_file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$log_file = $_SESSION['switch']['log']['dir'].'/freeswitch.log';
|
||||
}
|
||||
|
|
@ -81,11 +83,13 @@
|
|||
if (isset($_GET['n'])) {
|
||||
if (isset($filename)) { unset($filename); }
|
||||
$approved_files = glob($_SESSION['switch']['log']['dir'].'/freeswitch.log*');
|
||||
if (is_array($approved_files)) {
|
||||
foreach($approved_files as $approved_file) {
|
||||
if ($approved_file == $_SESSION['switch']['log']['dir'].'/'.$_GET['n']) {
|
||||
$filename = $approved_file;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($filename) && file_exists($filename)) {
|
||||
session_cache_limiter('public');
|
||||
$fd = fopen($filename, "rb");
|
||||
|
|
@ -98,6 +102,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
//get the file size
|
||||
if (file_exists($log_file)) {
|
||||
$file_size = filesize($log_file);
|
||||
}
|
||||
|
||||
//read the log
|
||||
if (file_exists($log_file)) {
|
||||
$file_handle = fopen($log_file, "r");
|
||||
}
|
||||
|
||||
//include the header
|
||||
$document['title'] = $text['title-log_viewer'];
|
||||
require_once "resources/header.php";
|
||||
|
|
@ -109,9 +123,11 @@
|
|||
echo "<form name='frm' id='frm' class='inline' method='post'>\n";
|
||||
echo " ".$text['label-log_file']." <select name='log_file' class='formfld' style='width: 150px; margin-right: 20px;'>";
|
||||
$files = glob($_SESSION['switch']['log']['dir'].'/freeswitch.log*');
|
||||
foreach($files as $file) {
|
||||
$selected = ($file == $log_file) ? "selected='selected'" : "";
|
||||
echo " <option value='".basename($file)."'".$selected.">".basename($file)."</option>";
|
||||
if (is_array($files)) {
|
||||
foreach($files as $file_name) {
|
||||
$selected = ($file_name == $log_file) ? "selected='selected'" : "";
|
||||
echo " <option value='".basename($file_name)."'".$selected.">".basename($file_name)."</option>";
|
||||
}
|
||||
}
|
||||
echo " </select>\n";
|
||||
echo $text['label-filter']." <input type='text' name='filter' class='formfld' style='width: 150px; text-align: center; margin-right: 20px;' value=\"".escape($_POST['filter'])."\" onclick='this.select();'>";
|
||||
|
|
@ -181,8 +197,6 @@
|
|||
$array_filter[6]['type'] = 'bold';
|
||||
$array_filter[6]['font'] = 'monospace';
|
||||
|
||||
$file_size = filesize($log_file);
|
||||
|
||||
/*
|
||||
// removed: duplicate of above
|
||||
if (isset($_POST['submit'])) {
|
||||
|
|
@ -208,8 +222,6 @@
|
|||
echo " ".$text['label-displaying']." ".number_format($user_file_size,0,'.',',')." of ".number_format($file_size,0,'.',',')." ".$text['label-bytes'].".";
|
||||
echo "</div>";
|
||||
|
||||
$file = fopen($log_file, "r") or exit($text['error-open_file']);
|
||||
|
||||
//set pointer in file
|
||||
if ($user_file_size >= '0') {
|
||||
if ($user_file_size == '0') {
|
||||
|
|
@ -231,7 +243,9 @@
|
|||
else {
|
||||
//open the file
|
||||
$byte_count ='0';
|
||||
fseek($file, 0);
|
||||
if ($file_handle) {
|
||||
fseek($file_handle, 0);
|
||||
}
|
||||
echo "<br>".$text['label-open_file']."<br>";
|
||||
}
|
||||
}
|
||||
|
|
@ -253,8 +267,9 @@
|
|||
|
||||
//start processing
|
||||
$byte_count = 0;
|
||||
while(!feof($file)) {
|
||||
$log_line = escape(fgets($file));
|
||||
if ($file_handle) {
|
||||
while(!feof($file_handle)) {
|
||||
$log_line = escape(fgets($file_handle));
|
||||
$byte_count++;
|
||||
$noprint = false;
|
||||
|
||||
|
|
@ -290,6 +305,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// output according to ordinal selected
|
||||
if ($_POST['sort'] == 'desc') {
|
||||
|
|
@ -299,6 +315,7 @@
|
|||
else {
|
||||
$adj_index = 1;
|
||||
}
|
||||
if (is_array($array_output)) {
|
||||
foreach ($array_output as $index => $line) {
|
||||
$line_num = "";
|
||||
if ($line != "<span style='color: #fff; font-family: monospace;'></span><br>") {
|
||||
|
|
@ -308,7 +325,8 @@
|
|||
echo $line_num." ".$line;
|
||||
}
|
||||
}
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
echo " </div>";
|
||||
}
|
||||
echo " </td>";
|
||||
|
|
@ -318,4 +336,9 @@
|
|||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
//close the file
|
||||
if ($file_handle) {
|
||||
fclose($file_handle);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue