Jump to content


[Hack] Allow Users to select Nick for Chat


7 replies to this topic

#1 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 05 July 2006 - 09:22 AM

Here is a hack that allows users to enter a custom Nick for the MKPortal java chat. If they do not enter a custom Nick then it will use their forum Username for the Nick.

FIND in /mkportal/lang/*/lang_chat.php:
?>
ADD ABOVE:
$langmk['ch_selectnick'] = "Select Nick:";
$langmk['ch_username1'] = "Use";
$langmk['ch_username2'] = "as Nick:";
$langmk['ch_customnick'] = "Or Enter Custom Nick:";
$langmk['ch_enterchat'] = "Enter Chat";
FIND in /mkportal/modules/chat/tpl_chat.php:
function view_chat($chat_server, $chat_port, $chat_channel) {
REPLACE WITH:
//function view_chat($chat_server, $chat_port, $chat_channel) {
function view_chat($chat_server, $chat_port, $chat_channel, $nick) { // Nick Hack
FIND:
				  <param name="nick" value="{$mkportals->member['name']}" />
REPLACE WITH:
		  <!--<param name="nick" value="{$mkportals->member['name']}" />-->
		  <!-- Nick Hack -->
				  <param name="nick" value="{$nick}" />
FIND in /mkportal/modules/chat/index.php (function mk_chat):
		switch($mkportals->input['op']) {
				case 'refresh_list':
					$this->refresh_list();
				break;
				default:
					$this->run_chat();
				break;
		}
REPLACE WITH:
		// Nick Hack
			switch($mkportals->input['op']) {
				case 'refresh_list':
					$this->refresh_list();
			break;
				case 'run_chat':
					$this->run_chat();
				break;
			default:
				$this->select_nick();
				//$this->run_chat();
				break;
		}
		// end Nick Hack
FIND:
	function run_chat() {
ADD ABOVE:
	function select_nick() {
		global $mkportals, $DB, $mklib, $Skin;


		$output = 
<<<EOF
<tr>
  <td>
	
	  <table cellspacing="0" width="100%" border="0">
	<tr>
	  <td class="tdblock">{$mklib->lang['ch_welc']}</td>
	</tr>	
	<tr>
	  <td valign="top" align="center" class="taburlo">
 		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
				<tr>
		<td valign="top">
EOF;

$output .= "
			<form action="index.php?ind=chat&op=run_chat" name="editor" method="post" enctype="multipart/form-data">
			<table width="100%" border="0">
			  <tr>
			<td class="titadmin" style="border-top: 0" colspan="2">{$mklib->lang['ch_selectnick']}

			</td>	   
			  </tr>
			  <tr>
			<td width="15%" style="padding-top: 20px">{$mklib->lang['ch_username1']} <span class="mktxtcontr">{$mkportals->member['name']}</span> {$mklib->lang['ch_username2']}</td>
			<td width="85%" style="padding-top: 20px"> </td>
			  </tr>
			  <tr>
			<td valign="top" style="padding-top: 20px">{$mklib->lang['ch_customnick']}</td>
			<td style="padding-top: 20px">
			  <input type="text" name="customnick" size="40" class="bgselect" />
			</td>
			  </tr>
	  
			  <tr>
			<td style="padding-top: 20px"><input type="submit" value="{$mklib->lang['ch_enterchat']}" class="bgselect" /></td>
			<td align="left"> </td>
			  </tr>
			</table>
			</form>
		  </td>
		</tr>

			  ";	
	

$output .= 
<<<EOF
		</td>
		  </tr>
		</table>							 
	  </td>
	</tr>
	  </table>
	</div>
	
	


	<div align="center"><a href="http://www.mkportal.it" target="_blank">MKPChat</a> ©2004-2005 - SelectNick by <a href="http://www.visiblesoul.net/" title="Visible Soul Website Design - Corpus Christi, Texas" target="_blank">visible soul</a></div>

  </td>
</tr>
EOF;


		$blocks .= $Skin->view_block("{$mklib->lang['ch_pagetitle']}", $output);
		$mklib->printpage("0", "0", "{$mklib->lang['ch_pagetitle']}", $blocks);
 	}
FIND in (function run_chat):
		$nick = $mkportals->member['name'];
REPLACE WITH:
		// Nick Hack
		$nick = $mkportals->input['customnick'];

		if (!$nick || $nick == '')
			$nick = $mkportals->member['name'];
		// end Nick Hack
FIND:
			$DB->query("UPDATE mkp_chat SET run_time='$run_time' WHERE id='$id' ");
REPLACE WITH:
			// Nick Hack
			//$DB->query("UPDATE mkp_chat SET run_time='$run_time' WHERE id='$id' ");
			$DB->query("UPDATE mkp_chat SET nick='$nick', run_time='$run_time' WHERE id='$id'");
			// end Nick Hack
FIND:
		$output  = $this->tpl->view_chat($chat_server, $chat_port, $chat_channel);
REPLACE WITH:
		//$output  = $this->tpl->view_chat($chat_server, $chat_port, $chat_channel);
			$output  = $this->tpl->view_chat($chat_server, $chat_port, $chat_channel, $nick); // Nick Hack
FIND in (function refresh_list):
		$nick = $mkportals->member['name'];
REPLACE WITH:
		//$nick = $mkportals->member['name'];
FIND:
		$DB->query("select nick FROM mkp_chat WHERE id = '$id'");
ADD BELOW:
		// Nick Hack
		$row = $DB->fetch_row();		
		
		$nick = $row['nick'];
		// end Nick Hack
FIND:
			$query="INSERT INTO mkp_chat(id, nick, run_time)VALUES('$id', '$nick', '$run_time')";
ADD ABOVE:
			$nick = $mkportals->member['name']; // Nick Hack



Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard

#2 neoxrg

  • Members
  • 8 posts
  • Location:Netherlands
  • Aruba

Posted 06 July 2006 - 12:17 PM

hey how are you i tried the hack out but i'm getting a parse error can't seem to find out wha't it's about can you take a look it's the strangest thing cauz there is no line 242

this is the error that i get..

Parse error: parse error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /storage/mijndomein/users/017840/public/sites/www.chill-zone.nl/mkportal/modules/chat/tpl_chat.php on line 242
and this is line 238 to 241

EOF;
}
}
?>

thnks
The Reality Is That The Hitman Doesn't Exist. He Is An Illusion, An Entity Which His Enemies Cannot See Or Touch.

#3 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 06 July 2006 - 01:44 PM

neoxrg said:

hey how are you i tried the hack out but i'm getting a parse error can't seem to find out wha't it's about can you take a look it's the strangest thing cauz there is no line 242
I double-checked my instructions and they are correct. You must have made some small error when you edited the files.

Be sure you are using an editor that supports php. If in doubt use MS Wordpad.

Also be sure that there are no linebreaks after the closing php tag "?>" in your edited files.

Be very careful also to make the edits in the correct functions in /chat/index.php


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard

#4 neoxrg

  • Members
  • 8 posts
  • Location:Netherlands
  • Aruba

Posted 06 July 2006 - 02:57 PM

hey thnks i double checked everything and when i used dzsoft php editor it worked i am getting on chat but i get a wierd warning on the top of my screen and the second thing is that the nickname you choose is not set.. i still get the standaard name don't know what i did wrong :s


this one

Warning: Missing argument 4 for view_chat() in /storage/mijndomein/users/017840/public/sites/www.chill-zone.nl/mkportal/modules/chat/tpl_chat.php on line 7

maybe there is an awnser for this to i'm sorry i know i'm am making you crazy wehehe

thnks mann

http://www.chill-zon...ex.php?ind=chat

hey i forgot to say that line 7 is

global $mkportals, $mklib;
The Reality Is That The Hitman Doesn't Exist. He Is An Illusion, An Entity Which His Enemies Cannot See Or Touch.

#5 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 06 July 2006 - 03:35 PM

neoxrg said:

hey thnks i double checked everything and when i used dzsoft php editor it worked i am getting on chat but i get a wierd warning on the top of my screen

this one

Warning: Missing argument 4 for view_chat() in /storage/mijndomein/users/017840/public/sites/www.chill-zone.nl/mkportal/modules/chat/tpl_chat.php on line 7

maybe there is an awnser for this to i'm sorry i know i'm am making you crazy wehehe

thnks mann

http://www.chill-zon...ex.php?ind=chat

hey i forgot to say that line 7 is

global $mkportals, $mklib;
I think maybe you forgot to edit this line in tpl_chat.php...
//function view_chat($chat_server, $chat_port, $chat_channel) {
function view_chat($chat_server, $chat_port, $chat_channel, $nick) { // Nick Hack
Or maybe you forgot to edit this line in the chat index.php...
		//$output  = $this->tpl->view_chat($chat_server, $chat_port, $chat_channel);
			$output  = $this->tpl->view_chat($chat_server, $chat_port, $chat_channel, $nick); // Nick Hack
If you edited those 2 lines correctly and you still have the error maybe try this code in tpl_chat.php...
//function view_chat($chat_server, $chat_port, $chat_channel) {
function view_chat($chat_server, $chat_port, $chat_channel, $nick="Guest") { // Nick Hack



Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard

#6 neoxrg

  • Members
  • 8 posts
  • Location:Netherlands
  • Aruba

Posted 06 July 2006 - 03:58 PM

ok i edited those 2 lines correcty so i tried that other code in thl_chat.php and it worked but i am still stuck with the biggest problem the nick that you choose is not displayd it's the standaard nick that is displayd so i don't know what went wrong...
The Reality Is That The Hitman Doesn't Exist. He Is An Illusion, An Entity Which His Enemies Cannot See Or Touch.

#7 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 06 July 2006 - 04:33 PM

neoxrg said:

ok i edited those 2 lines correcty so i tried that other code in thl_chat.php and it worked but i am still stuck with the biggest problem the nick that you choose is not displayd it's the standaard nick that is displayd so i don't know what went wrong...
If you want to email me your edited /chat/index.php and /chat/tpl_chat.php files I will look at them for you. My email address is on this page...

http://www.visiblesoul.net/contact.php


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard

#8 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 07 July 2006 - 11:30 AM

neoxrg said:

ok i edited those 2 lines correcty so i tried that other code in thl_chat.php and it worked but i am still stuck with the biggest problem the nick that you choose is not displayd it's the standaard nick that is displayd so i don't know what went wrong...
You did not edit index.php or tpl_cat.php correctly. You need to get new default files and start over.

I offer commercial (for-pay) modification services if you need me to do it for you. Otherwise just be very careful to follow the instructions exactly and use a good editor.


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users