Salve,
partendo dal presupposto che sicuramente esisteva qualcosa di già fatto su internet e fatto sicuramente meglio, io ho elaborato questo script:
in pratica mi serviva un elenco di tutte le "cose" presenti nel mio sito a cui associare dei permessi di accesso agli utenti del gestionale.
Questo script disegna un menu a tendina in cui parte dal folder di partenza assegnato alla funzione disegnamenu, e scorre nella cartella fisica stampando a video file e cartelle presenti, potendo aggiungere filtri per evitare che file indesiderati vengano visualizzati
funziona benissimo (come al solito non vuol dire che sia fatto bene), solo che è lento...cioè in locale ancora va discretamente, ma online è parecchio lento.
Se magari qualcuno sapesse darmi qualche dritta e suggerimento, nonchè critica, gli sarei grato.
ciaoz
codice:<% class Cartella private nome private path private padre public sub cartella(pathC,padreC,nomeC) nome=nomeC path=pathC padre=padreC end sub public function toString() toString=nome end function public function getPath() getPath=path end function public function getPadre() getPadre=padre end function public function getNome() getNome=nome end function end class %> <% dim contatore,contenitore(),principale,strfiltri sub disegnaMenu (startFolderPath) contatore=-1 principale=startFolderPath 'disegno il menu Riempi(server.MapPath(perFolder & startFolderPath)) end sub sub Riempi(startPath) dim fso,folder set fso=server.CreateObject("scripting.filesystemobject") set folder=fso.getFolder(startPath) AddCartella startPath,fso.getParentFolderName(startPath),folder.name for each el in folder.subFolders Riempi startPath & "\" & el.name next set folder=nothing set fso=nothing end sub sub AddCartella (path,padre,nome) contatore=contatore+1 redim preserve contenitore(contatore) set contenitore(contatore)=new Cartella contenitore(contatore).cartella path,padre,nome end sub sub stampa(cartella) dim stringa stringa= "<div align=""left"" style=""padding-left:" & getSpazio(cartella.getPath,1) & """>" & vbcrlf stringa=stringa & "<table cellpadding=""0"" & cellspacing=""0""><tr><td>" & vbcrlf stringa=stringa & "<a href=""javascript:showHideT('" & replace(cartella.getPath,"\","-") & "');"">" & vbcrlf stringa=stringa & "[img][/img]" & vbcrlf stringa=stringa & "[img][/img]" & vbcrlf & "</a>" stringa=stringa & "</td><td style=""padding-left:5px""><span " & stFolder & ">" & vbcrlf stringa=stringa & cartella.toString & "</span></td></tr></table>" & "</div>" & vbcrlf response.write stringa response.Write "<div id=""" & replace(cartella.getPath,"\","-") & """ style=""padding-left:" & getSpazio(cartella.getPath,1) & "; display:none"">" & vbcrlf if hasFigli(cartella) then stampaFigli(cartella) end if stampaFile cartella.getPath response.write "</div>" end sub sub stampaFigli(cartella) for i=lbound(contenitore) to ubound(contenitore) if contenitore(i).getPadre=cartella.getPath then stampa(contenitore(i)) end if next end sub sub stampaFile(path) dim fso,folder set fso=server.CreateObject("scripting.filesystemobject") if fso.folderExists(path) then set folder=fso.getFolder(path) 'response.Write("<div id=""prova"">") for each el in folder.files if forStampa(el.name) then response.write "<div align=""left"" style=""padding-left:" & getSpazio(path,2) & """>" & "<input type=""checkbox"" name=""pagine"" value="""& path & "|" & el.name & "|" & idArea & """ " & checkPage(path,el.name,idArea) & " /><span " & stFile & ">" & el.name & "</span></div>"& vbcrlf end if next 'response.Write("</div") set folder=nothing end if set fso=nothing end sub function hasFigli(cartella) dim trovato trovato=false for i=lbound(contenitore) to ubound(contenitore) if contenitore(i).getPadre=cartella.getPath then trovato=true end if next hasFigli=trovato end function function getSpazio(path,sit) dim temp,conta,misura,trovato misura=10 'unità di spazio per ogni livello temp=split(path,"\") trovato=false conta=0 for i=lbound(temp) to ubound(temp) if temp(i)=principale then trovato=true if trovato=true then conta=conta+1 next if sit=2 then getSpazio=(conta*misura)+int(misura/2) & "px" else getSpazio=conta*misura & "px" end if end function sub addFiltro(valore) strfiltri=strfiltri & ",." & ucase(valore) & "," end sub function isFilter(valore) if instr(strfiltri,"," & ucase(valore) & ",")>0 then isFilter=true else isFilter=false end if end function function forStampa(nome) dim temp temp=split(nome,".") forStampa=not isFilter("." & temp(ubound(temp))) end function function checkPage(path,pagina,area) dim ritorno oConnName "pippo", strConnG sql="select pagine_rc.id from pagine_rc where pagine_rc.path='" & noApici(path) & "' and pagine_rc.pagina='" & noApici(pagina) & "' and exists (select t2.id from aree_link t2 where t2.idlink=pagine_rc.id and t2.idarea=" & area & ")" 'response.Write(sql) oRsConn "rsC",sql,pippo,1,1 if not rsC.eof then ritorno="checked" else ritorno="" end if cRs rsC: cConnName pippo checkPage=ritorno end function 'function contaFigli(cartella) 'dim conta 'conta=0 'for i=lbound(contenitore) to ubound(contenitore) 'if contenitore(i).getPadre=cartella.getPath then 'conta=conta+1 'end if 'next 'contaFigli=conta 'end function %> <form action="<%= toPage %>" method="post" name="treemenu"> <% addFiltro("gif"): addFiltro("jpg"): addFiltro("css"): addFiltro("pnp"): addFiltro("tif"): addFiltro("rar"): addFiltro("txt") addFiltro("jpeg"): addFiltro("php"): addFiltro("doc"): addFiltro("aspx"): addFiltro("zip"): addFiltro("iso") disegnaMenu "kegarne.it\rc" 'carico l'array contenitore stampa contenitore(0) 'stampo il menu %> <input type="submit" class="TitoloLogS" name="Submit" value="-- Procedi --" /> </form>

Rispondi quotando
