-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathte_functions.asp
More file actions
245 lines (224 loc) · 7.64 KB
/
te_functions.asp
File metadata and controls
245 lines (224 loc) · 7.64 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<%
'==============================================================
' TableEditoR 0.81 Beta
' http://www.2enetworx.com/dev/projects/tableeditor.asp
'--------------------------------------------------------------
' File: te_functions.asp
' Description: function for TableEditor
' Initiated By Rami Kattan on May 31, 2002
'--------------------------------------------------------------
' Copyright (c) 2002, 2eNetWorX/dev.
'
' TableEditoR is distributed with General Public License.
' Any derivatives of this software must remain OpenSource and
' must be distributed at no charge.
' (See license.txt for additional information)
'
' See Credits.txt for the list of contributors.
'
' Change Log:
'--------------------------------------------------------------
'==============================================================
sub allTablesCombo() 'Database Selector
if bComboTables and bJSEnable then
iCID = cint(request("cid"))
response.write "<select id=""allDBs"" name=""allDBs"" class=""smallertext"" onchange=""cboChangeDB()"">"
if bAdmin and iCID = 0 then response.write "<option value=""0"">Administrator Database"
for lv = 1 to iTotalConnections
response.write "<option value=""" & lv & """"
if iCID = lv then response.write " selected"
response.write ">" & arrDesc(lv) & vbCrLf
next
response.write "</select>"
else
response.write "<a href=""te_listtables.asp?cid=" & request("cid") &""">" & arrDesc(request("cid")) & "</a>"
end if
end sub
sub allTablesCombo2(lConnID) 'Table Selector
if bComboTables and bJSEnable then
conn.Open arrConn(lConnID)
set rs = conn.OpenSchema(adSchemaTables)
response.write "<select name=""allTables"" id=""allTables"" class=""smallertext"" onchange=""ChangeTable()"">"
response.write "<option value='<<'><- Back"
while not rs.eof
if rs("table_type") = "TABLE" then
response.write "<option value=""" & rs("table_name") & """"
if request("tablename") = rs("table_name") then response.write " selected"
response.write ">" & rs("table_name") & vbCrLf
end if
rs.movenext
wend
response.write "</select>"
rs.close
conn.close
else
response.write sTableName
end if
end sub
Sub isPerPage(InValue, ThisValue)
if cint(InValue) = cint(ThisValue) then Response.Write " Selected"
End sub
function isSelected(InValue, ThisValue)
if cint(InValue) = cint(ThisValue) then isSelected = " Selected"
end function
function MakeURL(Data)
UrlData = Data
if ConvertURL then
UrlData = edit_hrefs(UrlData, 1)
UrlData = edit_hrefs(UrlData, 2)
'UrlData = edit_hrefs(UrlData, 3)
UrlData = edit_hrefs(UrlData, 4)
UrlData = edit_hrefs(UrlData, 5)
UrlData = edit_hrefs(UrlData, 6)
end if
MakeURL = UrlData
end function
function SQLEncode(strTheText)
SQLEncode = "'" & Replace (strTheText, "'", "''" ) & "'"
end function
function GetRandomChars(width)
Randomize
data = ""
while len(data) < width
data = data & chr(Int((80 * Rnd) + 47))
wend
GetRandomChars = data
end function
function GetSecurityID(ForAction)
session("TableEditor_" & ForAction) = GetRandomChars(6) & right(Session.SessionID,4) & GetRandomChars(6)
GetSecurityID = session("TableEditor_" & ForAction)
end function
function ValidSecurityID(ForAction, SecID)
if session("TableEditor_" & ForAction) = SecID then
ValidSecurityID = true
else
ValidSecurityID = false
end if
end function
function FormatXML(data)
if isNumeric(left(data,1)) then
data = FormatNumericXML(data)
end if
data = replace(data, "?", "_x003F_")
data = replace(data, " ", "_x0020_")
data = replace(data, "/", "_x002F_")
data = replace(data, "=", "_x003D_")
data = replace(data, "%", "_x0025_")
slash = "\"
data = replace(data, slash, "_x005C_")
data = replace(data, "~", "_x007E_")
data = replace(data, "@", "_x0040_")
data = replace(data, "#", "_x0023_")
data = replace(data, "$", "_x0024_")
data = replace(data, "%", "_x0025_")
data = replace(data, "^", "_x005E_")
data = replace(data, "&", "_x0026_")
data = replace(data, "*", "_x002A_")
data = replace(data, "(", "_x0028_")
data = replace(data, ")", "_x0029_")
data = replace(data, "+", "_x002B_")
data = replace(data, "{", "_x007B_")
data = replace(data, "}", "_x007D_")
data = replace(data, "|", "_x007C_")
data = replace(data, "'", "_x0027_")
data = replace(data, "<", "_x003C_")
data = replace(data, ">", "_x003E_")
data = replace(data, ",", "_x002C_")
data = replace(data, ";", "_x003B_")
FormatXML = data
end function
function FormatNumericXML(data)
StrLeft = Left(data, 1)
StrRight = Right(data, (len(data) - 1))
ReturnValue = "_x003" & StrLeft & "_" & StrRight
FormatNumericXML = ReturnValue
end function
function FormatXMLRev(data)
if left(data,5) = "_x003" then
if isNumeric(mid(data,6,1)) then
data = mid(data,6,1) & right(data, len(data)-7)
end if
end if
data = replace(data, "_x003F_", "?")
data = replace(data, "_x0020_", " ")
data = replace(data, "_x002F_", "/")
data = replace(data, "_x003D_", "=")
data = replace(data, "_x0025_", "%")
slash = "\"
data = replace(data, "_x005C_", slash)
data = replace(data, "_x007E_", "~")
data = replace(data, "_x0040_", "@")
data = replace(data, "_x0023_", "#")
data = replace(data, "_x0024_", "$")
data = replace(data, "_x0025_", "%")
data = replace(data, "_x005E_", "^")
data = replace(data, "_x0026_", "&")
data = replace(data, "_x002A_", "*")
data = replace(data, "_x0028_", "(")
data = replace(data, "_x0029_", ")")
data = replace(data, "_x002B_", "+")
data = replace(data, "_x007B_", "{")
data = replace(data, "_x007D_", "}")
data = replace(data, "_x007C_", "|")
data = replace(data, "_x0027_", "'")
data = replace(data, "_x003C_", "<")
data = replace(data, "_x003E_", ">")
data = replace(data, "_x002C_", ",")
data = replace(data, "_x003B_", ";")
FormatXMLRev = data
end function
function DataNeedCDATA(data)
need = false
if instr(data, "<") then need = true
if instr(data, "&") then need = true
DataNeedCDATA = need
end function
function LeadingZero(data, numdigits)
while len(data) < numdigits
data = "0" & data
wend
LeadingZero = data
end function
function IsObjInstalled(strClassString)
Err.clear
set oTest2 = Server.CreateObject(strClassString)
if err = 0 then
IsObjectInstalled = true
else
err.Clear
IsObjectInstalled = false
end if
set oTest2 = nothing
IsObjInstalled = IsObjectInstalled
end function
%>
<script language="javascript1.2" runat=server>
function edit_hrefs(s_html, type){
s_str = new String(s_html);
if (type == 1) { // Start with http://
s_str = s_str.replace(/\b(http\:\/\/[\w+\.]+[\w+\.\:\/\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
"<a href=\"$1\" target=\"_blank\">$1<\/a>");
}
if (type == 2) { // Start with https://
s_str = s_str.replace(/\b(https\:\/\/[\w+\.]+[\w+\.\:\/\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
"<a href=\"$1\" target=\"_blank\">$1<\/a>");
}
if (type == 3) { // Start with file://
s_str = s_str.replace(/\b(file\:\/\/\/\w\:\\[\w+\/\w+\.\:\/\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
"<a href=\"$1\" target=\"_blank\">$1<\/a>");
}
if (type == 4) { // Start with www.
s_str = s_str.replace(/\b(www\.[\w+\.\:\/\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
"<a href=\"http://$1\" target=\"_blank\">$1</a>");
}
if (type == 5) { // email
s_str = s_str.replace(/\b([\w+\-\'\#\%\.\_\,\$\!\+\*]+@[\w+\.?\-\'\#\%\~\_\.\;\,\$\!\+\*]*)/gi,
"<a href=\"mailto\:$1\">$1</a>");
}
if (type == 6) { // Start with ftp://
s_str = s_str.replace(/\b(ftp\:\/\/[\w+\.]+[\w+\.\:\/\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
"<a href=\"$1\" target=\"_blank\">$1<\/a>");
}
return s_str;
}
</script>