Location: PHPKode > projects > X-kernoel-x.NET Chat Engine > xchatx-0.1/includes/cmd.proc.inc.php
<?

/*********************************************************************************
x-kernoel-x.NET Chat Engine is Copyright (c) 2002 by Markus Duft
You can reach me ofer E-Mail at: hide@address.com
This peace of Software underlies the GPL General Public License
Feel free to take peaces of this software for your own programs, but please let me know,
and leave a copyright notice where you use something out of this script!
*********************************************************************************/


//===CDM PROCESSOR===//

function cmdProc($text="", $color="#ffffff",  $nick)
{
	if(substr($text,0,1) == "/") {
		$cmd = explode(" ",$text);
		switch($cmd[0]) {
			case "/me":
				$op_string = "<font face='Arial' size='2' color='$color'><b><i>&gt; $nick ".substr($text,3)."</i></b></font><br>";
				$regi = @regProc($op_string,$color,$nick,"normal");
				break;
			case "/s":
				$op_string = "<font face='Arial' size='2' color='$color'><b><i>$nick schreit:</i> ".substr($text,3)."</b></font><br>";
				$regi = @regProc($op_string,$color,$nick,"normal");
				break;
			case "/j":
				$proc_room = sysProc($nick,"j",$cmd[1]);
				return $proc_room;
				break;
			case "/k":
				$procvip = userProc($nick,"k",$cmd[1]);
				return $procvip;
				break;
			case "/su":
				$procvip = userProc($nick,"su",$cmd[1]);
				return $procvip;
				break;
			case "/rsu":
				$procvip = userProc($nick,"rsu",$cmd[1]);
				return $procvip;
				break;
			case "/kh":
				break;
			case "/kc":
				break;
			case "/gag":
				$procvip = userProc($nick,"gag",$cmd[1]);
				return $procvip;
				break;
			case "/m":
				include("includes/config.inc.php");
				$u_db = new Database($db_host,$db_name,$db_user,$db_pass);
				$user_q = $cmd[1];
				$query = "SELECT * FROM on_user WHERE name = '$user_q'";
				$u_db->query($query);
				$u_db->nextRecord();
				if($u_db->getField(1)) {
					$u_len = strlen($user_q) + 4;
					$op_string  = "<font face='Arial' size='2' color='#ffffff'><b><i>Fl&uuml;ster zu ".$u_db->getField(1).": </font>";
					$op_string .= "<font face='Arial' size='2' color='$color'>".substr($text,$u_len)."</font></b></i><br>";
					$op2_string  = "<font face='Arial' size='2' color='#ffffff'><b><i>$nick fl&uuml;stert: </font>";
					$op2_string .= "<font face='Arial' size='2' color='$color'>".substr($text,$u_len)."</font></b></i><br>";
					$regi = @regProc($op2_string,$color,$nick,"whisper:".$u_db->getField(1));
					return $op_string;
					break;
				} else {
					$op_string  = "<font face='Arial' size='2' color='#ffffff'><b><i>$user_q ist nicht im Chat!</i></b></font><br>";
					return $op_string;
					break;
				}
			case "/w":
				$procvip = userProc($nick,"w",$cmd[1]);
				return $procvip;
				break;
			case "/wc":
				$procvip = userProc($nick,"wc",$cmd[1]);
				return $procvip;
				break;
			case "/f":
				break;
			case "/i":
				$proc_room = sysProc($nick,"i",$cmd[1]);
				return $proc_room;
				break;
			case "/l":
				$proc_room = sysProc($nick,"l",$cmd[1]);
				return $proc_room;
				break;
			case "/vip":
				$procvip = userProc($nick,"vip",$cmd[1]);
				return $procvip;
				break;
			case "/sysmsg":
				include("includes/config.inc.php");
				$db = new Database($db_host,$db_name,$db_user,$db_pass);
				$sql = "SELECT * FROM reg_user WHERE name = '$nick'";
				$db->query($sql);
				$db->nextRecord();
				if($db->getField(4)==3) {
					$op_string = "<font face='Arial' size='3' color='#ffffff'><b>Nachricht vom Systemadministrator: ".substr($text,8)."</b></font><br>";
					$regi = @regProc($op_string,$color,$nick,"sysmsg");
					break;
				} else {
					$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Sie haben nicht die nötigen Rechte f&uuml;r diesen Befehl!</i></b></font><br>";
					return $op_string;
					break;
				}
			case "/t":
				$procvip = userProc($nick,"t",substr($text,3));
				return $procvip;			
				break;
			case "/away":
				$procvip = userProc($nick,"away",$cmd[1]);
				return $procvip;
				break;
			case "/col":
				$procvip = userProc($nick,"col",$cmd[1]);
				return $procvip;
				break;
			case "/q":
				break;
			case "/a":
				$proc_room = sysProc($nick,"a",$cmd[1]);
				break;
			case "/sepa":
				$proc_room = sysProc($nick,"sepa",$cmd[1]);
				return $proc_room;
				break;
			case "/ju":
				include("includes/config.inc.php");
				$db = new Database($db_host,$db_name,$db_user,$db_pass);
				$sql="SELECT * FROM on_user WHERE name='$cmd[1]'";
				$db->query($sql);
				if($db->nextRecord()) {
					$room = $db->getField(3);
					$proc_room = sysProc($nick,"j",$room);
					return $proc_room;
					break;
				} else {
					$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>$user_q ist nicht im Chat!</i></b></font><br>";
					return $op_string;
					break;
				}
			case "/aq":
				$op_string = "<font face='Arial' size='2' color='$color'><b><i>Frage von $nick: ".substr($text,4)."</i></b></font><br>";
				$regi = @regProc($op_string,$color,$nick,"normal");
				break;
			case "/ig":
				break;
			case "/ia":
				include("includes/config.inc.php");
				$db = new Database($db_host,$db_name,$db_user,$db_pass);
				$sql = "SELECT * FROM on_user WHERE room = '$cmd[1]'";
				$db->query($sql);
				$num = $db->numRows();
				for($i=0;$i<$num;$i++) {
					$db->nextRecord();
					$proc_room = sysProc($nick,"i",$db->getField(1));
					return $proc_room;
					break;
				}
			case "/rvip":
				$procvip = userProc($nick,"rvip",$cmd[1]);
				break;
			default:
				include("includes/config.inc.php");
				$u_db = new Database($db_host,$db_name,$db_user,$db_pass);
				$user_q = substr($cmd[0],1);
				$query = "SELECT * FROM on_user WHERE name = '$user_q'";
				$u_db->query($query);
				$u_db->nextRecord();
				if($u_db->getField(1)) {
					$u_len = strlen($user_q) + 2;
					$op_string  = "<font face='Arial' size='2' color='#ffffff'><b><i>Fl&uuml;ster zu ".$u_db->getField(1).": </font>";
					$op_string .= "<font face='Arial' size='2' color='$color'>".substr($text,$u_len)."</font></b></i><br>";
					$op2_string  = "<font face='Arial' size='2' color='#ffffff'><b><i>$nick fl&uuml;stert: </font>";
					$op2_string .= "<font face='Arial' size='2' color='$color'>".substr($text,$u_len)."</font></b></i><br>";
					$regi = @regProc($op2_string,$color,$nick,"whisper:".$u_db->getField(1));
					return $op_string;
					break;
				} else {
					$op_string  = "<font face='Arial' size='2' color='#ffffff'><b><i>$user_q ist nicht im Chat!</i></b></font><br>";
					return $op_string;
					break;
				}
		}
	} else {
		$op_string = "<font face='Arial' size='2' color='$color'>&lt;$nick&gt; $text</font><br>";
		$regi = @regProc($op_string,$color,$nick,"normal");
	}
}

function regProc($text,$color,$nick,$type)
{
	include("includes/config.inc.php");
	$db = new Database($db_host,$db_name,$db_user,$db_pass);
	$sql = "SELECT * FROM on_user WHERE name = '$nick'";
	$db->query($sql);
	$db->nextRecord();
	
	$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"".$db->getField(3)."\",\"$text\",\"$nick\",\"$color\",\"$type\")";
	$db->query($sql);
	
	return true;
}

function userProc($nick,$action,$param="",$param2="")
{
	include("includes/config.inc.php");
	$db = new Database($db_host,$db_name,$db_user,$db_pass);
	
	switch($action) {
		case "vip":
			$sql = "SELECT * FROM reg_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
			if($db->getField(4)==3) {
				$sql = "UPDATE reg_user SET priv='2' WHERE name = '$param'";
				$db->query($sql);	
				$sql = "UPDATE on_user SET priv='2' WHERE name = '$param'";
				$db->query($sql);
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Der User $param wurde von $nick zum VIP ernannt!</i></b></font><br>";
				$regi = @regProc($op_string,'#ffffff',$nick,"normal");
				break;
			} else {
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Sie haben nicht die n&ouml;tigen Rechte f&uuml;r diesen Befehl!</i></b></font><br>";
				return $op_string;
				break;
			}
		case "su":
			$sql = "SELECT * FROM on_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
			if($db->getField(6)>0) {
				$sql = "UPDATE on_user SET priv='1' WHERE name = '$param'";
				$db->query($sql);
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Der User $param wurde von $nick zum Super-User ernannt!</i></b></font><br>";
				$regi = @regProc($op_string,'#ffffff',$nick,"normal");
				break;
			} else {
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Sie haben nicht die n&ouml;tigen Rechte f&uuml;r diesen Befehl!</i></b></font><br>";
				return $op_string;
				break;
			}
		case "rvip":
			$sql = "SELECT * FROM reg_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
			if($db->getField(4)>1) {
				$sql = "UPDATE reg_user SET priv='0' WHERE name = '$param'";
				$db->query($sql);	
				$sql = "UPDATE on_user SET priv='0' WHERE name = '$param'";
				$db->query($sql);
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Der User $param wurde von $nick zum normalen User degradiert!</i></b></font><br>";
				$regi = @regProc($op_string,'#ffffff',$nick,"normal");
				break;
			} else {
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Sie haben nicht die n&ouml;tigen Rechte f&uuml;r diesen Befehl!</i></b></font><br>";
				return $op_string;
				break;
			}
		case "rsu":
			$sql = "SELECT * FROM on_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
			if($db->getField(6)>1) {
				$sql = "UPDATE on_user SET priv='0' WHERE name = '$param'";
				$db->query($sql);
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Der User $param wurde von $nick zum normalen User degradiert!</i></b></font><br>";
				$regi = @regProc($op_string,'#ffffff',$nick,"normal");
				break;
			} else {
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Sie haben nicht die n&ouml;tigen Rechte f&uuml;r diesen Befehl!</i></b></font><br>";
				return $op_string;
				break;
			}
		case "k":
			$sql = "SELECT * FROM on_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
			if($db->getField(6)>0) {
				$sql = "SELECT * FROM on_user WHERE name = '$param'";
				$db->query($sql);
				$db->nextRecord();
				if($db->getField(6)>0) {
					$sql = "UPDATE on_user SET priv='0', room='Exil' WHERE name = '$param'";
					$db->query($sql);
					$op_string = "<font face='Arial' size='2' color='#ffffff'><i>Der User $param wurde von $nick aus dem Raum geschmissen!</i></font><br>";
					$regi = @regProc($op_string,'#ffffff',$nick,"normal");
					break;
				} else {
					$op_string = "<font face='Arial' size='2' color='#ffffff'><i><b>Super-User und VIPs k&ouml;nnen nicht hinausgeschmissen werden!</b></i></font><br>";
					return $op_string;
					break;
				}
			} else {
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Sie haben nicht die n&ouml;tigen Rechte f&uuml;r diesen Befehl!</i></b></font><br>";
				return $op_string;
				break;
			}
		case "gag":
			$sql = "SELECT * FROM on_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
			if($db->getField(6) > 0) {
				$sql = "SELECT * FROM on_user WHERE name = '$param'";
				$db->query($sql);
				$db->nextRecord();
				if($db->getField(5) != "gag") {
					$sql = "UPDATE on_user SET status='gag' WHERE name = '$param'";
					$db->query($sql);
					$op_string = "<font face='Arial' size='2' color='#ffffff'><i><b>Der User $param wurde von $nick geknebelt!</b></i></font><br>";
					$regi = @regProc($op_string,'#ffffff',$nick,"normal");
					break;
				} else {
					$sql = "UPDATE on_user SET status='normal' WHERE name = '$param'";
					$db->query($sql);
					$op_string = "<font face='Arial' size='2' color='#ffffff'><i><b>Der User $param wurde von $nick entknebelt!</b></i></font><br>";
					$regi = @regProc($op_string,'#ffffff',$nick,"normal");
					break;
				}
			} else {
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Sie haben nicht die n&ouml;tigen Rechte f&uuml;r diesen Befehl!</i></b></font><br>";
				return $op_string;
				break;
			}
		case "col":
			$sql = "UPDATE on_user SET color = '$param' WHERE name = '$nick'";
			$db->query($sql);
			$op_string = "<font face='Arial' size='2' color='$param'><i><b>$nick hat die Farbe gewechselt!</b></i></font><br>";
			$regi = @regProc($op_string,$param,$nick,"normal");
			$sql = "UPDATE reg_user SET color = '$param' WHERE name = '$nick'";
			$db->query($sql);
			break;
		case "away":
			//away output / registration!
			break;
		case "w":
			if($param){
				$sql = "SELECT * FROM on_user WHERE name = '$param'";
				$db->query($sql);
				if($db->nextRecord()) {
					if($db->getField(8)) {
						$op_string  = "<font face='Arial' size='2' color='#ffffff'><i><b>$param ist ein registrierter Benutzer!<br>";
						$op_string .= "Klicken Sie links auf Visitenkarte und suchen Sie nach dem Benutzernamen!</b></i></font><br>";
					} else {
						$op_string  = "<font face='Arial' size='2' color='#ffffff'><i><b>$param ist ein unregistrierter Benutzer!<br>";
						$op_string .= "Sie können keine weiteren Informationen zu diesem User erhalten!</b></i></font><br>";
					}
					return $op_string;
					break;
				} else {
					$op_string = "<font face='Arial' size='2' color='#ffffff'><i><b>$param ist nicht im Chat!</b></i></font><br>";
					return $op_string;
					break;					
				}
			} else {
				$sql = "SELECT * FROM on_user WHERE name = '$nick'";
				$db->query($sql);
				$db->nextRecord();
				$room = $db->getField(3);
				$sql = "SELECT * FROM on_user WHERE room = '$room'";
				$db->query($sql);
				if($num = $db->numRows()) {
					$op_string = "<font face='Arial' size='2' color='#ffffff'><i><b>Benutzer im Raum:</b><br>";
					for($i=0;$i<$num;$i++) {
						$db->nextRecord();
						if($db->getField(8)) {
							$op_string .= "* ".$db->getField(1)." (registriert)<br>";
						} else {
							$op_string .= "* ".$db->getField(1)." (unregistriert)<br>";
						}
					}
					$op_string .= "</i></font>";
					return $op_string;
				}
			}
		case "wc":
			if($param) {
				$room = $param;
				$sql = "SELECT * FROM on_user WHERE room = '$room'";
				$db->query($sql);
				if($num = $db->numRows()) {
					$op_string = "<font face='Arial' size='2' color='#ffffff'><i><b>Benutzer im Raum $param:</b><br>";
					for($i=0;$i<$num;$i++) {
						$db->nextRecord();
						if($db->getField(8)) {
							$op_string .= "* ".$db->getField(1)." (registriert)<br>";
						} else {
							$op_string .= "* ".$db->getField(1)." (unregistriert)<br>";
						}
					}
					$op_string .= "</i></font>";
					return $op_string;
				} else {
					$op_string = "<font face='Arial' size='2' color='#ffffff'><i><b>Kein User im Raum $param!</b></i></font><br>";
					return $op_string;
				}
			} else {
				$sql = "SELECT * FROM on_user ORDER BY room";
				$db->query($sql);
				$num = $db->numRows();
				$op_string = "<font face='Arial' size='2' color='#ffffff'><i><b>Benutzer im Chat:</b><br>";
				for($i=0;$i<$num;$i++) {
					$db->nextRecord();
					if($db->getField(8)) {
						$op_string .= "* ".$db->getField(1)." (registriert) im Raum ".$db->getField(3)."<br>";
					} else {
						$op_string .= "* ".$db->getField(1)." (unregistriert) im Raum ".$db->getField(3)."<br>";
					}
				}
				$op_string .= "</i></font>";
				return $op_string;
			}
		case "t":
			$sql = "SELECT * FROM on_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
			if($db->getField(6) > 0) {
				$room = $db->getField(3);
				$op_string = "<font face='Arial' size='2' color='#ffffff'><i>$nick hat ein neues Thema vergeben: '$param'</i></font><br>";
				$regi = @regProc($op_string,$param,$nick,"normal");
				$sql = "UPDATE rooms SET thema='$param' WHERE name = '$room'";
				$db->query($sql);
				break;
			} else {
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Sie haben nicht die n&ouml;tigen Rechte f&uuml;r diesen Befehl!</i></b></font><br>";
				return $op_string;
				break;
			}
	}
}

function sysProc($nick,$action,$param="")
{
	include("includes/config.inc.php");
	$db = new Database($db_host,$db_name,$db_user,$db_pass);
	
	switch($action) {
		case "j":
			$sql = "SELECT * FROM on_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
			$old_room = $db->getField(3);
			$priv = $db->getField(6);
			$sql = "SELECT * FROM on_user WHERE room = '$old_room'";
			$db->query($sql);
			if($db->nextRecord) {
				$still_user = true;
			}
			$sql = "SELECT * FROM rooms WHERE name = '$old_room'";
			$db->query($sql);
			$db->nextRecord();
			if($db->getField(5)) {
				$static = true;
			}
			if($db->getField(2)) {
				$old_locked = true;
			}
			$sql = "SELECT * FROM rooms WHERE name = '$param'";
			$db->query($sql);
			if($db->nextRecord()) {
				if(!$db->getField(2)) {
					$text = "<font face='Arial' size='2' color='#ffffff'><i>-- $nick geht in einen anderen Raum: <b>'$param'</b></i></font><br>";
					$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$old_room\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
					$db->query($sql);
					if(!$still_user) {
						if(!$static) {
							$sql = "DELETE FROM rooms WHERE name='$old_room'";
							$db->query($sql);
						} else {
							if($old_locked) {
								$sql = "UPDATE rooms SET locked = '0' WHERE name = '$old_room'";
								$db->query($sql);
							}
						}
					}
					$text = "<font face='Arial' size='2' color='#ffffff'><i>-- $nick kommt aus dem Raum <b>'$old_room'</b> herein</i></font><br>";
					$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$param\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
					$db->query($sql);
					$sql = "UPDATE on_user SET room='$param' WHERE name='$nick'";
					$db->query($sql);
					break;
				} else {
					if($priv < 2) {
						$op_string = "<font face='Arial' size='2' color='#ffffff'><i><b>Der Raum ist abgesperrt!</b></i></font><br>";
						return $op_string;
						break;
					} else {
						$text = "<font face='Arial' size='2' color='#ffffff'><i>-- $nick geht in einen anderen Raum: <b>'$param'</b></i></font><br>";
						$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$old_room\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
						$db->query($sql);
						if(!$still_user) {
							if(!$static) {
								$sql = "DELETE FROM rooms WHERE name='$old_room'";
								$db->query($sql);
							} else {
								if($old_locked) {
									$sql = "UPDATE rooms SET locked = '0' WHERE name = '$old_room'";
									$db->query($sql);
								}
							}
						}
						$text = "<font face='Arial' size='2' color='#ffffff'><i>-- $nick kommt aus dem Raum <b>'$old_room'</b> herein</i></font><br>";
						$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$param\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
						$db->query($sql);
						$sql = "UPDATE on_user SET room='$param' WHERE name='$nick'";
						$db->query($sql);
						break;
					}
				}
			} else {
				$text = "<font face='Arial' size='2' color='#ffffff'><i>-- $nick geht in einen anderen Raum: <b>'$param'</b></i></font><br>";
				$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$old_room\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
				$db->query($sql);
				$sql = "INSERT INTO rooms (id,name,locked) VALUES (\"\",\"$param\",\"0\")";
				$db->query($sql);
				if(!$still_user) {
					if(!$static) {
						$sql = "DELETE FROM rooms WHERE name='$old_room'";
						$db->query($sql);
					} else {
						if($old_locked) {
							$sql = "UPDATE rooms SET locked = '0' WHERE name = '$old_room'";
							$db->query($sql);
						}
					}
				}
				$text = "<font face='Arial' size='2' color='#ffffff'><i>-- $nick kommt aus dem Raum <b>'$old_room'</b> herein</i></font><br>";
				$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$param\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
				$db->query($sql);
				$sql = "UPDATE on_user SET room='$param' WHERE name='$nick'";
				$db->query($sql);
				break;
			}
			break;
		case "sepa":
			$sql = "SELECT * FROM on_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
			$old_room = $db->getField(3);
			$priv = $db->getField(6);
			$sql = "SELECT * FROM on_user WHERE room = '$old_room'";
			$db->query($sql);
			if($db->nextRecord) {
				$still_user = true;
			}
			$sql = "SELECT * FROM rooms WHERE name = '$old_room'";
			$db->query($sql);
			$db->nextRecord();
			if($db->getField(5)) {
				$static = true;
			}
			if($db->getField(2)) {
				$old_locked = true;
			}
			$sql = "SELECT * FROM rooms WHERE name = '$param'";
			$db->query($sql);
			if($db->nextRecord()) {
				$op_string = "<font face='Arial' size='2' color='#ffffff'><b><i>Der Raum existiert bereits!</i></b></font><br>";
				return $op_string;
				break;
			} else {
				$text = "<font face='Arial' size='2' color='#ffffff'><i>-- $nick geht in einen anderen Raum <b>'$param'</b> und sperrt ab!</i></font><br>";
				$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$old_room\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
				$db->query($sql);
				$sql = "INSERT INTO rooms (id,name,locked) VALUES (\"\",\"$param\",\"1\")";
				$db->query($sql);
				if(!$still_user) {
					if(!$static) {
						$sql = "DELETE FROM rooms WHERE name='$old_room'";
						$db->query($sql);
					} else {
						if($old_locked) {
							$sql = "UPDATE rooms SET locked = '0' WHERE name = '$old_room'";
							$db->query($sql);
						}
					}
				}
				$text = "<font face='Arial' size='2' color='#ffffff'><i>-- $nick kommt aus dem Raum <b>'$old_room'</b> herein</i></font><br>";
				$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$param\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
				$db->query($sql);
				$sql = "UPDATE on_user SET room='$param' WHERE name='$nick'";
				$db->query($sql);
				break;
			}
		case "i":
			$sql = "SELECT * FROM on_user WHERE name = '$param'";
			$db->query($sql);
			if($db->nextRecord()) {
				$sql = "SELECT * FROM on_user WHERE name = '$nick'";
				$db->query($sql);
				$db->nextRecord();
				$i_room = $db->getField(3);
				$sql = "UPDATE on_user SET invite='$i_room' WHERE name = '$param'";
				$db->query($sql);
				$op_string  = "<font face='Arial' size='2' color='#ffffff'><i><b>Sie sind von $nick in den Raum '$i_room' eingeladen worden!<br>";
				$op_string .= "Geben Sie '/a' ein um die Einladung anzunehmen!</b></i></font><br>";
				$regi = @regProc($op_string,"#ffffff",$nick,"whisper:".$param);
				$op2_string  = "<font face='Arial' size='2' color='#ffffff'><i><b>Sie haben $param eingeladen!</b></i></font><br>";
				return $op2_string;
				break;
			} else {
				$op2_string  = "<font face='Arial' size='2' color='#ffffff'><i><b>$param ist nicht im Chat!</b></i></font><br>";
				return $op2_string;
				break;
			}
		case "a":
			$sql = "SELECT * FROM on_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
				$i_room = $db->getField(10);
				$old_room = $db->getField(3);
				$sql = "SELECT * FROM on_user WHERE room = '$old_room'";
				$db->query($sql);
				if($db->nextRecord) {
					$still_user = true;
				}
				$sql = "SELECT * FROM rooms WHERE name = '$old_room'";
				$db->query($sql);
				$db->nextRecord();
				if($db->getField(5)) {
					$static = true;
				}
				if($db->getField(2)) {
					$old_locked = true;
				}
				$text = "<font face='Arial' size='2' color='#ffffff'><i>-- $nick geht in einen anderen Raum: <b>'$i_room'</b></i></font><br>";
				$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$old_room\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
				$db->query($sql);
				$sql = "UPDATE on_user SET room='$i_room' WHERE name='$nick'";
				$db->query($sql);
				if(!$still_user) {
					if(!$static) {
						$sql = "DELETE FROM rooms WHERE name='$old_room'";
						$db->query($sql);
					} else {
						if($old_locked) {
							$sql = "UPDATE rooms SET locked = '0' WHERE name = '$old_room'";
							$db->query($sql);
						}
					}
				}
				$text = "<font face='Arial' size='2' color='#ffffff'><i>-- $nick kommt aus dem Raum <b>'$old_room'</b> herein</i></font><br>";
				$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$i_room\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
				$db->query($sql);
				$sql = "UPDATE on_user SET invite = '' WHERE name = '$nick'";
				$db->query($sql);
			break;
		case "l":
			$sql = "SELECT * FROM on_user WHERE name = '$nick'";
			$db->query($sql);
			$db->nextRecord();
			$priv = $db->getField(6);
			
			if($priv > 0) {
				$sql = "SELECT * FROM on_user WHERE name = '$nick'";
				$db->query($sql);
				$db->nextRecord();
				$room = $db->getField(3);
				$sql = "SELECT * FROM rooms WHERE name = '$room'";
				$db->query($sql);
				$db->nextRecord();
				if($db->getField(2)) {
					$sql = "UPDATE rooms SET locked = '0' WHERE name = '$room'";
					$db->query($sql);
					$text = "<font face='Arial' size='2' color='#ffffff'><i>$nick hat den Raum wieder aufgesperrt!</i></font><br>";
					$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$room\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
					$db->query($sql);
					break;
				} else {
					$sql = "UPDATE rooms SET locked = '1' WHERE name = '$room'";
					$db->query($sql);
					$text = "<font face='Arial' size='2' color='#ffffff'><i>$nick hat den Raum zugesperrt!</i></font><br>";
					$sql = "INSERT INTO chat (id, room, text, user, color, type) VALUES (\"\",\"$room\",\"$text\",\"$nick\",\"#ffffff\",\"normal\")";
					$db->query($sql);
					break;			
				}
			}
	}
}

//===PROCESSOR END===//

?>
Return current item: X-kernoel-x.NET Chat Engine