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

  1.  
  2. {
  3. WebCenter HtmlResources helper script
  4. }
  5.  
  6. const HTML_FILE='';//Path and name of result report file.
  7.                    //If empty defaults to nv_directory+'\Scripts\HTTP\DefaultHost\HtmlReport\index.html';
  8.  
  9. const HtmlHead='<head>'#13#10
  10. '<title>NetView HtmlResources</title>'#13#10
  11. '<SCRIPT LANGUAGE="JavaScript">'#13#10
  12. 'function Toggle(node)'#13#10
  13. '{'#13#10
  14. 'var m_ToggleStyle = node.nextSibling.style.display;'#13#10
  15. 'm_ToggleStyle=(m_ToggleStyle==''none'')?''block'':''none'';'#13#10
  16. 'node.nextSibling.style.display = m_ToggleStyle;'#13#10
  17. '}'#13#10
  18. 'var ToggleStyle = ''block'';'#13#10
  19. 'function ToggleAll(node)'#13#10
  20. '{'#13#10
  21. 'ToggleStyle=(ToggleStyle==''none'')?''block'':''none'';'#13#10
  22. 'node=node.nextSibling.firstChild;'#13#10
  23. 'while(node)'#13#10
  24. ' {'#13#10
  25. ' node.firstChild.firstChild.firstChild.firstChild.nextSibling.nextSibling.nextSibling.style.display = ToggleStyle;'#13#10
  26. ' node=node.nextSibling;'#13#10
  27. ' }'#13#10
  28. '}'#13#10
  29. '</SCRIPT>'#13#10
  30. '</head>'#13#10;
  31.  
  32.  
  33. procedure WriteResourceList(f:integer;proto,img:string;var lst:TStringList);
  34. var i:integer;
  35. begin
  36. if lst.Count>0 then
  37. for i:=0 to lst.Count-1 do
  38.  begin
  39.  writefile(f,'<li>  <a target="_blank" href="'+proto+lst.Strings[i]+'"> <IMG src="'+
  40.           img+'">'+lst.Strings[i]+'</a><br>'#13#10);
  41.  end;
  42. end;
  43.  
  44. procedure GoReport;
  45. var hst:TNVHost;
  46.     l_nb,l_ftp,l_hosts:TStringList;
  47.     s_http,ts,fn,sdesc:string;
  48.     n,i,f,nextid:integer;
  49.     condel:boolean;
  50. begin
  51. if length(HTML_FILE)=0 then fn:=nv_directory+'\Scripts\HTTP\DefaultHost\HtmlResources\index.html'
  52.                        else fn:=HTML_FILE;
  53. CreateDirectory(ExtractFilePath(fn));
  54. f:=openfile(fn,11);
  55.  
  56. writefile(f,'<html>'#13#10);
  57. writefile(f,HtmlHead);
  58. writefile(f,'<body text="#FFFFFF" bgcolor="#000000" link="#00FFFF" vlink="#00FFAA" alink="#00FFFF">'#13#10);
  59. writefile(f,'<p align=center><a href=/>Go to main page</a></p>'#13#10);
  60. writefile(f,'<H3><p align=center>Accessible resources tree generated by NetView on '+FormatDateTime(' YYYY-MM-DD HH:MM.SS',Now)+'</p></H3>'#13#10);
  61. writefile(f,'<table cellpadding=4 cellspacing=2>'#13#10'<tr><td>'#13#10
  62.             '<a onclick="ToggleAll(this)" style=''cursor: hand; color:#CC0000; '+
  63.             'font-weight: bold''>Expand/collapse all</a><div style=''display:block''>');
  64.  
  65. l_nb:=TStringList.Create;l_nb.CaseSensitive:=false;l_nb.Sorted:=true;
  66. l_ftp:=TStringList.Create;l_ftp.CaseSensitive:=false;l_ftp.Sorted:=true;
  67. l_hosts:=TStringList.Create;l_hosts.CaseSensitive:=false;l_hosts.Sorted:=true;
  68.  
  69. nextid:=0;
  70.     repeat
  71.     condel:=true;
  72.     hst:=TNVHost.create;
  73.     hst.GetHost(nextid,0);
  74.     if hst.id<>0 then
  75.      begin
  76.      nextid:=hst.nextid;
  77.      if hst.GetMetaVar('ison')<>'off' then
  78.       begin
  79.       l_hosts.AddObject(hst.hname,hst);
  80.       condel:=false;
  81.       end;
  82.      end else nextid:=0;
  83.     if condel then hst.Free;
  84.     until nextid=0;
  85.  
  86.  
  87. if l_hosts.Count<>0 then
  88. for n:=0 to l_hosts.Count-1 do
  89.     begin
  90.     hst:=TNVHost(l_hosts.Objects[n]);
  91.     ts:=hst.GetMetaVar('!nbcache');
  92.     if ts<>chr(1) then l_nb.Text:=ts else l_nb.Clear;
  93.     ts:=hst.GetMetaVar('!ftpcache');
  94.     if ts<>chr(1) then l_ftp.Text:=ts else l_ftp.Clear;
  95.     ts:=hst.GetMetaVar('!httitle');
  96.     if length(ts)>0 then
  97.      begin
  98.      if length(ts)>1 then delete(ts,1,1)
  99.                      else ts:='Possible HTTP server';
  100.      end;
  101.     s_http:=ts;
  102.     if l_nb.Count<>0 then
  103.     for i:=l_nb.Count-1 downto 0 do
  104.      begin
  105.      ts:=l_nb.Strings[i];
  106.      if length(ts)=0 then l_nb.Delete(i) else
  107.      if ts[length(ts)]='$' then l_nb.Delete(i);
  108.      end;
  109.  
  110.     if (l_nb.Count<>0) or (l_ftp.Count<>0) or (length(s_http)<>0) then
  111.      begin
  112.      sdesc:=hst.GetMetaVar('sdesc');
  113.      writefile(f,'<table cellpadding=4 cellspacing=2>'#13#10'<tr><td>'#13#10);
  114.      writefile(f,'<IMG src="comp.gif"> <a onclick="Toggle(this)" style=''cursor: hand; color:#CC0000; font-weight: bold''>'
  115.                  +hst.hname+' - '+hst.hip);
  116.      if length(sdesc)<>0 then writefile(f,' ('+sdesc+')');
  117.      writefile(f,'</a><div style=''display:block''>'#13#10);
  118.      writefile(f,'<table border=0>'#13#10'<tr><td>'#13#10'<ul class="li_main">'#13#10);
  119.      if l_nb.Count<>0 then WriteResourceList(f,'file://'+hst.hip+'/','netbios.gif',l_nb);
  120.      if l_ftp.Count<>0 then WriteResourceList(f,'ftp://'+hst.hip+'/','ftp.gif',l_ftp);
  121.      if length(s_http)<>0 then
  122.       begin
  123.       writefile(f,'<li>  <a target="_blank" href="http://'+hst.hip+'/"> <IMG src="'+
  124.                   'http.gif">'+s_http+'</a><br>'#13#10);
  125.       end;
  126.  
  127.      writefile(f,'</ul>'#13#10'</td></tr>'#13#10'</table>'#13#10'</div>'#13#10
  128.      '</td></tr>'#13#10'</table>'#13#10);
  129.      end;
  130.     hst.Free;
  131.     end;
  132.  
  133. l_nb.Free;
  134. l_ftp.Free;
  135. l_hosts.Free;
  136. writefile(f,'</tr></td></table>'#13#10);
  137. 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>');
  138. writefile(f,'</body><script language="JavaScript" src="/fade.js"></script></html>');
  139. CloseFile(f);
  140. end;
  141.  
  142. var e,i1,i2:integer;
  143. begin
  144. GoReport;
  145. repeat
  146.  e:=waitevent(i1,i2);
  147.  if ( (e=NMNP_ACTION) and ((i1 and NVACTION_LIST)<>0) and
  148.    ( ((i1 and NVACTION_RECHECK)<>0) or ((i1 and NVACTION_GETFROMFILE)<>0) or ((i1 and NVACTION_GETFROMNET)<>0) ) )
  149.   or ( (e=NMNP_ALERT) and ((i1 and NVALERT_RESSCANER)<>0) ) then GoReport;
  150.  until e=0;
  151. end.
  152.  
  153.