home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2007 April / PCpro_2007_04.ISO / files / dsl / NVinst.exe / Scripts / Scripter / HtmlReport.nvs < prev    next >
Encoding:
Text File  |  2007-02-10  |  3.8 KB  |  107 lines

  1. {
  2. HTML report script v1.0 for NetView by KillerR
  3. Saves current hostlist state to an HTML file
  4. Saving occurs after every list recheck
  5. By the way you can use this script with NetView's
  6. HTTP server listener script in pair
  7.  
  8. User defined constants:
  9. HTMLFILENAME  - report file path and name. If you want to use
  10.                 this script with HTTP script you should set this
  11.                 const like '\Scripts\HTTP\DefaultHost\index.html' or any other
  12.                 filename and set reference to it in index.html
  13. }
  14. {
  15. WebCenter HtmlReport helper script
  16. }
  17. const HTML_FILE='';//Path and name of result report file.
  18.                    //If empty default to nv_directory+'\Scripts\HTTP\DefaultHost\HtmlReport\index.html';
  19.  
  20. procedure GoReport;
  21. var fn,ts,lst,ctime:string;
  22.     hst:TNVHost;
  23.     i,f,flg:integer;
  24.     tabs:TStringList;
  25. begin
  26. hst:=TNVHost.Create;
  27. tabs:=TStringList.Create;
  28. if length(HTML_FILE)=0 then fn:=nv_directory+'\Scripts\HTTP\DefaultHost\HtmlReport\index.html'
  29.                        else fn:=HTML_FILE;
  30. CreateDirectory(ExtractFilePath(fn));
  31. f:=openfile(fn,11);
  32. tabs.Clear;
  33. writefile(f,'<html><title>NetView hostlist</title>'+
  34.             '<body text="#FFFFFF" bgcolor="#000000" link="#00FFFF" vlink="#00FFAA" alink="#00AAAA">');
  35. writefile(f,'<p align=center><a href=/>Go to main page</a></p>');
  36. writefile(f,'<H3><p align=center>Full servers list generated by NetView on '+
  37.             FormatDateTime(' YYYY-MM-DD HH:MM.SS',Now)+'</p></H3>');
  38. writefile(f,'<TABLE x:str align=center border=1 cellpadding=0 cellspacing=0 '+
  39.             'style=''border-collapse: collapse;table-layout:fixed'' bgcolor="#101010">');
  40.  
  41. writefile(f,'<TR bgcolor="#404040">');
  42. writefile(f,'<td width=150><b>Hostname</b></td>');
  43. writefile(f,'<td width=150><b>IP address</b></td>');
  44. writefile(f,'<td width=150><b>Connection</b></td>');
  45. writefile(f,'<td width=150><b>Workgroup</b></td>');
  46. writefile(f,'</TR>');
  47.  
  48. hst.nextid:=0;
  49. repeat
  50.  hst.gethost(hst.nextid,0);
  51.  if(hst.id<>0)then
  52.   begin
  53.   flg:=strtoint(hst.getmetavar('flags'));
  54.   lst:=hst.getmetavar('wgrp');
  55.   if length(lst)=0 then lst:=' ';
  56.   ctime:=hst.getmetavar('ctime');
  57.   if(flg and $200)=0 then
  58.    begin
  59.    if(hst.getmetavar('ison')='on')then ts:='<TR bgcolor="#384045">' else ts:='<TR>';
  60.    ts:=ts+'<td width=150><a href="file://'+hst.hname+'/" target="_blank">\\'+hst.hname+'</a></td>';
  61.    ts:=ts+'<td width=150><a href="file://'+hst.hip+'/" target="_blank">\\'+hst.hip+'</a></td>';
  62.    ts:=ts+'<td width=150>'+ctime+'</td>';
  63.    ts:=ts+'<td width=150>'+lst+'</td>';
  64.    ts:=ts+'</TR>';
  65.    tabs.add(lst+hst.hname+#13+ts);
  66.    end;
  67.   if((flg and $400)<>0) or ((flg and $1000)<>0) then
  68.    begin
  69.    if(hst.getmetavar('ison')='on')then ts:='<TR bgcolor="#384045">' else ts:='<TR>';
  70.    ts:=ts+'<td width=150><a href="ftp://'+hst.hname+'" target="_blank">ftp://'+hst.hname+'</a></td>';
  71.    ts:=ts+'<td width=150><a href="ftp://'+hst.hip+'" target="_blank">ftp://'+hst.hip+'</a></td>';
  72.    ts:=ts+'<td width=150>'+ctime+'</td>';
  73.    ts:=ts+'<td width=150>'+lst+'</td>';
  74.    ts:=ts+'</TR>';
  75.    tabs.Add(lst+hst.hname+#13+ts);
  76.    end;
  77.   end;
  78.  until hst.nextid=0;
  79. tabs.Sort;
  80. for i:=0 to tabs.count-1 do
  81.  begin
  82.  ts:=tabs.strings[i];
  83.  delete(ts,1,pos(#13,ts));
  84.  writefile(f,ts);
  85.  end;
  86. writefile(f,'</TABLE>');
  87. writefile(f,'<p align="center">Powered by NetView<br><img border="0" src="/nvico.gif" width="64" height="64"><br><a href="http://www.killprog.com">http://www.killprog.com</a></p>');
  88. writefile(f,'</body><script language="JavaScript" src="/fade.js"></script></html>');
  89. closefile(f);
  90. hst.free;
  91. tabs.Free;
  92. end;
  93.  
  94. var e,i1,i2:integer;
  95. begin
  96. GoReport;
  97. repeat
  98.  e:=waitevent(i1,i2);
  99.  if(e=NMNP_ACTION)then
  100.   begin
  101.   if ((i1 and NVACTION_LIST)<>0) and
  102.   (((i1 and NVACTION_RECHECK)<>0)or((i1 and NVACTION_GETFROMFILE)<>0)or((i1 and NVACTION_GETFROMNET)<>0))
  103.    then GoReport;
  104.   end;
  105.  until e=0;
  106. end.
  107.