1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
function FolderExists(fn)
{
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try
{
var objShell = new ActiveXObject("Shell.Application");
var fso = new ActiveXObject("Scripting.FileSystemObject");
return fso.FolderExists(fn);
}
catch(e) { }
/*@end @*/
return false;
}
function FileExists(fn)
{
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
return fso.FileExists(fn);
}
catch(e) { }
/*@end @*/
return true;
}
function TryShellExec(fn)
{
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try
{
var objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute(fn, "", "", "open", 1);
return true;
}
catch(e) { }
/*@end @*/
return false;
}
function parser(fn)
{
var X, Y, sl, a, ra, re;
ra = /:/;
a = location.href.search(ra);
if (a == 2)
X = 14;
else
X = 7;
sl = "\\";
Y = location.href.lastIndexOf(sl) + 1;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
}
catch(e)
{
if (fn.substring(0, 3) == "../")
{
fn = fn.substring(3);
}
}
@else @*/
if (fn.substring(0, 3) == "../")
{
fn = fn.substring(3);
}
/*@end @*/
lfn = location.href.substring(X, Y) + fn;
re = /%20/g;
lfn = lfn.replace(re, " ");
re = /\//g;
lfn = lfn.replace(re, "\\");
if (FolderExists(lfn))
{
if (!TryShellExec(lfn))
{
var objShell = new ActiveXObject("Shell.Application");
objShell.Open(lfn);
}
}
else if (FileExists(lfn))
{
execed = false;
htmlre = /\.html?$/;
txtre = /\.txt$/;
if (!lfn.match(htmlre) && !lfn.match(txtre))
{
execed = TryShellExec(lfn);
}
if (!execed)
{
re = /\\/g;
lfn = lfn.replace(re, "/");
re = /\ /g;
lfn = lfn.replace(re, "%20");
location.href = 'file:///' + lfn;
}
}
else if (fn.substring(0, 3) == "../")
{
parser(fn.substring(3));
}
else
{
alert(fn + " doesn't exist");
}
}
|