KLoWnX — File Browser

klownX / klownX / flood_prot-2.mrc

flood_prot-2.mrc — 17.65 KB — Download this file

menu channel {
  KLøWñ× Flood Prot
  .$chk.ex(NEWFLOOD,$¥_l(#)) KLøWñ× Flood Prot # $+ :
  ..Current Status $+ $chr(58) $¥fld_chk.state(#) :halt 
  ..-
  .. x Click here to turn $¥fld_chk.reverse($¥fld_chk.state(#)) :{
    if (On isin $¥fld_chk.reverse($fld.settings-read($¥_l(#),State))) { 
      if ($fld.settings-read($¥_l(#),fld.c-lim)) { ¥fld_turn.ON # } 
      else { ¥fld_turn.ON # 2 5 5 d 2 10 30 0 }
      echo 2 -a Flood Protection for # is now on. 
    }
    elseif (Off isin $¥fld_chk.reverse($fld.settings-read($¥_l(#),State))) {
      ¥fld_turn.OFF # 
      echo 2 -a Flood Protection for # is now off.
    }
  }
  .. x Click here to erase/remove # $+ 's profile.:{
    remini $fld.settings-loc(#) #
    ¥fld_turn.OFF # 1
    echo 2 # Flood Protection profile for # has now been removed. If you were experiencing any abnormalities, turning it back on now should rectify them. 
  }
  ..-
  .. o Flood Protection trigger levels -> 
  ...Flood Protection will trigger $+ $chr(58) :halt
  ... o On ' $+ $¥fld_m-c(#,.fld.c-lim) $+ ' lines...:{
    set %fld_menu.t1 $?="Enter how many lines of Text/Action/Notice are needed to trigger flood protection (recommended value is 5)."
    if (%fld_menu.t1) { 
      echo 2 -a Flood Protection for # will now trigger on " $+ %fld_menu.t1 $+ " lines.
      set [ % $+ [ # ] $+ .fld.c-lim ] %fld_menu.t1 
      ¥fld_backup #
    } 
    unset %fld_menu.t1
  }
  ... o Within ' $+ $¥fld_m-c(#,.fld.c-time) $+ ' seconds...:{
    set %fld_menu.t2 $?="Enter how many seconds a user has to trigger flood protection if they exceed the set amount of lines above (recommended value is either 4 or 5)."
    if (%fld_menu.t2) { 
      echo 2 -a Flood Protection for # will now trigger in " $+ %fld_menu.t2 $+ " seconds. 
      set [ % $+ [ # ] $+ .fld.c-time ] %fld_menu.t2    
      ¥fld_backup #
    }
    unset %fld_menu.t2 
  }
  ... o Using the banmask ' $+ $¥fld_m-c(#,.fld.c-banmask) $+ ' ( $+ $mask(Nick!UserID@host.domain,$¥fld_m-c(#,.fld.c-banmask)) $+ ).:{
    set %fld_menu.t3 $?="Enter the address mask you'd like to ban. $crlf $+ $crlf $+  (Note: Unless you're on a network that uses '***' to mask the host part of an address (Nick!UserID@***.domain) - it would be unwise to use any other value than '2' here)."
    if (%fld_menu.t3) { 
      echo 2 -a Flood Protection for # will now use the address mask " $+ %fld_menu.t3 $+ " ( $+ $mask(Nick!UserID@host.domain,%fld_menu.t3) $+ ) when placing a ban on flooding clients.
      set [ % $+ [ # ] $+ .fld.c-banmask ] %fld_menu.t3 
      ¥fld_backup #
    }
    unset %fld_menu.t3
  }
  .. o Flood Repeat Protection trigger levels -> 
  ...Flood Repeat Protection will trigger $+ $chr(58) :halt
  ... On 3+ identical lines in under 6 seconds (can't change).:halt 
  ... Or 5+ identical lines in under 10 seconds (can't change).:halt
  ... o Using the banmask ' $+ $¥fld_m-c(#,.fld.rpt-c.banmask) $+ ' ( $+ $mask(Nick!UserID@host.domain,$¥fld_m-c(#,.fld.rpt-c.banmask)) $+ ).:{
    set %fld_menu.t3 $?="Enter the address mask you'd like to ban. $crlf $+ $crlf $+  (Note: Unless you're on a network that uses '***' to mask the host part of an address (Nick!UserID@***.domain) - it would be unwise to use any other value than '2' here)."
    if (%fld_menu.t3) { 
      echo 2 -a Flood Protection for # will now use the address mask " $+ %fld_menu.t3 $+ " ( $+ $mask(Nick!UserID@host.domain,%fld_menu.t3) $+ ) when placing a ban on flooding clients.
      set [ % $+ [ # ] $+ .fld.rpt-c.banmask ] %fld_menu.t3 
      ¥fld_backup #
    }
  }
  .. o /expiry.sync trigger levels -> 
  ...The expiry routine will run $+ $chr(58) :halt 
  ... o Every ' $+ $¥fld_t->conv($¥fld_m-c(#,.fld_expiry.time)) $+ '. :{ 
    set %fld_menu.t3 $?="Enter time in minutes (recommended value: 10-15 minutes plus on a small channel, $crlf $+ anywhere as low as 5 minutes on an extremely busy channel)." 
    if (%fld_menu.t3) { 
      if ($int(%fld_menu.t3) != %fld_menu.t3) { echo 2 -a Please enter an integer value (whole number, ie; no decimal points). | halt } 
      echo 2 -a Flood Protection: The expiry routine for # will now trigger every $¥fld_t->conv(%fld_menu.t3) $+ . 
      set [ % $+ [ # ] $+ .fld_expiry.time ] %fld_menu.t3 
      ¥fld_backup #
    }
  }
  ... o Or when the entry files reach ' $+ $¥fld_m-c(#,.fld_expiry.size) $+ KB'.: { 
    set %fld_menu.t3 $?="Enter size in kilobytes/KB (recommended value: 30KB. Note that Windows restricts $crlf $+ .ini files from growing larger than ~62.5KB, so it isn't recommended to set this over 55-60KB (30KB is a perfect level for all situations))."
    if (%fld_menu.t3) { 
      if ($int(%fld_menu.t3) != %fld_menu.t3) { echo 2 -a Please enter an integer value (whole number, ie; no decimal points). | halt } 
      echo 2 -a Flood Protection: The expiry routine for # will now trigger when the file reaches ' $+ %fld_menu.t3 KB $+ ' in size.  
      set [ % $+ [ # ] $+ .fld_expiry.size ] %fld_menu.t3 
      ¥fld_backup #
    }
  }
  ... ('whatever comes first' basis is used).:halt 
  .. o /kill users for flooding when un-op'd? ->
  ... Current setting $+ $chr(58) $¥fld_chk.existsB?(#) :halt
  ...-
  ... Click here to turn $¥fld_chk.reverse($¥fld_chk.existsB?(#)) $+ .:{ 
    if (On isin $¥fld_chk.reverse($¥fld_chk.existsB?(#))) { 
      echo 2 -a Flood Protection: Users who trigger the appropriate flood levels of # when you're not op'd will now be /kill'd with the kill message "Channel Flooding" (given that you're oper'd up). NB: This mode is extremely useful in un-op'd channels that are having problems with flooders.   
      set [ % $+ [ # ] $+ .fld_Don'tKillUsersForFlooding? ] 0   
      fld.settings-write # fld_Don'tKillUsersForFlooding? 0
      ¥fld_backup #
    }
    else { 
      echo 2 -a Flood Protection: Users who trigger the appropriate flood levels of # when you're not op'd will now not be killed. 
      set [ % $+ [ # ] $+ .fld_Don'tKillUsersForFlooding? ] 1  
      fld.settings-write # fld_Don'tKillUsersForFlooding? 1
      ¥fld_backup # 
    } 
  }
  ..-
  .. o Strict Protection -> 
  ... Current state $+ $chr(58)  $¥fld_chk.sp(#) $+ . :halt 
  ...-
  ... Click here to turn $¥fld_chk.reverse($¥fld_chk.sp(#)) :{
    if (Off isin $¥fld_chk.sp(#)) { 
      echo 2 -a Flood Protection: Strict Protection for # is now on (please read the readme file with this script for an explanation of this mode). 
      set % $+ # $+ .fld.rpt-c.s 1 
      ¥fld_backup # 
    }
    elseif (On isin $¥fld_chk.sp(#)) { 
      echo 2 -a Flood Protection: Strict Protection for # is now off. 
      set [ % $+ [ [ # ] $+ .fld.rpt-c.s ] ] 
      ¥fld_backup # 
    }
  }
}

alias expiry.sync { 
  unset %exp-s.*
  if ($1 == $null) { halt }
  elseif (($asc($1) == 35) && ($2 == $null)) { 
    set %exp-s.m onotice $1 : Op's : $1 : 
    goto expiry.run_prime 
  } 
  else { 
    if ((s isin $2) && (e !isin $2)) { set %exp-s.m | goto expiry.run_prime }     
    if (o isin $2) { set %exp-s.m onotice $1 : Op's : $1 : | goto expiry.run_prime }
    if (e isin $2) { 
      if (a isin $2) { set %exp-s.m1 a }
      elseif (s isin $2) { set %exp-s.m1 s }
      else { set %exp-s.m1 a }
      set %exp-s.m echo 5 [ - $+ [ %exp-s.m1 ] ] *** Flood Protection: 
      unset %exp-s.m1 
      goto expiry.run_prime 
    } 
  }
  :expiry.run_prime    
  set %exp-s.f1 $fld-loc($lower($1))
  set %exp-s.f2 $fld.rpt-loc($lower($1))
  set %exp-s.e1 fld.c-lim 
  set %exp-s.h1 fld.c-time
  set %exp-s.t1 $ticks
  if (%exp-s.m) { 
    if (echo isin %exp-s.m) { %exp-s.m Received SIGHUP from $me ( $+ $gettok($address($me,5),2,33) $+ ) $+ . Starting expiry run for ' $+ $1 $+ '. }
    else { %exp-s.m Received SIGHUP from $me ( $+ $gettok($address($me,5),2,33) $+ ) $+ . Starting expiry run. } 
  }
  :expiry.run_init
  inc %exp-s.l1 1
  if (%exp-s.l1 <= 2) { 
    set %exp-s.a1 [ % $+ [ exp-s.f $+ [ %exp-s.l1 ] ] ] 
    set %exp-s.a2 $lines(%exp-s.a1)
    if ($exists(%exp-s.a1) == $false) {
      if (%exp-s.m) { %exp-s.m Data file " $+ $gettok(%exp-s.a1,¥_i($count(%exp-s.a1,$chr(92))),92) $+ " $¥fld_chk.expiry-al($1) does not exist. } 
      if (%exp-s.l1 == 2) { goto expiry.end_secondary } 
      else { goto expiry.run_init }
    }
    elseif (%exp-s.a2 <= 1) { 
      if (%exp-s.m) { %exp-s.m Data file " $+ $gettok(%exp-s.a1,$¥_i($count(%exp-s.a1,$chr(92))),92) $+ " $¥fld_chk.expiry-al($1) doesn't contain any entries. }
      if (%exp-s.l1 == 2) { goto expiry.end_secondary } 
      else { goto expiry.run_init }
    }
    if ($asc($left( [ $read -nl1 [ %exp-s.a1 ] ] ,1)) == 91) { set %exp-s.l2 2 | goto expiry.run_loop } 
    else {
      if (%exp-s.m) { %exp-s.m Error while performing expiry run: corrupt header in .ini file. Halting | halt }
      else { echo 5 -a Error while performing expiry run: corrupt header in .ini file. Halting | halt } 
    }
    :expiry.run_loop
    if (%exp-s.l2 <= %exp-s.a2) { 
      set %exp-s.a3.0  [ $read -nl $+ [ %exp-s.l2 ] %exp-s.a1 ] 
      if ((%exp-s.a3.0 == $null) || ($chr(61) !isin %exp-s.a3.0)) { goto expiry.run_init } 
      set %exp-s.a3.1 $gettok(%exp-s.a3.0,1,61)
      set %exp-s.a3.2 $gettok(%exp-s.a3.0,2,61) 
      inc %exp-s.b1 1 
      if (%exp-s.l1 == 1) { 
        if ($calc($ctime - $gettok(%exp-s.a3.2,2,44)) <= [ % $+ [ [ $1 ] $+ .fld.c-time ] ] ) { 
          inc %exp-s.l2 1 
          goto expiry.run_loop 
        } 
        else { 
          .remini [ %exp-s.a1 ] 1 [ %exp-s.a3.1 ]
          set %exp-s.a2 $lines(%exp-s.a1)
          inc %exp-s.ex1 1 
          goto expiry.run_loop
        }
      }
      elseif (%exp-s.l1 == 2) { 
        set %exp-s.h2 $calc($ctime - $gettok(%exp-s.a3.2,2,44))
        if (%exp-s.h2 <= 6) { 
          inc %exp-s.l2 1
          goto expiry.run_loop 
        }
        elseif ((%exp-s.h2 <= 10) && ($gettok(%exp-s.a3.2,1,44) <= 5)) { 
          inc %exp-s.l2 1
          goto expiry.run_loop 
        }
        else { 
          remini %exp-s.a1 1 %exp-s.a3.1                 
          set %exp-s.a2 $lines(%exp-s.a1)
          inc %exp-s.ex1 1
          goto expiry.run_loop 
        }
      }
    }
    else { goto expiry.run_init }
  }
  else { goto expiry.end }
  :expiry.end
  if (%exp-s.m == $null) { goto expiry.end_secondary } 
  if ((%exp-s.b1) && (%exp-s.ex1 == $null)) {
    if (echo isin %exp-s.m) { %exp-s.m Notice: Expiry run for ' $+ $1 $+ ' completed successfully. No entries (0/ $+ [ %exp-s.b1 ] $+ ) needed to be expired. }
    else { %exp-s.m Notice: Expiry run completed successfully. No entries (0/ $+ [ %exp-s.b1 ] $+ ) needed to be expired. }
    goto expiry.end_secondary
  }
  else {  
    set %exp-s.t4 $calc((%exp-s.ex1 / %exp-s.b1) * 100)
    if (echo isin %exp-s.m) {
      %exp-s.m Notice: Expiry run for ' $+ $1 $+ ' completed successfully. 
      %exp-s.m %exp-s.ex1 entries out of %exp-s.b1 ( $+ $iif(($int(%exp-s.t4) == 0),$round(%exp-s.t4,3),$round(%exp-s.t4,1)) $+ $chr(37) $+ ) removed in $calc(($ticks - %exp-s.t1) / 1000) $+ s.
      goto expiry.end_secondary
    }
    else { 
      %exp-s.m Notice: Expiry run completed successfully.
      %exp-s.m %exp-s.ex1 entries out of %exp-s.b1 ( $+ $iif(($int(%exp-s.t4) == 0),$round(%exp-s.t4,3),$round(%exp-s.t4,1)) $+ $chr(37) $+ ) removed in $calc(($ticks - %exp-s.t1) / 1000) $+ s. 
      goto expiry.end_secondary 
    }
  }
  :expiry.end_secondary
  flushini %exp-s.f1
  flushini %exp-s.f2
  unset %exp-s.*
}
alias ¥fld_chk.isin {
  ; Optimised routine for data comparison.
  unset %fld_chk.isin.loop
  set %fld_chk.isin.target [ % $+ [ $1 ] ]
  if (%fld_chk.isin.target) {
    set %fld_chk.isin.count $calc($count(%fld_chk.isin.target,$chr(44)) + 1)
    if (%fld_chk.isin.count > 0) {
      :chk.isin.loop
      inc %fld_chk.isin.loop
      if (%fld_chk.isin.loop <= %fld_chk.isin.count) {
        if ($gettok(%fld_chk.isin.target,%fld_chk.isin.loop,44) == $2) { 
          unset %fld_chk.isin.*     
          return 1 
        }
        else {
          goto chk.isin.loop 
        }
      }
      else { 
        unset %fld_chk.isin.*
        return 0 
      }
    }
    else {
      if (%fld_chk.isin.target == $1) { 
        unset %fld_chk.isin.*
        return 1
      }
      else {
        unset %fld_chk.isin.*
        return 0 
      }
    }
  }
  else {
    unset %fld_chk.isin.*
    return 0
  }
}

alias ¥fld_r-files {
  if ($exists($fld.rpt-loc($¥_l($1)))) { .write -c $fld.rpt-loc($¥_l($1)) [1] } 
  if ($exists($fld-loc($¥_l($1)))) { .write -c $fld-loc($¥_l($1)) [1] } 
}
alias ¥fld_chk.exists? {
  if ( [ % $+ [ $1 ] ] ) { 
    if ($¥fld_chk.isin($1,$2)) { return On. }
    else { return Off. }
  }
  else { return Off. }
}
alias ¥fld_chk.state { 
  if ($fld.settings-read($¥_l($1),State) == On) { return On <profile exists> } 
  elseif (($fld.settings-read($¥_l($1),State) == Off) && ($fld.settings-read($¥_l($1),fld.c-lim))) { return Off <profile exists> } 
  else { return Off <no profile exists> } 
}
alias ¥fld_chk.state-snd { 
  if (On isin $¥fld_chk.state($1)) { return } 
  elseif ((Off isin $¥fld_chk.state($1)) && (<no isin $¥fld_chk.state($1))) { return <creates new profile> }
  elseif ((Off isin $¥fld_chk.state($1)) && (<no !isin $¥fld_chk.state($1))) { return <uses existing profile> }
}
alias ¥fld_chk.expiry-al {
  if (echo isin %exp-s.m) { return for $1 }
  else { return }
}
alias ¥fld_chk.existsB? { 
  set %fld_chk.exB.t1 $fld.settings-read($1,fld_Don'tKillUsersForFlooding?) 
  if (%fld_chk.exB.t1 == 0) { unset %fld_chk.exB.* | return On. }
  elseif (%fld_chk.exB.t1 == 1) { unset %fld_chk.exB.* | return Off. }
  else { unset %fld_chk.exB.* | return <no value set> }   
}  
alias ¥fld_chk.reverse {
  if (On isin $1) { return OFF }
  elseif (Off isin $1) { return ON }
  else { return ON }
}
alias ¥fld_r-add.target {
  set %r-add.target [ [ % $+ [ $1 ] ] ]
  if ($2 !isin [ % $+ [ $1 ] ] ) { 
    if (%r-add.target) { set % $+ $1 %r-add.target $+ $chr(44) $+ $2 }
    else { set % $+ $1 $2 }
  }
  unset %r-add.target 
}
alias ¥fld_t->conv { 
  if ($1 isnum) { 
    if ($1 == 1) { return $1 minute }
    else { return $1 minutes } 
  }
  else { return $1- }
}
alias ¥_l { return $lower($1) }
alias ¥_i { 
  if ($2) { return $calc($1 + $2) }
  else { return $calc($1 + 1) } 
}
alias -l chk.ex {
  if ( [ % $+ [ $1 ] ] ) {
    if ($¥fld_chk.isin($1,$2)) { return $chr(91) $+ $chr(111) $+ $chr(93) } 
    else { return $chr(91) $+ $str($chr(160),2) $+ $chr(93) } 
  }
  else { return $chr(91) $+ $str($chr(160),2) $+ $chr(93) }
}
alias -l ¥fld_chk.sp { 
  if ( [ % $+ [ [ $1 ] $+ .fld.rpt-c.s ] ] ) { return On }
  else { return Off }
}
alias ¥fld_export { 
  unset %¥fld_t-*
  if ($fld.settings-read($1,State) == On) { ¥fld_r-add.target NEWFLOOD $1 } 
  elseif ($¥fld_chk.isin(NEWFLOOD,$1)) { .writeini -n $fld.settings-loc $¥_l($1) State On | .flushini $fld.settings-loc } 
  set %¥fld_t-string fld.c-banmask,fld.c-lim,fld.c-time,fld.rpt-c.mode,fld.rpt-c.banmask,fld_expiry.time,fld_expiry.size,fld_Don'tKillUsersForFlooding?
  set %¥fld_t-c $calc($count(%¥fld_t-string,$chr(44)) + 1) 
  :¥fld_loop
  inc %¥fld_t-l1 1
  if (%¥fld_t-l1 <= %¥fld_t-c) { 
    set % $+ $1 $+ $chr(46) $+ $gettok(%¥fld_t-string,%¥fld_t-l1,44) [ $readini -n $fld.settings-loc $¥_l($1) [ $gettok(%¥fld_t-string,%¥fld_t-l1,44) ] ]
    goto ¥fld_loop
  }
  else { unset %¥fld_t-* }
}
alias ¥fld_backup {
  if ($¥fld_chk.isin(NEWFLOOD,$1)) { .writeini -n $fld.settings-loc $¥_l($1) State On | .flushini $fld.settings-loc }
  else { .writeini -n $fld.settings-loc $¥_l($1) State Off | .flushini $fld.settings-loc }
  .writeini -n $fld.settings-loc $¥_l($1) HashCode $hash($¥_l($1),$bits)
  ¥fld_write.import $1 fld.c-banmask
  ¥fld_write.import $1 fld.c-lim
  ¥fld_write.import $1 fld.c-time
  ¥fld_write.import $1 fld.rpt-c.mode
  ¥fld_write.import $1 fld.rpt-c.banmask
  ¥fld_write.import $1 fld_expiry.time
  ¥fld_write.import $1 fld_expiry.size 
  ¥fld_write.import $1 fld_Don'tKillUsersForFlooding?
}
alias ¥fld_write.import { if (( [ % $+ [ $1 $+ [ $chr(46) $+ [ $2 ] ] ] ] ) || ( [ % $+ [ $1 $+ [ $chr(46) $+ [ $2 ] ] ] ] isnum)) { .writeini -n $fld.settings-loc $¥_l($1) $2 [ % $+ [ $1 $+ [ $chr(46) $+ [ $2 ] ] ] ]  } } 
alias ¥fld_turn.ON {
  if ( [ $readini -n $fld.settings-loc $¥_l($1) fld.c-banmask ] ) { set %NEWFLOOD $addtok(%NEWFLOOD,$1,44) | ¥fld_export $1 } 
  else { 
    set % $+ $1 $+ .fld.c-banmask $2 
    set % $+ $1 $+ .fld.c-lim $3
    set % $+ $1 $+ .fld.c-time $4
    set % $+ $1 $+ .fld.rpt-c.mode $5
    set % $+ $1 $+ .fld.rpt-c.banmask $6
    set % $+ $1 $+ .fld_expiry.time $7
    set % $+ $1 $+ .fld_expiry.size $8
    set % $+ $1 $+ .fld_Don'tKillUsersForFlooding? $9 
    set %NEWFLOOD $addtok(%NEWFLOOD,$1,44) 
    ¥fld_backup $1 
  }
  if ($finddir( [ $mIRCdir ] ,protection,1) == $null) { mkdir [ $mIRCdir $+ [ protection ] ] | mkdir [ $mIRCdir $+ [ protection\ $+ [ $hash($¥_l($1),$bits) ] ] ] }
  elseif ($finddir( [ $mIRCdir $+ protection ] , [ $hash($¥_l($1),$bits) ] ,1) == $null) { mkdir [ $mIRCdir $+ [ protection\ $+ [ $hash($¥_l($1),$bits) ] ] ] }
}
alias ¥fld_turn.OFF {
  if ($2) { goto stage_unset }
  set %NEWFLOOD $remtok(%NEWFLOOD,$1,1,44) 
  ¥fld_backup $1 
  :stage_unset
  set [ % $+ [ $1 ] $+ .fld.c-banmask ]
  set [ % $+ [ $1 ] $+ .fld.c-lim ]
  set [ % $+ [ $1 ] $+ .fld.c-time ]
  set [ % $+ [ $1 ] $+ .fld.rpt-c.s ]
  set [ % $+ [ $1 ] $+ .fld.rpt-c.mode ]
  set [ % $+ [ $1 ] $+ .fld.rpt-c.banmask ]
  set [ % $+ [ $1 ] $+ .fld_expiry.time ] 
  set [ % $+ [ $1 ] $+ .fld_expiry.size ] 
  set [ % $+ [ $1 ] $+ .fld_Don'tKillUsersForFlooding? ] 
}
alias ¥fld_m-c { 
  if ( [ % $+ [ $1 $+ [ $2- ] ] ] ) { return [ % $+ [ $1 $+ [ $2- ] ] ] }
  else { return <no value set> }
}