Discuz! 论坛软件系统
big5
源代码在线查看: pm.inc.php
/*
[DISCUZ!] wap/include/pm.inc.php - send and receive P.M.s via wap
This is NOT a freeware, use is subject to license terms
Version: 4.0.0
Web: http://www.comsenz.com
Copyright: 2001-2005 Comsenz Technology Ltd.
Last Modified: 2005-2-28 10:15
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$discuz_action = 197;
if(!$discuz_uid) {
wapmsg('not_loggedin');
}
if(empty($do)) {
$num_read = $num_unread = 0;
$query = $db->query("SELECT COUNT(*) AS num, new FROM {$tablepre}pms WHERE msgtoid='$discuz_uid' AND folder='inbox' GROUP BY new='0'");
while($pm = $db->fetch_array($query)) {
$pm['new'] ? $num_unread = $pm['num'] : $num_read = $pm['num'];
}
echo "$lang[pm_unread]($num_unread)\n".
"$lang[pm_all](".($num_read + $num_unread).")\n".
"$lang[pm_send]\n";
} else {
echo "$lang[pm_home]\n";
if($do == 'list') {
$unreadadd = empty($unread) ? '' : 'AND new>\'0\'';
$page = empty($page) || !ispage($page) ? 1 : $page;
$start_limit = $number = ($page - 1) * $waptpp;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}pms WHERE msgtoid='$discuz_uid' AND folder='inbox' $unreadadd");
if(!($totalpms = $db->result($query, 0))) {
wapmsg('pm_nonexistence');
}
$query = $db->query("SELECT pmid, new, msgfrom, subject, dateline FROM {$tablepre}pms
WHERE msgtoid='$discuz_uid' AND folder='inbox' $unreadadd
ORDER BY dateline DESC
LIMIT $start_limit, $waptpp");
while($pm = $db->fetch_array($query)) {
echo "#".++$number.' '.(empty($unread) && $pm['new'] ? "($lang[unread])" : '').cutstr($pm['subject'], 30)."\n".
" ".gmdate("$wapdateformat $timeformat", $pm['dateline'] + $timeoffset * 3600)."\n".
" $pm[msgfrom]\n";
}
echo "$lang[page]$page ".
($start_limit + $waptpp < $totalpms ? ">>$lang[next_page]" : $lang['end']).
"\n";
} elseif($do == 'view') {
$query = $db->query("SELECT * FROM {$tablepre}pms WHERE pmid='$pmid' AND msgtoid='$discuz_uid' AND folder='inbox'");
if(!$pm = $db->fetch_array($query)) {
wapmsg('pm_nonexistence');
}
echo "$pm[subject]\n".
"$pm[msgfrom]\n".
"".gmdate("$wapdateformat $timeformat", $pm['dateline'] + $timeoffset * 3600)."\n".
"".nl2br(dhtmlspecialchars(trim($pm['message'])))."\n".
"$lang[reply]\n".
"$lang[delete]\n";
$db->query("UPDATE {$tablepre}pms SET new='0' WHERE pmid='$pmid'");
} elseif($do == 'send') {
if(empty($msgto)) {
if(!empty($pmid)) {
$query = $db->query("SELECT msgfrom, subject FROM {$tablepre}pms WHERE pmid='$pmid' AND msgtoid='$discuz_uid' AND folder='inbox'");
$pm = $db->fetch_array($query);
$pm['subject'] = 'Re: '.$pm['subject'];
} else {
$pm = array('msgfrom' => '', 'subject' => '');
}
echo "$lang[pm_to]:\n".
"$lang[subject]:\n".
"$lang[message]:\n".
"$lang[submit]".
"\n".
"\n".
"\n".
"\n".
"\n";
} else {
$floodctrl = $floodctrl * 2;
if($floodctrl && !$disablepostctrl && $timestamp - $lastpost < $floodctrl) {
wapmsg('pm_flood_ctrl');
}
$query = $db->query("SELECT m.uid AS msgtoid, mf.ignorepm FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf USING (uid)
WHERE username='$msgto'");
if(!$member = $db->fetch_array($query)) {
wapmsg('pm_send_nonexistence');
}
if(preg_match("/(^{ALL}$|(,|^)\s*".preg_quote($discuz_user, '/')."\s*(,|$))/i", $member['ignorepm'])) {
wapmsg('pm_send_ignore');
}
if(empty($subject) || empty($message)) {
wapmsg('pm_sm_isnull');
}
$subject = cutstr(trim($subject), 75);
$db->query("INSERT INTO {$tablepre}pms (msgfrom, msgfromid, msgtoid, folder, new, subject, dateline, message)
VALUES('$discuz_user', '$discuz_uid', '$member[msgtoid]', 'inbox', '1', '$subject', '$timestamp', '$message')");
$db->query("UPDATE {$tablepre}members SET newpm='1' WHERE uid='$member[msgtoid]'", 'UNBUFFERED');
if($floodctrl) {
$db->query("UPDATE {$tablepre}members SET lastpost='$timestamp' WHERE uid='$discuz_uid'");
}
wapmsg('pm_send_succeed');
}
} elseif($do == 'delete') {
$db->query("DELETE FROM {$tablepre}pms WHERE pmid='$pmid' AND msgtoid='$discuz_uid' AND folder='inbox'");
wapmsg('pm_delete_succeed');
}
}
?>