(let ((data "")(b "") (c '()) (v nil))
(while (read 0 b 1000) (extend data b))
(setf v (map (fn (x) (parse x "=")) (parse data "&")))
- (push (list 'control "ipset-control.lsp") c -1)
(push (list 'gap (int-parse (lookup "gap" v))) c -1)
(push (list 'clip (int-parse (lookup "clip" v))) c -1)
(for (i 1 7)
(mode-parse (lookup (string "mode" i) v))
(time-parse (lookup (string "start" i) v))
(time-parse (lookup (string "limit" i) v))
- (time-parse (lookup (string "end" i) v))
- ) c -1))
- (write-file "control.dat"
+ (time-parse (lookup (string "end" i) v)) )
+ c -1))
+ (write-file CONTROLFILE
(append (format "; Updated at %s\n(" (date))
(join (map string c) "\n " true)
")\n"))
(load "expand-string.lsp")
+(constant
+ 'CONTROLFILE SITE:control.dat
+ )
+
(setf UPDATE "")
(when (= (env "REQUEST_METHOD") "POST")
)
(constant
- 'CONTROLFILE "control.dat"
'CONTROL (read-expr (read-file CONTROLFILE))
'GAP (or (lookup 'gap CONTROL) 5)
'CLIP (or (lookup 'clip CONTROL) 5)
- 'INCL (or (lookup 'control CONTROL) "ipset-control.lsp")
'TIMES (map (fn (n) (or (assoc n CONTROL) '(1 timed (7 0) (3 0) (19 0))))
(sequence 1 7))
- 'NET (or (lookup 'net CONTROL) "10.0.0.0/8")
)
(setf
DAYS '(0 "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun")
- incl-options '("ipset-control.lsp")
gap-options '(0 1 2 5 10 15 30)
clip-options '(0 200 500 800 1000 1200 1500 2000)
mode-options '("opened" "timed" "closed")
(define (set-usage-extra m)
(let ((h (/ m 60)))
(setf m (- m (* h 60)))
- (write-file "../control-extra.dat" (format "%d %d\n" h m))))
+ (write-file EXTRAFILE (format "%d %d\n" h m))))
(catch
(let ((data "")(b "") (c '()) (v nil))
(load "expand-string.lsp")
+(constant
+ 'USAGEFILE SITE:control.usage.dat
+ 'EXTRAFILE SITE:control.extra.dat
+ )
+
(when (= (env "REQUEST_METHOD") "POST")
(load "usage-extra.lsp")
)
-(define (get-remote-user) REMOTE_USER)
-
(constant
- 'ADMIN (member REMOTE_USER '("ralph" "lin"))
- 'USAGE (read-expr (read-file "usage.dat"))
- 'extra-options '(0 10 30 60)
- 'EXTRAFILE "control-extra.dat"
+ 'USAGE (read-expr (read-file USAGEFILE))
'EXTRATM (file-info EXTRAFILE 6)
- 'TM (date-value)
'EXTRA (and (regex "([0-9]+) ([0-9]+)" (or (read-file EXTRAFILE) "") 0)
(list (int $1 0 10) (int $2 0 10)))
+ 'TM (date-value)
+ 'extra-options '(0 10 30 60)
)
(define (tm2time tm)