I modified one of the abovementioned scripts to do something similar. I am still working on getting the bugs out, but here's what I have so far.
<?php
#$argv[1]=$HTTP_GET_VARS["fname"];
$argv[1]="test1.html";
$Agv[1]="https://www.omnistep.com/~recompiler/Work/HTML%20Validate/test1.html";
/
if ($argc < 2)
{
print "argv[1] should be the name of the file you want to parse.\n";
print "Argv[1] can be a valid URL\n";
exit(0);
}
/
$array = file($argv[1]);
$array_size = count($array);
$open_tables = 0; #tables declared
$close_tables = 0; #tables closed
$open_links = 0; #links opened
$close_links = 0; #links_closed
$open_bld = 0; #open bold tags
$close_bld = 0; #close bold tags
$open_itl = 0; #open italic tags
$close_itl = 0; #close italic tags
$open_ttl = 0; #open title tags
$close_ttl = 0; #close title tags
$open_hdr = 0; #open header tags
$close_hdr = 0; #close header tags
$open_big = 0; #open big tags
$close_big = 0; #close big tags
$open_p = 0; #open paragraph tags
$close_p = 0; #close paragraph tags
#--------------Check Tables-------------------------
$max = 0;
$deep = 0;
while(list($key, $val) = each($array))
{
if (eregi('<table',strtolower($val)))
{
$open_tables++;
$deep++;
if ($deep > $max)
$max = $deep;
}
else if (eregi('</table>',strtolower($val)))
{
$deep--;
}
if (eregi('</table>',strtolower($val)))
$close_tables++;
}
print "The total number of open table tags is $open_tables <br>\n";
print "The total number of close table tags is $close_tables <br>\n";
if ($close_tables != $open_tables)
print "Warning: The number of open table tags does not equal the number of close tables tags. Make sure you check your code!<br>\n\n";
print "The max depth of imbeded tables is $max\n<br><br>";
#--------------Check Links-------------------------
$max = 0;
$deep = 0;
while(list($key, $val) = each($array))
{
if (eregi('<a href',strtolower($val)))
{
$open_links++;
$deep++;
if ($deep > $max)
$max = $deep;
}
else if (eregi('</a>',strtolower($val)))
{
$deep--;
}
if (eregi('</a>',strtolower($val)))
$close_links++;
}
print "The total number of open link tags is $open_links<br>\n";
print "The total number of close link tags is $close_links<br>\n";
if ($close_links != $open_links)
print "Warning: The number of open link tags does not equal the number of close link tags. Make sure you check your code!<br><br>\n\n";
#print "The max depth of imbeded links is $max<br><br>\n";
print "<br><br>\n";
#--------------Check Bold-------------------------
$max = 0;
$deep = 0;
while(list($key, $val) = each($array))
{
if (eregi('<b>',strtolower($val)))
{
$open_bld++;
$deep++;
if ($deep > $max)
$max = $deep;
}
else if (eregi('</b>',strtolower($val)))
{
$deep--;
}
if (eregi('</b>',strtolower($val)))
$close_bld++;
}
print "The total number of open bold tags is $open_bld<br>\n";
print "The total number of close bold tags is $close_bld<br>\n";
if ($close_bld != $open_bld)
print "Warning: The number of open link tags does not equal the number of close link tags. Make sure you check your code!<br><br>\n\n";
#print "The max depth of imbeded bold tags is $max<br><br>\n";
print "<br><br>\n";
#--------------Check Italics-------------------------
$max = 0;
$deep = 0;
while(list($key, $val) = each($array))
{
if (eregi('<i>',strtolower($val)))
{
$open_itl++;
$deep++;
if ($deep > $max)
$max = $deep;
}
else if (eregi('</i>',strtolower($val)))
{
$deep--;
}
if (eregi('</i>',strtolower($val)))
$close_itl++;
}
print "The total number of open italics tags is $open_itl<br>\n";
print "The total number of close italics tags is $close_itl<br>\n";
if ($close_itl != $open_itl)
print "Warning: The number of open italics tags does not equal the number of close italics tags. Make sure you check your code!<br><br>\n\n";
#print "The max depth of imbeded italics is $max<br>\n";
print "<br><br>\n";
#--------------Check Title-------------------------
$max = 0;
$deep = 0;
while(list($key, $val) = each($array))
{
if (eregi('<title',strtolower($val)))
{
$open_ttl++;
$deep++;
if ($deep > $max)
$max = $deep;
}
else if (eregi('</title>',strtolower($val)))
{
$deep--;
}
if (eregi('</title>',strtolower($val)))
$close_ttl++;
}
print "The total number of open title tags is $open_ttl<br>\n";
print "The total number of close title tags is $close_ttl<br>\n";
if ($close_ttl != $open_ttl)
print "Warning: The number of open title tags does not equal the number of close italics tags. Make sure you check your code!<br><br>\n\n";
#print "The max depth of imbeded title is $max<br><br>\n";
print "<br><br>\n";
#--------------Check Header-------------------------
$max = 0;
$deep = 0;
while(list($key, $val) = each($array))
{
if (eregi('<head',strtolower($val)))
{
$open_hdr++;
$deep++;
if ($deep > $max)
$max = $deep;
}
else if (eregi('</head>',strtolower($val)))
{
$deep--;
}
if (eregi('</head>',strtolower($val)))
$close_hdr++;
}
print "The total number of open header tags is $open_hdr<br>\n";
print "The total number of close header tags is $close_hdr<br>\n";
if ($close_hdr != $open_hdr)
print "Warning: The number of open header tags does not equal the number of close italics tags. Make sure you check your code!<br><br>\n\n";
#print "The max depth of imbeded italics is $max<br><br>\n";
print "<br><br>\n";
#--------------Check Big-------------------------
$max = 0;
$deep = 0;
while(list($key, $val) = each($array))
{
if (eregi('<big',strtolower($val)))
{
$open_big++;
$deep++;
if ($deep > $max)
$max = $deep;
}
else if (eregi('</big>',strtolower($val)))
{
$deep--;
}
if (eregi('</big>',strtolower($val)))
$close_big++;
}
print "The total number of open big tags is $open_big<br>\n";
print "The total number of close big tags is $close_big<br>\n";
if ($close_big != $open_big)
print "Warning: The number of open big tags does not equal the number of close italics tags. Make sure you check your code!<br><br>\n\n";
print "The max depth of imbeded big is $max<br><br>\n";
#--------------Check Paragraph-------------------------
$max = 0;
$deep = 0;
while(list($key, $val) = each($array))
{
if (eregi('<p>',strtolower($val)))
{
$open_p++;
$deep++;
if ($deep > $max)
$max = $deep;
}
else if (eregi('</p>',strtolower($val)))
{
$deep--;
}
if (eregi('</p>',strtolower($val)))
$close_big++;
}
print "The total number of open paragraph tags is $open_p<br>\n";
print "The total number of close paragraph tags is $close_p<br>\n";
if ($close_p != $open_p)
print "Warning: The number of open paragraph tags does not equal the number of close paragraph tags. Make sure you check your code!<br><br>\n\n";
print "The max depth of imbeded big is $max<br><br>\n";
?>