nneonneo's Shoutbox

Started by nneonneo, December 26, 2006, 06:58:11 PM

Previous topic - Next topic

nneonneo

Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

sipko


nneonneo

Have you tried chmod'ding the script to 755? This is probably caused by mod_security disliking the permissions on the file.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

sipko

Aye. Tried it with yshout.php. and with the yshout file.

pongsak

Quote from: nneonneo on March 19, 2008, 10:14:09 PMWhat is updateTimeout? It's possible that in some rare cases, the yshout.php script runs out of time before managing to send an update. Also consider seeing if there's any information in the server error log.
-Updatetimeout = 20
-no error shows in error log. for the shout box.
smf 1.1.2 with dilbermc themes.
> 50 mods installed.

nneonneo

@sipko: Nothing else? Just "Premature end of script headers"? Usually, the error message comes with some other thing (maybe "mod_security: permission denied, file is writable by group" or something). This doesn't give me much to go on. Try visiting the yshout/yshout.php file directly -- see if there's anything useful there.

@pongsak: Two things to try (since this problem won't occur all the time, it might be difficult to accurately pin it down):
1) decrease updateTimeout to 15 (or maybe 17); if your host happens to have the timeout at 20 seconds, this might cause the problem (default 60, but many hosts will set it lower for safety)
2) set gzipCompression to false, which prevents the shoutbox from trying to compress the output
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

pongsak

Thanks, I'll try 15 first.
smf 1.1.2 with dilbermc themes.
> 50 mods installed.

Mystiquo

code at the very top of yshout.js. it's no good
whould you like see my yshout.js????

Mystiquo

// Flood control time in milliseconds:
var floodTime = 1000;

// Time between refreshes (minimum) in milliseconds:
// Note that since 1.08, this option will have less of an effect on performance,
// hence the default value is very low :)
var refreshTime = 150;

// Check for duplicate instances?
// This can improve performance in some cases.
var checkDuplicates = false;

// Internet Explorer 7 has a bug (feature?) which causes extreme lag when
// moving between pages. This delay controls "false alarms"; the amount
// of time between detecting a page move and reloading the shoutbox.
// If it is too high, users may experience laggy shoutboxes.
// If it is too low, users may experience lag moving to a new page.
// This bug only affects Internet Explorer 7 (not previous versions)
var falseAlarmDelay = 5000;

// Don't edit below this line, unless you know what you are doing ;)
username = "";

var yshout_php=(board_url?board_url:'')+'/yshout/yshout.php';

// Set up Behaviour
var myrules = {
   '#shout-form' : function(element){
      element.onsubmit = function(){
         return false;
      }
   },
   
   '#shout-text' : function(element){
      element.onkeypress = function(evt){
         return onKP(element, evt);
      }
      element.onfocus = function() {
         onF(element);
      }
   },
   
   '#shout-button' : function(element){
      element.onclick = function(){
         doSend();
      }
   }
};

var guest;

Behaviour.register(myrules);

// onKeyPress event handler for the two textboxes
function onKP (element, evt) {
   evt = (evt) ? evt : (window.event) ? event : null;

   var charCode;
   if (evt)
   charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :   ((evt.which) ? evt.which : 0));

   if (charCode == 13 || charCode == 3) {
      doSend();
      return false;
   }
}

// onFocus event handler for the two textboxes
function onF (element) {
   element.value = "";
   defocus(element);
}

// Clear the onFocus event handler and set the foreground color to black.
function defocus(element) {
   element.onfocus = null;
   element.style.color = null;
}

// Set off the AJAX call to load the chat form into the empty yShout div
function loadChat() {
   if ($("yshout").style.display=="none") return;
   if(checkDuplicates)
   {
      if(get_cookie("yShout_open"))
      {
         $("yshout").innerHTML="Shoutbox loaded in another window. Retrying...";
         setTimeout("loadChat()",Math.random()*1000+1000/*between 1 and 2 seconds*/);
         return;
      }
      set_cookie("yShout_open","true",3/*seconds*/);
   }
   window.onunload = delcookie;
   if ($("yshout") && shoutFile != "") {
      new ajax (yshout_php, {
         postBody: 'reqtype=init&file=' + shoutFile,
         update: $('yshout'),
         onComplete: loadDone
      });
   }
}

function delcookie() {
   
   delete_cookie("yShout_open");
}

// Re-apply Behaviour after the chat loads
function loadDone() {
   setTimeout("Behaviour.apply()", 5);
   setTimeout("setupChat()", 5);
}

var oldNameBackgroundColor, oldTextBackgroundColor;

function setupChat() {
   startRefresh();
   username = $("forum-name").value;
   if($("forum-name").disabled) guest=false;
   else guest=true;
}

function complex_escape(text) {
   return escape(textToEntities(text.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
}

// Send the message
function doSend() {
   if (guest) {
      if($("forum-name").value=='')
      {
         alert("Please enter a username.");
         return;
      }
      username=complex_escape($F("forum-name"));
      set_cookie("username",username,20*365*24*3600);
      var toShout = complex_escape($F("shout-text"));
      floodControl();
      new ajax (yshout_php, {
         postBody: 'reqtype=shout&shout=' + toShout + '&file=' + shoutFile + '&username=' + username,
         update: $('shouts'),
         onComplete: shoutDone
      });
      return;
   }
   if (formValidate() && $("shout-text").value) {
      var toShout = complex_escape($F("shout-text"));
      floodControl();
      
      new ajax (yshout_php, {
         postBody: 'reqtype=shout&shout=' + toShout + '&file=' + shoutFile,
         update: $('shouts'),
         onComplete: shoutDone
      });
   }
}

function autoShout(theText) {
   new ajax (yshout_php, {
         postBody: 'reqtype=autoshout&shout=' + theText + '&file=' + shoutFile,
         update: $('shouts'),
         onComplete: shoutDone
      });
}

function ajaxGet(args) {
   new ajax (yshout_php+'?'+args, {
         update: $('shouts'),
         onComplete: shoutDone
      });
}

function goTo(args) {
   if(request) request.transport.abort();
   document.location=yshout_php+'?'+args;
}

// Start refreshing the chat after a message has been sent
function shoutDone() {
   startRefresh();
}

var refreshSet = false;

function startRefresh() {
   if (!refreshSet) {
      setTimeout("doRefresh()", refreshTime);
      refreshSet = true;
   }
}

function schedRefresh() {
   if (refreshSet) {
      setTimeout("doRefresh()", refreshTime);
   }
}

// Validate the form to ensure that the fields are filled
function formValidate() {
   var shoutText = $F("shout-text");

   var textValid = true;

   if (shoutText == "Shout text" || shoutText == "")
      textValid = false;

   if (!textValid) {
      changeClass($("shout-text"), "shout-invalid");
      $("shout-text").focus();
      return false;
   } else {
      changeClass($("shout-text"), "shout-valid-shout");
   }

   return true;
}

// This gets called each refresh; it reloads the shoutboxes content.

var oldShouts = null;
function doRefresh() {
   
   
if (oldShouts != null && oldShouts != $("shouts").innerHTML)
{
   
   if(get_cookie("shoutSound") == "true")
   
{
   if (delete_cookie('shoutSound'))
{
set_cookie('shoutSound','true',3600*24);
}   
soundManager.setVolume('sound',0); // my addition line, you can remove it
soundManager.play('sound');
}

soundManager.play('sound')
}


oldShouts = $("shouts").innerHTML;
   if($("yshout").style.display == "none") {refreshSet = false; return;};
   set_cookie("yShout_open","true",3/*seconds*/);
   request=new ajax (yshout_php, {
      postBody: 'reqtype=refresh&file=' + shoutFile,
      update: $('shouts'),
      onComplete: schedRefresh
   });
   // IE7 kludge: Abort transfers before navigating away, otherwise IE waits for completion
   for (i=0;i<document.links.length;i++){
      if(document.links.getAttribute("href").substring(11,0) != "javascript:")
         document.links.setAttribute("onactivate",function(){request.transport.abort();setTimeout("schedRefresh()",falseAlarmDelay);});
   }
}

function floodControl() {
   $("shout-text").disabled = true;
   $("shout-text").value = "";
   Form.disable($("shout-form"));
   setTimeout("enableShout()", floodTime);

}

function enableShout() {
   Form.enable($("shout-form"));
   $("shout-text").value = "";
   if(!guest) $("forum-name").disabled = true;
   $("shout-text").disabled = false;

   setTimeout('$("shout-text").focus()', 0);
}

function changeClass(element, newClass) {
   element.className = newClass;
}

function set_cookie( name, value, expires, path, domain, secure )
{
   
   // set time, it's in milliseconds
   var today = new Date();
   today.setTime( today.getTime() );
   
   /*
   if the expires variable is set, make the correct
   expires time, the current script below will set
   it for x number of days, to make it for hours,
   delete * 24, for minutes, delete * 60 * 24
   */
   if ( expires )
   {
      expires = expires * 1000;
   }
   var expires_date = new Date( today.getTime() + (expires) );
   
   document.cookie = name + "=" +escape( value ) +
   ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
   ( ( path ) ? ";path=" + path : "" ) +
   ( ( domain ) ? ";domain=" + domain : "" ) +
   ( ( secure ) ? ";secure" : "" );
}

// this function gets the cookie, if it exists
function get_cookie( name ) {
   var start = document.cookie.indexOf( name + "=" );
   var len = start + name.length + 1;
   if ( ( !start ) &&
   ( name != document.cookie.substring( 0, name.length ) ) )
   {
   return null;
   }
   if ( start == -1 ) return null;
   var end = document.cookie.indexOf( ";", len );
   if ( end == -1 ) end = document.cookie.length;
   return unescape( document.cookie.substring( len, end ) );

   }

function delete_cookie ( cookie_name )
{
   var cookie_date = new Date ( );  // current date & time
   cookie_date.setTime ( cookie_date.getTime() - 1 );
   document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}


nneonneo

Works for me. You have to get rid of the second soundManager.play('sound') line.

yshout.js:
if (delete_cookie('shoutSound'))
{
set_cookie('shoutSound','true',3600*24);
}

// Flood control time in milliseconds:
var floodTime = 1000;

// Time between refreshes (minimum) in milliseconds:
// Note that since 1.08, this option will have less of an effect on performance,
// hence the default value is very low :)
var refreshTime = 150;

// Check for duplicate instances?
// This can improve performance in some cases.
var checkDuplicates = false;

// Internet Explorer 7 has a bug (feature?) which causes extreme lag when
// moving between pages. This delay controls "false alarms"; the amount
// of time between detecting a page move and reloading the shoutbox.
// If it is too high, users may experience laggy shoutboxes.
// If it is too low, users may experience lag moving to a new page.
// This bug only affects Internet Explorer 7 (not previous versions)
var falseAlarmDelay = 5000;

// Don't edit below this line, unless you know what you are doing ;)
username = "";

var yshout_php=(board_url?board_url:'')+'/yshout/yshout.php';

// Set up Behaviour
var myrules = {
'#shout-form' : function(element){
element.onsubmit = function(){
return false;
}
},

'#shout-text' : function(element){
element.onkeypress = function(evt){
return onKP(element, evt);
}
element.onfocus = function() {
onF(element);
}
},

'#shout-button' : function(element){
element.onclick = function(){
doSend();
}
}
};

var guest;

Behaviour.register(myrules);

// onKeyPress event handler for the two textboxes
function onKP (element, evt) {
evt = (evt) ? evt : (window.event) ? event : null;

var charCode;
if (evt)
charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));

if (charCode == 13 || charCode == 3) {
doSend();
return false;
}
}

// onFocus event handler for the two textboxes
function onF (element) {
element.value = "";
defocus(element);
}

// Clear the onFocus event handler and set the foreground color to black.
function defocus(element) {
element.onfocus = null;
element.style.color = null;
}

// Set off the AJAX call to load the chat form into the empty yShout div
function loadChat() {
if ($("yshout").style.display=="none") return;
if(checkDuplicates)
{
if(get_cookie("yShout_open"))
{
$("yshout").innerHTML="Shoutbox loaded in another window. Retrying...";
setTimeout("loadChat()",Math.random()*1000+1000/*between 1 and 2 seconds*/);
return;
}
set_cookie("yShout_open","true",3/*seconds*/);
}
window.onunload = delcookie;
if ($("yshout") && shoutFile != "") {
new ajax (yshout_php, {
postBody: 'reqtype=init&file=' + shoutFile,
update: $('yshout'),
onComplete: loadDone
});
}
}

function delcookie() {

delete_cookie("yShout_open");
}

// Re-apply Behaviour after the chat loads
function loadDone() {
setTimeout("Behaviour.apply()", 5);
setTimeout("setupChat()", 5);
}

var oldNameBackgroundColor, oldTextBackgroundColor;

function setupChat() {
startRefresh();
username = $("forum-name").value;
if($("forum-name").disabled) guest=false;
else guest=true;
}

function complex_escape(text) {
return escape(textToEntities(text.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
}

// Send the message
function doSend() {
if (guest) {
if($("forum-name").value=='')
{
alert("Please enter a username.");
return;
}
username=complex_escape($F("forum-name"));
set_cookie("username",username,20*365*24*3600);
var toShout = complex_escape($F("shout-text"));
floodControl();
new ajax (yshout_php, {
postBody: 'reqtype=shout&shout=' + toShout + '&file=' + shoutFile + '&username=' + username,
update: $('shouts'),
onComplete: shoutDone
});
return;
}
if (formValidate() && $("shout-text").value) {
var toShout = complex_escape($F("shout-text"));
floodControl();

new ajax (yshout_php, {
postBody: 'reqtype=shout&shout=' + toShout + '&file=' + shoutFile,
update: $('shouts'),
onComplete: shoutDone
});
}
}

function autoShout(theText) {
new ajax (yshout_php, {
postBody: 'reqtype=autoshout&shout=' + theText + '&file=' + shoutFile,
update: $('shouts'),
onComplete: shoutDone
});
}

function ajaxGet(args) {
new ajax (yshout_php+'?'+args, {
update: $('shouts'),
onComplete: shoutDone
});
}

function goTo(args) {
if(request) request.transport.abort();
document.location=yshout_php+'?'+args;
}

// Start refreshing the chat after a message has been sent
function shoutDone() {
startRefresh();
}

var refreshSet = false;

function startRefresh() {
if (!refreshSet) {
setTimeout("doRefresh()", refreshTime);
refreshSet = true;
}
}

function schedRefresh() {
if (refreshSet) {
setTimeout("doRefresh()", refreshTime);
}
}

// Validate the form to ensure that the fields are filled
function formValidate() {
var shoutText = $F("shout-text");

var textValid = true;

if (shoutText == "Shout text" || shoutText == "")
textValid = false;

if (!textValid) {
changeClass($("shout-text"), "shout-invalid");
$("shout-text").focus();
return false;
} else {
changeClass($("shout-text"), "shout-valid-shout");
}

return true;
}

// This gets called each refresh; it reloads the shoutboxes content.

var oldShouts = null;
function doRefresh() {
    if (oldShouts != null && oldShouts != $("shouts").innerHTML)
    {
        if(get_cookie("shoutSound") == "true")
        {
            if (delete_cookie('shoutSound'))
            {
                set_cookie('shoutSound','true',3600*24);
            }
            //soundManager.setVolume('sound',0); // my addition line, you can remove it
            soundManager.play('sound');
        }
        //soundManager.play('sound');
    }

    oldShouts = $("shouts").innerHTML;
if($("yshout").style.display == "none") {refreshSet = false; return;};
set_cookie("yShout_open","true",3/*seconds*/);
request=new ajax (yshout_php, {
postBody: 'reqtype=refresh&file=' + shoutFile,
update: $('shouts'),
onComplete: schedRefresh
});
// IE7 kludge: Abort transfers before navigating away, otherwise IE waits for completion
for (i=0;i<document.links.length;i++){
if(document.links[i].getAttribute("href").substring(11,0) != "javascript:")
document.links[i].setAttribute("onactivate",function(){request.transport.abort();setTimeout("schedRefresh()",falseAlarmDelay);});
}
}

function floodControl() {
$("shout-text").disabled = true;
$("shout-text").value = "";
Form.disable($("shout-form"));
setTimeout("enableShout()", floodTime);

}

function enableShout() {
Form.enable($("shout-form"));
$("shout-text").value = "";
if(!guest) $("forum-name").disabled = true;
$("shout-text").disabled = false;

setTimeout('$("shout-text").focus()', 0);
}

function changeClass(element, newClass) {
element.className = newClass;
}

function set_cookie( name, value, expires, path, domain, secure )
{

// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// this function gets the cookie, if it exists
function get_cookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );

}

function delete_cookie ( cookie_name )
{
var cookie_date = new Date ( );  // current date & time
cookie_date.setTime ( cookie_date.getTime() - 1 );
document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

shadow82x

Cant get it to work actually. Are the manually theme instructions the same on 2.x as 1.x? (On the mod page)
Colin B
Former Spammer, Customize, & Support Team Member

nneonneo

Is it the shoutbox installed at http://www.egadforums.com/? If so, then here's the problem: the yshout folder is missing.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

shadow82x

Quote from: nneonneo on March 20, 2008, 05:47:38 PM
Is it the shoutbox installed at http://www.egadforums.com/? If so, then here's the problem: the yshout folder is missing.
I recently disabled it because it was not displaying I will enable it. :P But that folder was present chmodded correctly.
Colin B
Former Spammer, Customize, & Support Team Member

nneonneo

Disable gzipCompression. Also, there is some sort of warning:
http://egadforums.com/yshout/yshout.php
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

shadow82x

OK ill look into it in a few hours. Weird because thats a fresh copy of subs.php too.
Colin B
Former Spammer, Customize, & Support Team Member

shadow82x

OK its not subs.php I think its leading to boardindex.php anyway is there a way (once I get the error resolved) to make it so it only shows on the boardindex?
Colin B
Former Spammer, Customize, & Support Team Member

nneonneo

Yes. Instead of installing the <div id="yshout"... piece to index.template.php, install it to BoardIndex.template.php.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

shadow82x

Quote from: nneonneo on March 20, 2008, 08:00:27 PM
Yes. Instead of installing the <div id="yshout"... piece to index.template.php, install it to BoardIndex.template.php.
Ahh thanks I thought it may cause an error because you put (in the index.template.php file!)

Anyway I'm it turns out the error is from something at my hosts end with subs.php. Hopefully I wont notice any speed impact installing this. It seems like an awesome mod. :D I would definitely recommend it.

Colin B
Former Spammer, Customize, & Support Team Member

majarm

#1858
i want to put the shoutbox on a separate page in boardindex.template.php

which code i use?
i want to display the shoutbox only the main page.

thank you

nneonneo

On a separate page, or on the board index?

For the former, see http://www.simplemachines.org/community/index.php?topic=137508.msg1195341#msg1195341
For the latter, install the second piece of code (on the main mod page) to BoardIndex.template.php instead of index.template.php.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

Advertisement: