/** * 以某个用户的身份给另一个用户发送短消息 * @param int $userId 发送者uid * @param string $receiver 接受者用户名 * @param string $subject 标题 * @param string $content 内容 * return bool */ function sendMessage($userId, $receiver, $subject, $content) { global $winddb, $winduid, $windid, $groupid, $_G, $SYSTEM; $userService = $this->_getUserService(); $winddb = $userService->get($userId, true, true); $winduid = $winddb['uid']; $groupid = $winddb['groupid']; $windid = $winddb['username']; $groupid == '-1' && ($groupid = $winddb['memberid']); if (file_exists(D_P . "data/groupdb/group_{$groupid}.php")) { extract(pwCache::getData(S::escapePath(D_P . "data/groupdb/group_{$groupid}.php", false))); } else { extract(pwCache::getData(D_P . 'data/groupdb/group_1.php', false)); } M::sendMessage($userId, array($receiver), array('create_uid' => $winduid, 'create_username' => $windid, 'title' => S::escapeChar(stripslashes($subject)), 'content' => S::escapeChar(stripslashes($content)))); return new ApiResponse(true); }
/** * 发送社区短消息或系统通知 * 重构新消息中心 * @param array $msg 信息格式如下: * $msg = array( * 'toUser' => 'admin', //接收者用户名,可为数组群发:array('admin','abc') * 'toUid' => 1, //接收者uid,可为数组群发:array(1,2),当与 toUser 同时存在时,自然失效 * 'fromUid' => 2, //发送者UID,与fromUser同时存在才有效 (可选,默认为'0') * 'fromUser' => 'pwtest',//发送者用户名,与fromUid同时存在才有效(可选,默认为'SYSTEM') * 'subject' => 'Test', //消息标题 * 'content' => '~KO~', //消息内容 * 'other' => array() //其他信息变量 * ); * @return boolean 返回消息发送是否完成 */ function pwSendMsg($msg) { global $db, $timestamp; if (!$msg['toUser'] && !$msg['toUid'] || !$msg['subject'] || !$msg['content']) { return false; } $msg['subject'] = getLangInfo('writemsg', $msg['subject'], $msg); $msg['content'] = getLangInfo('writemsg', $msg['content'], $msg); $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ $usernames = $msg['toUser'] ? $msg['toUser'] : $userService->getUserNameByUserId($msg['toUid']); $usernames = is_array($usernames) ? $usernames : array($usernames); if (!$msg['fromUid'] || !$msg['fromUser']) { M::sendNotice($usernames, array('title' => $msg['subject'], 'content' => $msg['content'])); } else { M::sendMessage($msg['fromUid'], $usernames, array('create_uid' => $msg['fromUid'], 'create_username' => $msg['fromUser'], 'title' => $msg['subject'], 'content' => $msg['content'])); } return true; }
$sql .= " AND ifadmin='1'"; break; case '2': $sql .= " AND ifadmin='0'"; break; case '3': $sql .= " AND ifadmin='-1'"; break; } $query = $db->query("SELECT username FROM pw_cmembers {$sql} LIMIT 500"); while ($rt = $db->fetch_array($query)) { $toUsers[] = $rt['username']; } } if ($toUsers) { M::sendMessage($winduid, $toUsers, array('create_uid' => $winduid, 'create_username' => $windid, 'title' => $subject, 'content' => stripslashes($content))); } Showmsg('send_success'); } } elseif ($a == 'invite') { empty($winduid) && Showmsg('not_login'); S::gp(array('id', 'type')); require_once R_P . 'require/functions.php'; $customdes = getLangInfo('other', 'invite_custom_des'); $tmpUrlAdd .= '&a=invite'; if ($type == 'groupactive') { $invite_url = $db_bbsurl . '/u.php?a=invite&type=groupactive&id=' . $id . '&uid=' . $winduid . '&hash=' . appkey($winduid, $type); $activeArray = $db->get_one("SELECT * FROM pw_active WHERE id=" . S::sqlEscape($id)); $objectName = $activeArray['title']; $objectDescrip = substrs($activeArray['content'], 30); $activeId = $activeArray['id'];
/** * 发送消息 * @param string $receiver * @param array $content */ function sendMessage($receiver, $title, $content) { global $winduid, $windid; $messageInfo = array('create_uid' => $winduid, 'create_username' => $windid, 'title' => $title, 'content' => $content); M::sendMessage($winduid, array($receiver), $messageInfo, 'sms_ratescore', 'sms_rate'); }
} if (isset($_G['messagecontentsize']) && $_G['messagecontentsize'] > 0 && strlen($atc_content) > $_G['messagecontentsize']) { Showmsg('内容超过限定长度' . $_G['messagecontentsize'] . '字节'); } if ($pwuser == $windid) { Showmsg('send_message_to_self'); } require_once R_P . 'require/bbscode.php'; $wordsfb = L::loadClass('FilterUtil', 'filter'); if (($banword = $wordsfb->comprise($msg_title)) !== false) { Showmsg('title_wordsfb'); } if (($banword = $wordsfb->comprise($atc_content, false)) !== false) { Showmsg('content_wordsfb'); } //$msgq && Qcheck($_POST['qanswer'], $_POST['qkey']); $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ $rt = $userService->getByUserName($pwuser); //uid,banpm,msggroups if (!$rt) { $errorname = $pwuser; Showmsg('user_not_exists'); } if ($rt['msggroups'] && strpos($rt['msggroups'], ",{$groupid},") !== false || strpos(",{$rt['banpm']},", ",{$windid},") !== false) { $errorname = $pwuser; Showmsg('msg_refuse'); } M::sendMessage($winduid, array($pwuser), array('create_uid' => $winduid, 'create_username' => $windid, 'title' => $msg_title, 'content' => stripslashes($atc_content))); Showmsg('send_success'); }
function sendMail() { global $db_msgreplynotice, $db_replysendmail, $db_replysitemail, $windid, $winduid; $ret = $msgNotice = 0; $this->data['content'] = preg_replace("/\\[quote\\](.*)\\[\\/quote\\]/is", "", $this->data['content']); if ($db_msgreplynotice && $this->replyToUser && $this->replyToUser != $windid) { M::sendMessage($winduid, array($this->replyToUser), array('create_uid' => $winduid, 'create_username' => $windid, 'title' => getLangInfo('writemsg', 'subject_replytouser_title', array('windid' => $windid, 'title' => substrs(strip_tags($this->tpcArr['subject']), 30, 'Y'))), 'content' => getLangInfo('writemsg', 'subject_reply_content', array('tid' => $this->tid, 'pid' => $this->pid, 'windid' => $windid, 'content' => substrs(strip_tags($this->data['content']), 100, 'Y')))), 'sms_reply', 'sms_reply'); $msgNotice = 1; } if ($this->data['authorid'] == $this->tpcArr['authorid']) { return $ret; } if ($db_replysendmail == 1 && ($this->tpcArr['ifmail'] == 1 || $this->tpcArr['ifmail'] == 3)) { $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ $receiver = $this->tpcArr['author']; $old_title = $this->tpcArr['subject']; $detail = $userService->get($this->tpcArr['authorid']); $send_address = $detail['email']; if (getstatus($detail['userstatus'], PW_USERSTATUS_RECEIVEMAIL)) { require_once R_P . 'require/sendemail.php'; sendemail($send_address, 'email_reply_subject', 'email_reply_content', 'email_additional'); } $ret = 1; } if ($db_replysitemail && !$msgNotice && ($this->tpcArr['ifmail'] == 2 || $this->tpcArr['ifmail'] == 3)) { /* $userService = L::loadClass('UserService', 'user'); $rt = $userService->get($this->tpcArr['authorid'], true, false, true); $replyinfo = $rt['replyinfo'] ? $rt['replyinfo'] . $this->tid . ',' : ",$this->tid,"; $userService->update($this->tpcArr['authorid'], array(), array(), array('replyinfo' => $replyinfo)); if (!getstatus($rt['userstatus'], PW_USERSTATUS_NEWRP)) { $userService->setUserStatus($this->tpcArr['authorid'], PW_USERSTATUS_NEWRP, true); } */ M::sendMessage($winduid, array($this->tpcArr['author']), array('create_uid' => $winduid, 'create_username' => $windid, 'title' => getLangInfo('writemsg', 'subject_reply_title', array('windid' => $windid, 'author' => $this->tpcArr['author'], 'title' => substrs(strip_tags($this->tpcArr['subject']), 30, 'Y'))), 'content' => getLangInfo('writemsg', 'subject_reply_content', array('tid' => $this->tid, 'pid' => $this->pid, 'windid' => $windid, 'content' => substrs(strip_tags(stripWindCode($this->data['content'])), 100, 'Y')))), 'sms_reply', 'sms_reply'); $ret += 2; } return $ret; }
$pw_posts = GetPtable('N', $tid); $sqlsel = "t.content as subject,t.postdate,"; $sqltab = "{$pw_posts} t"; $sqladd = 'WHERE t.pid=' . S::sqlEscape($pid); } else { $sqlsel = "t.subject,t.postdate,"; $sqltab = "pw_threads t"; $sqladd = 'WHERE t.tid=' . S::sqlEscape($tid); } $rs = $db->get_one("SELECT {$sqlsel} t.fid,f.forumadmin FROM {$sqltab} LEFT JOIN pw_forums f USING(fid) {$sqladd}"); if ($rs['forumadmin']) { //* include_once pwCache::getPath(D_P.'data/bbscache/forum_cache.php'); pwCache::getData(D_P . 'data/bbscache/forum_cache.php'); $admin_a = explode(',', $rs['forumadmin']); $iftpc = $pid ? '0' : '1'; M::sendMessage($winduid, array($admin_a), array('create_uid' => $winduid, 'create_username' => $windid, 'title' => getLangInfo('writemsg', 'report_title'), 'content' => getLangInfo('writemsg', 'report_content_' . $type . '_' . $iftpc, array('fid' => $rs['fid'], 'tid' => $tid, 'pid' => $pid, 'postdate' => get_date($rs['postdate']), 'forum' => $forum[$rs['fid']]['name'], 'subject' => $rs['subject'], 'admindate' => get_date($timestamp), 'reason' => stripslashes($reason))))); } } if (defined('AJAX')) { Showmsg('report_success'); } else { refreshto("read.php?tid={$tid}&ds=1&page={$page}", 'report_success'); } } } elseif ($action == 'commentsPic') { S::gp(array('tid', 'aid')); require_once PrintEot('ajax_operate'); ajax_footer(); } else { Showmsg('undefined_action'); }