예제 #1
0
function light_draw_pm_inbox()
{
    $webtag = get_webtag();
    forum_check_webtag_available($webtag);
    $new_count = 0;
    $outbox_count = 0;
    $unread_count = 0;
    $current_folder = PM_FOLDER_INBOX;
    pm_get_message_count($new_count, $outbox_count, $unread_count);
    if (!($folder_names_array = pm_get_folder_names())) {
        $folder_names_array = array(PM_FOLDER_INBOX => gettext("Inbox"), PM_FOLDER_SENT => gettext("Sent Items"), PM_FOLDER_OUTBOX => gettext("Outbox"), PM_FOLDER_SAVED => gettext("Saved Items"), PM_FOLDER_DRAFTS => gettext("Drafts"));
    }
    if (isset($_GET['page']) && is_numeric($_GET['page'])) {
        $page = $_GET['page'] > 0 ? $_GET['page'] : 1;
    } else {
        if (isset($_POST['page']) && is_numeric($_POST['page'])) {
            $page = $_POST['page'] > 0 ? $_POST['page'] : 1;
        } else {
            $page = 1;
        }
    }
    if (isset($_GET['mid']) && is_numeric($_GET['mid'])) {
        $mid = $_GET['mid'] > 0 ? $_GET['mid'] : 0;
    } else {
        if (isset($_POST['mid']) && is_numeric($_POST['mid'])) {
            $mid = $_POST['mid'] > 0 ? $_POST['mid'] : 0;
        } else {
            $mid = null;
        }
    }
    if (isset($_GET['folder'])) {
        if ($_GET['folder'] == PM_FOLDER_INBOX) {
            $current_folder = PM_FOLDER_INBOX;
        } else {
            if ($_GET['folder'] == PM_FOLDER_SENT) {
                $current_folder = PM_FOLDER_SENT;
            } else {
                if ($_GET['folder'] == PM_FOLDER_OUTBOX) {
                    $current_folder = PM_FOLDER_OUTBOX;
                } else {
                    if ($_GET['folder'] == PM_FOLDER_SAVED) {
                        $current_folder = PM_FOLDER_SAVED;
                    } else {
                        if ($_GET['folder'] == PM_FOLDER_DRAFTS) {
                            $current_folder = PM_FOLDER_DRAFTS;
                        } else {
                            if ($_GET['folder'] == PM_SEARCH_RESULTS) {
                                $current_folder = PM_SEARCH_RESULTS;
                            }
                        }
                    }
                }
            }
        }
    } else {
        if (isset($_POST['folder'])) {
            if ($_POST['folder'] == PM_FOLDER_INBOX) {
                $current_folder = PM_FOLDER_INBOX;
            } else {
                if ($_POST['folder'] == PM_FOLDER_SENT) {
                    $current_folder = PM_FOLDER_SENT;
                } else {
                    if ($_POST['folder'] == PM_FOLDER_OUTBOX) {
                        $current_folder = PM_FOLDER_OUTBOX;
                    } else {
                        if ($_POST['folder'] == PM_FOLDER_SAVED) {
                            $current_folder = PM_FOLDER_SAVED;
                        } else {
                            if ($_POST['folder'] == PM_FOLDER_DRAFTS) {
                                $current_folder = PM_FOLDER_DRAFTS;
                            } else {
                                if ($_POST['folder'] == PM_SEARCH_RESULTS) {
                                    $current_folder = PM_SEARCH_RESULTS;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (isset($_GET['delete_msg']) && is_numeric($_GET['delete_msg']) && ($message_data = pm_message_get($_GET['delete_msg']))) {
        $delete_mid = $_GET['delete_msg'];
        $type = pm_get_folder_type($current_folder);
        $message_data['CONTENT'] = pm_get_content($delete_mid);
        if (isset($_POST['pm_delete_confirm'])) {
            if (pm_delete_message($delete_mid)) {
                header_redirect("lpm.php?webtag={$webtag}&folder={$current_folder}&deleted=true");
                exit;
            }
        } else {
            if (isset($_POST['cancel'])) {
                header_redirect("lpm.php?webtag={$webtag}&folder={$current_folder}&mid={$delete_mid}");
                exit;
            }
        }
        echo "<form method=\"post\" action=\"lpm.php?delete_msg={$delete_mid}&folder={$current_folder}\">";
        echo form_csrf_token_field();
        light_pm_display($message_data, true);
        echo "<div class=\"post_buttons\">";
        echo light_form_submit("pm_delete_confirm", gettext("Delete"));
        echo light_form_submit("cancel", gettext("Cancel"));
        echo "</div>\n";
        return;
    }
    if (isset($mid) && is_numeric($mid) && $mid > 0) {
        if (!($message_data = pm_message_get($mid))) {
            light_html_display_error_msg(gettext("Message not found. Check that it hasn't been deleted."));
        } else {
            if (isset($_GET['message_sent'])) {
                light_html_display_success_msg(gettext("Message sent successfully."));
            } else {
                if (isset($_GET['deleted'])) {
                    light_html_display_success_msg(gettext("Successfully deleted selected messages"));
                } else {
                    if (isset($_GET['message_saved'])) {
                        light_html_display_success_msg(gettext("Message was successfully saved to 'Drafts' folder"));
                    }
                }
            }
            $message_data['CONTENT'] = pm_get_content($mid);
            light_pm_display($message_data);
            if ($current_folder == PM_FOLDER_INBOX && $message_data['TYPE'] == PM_UNREAD) {
                pm_mark_as_read($mid);
            }
        }
    } else {
        if (isset($_GET['message_sent'])) {
            light_html_display_success_msg(gettext("Message sent successfully."));
        } else {
            if (isset($_GET['deleted'])) {
                light_html_display_success_msg(gettext("Successfully deleted selected messages"));
            } else {
                if (isset($_GET['message_saved'])) {
                    light_html_display_success_msg(gettext("Message was successfully saved to 'Drafts' folder"));
                }
            }
        }
        $message_count_array = pm_get_folder_message_counts();
        echo "<div id=\"folder_view\">\n";
        echo "<form accept-charset=\"utf-8\" method=\"get\" action=\"lpm.php\">\n";
        echo "<ul>\n";
        echo "<li>", light_form_dropdown_array("folder", $folder_names_array, $current_folder), "</li>\n";
        echo "<li class=\"right_col\">", light_form_submit("go", gettext("Go!")), "</li>\n";
        echo "</ul>\n";
        echo "</form>\n";
        echo "</div>\n";
        if (isset($message_count_array[$current_folder]) && is_numeric($message_count_array[$current_folder])) {
            echo "<div class=\"folder\">";
            echo "  <h3>", html_style_image('folder'), "{$folder_names_array[$current_folder]}</h3>\n";
            echo "  <div class=\"folder_inner\">\n";
            echo "    <div class=\"folder_info\">{$message_count_array[$current_folder]} ", gettext("Messages"), "</div>\n";
            if ($current_folder == PM_FOLDER_INBOX) {
                $messages_array = pm_get_inbox(false, false, $page, 20);
            } else {
                if ($current_folder == PM_FOLDER_SENT) {
                    $messages_array = pm_get_sent(false, false, $page, 20);
                } else {
                    if ($current_folder == PM_FOLDER_OUTBOX) {
                        $messages_array = pm_get_outbox(false, false, $page, 20);
                    } else {
                        if ($current_folder == PM_FOLDER_SAVED) {
                            $messages_array = pm_get_saved_items(false, false, $page, 20);
                        } else {
                            if ($current_folder == PM_FOLDER_DRAFTS) {
                                $messages_array = pm_get_drafts(false, false, $page, 20);
                            }
                        }
                    }
                }
            }
            if (isset($messages_array['message_array']) && sizeof($messages_array['message_array']) > 0) {
                if ($page > 1) {
                    echo "<div class=\"folder_pagination\"><a href=\"lpm.php?webtag={$webtag}&amp;folder={$current_folder}&amp;page=", $page - 1, "\">", gettext("Previous"), "</a></div>\n";
                }
                echo "<ul>\n";
                foreach ($messages_array['message_array'] as $message) {
                    echo "<li>";
                    echo "<span class=\"pm_icon\">";
                    if ($message['TYPE'] == PM_UNREAD) {
                        echo html_style_image('pm_unread');
                    } else {
                        echo html_style_image('pm_read');
                    }
                    echo "</span><span class=\"pm_title\">";
                    echo "<a href=\"lpm.php?webtag={$webtag}&amp;folder={$current_folder}&amp;mid={$message['MID']}\">{$message['SUBJECT']}</a>";
                    echo "</span>";
                    echo "<span class=\"pm_time\">", format_date_time($message['CREATED']), "</span>";
                    echo "</li>\n";
                }
                echo "</ul>\n";
                $more_messages = $message_count_array[$current_folder] - $page - 1;
                if ($more_messages > 0) {
                    echo "<div class=\"folder_pagination\"><a href=\"lpm.php?webtag={$webtag}&amp;folder={$current_folder}&amp;page=", $page + 1, "\">", gettext("Next"), "</a></div>\n";
                }
            }
            echo "  </div>\n";
            echo "</div>\n";
        }
        $free_space = pm_get_free_space($_SESSION['UID']);
        $max_user_messages = forum_get_setting('pm_max_user_messages', null, 100);
        $used_percent = 100 / $max_user_messages * ($max_user_messages - $free_space);
        echo "<div class=\"pm_bar\">\n";
        echo "<div class=\"pm_bar_inner\" style=\"width: {$used_percent}%\"></div>\n";
        echo "</div>\n";
        echo "<div class=\"pm_folder_usage\">", sprintf(gettext("Your PM folders are %s full"), "{$used_percent}%"), "</div>\n";
        if (pm_auto_prune_enabled()) {
            light_html_display_warning_msg(gettext("PM Folder pruning is enabled!"));
        }
    }
}
예제 #2
0
        }
    }
}
pm_user_prune_folders();
html_draw_top(sprintf('title=%s', sprintf(gettext("Private Messages = %s"), $pm_folder_names_array[$current_folder])), "basetarget=_blank", "search.js", "pm.js", 'pm_popup_disabled', 'class=window_title');
if ($current_folder == PM_FOLDER_INBOX) {
    $pm_messages_array = pm_get_inbox($sort_by, $sort_dir, $page, 10);
} else {
    if ($current_folder == PM_FOLDER_SENT) {
        $pm_messages_array = pm_get_sent($sort_by, $sort_dir, $page, 10);
    } else {
        if ($current_folder == PM_FOLDER_OUTBOX) {
            $pm_messages_array = pm_get_outbox($sort_by, $sort_dir, $page, 10);
        } else {
            if ($current_folder == PM_FOLDER_SAVED) {
                $pm_messages_array = pm_get_saved_items($sort_by, $sort_dir, $page, 10);
            } else {
                if ($current_folder == PM_FOLDER_DRAFTS) {
                    $pm_messages_array = pm_get_drafts($sort_by, $sort_dir, $page, 10);
                } else {
                    if ($current_folder == PM_SEARCH_RESULTS) {
                        $pm_messages_array = pm_fetch_search_results($sort_by, $sort_dir, $page, 10);
                    }
                }
            }
        }
    }
}
echo "<h1>", gettext("Private Messages"), "<img src=\"", html_style_image('separator.png'), "\" alt=\"\" border=\"0\" />{$pm_folder_names_array[$current_folder]}</h1>\n";
if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
    html_display_error_array($error_msg_array, '96%', 'center');
예제 #3
0
function light_draw_pm_inbox()
{
    $webtag = get_webtag();
    // Default values
    $pm_new_count = 0;
    $pm_outbox_count = 0;
    $pm_unread_count = 0;
    // Check for new PMs
    pm_get_message_count($pm_new_count, $pm_outbox_count, $pm_unread_count);
    if (!($pm_folder_names_array = pm_get_folder_names())) {
        $pm_folder_names_array = array(PM_FOLDER_INBOX => gettext("Inbox"), PM_FOLDER_SENT => gettext("Sent Items"), PM_FOLDER_OUTBOX => gettext("Outbox"), PM_FOLDER_SAVED => gettext("Saved Items"), PM_FOLDER_DRAFTS => gettext("Drafts"));
    }
    // Check to see which page we should be on
    if (isset($_GET['page']) && is_numeric($_GET['page'])) {
        $page = $_GET['page'];
    } else {
        if (isset($_POST['page']) && is_numeric($_POST['page'])) {
            $page = $_POST['page'];
        } else {
            $page = 1;
        }
    }
    if (isset($_GET['mid']) && is_numeric($_GET['mid'])) {
        $mid = $_GET['mid'] > 0 ? $_GET['mid'] : 0;
    } else {
        if (isset($_GET['pmid']) && is_numeric($_GET['pmid'])) {
            $mid = $_GET['pmid'] > 0 ? $_GET['pmid'] : 0;
        } else {
            if (isset($_POST['mid']) && is_numeric($_POST['mid'])) {
                $mid = $_POST['mid'] > 0 ? $_POST['mid'] : 0;
            }
        }
    }
    $folder = PM_FOLDER_INBOX;
    if (isset($_GET['folder'])) {
        if ($_GET['folder'] == PM_FOLDER_INBOX) {
            $folder = PM_FOLDER_INBOX;
        } else {
            if ($_GET['folder'] == PM_FOLDER_SENT) {
                $folder = PM_FOLDER_SENT;
            } else {
                if ($_GET['folder'] == PM_FOLDER_OUTBOX) {
                    $folder = PM_FOLDER_OUTBOX;
                } else {
                    if ($_GET['folder'] == PM_FOLDER_SAVED) {
                        $folder = PM_FOLDER_SAVED;
                    } else {
                        if ($_GET['folder'] == PM_FOLDER_DRAFTS) {
                            $folder = PM_FOLDER_DRAFTS;
                        }
                    }
                }
            }
        }
    } else {
        if (isset($_POST['folder'])) {
            if ($_POST['folder'] == PM_FOLDER_INBOX) {
                $folder = PM_FOLDER_INBOX;
            } else {
                if ($_POST['folder'] == PM_FOLDER_SENT) {
                    $folder = PM_FOLDER_SENT;
                } else {
                    if ($_POST['folder'] == PM_FOLDER_OUTBOX) {
                        $folder = PM_FOLDER_OUTBOX;
                    } else {
                        if ($_POST['folder'] == PM_FOLDER_SAVED) {
                            $folder = PM_FOLDER_SAVED;
                        } else {
                            if ($_POST['folder'] == PM_FOLDER_DRAFTS) {
                                $folder = PM_FOLDER_DRAFTS;
                            }
                        }
                    }
                }
            }
        }
    }
    if (isset($_GET['deletemsg']) && is_numeric($_GET['deletemsg']) && ($pm_message_array = pm_message_get($_GET['deletemsg']))) {
        $delete_mid = $_GET['deletemsg'];
        $pm_message_array['CONTENT'] = pm_get_content($delete_mid);
        if (isset($_POST['pm_delete_confirm'])) {
            if (pm_delete_message($delete_mid)) {
                header_redirect("lpm.php?webtag={$webtag}&folder={$folder}&deleted=true");
                exit;
            }
        } else {
            if (isset($_POST['cancel'])) {
                header_redirect("lpm.php?webtag={$webtag}&folder={$folder}&mid={$delete_mid}");
                exit;
            }
        }
        echo "<form method=\"post\" action=\"lpm.php?deletemsg={$delete_mid}&folder={$folder}\">";
        light_pm_display($pm_message_array, $folder, true);
        echo "<div class=\"post_buttons\">";
        echo light_form_submit("pm_delete_confirm", gettext("Delete"));
        echo light_form_submit("cancel", gettext("Cancel"));
        echo "</div>\n";
        return;
    }
    if (isset($mid) && is_numeric($mid)) {
        if (!($folder = pm_message_get_folder($mid))) {
            light_html_display_error_msg(gettext("Message not found in selected folder. Check that it hasn't been moved or deleted."));
            return;
        }
        if (!($pm_message_array = pm_message_get($mid))) {
            light_html_display_error_msg(gettext("Message not found. Check that it hasn't been deleted."));
            return;
        }
        if (isset($_GET['message_sent'])) {
            light_html_display_success_msg(gettext("Message sent successfully."));
        } else {
            if (isset($_GET['deleted'])) {
                light_html_display_success_msg(gettext("Successfully deleted selected messages"));
            } else {
                if (isset($_GET['message_saved'])) {
                    light_html_display_success_msg(gettext("Message was successfully saved to 'Drafts' folder"));
                }
            }
        }
        $pm_message_array['CONTENT'] = pm_get_content($mid);
        light_pm_display($pm_message_array, $folder);
        echo "<a href=\"lpm.php?webtag={$webtag}&amp;folder={$folder}\" class=\"folder_list_link\">", gettext("Back to folder list"), "</a>";
    } else {
        if (isset($_GET['message_sent'])) {
            light_html_display_success_msg(gettext("Message sent successfully."));
        } else {
            if (isset($_GET['deleted'])) {
                light_html_display_success_msg(gettext("Successfully deleted selected messages"));
            } else {
                if (isset($_GET['message_saved'])) {
                    light_html_display_success_msg(gettext("Message was successfully saved to 'Drafts' folder"));
                }
            }
        }
        $pm_message_count_array = pm_get_folder_message_counts();
        echo "<div id=\"folder_view\">\n";
        echo "<form accept-charset=\"utf-8\" method=\"get\" action=\"lpm.php\">\n";
        echo "<ul>\n";
        echo "<li>", light_form_dropdown_array("folder", $pm_folder_names_array, $folder), "</li>\n";
        echo "<li class=\"right_col\">", light_form_submit("go", gettext("Go!")), "</li>\n";
        echo "</ul>\n";
        echo "</form>\n";
        echo "</div>\n";
        if (isset($pm_message_count_array[$folder]) && is_numeric($pm_message_count_array[$folder])) {
            echo "<div class=\"folder\">";
            echo "  <h3>{$pm_folder_names_array[$folder]}</h3>\n";
            echo "  <div class=\"folder_inner\">\n";
            echo "    <div class=\"folder_info\">{$pm_message_count_array[$folder]} ", gettext("Messages"), "</div>\n";
            if ($folder == PM_FOLDER_INBOX) {
                $pm_messages_array = pm_get_inbox(false, false, $page, 20);
            } else {
                if ($folder == PM_FOLDER_SENT) {
                    $pm_messages_array = pm_get_sent(false, false, $page, 20);
                } else {
                    if ($folder == PM_FOLDER_OUTBOX) {
                        $pm_messages_array = pm_get_outbox(false, false, $page, 20);
                    } else {
                        if ($folder == PM_FOLDER_SAVED) {
                            $pm_messages_array = pm_get_saved_items(false, false, $page, 20);
                        } else {
                            if ($folder == PM_FOLDER_DRAFTS) {
                                $pm_messages_array = pm_get_drafts(false, false, $page, 20);
                            }
                        }
                    }
                }
            }
            if (isset($pm_messages_array['message_array']) && sizeof($pm_messages_array['message_array']) > 0) {
                if ($page > 1) {
                    echo "<div class=\"folder_pagination\"><a href=\"lpm.php?webtag={$webtag}&amp;folder={$folder}&amp;page=", $page - 1, "\">", gettext("Previous"), "</a></div>\n";
                }
                echo "<ul>\n";
                foreach ($pm_messages_array['message_array'] as $message) {
                    if ($message['TYPE'] == PM_UNREAD) {
                        echo "<li class=\"pm_unread\">";
                    } else {
                        echo "<li class=\"pm_read\">";
                    }
                    echo "<span class=\"pm_title\">";
                    echo "<a href=\"lpm.php?webtag={$webtag}&amp;folder={$folder}&amp;mid={$message['MID']}\">{$message['SUBJECT']}</a>";
                    echo "</span>";
                    echo "<span class=\"pm_time\">", format_time($message['CREATED']), "</span>";
                    echo "</li>\n";
                }
                echo "</ul>\n";
                $more_messages = $pm_message_count_array[$folder] - $page - 1;
                if ($more_messages > 0) {
                    echo "<div class=\"folder_pagination\"><a href=\"lpm.php?webtag={$webtag}&amp;folder={$folder}&amp;page=", $page + 1, "\">", gettext("Next"), "</a></div>\n";
                }
            }
            echo "  </div>\n";
            echo "</div>\n";
        }
        echo "<a href=\"lpm_write.php?webtag={$webtag}\" class=\"pm_send_new\">", gettext("Send New PM"), "</a>\n";
        // Fetch the free PM space and calculate it as a percentage.
        $pm_free_space = pm_get_free_space();
        $pm_max_user_messages = forum_get_setting('pm_max_user_messages', null, 100);
        $pm_used_percent = 100 / $pm_max_user_messages * ($pm_max_user_messages - $pm_free_space);
        echo "<div class=\"pm_bar\">\n";
        echo "<div class=\"pm_bar_inner\" style=\"width: {$pm_used_percent}%\"></div>\n";
        echo "</div>\n";
        echo "<div class=\"pm_folder_usage\">", sprintf(gettext("Your PM folders are %s full"), "{$pm_used_percent}%"), "</div>\n";
        if (pm_auto_prune_enabled()) {
            light_html_display_warning_msg(gettext("PM Folder pruning is enabled!"));
        }
    }
}
예제 #4
0
function pm_export_folders($pm_folders_array, $options_array)
{
    if (!is_array($pm_folders_array)) {
        return false;
    }
    if (!is_array($options_array)) {
        return false;
    }
    $zip = new ZipArchive();
    $zip_filename = tempnam(sys_get_temp_dir(), 'bhpe');
    if (!$zip->open($zip_filename, ZipArchive::CREATE)) {
        return false;
    }
    $messages_array = array();
    $pm_message_count_array = pm_get_folder_message_counts(false);
    foreach ($pm_folders_array as $folder) {
        $folder_messages_array = array();
        switch ($folder) {
            case PM_FOLDER_INBOX:
                $folder_messages_array = pm_get_inbox('CREATED', 'ASC', 1, $pm_message_count_array[PM_FOLDER_INBOX]);
                break;
            case PM_FOLDER_SENT:
                $folder_messages_array = pm_get_sent('CREATED', 'ASC', 1, $pm_message_count_array[PM_FOLDER_SENT]);
                break;
            case PM_FOLDER_OUTBOX:
                $folder_messages_array = pm_get_outbox('CREATED', 'ASC', 1, $pm_message_count_array[PM_FOLDER_OUTBOX]);
                break;
            case PM_FOLDER_SAVED:
                $folder_messages_array = pm_get_saved_items('CREATED', 'ASC', 1, $pm_message_count_array[PM_FOLDER_SAVED]);
                break;
            case PM_FOLDER_DRAFTS:
                $folder_messages_array = pm_get_drafts('CREATED', 'ASC', 1, $pm_message_count_array[PM_FOLDER_DRAFTS]);
                break;
        }
        if (sizeof($folder_messages_array) > 0) {
            $messages_array = array_merge($messages_array, $folder_messages_array['message_array']);
        }
    }
    pm_export_messages($messages_array, $zip, $options_array);
    $zip->close();
    $file_size = filesize($zip_filename);
    while (@ob_end_clean()) {
    }
    header("Content-Length: {$file_size}");
    header("Content-Type: application/zip");
    header("Content-Disposition: attachment; filename=\"pm_backup_{$_SESSION['LOGON']}.zip\"");
    readfile($zip_filename);
    exit;
}
예제 #5
0
function pm_export_folders($pm_folders_array, $options_array)
{
    if (!is_array($pm_folders_array)) {
        return false;
    }
    if (!is_array($options_array)) {
        return false;
    }
    $messages_array = array();
    foreach ($pm_folders_array as $folder) {
        $folder_messages_array = array();
        switch ($folder) {
            case PM_FOLDER_INBOX:
                $folder_messages_array = pm_get_inbox();
                break;
            case PM_FOLDER_SENT:
                $folder_messages_array = pm_get_sent();
                break;
            case PM_FOLDER_OUTBOX:
                $folder_messages_array = pm_get_outbox();
                break;
            case PM_FOLDER_SAVED:
                $folder_messages_array = pm_get_saved_items();
                break;
            case PM_FOLDER_DRAFTS:
                $folder_messages_array = pm_get_drafts();
                break;
        }
        if (sizeof($folder_messages_array) > 0) {
            $messages_array = array_merge($messages_array, array_keys($folder_messages_array['message_array']));
        }
    }
    if (!pm_export_messages($messages_array, $options_array)) {
        return false;
    }
    return true;
}