Converting mIRC and hit a problem

I’ve done alot of mIRC work recently and have decided I am redoing my website. In ny MySQL table, users have something called “flags” which are set by the shoutcast irc bot, ShoutIRC.

The following mIRC script can take the values from the database and return the letters representing those flags:

alias IRCBotFlagsFromLong {
  set -u0 %ibf.n 1
  while (%ibf.n <= 26) {
    if ($isbit($1,%ibf.n)) {
      set -u0 %ibf.ret %ibf.ret $+ $chr($calc(%ibf.n + 96))
    }
    inc %ibf.n
  }
  while (%ibf.n <= 32) {
    if ($isbit($1,%ibf.n)) {
      set -u0 %ibf.ret %ibf.ret $+ $chr($calc(%ibf.n + 64 - 26))
    }
    inc %ibf.n
  }
  return %ibf.ret
}

For example, if I type //echo $IRCBotFlagsFromLong(466952) it would echo out dnqrs.

I am trying to convert this into php and all of it is fine, except for the line(s)

if ($isbit($1,%ibf.n))

$1 is the value given to the “function” (466952) and %ibf.n is a counter. I can’t seem to find a php equivalent to the $isbit function

$isbit(A,N) - Returns 1 if the Nth bit in number A is turned on.

Anyone have any ideas to this?

Sponsor our Newsletter | Privacy Policy | Terms of Service