Jump to content

Recommended Posts

Chatlog.php

 

<?php $db = mysql_connect("localhost", "root") or die("Could not connect."); //username and password
mysql_select_db("cute") or die(mysql_error());

$getnummessages="SELECT COUNT(*) as messagecount from chatmessages";

$getnummessages2=mysql_query($getnummessages) or die("blah");

$getnummessages3= mysql_result($getnummessages2, 0);

if($getnummessages3>40)

{

   $startrow=$getnummessages3-20;

}

else

{

  $startrow=0;

}

$getmsg="SELECT name, message from chatmessages order by postime ASC limit $startrow,$getnummessages3";

$getmsg2=mysql_query($getmsg) or die(mysql_error());

function replacesmiley($msg)
{
         $msg = str_replace('', '<img src="smile.gif" alt="" />', $msg);
         $msg = str_replace('', '<img src="sad.gif" alt="" />', $msg);
         $msg = str_replace('', '<img src="tongue.gif" alt="" />', $msg);
         return $msg;
}

echo replacesmiley($text);

function filterBadWords($str)
{
    $result = mysql_query("SELECT badwords FROM clean") or die(mysql_error()); 
    $replacements = "*";
    
    while($row = mysql_fetch_assoc($result))
    {
          $str = eregi_replace($row['badwords'], str_repeat('*', strlen($row['badwords'])), $str);
    }  
    
    return $str;
}



while($getmsg3=mysql_fetch_array($getmsg2))

{

  $getmsg3['message'] = replacesmiley($getmsg3['message']);
  $getmsg3['message'] = filterBadWords($getmsg3['message']); //Smiley faces
  print "<font color='blue'><b>$getmsg3[name]:</b></font> $getmsg3[message]<br>";



}






?>

<script>
setTimeout("window.location.replace('chatlog.php')",2000);
var objDiv = document.body;
objDiv.scrollTop = objDiv.scrollHeight;
</script>

 

 

Javascript for to reload the page in same scroll position

 

<script type="text/javascript">
<!--
cookieName="page_scroll"
expdays=365

// An adaptation of Dorcht's cookie functions.

function setCookie(name, value, expires, path, domain, secure){
if (!expires){expires = new Date()}
document.cookie = name + "=" + escape(value) + 
((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
((secure == null) ? "" : "; secure")
}

function getCookie(name) {
var arg = name + "="
var alen = arg.length
var clen = document.cookie.length
var i = 0
while (i < clen) {
var j = i + alen
if (document.cookie.substring(i, j) == arg){
return getCookieVal(j)
}
i = document.cookie.indexOf(" ", i) + 1
if (i == 0) break
}
return null
}

function getCookieVal(offset){
var endstr = document.cookie.indexOf (";", offset)
if (endstr == -1)
endstr = document.cookie.length
return unescape(document.cookie.substring(offset, endstr))
}

function deleteCookie(name,path,domain){
document.cookie = name + "=" +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
"; expires=Thu, 01-Jan-00 00:00:01 GMT"
}

function saveScroll(){ // added function
var expdate = new Date ()
expdate.setTime (expdate.getTime() + (expdays*24*60*60*1000)); // expiry date

var x = (document.pageXOffset?document.pageXOffset:document.body.scrollLeft)
var y = (document.pageYOffset?document.pageYOffset:document.body.scrollTop)
Data=x + "_" + y
setCookie(cookieName,Data,expdate)
}

function loadScroll(){ // added function
inf=getCookie(cookieName)
if(!inf){return}
var ar = inf.split("_")
if(ar.length == 2){
window.scrollTo(parseInt(ar[0]), parseInt(ar[1]))
}
}

// add onload="loadScroll()" onunload="saveScroll()" to the opening BODY tag

// -->
</script>

 

 

Any one can combinie my script with this script?

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.