All pastes #964581 Raw Edit

Something

public text v1 · immutable
#964581 ·published 2008-03-31 10:49 UTC
rendered paste body
<?php
ob_start(); session_start();
include( 'sampQuery.php' );

class Bot {
	function __construct($IRC, $SQL)
	{
		$this->MainChannel = "#LVP.PROP";
		if(is_array($IRC) && is_array($SQL)) {
			$this->sServer 	= $IRC[0];	# Server IP
			$this->iPort	= $IRC[1];  # Server Port
			$this->aDebug = array();
			$this->aInChannel = array();
			if(!$this->Socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) {
				die("Error: Socket's are not allowed");
			} else {
				if(!socket_connect($this->Socket,$this->sServer,$this->iPort)) { 
					 die("Cant connect to IRC ".$Server." on ".$Port);
				}
			}
			if(mysql_connect($SQL[0], $SQL[1], $SQL[2])) {
				if(!mysql_select_db($SQL[3])) {
					die("Cant select database: ".$SQL[4]);
				}
			} else {
				 die("Cant connect to SQL ".$SQL[0]." on ".$SQL[1]);	
			}
		}
		$rSAMP = new QueryServer( "85.17.200.150", 7777 );
		$this->aSAMP['Information']  = $rSAMP->GetInfo( );
		$this->aSAMP['Players'] = $rSAMP->GetDetailedPlayers( );
		$rSAMP->Close( );
	}
	function Send($sData) {
		socket_write($this->Socket,$sData."\r\n");
		echo $sData."<br/>";
	}
	function Say($sChannel, $sInput) {
		$this->Send("PRIVMSG ".$sChannel." :".$sInput);
	}
	function Notice($sUsername, $sInput) {
		$this->Send("NOTICE ".$sUsername." :".$sInput);			
	}
	function Nick($aArray) {
		if(is_array($aArray)) {
			$this->sNick = $aArray[0];
			$this->sRealname = $aArray[1];
			$this->sIdent = $aArray[2];
			if(isset($aArray[4])) {
				$this->sHostname = $aArray[3];
			} else {
				$this->sHostname = 0;
			}
			$this->Send('USER '.$this->sIdent.' '.$this->sHostname.' '.$this->sServer.' :'.$this->sRealname); 
			$this->Send('NICK '.$this->sNick);
		}
		$this->AutoJoin();
	}
	function LogIn($sPassword) {
		$this->Say("NickServ", "IDENTIFY ".$sPassword);
	}
	function Join($sChannel, $sKey=false) {
		$sChannel = strtoupper($sChannel);
		if($sKey) {
			$this->Send("JOIN ".$sChannel." ".$sKey);
		} else {
			$this->Send("JOIN ".$sChannel);
		}
		if(!is_array($this->aInChannel)) {
			$this->aInChannel = array();
		}
		if(!in_array($sChannel,$this->aInChannel)) {
			$this->aInChannel[] = $sChannel;
		}
		array_unique($this->aInChannel);		
	}
	function Part($sChannel, $sReason=false) {
		if($sReason) {
			$this->Send("PART ".$sChannel." :".$sReason);
		} else {
			$this->Send("PART ".$sChannel);
		}
		foreach($this->aInChannel AS $key => $Channel) {
			if($Channel == $sChannel) {
				unset($this->aInChannel[$key]);
			}
		}
		array_unique($this->aInChannel);
	}
	function AutoJoin() {
		$rSQL = mysql_query("SELECT * FROM `tblautojoin`");
		while($aAssoc = mysql_fetch_assoc($rSQL)) {
			if(!empty($aAssoc['Channel'])) {
				if(empty($aAssoc['Key'])) {
					$this->Join($aAssoc['Channel']);
				} else {
					$this->Join($aAssoc['Channel'], $sKey);
				}
				if(!empty($aAssoc['AutoMessage'])) {
					$this->Say($aAssoc['Channel'], $aAssoc['AutoMessage']);
				}
			}
		}
	}
	function AMSG($sInput, $sUsername) {
		array_unique($this->aInChannel);
		foreach($this->aInChannel AS $Key => $Channel) {
			//$this->Say($this->Safe($Channel), "06*** 04AMSG 05".$sInput."04 (".$sUsername.")");
		}
	}
	function Safe($sInput) {
		$sInput = trim($sInput);
		$sInput = htmlentities($sInput,ENT_QUOTES);
		return $sInput;
	}
	function DeSafe($sInput) {
		$sInput = trim($sInput);
		$sInput = html_entity_decode($sInput,ENT_QUOTES);
		return $sInput;
	}


	function PropBuy($sName, $sUsername) {
		$rSQL = mysql_query("SELECT * FROM tblprops WHERE name='".$sName."'") or die(mysql_error());
		if(mysql_num_rows($rSQL)) {
			mysql_query("UPDATE tblprops SET username='".$sUsername."', lastbuytime='".time()."' WHERE name='".$sName."'") or die(mysql_error());
		} else {
			mysql_query("INSERT INTO tblprops (name,username,lastbuytime) VALUES ('".$sName."', '".$sUsername."', '".time()."')") or die(mysql_error());
		}
	}
	function PropSell($sName) {
		mysql_query("UPDATE tblprops SET username='',lastbuytime='' WHERE name='".$sName."'");
	}
	function GetLevel($sUsername) {
		$rSQL = mysql_query("SELECT level FROM tblusers WHERE username='".$sUsername."'");
		$aAssoc = mysql_fetch_assoc($rSQL);
		return $aAssoc['level'];
	}
	function AllowProp($sChannel) {
		$rSQL = mysql_query("SELECT * FROM tblchannel WHERE Channel='".$sChannel."'");
		if(mysql_num_rows($rSQL) == 1) {
			return true;
		} else {
			return false;
		}
	}
	function MessageNoProp($sChannel) {
		array_unique($this->aInChannel);
		$this->sSay = "06*** 04Propcommands are not allowed in this channel, only in: 06|| ";
		$rSQL = mysql_query("SELECT * FROM tblchannel") or die(mysql_error());
		while($aAssoc = mysql_fetch_assoc($rSQL)) {
			if(in_array($this->Safe($aAssoc['Channel']),$this->aInChannel)) {
				$this->sSay.="03".$this->Safe($aAssoc['Channel'])." 06|| 05";
			}
		}
		$this->Say($sChannel, $this->sSay);
	}

	function GetPlayer($ID) {
		foreach($this->aSAMP['Players'] AS $iKey => $aArray) {	
			if($aArray['PlayerID'] == $ID) {
				return $aArray;
				#print_r($this->aSAMP['Players'][$iKey]);
			}
		}
	}
	function GetStats($sUsername) {
		foreach($this->aSAMP['Players'] AS $iKey => $aArray) {	
			if(strtolower($aArray['Nickname']) == strtolower($this->Safe($sUsername))) {
				return $aArray;
				#print_r($this->aSAMP['Players'][$iKey]);
			}
		}
	}
	function Error() {
		$this->Send("QUIT : Error!");
	}
	function Me($sChannel,$sInput) {
		$this->Send('PRIVMSG '.$sChannel.' :' . chr(1) . 'ACTION ' . $sInput . chr(1));
	}
	function StayAlive() {
		while ($sData=@socket_read($this->Socket,65000)) {
			if($sData == "\n") continue; 
			
			$aData = explode(" ",$sData);
			if($aData[0] == "PING") {
				$this->Send("PONG ".$aData[1]);
			}


			if(preg_match("/^:(.+)!(.+) INVITE ".$this->sNick." :\#(.+)$/", $sData, $Match) && $this->GetLevel($Match[1]) >= 2) {
				$this->Join("#".$Match[3]);
			}

			if(preg_match("/^:(.+)!(.+) PRIVMSG ".$this->sNick." :(.+)$/", $sData, $Message)) {
				$this->Say("Delta", $Message[1].": ".$Message[3]);
				$rSQL = mysql_query("SELECT * FROM tblnetwork WHERE username='".$Message[1]."'");
				if(mysql_num_rows($rSQL)) {
					if((preg_match("/^!kick #(.+) (.+)$/", $Message[3], $Match) || preg_match("/^!kick #(.+) (.+) (.+)$/", $Message[3], $Match))) {
						if(isset($Match[3])) {
							$this->Send("KICK #".strtoupper($Match[1])." ".$Match[2]." :".$Match[3]);
						} else {
							$this->Send("KICK #".strtoupper($Match[1])." ".$Match[2]);
						}
					}
					if(preg_match("/^!ban #(.+) (.+)$/", $Message[3], $Match)) {
						$this->Send("MODE #".strtoupper($Match[1])." +b ".$Match[2]);
					} elseif(preg_match("/^!unban #(.+) (.+)$/", $Message[3], $Match)) {
						$this->Send("MODE #".strtoupper($Match[1])." -b ".$Match[2]);
					}
				
				}
			}
			
			if(preg_match("/^:(.+)!(.+) PRIVMSG #(.+) :(.+)$/", $sData, $Message)) {
				echo "[".date('H:i:s')."][#".$Message[3]."] ".$Message[1].": ".$this->Safe(strip_tags($Message[4]))."\r\n<br/>";
				foreach($Message AS $iKey => $sValue) {
					$Message[$iKey] = $this->Safe($sValue);
				}
				if(preg_match("/^!restart$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 4) {
					array_unique($this->aInChannel);
					foreach($this->aInChannel AS $iKey => $sValue) {
						setcookie("Channel[".$sValue."]", $sValue, time() + time());
					}
					$this->AMSG("Restarting Bot",$Message[1]);
					$this->Send("QUIT");
					
				}
				if(preg_match("/^!server$/", $Message[4])) {	
					$this->Say("#".$Message[3], "07*** 04Host: 07".$this->aSAMP['Information']['Hostname']."06 || 04Players: 07".$this->aSAMP['Information']['Players']."05/07".$this->aSAMP['Information']['MaxPlayers']." 06 || 04Password: 07".( $this->aSAMP['Information']['Password'] == 1 ? '04Yes' : '03No' ));
				}	
				if(preg_match("/^!add (.+) ([1-4])$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 4) {
					$rSQL = mysql_query("SELECT * FROM tblusers WHERE username='".$this->Safe($Match[1])."'");
					if(mysql_num_rows($rSQL)) {
						$aAssoc = mysql_fetch_assoc($rSQL);
						$this->Say("#".$Message[3], "06*** 04The user 05".$Match[1].", level ".$aAssoc['level']." 04has already been add");
					} else {
						mysql_query("INSERT INTO tblusers (username, level) VALUES ('".$this->Safe($Match[1])."', '".$this->Safe($Match[2])."')");
						$this->Say("#".$Message[3], "06*** 04The user 05".$Match[1]."04, 05level ".$Match[2]." 04has been add");
					}
				}
				if(preg_match("/^!network (rem|add) (.+)$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 4) {
					if($Match[1] == 'add') {
						$rSQL = mysql_query("SELECT * FROM tblnetwork WHERE username='".$this->Safe($Match[2])."'");
						if(mysql_num_rows($rSQL)) {
							$this->Say("#".$Message[3], "06*** 04The bot 05".$Match[2]." 04is already in the network");
						} else {
							mysql_query("INSERT INTO tblnetwork (username) VALUES ('".$this->Safe($Match[2])."')");
							$this->Say("#".$Message[3], "06*** 04The user 05".$Match[2]."04 has been add to the network");
						}					
					} elseif($Match[1] == 'rem') {
						$rSQL = mysql_query("SELECT * FROM tblnetwork WHERE username='".$this->Safe($Match[2])."'");
						if(mysql_num_rows($rSQL)) {
							$this->Say("#".$Message[3], "06*** 04The bot 05".$Match[2]." 04has been removed from the network");
							mysql_query("DELETE FROM tblnetwork WHERE username='".$this->Safe($Match[2])."'");
						} else {
							$this->Say("#".$Message[3], "06*** 04The bot 05".$Match[2]."04 doesn't exists in the network");
						}
					}
				}

				
				if(preg_match("/^!rem (.+)$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 4) {
					$rSQL = mysql_query("SELECT * FROM tblusers WHERE username='".$this->Safe($Match[1])."'");
					if(mysql_num_rows($rSQL)) {
						$aAssoc = mysql_fetch_assoc($rSQL);
						$this->Say("#".$Message[3], "06*** 04The user 05".$Match[1].", level ".$aAssoc['level']." 04has been removed");
						mysql_query("DELETE FROM tblusers WHERE username='".$this->Safe($Match[1])."'");
					} else {
						$this->Say("#".$Message[3], "06*** 04The user 05".$Match[1]."04 doesn't exists");
					}
				}
				if(preg_match("/^!resetids$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 3) {
					$rSQL = mysql_query("SELECT * FROM tblid");
					$this->Say("#".$Message[3], "06*** 04All ids 05(".mysql_num_rows($rSQL).")04 are reseted");
					mysql_query("DELETE FROM tblid");
				}
				if(preg_match("/^!resetprops$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 3) {
					$rSQL = mysql_query("SELECT * FROM tblprops WHERE username != ''");
					$this->Say("#".$Message[3], "06*** 04All props 05(".mysql_num_rows($rSQL).")04 are reseted");
					mysql_query("UPDATE tblprops SET username='', lastbuytime=''");
				}
				if(preg_match("/^!nick (.+)$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 3) {
					mysql_query("INSERT INTO tblnickchange (newnick,oldnick,username) VALUES ('".$this->Safe($Match[1])."', '".$this->sNick."', '".$Message[1]."')");
					$this->Send('NICK '.$Match[1]);
					$this->AMSG("Nickname has been changed from 04".$this->sNick." 05to 04".$Match[1],$Message[1]);
					$this->sNick = $Match[1];
				}
				
				if(preg_match("/^!join #(.+)$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 2) {
					if(in_array("#".$this->Safe($Match[1]),$aInChannel)) {
						$this->Say("#".$Message[3], "06*** 04I'm already in the channel: 05#".$Match[1]);
					} else {
						$this->Join("#".$Match[1]);
						$this->Say("#".$Message[3], "06*** 04Joining the channel: 05#".$Match[1]);
					}
				}
				if((preg_match("/^!part #(.+)$/", $Message[4], $Match) || $Message[4] == '!part') && $this->GetLevel($Message[1]) >= 2) {
					if(!isset($Match[1])) $Match[1] = $Message[3];
					$Match[1] = strtoupper($Match[1]);
					$rSQL = mysql_query("SELECT * FROM tblautojoin WHERE Channel='#".$this->Safe($Match[1])."'");
					if(mysql_num_rows($rSQL)) {
						$this->Say("#".$Message[3], "06*** 04It's not allowed to part autojoin channels");
					} else {
						$this->Part("#".$Match[1], " 04Part by 05".$Message[1]);
						$this->Say("#".$Message[3], "06*** 04Parting the channel: 05#".$Match[1]);
					}
				}
				if(preg_match("/^!part all$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 3) {
					array_unique($this->aInChannel);	
					$this->AMSG("Parting all NON-AutoJoin Channels", $Message[1]);
					$rSQL = mysql_query("SELECT * FROM tblautojoin") or die(mysql_error());
					while($aAssoc = mysql_fetch_assoc($rSQL)) {
						$aAutoJoin[] = strtoupper($aAssoc['Channel']);
					}
					foreach($this->aInChannel AS $key => $sChannel) {
						$sChannel = strtoupper($sChannel);
						if(!in_array($this->Safe($sChannel),$aAutoJoin)) {
							$this->Part($sChannel);
						}
					}
				}
				if(preg_match("/^!channels$/", $Message[4], $Match)) {
					array_unique($this->aInChannel);
					$this->sSay = "06*** 04I'm in these channels 06(".count($this->aInChannel).")04: 06|| ";
					foreach($this->aInChannel AS $key => $sChannel) {
						$rSQL = mysql_query("SELECT * FROM tblchannel WHERE Channel='".$this->Safe($sChannel)."'");
						if(mysql_num_rows($rSQL)) {
							$this->sSay .= "03".$this->Safe($sChannel)." 06|| 05";
						} else {
							$this->sSay .= "05".$this->Safe($sChannel)." 06|| 05";
						}
					}
					$this->Say("#".$Message[3], $this->sSay);
				}			
				if(($Message[4] == "!allow" || preg_match("/^!allow #(.+)$/", $Message[4], $Match)) && $this->GetLevel($Message[1]) >= 3) {
					if(!isset($Match[1])) $Match[1] = $Message[3];
					$rSQL = mysql_query("SELECT * FROM tblchannel WHERE Channel='#".$this->Safe($Match[1])."'");

					if(!mysql_num_rows($rSQL)) {
						mysql_query("INSERT INTO tblchannel (Channel) VALUES ('#".strtoupper($Match[1])."')") or die(mysql_error());
					}
					$this->Say("#".$Message[3], "06*** 04Prop commands are now allowed in: 03#".$Match[1]);	
					
				}
				if(($Message[4] == "!disallow" || preg_match("/^!disallow #(.+)$/", $Message[4], $Match)) && $this->GetLevel($Message[1]) >= 3) {
					if(!isset($Match[1])) $Match[1] = $Message[3];
					$rSQL = mysql_query("SELECT * FROM tblchannel WHERE Channel='#".$this->Safe($Match[1])."'");
					if(mysql_num_rows($rSQL)) {
						mysql_query("DELETE FROM tblchannel WHERE Channel='#".$this->Safe($Match[1])."'");
					}
					$this->Say("#".$Message[3], "06*** 04Prop commands are now not allowed in: 05#".$Match[1]);	
				}
				if(preg_match("/^!amsg (.+)$/", $Message[4], $Match) && $this->GetLevel($Message[1]) >= 3) {
					$this->AMSG($this->Safe($Match[1]),$Message[1]);
				}

	

				if(preg_match("/^!getid (.+)$/", $Message[4], $Match)) {
					if(!$this->AllowProp("#".$Message[3])) {
						$this->MessageNoProp("#".$Message[3]);
					} else {
						if(is_array($this->aSAMP['Players'])) {
							array_rand($this->aSAMP['Players'],4);
							$i = 1; $bDidIReturn = false;
							foreach($this->aSAMP['Players'] AS $iKey => $aArray) {
								foreach($aArray AS $iKey => $sValue) { $aArray[$iKey] = $this->Safe($sValue); }
								if(strtolower($aArray['Nickname']) == strtolower($Match[1]) || preg_match("/".str_replace("[", "\[", str_replace("]", "\]", strtolower($Match[1])))."/", strtolower($aArray['Nickname']) )) {
									if($i < 4) {
										$this->Say("#".$Message[3], "06*** 04ID05 ".$aArray['PlayerID']." 06|| 04Username:05 ".$aArray['Nickname']." 06|| 04Cash:05 $".$aArray['Score']." 06 || 04Ping: 05".$aArray['Ping']);
										$i++; $bDidIReturn = true;
									}
								}
							}
							if(!$bDidIReturn) {
								$this->Say("#".$Message[3], "06*** 04No ID found for 05".$Match[1]);
							}
						} else {
							$this->Error();
						}
					}
				}
				if(preg_match("/^!botwar$/", $Message[4], $Match)) {
						
					$this->Me("#".$Message[3], "Runs away");;
				
				}
				if(preg_match("/^!list (.+)$/", $Message[4], $Match)) {
					if(!$this->AllowProp("#".$Message[3])) {
						$this->MessageNoProp("#".$Message[3]);
					} else {
						if(is_numeric($this->Safe($Match[1]))) {
							$aStats = $this->GetPlayer($this->Safe($Match[1]));
							if(is_array($aStats)) {
								$Match[1] = $aStats['Nickname'];
							} else {
								$Match[1] = false;
							}
						}
						if(!$Match[1]) {
							$this->Say("#".$Message[3], "06*** 04No username found for this id.");
						} else {
								$rSQL = mysql_query("SELECT * FROM tblprops WHERE `username` = '".$this->Safe($Match[1])."'") or die(mysql_error());
								$this->Say("#".$Message[3], "06*** 04Properties from: 05".$Match[1]);
								if(mysql_num_rows($rSQL)) {
									while($aAssoc = mysql_fetch_assoc($rSQL)) {
										$this->Say("#".$Message[3], "06*** 04Property: 05".$this->DeSafe($aAssoc['name'])." 06|| 04Own Time: 05".round(((time() - $aAssoc['lastbuytime'])/60),1)." minutes");
									}
								} else {
									$this->Say("#".$Message[3], "06*** 04No properties found for 05".$Match[1]);
								}
								
							
						}
					}
				}
				
				if(preg_match("/^!owner (.{3,30})$/", $Message[4], $Match)) {
					if(!$this->AllowProp("#".$Message[3])) {
						$this->MessageNoProp("#".$Message[3]);
					} else {
						$rSQL = mysql_query("SELECT * FROM tblprops WHERE `username` != '' AND name LIKE '%".$this->Safe($Match[1])."%' ORDER BY lastbuytime ASC LIMIT 3") or die(mysql_error());
						if(mysql_num_rows($rSQL)) {
							while($aAssoc = mysql_fetch_assoc($rSQL)) {
								$aStats = $this->GetStats($aAssoc['username']);
								$this->Say("#".$Message[3], "06*** 04Property: 05".$this->DeSafe($this->DeSafe($aAssoc['name']))." 06|| 04Own Time: 05".round(((time() - $aAssoc['lastbuytime'])/60),1)." minutes 06|| 04Username: 05".$aAssoc['username']." 04[05 ".$aStats['PlayerID']." 04]");
							}
						} else {
							$this->Say("#".$Message[3], "06*** 04No properties found at 05".$Match[1]);
						}
					}
				}
				/* PropTool*/
				$LVPBot = array("Nuwini", "Nuweni", "Nuwoni", "Nuwuni", "Nuwani");
				if(in_array($Message[1],$LVPBot) && $Message[3] == "LVP.Echo") {
					if(preg_match("/^02\[(.+)\] 07(.+): D (.+)$/", $Message[4], $Match)) {
						if($this->GetLevel($Match[2]) >= 1) {
							$this->Say("#LVP.prop", "02[".$Match[1]."]  07".$Match[2].": ".$this->DeSafe($Match[3]));
						}
					}

					if(preg_match("/^02\[(.+)\] 07(.+): deltabot, are you on(.+)/", strtolower($Message[4]), $Match)) {
						$this->Say("#LVP.echo", "!msg Yes im online:)");
					}

				
					if(preg_match("/02\[([0-9]{0,3})\] 03\*\*\* (.+) joined the game./", $Message[4], $Match)) {
						$rSQL = mysql_query("SELECT * FROM tblrestore WHERE quittime > '".(time()-60*5)."' AND username='".$this->Safe($Match[2])."'");
						if(mysql_num_rows($rSQL)) {
							$aAssoc = mysql_fetch_assoc($rSQL);
							$aExplode = explode(",", $aAssoc['properties']);
							foreach($aExplode AS $iKey => $sProp) {
								mysql_query("UPDATE tblprops SET username='".$this->Safe($Match[2])."',lastbuytime='".time()."' WHERE name='".$sProp."'");
							}
							$aStats = $this->GetStats($Match[2]);
							$this->Say("#LVP.prop", "06*** 04The user 05".$this->Safe($Match[2])." 04[05 ".$aStats['PlayerID']." 04] 04 has been connected 05(Properties are restored, 04".(time() - $aAssoc['quittime'])." seconds05)");
							mysql_query("DELETE FROM tblrestore WHERE username='".$this->Safe($Match[2])."'");				
						}						
					} elseif(preg_match("/02\[([0-9]{0,3})\] 03\*\*\* (.+) left the game \((.+)\)./", $Message[4], $Match)) {
						$rSQL = mysql_query("SELECT * FROM tblprops WHERE `username`='".$this->Safe($Match[2])."'") or die(mysql_error());
						if(mysql_num_rows($rSQL)) {
							if($this->Safe($Match[3]) == "timeout") {
								$sProps = "";
								while($aAssoc = mysql_fetch_assoc($rSQL)) {
									$sProps .= $this->Safe($aAssoc['name']).",";
								}
								$rSQL = mysql_query("SELECT * FROM tblrestore WHERE username='".$this->Safe($Match[3])."'");
								if(mysql_num_rows($rSQL)) {
									mysql_query("UPDATE tblrestore SET quittime='".time()."', properties='".$this->Safe($sProps)."' WHERE username='".$this->Safe($Match[3])."'");
								} else {
									mysql_query("INSERT INTO tblrestore (quittime,username,properties) VALUES ('".time()."', '".$this->Safe($Match[2])."', '".$this->Safe($sProps)."')") or die(mysql_error());
								}
							}
							mysql_query("UPDATE tblprops SET username='',lastbuytime='' WHERE username='".$this->Safe($Match[2])."'") or die(mysql_error());
							$this->Say("#LVP.prop", "06*** 04The user 05".$this->Safe($Match[2])."04 has been disconnected 05(Properties are deleted, timeout)");
						}

					}
					if(preg_match("/3\*\*\* (.+) has bought the property (.+)!/", $Message[4], $Match)) {
						$aStats = $this->GetStats($this->Safe($Match[1]));
						$this->Say("#LVP.prop", "04Username: 05".$this->Safe($Match[1])." 04[ 05".$aStats['PlayerID']." 04] 06|| 04Bought Property: 05".$this->DeSafe($Match[2]));
						$this->PropBuy($this->Safe($Match[2]), $this->Safe($Match[1]));
					}
					if(preg_match("/3\*\*\* (.+) has sold the property (.+)!/", $Message[4], $Match)) {
						$aStats = $this->GetStats($this->Safe($Match[1]));
						$this->Say("#LVP.prop", "04Username: 05".$this->Safe($Match[1])." 04[ 05".$aStats['PlayerID']." 04] 06|| 04Sold Property: 05".$this->DeSafe($Match[2]));
						$this->PropSell($this->Safe($Match[2]));
					}

				}
			}		
		} 
	}
	
}
$oBOT = new BOT(
	array("irc.gtanet.com",6667),
	array("localhost","*","*","BOT")
);
$oBOT->Nick(
	array("DeltaBotje", "Propertie Bot", "BOT")
);
$oBOT->LogIn("*");
if (isset($_COOKIE['Channel'])) {
    foreach ($_COOKIE['Channel'] as $iKey => $sChannel) {
        $oBOT->Join($sChannel);
		setcookie("Channel[".$iKey."]", "", time() - time());
	}
}

$oBOT->StayAlive();
?>