This used to work, about 3 years ago. I'm not sure what's broken, and I can't seem to find anything wrong with it (I didn't write it, just modified it to my needs).

If any clever eyes don't mind taking a look, I'd appreciate it. I get the message "/goto: duplicate 'YES1' found (line 279, remote.ini)" and if I change all the redicts to individual names I just end up getting the error "/if: invalid format (line 279, remote.ini)".

Code:
on @*:text:*:#:linkpost $1- 
on @*:action:*:#:linkpost $1- 
on @*:notice:*:#:linkpost $1- 
alias -l linkpost { 
  if ((!%p) && (!$hfind(permit,$nick))) { inc -u4 %p 
    var %purge /^!(links\so(n|ff)|(permit))\b/iS 
    var %domain com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk|de|dk|se|co|be|es|pro|xxx|cat|fi|is|jp|cn|kr|lu|mx|no|ru|us|me
    var %link /(?<=^|\s)((?>\S{3,8}:\/\/|w{3}\56)\S+)|\56( $+ %domain $+ )\b/iS 
    ;; IF THE LINKER IS "VOICED" OR "REGULAR" (VR) && $1- (THE LINK) HAS %link (THE ABOVE VARIABLE) IN IT.
    if ($nick(#,$nick,vr) && $regex($1-,%link) && %Link. [ $+ [ $chan ] ] == off) { 
      $msgbot($chan,$nick you do not have permission to post a link, ask a mod to !permit you )
      msg # /timeout $nick 1
    } 
    elseif (($regex($1-,%purge)) && ($regml(1) = permit) && ($nick isop #) && ($$2 ison #) && ($$2 !isop) && %Link. [ $+ [ $chan ] ] == off) { 
      goto $iif($3 && $3 isnum,YES1,NO1) | :YES1 | hadd -mz permit $2 $3
      $msgbot($chan,You now have $3 seconds to post a link $2!)
      halt | :NO1 | hadd -mz permit $2 10
      $msgbot($chan,You now have 10 seconds to post a link $2!)
    } 
    elseif (($regml(1) = links on) && ($nick isop #)) { 
      goto $iif(%Link. [ $+ [ $chan ] ] == off,YES1,NO1) | :YES1 | set %Link. $+ $chan on
      .msg # Links are now enabled in: $right($chan,-1) $+ .
      halt | :NO1 | .msg # Links are already enabled.
    } 
    elseif (($regml(1) = links off) && ($nick isop #)) { 
      goto $iif(%Link. [ $+ [ $chan ] ] == on,YES2,NO2) | :YES2 | set %Link. $+ $chan off
      .msg # Links are now disabled in: $right($chan,-1) $+ . 
      halt | :NO2 | .msg # Links are already disabled.
      ! 
    } 
  } 
}

For anyone that would rather see it with syntax highlighting

!links on works
!links off works
!links works
!permit does not work

Thanks!