Bibliothèque de scripts (1/3) |
Asp, Php, JavaScript, ... |
|
 |
Bah, y'a de tout, à voir lesquels vous intéressent
|
Scripts Asp -
Scripts Php -
Script JavaScript
| Scripts Asp |
| Lister le nom des tables d'une DB Access |
<% Set conn = Server.CreateObject("ADODB.Connection") conn.open chaine_de_connexion_ou_DSN Set ObjTable = conn.OpenSchema(20) do while not ObjTable.eof if ObjTable("table_type")="TABLE" then response.write ObjTable("table_name")&" <br>" end if ObjTable.moveNext loop ObjTable.close set ObjTable = nothing conn.close set conn = nothing %> |
|
|
|

| Simple arborescence d'un répertoire |
<%
Parent = Server.MapPath(".") ' ou "C:\ton_rep"
'ouverture du systeme de fichiers
Set Fso = Server.createObject("Scripting.FileSystemObject")
'création de l'objet répertoire
Set Rep = Fso.GetFolder(Parent)
response.write "Répertoires :<BR>"
For Each RepFiles In Rep.SubFolders
response.write RepFiles.Name & "<BR>"
Next
response.write "<HR>Fichiers :<BR>"
For Each RepFiles In Rep.Files
response.write RepFiles.Name & "<BR>"
Next
%>
|
|
|
| Récuperer votre adresse IP externe |
Vous développez en local et vous désirez savoir votre adresse IP de connexion internet (Adresse Externe) voici un simple script :
<%
addr = "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("SCRIPT_NAME")
if request("ip") <> "" then
response.write request("ip")
else
response.redirect "http://www.madbison.fr.fm/getip.asp?addr=" & addr
end if
%>
|
|
|
| Lecture d'un fichier INI (Configuration) |
<%
Function GetIni(File, Section, Key)
GetIni = "Error"
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
Set F = FSO.OpenTextFile(File, 1)
C = F.ReadAll
F.Close
TC = Split(C, vbCrLf)
Section = "[" & Section & "]"
For a = 0 To UBound(TC) - 1
If TC(a) = Section Then
If Err.Number <> 0 Then Exit Function
a = a + 1
Do While Left(TC(a),1) <> "["
If Err.Number <> 0 Then Exit Function
K = Mid(TC(a), 1, InStr(1, TC(a), "=") - 1)
If K = Key Then
GetIni = Mid(TC(a), InStr(1, TC(a), "=") + 1)
Exit Function
End If
a = a + 1
Loop
End If
Next
End Function
%>
Appel :
<%
Response.Write GetIni("C:\Essai.ini", "Clé1", "Valeur2")
%>
|
|
|
| Ne pas laisser une page en cache |
<%
Response.Expires = -1
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "cache-control", "no-store"
%>
|
|
|
| Afficher le code HTML d'un site (via XMLHTTP) |
<%
dim objXMLHTTP
URL = "http://www.yahoo.com"
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "GET", URL, false
objXMLHTTP.Send
Response.Write "<hr>"
Response.Write "<h4>HTML Code of : " & URL & "</h4>"
Response.Write "<textarea rows=30 cols=120>"
Response.Write objXMLHTTP.responseText
Response.Write "</textarea>"
Set objXMLHTTP = Nothing
%>
|
|
|
|
|
|
|
|