<?

// 22.11.2006

class users extends logparser {
   function viewerconnectinfo($id) {
      $uid = $this->viewers[$id]['uid'] = abs(ip2long($this->viewers[$id]['ip']));

      global $ettvusers;
      if(isset($ettvusers[$uid])) {
         $this->viewers[$id]['muted'] = $ettvusers[$uid]['muted'];
         $this->viewers[$id]['spamcount'] = $ettvusers[$uid]['spamcount'];
      }
      else {
         $this->viewers[$id]['muted'] = 0;
         $this->viewers[$id]['spamcount'] = 0;
      }
      $this->viewers[$id]['visits'] = -1;

      if($this->viewers[$id]['muted'] > time()) {
         $this->send("mute $id");
         debug("Stickymuting ".$this->viewers[$id]['nick']."\n");
         addtimer($this->viewers[$id]['muted'], "if(\$procs[$this->procid]) \$procs[$this->procid]->unmute('$uid');");
      }
      debug("[$this->type$this->num] Connect ".$this->viewers[$id]['nick']." IP: ".$this->viewers[$id]['ip']." Slot: $id  Userid: $uid$vvv$reco$spsp\n");
   }

   function updatenicks($id, $nick_new) {
      $this->viewers[$id]['nick'] = $nick_new;
   }

   function muteid($id, $mutetime, $incr) {
      global $ettvusers;
      $muteend = time() + ($mutetime * 60);
      $this->viewers[$id]['muted'] = $muteend;
      $this->send("mute $id");
      debug("Muted ".$this->viewers[$id]['nick']." for $mutetime\n");
      addtimer($this->viewers[$id]['muted'], "if(\$procs[$this->procid]) \$procs[$this->procid]->unmute('".$this->viewers[$id]['uid']."');");
      if($incr) {
         $this->viewers[$id]['spamcount']++;
      }
      $ettvusers[$this->viewers[$id]['uid']] = array('muted' => $this->viewers[$id]['muted'], 'spamcount' => $this->viewers[$id]['spamcount']);
      foreach($ettvusers AS $uid => $info) {
         if($info['muted'] < time() - 3600*6) {
            unset($ettvusers[$uid]);
         }
      }

   }
   function unmuteid($id) {
      global $ettvusers;
      $this->send("unmute $id");
      $this->send("qsay Unmuted ".$this->viewers[$id]['nick']);
      $this->viewers[$id]['muted'] = time();
      $ettvusers[$this->viewers[$id]['uid']]['muted'] = time();
   }
}