📄 ucp_pm_viewfolder.php
字号:
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE t.user_id = ' . $user->data['user_id'] . " AND p.author_id = u.user_id AND t.folder_id = $folder_id AND t.msg_id = p.msg_id AND p.msg_id = $message_id"; $result = $db->sql_query_limit($sql, 1); $message_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $_types = array('u', 'g'); foreach ($_types as $ug_type) { if (isset($address[$message_id][$ug_type]) && sizeof($address[$message_id][$ug_type])) { if ($ug_type == 'u') { $sql = 'SELECT user_id as id, username as name FROM ' . USERS_TABLE . ' WHERE '; } else { $sql = 'SELECT group_id as id, group_name as name FROM ' . GROUPS_TABLE . ' WHERE '; } $sql .= $db->sql_in_set(($ug_type == 'u') ? 'user_id' : 'group_id', array_map('intval', array_keys($address[$message_id][$ug_type]))); $result = $db->sql_query($sql); while ($info_row = $db->sql_fetchrow($result)) { $address[$message_id][$ug_type][$address[$message_id][$ug_type][$info_row['id']]][] = $info_row['name']; unset($address[$message_id][$ug_type][$info_row['id']]); } $db->sql_freeresult($result); } } decode_message($message_row['message_text'], $message_row['bbcode_uid']); $data[] = array( 'subject' => censor_text($row['message_subject']), 'sender' => $row['username'], 'date' => $user->format_date($row['message_time']), 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? $address[$message_id] : '', 'message' => $message_row['message_text'] ); } switch ($export_type) { case 'CSV': case 'CSV_EXCEL': $mimetype = 'text/csv'; $filetype = 'csv'; if ($export_type == 'CSV_EXCEL') { $enclosure = '"'; $delimiter = ','; $newline = "\r\n"; } else { $newline = "\n"; } $string = ''; foreach ($data as $value) { $recipients = $value['to']; $value['to'] = $value['bcc'] = ''; if (is_array($recipients)) { foreach ($recipients as $values) { $value['bcc'] .= (isset($values['bcc']) && is_array($values['bcc'])) ? ',' . implode(',', $values['bcc']) : ''; $value['to'] .= (isset($values['to']) && is_array($values['to'])) ? ',' . implode(',', $values['to']) : ''; } // Remove the commas which will appear before the first entry. $value['to'] = substr($value['to'], 1); $value['bcc'] = substr($value['bcc'], 1); } foreach ($value as $tag => $text) { $cell = str_replace($enclosure, $enclosure . $enclosure, $text); if (strpos($cell, $enclosure) !== false || strpos($cell, $delimiter) !== false || strpos($cell, $newline) !== false) { $string .= $enclosure . $text . $enclosure . $delimiter; } else { $string .= $cell . $delimiter; } } $string = substr($string, 0, -1) . $newline; } break; case 'XML': $mimetype = 'application/xml'; $filetype = 'xml'; $string = '<?xml version="1.0"?>' . "\n"; $string .= "<phpbb>\n"; foreach ($data as $value) { $string .= "\t<privmsg>\n"; if (is_array($value['to'])) { foreach ($value['to'] as $key => $values) { foreach ($values as $type => $types) { foreach ($types as $name) { $string .= "\t\t<recipient type=\"$type\" status=\"$key\">$name</recipient>\n"; } } } } unset($value['to']); foreach ($value as $tag => $text) { $string .= "\t\t<$tag>$text</$tag>\n"; } $string .= "\t</privmsg>\n"; } $string .= '</phpbb>'; break; } header('Pragma: no-cache'); header("Content-Type: $mimetype; name=\"data.$filetype\""); header("Content-disposition: attachment; filename=data.$filetype"); echo $string; exit; } }}/*** Get Messages from folder/user*/function get_pm_from($folder_id, $folder, $user_id){ global $user, $db, $template, $config, $auth, $phpbb_root_path, $phpEx; $start = request_var('start', 0); // Additional vars later, pm ordering is mostly different from post ordering. :/ $sort_days = request_var('st', 0); $sort_key = request_var('sk', 't'); $sort_dir = request_var('sd', 'd'); // PM ordering options $limit_days = array(0 => $user->lang['ALL_MESSAGES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); $sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.message_time', 's' => 'p.message_subject'); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); $folder_sql = 't.folder_id = ' . (int) $folder_id; // Limit pms to certain time frame, obtain correct pm count if ($sort_days) { $min_post_time = time() - ($sort_days * 86400); if (isset($_POST['sort'])) { $start = 0; } $sql = 'SELECT COUNT(t.msg_id) AS pm_count FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . " p WHERE $folder_sql AND t.user_id = $user_id AND t.msg_id = p.msg_id AND p.message_time >= $min_post_time"; $result = $db->sql_query_limit($sql, 1); $pm_count = (int) $db->sql_fetchfield('pm_count'); $db->sql_freeresult($result); $sql_limit_time = "AND p.message_time >= $min_post_time"; } else { $pm_count = $folder[$folder_id]['num_messages']; $sql_limit_time = ''; } $template->assign_vars(array( 'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id&$u_sort_param"), $pm_count, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($pm_count, $config['topics_per_page'], $start), 'TOTAL_MESSAGES' => (($pm_count == 1) ? $user->lang['VIEW_PM_MESSAGE'] : sprintf($user->lang['VIEW_PM_MESSAGES'], $pm_count)), 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'PM_LOCKED') : $user->img('button_pm_new', 'POST_PM'), 'L_NO_MESSAGES' => (!$auth->acl_get('u_sendpm')) ? $user->lang['POST_PM_LOCKED'] : $user->lang['NO_MESSAGES'], 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_TOPIC_ICONS' => ($config['enable_pm_icons']) ? true : false, 'U_POST_NEW_TOPIC' => ($auth->acl_get('u_sendpm')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose') : '', 'S_PM_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id")) ); // Grab all pm data $rowset = $pm_list = array(); // If the user is trying to reach late pages, start searching from the end $store_reverse = false; $sql_limit = $config['topics_per_page']; if ($start > $pm_count / 2) { $store_reverse = true; if ($start + $config['topics_per_page'] > $pm_count) { $sql_limit = min($config['topics_per_page'], max(1, $pm_count - $start)); } // Select the sort order $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC'); $sql_start = max(0, $pm_count - $sql_limit - $start); } else { // Select the sort order $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); $sql_start = $start; } $sql = 'SELECT t.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.user_colour FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u WHERE t.user_id = $user_id AND p.author_id = u.user_id AND $folder_sql AND t.msg_id = p.msg_id $sql_limit_time ORDER BY $sql_sort_order"; $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); while ($row = $db->sql_fetchrow($result)) { $rowset[$row['msg_id']] = $row; $pm_list[] = $row['msg_id']; } $db->sql_freeresult($result); $pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list; return array( 'pm_count' => $pm_count, 'pm_list' => $pm_list, 'rowset' => $rowset );}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -