08-18-2017, 14:39 +0200
AuthorPost
thommey  01-12-2005, 22:15   | [TCL] Validate a date (format: dd.mm.yyyy) Jabber
(Administrator)
Member since 03/2004
62 Posts
Validate a date (format: dd.mm.yyyy)

                                                                                                                              
1
2
3
4
proc isdate {str} {
    if {![regexp {^(?:(?:[0-2]\d|30)\.(?:1\d|0[^2])|31\.(?:0[13578]|1[02])|([0-1]\d|2\d)\.02)\.(\d{4})$} $str "" t y] || ($t == 29 && ($y % 4 || ($y % 100 == 0 && $y % 400)))} { return 0 }
    return 1
}

It checks if a date is _100%_ valid (30.02.xxxx will not be accepted, 29.02.1000 will be 0, 29.02.2004 will be 1)

Search for IP:port in a string as word
                                                                                                                              
1
2
3
4
5
6
7
8
9
proc findgameserver {str} {
    global re_gameserver;
    set re_port {([1-9]\d{0,4}|(((([0-5]\d|6[0-4])\d|65[0-4])\d|655[0-2])\d|6553[0-5]))} # port 1-65535
    set re_ipblk_m {([1-9]|(\d|1\d|2[0-4])\d|25[0-5])} # all but last ip block 0-255
    set re_ipblk_e {((\d?|1\d|2[0-4])\d|25[0-4])} # last ip block 1-254
    if {![info exists re_gameserver]} { # cache compiled re globally
        set re_gameserver "\[\[:<:]]($re_ipblk_m\.){3}($re_ipblk_e):($re_port)\[\[:>:]]" }
    regexp -- $re_gameserver $str
}

This post was edited 3 times, last on 02-18-2010, 12:58 by thommey
thommey  01-21-2011, 22:10   Jabber
(Administrator)
Member since 03/2004
62 Posts
Created by Pixelz
                                                                                                                              
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Checks to see if the supplied cron is valid:
proc ::cron::valid {cron} {
    # This RE consists of 5 instances of the same basic RE. Each instance has
    # "\d+" substituted for a RE that validates the number sequence associated
    # with that instance.
    #
    # Base Regex, explained:
    # Match any number of comma separated items if there are any:
    # (0*\d+|\*)(-0*\d+)?(/\d+)?,)*
    # Match the last item in this instance:
    # (0*\d+|\*)(-0*\d+)?(/\d+)?\s
    regexp -expanded -- {
        # minute (0-59) - ([0-9]|[1-5][0-9])
        ^((0*([0-9]|[1-5][0-9])|\*)(-0*([0-9]|[1-5][0-9]))?(/\d+)?,)*
        (0*([0-9]|[1-5][0-9])|\*)(-0*([0-9]|[1-5][0-9]))?(/\d+)?\s
        # hour (0-23) - ([0-9]|1[0-9]|2[0-3])
        ((0*([0-9]|1[0-9]|2[0-3])|\*)(-0*([0-9]|1[0-9]|2[0-3]))?(/\d+)?,)*
        (0*([0-9]|1[0-9]|2[0-3])|\*)(-0*([0-9]|1[0-9]|2[0-3]))?(/\d+)?\s
        # day of month (1-31) - ([1-9]|[12][0-9]3[01])
        ((0*([1-9]|[12][0-9]3[01])|\*)(-0*([1-9]|[12][0-9]3[01]))?(/\d+)?,)*
        (0*([1-9]|[12][0-9]3[01])|\*)(-0*([1-9]|[12][0-9]3[01]))?(/\d+)?\s
        # month (1-12) - ([1-9]|1[0-2])
        ((0*([1-9]|1[0-2])|\*)(-0*([1-9]|1[0-2]))?(/\d+)?,)*
        (0*([1-9]|1[0-2])|\*)(-0*([1-9]|1[0-2]))?(/\d+)?\s
        # day of week (0-7) - [0-7]
        ((0*[0-7]|\*)(-0*[0-7])?(/\d+)?,)*
        (0*[0-7]|\*)(-0*[0-7])?(/\d+)?$
    } $cron
}

ampak  04-23-2013, 05:14   | Help with tcl code to find IP address from a URL
tcl_newbie
Member since 04/2013
1 Post
Location: California
Guys,

Need help with a a tcl code. Need to find out the ip address from a URL if it is present to do some activity.

The URLs will be of the form
<domain>?a=12345&d=somestring1(Note: "c=" not present)
<domain>?c=10.10.10.100&d=somestring1
<domain>?a=12345&b=somestring1&c=10.1.2.4&d=somestring2
<domain>?a=12345&c=10.1.2.4&b=somestring1&d=somestring2

Rules
1) The ip address is present after "c="
2) "c=" may or may not be present
3) If not present the condition should be handled gracefully
4) "c=" may be present anywhere except the end, it will always be "d=" at the end
5) It should only be "c=", something like "ac=" or "bc=" is not valid
6) "c=" will be preceded by either a "?" or "&"  only.

Any help with such a code will be helpful.
sedition  04-22-2014, 06:47   | helpme please
Member since 04/2014
2 Posts


someone can help with these regex codes to me
this is for protection anti dcc xploits

regex "\x01DCC (SEND|RESUME)[ ]+\"(.+ ){20}";
regex "\x01DCC (SEND|RESUME).{225}";


example;

bind CTCP - DCC handle:exploit
proc handle:exploit {nick uh hand dest key arg} {
  if {[regexp {(SEND|RESUME).*"(?:[^" ]*\s){32}.*$} $arg]} {
    set banmask *!*@[lindex [split $from @] 1]
    set chan [lindex [split $arg] 0]
    newchanban $chan $banmask Exploit "DCC Exploit" 1d
  }
}
Advanced options for this topic:

Ignore this topic (Do not list this topic in the "unread topics" search. You are currently not ignoring this topic.)
Hide this topic (Hidden topics are not displayed in the topics list. This topic is currently not hidden.)
Go to forum

Unclassified NewsBoard 1.5.3-d | © 2003-4 by Yves Goergen