'// FERRUH.MAVITUNA
'// http://ferruh.mavituna.com
'// ferruh@mavituna.com

'// Functions
On Error Resume Next
Function GetHeaders(URL)
	Set oHTTP = WScript.CreateObject("Microsoft.XMLHTTP") 
	Call oHTTP.Open("HEAD", URL, False)
	Call oHTTP.Send()
	GetHeaders = oHTTP.GetAllResponseHeaders()
	Set oHTTP = Nothing	
	If err Then GetHeaders = "ERR"
End Function


'// Options
Dim FilePath, WebSite, Prog_Name, WebSiteforPath
Prog_Name = "Site Getirici v.01 - 07.07.2003"
FilePath = "c:/sites/"
WebSite = InputBox("Bilgisi alınacak site adı : ", Prog_Name, "http://")
WebSiteforPath = Replace(Replace(WebSite,"http://",""),".","") & ".txt"

'// Exit If Empty
If WebSite = "" Then  WScript.Quit(1)


Dim HeaderTxt
HeaderTxt = GetHeaders(WebSite)
HeaderTxt = "Site : " & WebSite & vbNewline & "Path : " & FilePath & WebSiteforPath & vbNewLine & "*************************HEADER**********************" & vbNewLine & HeaderTxt

'// FSO
Set NewFSO = CreateObject("Scripting.FileSystemObject") 

'// Save
msgbox FilePath & WebSiteforPath
Set TxtFile = NewFSO.CreateTextFile(FilePath & WebSiteforPath)
TxtFile.WriteLine HeaderTxt

'// Kill
TxtFile.Close 
Set TxtFile = Nothing

Set NewFSO = Nothing

'// Control
Dim Prog_Result
If err Then
	Prog_Result = "Hata Oluştu;" & vbNewLine & "Number : "& err.Number & vbNewLine & "Description : " & err.Description & vbNewLine & "Source " & err.Source
	WScript.Echo Prog_Result
Else
	Prog_Result = "Dosya Başarıyla oluşturuldu;" & vbNewline & FilePath & WebSiteforPath
	WScript.Echo Prog_Result

	'// Run File
	Set oSh = CreateObject("WScript.Shell")
	oSh.Run "notepad " & FilePath & WebSiteforPath, 1, False
	Set oSh = Nothing
End If

'// Show Result
WScript.Quit(1)
