Programalama > ASP

Etiketler: döküman, yönetimi

Ort. 0
Puan ver:
<%@ Language=VBScript %>

<%Option Explicit%>
<%Response.Buffer = true%>

<%


dim conn 
dim rs
dim yaz
dim oku
dim dept
dim folderpath
dim wexRoot

	set conn=server.CreateObject("ADODB.Connection")
		conn.Open "tekintranet"
    set rs=server.CreateObject("ADODB.Recordset")
		rs.Open "users", conn
			
	' &#222;ifreyi kald&#253;rmak için t&#253;rnak aralar&#253;n&#253; bo&#254; b&#253;rak&#253;n = "" 
	Const wexPassword = "admin"
	' Ana dizin sanal bir dizin olabilir: "c:\test", "/test"
	' E&#240;er "c:\test" gibi fiziksel bir dizin kullan&#253;rsan&#253;z dosya yukleme, silme hakk&#253;na sahip olamayacaks&#253;n&#253;z.
	Select Case session("dept")
           Case 10    folderpath="c:\inetpub\wwwroot\portal"
           Case 41    folderpath="c:\inetpub\wwwroot\portal\diskhat"
           Case 42    folderpath="c:\inetpub\wwwroot\portal\sjanthat"
           Case 43    folderpath="c:\inetpub\wwwroot\portal\pjanthat"
           Case 44    folderpath="c:\inetpub\wwwroot\portal\ojanthat"
           Case 45    folderpath="c:\inetpub\wwwroot\portal\boyahat"
           Case 46    folderpath="c:\inetpub\wwwroot\portal\lchat"
           Case 50    folderpath="c:\inetpub\wwwroot\portal\muhhiz"
           Case 51    folderpath="c:\inetpub\wwwroot\portal\tekburo"           
           Case 52    folderpath="c:\inetpub\wwwroot\portal\kalip"
           Case 60    folderpath="c:\inetpub\wwwroot\portal\kalite"
           Case 70    folderpath="c:\inetpub\wwwroot\portal\bakim"
           Case 80    folderpath="c:\inetpub\wwwroot\portal\plansat"
           Case 85    folderpath="c:\inetpub\wwwroot\portal\bilgisistem"           
           Case 90    folderpath="c:\inetpub\wwwroot\portal\muhasebe" 
           Case Else   
    End Select	
    if session("admin")=true then
    folderpath="c:\inetpub\wwwroot"
    end if
			       
	session("folderpath")=folderpath
	wexRoot=session("folderpath")	
    
	' Düzenlenen karakter seti
	Const wexCharSet = "ISO-8859-9"
	' Gizli dosyalar&#253; göstersin mi?
	Const showHiddenItems = true
	' Klasör boyutlar&#253;n&#253; hesaplama, büyük klasörler için uzun sürebilir
	Const calculateTotalSize = true
	' Dosya boyutlar&#253;n&#253; hesaplama
	Const calculateFolderSize = true
	' A&#254;a&#240;&#253;daki dosyalar yan&#253;ndki T ikonuna t&#253;klayarak düzenlenebilir.
	Const editableExtensions = "*htm*|*html*|*asp*|*asa*|*txt*|*inc*|*css*|*aspx*|*js*|*vbs*|*shtm*|*shtml*|*xml*|*xsl*|*log*"
	' P yani resim olarak gösterilebilecek dosyalar
	Const viewableExtensions = "*gif*|*jpg*|*jpeg*|*png*|*bmp*|*jpe*"
	' E&#240;er script büyük dosyalar&#253; upload etmezse ne kadar zamanda script bu i&#254;lemi iptal etsin?
	Server.ScriptTimeout = 300
' ------------------------------------------------------------

	Const appName = "Tekersan Doküman Yönetimi"
	Const appVersion = "1.0"

	Dim scriptName
	scriptName = Request.ServerVariables("SCRIPT_NAME")
	
	Dim FSO
	Set FSO = server.CreateObject ("Scripting.FileSystemObject")

	Dim wexId
	wexId = appName & appVersion & "-" & FSO.GetParentFolderName(scriptName) & "-"
	
	Dim wexMessage, wexRootPath

	Const iconFolderOpenBig = "<img align=absmiddle border=0 width=32 height=27 src=""./klasor_buyuk.gif"">"
	Const iconFolderUp = "<img align=absmiddle border=0 width=15 height=13  src=""./yukari.gif"" alt=""Üst Dizin"">"
	Const iconFolder = "<img align=absmiddle border=0 width=15 height=13 src=""./klasor.gif"" alt=""Klasör - Detaylar&#253; Ö&#240;renmek &#221;çin T&#253;klay&#253;n"">"
	Const iconFile = "<img align=absmiddle border=0 width=11 height=14 src=""./dosya.gif"" alt=""Dosya - Detaylar&#253; Ö&#240;renmek &#221;çin T&#253;klay&#253;n"">"
	Const iconFileEditable = "<img align=absmiddle border=0 width=11 height=14 src=""./duzenlenebilir.gif"" alt=""Metin Dosyas&#253; - Detaylar&#253; Ö&#240;renmek &#221;çin T&#253;klay&#253;n"">"
	Const iconFileViewable = "<img align=absmiddle border=0 width=11 height=14 src=""./goruntulenebilir.gif"" alt=""Resim Dosyas&#253; - Detaylar&#253; Ö&#240;renmek &#221;çin T&#253;klay&#253;n"">"
	
	Const iconRefresh = "<img align=absmiddle border=0 width=21 height=20 src=""./yenile.gif"" alt=""Dosya Görüntülemeyi Yenile"">"
	Const iconCreateFile = "<img align=absmiddle border=0 width=21 height=20 src=""./dosya_olustur.gif"" alt=""Yeni Dosya Olu&#254;tur"">"
	Const iconCreateFolder = "<img align=absmiddle border=0 width=21 height=20 src=""./klasor_olustur.gif"" alt=""Yeni Klasör Olu&#254;tur"">"
	Const iconUpload = "<img align=absmiddle border=0 width=21 height=20 src=""./upload.gif"" alt=""Bu Klasöre Dosya Gönder"">"
	Const iconLogout = "<img align=absmiddle border=0 width=21 height=20 src=""./cikis.gif"" alt=""Oturumu Kapat"">"
	Const iconDelete = "<img align=absmiddle border=0 width=21 height=20 src=""./sil.gif"" alt=""Sil"">"

' - WebExplorer Özellikleri ------------------------------------
	' Html ba&#254;l&#253;&#240;&#253; yazar
	Sub HtmlHeader (title, charset)
	
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<meta http-equiv="Content-Language" content="tr">
<title><%=title%></title>
<%if Session(wexId & "Login") = true then %>
 <b><font color=lightgrey>Kullanici:</font>  <font color=white><%=session("user")%></font>
<%end if%>
<%HtmlStyle%>
<%HtmlJavaScript%>
</head>
<body>
<%	
	End Sub	
	' Html alt ba&#254;l&#253;&#240;&#253; yazar
	Sub HtmlFooter ()
%>	
</body>
</html>
<%
	End Sub

	
	Sub HtmlCopyright()
	%>
		<table cellspacing=0 cellpadding=0 border=0 align=center><tr><td>
			Tekersan Bilgi Sistemleri<a href="http://tjfabsr3/tekintranet/ti_anasayfa.asp">
                    Web Site</a> 
		</td></tr></table>
	<%
	End Sub
	
	
	Sub HtmlStyle
%>
<style>
BODY
{
    BACKGROUND-COLOR: #003366
}
TD
{
    FONT-WEIGHT: normal;
    FONT-SIZE: 10pt;
    COLOR: white;
    FONT-FAMILY: Verdana,Tahoma,Arial,Helvetica
}
.formClass
{
    BACKGROUND-COLOR: #99ccff;
    FONT-WEIGHT: normal;
    FONT-SIZE: 10pt;
    COLOR: black;
    FONT-FAMILY: Verdana,Tahoma,Arial,Helvetica
}
.lightRow {
	BACKGROUND-COLOR: #0066cc
}
.darkRow {
	BACKGROUND-COLOR: #003399
}
.titleRow {
	BACKGROUND-COLOR: black
}
.loginRow {
	border: black solid 1px;
	BACKGROUND-COLOR: DodgerBlue
}
.boldText
{
    FONT-WEIGHT: bold
}
A
{
    FONT-WEIGHT: bold;
    COLOR: #99ccff;
    TEXT-DECORATION: none
}
A:hover
{
    COLOR: #ccffff;
    TEXT-DECORATION: none
}
A:visited
{
    TEXT-DECORATION: none
}
A:active
{
    COLOR: #ccffff;
    TEXT-DECORATION: none
}
</style>
<%
	End Sub
	
	' Java script kodu
	Sub HtmlJavaScript
%>
<script language=javascript>
	function Command(cmd, param) {
		var str;
		var someWin;
		switch (cmd) {
			case "NewFile":
				str = prompt("Lütfen yeni dosyan&#253;n ismini giriniz", "Yeni Dosya");
				if(!str) return;
				document.forms.formBuffer.parameter.value = str;
				break;
			case "NewFolder":
				str = prompt("Lütfen yeni klasörün ismini giriniz", "Yeni Klasör");
				if(!str) return;
				document.forms.formBuffer.parameter.value = str;
				break;
			case "Edit":
				str = document.forms.formBuffer.folder.value + param;
				someWin = openWin(cmd + str, "", 800, 600, false, false);
				someWin.focus();
				createPage(someWin,cmd,param);
				someWin = null;
				return;
				break;
			case "View":
				if(document.forms.formBuffer.virtual.value=="") {alert("Net ba&#240;lant&#253;s&#253; olmadan resim görüntülenemiyor !"); return;}
				str = document.forms.formBuffer.folder.value + param;
				someWin = openWin(cmd + str, "", 800, 600, false, true);
				someWin.focus();
				createPage(someWin,cmd,param);
				someWin = null;
				return;
				break;
			case "FileDetails":
			case "FolderDetails":
				str = document.forms.formBuffer.folder.value + param;
				someWin = openWin(cmd + str, "", 350, 220, false, false);
				someWin.focus();
				createPage(someWin,cmd,param);
				someWin = null;
				return;
				break;
			case "NoDownload":
				alert("Net ba&#240;lant&#253;s&#253; olmadan dosya indirilemiyor!");
				return;
				break;
			case "Upload":
				someWin = openWin(cmd, "", 400, 150, true, false);
				someWin.focus(); 
				createPage(someWin,cmd,param);
				someWin = null;
				return;
				break;
			case "DeleteFolder":
				if (!confirm(' "' + param + '" klasörünü ve tüm içeri&#240;ini silmek istedi&#240;inizden eminmisiniz ?')) return;
				document.forms.formBuffer.parameter.value = param;
				break;
			case "DeleteFile":
				if (!confirm(' "' + param + '" dosyas&#253;n&#253; silmek istedi&#240;inizden eminmisiniz?')) return;
				document.forms.formBuffer.parameter.value = param;				
				break;
			default:
				document.forms.formBuffer.parameter.value = param;
		}
		document.forms.formBuffer.target = "";
		document.forms.formBuffer.command.value = cmd
		document.forms.formBuffer.submit();	
	}
	
	function Check() {
		if (document.forms.formBuffer.pwd.value == "") {
			alert("&#222;ifreyi Girmediniz!"); 
			return false;
		} else return true;
	}

	function openWin(winName, urlLoc, w, h, showStatus, isViewer) {
		l = (screen.availWidth - w)/2;
		t = (screen.availHeight - h)/2;
		features  = "toolbar=no";      // yes|no 
		features += ",location=no";    // yes|no 
		features += ",directories=no"; // yes|no 
		features += ",status=" + (showStatus?"yes":"no");  // yes|no 
		features += ",menubar=no";     // yes|no 
		features += ",scrollbars=" + (isViewer?"yes":"no");   // auto|yes|no 
		features += ",resizable=" + (isViewer?"yes":"no");   // yes|no 
		features += ",dependent";      // close the parent, close the popup, omit if you want otherwise 
		features += ",height=" + h;
		features += ",width=" + w;
		features += ",left=" + l;
		features += ",top=" + t;
		winName = winName.replace(/[^a-z]/gi,"_");
		return window.open(urlLoc,winName,features);
	} 
	
	function createPage (theWin, cmd, param){
		document.forms.formBuffer.target = theWin.name;
		document.forms.formBuffer.command.value = cmd;
		document.forms.formBuffer.parameter.value = param;
		document.forms.formBuffer.submit();
	}

	function EditorCommand (cmd) {
		switch (cmd) {
			case "Info":
				alert(document.forms.formBuffer.info.value.replace(/\|/gi,"\n"));
				break;
			case "Reload":
				document.forms.formBuffer.reset();
				break;
			case "Save":
				document.forms.formBuffer.subcommand.value = "Kaydet";
				document.forms.formBuffer.submit();
				break;
			case "SaveAs":
				var str, oldname;
				oldname = document.forms.formBuffer.parameter.value;
				str = prompt("Farkl&#253; Kaydet :", oldname);
				if (!str || str==oldname) return;
				document.forms.formBuffer.parameter.value = str;
				document.forms.formBuffer.subcommand.value = "Farkl&#253; Kaydet";
				document.forms.formBuffer.submit();
				break;
		}
	}

	function ViewerCommand (cmd) {
		switch (cmd) {
			case "Info":
				alert(document.forms.formBuffer.info.value.replace(/\|/gi,"\n"));
				break;
			case "Reload":
				document.forms.formBuffer.submit();
				break;
		}
	}

	function Upload() {
		document.forms.formBuffer.submit();
	}
</script>
<%
	End Sub

	' a
	Sub WriteListing (byref folder)
		Dim item, arr
		Dim rowType
		Dim listed
		
		on error resume next
		
%>
<form name=formGlobal action="v/noaction" onSubmit="return(false);">
<table cellspacing=0 cellpadding=0 border=0 width=100%>
	<tr class=titleRow>
		<td align=left> <font class=boldText><%=appName%></font> - <a href="http://<%=Request.ServerVariables("SERVER_NAME")%>" target="_blank"><%=Request.ServerVariables("SERVER_NAME")%></a></td>
		<td align=right><font class=boldText>v<%=appVersion%></font> - <%=Date()%> </td>
	</tr>
</table>
<table cellspacing=0 cellpadding=1 border=0 width=100%>
	<tr class=lightRow height=60>
		<td>
			<div style="font-size:12pt;"> <%=iconFolderOpenBig%> <font class=boldText><%=folder.Name%></font></div>
			<div style="font-size:8pt;">  <%=folder.path%></div>
			<%If VirtualPath(destFolder)<>"" Then%>
				<div style="font-size:8pt;">  (<a href="<%=VirtualPath(destFolder)%>" target="_blank"><%=VirtualPath(destFolder)%></a>)</div>
			<%Else%>
				<div style="font-size:8pt;">  (Net ba&#240;lant&#253;s&#253; yok)</div>
			<%End If%>
		</td>
		<td nowrap>
			<font class=boldText><%=folder.subfolders.count%></font> Klasör<br>
			<font class=boldText><%=folder.files.count%></font> Dosya
		</td>
		<td nowrap>
			Toplam Boyut: <font class=boldText><%If err.Number<>0 or (not calculateTotalSize) Then Response.Write "N/A" Else Response.Write FormatSize(folder.size)%></font>
		</td>
		<td>
			<a href="javascript:Command('Refresh', '');"><%=iconRefresh%></a> 
			<a href="javascript:Command('NewFile', '');"><%=iconCreateFile%></a> 
			<a href="javascript:Command('NewFolder', '');"><%=iconCreateFolder%></a> 
			<a href="javascript:Command('Upload', '');"><%=iconUpload%></a> 				
<%If wexPassword <> "" Then%>
			<a href="javascript:Command('Logout', '');"><%=iconLogout%></a>
<%
  rs.Close
  conn.close
End If%>
			<br><input name=wexMessage type=text class=formClass size=20 value="<%=server.HTMLEncode(wexMessage)%>" Salt okunur>
		</td>
		<td> </td>
	</tr>
	<tr class=titleRow>
		<td> <font class=boldText>&#221;sim</font></td>
		<td> <b>Boyut</b></td>
		<td> <font class=boldText>Tür</font></td>
		<td> <b>Düzenleme</b></td>
		<td> </td>
	</tr>
<%
	rowType = "darkRow"

	If len(destFolder) > len(wexRootPath) Then
%>
	<tr class=<%=rowType%>><td> <a href="javascript:Command('LevelUp','')"><%=iconFolderUp%></a> <a href="javascript:Command('LevelUp','')">..</a></td><td> </td><td> </td><td> </td><td> </td></tr>
<%
		rowType = "lightRow"
	End If
	
	listed = 0
	If (folder.subfolders.Count + folder.files.Count) = 0 Then
		' Do nothing when error occurs
	Else
		For each item in folder.subfolders
			If showHiddenItems or not item.Attributes and 2 Then
				listed = listed + 1
%>
	<tr class=<%=rowType%>><td> <%=GetIcon(item.Name, true)%> <a href="javascript:Command('OpenFolder','<%=item.Name%>')"><%=item.Name%></a></td><td> <%If calculateFolderSize Then Response.write FormatSize(item.Size)%></td><td> <%=item.Type%></td><td nowrap> <%=item.DateLastModified%></td><td> <a href="javascript:Command('DeleteFolder','<%=item.Name%>')"><%=iconDelete%></a></td></tr>
<%
				If rowType = "darkRow" Then rowType = "lightRow" Else rowType = "darkRow"
			End If
		Next

		For each item in folder.files
			If showHiddenItems or not item.Attributes and 2 Then
				listed = listed + 1
%>
	<tr class=<%=rowType%>><td> <%=GetIcon(item.Name, false)%> <a href="<%If VirtualPath(destFolder)<>"" Then Response.write VirtualPath(destFolder) & item.Name Else Response.Write "javascript:Command('NoDownload')"%>"><%=item.Name%></a></td><td> <%=FormatSize(item.Size)%></td><td> <%=item.Type%></td><td nowrap> <%=item.DateLastModified%></td><td> <a href="javascript:Command('DeleteFile','<%=item.Name%>')"><%=iconDelete%></a></td></tr>
<%
				If rowType = "darkRow" Then rowType = "lightRow" Else rowType = "darkRow"
			End If	
		Next
	End If
%>
</table>
<table cellspacing=0 cellpadding=0 border=0 width=100%>
	<tr class=titleRow>
		<td> </td>
	</tr>
</table>
</form>
<%
		If wexMessage="" Then 
			If (folder.subfolders.Count + folder.files.Count) <> listed Then
				wexMessage = "Listelenen " & listed & " n&#253;n " & (folder.subfolders.Count + folder.files.Count) & " dosya , " & (folder.subfolders.Count + folder.files.Count - listed) & "  dosya gizli..."
			Else
				wexMessage = "Listelenen " & (folder.subfolders.Count + folder.files.Count) & " dosya..."
			End If
			Response.Write "<script language=""javascript"">document.forms.formGlobal.wexMessage.value='" & wexMessage & "'</script>"
		End If
	End Sub

	' Login Ekran&#253;
	Sub	Login	
		If Request.Form("command") = "Login" Then
		    rs.MoveFirst 
		    do until rs.EOF 
		     If Request.Form("us") = rs("Afusername") Then
		      session("user")=rs("Afusername")
			    If Request.Form("pwd") =rs("Password") Then
			       yaz=rs("Write")
			       oku=rs("read")
			       dept=rs("dept")
			       session("dept")=dept
			       session("user")=rs("Afusername")		
			       if session("user")="takyonxxx" then
			       	session("admin")=true
			       end if
			       if rs("activation")=1 and yaz=1 and oku=1 or session("admin")=true then				            
						Session(wexId & "Login") = true
						Response.Redirect "indexwrite.Asp"			   
					elseif rs("activation")=1 and oku=1 then
						Session(wexId & "Login") = true
						Response.Redirect "indexread.Asp"	
					else	
				   Response.Redirect "yetkiyok.asp"		   
				   end if
				Exit Sub
			   End if
			End If
			rs.MoveNext 
			loop		
		 wexMessage="Yanlis Sifre veya Kullanici Adi!"	
	   End If		
		HtmlHeader appName, wexCharSet
		If(wexMessage<>"") Then Response.Write "<script language=""javascript"">alert('" & wexMessage & "');</script>"
        %>
<form name=formBuffer method=post action="<%=scriptName%>" onSubmit="javascript:return(Check());">
<table border=0 cellspacing=0 cellpadding=0 width=400 align=center>
	<tr><td><br><br><br></td></tr>
	<tr><td>
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr class=titleRow>
				<td align=left>
					 <font class=boldText>Login</font>
				</td>
			</tr>
		</table>
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr align=center class=lightRow>
				<td>
					<br>
					<font class=boldText> <%=appName%>  <%=appVersion%> 'a Ho&#254;geldiniz</font>
					<br><br>
					<table cellspacing=0 cellpadding=5 border=0 class=loginRow>
						<tr>
							<td align=left> <font class=boldText>Kullanici Adi</font></td>
							<td align=center><input  type="text" class=formClass name=us value="" size=21></td>
						</tr>						
						<tr>
							<td align=left> <font class=boldText>&#222;ifre</font></td>
							<td align=center><input  type="password" class=formClass name=pwd value="" size=21></td>
						</tr>
						<tr>
							<td align=right><input type=submit name=submitter value="Giri&#254;" class=formClass></td>
						</tr>
					</table>
					<br><br> Tekersan Bilgi Sistemleri<a href="http://tjfabsr3/tekintranet/ti_anasayfa.asp">
                    Web Site</a> <br>
				</td>
			</tr>
		</table>
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr class=titleRow>
				<td align=center> </td>
			</tr>
		</table>
	</td></tr>
</table>
<input type="hidden" name=command value="Login">
</form>
<script language="javascript">document.forms.formBuffer.pwd.focus();</script>
<%	
		HtmlFooter
		Response.End 
	End Sub
	
	' Tekrar Giri&#254; Mesaj&#253;
	Sub PopupRelogin
		Response.Write "<html><head>"
		Response.Write "<title>Web Gezgini - Mesaj</title>"
		Response.Write "<style>A{FONT-WEIGHT: bold; COLOR: #99ccff; TEXT-DECORATION: none}"
		Response.write "A:hover{COLOR: #ccffff; TEXT-DECORATION: none }"
		Response.Write "A:visited{TEXT-DECORATION: none}"
		Response.write "A:active {COLOR: #ccffff; TEXT-DECORATION: none}</style>"
		Response.Write "</head><body style=""BACKGROUND-COLOR: #003366"">"
		Response.Write "<div style=""COLOR: white; FONT-FAMILY: Verdana,Tahoma,Arial,Helvetica; FONT-SIZE: 10pt; FONT-WEIGHT: bold;"">"
		Response.Write appName & " oturum kaybedildi lütfen "
		Response.write "<a href=""javascript:opener.Command('Refresh'); window.close();"">Tekrar giri&#254; yap&#253;n</a>."
		Response.Write "</div></body></html>"
		Response.End 
	End Sub
	
	' Checks if there is a valid login
	Function Secure()
		If wexPassword = "" Then
			Secure = true
		Else
			If Session(wexId & "Login") Then Secure = true Else Secure = false
		End If
	End Function
		
	' Oturum kapama k&#253;sm&#253;
	Sub Logout
		Session(wexId & "Login") = false
		session("folderpath")=false
		session("dept")=false
		Session("admin") = false
		Login
	End Sub
		
	' Dosya ikonuna geri döner
	Function GetIcon(fileName, isFolder)
		Dim ext
		If isFolder Then
			GetIcon = "<a href=""javascript:Command('FolderDetails', '" & fileName & "');"">" & iconFolder & "</a>"
		Else
			ext = FSO.GetExtensionName(fileName)
			If InStr(1,editableExtensions, "*" & ext & "*", 1) <> 0 Then
				GetIcon = "<a href=""javascript:Command('Edit', '" & fileName & "');"">" & iconFileEditable & "</a>"
			ElseIf InStr(1,viewableExtensions, "*" & ext & "*", 1) <> 0 Then
				GetIcon = "<a href=""javascript:Command('View', '" & fileName & "');"">" & iconFileViewable & "</a>"
			Else
				GetIcon = "<a href=""javascript:Command('FileDetails', '" & fileName & "');"">" & iconFile & "</a>"
			End If
		End If
	End Function
	
	' Dosya format ve boutlar&#253;
	Function FormatSize (givenSize)
		If (givenSize < 1024) Then
			FormatSize = givenSize & " B"
		ElseIf (givenSize < 1024*1024) Then
			FormatSize = FormatNumber(givenSize/1024,2) & " KB"
		ElseIf (givenSize < 1024*1024*1024) Then
			FormatSize = FormatNumber(givenSize/(1024*1024),2) & " MB"
		Else
			FormatSize = FormatNumber(givenSize/(1024*1024*1024),2) & " GB"
		End If
	End Function

	' bb
	Function FixPath(path, slash)
		If Right(path, 1) <> slash Then
            FixPath = path & slash
        Else
			FixPath = path
        End If
	End Function

	' Fiziksel dizine çevirir
	Function RealizePath(thePath)
		Dim path
		path = replace(thePath,"/","\")
		If left(path,1) = "\" Then
			on error resume next
			RealizePath = FixPath(server.MapPath(path),"\")
			If err.Number<>0 Then RealizePath = thePath
		Else
			If InStr(1,path, ":", 1) <> 0 Then
				RealizePath = FixPath(path,"\")
			Else
				RealizePath = thePath & "?"
			End If
		End If
	End Function	

	' cc
	Function VirtualPath(thePath)
		Dim webRoot, path
		webRoot = FixPath(server.MapPath("/"),"\")
		path = FixPath(thePath,"\")
		VirtualPath = ""
		If left(wexRoot,1) = "/" Then
			VirtualPath = FixPath(wexRoot, "/")
			VirtualPath = VirtualPath & right(path, len(path) - len(wexRootPath))
			VirtualPath = replace(VirtualPath, "\", "/")
			VirtualPath = FixPath(VirtualPath,"/")
		ElseIf left(lcase(path), len(webRoot)) = lcase(webRoot) Then
			VirtualPath = "/" & right(path, len(path) - len(webRoot))
			VirtualPath = replace(VirtualPath, "\", "/")
			VirtualPath = FixPath(VirtualPath,"/")
		End If
	End Function
	
	' dd
	Function SecureFileName(name)
		SecureFileName = replace(name,"/","?")
		SecureFileName = replace(SecureFileName,"\","?")
	End Function

	' Yeni dosya veya klasör olu&#254;turmak
	Function CreateItem()
		Dim itemType, itemName, itemPath
		itemType = Request.Form("command")
		itemName = SecureFileName(Request.Form("parameter"))
		itemPath = destFolder & itemName

		on error resume next
		
		Select Case itemType
			Case "NewFolder"
				If (FSO.FolderExists(itemPath) = false and FSO.FileExists(itemPath) = false ) Then 
					FSO.CreateFolder(itemPath)
					If (err.Number <> 0 ) Then 
						CreateItem = "Klasör olu&#254;turulam&#253;yor""" & itemName & """, bir hata olu&#254;tu..." 
					Else
						CreateItem = "Bu klasör olu&#254;turuldu""" & itemName & """..."
					End If
				Else
					CreateItem = "Klasör olu&#254;turulam&#253;yor """ & itemName & """, ayn&#253; isimde ba&#254;ka bir klasör veya dosya var..."
				End If
			Case "NewFile"
				If (FSO.FolderExists(itemPath) = false and FSO.FileExists(itemPath) = false ) Then 
					FSO.CreateTextFile(itemPath)
					If (err.Number <> 0 ) Then 
						CreateItem = "Dosya olu&#254;turulam&#253;yor""" & itemName & """, bir hata olu&#254;tu..."
					Else
						CreateItem = "Dosya olu&#254;turuldu""" & itemName & """..."
					End If
				Else 
					CreateItem = "Dosya olu&#254;turulam&#253;yor""" & itemName & """, ayn&#253; isimde ba&#254;ka bir klasör veya dosya var..."
				End IF
		End Select
	End Function
	
	' Deletes a folder or a file
	Function DeleteItem
		Dim itemType, itemName, itemPath
		itemType = Request.Form("command")
		itemName = SecureFileName(Request.Form("parameter"))
		itemPath = destFolder & itemName

		on error resume next
		
		Select Case itemType
			Case "DeleteFolder"
				FSO.DeleteFolder itemPath, true
				If (err.Number <> 0 ) Then 
					DeleteItem = "Klasör silinemiyor""" & itemName & """, bir hata olu&#254;tu..." 
				Else
					DeleteItem = "Klasör silindi """ & itemName & """..."
				End If
			Case "DeleteFile"
				FSO.DeleteFile itemPath, true
				If (err.Number <> 0 ) Then 
					DeleteItem = "Dosya silinemiyor """ & itemName & """, bir hata olu&#254;tu..." 
				Else
					DeleteItem = "Dosya Silindi """ & itemName & """..."
				End If
		End Select
	End Function
	
	' Web Gezgini By isa SARI
	Sub Editor
		Dim fileName, filePath, file
		
		If not Secure() Then PopupRelogin

		on error resume next

		Select Case Request.Form("subcommand")
			Case "Save", "SaveAs"
				fileName = SecureFileName(Request.Form("parameter"))
				filePath = destFolder & fileName
				Set file = FSO.OpenTextFile (filePath,2,true,0)
				If (err.Number<>0) Then 
					wexMessage = "Dosyaya yaz&#253;lam&#253;or""" & fileName & """, eri&#254;im engellendi!"
					err.Clear
				Else
					file.write Request.Form("content")
				End If
				Set file = Nothing
				Set file = FSO.OpenTextFile (filePath,1,false,0)
			Case Else
				fileName = SecureFileName(Request.Form("parameter"))
				filePath = destFolder & fileName
				
				If not FSO.FileExists(filePath) Then
					wexMessage = "&#222;u dosya """ & fileName & """ kay&#253;p"
					Set file = FSO.CreateTextFile (filePath, false, false)
					If err.Number<>0 Then 
						wexMessage = wexMessage & ", yeni dosya olu&#254;turulam&#253;yor."
						err.Clear 
					Else
						wexMessage = wexMessage & ", yeni dosya olu&#254;turuldu."
					End If
				Else
					Set file = FSO.OpenTextFile (filePath,1,false,0)
					If err.Number<>0 Then 
						wexMessage = "Dosya okunam&#253;yor """ & fileName & """, eri&#254;im engellendi!"
						err.Clear 
					End If
				End If
		End Select
		
		HtmlHeader appName, wexCharSet
		If(wexMessage<>"") Then Response.Write "<script language=""javascript"">alert('" & wexMessage & "');</script>"
%>
<form name=formBuffer method=post action="<%=scriptName%>">
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr class=titleRow>
				<td align=left>
					 <font class=boldText>Dosya Düzenleniyor</font> - <%=fileName%>
				</td>
			</tr>
		</table>
		<table border=0 cellspacing=0 cellpadding=0 width=100% height=90%>
			<tr align=center class=lightRow>
				<td valign=middle>
<textarea name=content class=formClass rows=22 cols=46 style="width:580; height:370;" wrap="off">
<%=Server.HTMLEncode(file.ReadAll)%></textarea>
				</td>
			</tr>
		</table>
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr class=titleRow>
				<td align=center>					
					<a href="javascript:EditorCommand('Save');">Kaydet</a> | <a href="javascript:EditorCommand('SaveAs');">Fakl&#253; Kaydet</a> | <a href="javascript:EditorCommand('Reload');">Tekrar Yükle</a> | <a href="javascript:EditorCommand('Info');">Bilgi</a> | <a href="javascript:this.close();">Kapat</a>
				</td>
			</tr>
		</table>
<%
		Set file = Nothing
		Set file = FSO.GetFile (filePath)
%>
<input type="hidden" name=command value="Edit">
<input type="hidden" name=subcommand value="">
<input type="hidden" name=parameter value="<%=fileName%>">
<input type="hidden" name=folder value="<%=Request.Form("folder")%>">
<input type="hidden" name=info value="Boyut: <%=FormatSize(file.Size)%>|Tür: <%=file.Type%>|Olu&#254;turma: <%=file.DateCreated%>|Son eri&#254;im: <%=file.DateLastAccessed%>|Son düzenleme: <%=file.DateLastModified%>">
</form>
<%
		Set file = Nothing
		HtmlFooter
		Response.End 
	End Sub

	' Web Gezgini görüntüleme
	Sub Viewer
		Dim fileName, filePath, file, imageSrc

		If not Secure() Then PopupRelogin

		on error resume next
		fileName = Request.Form("parameter")
		filePath = destFolder & fileName
		imageSrc = replace(VirtualPath(destFolder) & fileName, " ", "%20")

		HtmlHeader appName, wexCharSet
%>
<form name=formBuffer method=post action="<%=scriptName%>">
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr class=titleRow>
				<td align=left>
					 <font class=boldText>Dosya Görüntüleniyor</font> - <%=fileName%>
				</td>
			</tr>
		</table>
		<table border=0 cellspacing=0 cellpadding=0 width=100% height=90%>
			<tr align=center class=lightRow>
				<td valign=middle>
					<img src="<%=imageSrc%>">
				</td>
			</tr>
		</table>
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr class=titleRow>
				<td align=center>					
					<a href="javascript:ViewerCommand('Reload');">Tekrar Yükle</a> | <a href="javascript:ViewerCommand('Info');">Bilgi</a> | <a href="javascript:this.close();">Kapat</a>
				</td>
			</tr>
		</table>
<%
		Set file = FSO.GetFile (filePath)
%>
<input type="hidden" name=command value="View">
<input type="hidden" name=subcommand value="Refresh">
<input type="hidden" name=parameter value="<%=fileName%>">
<input type="hidden" name=folder value="<%=Request.Form("folder")%>">
<input type="hidden" name=info value="Boyut: <%=FormatSize(file.Size)%>|Tür: <%=file.Type%>|Olu&#254;turma: <%=file.DateCreated%>|Son Eri&#254;im: <%=file.DateLastAccessed%>|Son Düzenleme: <%=file.DateLastModified%>">
</form>
<%
		Set file = Nothing
		HtmlFooter
		Response.End 
	End Sub

	' Detaylar
	Sub Details
		Dim fileName, filePath, file
		
		If not Secure() Then PopupRelogin
		
		on error resume next
		fileName = Request.Form("parameter")
		filePath = destFolder & fileName

		HtmlHeader appName, wexCharSet
%>
<form name=formBuffer method=post action="<%=scriptName%>">
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr class=titleRow>
				<td align=left>
					 <font class=boldText>Detaylar</font> - <%=fileName%>
				</td>
			</tr>
		</table>
		<table border=0 cellspacing=0 cellpadding=0 width=100% height=80%>
			<tr align=center class=lightRow>
				<td valign=middle>
<%
		If Request.Form("command") = "FileDetails" Then
				Set file = FSO.GetFile (filePath)
		Else
				Set file = FSO.GetFolder (filePath)
		End If
%>
				<table border=0 cellspacing=5 cellpadding=0>
					<tr><td><font class=boldText>Boyut:</font></td><td><%=FormatSize(file.Size)%></td></tr>
					<tr><td><font class=boldText>Tür:</font></td><td><%=file.Type%></td></tr>
					<tr><td><font class=boldText>Olu&#254;turma:</font></td><td><%=file.DateCreated%></td></tr>
					<tr><td><font class=boldText>Son Eri&#254;im:</font></td><td><%=file.DateLastAccessed%></td></tr>
					<tr><td><font class=boldText>Son Düzenleme:</font></td><td><%=file.DateLastModified%></td></tr>
				</table>
<%
		Set file = Nothing
%>
				</td>
			</tr>
		</table>
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr class=titleRow>
				<td align=center>					
					<a href="javascript:this.close();">Kapat</a>
				</td>
			</tr>
		</table>
<input type="hidden" name=command value="<%=Request.Form("command")%>">
<input type="hidden" name=parameter value="<%=fileName%>">
<input type="hidden" name=folder value="<%=Request.Form("folder")%>">
</form>
<%
		HtmlFooter
		Response.End 
	End Sub
	
	' Uploads a file
	Sub Upload
		If not Secure() Then PopupRelogin

		If Request.QueryString("command")="DoUpload" Then 
			destFolder = wexRootPath & Request.QueryString("folder")
			destFolder = FixPath(destFolder, "\")
			If len(destFolder) < len(wexRootPath) Then Response.End 
		End If
		
		HtmlHeader appName, wexCharSet
%>
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr class=titleRow>
				<td align=left>
					 <font class=boldText>Upload</font> - <%=FSO.GetBaseName(destFolder)%>
				</td>
			</tr>
		</table>
		<table border=0 cellspacing=0 cellpadding=0 width=100% height=80%>
			<tr align=center class=lightRow>
				<td valign=middle>
					<font class=boldText>
<%
		If Request.QueryString("command")="DoUpload" Then
	
			Dim Uploader
			Set Uploader = New classUploader
	
			Uploader.Upload()
	
			If not Uploader.uploaded Then
				Response.Write "Dosya Gönderilmedi"
			Else
				If Uploader.uploadedFile.FileName="" Then
					Response.Write "Dosya Gönderilmedi"
				Else
					If Uploader.uploadedFile.Save(destFolder) Then
						Response.Write Uploader.uploadedFile.FileName & " gönderildi<br>"
						Response.Write FormatSize(Uploader.uploadedFile.FileSize) & " (" & Uploader.uploadedFile.FileSize & " byte) yaz&#253;ld&#253;<br>"
						Response.Write "<script language=""javascript"">opener.Command('Refresh');</script>"
					Else
						Response.Write Uploader.uploadedFile.FileName & " yaz&#253;lamad&#253;<br>"
					End If
				End If
			End If
%>
					</font>
					<form name=formBuffer method=post action="<%=scriptName%>">
						<input type=hidden name=command value="Upload">
						<input type=hidden name=folder value="<%=Request.QueryString("folder")%>">
					</form>
<%	
		Else
%>
					<form enctype="multipart/form-data" name=formBuffer method=post action="<%=scriptName%>?command=DoUpload&folder=<%=server.URLEncode(Request.Form("folder"))%>">
						<input type=file name=file class=formClass size="20">
					</form>
<%
		End If
%>					
				</td>
			</tr>
		</table>
		<table border=0 cellspacing=0 cellpadding=0 width=100%>
			<tr class=titleRow>
				<td align=center>					
					<a href="javascript:Upload();">Gönder</a> | <a href="javascript:this.close();">Kapat</a>
				</td>
			</tr>
		</table>
<%
		HtmlFooter
		Response.End 
	End Sub

	' ff
	Class classUploader
		Public uploaded
		Public uploadedFile
	
		Public Default Sub Upload()
			Dim biData, sInputName
			Dim nPosBegin, nPosEnd, nPos, vDataBounds, nDataBoundPos
			Dim nPosFile, nPosBound
	
			biData = Request.BinaryRead(Request.TotalBytes)
			nPosBegin = 1
			nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
			
			If (nPosEnd-nPosBegin) <= 0 Then Exit Sub
			 
			vDataBounds = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
			nDataBoundPos = InstrB(1, biData, vDataBounds)
			
			Do Until nDataBoundPos = InstrB(biData, vDataBounds & CByteString("--"))
				
				nPos = InstrB(nDataBoundPos, biData, CByteString("Content-Disposition"))
				nPos = InstrB(nPos, biData, CByteString("name="))
				nPosBegin = nPos + 6
				nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))
				sInputName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
				nPosFile = InstrB(nDataBoundPos, biData, CByteString("filename="))
				nPosBound = InstrB(nPosEnd, biData, vDataBounds)
				
				If nPosFile <> 0 And  nPosFile < nPosBound Then
					Dim sFileName
					Set uploadedFile = New classUploadedFile
					
					nPosBegin = nPosFile + 10
					nPosEnd =  InstrB(nPosBegin, biData, CByteString(Chr(34)))
					sFileName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
					uploadedFile.FileName = Right(sFileName, Len(sFileName)-InStrRev(sFileName, "\"))
	
					nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))
					nPosBegin = nPos + 14
					nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
					
					nPosBegin = nPosEnd+4
					nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
					uploadedFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
					
					If uploadedFile.FileSize > 0 Then uploaded = true Else uploaded = false
				End If

				nDataBoundPos = InstrB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)
			Loop
		End Sub

		' gg
		Private Function CByteString(sString)
			Dim index
			For index = 1 to Len(sString)
				CByteString = CByteString & ChrB(AscB(Mid(sString,index,1)))
			Next
		End Function

		' hh
		Private Function CWideString(bsString)
			Dim index
			CWideString =""
			For index = 1 to LenB(bsString)
				CWideString = CWideString & Chr(AscB(MidB(bsString,index,1))) 
			Next
		End Function
	End Class

	' Dosya bilgisi ta&#254;&#253;yan k&#253;s&#253;m
	Class classUploadedFile
		Public FileName, FileData
		
		Public Property Get FileSize()
			FileSize = LenB(FileData)
		End Property
	
		Public Function Save(path)
			Dim file
			Dim index
		
			If path = "" Or FileName = "" Then 
				Save = false
				Exit Function
			End If
			path = FixPath(path, "\")
		
			If Not FSO.FolderExists(path) Then
				Save = false
				Exit Function
			End If
		
			on error resume next
			Set file = FSO.CreateTextFile(path & FileName, True)
			
			For index = 1 to LenB(FileData)
			    file.Write Chr(AscB(MidB(FileData,index,1)))
			Next
	
			file.Close
			If err.Number<>0 Then
				Save = false
			Else
				Save = true
			End If
		End Function
	End Class
' ------------------------------------------------------------

' - Web Gezgini Genel -----------------------------------------
	Dim folder, destFolder

	wexRootPath = RealizePath(wexRoot)

	If Request.QueryString("command")="DoUpload" Then Upload()
	
	destFolder = wexRootPath & Request.Form("folder")
	destFolder = FixPath(destFolder, "\")
	If len(destFolder) < len(wexRootPath) Then Response.End 
	
	' Actions in the popup windows
	Select Case Request.Form("command")
		Case "Edit"
			Editor()
		Case "View"
			Viewer()
		Case "FileDetails", "FolderDetails"
			Details()
		Case "Upload"
			Upload()
	End Select
	
	' Ana pencere
	If not Secure() Then Login
	
	Select Case Request.Form("command")
		Case "NewFile", "NewFolder"
			wexMessage = CreateItem()
		Case "Logout"
			Logout()
		Case "DeleteFile", "DeleteFolder"
			wexMessage = DeleteItem()
		Case "OpenFolder"
			If Request.Form("folder") = "" Then
				destFolder = wexRootPath & Request.Form("parameter")
			Else	
				destFolder = wexRootPath & FixPath(Request.Form("folder"),"\") & Request.Form("parameter")
			End If
			destFolder = FixPath(destFolder, "\")
			If len(destFolder) < len(wexRootPath) Then Response.End 
		Case "LevelUp"
			destFolder = FSO.GetParentFolderName(destFolder)
			destFolder = FixPath(destFolder, "\")
			If len(destFolder) < len(wexRootPath) Then Response.End 
	End Select

	on error resume next
	Set folder = FSO.GetFolder(destFolder)
	if err.Number<>0 Then wexMessage = "Klasör Aç&#253;lam&#253;yor""" & destFolder & """"

	HtmlHeader appName, wexCharSet
	WriteListing (folder)
%>
<form method=post action="<%=scriptName%>" name=formBuffer>
	<input type=hidden name=command value="">
	<input type=hidden name=parameter value="">
	<input type=hidden name=virtual value="<%=VirtualPath(destFolder)%>">
	<input type=hidden name=folder value="<%=right(destFolder, len(destFolder)-len(wexRootPath))%>">
</form>

<%
	Set folder = Nothing
	HtmlCopyright
	HtmlFooter

%>


Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.