Jump to content


[Hack] D-Shoutbox x MKP S1.2 Integration (S1.1a & 1.1b also)


  • You cannot reply to this topic
No replies to this topic

#1 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 07 June 2005 - 02:17 PM

Many people have asked for the D-Shoutbox x MKP S1.2 Integration that I use on my site. Here it is. I am not going to spend alot of time offering support for it so use it at your own risk.

This hack will put the D-Shoutbox global shout in MKPortal. It supports most D-Shoutbox functions but it does not support the fader effect. I'm sure there is a better way to do this but this is the best I could do when I created the hack. Backup the relevant MKPortal files before editing.

This Hack requires:
*MKPortal S1.1a, S1.1b or S1.2
*IPB 1.3 or 1.3.1
*pre-installed D-Shoutbox version 5.7.4

Demo



FILES TO EDIT:

mkportal/include/functions.php
mkportal/templates/Forum_Skin/tpl_main.php (of course you can adapt this to other skins)


-----------------------------------------
functions.php

FIND (in function header):
		if (!$this->config['mod_urlobox']) {
			  $urlo = $this->retrieve_urlo();
			if(!$ibforums->member['g_access_cp'] && !$this->member['g_access_urlobox']) {
				$urlo[0] = $this->lang['urlo_invis'];
				$urlo[1] = $this->lang['urlo_unauth'];
			}
		}
ADD BELOW:
	// D- Shoutbox (show the D-Shoutbox shouts)	
	$globalshouts = $this->global_shouts();
		$sbcolors = $this->get_sbcolors();
	// end D- Shoutbox
FIND (in function header):
				switch ($entry[1]) {
					case "2" :  $target = "target="_blank"";
								break;
					case "3" :  $dest = "java script:PopWindow('$dest','$title','{$entry[2]}','{$entry[3]}','1','1','1','0','0')";
								$target = "";
								break;
					default  :  $target = "";
								break;
				}
				$row_link .= $Skin->row_link("$this->images/{$this->navbar_links[$entry[0]]['image']}", "href="$dest" $target", $title);
			}
			$output .= $Skin->view_linkbar($row_link);
		}
ADD BELOW:
	// D- Shoutbox (show the D-Shoutbox template)
	$DB->query("SELECT showglobal FROM ibf_shoutbox_settings");
	$shoutbox = $DB->fetch_row();
  
	if ($shoutbox['showglobal'] == 1) {
  if ($ibforums->member['sb_shoutboxtype'] == 2)
  {
	  $link = "<a href='#' onclick="window.open('{$ibforums->vars['board_url']}/index.php?act=Shoutbox','DShoutbox','width=377,height=438,resizable=no,location=no,menubar=no,status=no,left=0,top=0,
screenX=0,screenY=0,scrollbars=no'); return false">View The Shoutbox</a>";
  }
  else if ($ibforums->member['sb_shoutboxtype'] != 2)
  {
	  $link = "<a href="{$ibforums->base_url}act=Shoutbox">View The Shoutbox</a>";
  } 
	  $output .= $Skin->tmpl_dshoutbox($globalshouts, $sbcolors, $link);
		}
	// end D-Shoutbox
FIND (in function update_counter) :
	function update_counter () {
		global $DB;
		$counter = $this->config['counter'];
		++$counter;
		$DB->query("UPDATE mkp_config SET valore ='$counter' where chiave = 'counter'");
	}
ADD BELOW:
// D-Shoutbox functions

		function get_sbcolors()
	{
  global $ibforums, $DB, $shoutbox;

  $DB->query("SELECT * FROM ibf_shoutbox_colors");
  while ($color = $DB->fetch_row())
  {
	  $sbcolors .= "<option value='{$color['color']}' style='color: {$color['color']}'";
	  $sbcolors .= $color['color'] == $ibforums->member['sb_defaultcolor'] ? "selected>{$color['color']}</option>n" : ">{$color['color']}</option>n";
  }
  
  return $sbcolors;
	}

	function global_shouts()
	{
  global $ibforums, $DB, $sess, $shoutbox;

  $DB->query("SELECT ss.*, st.* FROM ibf_shoutbox_settings ss, ibf_shoutbox_stats st");
  $shoutbox = $DB->fetch_row();  

  $ibfshout[] = array();
  $DB->query("SELECT m.*, m.id AS mid, s.* FROM ibf_shoutbox s, ibf_members m WHERE s.name=m.name ORDER BY s.id DESC LIMIT {$shoutbox['gsnum']}");
  while($r = $DB->fetch_row())
  {
	  $r['message'] = stripslashes($r[message]);
	  $r['message'] = "<span style='color: ".$r['color']."'>".$r['message']."</span>";
	  $r['message'] = $this->bad_words($r['message']);
	  $r['message'] = $this->global_clean($r['message']);

	  $num++;
	  if (($ibforums->member['id'] == "0" || $ibforums->member['id'] == "" || $ibforums->member['name'] == "Guest" || $ibforums->member['name'] == "") && ($shoutbox['guestviewsb'] != "1"))
	  {
	$ibfshout[$num] = stripslashes($shoutbox['error_msg_1']);
	  }
	  else
	  {
	$ibfshout[$num] = "<a href='{$ibforums->base_url}act=Profile&CODE=03&MID={$r['mid']}'><b>{$r['name']}</b></a> -- {$r['message']}
";
	  }
  }
  
  if (($shoutbox['online'] == '1') && ($ibforums->member['g_view_dshoutbox'] == 1 || $ibforums->member['use_dshoutbox'] == 1))
  {
	  if (($ibforums->member['g_view_dshoutbox'] != 1 || $ibforums->member['use_dshoutbox'] != 1) && ($ibforums->member['id'] > 0))
	  {
	$globalshouts = $shoutbox['error_msg_3'];
	  }
	  else if (($ibforums->member['id'] == "" || $ibforums->member['id'] == "0") && ($shoutbox['guestviewsb'] == 0)) 
	  {
	$globalshouts = $shoutbox['error_msg_1'];
	  }
	  else
	  {
	if ($shoutbox['gseffect'] == '0')
	{
		$DB->query("SELECT m.*, m.id AS mid, s.* FROM ibf_shoutbox s, ibf_members m WHERE s.name=m.name ORDER BY s.id DESC LIMIT {$shoutbox['gsnum']}");
		while($r = $DB->fetch_row())
		{
	  $r['message'] = stripslashes($r[message]);
	  $r['message'] = "<span style='color: ".$r['color']."'>".$r['message']."</span>";
	  $r['message'] = $this->bad_words($r['message']);
	  $r['message'] = $this->global_clean($r['message']);

	  if (($ibforums->member['id'] == "0" || $ibforums->member['id'] == "" || $ibforums->member['name'] == "Guest" || $ibforums->member['name'] == "") && ($shoutbox['guestviewsb'] != "1"))
	  {
		  $gshouts = stripslashes($shoutbox['error_msg_1']);
	  }
	  else
	  {
		  $gshouts .= "<a href='{$ibforums->base_url}act=Profile&CODE=03&MID={$r['mid']}'><b>{$r['name']}</b></a> -- {$r['message']}
n";
	  }
		}

		$globalshouts = $gshouts;
	}
	else if ($shoutbox['gseffect'] == '1')
	{
		$DB->query("SELECT m.*, m.id AS mid, s.* FROM ibf_shoutbox s, ibf_members m WHERE s.name=m.name ORDER BY s.id DESC LIMIT {$shoutbox['gsnum']}");
		while($r = $DB->fetch_row())
		{
	  $r['message'] = stripslashes($r[message]);
	  $r['message'] = "<span style='color: ".$r['color']."'>".$r['message']."</span>";
	  $r['message'] = $this->bad_words($r['message']);
	  $r['message'] = $this->global_clean($r['message']);

	  if (($ibforums->member['id'] == "0" || $ibforums->member['id'] == "" || $ibforums->member['name'] == "Guest" || $ibforums->member['name'] == "") && ($shoutbox['guestviewsb'] != "1"))
	  {
		  $gshouts = stripslashes($shoutbox['error_msg_1']);
	  }
	  else
	  {
		  $gshouts .= "<a href='{$ibforums->base_url}act=Profile&CODE=03&MID={$r['mid']}'><b>{$r['name']}</b></a> -- {$r['message']}   ·   ";
	  }
		}

		$globalshouts = "<marquee>{$gshouts}</marquee>";		
	}
	else if ($shoutbox['gseffect'] == '2')
	{
		$DB->query("SELECT m.*, m.id AS mid, s.* FROM ibf_shoutbox s, ibf_members m WHERE s.name=m.name ORDER BY s.id DESC LIMIT {$shoutbox['gsnum']}");
		while($r = $DB->fetch_row())
		{
	  $r['message'] = stripslashes($r[message]);
	  $r['message'] = "<span style='color: ".$r['color']."'>".$r['message']."</span>";
	  $r['message'] = $this->bad_words($r['message']);
	  $r['message'] = $this->global_clean($r['message']);

	  if (($ibforums->member['id'] == "0" || $ibforums->member['id'] == "" || $ibforums->member['name'] == "Guest" || $ibforums->member['name'] == "") && ($shoutbox['guestviewsb'] != "1"))
	  {
		  $gshouts = stripslashes($shoutbox['error_msg_1']);
	  }
	  else
	  {
		  $gshouts .= "<a href='{$ibforums->base_url}act=Profile&CODE=03&MID={$r['mid']}'><b>{$r['name']}</b></a> -- {$r['message']}   ·   ";
	  }
		}

		$globalshouts = "<marquee direction='right'>{$gshouts}</marquee>";		
	}
	else if ($shoutbox['gseffect'] == '3')
	{
		$globalshouts = "
		<script language='JavaScript'>
		var delay = 2000
		var fcontent = new Array()
		fcontent[1] = "{$ibfshout[1]}"
		fcontent[2] = "{$ibfshout[2]}"
		fcontent[3] = "{$ibfshout[3]}"
		fcontent[4] = "{$ibfshout[4]}"
		fcontent[5] = "{$ibfshout[5]}"
		fcontent[6] = "{$ibfshout[6]}"
		fcontent[7] = "{$ibfshout[7]}"
		fcontent[8] = "{$ibfshout[8]}"
		fcontent[9] = "{$ibfshout[9]}"
		fcontent[10] = "{$ibfshout[10]}"
		fcontent[11] = "{$ibfshout[11]}"
		fcontent[12] = "{$ibfshout[12]}"
		fcontent[13] = "{$ibfshout[13]}"
		fcontent[14] = "{$ibfshout[14]}"
		fcontent[15] = "{$ibfshout[15]}"

		var fadescheme = 0
		var fadelinks = 1

		var hex = (fadescheme==0) ? 255 : 0
		var startcolor = (fadescheme==0) ? 'rgb(255,255,255)' : 'rgb(0,0,0)'
		var endcolor = (fadescheme==0) ? 'rgb(0,0,0)' : 'rgb(255,255,255)'

		var ie4 = document.all&&!document.getElementById
		var ns4 = document.layers
		var DOM2 = document.getElementById
		var faderdelay = 0
		var index = 1

		if (DOM2)
		faderdelay = 2000

		function changecontent()
		{
	  if (index>{$shoutbox['gsnum']})
	  index=1
	  if (DOM2)
	  {
		  document.getElementById('fscroller').style.color = startcolor
		  document.getElementById('fscroller').innerHTML = fcontent[index]
		  linksobj = document.getElementById('fscroller').getElementsByTagName('A')
		  if (fadelinks)
		  {
		linkcolorchange(linksobj)
		colorfade()
		  }
	  }
	  else if (ie4)
	  {
		  document.all.fscroller.innerHTML = fcontent[index]
	  }
	  else if (ns4)
	  {
		  document.fscrollerns.document.fscrollerns_sub.document.write(fcontent[index])
		  document.fscrollerns.document.fscrollerns_sub.document.close()
	  }
	
	  index++
	  setTimeout('changecontent()',delay+faderdelay)
		}

		frame = 20;
		function linkcolorchange(obj)
		{
	  if (obj.length>0)
	  {
		  for (i=0;i<obj.length;i++)
		  obj[i].style.color = 'rgb('+hex+','+hex+','+hex+')'
	  }
		}

		function colorfade()
		{
	  if(frame>0)
	  {
		  hex = (fadescheme==0) ? hex-12 : hex+12
		  document.getElementById('fscroller').style.color = 'rgb('+hex+','+hex+','+hex+')';
		  if (fadelinks)
		  {
		linkcolorchange(linksobj)
		frame--;
		setTimeout('colorfade()',20);
		  }
	  }
	  else
	  {
		  document.getElementById('fscroller').style.color = endcolor;
		  frame = 20;
		  hex = (fadescheme==0) ? 255 : 0
	  }
		}

		if (ie4 || DOM2)
		{
	  document.write('<div id="fscroller" style="width:70%;padding:2px"></div>')
		}
		window.onload=changecontent
		</script>

		<ilayer id='fscrollerns' valign='top' width=&{fwidth}; height=&{fheight};>
		<layer id='fscrollerns_sub' valign='top' width=&{fwidth}; height=&{fheight}; left=0 top=0></layer>
		</ilayer>";
	}
	else if ($shoutbox['gseffect'] == '4')
	{
		$globalshouts = "
		<script language='Javascript'>
		var scrollerdelay = '2000'
		var scrollerwidth = '560px'
		var scrollerheight = '58px'
		var scrollerbgcolor = ''
		var scrollerbackground = ''
		var messages = new Array()
		messages[0] = ""
		messages[1] = "{$ibfshout[1]}"
		messages[2] = "{$ibfshout[2]}"
		messages[3] = "{$ibfshout[3]}"
		messages[4] = "{$ibfshout[4]}"
		messages[5] = "{$ibfshout[5]}"
		messages[6] = "{$ibfshout[6]}"
		messages[7] = "{$ibfshout[7]}"
		messages[8] = "{$ibfshout[8]}"
		messages[9] = "{$ibfshout[9]}"
		messages[10] = "{$ibfshout[10]}"
		messages[11] = "{$ibfshout[11]}"
		messages[12] = "{$ibfshout[12]}"
		messages[13] = "{$ibfshout[13]}"
		messages[14] = "{$ibfshout[14]}"
		messages[15] = "{$ibfshout[15]}"

		var ie = document.all
		var dom = document.getElementById

		if (messages.length>2)
		{
	  i=2
		}
		else
		{
	  i=1
		}
	
		function move1(whichlayer)
		{
	  if (i > {$shoutbox['gsnum']})
	  i = 1
	  tlayer = eval(whichlayer)
	  if (tlayer.top>0 && tlayer.top<=5)
	  {
		  tlayer.top=0
		  setTimeout('move1(tlayer)',scrollerdelay)
		  setTimeout('move2(document.main.document.second)',scrollerdelay)
		  return
	  }
	  if (tlayer.top >= tlayer.document.height*-1)
	  {
		  tlayer.top-=5
		  setTimeout('move1(tlayer)',50)
	  }
	  else
	  {
		  tlayer.top = parseInt(scrollerheight)
		  tlayer.document.write(messages[i])
		  tlayer.document.close()
		  if (i == messages.length-1)
		  {
		i=1
		  }
		  else
		  {
		i++
		  }
	  }
		}
	
		function move2(whichlayer)
		{
	  if (i > {$shoutbox['gsnum']})
	  i = 1
	  tlayer2 = eval(whichlayer)
	  if (tlayer2.top>0 && tlayer2.top<=5)
	  {
		  tlayer2.top = 0
		  setTimeout('move2(tlayer2)',scrollerdelay)
		  setTimeout('move1(document.main.document.first)',scrollerdelay)
		  return
	  }
	  if (tlayer2.top >= tlayer2.document.height*-1)
	  {
		  tlayer2.top-=5
		  setTimeout('move2(tlayer2)',50)
	  }
	  else
	  {
		  tlayer2.top = parseInt(scrollerheight)
		  tlayer2.document.write(messages[i])
		  tlayer2.document.close()
		  if (i == messages.length-1)
		  {
		i=1
		  }
		  else
		  {
		i++
		  }
	  }
		}

		function move3(whichdiv)
		{
	  if (i > {$shoutbox['gsnum']})
	  i = 1
	  tdiv = eval(whichdiv)
	  if (parseInt(tdiv.style.top)>0 && parseInt(tdiv.style.top)<=5)
	  {
		  tdiv.style.top = 0+'px'
		  setTimeout('move3(tdiv)',scrollerdelay)
		  setTimeout('move4(second2_obj)',scrollerdelay)
		  return
	  }
	  if (parseInt(tdiv.style.top) >= tdiv.offsetHeight*-1)
	  {
		  tdiv.style.top = parseInt(tdiv.style.top)-5+'px'
		  setTimeout('move3(tdiv)',50)
	  }
	  else
	  {
		  tdiv.style.top = parseInt(scrollerheight)
		  tdiv.innerHTML = messages[i]
		  if (i == messages.length-1)
		  {
		i=1
		  }
		  else
		  {
		i++
		  }
	  }
		}
	
		function move4(whichdiv)
		{
	  if (i > {$shoutbox['gsnum']})
	  i = 1
	  tdiv2 = eval(whichdiv)
	  if (parseInt(tdiv2.style.top)>0 && parseInt(tdiv2.style.top)<=5)
	  {
		  tdiv2.style.top = 0+'px'
		  setTimeout('move4(tdiv2)',scrollerdelay)
		  setTimeout('move3(first2_obj)',scrollerdelay)
		  return
	  }
	  if (parseInt(tdiv2.style.top) >= tdiv2.offsetHeight*-1)
	  {
		  tdiv2.style.top = parseInt(tdiv2.style.top)-5+'px'
		  setTimeout('move4(second2_obj)',50)
	  }
	  else
	  {
		  tdiv2.style.top = parseInt(scrollerheight)
		  tdiv2.innerHTML = messages[i]
		  if (i == messages.length-1)
		  {
		i=1
		  }
		  else
		  {
		i++
		  }
	  }
		}
  
		function startscroll()
		{
	  if (ie || dom)
	  {
		  first2_obj = ie ? first2 : document.getElementById('first2')
		  second2_obj = ie ? second2 : document.getElementById('second2')
		  move3(first2_obj)
		  second2_obj.style.top = scrollerheight
		  second2_obj.style.visibility = 'visible'
	  }
	  else if (document.layers)
	  {
		  document.main.visibility = 'show'
		  move1(document.main.document.first)
		  document.main.document.second.top = parseInt(scrollerheight)+5
		  document.main.document.second.visibility = 'show'
	  }
		}
		window.onload=startscroll
		</script>
  
		<ilayer id='main' width=&{scrollerwidth}; height=&{scrollerheight}; visibility=hide>
		<layer id='first' left=0 top=1 width=&{scrollerwidth};>
		<script language='Javascript'>
		if (document.layers)
		document.write(messages[1])
		</script>
		</layer>
		<layer id='second' left=0 top=0 width=&{scrollerwidth}; visibility=hide>
		<script language='Javascript'>
		if (document.layers)
		document.write(messages[dyndetermine=(messages.length==1)? 1 : 1])
		</script>
		</layer>
		</ilayer>
  
		<script language='Javascript'>
		if (ie || dom)
		{
	  document.writeln('<div id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden;background-color:'+scrollerbgcolor+';">')
	  document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0px;top:0px">')
	  document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:1px;">')
	  document.write(messages[0])
	  document.writeln('</div>')
	  document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:0px;visibility:hidden">')
	  document.write(messages[dyndetermine=(messages.length==1)? 1 : 1])
	  document.writeln('</div>')
	  document.writeln('</div>')
	  document.writeln('</div>')
		}
		</script>";
	}
	  }
  }
  else
  {
	  $globalshouts = $shoutbox['error_msg_2'];
  }
  
  return $globalshouts;
	}


	function global_clean($txt)
	{
  global $DB, $shoutbox;

  if ($shoutbox['global_rlb'] == 1)
  {
	  $txt = str_replace("
", " ", $txt);
	  $txt = str_replace("
", " ", $txt);
  }
  
  return $txt;
	}

	function bad_words($text = "")
	{
  global $DB, $ibforums;
  
  if ($text == "")
  {
	  return "";
  }
  
  if ( $this->no_badwords == 1 )
  {
	  return $text;
  }
  
  if ( !is_array($this->badwords) )
  {
	  $DB->query("SELECT * from ibf_shoutbox_badwords");
	  $this->badwords = array();
	  if ( $DB->get_num_rows() )
	  {
	while ( $r = $DB->fetch_row() )
	{
		$this->badwords[] = array( 'bword'  => stripslashes($r['bword']),
			  'switch' => stripslashes($r['switch']),
			  'exact'  => $r['exact'],
			);
	}
	  }
  }
  
  usort($this->badwords, array( 'sbfuncs', 'word_sort' ) );
  
  if ( count($this->badwords) > 0 )
  {
	  foreach($this->badwords as $idx => $r)
	  {
	if ($r['replace'] == "")
	{
		$replace = '*~*~*';
	}
	else
	{
		$replace = $r['switch'];
	}

	$r['bword'] = preg_quote($r['bword'], "/");

	if ($r['exact'] == 1)
	{
		$text = preg_replace( "/(^|b)".$r['bword']."(b|!|?|.|,|$)/i", "$replace", $text );
	}
	else
	{
		$text = preg_replace( "/".$r['bword']."/i", "$replace", $text );
	}
	  }
  }
  
  return $text;
	}

	
	function word_sort($a, $b)
	{
  if ( strlen($a['bword']) == strlen($b['bword']) )
  {
	  return 0;
  }
  
  return ( strlen($a['bword']) > strlen($b['bword']) ) ? -1 : 1;
	}

// end D-Shoutbox functions
-----------------------------------------
tpl_main.php (Example: Forum_Skin)


FIND:
function view_urlo($urlo1, $urlo2) {
ADD ABOVE:
// D-Shoutbox
function tmpl_dshoutbox($globalshouts, $sbcolors, $link) {
global $mklib, $ibforums;
return <<<EOF

<script language="Javascript">
<!--
function emo_pop()
{
  window.open('{$ibforums->base_url}act=sbextras&CODE=emoticons2&s={$ibforums->session_id}','SBExtras','width=250,height=500,resizable=yes,scrollbars=yes'); 
}
function bbc_pop()
{
  window.open('{$ibforums->base_url}act=sbextras&CODE=bbcode&s={$ibforums->session_id}','SBExtras','width=700,height=500,resizable=yes,scrollbars=yes'); 
}
-->
</script>
<tr><td>
<table width="100%" style="border:1px solid;" cellspacing="0" align="center" cellpadding="4">
<tr><td class="maintitle" width="100%" align="center" colspan="2" nowrap>Latest Shouts In The Shoutbox -- {$link}</td></tr>
<tr><td class="row2" width="70%" align="left">{$globalshouts}</td>
<td class="row2" width="30%">
<form action="{$ibforums->base_url}act=Shoutbox" name="GSHOUT" method="post" onsubmit="document.GSHOUT.submit.disabled = true;">
<input type="text" name="Post" class="forminput"> <input type="submit" name="submitshout" value="Add Shout" class="forminput">

<select name="Color" class="codebuttons">{$sbcolors}</select> [ <a class="dshout" href="java script:" onclick="emo_pop()">Smilies</a> | <a class="dshout" href="java script:" onclick="bbc_pop()">BBCodes</a> ]
</form></td></tr></table>
</td>
</tr>

EOF;
} 
// D-Shoutbox end



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