function mob_get_participated_forum() { global $mobdb, $context, $scripturl, $settings, $user_info; if ($user_info['is_guest']) { mob_error('guests not allowed'); } $request = $mobdb->query(' SELECT b.name, b.ID_BOARD AS id_board' . ($user_info['is_guest'] ? ", 1 AS is_read, 0 AS new_from" : ", (IFNULL(lb.ID_MSG, 0) >= b.ID_MSG_UPDATED) AS is_read, IFNULL(ln.sent, -1) AS is_notify") . ' FROM {db_prefix}messages AS m INNER JOIN {db_prefix}boards AS b ON (m.ID_BOARD = b.ID_BOARD)' . (!$user_info['is_guest'] ? "\n LEFT JOIN {db_prefix}log_boards AS lb ON (lb.ID_BOARD = b.ID_BOARD AND lb.ID_MEMBER = {int:member})\n LEFT JOIN {db_prefix}log_notify AS ln ON (ln.ID_BOARD = b.ID_BOARD AND ln.ID_MEMBER = {int:member})" : '') . ' WHERE m.ID_MEMBER = {int:member} AND {query_see_board} GROUP BY b.ID_BOARD ORDER BY m.posterTime DESC', array('member' => $user_info['id'])); $boards = array(); while ($row = $mobdb->fetch_assoc($request)) { $boards[] = new xmlrpcval(array('forum_id' => new xmlrpcval($row['id_board'], 'string'), 'forum_name' => new xmlrpcval(processSubject($row['name']), 'base64'), 'new_post' => new xmlrpcval($row['is_read'], 'boolean'), 'icon_url' => new xmlrpcval(get_board_icon($row['id_board'], $row['is_read'], false), 'string')), 'struct'); } $mobdb->free_result($request); return new xmlrpcresp(new xmlrpcval(array('total_forums_num' => new xmlrpcval(count($boards), 'int'), 'forums' => new xmlrpcval($boards, 'array')), 'struct')); }
/** * Displays message header row in messages list * * @param array $aMsg contains all message related parameters * @return void */ function printMessageInfo($aMsg) { // FIX ME, remove these globals as well by adding an array as argument for the user settings // specificly meant for header display global $checkall, $color, $default_use_priority, $message_highlight_list, $index_order, $truncate_sender, $email_address, $show_recipient_instead, $use_icons, $icon_theme; /* icons theming */ $color_string = $color[4]; // initialisation: $mailbox = $aMsg['MAILBOX']; $msg = $aMsg['HEADER']; $t = $aMsg['INDX']; $start_msg = $aMsg['PAGEOFFSET']; $last = $aMsg['LAST']; if (isset($aMsg['SEARCH']) && count($aMsg['SEARCH']) > 1) { $where = $aMsg['SEARCH'][0]; $what = $aMsg['SEARCH'][1]; } else { $where = false; $what = false; } $iIndent = $aMsg['INDENT']; $sSubject = isset($msg['SUBJECT']) && $msg['SUBJECT'] != '' ? $msg['SUBJECT'] : _("(no subject)"); $sFrom = isset($msg['FROM']) ? $msg['FROM'] : _("Unknown sender"); $sTo = isset($msg['TO']) ? $msg['TO'] : _("Unknown recipient"); $sCc = isset($msg['CC']) ? $msg['CC'] : ''; $aFlags = isset($msg['FLAGS']) ? $msg['FLAGS'] : array(); $iPrio = isset($msg['PRIORITY']) ? $msg['PRIORITY'] : 3; $iSize = isset($msg['SIZE']) ? $msg['SIZE'] : 0; $sType0 = isset($msg['TYPE0']) ? $msg['TYPE0'] : 'text'; $sType1 = isset($msg['TYPE1']) ? $msg['TYPE1'] : 'plain'; if (isset($msg['INTERNALDATE'])) { $sDate = getDateString(getTimeStamp(explode(' ', $msg['INTERNALDATE']))); } else { $sDate = isset($msg['DATE']) ? getDateString(getTimeStamp(explode(' ', $msg['DATE']))) : ''; } $iId = isset($msg['UID']) ? $msg['UID'] : false; if (!$iId) { return; } if ($GLOBALS['alt_index_colors']) { if (!($t % 2)) { if (!isset($color[12])) { $color[12] = '#EAEAEA'; } $color_string = $color[12]; } } $urlMailbox = urlencode($mailbox); // FIXME, foldertype should be set in right_main.php // in other words, handle as sent is obsoleted from now. // We replace that by providing an array to aMailbox with the to shown headers // that way we are free to show the user different layouts for different folders $bSentFolder = handleAsSent($mailbox); if (!$bSentFolder && $show_recipient_instead) { // If the From address is the same as $email_address, then handle as Sent $from_array = parseAddress($sFrom, 1); if (!isset($email_address)) { global $datadir, $username; $email_address = getPref($datadir, $username, 'email_address'); } $bHandleAsSent = isset($from_array[0][0]) && $from_array[0][0] == $email_address; } else { $bHandleAsSent = $bSentFolder; } // If this is a Sent message, display To address instead of From if ($bHandleAsSent) { $sFrom = $sTo; } // Passing 1 below results in only 1 address being parsed, thus defeating the following code $sFrom = parseAddress($sFrom); /* * This is done in case you're looking into Sent folders, * because you can have multiple receivers. */ $senderNames = $sFrom; $senderName = ''; $senderAddress = ''; if (sizeof($senderNames)) { foreach ($senderNames as $senderNames_part) { if ($senderName != '') { $senderName .= ', '; $senderAddress .= ', '; } $sender_address_part = htmlspecialchars($senderNames_part[0]); $sender_name_part = str_replace(' ', ' ', decodeHeader($senderNames_part[1])); if ($sender_name_part) { $senderName .= $sender_name_part; $senderAddress .= $sender_name_part . ' <' . $sender_address_part . '>'; } else { $senderName .= $sender_address_part; $senderAddress .= $sender_address_part; } } } // If Sent, prefix with To: but only if not Sent folder if ($bHandleAsSent ^ $bSentFolder) { $senderName = _("To") . ': ' . $senderName; $senderAddress = _("To") . ': ' . $senderAddress; } // this is a column property which can apply to multiple columns. Do not use vars for one column // only. instead we should use something like this: // 1ed column $aMailbox['columns']['SUBJECT'] value: aray with properties ... // 2ed column $aMailbox['columns']['FROM'] value: aray with properties ... // NB in case of the sentfolder this could be the TO field // properties array example: // 'truncate' => length (0 is no truncate) // 'prefix => if (x in b then do that ) if ($truncate_sender > 0) { $senderName = truncateWithEntities($senderName, $truncate_sender); } $flag = $flag_end = $bold = $bold_end = $fontstr = $fontstr_end = $italic = $italic_end = ''; $bold = '<b>'; $bold_end = '</b>'; foreach ($aFlags as $sFlag => $value) { switch ($sFlag) { case '\\flagged': if ($value) { $flag = "<font color=\"{$color['2']}\">"; $flag_end = '</font>'; } break; case '\\seen': if ($value) { $bold = ''; $bold_end = ''; } break; case '\\deleted': if ($value) { $fontstr = "<font color=\"{$color['9']}\">"; $fontstr_end = '</font>'; } break; } } if ($bHandleAsSent) { $italic = '<i>'; $italic_end = '</i>'; } if ($where && $what) { $searchstr = '&where=' . $where . '&what=' . $what; } else { $searchstr = ''; } /* * Message highlight code */ $matches = array('TO' => 'sTo', 'CC' => 'sCc', 'FROM' => 'sFrom', 'SUBJECT' => 'sSubject'); if (is_array($message_highlight_list) && count($message_highlight_list)) { $sTo = parseAddress($sTo); $sCc = parseAddress($sCc); foreach ($message_highlight_list as $message_highlight_list_part) { if (trim($message_highlight_list_part['value']) != '') { $high_val = strtolower($message_highlight_list_part['value']); $match_type = strtoupper($message_highlight_list_part['match_type']); if ($match_type == 'TO_CC') { $match = array('TO', 'CC'); } else { $match = array($match_type); } foreach ($match as $match_type) { switch ($match_type) { case 'TO': case 'CC': case 'FROM': foreach (${$matches}[$match_type] as $address) { $address[0] = decodeHeader($address[0], true, false); $address[1] = decodeHeader($address[1], true, false); if (strstr('^^' . strtolower($address[0]), $high_val) || strstr('^^' . strtolower($address[1]), $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 4; } } break; default: $headertest = strtolower(decodeHeader(${$matches}[$match_type], true, false)); if (strstr('^^' . $headertest, $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 3; } break; } } } } } /* end Message highlight code */ if (!isset($hlt_color)) { $hlt_color = $color_string; } $col = 0; $sSubject = str_replace(' ', ' ', decodeHeader($sSubject)); $subject = processSubject($sSubject, $iIndent); echo html_tag('tr', '', '', '', 'valign="top"') . "\n"; if (sizeof($index_order)) { foreach ($index_order as $index_order_part) { switch ($index_order_part) { case 1: /* checkbox */ echo html_tag('td', addCheckBox("msg[{$t}]", $checkall, $iId), 'center', $hlt_color); break; case 2: /* from */ if ($senderAddress != $senderName) { $senderAddress = strtr($senderAddress, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); $title = ' title="' . str_replace('"', "''", $senderAddress) . '"'; } else { $title = ''; } echo html_tag('td', $italic . $bold . $flag . $fontstr . $senderName . $fontstr_end . $flag_end . $bold_end . $italic_end, 'left', $hlt_color, $title); break; case 3: /* date */ if ($sDate == '') { $sDate = _("Unknown date"); } echo html_tag('td', $bold . $flag . $fontstr . $sDate . $fontstr_end . $flag_end . $bold_end, 'center', $hlt_color, 'nowrap'); break; case 4: /* subject */ $td_str = $bold; if ($iIndent) { $td_str .= str_repeat(" ", $iIndent); } $td_str .= '<a href="read_body.php?mailbox=' . $urlMailbox . '&passed_id=' . $iId . '&startMessage=' . $start_msg . $searchstr . '"'; $td_str .= ' ' . concat_hook_function('subject_link', array($start_msg, $searchstr)); if ($subject != $sSubject) { $title = get_html_translation_table(HTML_SPECIALCHARS); $title = array_flip($title); $title = strtr($sSubject, $title); $title = str_replace('"', "''", $title); $td_str .= " title=\"{$title}\""; } $td_str .= ">{$flag}{$subject}{$flag_end}</a>{$bold_end}"; echo html_tag('td', $td_str, 'left', $hlt_color); break; case 5: /* flags */ // icon message markers // if ($use_icons && $icon_theme != 'none') { $td_str = "<b><small>"; if (isset($aFlags['\\flagged']) && $aFlags['\\flagged'] == true) { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/flagged.png" border="0" height="10" width="10" /> '; } if ($default_use_priority) { if ($iPrio == 1 || $iPrio == 2) { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/prio_high.png" border="0" height="10" width="5" /> '; } else { if ($iPrio == 5) { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/prio_low.png" border="0" height="10" width="5" /> '; } else { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/transparent.png" border="0" width="5" /> '; } } } if ($sType1 == 'mixed') { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/attach.png" border="0" height="10" width="6" />'; } else { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/transparent.png" border="0" width="6" />'; } $msg_icon = ''; if (!isset($aFlags['\\seen']) || $aFlags['\\seen'] == false) { $msg_alt = '(' . _("New") . ')'; $msg_title = '(' . _("New") . ')'; $msg_icon .= SM_PATH . 'images/themes/' . $icon_theme . '/msg_new'; } else { $msg_alt = '(' . _("Read") . ')'; $msg_title = '(' . _("Read") . ')'; $msg_icon .= SM_PATH . 'images/themes/' . $icon_theme . '/msg_read'; } if (isset($aFlags['\\deleted']) && $aFlags['\\deleted'] == true) { $msg_icon .= '_deleted'; } if (isset($aFlags['\\answered']) && $aFlags['\\answered'] == true) { $msg_alt = '(' . _("Answered") . ')'; $msg_title = '(' . _("Answered") . ')'; $msg_icon .= '_reply'; } $td_str .= '<img src="' . $msg_icon . '.png" border="0" alt="' . $msg_alt . '" title="' . $msg_title . '" height="12" width="18" />'; $td_str .= '</small></b>'; echo html_tag('td', $td_str, 'right', $hlt_color, 'nowrap'); } else { $stuff = false; $td_str = "<b><small>"; if (isset($aFlags['\\answered']) && $aFlags['\\answered'] == true) { $td_str .= _("A"); $stuff = true; } if ($sType1 == 'mixed') { $td_str .= '+'; $stuff = true; } if ($default_use_priority) { if ($iPrio == 1 || $iPrio == 2) { $td_str .= "<font color=\"{$color['1']}\">!</font>"; $stuff = true; } if ($iPrio == 5) { $td_str .= "<font color=\"{$color['8']}\">?</font>"; $stuff = true; } } if (isset($aFlags['\\deleted']) && $aFlags['\\deleted'] == true) { $td_str .= "<font color=\"{$color['1']}\">D</font>"; $stuff = true; } if (!$stuff) { $td_str .= ' '; } $td_str .= '</small></b>'; echo html_tag('td', $td_str, 'center', $hlt_color, 'nowrap'); } break; case 6: /* size */ echo html_tag('td', $bold . $fontstr . show_readable_size($iSize) . $fontstr_end . $bold_end, 'right', $hlt_color); break; } ++$col; } } /* html for separationlines between rows */ if ($last) { echo '</tr>' . "\n"; } else { echo '</tr>' . "\n" . '<tr><td colspan="' . $col . '" bgcolor="' . $color[0] . '" height="1"></td></tr>' . "\n"; } }
function mob_forget_password($rpcmsg) { global $sourcedir, $db_prefix, $scripturl, $txt; $token = $rpcmsg->getParam(1) ? $rpcmsg->getScalarValParam(1) : ''; $code = $rpcmsg->getParam(2) ? $rpcmsg->getScalarValParam(2) : ''; $_POST['user'] = $rpcmsg->getParam(0) ? $rpcmsg->getScalarValParam(0) : ''; $_POST['user'] = utf8ToAscii($_POST['user']); $_POST = htmltrim__recursive($_POST); $_POST = stripslashes__recursive($_POST); $_POST = htmlspecialchars__recursive($_POST); $_POST = addslashes__recursive($_POST); loadLanguage('Profile'); loadTemplate('Reminder'); //checkSession(); // You must enter a username/email address. if (!isset($_POST['user']) || $_POST['user'] == '') { fatal_lang_error(40, false); } // Find the user! $request = db_query("\n SELECT ID_MEMBER, realName, memberName, emailAddress, is_activated, validation_code, ID_GROUP\n FROM {$db_prefix}members\n WHERE memberName = '{$_POST['user']}'\n LIMIT 1", __FILE__, __LINE__); if (mysql_num_rows($request) == 0) { mysql_free_result($request); $request = db_query("\n SELECT ID_MEMBER, realName, memberName, emailAddress, is_activated, validation_code, ID_GROUP\n FROM {$db_prefix}members\n WHERE emailAddress = '{$_POST['user']}'\n LIMIT 1", __FILE__, __LINE__); if (mysql_num_rows($request) == 0) { fatal_lang_error(40, false); } } $row = mysql_fetch_assoc($request); mysql_free_result($request); // If the user isn't activated/approved, give them some feedback on what to do next. if ($row['is_activated'] != 1) { // Awaiting approval... if (trim($row['validation_code']) == '') { fatal_error($txt['registration_not_approved'] . ' <a href="' . $scripturl . '?action=activate;user='******'user'] . '">' . $txt[662] . '</a>.', false); } else { fatal_error($txt['registration_not_activated'] . ' <a href="' . $scripturl . '?action=activate;user='******'user'] . '">' . $txt[662] . '</a>.', false); } } // You can't get emailed if you have no email address. $row['emailAddress'] = trim($row['emailAddress']); if ($row['emailAddress'] == '') { fatal_error($txt[394]); } // verify Tapatalk Authorization if ($token && $code && $row['ID_GROUP'] != 1) { $ttid = TapatalkSsoVerification($token, $code); if ($ttid && $ttid->result) { $tapatalk_id_email = $ttid->email; if (strtolower($row['emailAddress']) == strtolower($tapatalk_id_email)) { $response = array('result' => new xmlrpcval(true, 'boolean'), 'verified' => new xmlrpcval(true, 'boolean')); return new xmlrpcresp(new xmlrpcval($response, 'struct')); } } } // Randomly generate a new password, with only alpha numeric characters that is a max length of 10 chars. require_once $sourcedir . '/Subs-Members.php'; $password = generateValidationCode(); // Set the password in the database. updateMemberData($row['ID_MEMBER'], array('validation_code' => "'" . substr(md5($password), 0, 10) . "'")); require_once $sourcedir . '/Subs-Post.php'; sendmail($row['emailAddress'], $txt['reminder_subject'], sprintf($txt['sendtopic_dear'], $row['realName']) . "\n\n" . "{$txt['reminder_mail']}:\n\n" . "{$scripturl}?action=reminder;sa=setpassword;u={$row['ID_MEMBER']};code={$password}\n\n" . "{$txt['512']}: {$user_info['ip']}\n\n" . "{$txt['35']}: {$row['memberName']}\n\n" . $txt[130]); $response = array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval(processSubject($txt['reminder_sent']), 'base64')); return new xmlrpcresp(new xmlrpcval($response, 'struct')); }
function mob__get_thread($_topic = null, $post = null, $start = 0, $limit = 20, $per_page = null, $from_new = false) { global $mobdb, $context, $modSettings, $scripturl, $user_info, $memberContext, $user_profile, $board, $topic; // If we are not given the topic ID, we load the start, limit and the topic $topic = $_topic; $position = 0; if (is_null($topic)) { if (is_null($post) || is_null($per_page)) { mob_error('invalid parameters'); } $limit = $per_page; // Get the topic $request = $mobdb->query(' SELECT ID_TOPIC AS id_topic FROM {db_prefix}messages WHERE id_msg = {int:post}', array('post' => $post)); list($topic) = $mobdb->fetch_row($request); $mobdb->free_result($request); // Get the start value $request = $mobdb->query(' SELECT COUNT(*) FROM {db_prefix}messages WHERE id_msg < {int:msg} AND id_topic = {int:topic}', array('topic' => $topic, 'msg' => $post)); list($start) = $mobdb->fetch_row($request); $position = $start; $mobdb->free_result($request); } // Load the topic info $request = $mobdb->query(' SELECT t.ID_TOPIC AS id_topic, t.ID_FIRST_MSG AS id_first_msg, t.ID_LAST_MSG AS id_last_msg, t.ID_MEMBER_STARTED AS id_member_started, ' . ($user_info['is_guest'] ? '0' : 'ln.ID_TOPIC') . ' AS is_notify, t.locked, t.isSticky AS is_sticky, t.numReplies AS replies, t.numViews As views, ' . ($user_info['is_guest'] ? 't.ID_LAST_MSG + 1' : 'IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1') . ' AS new_from, b.id_board, b.name, m.subject FROM {db_prefix}topics AS t INNER JOIN {db_prefix}boards AS b ON (b.ID_BOARD = t.ID_BOARD) INNER JOIN {db_prefix}messages AS m ON (m.ID_MSG = t.ID_FIRST_MSG)' . ($user_info['is_guest'] ? '' : ' LEFT JOIN {db_prefix}log_notify AS ln ON (ln.ID_TOPIC = t.ID_TOPIC AND ln.ID_MEMBER = {int:member}) LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = {int:topic} AND lt.id_member = {int:member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.ID_BOARD AND lmr.id_member = {int:member})') . ' WHERE t.ID_TOPIC = {int:topic} LIMIT 1', array('topic' => $topic, 'member' => $user_info['id'])); if ($mobdb->num_rows($request) == 0) { mob_error('topic not found or out of reach'); } $topicinfo = $mobdb->fetch_assoc(); $mobdb->free_result($request); if ($from_new) { // Get the start value $request = $mobdb->query(' SELECT COUNT(*) FROM {db_prefix}messages WHERE id_msg < {int:msg} AND id_topic = {int:topic}', array('topic' => $topic, 'msg' => $topicinfo['new_from'])); list($start) = $mobdb->fetch_row($request); $mobdb->free_result($request); $position = $start; $limit = $per_page; } // Emulate the permissions $topic = $topicinfo['id_topic']; $board = $topicinfo['id_board']; loadBoard(); loadPermissions(); // Up the views! if (empty($_SESSION['last_read_topic']) || $_SESSION['last_read_topic'] != $id_topic) { $mobdb->query(' UPDATE {db_prefix}topics SET numViews = numViews + 1 WHERE ID_TOPIC = {int:topic}', array('topic' => $topic)); } // If this user is not a guest, mark this topic as read if (!$user_info['is_guest']) { $mobdb->query(' REPLACE INTO {db_prefix}log_topics (id_member, id_topic, id_msg) VALUES ({int:member}, {int:topic}, {int:msg})', array('member' => $user_info['id'], 'topic' => $topic, 'msg' => $modSettings['maxMsgID'])); } // Set the last read topic $_SESSION['last_read_topic'] = $id_topic; // Fix the start $start = max(0, (int) $start - (int) $start % (int) $limit); // Load posts $posts = array(); $id_posts = array(); $id_members = array(); $request = $mobdb->query(' SELECT m.ID_MSG AS id_msg, m.subject, m.body, m.ID_MEMBER AS id_member, m.smileysEnabled AS smileys_enabled, m.posterName AS poster_name, m.posterTime AS poster_time, ID_MSG_MODIFIED < {int:new_from} AS is_read FROM {db_prefix}messages AS m WHERE m.ID_TOPIC = {int:topic} ORDER BY m.ID_MSG ASC LIMIT {int:start}, {int:limit}', array('topic' => $topic, 'start' => $start, 'limit' => $limit, 'new_from' => $topicinfo['new_from'])); while ($row = $mobdb->fetch_assoc($request)) { $posts[] = $row; $id_posts[] = $row['id_msg']; $id_members[] = $row['id_member']; } $mobdb->free_result($request); // Load all the member data and context loadMemberData($id_members); // Load the attachments if we need to $attachments = array(); if (!empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) { $request = $mobdb->query(' SELECT a.ID_ATTACH as id_attach, a.filename, thumb.id_attach AS id_thumb, a.ID_MSG AS id_msg, a.width, a.height FROM {db_prefix}attachments AS a LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = a.id_thumb) WHERE a.ID_MSG IN ({array_int:msg}) AND a.attachmentType = 0', array('msg' => $id_posts)); while ($row = $mobdb->fetch_assoc($request)) { if (empty($attachments[$row['id_msg']])) { $attachments[$row['id_msg']] = array(); } $attachments[$row['id_msg']][] = new xmlrpcval(array('content_type' => new xmlrpcval(!empty($row['width']) && !empty($row['height']) ? 'image' : 'other', 'string'), 'thumbnail_url' => new xmlrpcval(!empty($row['id_thumb']) ? $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $row['id_thumb'] . ';image' : '', 'string'), 'url' => new xmlrpcval($scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $row['id_attach'], 'string')), 'struct'); } $mobdb->free_result($request); } $topic_started = $topicinfo['id_member_started'] == $user_info['id'] && !$user_info['is_guest']; // Load the posts into a proper array foreach ($posts as $k => $post) { loadMemberContext($post['id_member']); $post_attachments = isset($attachments[$post['id_msg']]) ? $attachments[$post['id_msg']] : array(); $member = !empty($memberContext[$post['id_member']]) ? $memberContext[$post['id_member']] : array(); $posts[$k] = new xmlrpcval(array('post_id' => new xmlrpcval($post['id_msg'], 'string'), 'post_title' => new xmlrpcval(processSubject($post['subject']), 'base64'), 'post_content' => new xmlrpcval(processBody($post['body']), 'base64'), 'post_author_id' => new xmlrpcval(!empty($member) ? $member['id'] : 0, 'string'), 'post_author_name' => new xmlrpcval(processUsername(!empty($member) ? $member['name'] : $row['poster_name']), 'base64'), 'is_online' => new xmlrpcval(!empty($member) ? $user_profile[$post['id_member']]['isOnline'] : false, 'boolean'), 'can_edit' => new xmlrpcval((!$topicinfo['locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || allowedTo('modify_replies') && $topic_started || allowedTo('modify_own') && $post['id_member'] == $user_info['id']), 'boolean'), 'icon_url' => new xmlrpcval($member['avatar']['href'], 'string'), 'post_time' => new xmlrpcval(mobiquo_time($post['poster_time']), 'dateTime.iso8601'), 'allow_smileys' => new xmlrpcval($post['smileys_enabled'], 'boolean'), 'attachments' => new xmlrpcval($post_attachments, 'array'), 'can_delete' => new xmlrpcval($post['id_msg'] != $topicinfo['id_first_msg'] && (allowedTo('delete_any') || allowedTo('delete_replies') && $topic_started || allowedTo('delete_own') && $user_info['id'] == $post['id_member']), 'boolean'), 'can_approve' => new xmlrpcval(false, 'boolean'), 'can_stick' => new xmlrpcval(allowedTo('make_sticky'), 'boolean'), 'can_move' => new xmlrpcval($topicinfo['id_first_msg'] != $post['id_msg'] && (allowedTo('move_any') || $topic_started && allowedTo('move_own')), 'boolean'), 'can_ban' => new xmlrpcval(allowedTo('manage_bans'), 'boolean')), 'struct'); } // Return the topic return new xmlrpcresp(new xmlrpcval(array('total_post_num' => new xmlrpcval($topicinfo['replies'] + 1, 'int'), 'forum_id' => new xmlrpcval($topicinfo['id_board'], 'string'), 'forum_name' => new xmlrpcval(processSubject($topicinfo['name']), 'base64'), 'topic_id' => new xmlrpcval($topicinfo['id_topic'], 'string'), 'topic_title' => new xmlrpcval(processSubject($topicinfo['subject']), 'base64'), 'view_number' => new xmlrpcval($topicinfo['views'], 'int'), 'is_subscribed' => new xmlrpcval($topicinfo['is_notify'], 'boolean'), 'can_subscribe' => new xmlrpcval(allowedTo('mark_notify') && !$user_info['is_guest'], 'boolean'), 'is_closed' => new xmlrpcval($topicinfo['locked'], 'boolean'), 'can_reply' => new xmlrpcval(allowedTo('post_reply_any') || allowedTo('post_reply_own') && $topic_started, 'boolean'), 'can_delete' => new xmlrpcval(allowedTo('remove_any') || $topic_started && allowedTo('remove_own'), 'boolean'), 'can_close' => new xmlrpcval(allowedTo('lock_any') || $topic_started && allowedTo('lock_own'), 'boolean'), 'can_approve' => new xmlrpcval(false, 'boolean'), 'can_stick' => new xmlrpcval(allowedTo('make_sticky'), 'boolean'), 'can_move' => new xmlrpcval(allowedTo('move_any') || $topic_started && allowedTo('move_own'), 'boolean'), 'can_rename' => new xmlrpcval(allowedTo('modify_any') || $topic_started && allowedTo('modify_own'), 'boolean'), 'can_ban' => new xmlrpcval(allowedTo('manage_bans'), 'boolean'), 'position' => new xmlrpcval($position, 'int'), 'posts' => new xmlrpcval($posts, 'array')), 'struct')); }
function printMessageInfo($imapConnection, $t, $not_last = true, $key, $mailbox, $start_msg, $where, $what) { global $checkall, $color, $msgs, $msort, $td_str, $msg, $default_use_priority, $message_highlight_list, $index_order, $indent_array, $pos, $thread_sort_messages, $server_sort_order, $row_count, $allow_server_sort; /* enable/disable server-side sorting */ $color_string = $color[4]; if ($GLOBALS['alt_index_colors']) { if (!isset($row_count)) { $row_count = 0; } $row_count++; if ($row_count % 2) { if (!isset($color[12])) { $color[12] = '#EAEAEA'; } $color_string = $color[12]; } } $msg = $msgs[$key]; if ($mailbox == 'None') { $boxes = sqimap_mailbox_list($imapConnection); $mailbox = $boxes[0]['unformatted']; unset($boxes); } $urlMailbox = urlencode($mailbox); if (handleAsSent($mailbox)) { $msg['FROM'] = $msg['TO']; } /* * This is done in case you're looking into Sent folders, * because you can have multiple receivers. */ $senderNames = $msg['FROM']; $senderName = ''; if (sizeof($senderNames)) { foreach ($senderNames as $senderNames_part) { if ($senderName != '') { $senderName .= ', '; } if ($senderNames_part[1]) { $senderName .= decodeHeader($senderNames_part[1]); } else { $senderName .= htmlspecialchars($senderNames_part[0]); } } } $subject_full = decodeHeader($msg['SUBJECT']); $subject = processSubject($subject_full, $indent_array[$msg['ID']]); echo html_tag('tr', '', '', '', 'VALIGN="top"') . "\n"; if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true) { $flag = "<font color=\"{$color['2']}\">"; $flag_end = '</font>'; } else { $flag = ''; $flag_end = ''; } if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false) { $bold = '<b>'; $bold_end = '</b>'; } else { $bold = ''; $bold_end = ''; } if (handleAsSent($mailbox)) { $italic = '<i>'; $italic_end = '</i>'; } else { $italic = ''; $italic_end = ''; } if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) { $fontstr = "<font color=\"{$color['9']}\">"; $fontstr_end = '</font>'; } else { $fontstr = ''; $fontstr_end = ''; } if ($where && $what) { $searchstr = '&where=' . $where . '&what=' . $what; } else { $searchstr = ''; } /** * AAAAH! Make my eyes stop bleeding! * Who wrote this?! */ if (is_array($message_highlight_list) && count($message_highlight_list)) { foreach ($message_highlight_list as $message_highlight_list_part) { if (trim($message_highlight_list_part['value']) != '') { $high_val = strtolower($message_highlight_list_part['value']); $match_type = strtoupper($message_highlight_list_part['match_type']); if ($match_type == 'TO_CC') { foreach ($msg['TO'] as $address) { if (strstr('^^' . strtolower($address[0]), $high_val) || strstr('^^' . strtolower($address[1]), $high_val)) { $hlt_color = $message_highlight_list_part['color']; continue; } } foreach ($msg['CC'] as $address) { if (strstr('^^' . strtolower($address[0]), $high_val) || strstr('^^' . strtolower($address[1]), $high_val)) { $hlt_color = $message_highlight_list_part['color']; continue; } } } else { if (strstr('^^' . strtolower($msg[$match_type]), $high_val)) { $hlt_color = $message_highlight_list_part['color']; continue; } } } } } if (!isset($hlt_color)) { $hlt_color = $color_string; } $checked = $checkall == 1 ? ' CHECKED' : ''; $col = 0; if (sizeof($index_order)) { foreach ($index_order as $index_order_part) { switch ($index_order_part) { case 1: /* checkbox */ echo html_tag('td', "<input type=checkbox name=\"msg[{$t}]\" value=\"" . $msg['ID'] . "\"{$checked}>", 'center', $hlt_color); break; case 2: /* from */ echo html_tag('td', $italic . $bold . $flag . $fontstr . $senderName . $fontstr_end . $flag_end . $bold_end . $italic_end, 'left', $hlt_color); break; case 3: /* date */ $date_string = $msg['DATE_STRING'] . ''; if ($date_string == '') { $date_string = _("Unknown date"); } echo html_tag('td', $bold . $flag . $fontstr . $date_string . $fontstr_end . $flag_end . $bold_end, 'center', $hlt_color, 'nowrap'); break; case 4: /* subject */ $td_str = $bold; if ($thread_sort_messages == 1) { if (isset($indent_array[$msg['ID']])) { $td_str .= str_repeat(" ", $indent_array[$msg['ID']]); } } $td_str .= '<a href="read_body.php?mailbox=' . $urlMailbox . '&passed_id=' . $msg["ID"] . '&startMessage=' . $start_msg . $searchstr . '"'; do_hook("subject_link"); if ($subject != $subject_full) { $title = get_html_translation_table(HTML_SPECIALCHARS); $title = array_flip($title); $title = strtr($subject_full, $title); $title = str_replace('"', "''", $title); $td_str .= " title=\"{$title}\""; } $td_str .= ">{$flag}{$subject}{$flag_end}</a>{$bold_end}"; echo html_tag('td', $td_str, 'left', $hlt_color); break; case 5: /* flags */ $stuff = false; $td_str = "<b><small>"; if (isset($msg['FLAG_ANSWERED']) && $msg['FLAG_ANSWERED'] == true) { $td_str .= _("A"); $stuff = true; } if ($msg['TYPE0'] == 'multipart') { $td_str .= '+'; $stuff = true; } if ($default_use_priority) { if ($msg['PRIORITY'] == 1 || $msg['PRIORITY'] == 2) { $td_str .= "<font color=\"{$color['1']}\">!</font>"; $stuff = true; } if ($msg['PRIORITY'] == 5) { $td_str .= "<font color=\"{$color['8']}\">?</font>"; $stuff = true; } } if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'] == true) { $td_str .= "<font color=\"{$color['1']}\">D</font>"; $stuff = true; } if (!$stuff) { $td_str .= ' '; } do_hook("msg_envelope"); $td_str .= '</small></b>'; echo html_tag('td', $td_str, 'center', $hlt_color, 'nowrap'); break; case 6: /* size */ echo html_tag('td', $bold . $fontstr . show_readable_size($msg['SIZE']) . $fontstr_end . $bold_end, 'right', $hlt_color); break; } ++$col; } } if ($not_last) { echo '</tr>' . "\n" . '<tr><td COLSPAN="' . $col . '" BGCOLOR="' . $color[0] . '" HEIGHT="1"></td></tr>' . "\n"; } else { echo '</tr>' . "\n"; } }
function method_get_quote_pm() { global $context, $mobdb, $user_info, $sourcedir, $txt, $modSettings, $func, $language; if ($user_info['is_guest']) { outputRPCResult(false, $txt[1]); } if (!allowedTo('pm_read')) { outputRPCResult(false, $txt['cannot_pm_read']); } if (!allowedTo('pm_send')) { outputRPCResult(false, $txt['cannot_pm_send']); } require_once $sourcedir . '/PersonalMessage.php'; // Get the message ID if (!isset($context['mob_request']['params'][0])) { outputRPCResult(false, $txt['smf272']); } $id_pm = $context['mob_request']['params'][0][0]; // Load this message... $mobdb->query(' SELECT pm.ID_PM AS id_pm, pm.subject, pm.body, pm.msgtime, pm.ID_MEMBER_FROM AS id_member_from, mem_from.realName FROM {db_prefix}personal_messages AS pm LEFT JOIN {db_prefix}pm_recipients AS pr ON (pm.ID_PM = pr.ID_PM) LEFT JOIN {db_prefix}members AS mem_from ON (mem_from.ID_MEMBER = pm.ID_MEMBER_FROM) WHERE pm.ID_PM = {int:pm} AND (pm.ID_MEMBER_FROM = {int:member} OR pr.ID_MEMBER = {int:member})', array('pm' => $id_pm, 'member' => $user_info['id'])); if ($mobdb->num_rows() == 0) { outputRPCResult(false, $txt['pm_not_yours']); } $pm = $mobdb->fetch_assoc(); $mobdb->free_result(); censorText($pm['subject']); censorText($pm['body']); // Add 'Re: ' to it.... if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) { if ($language === $user_info['language']) { $context['response_prefix'] = $txt['response_prefix']; } else { loadLanguage('index', $language, false); $context['response_prefix'] = $txt['response_prefix']; loadLanguage('index'); } cache_put_data('response_prefix', $context['response_prefix'], 600); } $form_subject = $pm['subject']; if (trim($context['response_prefix']) != '' && $func['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { $form_subject = $context['response_prefix'] . $form_subject; } // Remove any nested quotes and <br />... $form_message = preg_replace('~<br( /)?' . '>~i', "\n", $pm['body']); if (!empty($modSettings['removeNestedQuotes'])) { $form_message = preg_replace(array('~\\n?\\[quote.*?\\].+?\\[/quote\\]\\n?~is', '~^\\n~', '~\\[/quote\\]~'), '', $form_message); } $form_message = processBody($form_message); if (empty($pm['id_member_from'])) { $form_message = '[quote author="' . $pm['realName'] . ""]\n" . $form_message . "\n[/quote]"; } else { $form_message = '[quote author=' . $pm['realName'] . ' link=action=profile;u=' . $pm['id_member_from'] . ' date=' . $pm['msgtime'] . "]\n" . $form_message . "\n[/quote]"; } outputRPCResponse(' <params> <param> <value> <struct> <member> <name>msg_id</name> <value><string>' . $id_pm . '</string></value> </member> <member> <name>msg_subject</name> <value><base64>' . base64_encode(mobi_unescape_html(processSubject($form_subject))) . '</base64></value> </member> <member> <name>text_body</name> <value><base64>' . base64_encode(mobi_unescape_html($form_message)) . '</base64></value> </member> </struct> </value> </param> </params>'); }
function get_topics_xmlrpc($_topics, $use_first = true) { global $user_info; $topics = array(); $permission = array(); $perms = array('mark_notify', 'remove_any', 'remove_own', 'lock_any', 'lock_own', 'make_sticky', 'move_any', 'move_own', 'modify_any', 'modify_own', 'manage_bans'); foreach ($_topics as $topic) { $started = !$user_info['is_guest'] && $user_info['id'] == $topic['first_post']['member']['id']; if ($use_first) { $message = isset($topic['first_post']['preview']) ? $topic['first_post']['preview'] : $topic['first_post']['body']; } else { $message = isset($topic['last_post']['preview']) ? $topic['last_post']['preview'] : $topic['last_post']['body']; } if ($use_first) { if (!is_numeric($topic['first_post']['time']) && isset($topic['first_post']['timestamp'])) { $post_time = mobiquo_time($topic['first_post']['timestamp'], true); } else { $post_time = mobiquo_time($topic['first_post']['time']); } } else { if (!is_numeric($topic['last_post']['time']) && isset($topic['last_post']['timestamp'])) { $post_time = mobiquo_time($topic['last_post']['timestamp'], true); } else { $post_time = mobiquo_time($topic['last_post']['time']); } } $fid = $topic['board']['id']; foreach ($perms as $perm) { if (!isset($permission[$fid][$perm])) { $permission[$fid][$perm] = allowedTo($perm, $fid); } } // Add stuff to the array $topics[] = new xmlrpcval(array('topic_id' => new xmlrpcval($topic['id'], 'string'), 'topic_title' => new xmlrpcval(processSubject($topic['subject']), 'base64'), 'reply_number' => new xmlrpcval($topic['replies'], 'int'), 'view_number' => new xmlrpcval($topic['views'], 'int'), 'topic_author_id' => new xmlrpcval($topic['first_post']['member']['id'], 'string'), 'topic_author_name' => new xmlrpcval(processUsername($topic['first_post']['member']['name']), 'base64'), 'post_author_id' => new xmlrpcval($topic['last_post']['member']['id'], 'string'), 'post_author_name' => new xmlrpcval(processUsername($topic['last_post']['member']['name']), 'base64'), 'forum_id' => new xmlrpcval($topic['board']['id'], 'string'), 'forum_name' => new xmlrpcval(processSubject($topic['board']['name']), 'base64'), 'post_id' => new xmlrpcval($topic['last_post']['id'], 'string'), 'is_subscribed' => new xmlrpcval($topic['is_notify'], 'boolean'), 'can_subscribe' => new xmlrpcval($permission[$fid]['mark_notify'] && !$user_info['is_guest'], 'boolean'), 'is_closed' => new xmlrpcval(isset($topic['locked']) ? $topic['locked'] : $topic['is_locked'], 'boolean'), 'new_post' => new xmlrpcval($topic['new'], 'boolean'), 'short_content' => new xmlrpcval(processShortContent($message), 'base64'), 'post_time' => new xmlrpcval($post_time, 'dateTime.iso8601'), 'last_reply_time' => new xmlrpcval($post_time, 'dateTime.iso8601'), 'icon_url' => new xmlrpcval($use_first ? $topic['first_post']['member']['avatar']['href'] : $topic['last_post']['member']['avatar']['href'], 'string'), 'can_delete' => new xmlrpcval($permission[$fid]['remove_any'] || $started && $permission[$fid]['remove_own'], 'boolean'), 'can_close' => new xmlrpcval($permission[$fid]['lock_any'] || $started && $permission[$fid]['lock_own'], 'boolean'), 'can_approve' => new xmlrpcval(false, 'boolean'), 'can_stick' => new xmlrpcval($permission[$fid]['make_sticky'], 'boolean'), 'can_move' => new xmlrpcval($permission[$fid]['move_any'] || $started && $permission[$fid]['move_own'], 'boolean'), 'can_rename' => new xmlrpcval($permission[$fid]['modify_any'] || $started && $permission[$fid]['modify_own'], 'boolean'), 'can_ban' => new xmlrpcval($permission[$fid]['manage_bans'], 'boolean'), 'is_sticky' => new xmlrpcval($topic['is_sticky'], 'boolean')), 'struct'); } return $topics; }