Hello All!!!
I have a problem with the site we have developed. The problem lies within our Instant Messaging system. I have 1 file that I need help with. Now I need help with the 0im.php file to work the way it is supposed to.
The problem that lies within this file is the fact that it causes blank messages to be displayed whenever someone logs into their account. For example, when I log into my account, I immediately get a blank message with no sender, no message, no nothing. Its blank. I get this whenever I refresh the page or visit another section. Its a bit annoying, especially for our customers. Now the ways it is supposed to work is that whenever I click on send an instant message to an individual who I'm browsing, its supposed to send the message directly to them.
Here is the original 0im.php file for you all to look over. Please make suggestions, of what I would need to take out or input in order for the blank messages to stop. The "actual" messages from people are needed to only be displayed. The coding is as followed:
<?php
require "engine/load_configuration.pml";
$smiles_list = array( ":-)",
"🙂",
";-)",
"😉",
"B-)",
"😎",
":-(",
"🙁",
":-O",
"😮",
":-P",
"😛",
":-X",
":X",
":-D",
"😃",
":shock:"
);
$slile_images_list = array(
"<img src='images/icon_smile.gif' border=0>",
"<img src='images/icon_smile.gif' border=0>",
"<img src='images/icon_wink.gif' border=0>",
"<img src='images/icon_wink.gif' border=0>",
"<img src='images/icon_cool.gif' border=0>",
"<img src='images/icon_cool.gif' border=0>",
"<img src='images/icon_sad.gif' border=0>",
"<img src='images/icon_sad.gif' border=0>",
"<img src='images/icon_surprised.gif' border=0>",
"<img src='images/icon_surprised.gif' border=0>",
"<img src='images/icon_razz.gif' border=0>",
"<img src='images/icon_razz.gif' border=0>",
"<img src='images/icon_mad.gif' border=0>",
"<img src='images/icon_mad.gif' border=0>",
"<img src='images/icon_biggrin.gif' border=0>",
"<img src='images/icon_biggrin.gif' border=0>",
"<img src='images/icon_eek.gif' border=0>");
$esc_symbols_list = array(
"/\\/",
"/\/",
"/\\$/",
"/\./",
"/\[/",
"/\]/",
"/\|/",
"/\(/",
"/\)/",
"/\?/",
"/\*/",
"/\+/",
"/\{/",
"/\}/",
"/\//"
);
$esc_repl_list = array(
"\\",
"\^",
"\\$",
"\.",
"\[",
"\]",
"\|",
"\(",
"\)",
"\\?",
"\*",
"\+",
"\{",
"\}",
"\\/"
);
session_start();
//require('lib-xmlrpc-class.inc.php');
//$xmlrpcbanner = new phpAds_XmlRpc('ads.etribe.ca', '');
$db = c();
$id = $sAuth;
if ($action == "check" && $id != "")
{
$rMessages = q("select id from dt_im_messages where rid=$id");
if ((int)nr($rMessages) > 0)
{
header('Content-Type: image/jpeg');
readfile("images/2x2.jpg");
/
if(function_exists('imagecreate')) {
$im = imagecreate(2, 2);
if(function_exists('imagejpeg')) {
imagejpeg($im);
}
}
/
}
else
{
header('Content-Type: image/jpeg');
readfile("images/2x2.jpg");
/
if(function_exists('imagecreate')) {
$im = imagecreate(1, 1);
if(function_exists('imagejpeg')) {
imagejpeg($im);
}
}
/
}
}
else if ($action == "send_im")
{
if ($sAuth)
{
echo "<html><head><script language=javascript>window.close();</script></head></html>";
$fBlocked = f(q("SELECT id FROM dt_blocked WHERE member_id = '$rid' and blocked_id = '$sAuth'"));
if ($fBlocked[id] == "")
{
q("insert into dt_im_messages (rid, sid, message) values ($rid, $sAuth, '$message')");
}
}
}
else if ($action == "message")
{
if ($sAuth)
{
$fMember = f(q("select * from dt_members where id=".$rid));
$fProfile = f(q("select name from dt_profile where member_id=".$rid));
include "templates/im_send.ihtml";
}
else
echo "Please register for an account first or sign in.";
}
else if ($action == "block_user")
{
$f_blocked = f(q("SELECT id FROM dt_blocked WHERE member_id=$sAuth and blocked_id = '$blocked_id'"));
if ($f_blocked["id"] == "")
{
q("insert into dt_blocked (member_id, blocked_id) values ($sAuth, '$blocked_id')");
}
echo "<html><head>";
echo '<script language=javascript>alert("The user has been blocked!");</script><script language=javascript>window.close();</script></head></html>';
}
else if ($action == "unblock_user")
{
echo "<html><head>";
echo '<script language=javascript>alert("The user has been unblocked!");</script><script language=javascript>window.close();</script></head></html>';
}
else
{
$rMessages = q("select from dt_im_messages where rid=$id");
$fMessage = f($rMessages);
$sid = $fMessage["sid"];
$fMember = f(q("select from dt_members where id=".$fMessage["sid"]));
$message = $fMessage["message"];
$message = stripslashes($message);
while(list($k, $v) = each ($smiles_list))
{
$smiles_list[$k] = preg_replace($esc_symbols_list, $esc_repl_list, $v);
$smiles_list[$k] = "/".$smiles_list[$k]."/";
}
$message = preg_replace($smiles_list, $slile_images_list, $message);
$message_text .= "<b>".$fMember["login"]."</b>: ".$message."<br>";
q("delete from dt_im_messages where id=$fMessage[id]");
$rMessages = q("select * from dt_im_messages where rid=$id and sid=$sid");
while ($fMessage = f($rMessages))
{
$message = $fMessage["message"];
$message = stripslashes($message);
$message = preg_replace($smiles_list, $slile_images_list, $message);
$message_text .= "<b>".$fMember["login"]."</b>: ".$message."<br>";
q("delete from dt_im_messages where id=$fMessage[id]");
}
//q("delete from dt_im_messages where rid=$id and sid=$sid");
include("templates/im_box.ihtml");
}
//if(isset($im)) {
// imagedestroy($im);
//}
d($db);
?>
Please help, any suggestions or comments would be appreciated.