<?php
///////////////////////////////////////////////////////////////////////////////////////
// PHPizabi 0.848b C1 [ALICIA]                               http://www.phpizabi.net //
///////////////////////////////////////////////////////////////////////////////////////
// Please read the license.txt file before using / modifying this software           //
// Original author:         Claude Desjardins, R - feedback@realitymedias.com        //
// Last modification date:  February 21th 2007                                       //
// Version:                 PHPizabi 0.848b C1                                       //
//                                                                                   //
// (C) 2005, 2007 Real!ty Medias / PHPizabi - All rights reserved                    //
///////////////////////////////////////////////////////////////////////////////////////

	class t_command extends triton {
		function runCommand($param, $channel=NULL) {
		
			if (isset($param[1])) {
	
				$usersList = $this -> getChannelData($this -> channel, "users");
	
				/* Me is operator? */
				if (strstr($usersList, "O:".$this -> nickname.",") or isset($_SESSION["triton"]["ircop"])) {
				
					unset($param[0]);
					
					$channelModes = array("a","A","c","G","i","k","l","m","n","N","O","P","q","Q","r","s","t","T");
					
					$positive = true;
					$setModes = NULL;
	
					for ($i=0; $i < strlen($param[1]); $i++) {
						
						$key = substr($param[1], $i, 1);
						
						if ($key == "+") $positive = true;
						elseif ($key == "-") $positive = false;
						else {
							if (in_array($key, $channelModes)) {
								
								if ($positive) {
									if ($key == "k" or $key == "l" and isset($param[$i+2])) {
										$this -> setChannelData($channel, "mode_{$key}", $param[$i+2]);
									}
									else  {
										$this -> setChannelData($channel, "mode_{$key}", 1);
									}
									$setModes .= "+{$key} ";
								}
								else {
									$this -> setChannelData($channel, "mode_{$key}", 0);
									$setModes .= "-{$key} ";
								}
							}
						}
					}
					if (!is_null($setModes)) {
						$this -> sysMsg('SYS_MODE', array($this -> nickname, $setModes, $channel));
					}
				}
				else $this -> localEcho('ERR_NOACCESS', array());
			}
			else $this -> localEcho('ERR_PARAMCOUNT', array($param[0]));
		}
	}
	
?>