Welcome to Geeklog, Anonymous Tuesday, January 31 2023 @ 10:41 pm EST

Geeklog Forums

Messenger board -PLEASE HELP


Status: offline

newyorker

Forum User
Chatty
Registered: 06/13/06
Posts: 39
Hi!
I like to install this messenger board in centerblock and I tryed with:
------------------------------------------------------------------------------------------------------

/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2005 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------+
| Private Message system developed by CrappoMan
| email: simonpatterson@dsl.pipex.com
+----------------------------------------------------*/
require_once "maincore.php";
require_once BASEDIR."subheader.php";
require_once BASEDIR."side_left.php";
require_once INCLUDES."sendmail_include.php";
include LOCALE.LOCALESET."messages.php";

if (!iMEMBER) fallback("index.php");
if (isset($msg_send) && !($msg_send == "" || isNum($msg_send))) fallback(FUSION_SELF);

$settings['privmsg_subject_tooltip']=1; // use subject tooltip to show message preview
$userdata['user_pm_ban']=0; // set to 1 to ban user from pm'ing. Used if adding new field 'user_pm_ban' to to 'xxx_users' table
$itemsperpage=20; // number of messages to display per page

function builduserclassoptionlist($selected_user_class=1,$restricted=false){
global $locale;
$user_class_option_list = "";
$user_class_option_list .= "n";
$levels = array(101=>$locale['user1'], $locale['user2'], $locale['user3']);
foreach ($levels as $level => $modlevel) {
if ($level==$selected_user_class) { $sel = " selected"; } else { $sel=""; }
if ($restricted) { $userlevel = iUSER; } else { $userlevel = max(array_keys($levels)); }
if ($level".$modlevel."n";
}

$groups_qry = dbquery("SELECT group_id,group_name FROM ".DB_PREFIX."user_groups");
if (dbrows($groups_qry) != 0) {
$user_class_option_list .= "n";
while ($user_groups = dbarray($groups_qry)) {
$sel = ($user_groups['group_id'] == $selected_user_class ? " selected" : "");
$user_class_option_list.="".$user_groups['group_name']."n";
}
}

return $user_class_option_list;
}
function builduseroptionlist($selected_user_id=1){
global $locale;
$user_option_list = "";
$levels = array(
0 => array($locale['user3'], "103"),
1 => array($locale['user2'], "102"),
2 => array($locale['user1'], "101")
);
while(list($key, $user_level) = each($levels)) {
$uresult = dbquery("SELECT * FROM ".DB_PREFIX."users WHERE user_level='".$user_level['1']."' ORDER BY user_name");
if (dbrows($uresult) > 0) {
$user_option_list .= "n";
while ($udata = dbarray($uresult)) {
$sel = ($udata['user_id'] == $selected_user_id ? " selected" : "");
$user_option_list .= "".$udata['user_name']."n";
}
$user_option_list .= "n";
}
}

return $user_option_list;
}
function displayMessagePreview($prev_subject,$prev_message,$site_broadcast=false){
global $locale,$settings,$userdata;
opentable($locale['438']);
if (isset($_POST['chk_sitebroadcast'])) {
$prev_recipient = $locale['408'];
} else {
$prev_recipient = "".$userdata['user_name']."";
}
$prev_msgdate=strftime($settings['longdate'], time()+($settings['timeoffset']*3600));
echo "

".$locale['406'].":
".$prev_recipient."


".$locale['407'].":
".$prev_msgdate."


".$locale['405'].":
".$prev_subject."


".$prev_message."

n";
closetable();
tablebreak();
}

$msg_folders = array("inbox" => 0, "sentbox" => 1, "savebox" => 2, "options" => 3);

$folder_status = array(
array("","","","","","","",""),
array("","","","","","","",""),
array("","","","","","","",""),
array("","","","","","","","")
);

// Save user options
if (isset($saveoptions)) {
$pm_email_notify = isNum($_POST['pm_email_notify']) ? $_POST['pm_email_notify'] : "0";
$pm_save_sent = isNum($_POST['pm_save_sent']) ? $_POST['pm_save_sent'] : "0";
if ($_POST['update_type']=="new") {
dbquery("INSERT INTO ".$db_prefix."messages_options (user_id, pm_email_notify, pm_save_sent, pm_inbox, pm_savebox, pm_sentbox) VALUES ('".$userdata['user_id']."', '$pm_email_notify', '$pm_save_sent', '0', '0', '0')");
} else {
dbquery("UPDATE ".$db_prefix."messages_options SET pm_email_notify='$pm_email_notify', pm_save_sent='$pm_save_sent' WHERE user_id='".$userdata['user_id']."'");
}
$message = $locale['624'];
}

if (!isset($folder)) $folder="inbox";
if (!array_key_exists($folder,$msg_folders)) $folder="inbox";
$folder_stat=$folder_status[$msg_folders[$folder]];
$result_where_message_folder="message_folder=".$msg_folders[$folder];
if (isset($msg_view)) {
if (!isNum($msg_view)) fallback("messages.php");
$result_where_message_id="message_id=".$msg_view;
} elseif (isset($msg_reply)) {
if (!isNum($msg_reply)) fallback("messages.php");
$result_where_message_id="message_id=".$msg_reply;
} elseif (isset($_POST['reply_preview'])) {
if (!isNum($msg_reply_preview)) fallback("messages.php");
$result_where_message_id="message_id=".$msg_reply_preview;
$msg_reply = $msg_reply_preview;
} elseif (isset($msg_setread)) {
if (!isNum($msg_setread)) fallback("messages.php");
$result_where_message_id="message_id=".$msg_setread;
} elseif (isset($msg_setunread)) {
if (!isNum($msg_setunread)) fallback("messages.php");
$result_where_message_id="message_id=".$msg_setunread;
} elseif (isset($msg_save)) {
if (!isNum($msg_save)) fallback("messages.php");
$result_where_message_id="message_id=".$msg_save;
$cnt_messages = '1';
} elseif (isset($msg_unsave)) {
if (!isNum($msg_unsave)) fallback("messages.php");
$result_where_message_id="message_id=".$msg_unsave;
$cnt_messages = '1';
} elseif (isset($msg_delete)) {
if (!isNum($msg_delete)) fallback("messages.php");
$result_where_message_id="message_id=".$msg_delete;
} elseif (isset($chk_mark)) {
if (is_array($chk_mark) && count($chk_mark) > 1) {
// Count how many elements (messages) in array
$cnt_messages = count($chk_mark);
foreach ($chk_mark as $thisnum) { if (!isNum($thisnum)) { fallback("messages.php"); } }
$result_where_message_id = "message_id IN(".implode(',',$chk_mark).")";
} else {
$cnt_messages = '1';
$result_where_message_id = "message_id=".(isNum($chk_mark[0]) ? $chk_mark[0] : "0");
}
}

$result_where_message_to="message_to=".$userdata['user_id']; // a double check to make sure the script only operates on the current users messages

$sender_id = (isset($_POST['chk_sitebroadcast']) ? 0 : $userdata['user_id']);

if (isset($_POST['send_preview']) || isset($_POST['reply_preview'])) {
if(isset($_POST['chk_showsig'])) $checked_sig=" checked";
if(isset($_POST['chk_disablesmileys'])) $checked_smileys=" checked";
if(isset($_POST['chk_sendtoall'])) $checked_sendtoall=" checked";
if(isset($_POST['chk_sitebroadcast'])) $checked_sitebroadcast=" checked";
$prev_subject=stripinput($_POST['subject']);
$prev_message=stripinput($_POST['message']);
if ($checked_sig) $prev_message = $prev_message."nn".$userdata['user_sig'];
if (!$checked_smileys) $prev_message = parsesmileys($prev_message);
$prev_message = nl2br(parseubb($prev_message));
// $msg_send = $msg_to;
}
if(iGUEST){ // not logged in - display "iMEMBERs only"
opentable($locale['400']);
echo "
".$locale['483']."

n";
} elseif ($userdata['user_pm_ban'] == "1"){ // user is banned from pm'ing
opentable($locale['400']);
echo "
".$locale['484']."

n";
} elseif (isset($_POST['btn_cancel'])) { // handle cancel button
redirect(FUSION_SELF."?folder=".$folder);
} elseif (isset($_POST['btn_setread']) || isset($msg_setread)) { // set message as read
dbquery("UPDATE ".$db_prefix."messages SET message_read=1 WHERE ".$result_where_message_id." AND ".$result_where_message_to);
redirect(FUSION_SELF."?folder=".$folder);
} elseif (isset($_POST['btn_setunread']) || isset($msg_setunread)) { // set message as un-read
dbquery("UPDATE ".$db_prefix."messages SET message_read=0 WHERE ".$result_where_message_id." AND ".$result_where_message_to);
redirect(FUSION_SELF."?folder=".$folder);
} elseif (isset($_POST['btn_save']) || isset($msg_save)) { // move message to 'savebox' folder
// Count how many messages in archive/savebox
$cnt_savebox_qry = dbquery("SELECT COUNT(message_id) cnt_savebox FROM ".$db_prefix."messages WHERE message_to='".$userdata['user_id']."' AND message_folder='2' GROUP BY message_to");
if (dbrows($cnt_savebox_qry) != 0) { $cnt_savebox = dbresult($cnt_savebox_qry,0); }
// Get limit
$limit_savebox = dbresult(dbquery("SELECT pm_savebox FROM ".$db_prefix."messages_options WHERE user_id='0'"),0);
// Check if current + new messages is > limit
if ($limit_savebox != '0' && ($cnt_messages + $cnt_savebox) > $limit_savebox) { $error = $locale['629']; }
if (isset($error)) {
opentable($locale['627']);
echo "
".$error."

";
} else {
$result = dbquery("UPDATE ".$db_prefix."messages SET message_folder=2 WHERE ".$result_where_message_id." AND ".$result_where_message_to);
redirect(FUSION_SELF."?folder=".$folder);
}
} elseif (isset($_POST['btn_unsave']) || isset($msg_unsave)){ // move message to 'inbox' folder
// Count how many messages in inbox
$cnt_inbox_qry = dbquery("SELECT COUNT(message_id) cnt_inbox FROM ".$db_prefix."messages WHERE message_to='".$userdata['user_id']."' AND message_folder='0' GROUP BY message_to");
if (dbrows($cnt_inbox_qry) != 0) { $cnt_inbox = dbresult($cnt_inbox_qry,0); }
// Get limit
$limit_inbox=dbresult(dbquery("SELECT pm_inbox FROM ".$db_prefix."messages_options WHERE user_id='0'"),0);
// Check if current + new messages is > limit
if ( $limit_inbox != '0' && ($cnt_messages + $cnt_inbox) > $limit_inbox) { $error = $locale['629']; }

if (isset($error)) {
opentable($locale['627']);
echo "
".$error."

";
} else {
dbquery("UPDATE ".$db_prefix."messages SET message_folder=0 WHERE ".$result_where_message_id." AND ".$result_where_message_to);
redirect(FUSION_SELF."?folder=".$folder);
}
} elseif (isset($_POST['btn_delete']) || isset($msg_delete)) { // delete message
if (!isset($msg_delete) && !isset($chk_mark)) fallback("messages.php");
$result = dbquery("DELETE FROM ".$db_prefix."messages WHERE ".$result_where_message_id." AND ".$result_where_message_to);
redirect(FUSION_SELF."?folder=".$folder);
} elseif (isset($msg_view)) { // view message
$result=dbquery(
"SELECT tm.*, user_id, user_name FROM ".$db_prefix."messages tm LEFT JOIN ".$db_prefix."users ".
"ON message_from=user_id WHERE ".$result_where_message_id." AND ".$result_where_message_to
);
if (dbrows($result) == "1"){
$data=dbarray($result);
$subject = $data['message_subject'];
$message = parseubb(nl2br($data['message_message']));
if ($data['message_smileys']=="y") $message=parsesmileys($message);
$msgdate = strftime($settings['longdate'], $data['message_datestamp']+($settings['timeoffset']*3600));
if ($data['message_read'] == 0) {
$result=dbquery("UPDATE ".$db_prefix."messages SET message_read='1' WHERE ".$result_where_message_id." AND ".$result_where_message_to);
}
$msg_fld_name = array_search($data['message_folder'],$msg_folders);
opentable($locale['431']." (".$msg_fld_name.")");
echo "

".($data['message_folder']==1?$locale['421']:$locale['406']).":
";
if ($data['message_from'] == 0) {
echo $locale['408'];
} else {
echo "".$data['user_name']."";
}
echo "


".($data['message_folder']==1?$locale['426']:$locale['407']).":".$msgdate."


".$locale['405'].":
".$subject."


".$message."





n";
if ($data['message_folder'] != "1" && $data['user_id'] != "0") {
echo " ";
}
if ($data['message_folder']== "2") {
echo " ";
} else {
echo " ";
}
echo "



n";
} else {
opentable($locale['480']);
echo "
".$locale['481']."

n";
}
} elseif (isset($msg_send)||isset($_POST['send_preview'])){ // write message
if ($msg_send "" && (((int)$msg_send) == $msg_send)){
$type = "user";
$uresult=dbquery("SELECT user_name FROM ".$db_prefix."users WHERE user_id='".$msg_send."'");
$rows=dbrows($uresult);
if ($rows == 1) $data=dbarray($uresult);
} else {
$rows = 1;
}
if ($rows == 1){
if (isset($_POST['send_preview'])) displayMessagePreview($prev_subject,$prev_message);
opentable($locale['420']);
echo "function ValidateForm(frm){if((frm.subject.value=='')||(frm.message.value=='')){alert('".$locale['486']."');return false;}else return true;}




".$locale['421'].":
";
if (($msg_send "") && !isset($prev_message)) {
echo "".$data['user_name']."";
} else {
echo "n".builduseroptionlist((isset($msg_to) ? $msg_to : 1))."";
if(iSUPERADMIN){
if (!isset($msg_to_class)) $msg_to_class = 1;
echo "".$locale['434'].":
".builduserclassoptionlist($msg_to_class,true)."";
}
}

echo "


".$locale['405'].":



".$locale['422'].":
".(isset($message) ? stripslashes($message) : "")."












', ' [/code]');">



".displaysmileys("message")."



".$locale['425'].":

".$locale['427'];
if ($userdata['user_sig']) echo "
n".$locale['428'];
if (iADMIN) echo "
n".$locale['441'];
echo "











n";
} else {
opentable($locale['480']);
echo "
".$locale['482']."

n";
}
} elseif (isset($_POST['send_message'])) { // send message
$smileys = (isset($_POST['chk_disablesmileys']) ? "n" : "y");
$subject = stripinput($_POST['subject']);
$message = stripinput($_POST['message']);
if (isset($_POST['chk_showsig'])) $message.="nn".$userdata['user_sig'];
// Get PM folder restrictions
// (room for future option to restrict number of pm's for a specific user)
$limits = dbarray(dbquery("SELECT pm_inbox,pm_sentbox FROM ".$db_prefix."messages_options WHERE user_id='0'"));
$limit_inbox = $limits['pm_inbox'];
$limit_sentbox = $limits['pm_sentbox'];
if (isset($_POST['chk_sendtoall'])) {
// Determine if Group or User Level
if (strstr($msg_to_class, "g-")) {
$msg_to_class = str_replace("g-", "", $msg_to_class);
// Select all users from users table and loop through list
$user_groups_qry = dbquery("SELECT user_id,user_groups FROM ".$db_prefix."users");
while ($ugroups = dbarray($user_groups_qry)) {
// Explode the array into a list of user group id's
$user_groups = explode(".", $ugroups['user_groups']);
// If there's a match, then send to that user
if (in_array($msg_to_class, $user_groups)) {
$uresult = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id=".$ugroups['user_id']);
while($udata=dbarray($uresult)){
if ($udata['user_id'] != $userdata['user_id']) $result = dbquery("INSERT INTO ".$db_prefix."messages VALUES('','".$udata['user_id']."','".$sender_id."','".$subject."','".$message."','".$smileys."','0','".time()."','0')");
// Lookup receiving users options
$options_qry = dbquery("SELECT * FROM ".$db_prefix."messages_options WHERE user_id='".$udata['user_id']."'");
if (dbrows($options_qry) != 0) { $options = dbarray($options_qry); } else { unset($options); }
// Send notification email if user option is set
if (isset($options) && $options['pm_email_notify'] == "1") {
sendemail($udata['user_name'],$udata['user_email'],$settings['siteusername'],$settings['siteemail'],$locale['625'],$udata['user_name'].$locale['626']);
}
}
}
}
} else {
$uresult = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_level='".$msg_to_class."' ORDER BY user_id");
while($udata = dbarray($uresult)){
if ($udata['user_id'] != $userdata['user_id']) $result=dbquery("INSERT INTO ".$db_prefix."messages (message_to, message_from, message_subject, message_message, message_smileys, message_read, message_datestamp, message_folder) VALUES ('".$udata['user_id']."','".$sender_id."','".$subject."','".$message."','".$smileys."','0','".time()."','0')");
// Lookup receiving users options
$options_qry = dbquery("SELECT * FROM ".$db_prefix."messages_options WHERE user_id='".$udata['user_id']."'");
if (dbrows($options_qry) != 0) { $options = dbarray($options_qry); } else { unset($options); }
// Send notification email if user option is set
if (isset($options) && $options['pm_email_notify'] == "1") {
sendemail($udata['user_name'],$udata['user_email'],$settings['siteusername'],$settings['siteemail'],$locale['625'],$udata['user_name'].$locale['626']);
}
}
}

} elseif (isset($msg_to) && (((int)$msg_to) == $msg_to)) {
// Count inbox usage
$cnt_inbox_qry = dbquery("SELECT COUNT(message_id) cnt_inbox FROM ".$db_prefix."messages WHERE message_to='".$msg_to."' AND message_folder='0' GROUP BY message_to");
if (dbrows($cnt_inbox_qry) != 0) { $cnt_inbox = dbresult($cnt_inbox_qry, 0); } else { $cnt_inbox = 0; }
// Check if user has reached inbox limit
if ($limit_inbox == "0" || ($cnt_inbox $result=dbquery("INSERT INTO ".$db_prefix."messages (message_to, message_from, message_subject, message_message, message_smileys, message_read, message_datestamp, message_folder) VALUES('".$msg_to."','".$sender_id."','".$subject."','".$message."','".$smileys."','0','".time()."','0')");
} else {
$error = $locale['628'];
}
// Get user options
$options_qry = dbquery("SELECT pm_email_notify FROM ".$db_prefix."messages_options WHERE user_id='".$msg_to."'");
if (dbrows($options_qry) != 0) {
$options = dbarray($options_qry);
} else {
$options = dbarray(dbquery("SELECT pm_email_notify FROM ".$db_prefix."messages_options WHERE user_id='0'"));
}
// Send notification email if user option is set
if ($options['pm_email_notify'] == "1") {
$uresult = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='".$msg_to."'");
$udata = dbarray($uresult);
sendemail($udata['user_name'],$udata['user_email'],$settings['siteusername'],$settings['siteemail'],$locale['625'],$udata['user_name'].$locale['626']);
}
}
// If there's an error, display error and don't save PM
if (isset($error)) {
opentable($locale['627']);
echo "
".$error."

";
} else {
// Lookup sending users options
$options_qry = dbquery("SELECT pm_save_sent FROM ".$db_prefix."messages_options WHERE user_id='".$userdata['user_id']."'");
if (dbrows($options_qry) != 0) {
$options = dbarray($options_qry);
} else {
$options = dbarray(dbquery("SELECT pm_save_sent FROM ".$db_prefix."messages_options WHERE user_id='0'"));
}
if ($options['pm_save_sent'] == "1") {
// Check how many messages in sentbox
$cnt_sentbox_qry=dbquery("SELECT COUNT(message_id) cnt_sentbox FROM ".$db_prefix."messages WHERE message_to='".$userdata['user_id']."' AND message_folder='1' GROUP BY message_to");
if (dbrows($cnt_sentbox_qry) != 0) { $cnt_sentbox = dbresult($cnt_sentbox_qry, 0); } else { $cnt_sentbox = 0; }
// If equal to or greater than limit, delete difference (delete oldest sent messages)
if ($limit_sentbox != "0" && $cnt_sentbox >= $limit_sentbox) {
$difference = $cnt_sentbox - $limit_sentbox + 1;
$del_sent_qry = dbquery("SELECT message_id FROM ".$db_prefix."messages WHERE message_to='".$userdata['user_id']."' AND message_folder='1' ORDER BY message_id ASC LIMIT 0,".$difference);

while ($del_pm = dbarray($del_sent_qry)) { dbquery("DELETE FROM ".$db_prefix."messages WHERE message_id='".$del_pm['message_id']."'");}
}
$result = dbquery("INSERT INTO ".$db_prefix."messages (message_to, message_from, message_subject, message_message, message_smileys, message_read, message_datestamp, message_folder) VALUES ('".$userdata['user_id']."','".$msg_to."','".$subject."','".$message."','".$smileys."','0','".time()."','1')");
}
redirect(FUSION_SELF."?folder=".$folder);
}
} elseif (isset($msg_reply) || isset($_POST['reply_preview'])) { // reply to message
$result=dbquery(
"SELECT * FROM ".$db_prefix."messages LEFT JOIN ".$db_prefix."users ".
"ON message_from=user_id WHERE ".$result_where_message_id." AND ".$result_where_message_to
);
if(dbrows($result)) {
if (isset($_POST['reply_preview'])) displayMessagePreview($prev_subject,$prev_message);
$data = dbarray($result);
$recipient = "".$data['user_name']."";
$subject = ($data['message_subject']);
if (!strstr($subject,"RE: ")) $subject="RE: ".$subject;
$orig_message = parseubb(nl2br($data['message_message']));
if ($data['message_smileys'] == "y") $orig_message = parsesmileys($orig_message);
$msgdate = strftime($settings['longdate'], $data['message_datestamp']+($settings['timeoffset']*3600));
opentable($locale['439']);
echo "
function ValidateForm(frm) {
if ((frm.subject.value == '') || (frm.message.value == '')) {
alert('".$locale['486']."');
return false;
} else return true;
}







".$locale['421'].":
".$recipient."


".$locale['405'].":



".$locale['422'].":
".$orig_message."

".sprintf($locale['440'], $msgdate)."


".(0?$locale['422']:$locale['433']).":
".stripslashes($message)."












', ' [/code]');">



".displaysmileys("message")."



".$locale['425'].":

".$locale['427'];
if ($userdata[user_sig]) echo "
n".$locale['428'];
echo "


n







n";
} else {
opentable($locale['480']);
echo "
".$locale['481']."

n";
}
} elseif (isset($_POST['reply_message'])) { // send message
$smileys = (isset($_POST['chk_disablesmileys']) ? "n" : "y");
$subject = stripinput($_POST['subject']);
$message = stripinput($_POST['message']);
if (isset($_POST['chk_showsig'])) $message.="nn".$userdata['user_sig'];
if (isset($msg_to)&&(((int)$msg_to) == $msg_to)){
// Get message limits
$limits = dbarray(dbquery("SELECT pm_inbox,pm_sentbox FROM ".$db_prefix."messages_options WHERE user_id='0'"));
$limit_inbox = $limits['pm_inbox'];
$limit_sentbox = $limits['pm_sentbox'];
// Count inbox usage
$cnt_inbox_qry = dbquery("SELECT COUNT(message_id) cnt_inbox FROM ".$db_prefix."messages WHERE message_to='".$msg_to."' AND message_folder='0' GROUP BY message_to");
if (dbrows($cnt_inbox_qry)!=0) { $cnt_inbox = dbresult($cnt_inbox_qry,0); } else { $cnt_inbox = 0; }
// Check if user has reached inbox limit
if ($limit_inbox == "0" || ($cnt_inbox $result = dbquery("INSERT INTO ".$db_prefix."messages (message_to, message_from, message_subject, message_message, message_smileys, message_read, message_datestamp, message_folder) VALUES ('".$msg_to."', '".$userdata['user_id']."', '".$subject."', '".$message."', '".$smileys."', '0', '".time()."', 0)");
} else {
$error = $locale['628'];
}
// Get user options
$options_qry = dbquery("SELECT pm_email_notify FROM ".$db_prefix."messages_options WHERE user_id='".$msg_to."'");
if (dbrows($options_qry) != 0) {
$options = dbarray($options_qry);
} else {
$options = dbarray(dbquery("SELECT pm_email_notify FROM ".$db_prefix."messages_options WHERE user_id='0'"));
}
// Send notification email if user option is set
if ($options['pm_email_notify'] == "1") {
$uresult = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='".$msg_to."'");
$udata = dbarray($uresult);
sendemail($udata['user_name'],$udata['user_email'],$settings['siteusername'],$settings['siteemail'],$locale['625'],$udata['user_name'].$locale['626']);
}
// Lookup sending users options
$options_qry = dbquery("SELECT pm_save_sent FROM ".$db_prefix."messages_options WHERE user_id='".$userdata['user_id']."'");
if (dbrows($options_qry) != 0) {
$options = dbarray($options_qry);
} else {
$options = dbarray(dbquery("SELECT pm_save_sent FROM ".$db_prefix."messages_options WHERE user_id='0'"));
}
if ($options['pm_save_sent'] == "1") {
// Check how many messages in sentbox
$cnt_sentbox_qry=dbquery("SELECT COUNT(message_id) cnt_sentbox FROM ".$db_prefix."messages WHERE message_to='".$userdata['user_id']."' AND message_folder='1' GROUP BY message_to");
if (dbrows($cnt_sentbox_qry) != 0) { $cnt_sentbox = dbresult($cnt_sentbox_qry,0); } else { $cnt_sentbox = 0; }
// If equal to or greater than limit, delete difference (delete oldest sent messages)
if ($limit_sentbox != "0" && $cnt_sentbox >= $limit_sentbox) {
$difference = $cnt_sentbox - $limit_sentbox + 1;
$del_sent_qry = dbquery("SELECT message_id FROM ".$db_prefix."messages WHERE message_to='".$userdata['user_id']."' AND message_folder='1' ORDER BY message_id ASC LIMIT 0,".$difference);
while ($del_pm = dbarray($del_sent_qry)) { dbquery("DELETE FROM ".$db_prefix."messages WHERE message_id='".$del_pm['message_id']."'");}
}
}

}
if (isset($error)) {
opentable($locale['627']);
echo "
".$error."

";
} else {
if ($options['pm_save_sent'] == '1') {
$result = dbquery("INSERT INTO ".$db_prefix."messages (message_to, message_from, message_subject, message_message, message_smileys, message_read, message_datestamp, message_folder) VALUES ('".$userdata['user_id']."','".$msg_to."','".$subject."','".$message."','".$smileys."','0','".time()."','1')");
}
redirect(FUSION_SELF."?folder=".$folder);
}
} else {
$srch_fields = array(
//code=>array(add_slashes,'field name','display name');
"s" => array(1,'message_subject',$locale['462']),
"m" => array(1,'message_message',$locale['463']),
"f" => array(0,'user_name',$locale['464'])
);
$sort_fields=array(
//code=>array('field name','display name');
"d" => array('message_datestamp DESC',$locale['465']),
"f" => array('message_from',$locale['464']),
"s" => array('message_subject',$locale['462'])
);
if (isset($srch_type) && !in_array($srch_type,array("s","m","f"))) $srch_type = "s";
if (isset($sort_type) && !in_array($sort_type,array("d","f","s"))) $sort_type = "d";
if (isset($_POST['srch_reset'])) {
unset($show,$srch_text,$srch_type,$sort_type);
} elseif (isset($srch_text) && $srch_text"" && $srch_type "") {
if ($srch_fields[$srch_type][0]) { $srch_text2 = stripinput($srch_text); } else { $srch_text2 = $srch_text; }
$srch_text2 = str_replace(array('?','*'), array('_','%'), $srch_text2);
$srch_where = " AND ".$srch_fields[$srch_type][1]." LIKE '$srch_text2'";
} elseif(isset($show)){
$show = strtolower($show);
if ($show!="all" && preg_match("/^[a-z]$/", $show)) $srch_where=" AND LEFT(user_name,1)='".$show."'";
} else {
$srch_text="";
$srch_where="";
}
if (isset($sort_type) && $sort_type "") {
$sort_where = $sort_fields[$sort_type][0];
} else {
$sort_where = "message_datestamp DESC";
}
if ($srch_text != ""){
$title = sprintf($locale['458'], $srch_text, $srch_fields[$srch_type][2]);
} elseif (isset($show)) {
($show != "all" ? $title = sprintf($locale['459'], $show) : "");
} else {
$title = "";
}
if(isset($sort_type)){
$title.=sprintf($locale['460'],$sort_fields[$sort_type][1]);
}
if($title != ""){
$title="

".$title."


n";
}
opentable($locale['400']);
$data = dbarray(dbquery(
"SELECT COUNT(message_id) cnt_total, COUNT(IF(message_folder=0, 1, null)) cnt_inbox, ".
"COUNT(IF(message_folder=1, 1, null)) cnt_sentbox, COUNT(IF(message_folder=2, 1, null)) cnt_savebox ".
"FROM ".$db_prefix."messages WHERE ".$result_where_message_to." GROUP BY message_to"
));
// Get folder size restrictions (room for future option to restrict number of pm's for a specific user)
$limit = dbarray(dbquery("SELECT * FROM ".$db_prefix."messages_options WHERE user_id='0'"));
if (isset($data['cnt_total'])) { $cnt_total = $data['cnt_total']; } else { $cnt_total = "0"; }
if (isset($data['cnt_inbox'])) { $cnt_inbox = $data['cnt_inbox']; } else { $cnt_inbox = "0"; }
if (isset($data['cnt_sentbox'])) { $cnt_sentbox = $data['cnt_sentbox']; } else { $cnt_sentbox = "0"; }
if (isset($data['cnt_savebox'])) { $cnt_savebox = $data['cnt_savebox']; } else { $cnt_savebox = "0"; }
$limit_inbox = $limit['pm_inbox'];
$limit_sentbox = $limit['pm_sentbox'];
$limit_savebox = $limit['pm_savebox'];

// Set display of top bar
if ($limit_inbox != "0") { $inbox_display = " (".$cnt_inbox."/".$limit_inbox.")"; } else { $inbox_display = " (".$cnt_inbox.")"; }
if ($limit_sentbox != "0") { $sentbox_display = " (".$cnt_sentbox."/".$limit_sentbox.")"; } else { $sentbox_display = " (".$cnt_sentbox.")"; }
if ($limit_savebox != "0") { $savebox_display = " (".$cnt_savebox."/".$limit_savebox.")"; } else { $savebox_display = " (".$cnt_savebox.")"; }

if ($cnt_total !=0 || $folder != "settings"){
tablebreak();
echo $title."






n".$folder_stat[0]."".$locale['402'].$inbox_display."".$folder_stat[1]."nn
n".$folder_stat[2]."".$locale['403'].$sentbox_display."".$folder_stat[3]."nn
n".$folder_stat[4]."".$locale['404'].$savebox_display."".$folder_stat[5]."nn
n".$folder_stat[6]."".$locale['620']."".$folder_stat[7]."nn




n";
tablebreak();
// Display Options Page
if ($folder == "options") {
$options_qry = dbquery("SELECT * FROM ".$db_prefix."messages_options WHERE user_id='".$userdata['user_id']."'");
if (dbrows($options_qry) != 0) {
$options = dbarray($options_qry);
$update_type = "update";
} else {
$update_type = "new";
}
// Select default value for options
$displayoptions['pm_email_notify'][0] = "".$locale['632']."";
$displayoptions['pm_email_notify'][1] = "".$locale['631']."";
$displayoptions['pm_save_sent'][0] = "".$locale['632']."";
$displayoptions['pm_save_sent'][1] = "".$locale['631']."";
// If value is set to '1' then display the correct default value of yes
$default_options = dbarray(dbquery("SELECT pm_email_notify,pm_save_sent FROM ".$db_prefix."messages_options WHERE user_id='0'"),0);
if ($default_options['pm_email_notify'] == 1) { rsort($displayoptions['pm_email_notify']); }
if ($default_options['pm_save_sent'] == 1) { rsort($displayoptions['pm_save_sent']); }

echo "




".$locale['620']."


".$locale['621']."

".
$displayoptions['pm_email_notify'][0].
$displayoptions['pm_email_notify'][1].
"



".$locale['622']."

".
$displayoptions['pm_save_sent'][0].
$displayoptions['pm_save_sent'][1].
"










n";
} else {
$rows=dbresult(dbquery(
"SELECT COUNT(*) FROM ".$db_prefix."messages LEFT JOIN ".$db_prefix."users ON user_id=message_from ".
"WHERE ".$result_where_message_folder." AND ".$result_where_message_to.$srch_where
),0);
if(!isset($rowstart) || !isNum($rowstart)) $rowstart=0;
$result=dbquery(
"SELECT * FROM ".$db_prefix."messages LEFT JOIN ".$db_prefix."users ".
"ON user_id=message_from WHERE ".$result_where_message_folder." AND ".$result_where_message_to.$srch_where.
" ORDER BY message_read,".$sort_where." LIMIT ".$rowstart.",".$itemsperpage
);
$msgcount=dbrows($result);
if($msgcount>0){
echo "n



".$locale['405']."
".($msg_folders[$folder]==1?$locale['421']:$locale['406'])."
".$locale['407']."
n";
$unread_shown=0;
$r=0;
while ($data = dbarray($result)) {
$msgdate=strftime($settings['forumdate'], $data['message_datestamp']+($settings['timeoffset']*3600));
if($data['message_read']$unread_shown){
if ($r > 0)echo "n";
$unread_shown = 1;
}
echo "n";
if ($data['message_read'] == 0){echo "";}
echo "";
$msg_title=($settings['privmsg_subject_tooltip']?substr(stripslashes($data['message_message']),0,75)."'":$locale['505']);
echo "".$data['message_subject']."";
if ($data['message_read'] == 0){echo "
";}
echo "n";
if ($data['message_from'] == 0){
echo $locale['408'];
} else {
echo "".$data['user_name']."";
}
echo "n".$msgdate."n";
$r++;
echo "n";
}
echo "

function setChecked(frmName,chkName,val){
dml=document.forms[frmName];
len=dml.elements.length;
for(i=0;i if(dml.elements.name==chkName){
dml.elements.checked=val;
}
}
}

function ValidateForm(dml,chkName){
len=dml.elements.length;
for(i=0;i if((dml.elements.name==chkName)&&(dml.elements.checked==1)) return true
}
alert('".$locale['485']."')
return false;
}
n";
} else {
echo "
".($srch_where==""?$locale['461']:$locale['453'])."

n";
}
if($msgcount>0){
tablebreak();
echo "n

n
".$locale['409']." n";
if($folder=='savebox'){
echo " ";
} else {
echo " ";
}
echo "

n
nnn";
tablebreak();
}
if ($msgcount > 0 || $srch_where != ""){
echo "
n".$locale['417']." ".$locale['418']."";
$srch_letters=array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
foreach($srch_letters as $srch_letter){
echo "|".$srch_letter."";
}
echo "nn";
}
echo "";
if($msgcount>0 || $srch_where!=""){
closetable();
if (isset($show)){
$link = "?show=".$show."&";
} elseif (isset($srch_text) && isset($srch_type)){
$link = "?srch_text=".$srch_text."&srch_type=".$srch_type."&";
} else {
$link = "?";
}
// Make pagination (Support for when 'Sender with Letter ?' is set)
if (isset($show)) { $url = "?folder=$folder&show=$show&"; } else { $url = "?folder=$folder&"; }
if ($rows != 0) echo "".makePageNav($rowstart,$itemsperpage,$rows,3,FUSION_SELF.$url)."n";
opentable($locale['450']);
echo "


".$locale['454']." 


".$locale['457']."


".$locale['455']." n
n";
foreach($srch_fields as $key=>$srch_field){
$sel=($key==$srch_type?"selected":"");
echo "".$srch_field[2]."n";
}
echo "".$locale['456']." n
n";
foreach($sort_fields as $key=>$sort_field){
$sel=($key==$sort_type?"selected":"");
echo "".$sort_field[1]."n";
}
echo "



n";
}
}
} else {
echo "
".$locale['419']."





n";
}
}
closetable();

require_once BASEDIR."side_right.php";
require_once BASEDIR."footer.php";
?>
------------------------------------------------------------------------------------------------------

What is wrong?
 Quote

All times are EST. The time is now 10:41 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content