/* module Access - part Client */ /* by iri : http://www.irizone.net */ /* version 1.0 - june 2004 */ typeof listeSite = [S r1];; typeof nameSite = S;; var fileAccess = "locked/conf/fileAccess.txt";; /* fun [I] I */ fun register(i)= let localtime time -> [_ _ _ day month year _ _] in let strcatn (itoa day)::":"::(itoa month)::":"::(itoa year)::nil -> date in if i > (sizelist listeSite) then (_storepack strcatn nameSite::" "::date::nil fileAccess; 0) else let strextr nth_list listeSite i -> [ll nxt] in let ll -> [name nxt] in if !strcmp name nameSite then (set listeSite = replace_nth_in_list listeSite i strcatn nameSite::" "::date::nil; _storepack linebuild listeSite fileAccess; 0) else register i+1;; /* fun [S] [I I I] */ fun extractDate(date)= let strfind ":" date 0 -> r in let substr date r+1 strlen date -> s in let strfind ":" s 0 -> r2 in let substr s r2+1 strlen s -> year in let substr date 0 r -> day in let substr s 0 r2 -> month in [atoi day atoi month atoi year];; /* fun [S] I */ fun calcDate(date)= /* _showconsole;*/ let localtime time -> [_ _ _ day month year _ _] in let extractDate date -> [d m y] in /* _fooS strcatn ">>>>>>>>>>>>"::(itoa d)::"_"::(itoa m)::"_"::(itoa y)::"_"::date::nil*/ if (d != day) && (m != month) && (y != year) then _DMSevent this "last" strcatn (_loc this "introlast" nil)::" ":: (itoa if y > year then y-year else year-y)::" ":: (_loc this "year" nil)::" ":: (itoa if m > month then m-month else month-m)::" ":: (_loc this "month" nil)::" ":: (itoa if d > day then d-day else day-d)::" ":: (_loc this "day" nil):: nil nil else if (d != day) && (m != month) && (y == year) then _DMSevent this "last" strcatn (_loc this "introlast" nil)::" ":: (itoa if m > month then m-month else month-m)::" ":: (_loc this "month" nil)::" ":: (itoa if d > day then d-day else day-d)::" ":: (_loc this "day" nil):: nil nil else if (d != day) && (m == month) && (y == year) then if (day-d) == 1 then _DMSevent this "last" strcatn (_loc this "introlast" nil)::" ":: (_loc this "yesterday" nil):: nil nil else _DMSevent this "last" strcatn (_loc this "introlast" nil)::" ":: (itoa if d > day then d-day else day-d)::" ":: (_loc this "day" nil):: nil nil else if (d == day) && (m != month) && (y != year) then _DMSevent this "last" strcatn (_loc this "introlast" nil)::" ":: (itoa if y > year then y-year else year-y)::" ":: (_loc this "year" nil)::" ":: (itoa if m > month then m-month else month-m)::" ":: (_loc this "month" nil)::" ":: nil nil else if (d != day) && (m == month) && (y != year) then _DMSevent this "last" strcatn (_loc this "introlast" nil)::" ":: (itoa if y > year then y-year else year-y)::" ":: (_loc this "year" nil)::" ":: (itoa if d > day then d-day else day-d)::" ":: (_loc this "day" nil):: nil nil else if (d == day) && (m == month) && (y != year) then _DMSevent this "last" strcatn (_loc this "introlast" nil)::" ":: (itoa if y > year then y-year else year-y)::" ":: (_loc this "year" nil)::" ":: nil nil else if (d == day) && (m != month) && (y == year) then _DMSevent this "last" strcatn (_loc this "introlast" nil)::" ":: (itoa if m > month then m-month else month-m)::" ":: (_loc this "month" nil)::" ":: nil nil else _DMSevent this "last" strcatn (_loc this "introlast" nil)::" "::" ":: (_loc this "today" nil):: nil nil ;; /* fun [I] I */ fun searchLastAccess(i)= if i > (sizelist listeSite) then (_DMSevent this "last" (_loc this "newaccess" nil) nil; 0) else let strextr nth_list listeSite i -> [ll nxt] in let ll -> [name[date _]] in if !strcmp name nameSite then (calcDate date; 0) else searchLastAccess i+1;; /* fun [DMI S S [User r1] Tag] I */ fun show(from, action, param, others, tag)= searchLastAccess 0; register 0;; /* fun [DMI S S [User r1] Tag] I */ fun forceRegister(from, action, param, others, tag)= register 0;; /* fun [S] I */ fun IniDMI(param)= set listeSite = lineextr _getpack _checkpack fileAccess; set nameSite = param; _DMSdefineActions this ["getLast" @show]:: ["register" @forceRegister]:: nil; 0;;