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

$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"){

	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));


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);
	$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) {
	$command = strtolower($match[2]);
	$comment = nifty3_convert($match[3]);
	switch ($command) {
		case 'help':
			$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.';
		case 'quit':
		case 'part':
		case 'leave':
			$send_message='Quit: '.($send_message?$send_message:'Leaving');
		case 'kick':
		case 'kill':
		case 'boot':
			if ($send_message) {
				if (!preg_match('/^\\\\+"([^"]*?)\\\\+"\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]}'");
					} 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!";
		case 'ome':
		case 'oaction':
			if (!$user_isadmin) {
				$error_message = "Only administrators can use '$command'!";
		case 'me':
		case 'action':
			if (!$send_message) {
				$error_message = "Don't type blank messages!";
		case 'away':
		case 'a':
		case 'afk':
		case 'wall':
		case 'omsg':
			if (!$user_isadmin) {
				$error_message = "Only administrators can use '$command'!";
			if ($command && $command!='msg' && $command != 'wall' && $command != 'omsg') {
				$error_message = "Invalid command '$command'!";
			if (!$command && !$comment) {
				$error_message = "Don't type blank messages!";
	//$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'))
			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%">
    <td><IFRAME SRC="about:blank" name="chatPost" width="5" height="5" frameborder="0" align="center" scrolling="no"></IFRAME></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>
<?if (isset($OekakiU)){?>
Return current item: OekakiPoteto