Location: PHPKode > scripts > OekakiPoteto > oekakipoteto/newchat/chatinput.php
<?
function rootpath(){
	global $DOCUMENT_ROOT;
	$rootdir = $DOCUMENT_ROOT;
	if ($DOCUMENT_ROOT[strlen($DOCUMENT_ROOT)] == "/"){
		return $rootdir;
	} else {
		$rootdir = $rootdir."/";
		return $rootdir;
	}
}

include('config.php');
include('banscript.php');	
include('dbconn.php');
include('niftytoo.php');
?>
<html>
<?
$user_isadmin = false;

if($OekakiU == ""){
	if (!$comment) include("templates/".$template.".php");
} else {
	$testrslt = mysql_query("SELECT usrname, usrpass, templatesel, usrflags FROM ".$OekakiPoteto_MemberPrefix."oekaki WHERE usrname='$OekakiU'");

	//extract the fields selected above into variables
	$row = mysql_fetch_array($testrslt);

	$user_isadmin = eregi('A',$row[usrflags]);
	
	if (!eregi('G',$row[usrflags])) unset($oekakiU);

	if (!$comment) include("templates/".$row[templatesel].".php");
}


if($apostrophes == "0"){
	set_magic_quotes_runtime(0);

	function nifty3_convert($in){
		return $in;
	}
} else {
	function nifty3_convert($in){
		return addslashes($in);
	}
}
function l33tcode($text) {
	return str_replace(array('e','t','o','ule','i'),array('3','7','0','00l','1'),strtolower($text));
}

$error_message=false;

if ($quit) $comment = '/quit';

if ($comment && isset($OekakiU) && ($result = mysql_query("SELECT lastmessage,afk FROM ".$OekakiPoteto_MemberPrefix."oekakichatmodusers WHERE usrname = '$OekakiU'"))&&($row = mysql_fetch_array($result))) {
	$hostname = gethostbyaddr($REMOTE_ADDR);
	
	preg_match('/^(\/\/?([a-z-0-9]+))?\s*(.*)$/i',$comment,$match);
	$aliases = array(
		'grin'		=> '/me grins evilly',
		'batman'	=> '/kick '.$OekakiU.' The batman kick!',
		'marcello'	=> 'doo dee dum dee doo!!!',
		'cheese'	=> '/away I am off to get cheese!!!',
		'save'		=> '/away I am off to save the world from evil microsofties!',
		'ponder'	=> 'are you pondering what I\'m pondering?',
		'way'		=> 'the way I see it, we could be in the middle of a---!',
		'worse'		=> 'what could be worse? *thunder cracks*',
		'reverse'	=> addslashes(strrev(stripslashes($match[3]))),
		'l33t'		=> l33tcode($match[3]),
		'lol'		=> 'omg! that is the @(#*&$ing funniest thing I\'ve ever heard!!! LOL!',
		'slap'		=> '/me slaps '.$match[3].' around a bit with a large trout.',
		'unix'		=> '/me drops a 3-ton unix manual on '.$match[3].'\'s head. (not that anyone gets it)',
		'linux'		=> '/me squeezes the linux penguin!',
		'fuck'		=> 'Chicken fries!',
		'damn'		=> 'Horn swaggler!',
		'crap'		=> 'Flying yams!',
		'shit'		=> 'Uncle !',
		'ranmaguy'	=> 'Um ya, ranmaguy, that um...you know....guy-thing.',
		'ine'		=> '/away running from you smelly people',
		'love'		=> '/quit Type /love, it\'s really cool!',
		'dog'		=> 'Chili Cheese Dog!'
		);
	$command = strtolower($match[2]);
	foreach ($aliases as $alias => $target) 
		if ($command==$alias) {
			$comment=$target;
			break;
		}
	preg_match('/^(\/\/?([a-z-0-9]+))?\s*(.*)$/i',$comment,$match);
	$command = strtolower($match[2]);
	$comment = nifty3_convert($match[3]);
	$send_message=$comment;
	$send_command="MESSAGE";
	$send_quit=false;
	$send_afk=false;
	$add_o="";
	switch ($command) {
		case 'help':
			$send_command=false;
			$error_message =	'HELP - OPMOD Chat v1.1 by marcello\n'.
								'/away, /afk, /a:\n\tset away and leave an optional message, example: /away eating!\n'.
								'/part, /leave, /quit:\n\tend chat session with an optional message, example: /quit seeya next week\n'.
								'/kick, /kill, /boot:\n\tkick a user with optional message (administrators only!), example: /kick MisterIdiot get a life\n'.
								'/me, /action:\n\tsend an \'action\' message, example: /me likes to eat ice cream\n'.
								'/omsg, /wall:\n\tsend a regular message to administrators only, example: /wall someone stole my lunch money!\n'.
      							'/ome, /oaction\n\tsend an \'action\' message to administrators only.\n'.
      							'/help:\n\topens this chat.';
			break;
		case 'quit':
		case 'part':
		case 'leave':
			$send_command='UQUIT';
			$send_message='Quit: '.($send_message?$send_message:'Leaving');
			$send_quit=true;
			break;
		case 'kick':
		case 'kill':
		case 'boot':
			$send_command=false;
			if ($send_message) {
				if (!preg_match('/^\\\\+"([^"]*?)\\\\+"\s*(.*)/',$send_message,$match))
					preg_match('/^([^\s]*)\s*(.*)/',$send_message,$match);
				if ($OekakiU!='marcello'&&eregi('marcello',$match[1]))
					$error_message = "You don't *really* want to kick marcello, do you!?";
				else if ($user_isadmin) {
					$result = mysql_query("SELECT ".$OekakiPoteto_MemberPrefix."oekakichatmodusers.usrname,lastmessage,usrflags,afk FROM ".$OekakiPoteto_MemberPrefix."oekakichatmodusers LEFT JOIN ".$OekakiPoteto_MemberPrefix."oekaki USING(usrname) WHERE ".$OekakiPoteto_MemberPrefix."oekakichatmodusers.usrname = '$match[1]'");
					if ($result && ($row = mysql_fetch_array($result))) {
						$send_message = '\\"'.$row[usrname].'\\" '.$match[2];
						mysql_query("DELETE FROM ".$OekakiPoteto_MemberPrefix."oekakichatmodusers WHERE usrname='{$match[1]}'");
						$send_command="KICK";
					} else
						$error_message = "Can't kick user '{$match[1]}' (not on chat?)!";
				} else
					$error_message = "Only administrators can kick users!";
			} else
				$error_message = "No user to kick!";
				
			break;
		case 'ome':
		case 'oaction':
			if (!$user_isadmin) {
				$send_command=false;
				$error_message = "Only administrators can use '$command'!";
				break;
			}
			$add_o="O";
		case 'me':
		case 'action':
			$send_command=$add_o."ACTION";
			if (!$send_message) {
				$send_command=false;
				$error_message = "Don't type blank messages!";
			}
			break;
		case 'away':
		case 'a':
		case 'afk':
			$send_command="AWAY";
			$send_afk=true;
			break;
		case 'wall':
		case 'omsg':
			if (!$user_isadmin) {
				$send_command=false;
				$error_message = "Only administrators can use '$command'!";
				break;
			}
			$add_o="O";
		default:
			$send_command=$add_o."MESSAGE";
			if ($command && $command!='msg' && $command != 'wall' && $command != 'omsg') {
				$send_command=false;
				$error_message = "Invalid command '$command'!";
			}
			if (!$command && !$comment) {
				$send_command=false;
				$error_message = "Don't type blank messages!";
			}
			break;
		
	}
	//$result5 = mysql_query("SELECT count(ChatID) as rowno FROM ".$OekakiPoteto_MemberPrefix."oekakichatmod");
	//$rownum2 = mysql_result($result5, 0, 'rowno');
	//if(intval($rownum2) > $chatMax) {
	//	$chatdel = mysql_query("DELETE FROM ".$OekakiPoteto_MemberPrefix."oekakichatmod");
	//}
	if (isset($OekakiU) && $send_command) {
		if ($send_quit)
			mysql_query("DELETE FROM ".$OekakiPoteto_MemberPrefix."oekakichatmodusers WHERE usrname='{$OekakiU}'");
		else {
			if (!$send_afk && ($result = mysql_query("SELECT afk FROM ".$OekakiPoteto_MemberPrefix."oekakichatmodusers WHERE usrname = '$OekakiU'"))&&($row = mysql_fetch_array($result)) && ($row[afk]=='yes'))
				$send_command.='*';
			mysql_query("UPDATE ".$OekakiPoteto_MemberPrefix."oekakichatmodusers SET afk='".($send_afk?'yes':'no')."',lastmessage=NOW() WHERE usrname='{$OekakiU}'");
		}
		$result = mysql_query("INSERT into ".$OekakiPoteto_MemberPrefix."oekakichatmod SET command='$send_command',usrname='$OekakiU', comment='$send_message',hostname='$hostname', IP='$REMOTE_ADDR'");
		
		mysql_query("DELETE FROM ".$OekakiPoteto_MemberPrefix."oekakichatmod WHERE DATE_ADD(session_time,INTERVAL 2 HOUR) < NOW()");
	}

} else if ($comment) $error_message = "You can't post if you're not logged in!";

?>
<body style="margin:0px"<?if($error_message){?> onLoad="alert('<?=str_replace(array('\'','"'),array('\\\'','&quot;'),$error_message)?>');"> <!-- <?=$error_message?> --><?}?>>
<?if(!$comment  && !$error_message) {?>
<?if (isset($OekakiU)){?><form method="post" target="chatPost" name="form1" onSubmit="setTimeout('document.forms.form1.comment.value=\'\'',2)"><?}?>
  <table border="0" cellspacing="0" cellpadding="2" align="center" class="header" width="100%">
    <tr> 
    <td><IFRAME SRC="about:blank" name="chatPost" width="5" height="5" frameborder="0" align="center" scrolling="no"></IFRAME></td>
      <td><?if(isset($OekakiU)){?>Message:</td>
      <td width="100%"><input type="text" name="comment" class="txtinput" size="25" style="width:100%"></td>
      <td><input type="hidden" name="send" value="Send"><input type="submit" name="submit" value="Send" class="submit"></td>
      <td><input type="submit" name="quit" value="Quit" class="submit">
      
      <?}else{?>Please login to speak on chat.<?}?></td>
    </tr>
  </table>
<?if (isset($OekakiU)){?>
</form>
<script><!--
document.form1.comment.focus();//--></script>
<?}?>
<?}?>
</body>
</html>
Return current item: OekakiPoteto