help - show data in html from txt file

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 12 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
grantboy1uk
Posts: 91
Last visit: Wed Jul 08, 2015 3:50 am

help - show data in html from txt file

Post by grantboy1uk »

Hi

I found some code on the net which uses php, js to pull data from txt and html files - it then displays these on a html webpage.

Can someone advise how you would modify it to diplay services which should be running but are not. I've created the powershell scripts whcih output to a txt file (these show which services are running).

I have attached the txt file, and my ps script. - maybe I shold output as different format but I'll to hear your feedback.
uploads/40463/UK_RMS10.0_A_Log.txt
uploads/40463/Mon_RMS10a.ps1.txt
Heres the code I found.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Centric Server Logfiles</title>
<meta name="copyright" content=""/>
<meta name="keywords" content=""/>
<meta name="description" content=""/>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>
<meta http-equiv="content-style-type" content="text/css"/>
<meta http-equiv="expires" content="0"/>

<style type="text/css">
h1 { font-size: 24px; margin-bottom: 4px;}
h2 { font-size: 18px; margin-bottom: 2px;}
table { background: #ff0; border: 3px solid black; padding: 0px;
empty-cells: hide }
tr.top { background: red }
td { border: 1px solid black;
background: white;
margin: 0px 0 0 0;
padding: 0 2px 0 2px;
font-size: 12px; }
p {margin: 3px;}
</style>


<script language="javascript">
function getItem(id)
{
var itm = false;
if(document.getElementById)
itm = document.getElementById(id);
else if(document.all)
itm = document.all[id];
else if(document.layers)
itm = document.layers[id];

return itm;
}

function toggleItem(id)
{
itm = getItem(id);

if(!itm)
return false;

if(itm.style.display == 'none')
itm.style.display = '';
else
itm.style.display = 'none';

return false;
}
</script>

</head>
<body>

<h1>Centric Server Logs</h1>
<p>Note: If Log is not listed, it has no Error or Warning entries. <i>Logs are updated manually</i> since these servers are in the DMZ.</p>
<?php
$arr = array("SERVER1", "SERVER2", "SERVER3" );

foreach ($arr as $value) {

echo "<h2>$value</h2>" . PHP_EOL;
$filename="C:inetpubwwwrootserverlogs".$value."-applog.html";
$output="";
$errors="";
$file = fopen($filename, "r");
while(!feof($file)) {
$output = $output . fgets($file, 4096);
}
fclose ($file);
$errors=substr_count($output, '<tr>');
if ($errors>0) {$errors = $errors-1;
echo "<p><a href="#" onclick="toggleItem('$value-applog')">$value Application Log</a> (Items: $errors)</p>" . PHP_EOL;
include("C:inetpubwwwrootserverlogs".$value."-applog.html");
}
$filename="C:inetpubwwwrootserverlogs".$value."-syslog.html";
$output="";
$errors="";
$file = fopen($filename, "r");
while(!feof($file)) {
$output = $output . fgets($file, 4096);
}
fclose ($file);
$errors=substr_count($output, '<tr>');
if ($errors>0) {$errors = $errors-1;
echo "<p><a href="#" onclick="toggleItem('$value-syslog')">$value System Log</a> (Items: $errors)</p>" . PHP_EOL;
include("C:inetpubwwwrootserverlogs".$value."-syslog.html");
echo " " . PHP_EOL;
}
}
?>


</body>
</html>
User avatar
grantboy1uk
Posts: 91
Last visit: Wed Jul 08, 2015 3:50 am

help - show data in html from txt file

Post by grantboy1uk »

Hi

I found some code on the net which uses php, js to pull data from txt and html files - it then displays these on a html webpage.

Can someone advise how you would modify it to diplay services which should be running but are not. I've created the powershell scripts whcih output to a txt file (these show which services are running).

I have attached the txt file, and my ps script. - maybe I shold output as different format but I'll to hear your feedback.
uploads/40463/UK_RMS10.0_A_Log.txt
uploads/40463/Mon_RMS10a.ps1.txt
Heres the code I found.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Centric Server Logfiles</title>
<meta name="copyright" content=""/>
<meta name="keywords" content=""/>
<meta name="description" content=""/>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/>
<meta http-equiv="content-style-type" content="text/css"/>
<meta http-equiv="expires" content="0"/>

<style type="text/css">
h1 { font-size: 24px; margin-bottom: 4px;}
h2 { font-size: 18px; margin-bottom: 2px;}
table { background: #ff0; border: 3px solid black; padding: 0px;
empty-cells: hide }
tr.top { background: red }
td { border: 1px solid black;
background: white;
margin: 0px 0 0 0;
padding: 0 2px 0 2px;
font-size: 12px; }
p {margin: 3px;}
</style>


<script language="javascript">
function getItem(id)
{
var itm = false;
if(document.getElementById)
itm = document.getElementById(id);
else if(document.all)
itm = document.all[id];
else if(document.layers)
itm = document.layers[id];

return itm;
}

function toggleItem(id)
{
itm = getItem(id);

if(!itm)
return false;

if(itm.style.display == 'none')
itm.style.display = '';
else
itm.style.display = 'none';

return false;
}
</script>

</head>
<body>

<h1>Centric Server Logs</h1>
<p>Note: If Log is not listed, it has no Error or Warning entries. <i>Logs are updated manually</i> since these servers are in the DMZ.</p>
<?php
$arr = array("SERVER1", "SERVER2", "SERVER3" );

foreach ($arr as $value) {

echo "<h2>$value</h2>" . PHP_EOL;
$filename="C:inetpubwwwrootserverlogs".$value."-applog.html";
$output="";
$errors="";
$file = fopen($filename, "r");
while(!feof($file)) {
$output = $output . fgets($file, 4096);
}
fclose ($file);
$errors=substr_count($output, '<tr>');
if ($errors>0) {$errors = $errors-1;
echo "<p><a href="#" onclick="toggleItem('$value-applog')">$value Application Log</a> (Items: $errors)</p>" . PHP_EOL;
include("C:inetpubwwwrootserverlogs".$value."-applog.html");
}
$filename="C:inetpubwwwrootserverlogs".$value."-syslog.html";
$output="";
$errors="";
$file = fopen($filename, "r");
while(!feof($file)) {
$output = $output . fgets($file, 4096);
}
fclose ($file);
$errors=substr_count($output, '<tr>');
if ($errors>0) {$errors = $errors-1;
echo "<p><a href="#" onclick="toggleItem('$value-syslog')">$value System Log</a> (Items: $errors)</p>" . PHP_EOL;
include("C:inetpubwwwrootserverlogs".$value."-syslog.html");
echo " " . PHP_EOL;
}
}
?>


</body>
</html>
This topic is 12 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked