示例#1
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;
}
示例#2
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;
}