View/Edit #12:add_connect_place

Switch to edit mode.

Name(s): add_connect_place
1:  !caller_perms().wizard && raise(E_PERM)
2:  {where} = args
3:  if (where == "")
4:    return
5:  endif
6:  dynamic = 0
7:  if (is_ip = $network:is_ip(where))
8:    where = $string_utils:from_list($list_utils:reverse($string_utils:explode(where, ".")), ".")
9:  endif
10: "Assume the IP is not dynamic unless otherwise implied to be."
11: if (`match((where_exp = $string_utils:explode(where, "."))[1], "[0-9][0-9]+") ! ANY => 0')
12:   "It has numbers in the first bit? Well that's an obvious tipoff of a dynamic IP"
13:   dynamic = 1
14: endif
15: site = ""
16: for chunk in ($list_utils:reverse(where_exp))
17:   site = tostr(chunk, site && ".", site)
18:   if (site in $network.static_domains)
19:     dynamic = 0
20:     break
21:     "No matter what."
22:   endif
23: endfor
24: "Ok, phase one is complete. We have determined whether the address is dynamic or not (Albeit in a simple sort of way)"
25: "Phase two, the construction of a new entry to merge the data of all addresses similar to this one (If there are any)."
26: done = 0
27: gathered = deletes = {}
28: for i in [1..length(places = this:all_connect_places())]
29:   if ((places_exp = $string_utils:explode(places[i], "."))[2..$] == where_exp[2..$])
30:     if (places_exp[1][1] == "[" && places_exp[1][$] == "]")
31:       "This has already been tagged as dynamic."
32:       gathered = {@$string_utils:explode(places_exp[1][2..$ - 1], "|"), @gathered}
33:       deletes = {@deletes, i}
34:     else
35:       gathered = {places_exp[1], @gathered}
36:       deletes = {i, @deletes}
37:     endif
38:   endif
39: endfor
40: for del in (deletes)
41:   places = listdelete(places, del)
42: endfor
43: gathered = setremove($list_utils:remove_duplicates(gathered), where_exp[1])
44: if (dynamic || length(where_exp[1]) > 160)
45:   where_exp[1] = "*"
46: elseif (gathered)
47:   where_exp[1] = tostr("[", $string_utils:from_list({@gathered, where_exp[1]}, "|"), "]")
48: endif
49: is_ip && (where_exp = $list_utils:reverse(where_exp))
50: where = $string_utils:from_list(where_exp, ".")
51: this:filewrite("all_connect_places", {@places, where})
52: this:filesetaccess("all_connect_places", "")
53: "This verb previously owned by Raptor (#6319), and chowned to $slacker upon dewizarding (Sat Aug 17 14:48:42 2002 MDT)."
54: "Last modified by whiz (#3135) on Sun Jan 13 11:41:12 2008 EST."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Slacker (#55)

You are not logged in.

[home | help | who | search | setup | code]