ISO Date & Time converter
(ASP/VBS) (ha ottenuto la pubblicazione su ASP 101)

Questa funzione è stata disegnata per ottenere un data numerica coerente in forma contraria (l'ora 18:57:21 del 20 Luglio 2004 sarà trasformato in 20040720185721). Può essere utile in uno svariato numero di applicazioni che richiedano l'uso della data/ora come, ad esempio, comunicati, notizie, time stamp di file upload.
Scarica il file ZIP (richiede WinZip) oppure copia il codice:
<%
'===========================================================
' Function: gfnISODateTime(pData)
' Written by: Cristiano Guglielmetti
' Web site: http://www.webalice.it/cguglielmetti/
' Description: Converts the system date/time (now) to a
' serial number usable in your applications
' (ASP/VBS).
'===========================================================
Function gfnISODateTime(pData)
gfnISODateTime = Cstr(Year(pData))
If Month(pData) <= 9 Then gfnISODateTime = gfnISODateTime + "0"
gfnISODateTime = gfnISODateTime + Cstr(Month(pData))
If Cstr(Day(pData)) <= 9 Then gfnISODateTime = gfnISODateTime + "0"
gfnISODateTime = gfnISODateTime + Cstr(Day(pData))
If Cstr(Hour(pData)) <= 9 Then gfnISODateTime = gfnISODateTime + "0"
gfnISODateTime = gfnISODateTime + Cstr(Hour(pData))
If Cstr(Minute(pData)) <= 9 Then gfnISODateTime = gfnISODateTime + "0"
gfnISODateTime = gfnISODateTime + Cstr(Minute(pData))
If Cstr(Second(pData)) <= 9 Then gfnISODateTime = gfnISODateTime + "0"
gfnISODateTime = gfnISODateTime + Cstr(Second(pData))
End Function
' Test Run For Illustration - just to test and display results
Response.Write(gfnISODateTime(now))
%>
File Name Converter
(ASP/VBS) (ha ottenuto la pubblicazione su ASP 101)

Questo script si esegue sui server IIS ed è disegnata per prendere una grande numero di file con estensione grafica (es: gif, jpg, jpeg, bmp) sena nome progressivo da una web directory, rinominarli con un numero progressivo parametrizzabile, mantenendo la medesima estensione, ed infine muovere i file in una nuova web directory target.
Ad esempio si possono avere questi file in una directory "FromDir"
Test.jpg
Hotel.gif
Hotel2.jpg
Dopo l'esecuzione dello script non avremo alcun file nella "FromDir" ed mentre avremo nella "TargetDir":
100001.jpg
100002.gif
100003.jpg
I file di tipo thumbs.db (anteprime grafiche) vengono esclusi dallo script.
Scarica il file ZIP (richiede WinZip) oppure copia il codice
<% @LANGUAGE = VBSCRIPT %>
<%Option Explicit%>
<%
'===========================================================
' File Name Move and Converter
' Written by: Cristiano Guglielmetti
' Web site: http://xoomer.virgilio.it/guglielmetti/
' Dec.2001
' This script moves and renames files into a webserver
' from a dir to another dir
' especially designed for large numbers of pictures files
'===========================================================
Response.Write "<html>" & VbCrLf & "<head>" & VbCrLf
Response.Write "<title>File Move-Name-Converter" & VbCrLf
Response.Write "</head>" & VbCrLf & "<body>" & VbCrLf
' Declare variables
Dim gbolGoProcedure
Dim strFromDir
Dim strTargetDir
Dim objFS
Dim objRootFolder
Dim objFile
Dim strFileNameLen
Dim strPrevFileName
Dim strFileExt
Dim strFileNameCount
Dim strNewFileName
Dim strRealCount
gbolGoProcedure = False
' Setup procedure execution
If (Request.Form("GoButton")) = "GO PROCEDURE" then
' Declare directories
strFromDir = "[Disk]:\Dir1\UnderDir1\UnderDir2\"
strTargetDir = "[Disk]:\Dir1\UnderDir1\UnderDir2\"
' Set to zero filecount before move
strRealCount = 0
' Count existing files in the target dir (starting from 100001)
Set objFS = Server.CreateObject("Scripting.FileSystemObject")
Set objRootFolder = objFS.GetFolder(strTargetDir)
strFileNameCount = 100001
' Remove from filecount Windows imagetumbs DB (Thumbs.db)
For each objFile in objRootFolder.Files
If objFile.Name = "Thumbs.db" then strFileNameCount = StrFileNameCount - 1
strFileNameCount = strFileNameCount + 1
Next
' Move and rename files from FromDir to TargetDir
Set objRootFolder = objFS.GetFolder(strFromDir)
For each objFile in objRootFolder.Files
strFileNameLen = Len (objFile.Name)
If Mid (objFile.Name,(strFileNameLen - 3),1) = "." then
strFileExt = right(objFile.Name, 4)
Else
strFileExt = right(objFile.Name, 5)
End If
strPrevFileName = objFile.Name
strNewFileName = strFileNameCount & strFileExt
objFile.Move strTargetDir & strNewFileName
Response.Write "Conv: " & strPrevFileName & " > To: " & strNewFileName & "<br>" & vbCrLF
strFileNameCount = strFileNameCount + 1
strRealCount = strRealCount + 1
Next
Response.Write "<p><b>Have been moved and renamed " & (strRealCount) & " files</B>" & vbCrLf
' Destroy objects
Set objRootFolder = Nothing
Set objFS = Nothing
gbolGoProcedure = True
End If
' Setup user interface
If gbolGoProcedure Then
Response.Write("<p><b>Procedure MOVE AND RENAME close</b>") & vbCrLf
Else
Response.Write("<form method=""post"" action=""FileNameConverter.asp"" ID=form1 name=""form1"">") & vbCrLf
Response.Write("<input type=""SUBMIT"" value=""GO PROCEDURE"" ID=""GoButton"" name=""GoButton"">") & vbCrLf
Response.Write("</form>") & vbCrLf
Response.Write("<p><b>Attention: click the button to start Move and Rename procedure</b>") & VbCrLf
End If
Response.Write "</body>" & VbCrLf & "</html>"
%>
Effetto opacità per foto
gallerie Web (Javascript, onmouseover & onmouseout e CSS Filter
Alpha) 
<SCRIPT LANGUAGE="JavaScript1.2">
function high(obj1)
{
theobject=obj1
highlighting=setInterval("highlightit(theobject)",50)
}
function low(obj2)
{
clearInterval(highlighting)
obj2.filters.alpha.opacity=50
}
function highlightit(obj3)
{
if (obj3.filters.alpha.opacity<100)
obj3.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
</SCRIPT>
.
.
<P><A HREF="/images/photo1.jpg"><IMG BORDER="0" SRC="/images/thumbs/photo1.jpg" ALT="photo1.jpg (x byte)" width="100" height="100" onmouseout="low(this)" onmouseover="high(this)" style="FILTER: alpha(opacity=80)"></A></TD>
.
.
Scrivere (metodo Append)
in un file TXT file (ASP/VBS) 
Set LocFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set LocTextStream = LocFileSystem.OpenTextFIle("c:\dirname\filename.txt", 8, true) ' change to 2 to overwrite existing txt content
LocTextStream.Write vbCrLf & strUserText ' where strUserText is a variable that you can get from a web form
LocTextStream.Close
vbCrLf do a return action in the txt file, is possible to add html tags if you will include the txt file in a asp page,
for example you can use LocTextStream.Write vbCrLf & "<P><B>" & strUserTextTitle & "</B></P>" & vbCrLf & "<P>" & "<HR>" & "</P>"
to add a <P> and <B> and also add an horizontal line <HR> to the end
Costruire un indice dei
file presenti in una directory vdir (ASP/VBS) 
Dim objFS
Dim objRootFolder
Dim objFile
Set objFS = Server.CreateObject("Scripting.FileSystemObject")
Set objRootFolder = objFS.GetFolder("c:\inetpub\wwwroot\dirname")
For each objFile in objRootFolder.Files
Response.Write "<a href=""http://servername/vdirname/" & objFile.Name & """ target=""_blank"">" & objFile.Name & "</a><br>"
Next
Set objRootFolder = Nothing
Set objFS = Nothing
obviously vdirname may direct to dirname
Redirect HTML (meta tag)
senza cache del browser 
<META HTTP-EQUIV="REFRESH"
CONTENT="0;URL=http://url/">
Conteggio delle linee di
testo in un file TXT (ASP/VBS) 
Set LocFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set LocTextStream = LocFileSystem.OpenTextFIle("c:\dirname\filename.txt", 1)
Do While LocTextStream.AtEndOfStream <> True
LocTextStream.ReadLine
a = a + 1
Loop
LocTextStream.Close
Inclusione pagina
condizionale (ASP/VBS) 
<% @LANGUAGE=VBSCRIPT %>
<% Option Explicit %>
<%
dim strUservar
strUservar = 0 'change to another value will cause the second include
%>
<%
if strUservar = 0 then
%>
<!--#INCLUDE VIRTUAL="/page_a.asp"-->
<%
else
%>
<!--#INCLUDE VIRTUAL="/page_b.asp"-->
<%
end if
%>
Codice esempio per Posting
Acceptor (ASP/VBS) 
Questo script necessita della libreria Microsoft cpshost.dll
<% @LANGUAGE=VBSCRIPT %>
<%
Option Explicit
Dim strServerURL
Dim strTargetURL
Dim strRepostURL
Dim strPA
Dim strPostingURL
strServerURL = "http://" + Request.ServerVariables("SERVER_NAME")
strTargetURL = strServerURL & "/upload"
strRepostURL = strServerURL & "/replypost.asp"
strPA = strServerURL & "/scripts/cpshost.dll"
strPostingURL = strPA + "?PUBLISH?" + strRepostURL
%>
<HTML>
.
<FORM ENCTYPE="multipart/form-data" ACTION="<% = strPostingURL %>"
METHOD="POST" NAME="IDPA1">
.
Composizione di e-mail
con oggetto e body (HTML) 
mailto:address@domain.com?subject=Test oggetto&body=Test body
Ultima modifica: $ Data: 2009-02-01 $