-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathBOOL.CGI
More file actions
86 lines (69 loc) · 2.21 KB
/
BOOL.CGI
File metadata and controls
86 lines (69 loc) · 2.21 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
* * * Top of File * * *
/* COPYRIGHT 2021 BY MOSHIX
*
*
* Name: BOOL RETURNS OR AND XOR VALUES DECIMAL, HEX OR BIN
*
*
* Author: moshix
* Date: 2021-JUL-27 RAB, CROATIA
*
*
*/
'OUTPUT' "<html>"
Address "COMMAND" 'GLOBALV SELECT HTTPD GET VRM'
'OUTPUT' "<!CMS HTTPD" vrm "BOOL CGI>"
/* eliminate piggy-backed CP command trojans */
'ADDPIPE *.INPUT: | SPLIT AT' '001500'x '| *.INPUT:'
If rc ¬= 0 Then Exit rc
'PEEKTO RECORD'
If rc ¬= 0 Then record = ""
Parse Upper Var record arg1 arg2 .
Select /* arg1 */
When Abbrev("OR",arg1,1) Then call exe_or(arg2)
When Abbrev("AND",arg1,3) Then call exe_and(arg2)
When Abbrev("XOR",arg1,1) Then call exe_xor(arg2)
Otherwise CALL nonsense("NON EXISTING BOOLEAN")
End /* Select arg1 */
'OUTPUT' "<pre>"
'OUTPUT' "</pre>"
'OUTPUT' "</html>"
Exit
exe_or:
parse upper arg INPUT
SELECT
when left(INPUT,1) = "D" then do /* WE GOT A DECIMAL NUMBER */
count=LENGTH(INPUT) - 1
cont1 = RIGHT(INPUT,count) /* now we have the supposed number */
if DATATYPE(cont1,'N') /= 1 then call nonsense("NOT A VALID NUMBER")
cont1hex = C2X(cont1) /*we got a valid number, convert to hex */
cont1bin = X2B(cont1) /* convert to binary */
result = BITOR(cont1bin,cont1bin)
resultstr = B2X(result) /* convert back to string */
'OUTPUT' resultstr result
end
OTHERWISE
CALL nonsense("WRONG FORMAT")
END
return 0
exe_xor:
parse upper arg INPUT
SELECT
when left(INPUT,1) = "D" then do /* WE GOT A DECIMAL NUMBER */
count=LENGTH(INPUT) - 1
cont1 = RIGHT(INPUT,count) /* now we have the supposed number */
if DATATYPE(cont1,'N') /= 1 then call nonsense("NOT A VALID NUMBER")
cont1hex = C2X(cont1) /*we got a valid number, convert to hex */
cont1bin = X2B(cont1) /* convert to binary */
result = BITXOR(cont1bin,cont1bin)
/* resultstr = B2X(result) */ /* convert back to string */
'OUTPUT' resultstr result
end
OTHERWISE
CALL nonsense("WRONG FORMAT")
END
return 0
nonsense:
parse UPPER ARG VALUE
'OUTPUT' "EITHER NONSENSE REQUEST OR "VALUE
return 0