1
kstan_79
Re: Xoop chat 1.5 on Xoops 2.0.18.2
  • 2009/9/24 13:51

  • kstan_79

  • Just popping in

  • Posts: 1

  • Since: 2007/5/9 1


Hi, currently I using xoopschat to communicate with my internal staff (with block). After some complain I'd do some changes of the code to make it more user friendly (Included some dynamic update, ajax, and hide post more older than 50). I feel quite satisfy with the changes and willing to share back with originator.
You can copy following code to replace source code in xoopschat/block folder.
Enjoy!
Quote:

<?php
// $Id: blockbottom.php,v 1.2 2003/09/03 coded by frankblack
// ------------------------------------------------------------------------- //
// German Xoops-Support-Site
// <http://www.myxoops.de >
// ------------------------------------------------------------------------- //
// Original Author : Pietro Lascari -http://www.cmq.it
// Modified for XOOPS 2 : Marko "Predator" Schmuck and frankblack
// Licence Type : Public GNU/GPL
// ------------------------------------------------------------------------- //


include("../../../mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
include(XOOPS_ROOT_PATH."/modules/xoopschat/include/xoopsuser.php");
include_once(XOOPS_ROOT_PATH."/modules/xoopschat/class/timestamp.php");
include(XOOPS_ROOT_PATH."/modules/xoopschat/include/functions.php");
include XOOPS_ROOT_PATH."/class/xoopsformloader.php";

if ( file_exists("../language/".$xoopsConfig['language']."/blocks.php") ) {
include("../language/".$xoopsConfig['language']."/blocks.php");
} else {
include("../language/english/blocks.php");
}

global $user;

//CheckIfBanned();
//$pchat = "false";
//if ($pchat == "false") {
//if ($room == "") {
$room = getDefaultRoom();
//}
//}

$iclass = new XchatTime();
$tstamp = $iclass->MakeTimeStamp();

echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"content-type\" content=\"text/html; charset="._CHARSET."\" />";
echo "<link rel='stylesheet' type='text/css' media='all' href='".xoops_getcss($xoopsConfig['theme_set'])."' />";
echo "</head>";
echo "<script language='JavaScript'>\r\n";
echo "<!--\n";
echo "function setfocus() {\n";
echo "document.msgform.msgtextbox.focus();\n";
echo "}\n";

//include(XOOPS_ROOT_PATH."/include/xoopsjs.php");
include(XOOPS_ROOT_PATH."/include/xoops.js");

echo "//-->\r\n";
echo "</script>\r\n";

include(XOOPS_ROOT_PATH."/include/xoopscodes.php");

echo "<body style='background-color: #".$xoopsModuleConfig["msgframebgcol"]."'>\r\n";
echo "<base target='_self'>\r\n";
echo "<form name='msgform' action='blockbottom.php?op=insertmessage&room=".$room."&pchat=".$pchat."&user=".$user."' method='POST'>";
echo "<table width=\"93%\">";
echo "<tr><td valign='top'>";
echo "<input type='text' id='msgtextbox' name='msg' size='".$xoopsModuleConfig["blockinputlength"]."' maxlength='".$xoopsModuleConfig["blockmaxlength"]."' ></td></tr>";
echo "<tr><td><input type='submit' name='msg_submit' value='"._BL_XCHAT_MSGSEND."'><input type='checkbox' name='msg_bold'><b>"._BL_XCHAT_FONTBOLD."</b></input>&nbsp;
<input type='checkbox' name='msg_italic'><i>"._BL_XCHAT_FONTITALIC."</i></input>&nbsp;
<input type='checkbox' name='msg_underlined'><u>"._BL_XCHAT_FONTUNDERL."</u></input></td></tr>";
echo "<tr><td style='width: 150;'>";

xoopsSmilies("msgtextbox");
//echo "</td></tr><tr><td>";

$thecolorarr = array(_BL_XCHAT_COLOR1,_BL_XCHAT_COLOR2,_BL_XCHAT_COLOR3,_BL_XCHAT_COLOR4,
_BL_XCHAT_COLOR5,_BL_XCHAT_COLOR6,_BL_XCHAT_COLOR7,_BL_XCHAT_COLOR8,
_BL_XCHAT_COLOR9,_BL_XCHAT_COLOR10,_BL_XCHAT_COLOR11);

$thecolornames = array(_BL_XCHAT_BLACK,_BL_XCHAT_DARKBLUE,_BL_XCHAT_BLUE,_BL_XCHAT_LGREEN,
_BL_XCHAT_GREEN,_BL_XCHAT_DARKRED,_BL_XCHAT_RED,_BL_XCHAT_ORANGE,
_BL_XCHAT_GOLD,_BL_XCHAT_SILVER,_BL_XCHAT_WHITE);

//echo "</td></tr>";

//echo "<tr><td>";
echo ""._BL_XCHAT_SELECTCOLOR."<select name='colors'>";
//echo "&nbsp;";
echo "";
echo "<option>"._BL_XCHAT_AUTO."</option>";

$countcolor = 0;
$currentcolor = _BL_XCHAT_AUTO;
if ($HTTP_POST_VARS['colors'] != "") {
$currentcolor = $HTTP_POST_VARS['colors'];
}

foreach ($thecolornames as $c) {
echo "<option";
if ($currentcolor == $c) {
echo " selected";
}
echo " style='color: ".$thecolorarr[$countcolor].";'>";
echo $c;
echo "</option>";
$countcolor++;
}

echo "</select></td>";
echo "</tr>";
echo "</table>";
echo "</form>";
echo "</body>";

if (isset($op)) {
if (!$HTTP_POST_VARS['msg'] == "") {
$message = $HTTP_POST_VARS['msg'];
if ($HTTP_POST_VARS['msg_underlined'] == "on") {
$message = "<u>".$message."</u>";
}

if ($HTTP_POST_VARS['msg_italic'] == "on") {
$message = "<i>".$message."</i>";
}

if ($HTTP_POST_VARS['msg_bold'] == "on") {
$message = "<b>".$message."</b>";
}

$mcolor = $HTTP_POST_VARS['colors'];

if ($mcolor == _BL_XCHAT_AUTO) {
$noformat = true;
} else {
$noformat = false;
$list = 0;
while($mcolor != $thecolornames[$list]) {
$list++;
}
}
$myts =& MyTextSanitizer::getInstance();
$messaggio_censurato = $myts->censorString($message);
if ($noformat == true) {
$messaggio = $messaggio_censurato;
} else {
$messaggio = '<font color="'.$thecolorarr[$list].'">'.$messaggio_censurato.'</font>';
}
} else {
exit();
}

switch ($pchat) {
case "false":
insertMessage($room, $messaggio, $userarray['nick'], $tstamp, $userarray['ipaddress']);
break;
}
}
echo "<script language='JavaScript'>\r\n";
echo "<!--\r\n";
echo " top.ChatFrame.location.reload();\r\n";
echo "//-->\r\n";
echo "</script>\r\n";
echo "</html>";
//include(XOOPS_ROOT_PATH."/footer.php");

?>


Quote:

<?php
// $Id: blockchat.php,v 1.2 2003/09/03 coded by frankblack
// ------------------------------------------------------------------------- //
// German Xoops-Support-Site
// <http://www.myxoops.de >
// ------------------------------------------------------------------------- //
// Original Author : Pietro Lascari -http://www.cmq.it
// Modified for XOOPS 2 : Marko "Predator" Schmuck and frankblack
// Licence Type : Public GNU/GPL
// ------------------------------------------------------------------------- //

include("../../../mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
include_once(XOOPS_ROOT_PATH."/modules/xoopschat/class/timestamp.php");
include(XOOPS_ROOT_PATH."/modules/xoopschat/include/functions.php");
include(XOOPS_ROOT_PATH."/modules/xoopschat/include/xoopsuser.php");

global $xoopsDB,$xoopsConfig,$xoopsTheme, $xoopsModuleConfig;

CheckIfBanned();
$room = getDefaultRoom();
$formatdate = new XchatTime();
getMessages($room);

echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>\n";
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"content-type\" content=\"text/html; charset="._CHARSET."\" />\n";
echo "<meta http-equiv='refresh' content=".$xoopsModuleConfig["chatrefresh"].">";
echo "<link rel='stylesheet' type='text/css' media='all' href='".xoops_getcss($xoopsConfig['theme_set'])."' />";
echo "</head>";
echo "<body style='background-color: #".$xoopsModuleConfig["chatframebgcol"].";'>";

include(XOOPS_ROOT_PATH."/include/xoopscodes.php");

echo "<div id='divchartblock'><table style='width: 93%;'>";
$countmessages = 1;
$msglimit=30;
if (!$xoopsDB->getRowsNum($res) == 0) {
$countmessages = 0;
$messages_array = array();
while($r = $xoopsDB->fetchRow($res)) {
$msgdate = $formatdate->GetTime("H:i:s",$r[4]);
$isnew=$r[4]-time();
$myts =& MyTextSanitizer::getInstance();
$messaggio = $myts->smiley($r[2]);

if ($xoopsModuleConfig['html'] == 0) {
$messaggio = strip_tags($messaggio, '<font><img><b><i><u>');
}



$messaggio = even_better_wordwrap($messaggio,$xoopsModuleConfig['blockwordwrap'],'');
if($isnew<1000)
$messaggio="<img src='../new.gif'>".$messaggio;


$messages_array[] .= "<i><small>".$msgdate."</small></i> <b><small>[".$r[3]."] : </small></b><small>".$messaggio."</small><br>";
$countmessages++;

}
$k=0;
for($x=$countmessages;$x>=0;$x--) {
if($k>=$msglimit)
break;

echo $messages_array[$x];
$k++;

}
} else {
echo "<tr><td align='center' valign='middle'>";
echo ""._MI_XCHAT_NOMESSAGES."";
echo "</td></tr>";
}

if($countmessages == 0) {
echo "<tr><td align='center' valign='middle'>";
echo "<b>[ "._BL_XCHAT_NOMSGSTODAY." ]</b>";
echo "</td></tr>";
}
echo "<tr><td>Check more history <a href='../xoopschat/' target='_blank'>here</a> </td></tr>";
echo "</table></div>";
echo <<< EOF
<script type='text/javascript'>
//alert("SD");
self.parent.document.getElementById("divdisplayblock").innerHTML=document.getElementById("divchartblock").innerHTML;
</script>
EOF;

echo "</body>";
if ($xoopsModuleConfig['orderascdesc'] == 'DESC') {
echo "<script language='JavaScript'>\n";
echo "<!--\n";
echo " window.scrollBy(0,900000);\n";
echo "//-->\n";
echo "</script>\n";
}
echo "</html>";

?>


Quote:

<?php
// $Id: xchatblock.php,v 1.2 2003/09/03 coded by frankblack
// ------------------------------------------------------------------------- //
// German Xoops-Support-Site
// <http://www.myxoops.de >
// ------------------------------------------------------------------------- //
// Original Author : Pietro Lascari -http://www.cmq.it
// Modified for XOOPS 2 : Marko "Predator" Schmuck and frankblack
// Licence Type : Public GNU/GPL
// ------------------------------------------------------------------------- //

function xchat_show($options)
{
global $xoopsModuleConfig, $theroom, $modversion, $xoopsConfig, $config_handler, $module_handler;
//$content="";

$config_handler=xoops_gethandler('config');
$module_handler=xoops_gethandler('module');
$xoopsModule =& $module_handler->getByDirname("xoopschat");
$xoopsModuleConfig =& $config_handler->getConfigsByCat(0, $xoopsModule->getVar('mid'));
$refreshinterval=$xoopsModuleConfig["chatrefresh"]*1000;
$content = "

<script type='text/javascript'>

var milliSecondsToWait = $refreshinterval;

function reloadIFrame(){
var f = document.getElementById('iframechat');
f.src =f.src;
myVar = setTimeout('reloadIFrame()',milliSecondsToWait);
}
var myVar = setTimeout('reloadIFrame()',milliSecondsToWait);
//<div align='center'>
//</div>

</script>
<iframe width='100%' name='MsgFrame' src='".$xoopsConfig['xoops_url']."/modules/xoopschat/blocks/blockbottom.php?pchat=false&room=".$theroom."'
frameborder='0' framespacing='0' border='0' marginwidth='0' marginheight='0' height=\""."110"."\" scrolling=\"no\"></iframe>
<iframe width='100%' id='iframechat' style='display:none'
name='ChatFrame' src='".$xoopsConfig['xoops_url']."/modules/xoopschat/blocks/blockchat.php?pchat=false&room=".$theroom."' frameborder='0' framespacing='0' border='0' marginwidth='0' marginheight='0' height=\"".$options[1]."\" scrolling=\"auto\"></iframe>
<div align='center' id='divdisplayblock' style='text-align:left'></div>
";

$block = array();
$block['content'] = $content;
$block['title'] = _XCHATBLOCKTITLE;
return $block;
}

function xchat_edit($options)
{
$form = _BL_XCHATWORDWRAP."&nbsp;<input type='text' name='options[]' value='".$options[0]."' /><br />";
$form .= _BL_XCHATBLMSGH."&nbsp;<input type='text' name='options[]' value='".$options[1]."' /><br />";
$form .= _BL_XCHATBLINPUTH."&nbsp;<input type='text' name='options[]' value='".$options[2]."' /><br />";
return $form;
}


?>





TopTop



Login

Who's Online

287 user(s) are online (168 user(s) are browsing Support Forums)


Members: 0


Guests: 287


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits