Exemplo n.º 1
0
            if (isset($_POST['t_to_uid']) && is_numeric($_POST['t_to_uid'])) {
                $t_to_uid = $_POST['t_to_uid'];
            } else {
                $t_to_uid = 0;
            }
            $page_prefs = (double) $page_prefs ^ POST_EMOTICONS_DISPLAY;
            $user_prefs = array('POST_PAGE' => $page_prefs);
            if (!user_update_prefs($_SESSION['UID'], $user_prefs)) {
                $error_msg_array[] = gettext("Some or all of your user account details could not be updated. Please try again later.");
                $valid = false;
            }
        } else {
            if (!isset($message_data['EDITABLE']) || $message_data['EDITABLE'] == 0) {
                pm_edit_refuse();
            }
            $parsed_message = new MessageTextParse(pm_get_content($mid));
            $t_content = $parsed_message->getMessage();
            $t_subject = $message_data['SUBJECT'];
        }
    }
}
light_html_draw_top(array('title' => gettext('Edit Message'), 'js' => array('js/fineuploader.min.js')));
light_navigation_bar(array('back' => "lpm.php?webtag={$webtag}&mid={$mid}"));
if ($valid && isset($_POST['preview'])) {
    echo "<h3>", gettext("Message Preview"), "</h3>\n";
    light_pm_display($message_data, true);
}
echo "<form accept-charset=\"utf-8\" name=\"f_post\" action=\"lpm_edit.php\" method=\"post\" target=\"_self\">\n";
echo "  ", form_csrf_token_field(), "\n";
echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
echo "  ", form_input_hidden('mid', htmlentities_array($mid)), "\n";
Exemplo n.º 2
0
         $t_subject = preg_replace('/^(RE:)?/iu', 'RE:', $pm_data['SUBJECT']);
     } else {
         light_pm_error_refuse();
     }
 } else {
     if (isset($t_forward_mid) && is_numeric($t_forward_mid) && $t_forward_mid > 0) {
         if ($pm_data = pm_message_get($t_forward_mid)) {
             $pm_data['CONTENT'] = pm_get_content($t_forward_mid);
             $t_subject = preg_replace('/^(FWD:)?/iu', 'FWD:', $pm_data['SUBJECT']);
         } else {
             light_pm_error_refuse();
         }
     } else {
         if (isset($t_edit_mid) && is_numeric($t_edit_mid) && $t_edit_mid > 0) {
             if ($pm_data = pm_message_get($t_edit_mid)) {
                 $pm_data['CONTENT'] = pm_get_content($t_edit_mid);
                 $t_subject = $pm_data['SUBJECT'];
                 $parsed_message = new MessageTextParse($pm_data['CONTENT']);
                 $t_content = $parsed_message->getMessage();
                 $t_subject = $pm_data['SUBJECT'];
                 $t_to_uid = $pm_data['TO_UID'];
                 $t_to_uid_others = $pm_data['RECIPIENTS'];
                 if (strlen($t_to_uid_others) > 0) {
                     $to_radio = 'others';
                 } else {
                     if ($t_to_uid > 0) {
                         $to_radio = 'friends';
                     }
                 }
                 $aid = $pm_data['AID'];
             } else {
Exemplo n.º 3
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!"));
        }
    }
}
Exemplo n.º 4
0
    echo "      <td align=\"right\" width=\"33%\" valign=\"top\" style=\"white-space: nowrap\">";
    if ($current_folder != PM_FOLDER_SAVED && $current_folder != PM_FOLDER_OUTBOX) {
        echo form_submit('pm_save_messages', gettext("Save"), sprintf('title="%s"', gettext("Save Selected Messages"))), "&nbsp;";
    }
    echo form_submit('pm_delete_messages', gettext("Delete")), "&nbsp;";
    echo "</span></td>\n";
} else {
    echo "      <td align=\"left\">&nbsp;</td>\n";
}
echo "    </tr>\n";
echo "    <tr>\n";
echo "      <td align=\"left\">&nbsp;</td>\n";
echo "    </tr>\n";
echo "  </table>\n";
if (isset($pm_message_array) && is_array($pm_message_array)) {
    $pm_message_array['CONTENT'] = pm_get_content($mid);
    echo "  <a name=\"message\"></a>\n";
    echo "  <br />\n";
    echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"96%\">\n";
    echo "    <tr>\n";
    echo "      <td>\n";
    echo "        <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
    echo "          <tr>\n";
    echo "            <td align=\"left\">", pm_display($pm_message_array, $message_folder), "</td>\n";
    echo "          </tr>\n";
    echo "        </table>\n";
    echo "      </td>\n";
    echo "    </tr>\n";
    echo "  </table>\n";
}
echo "</form>\n";
Exemplo n.º 5
0
    echo "      <td align=\"right\" width=\"33%\" valign=\"top\" style=\"white-space: nowrap\">";
    if ($current_folder == PM_FOLDER_INBOX || $current_folder == PM_FOLDER_SENT) {
        echo form_submit('pm_save_messages', gettext("Save"), sprintf('title="%s"', gettext("Save Selected Messages"))), "&nbsp;";
    }
    echo form_submit('pm_delete_messages', gettext("Delete")), "&nbsp;";
    echo "</span></td>\n";
} else {
    echo "      <td align=\"left\">&nbsp;</td>\n";
}
echo "    </tr>\n";
echo "    <tr>\n";
echo "      <td align=\"left\">&nbsp;</td>\n";
echo "    </tr>\n";
echo "  </table>\n";
if (isset($message_data) && is_array($message_data)) {
    $message_data['CONTENT'] = pm_get_content($mid);
    if ($current_folder == PM_FOLDER_INBOX && $message_data['TYPE'] == PM_UNREAD) {
        pm_mark_as_read($mid);
    }
    echo "  <a name=\"message\"></a>\n";
    echo "  <br />\n";
    echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"96%\">\n";
    echo "    <tr>\n";
    echo "      <td>\n";
    echo "        <table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
    echo "          <tr>\n";
    echo "            <td align=\"left\">";
    pm_display($message_data);
    echo "            </td>\n";
    echo "          </tr>\n";
    echo "        </table>\n";
Exemplo n.º 6
0
function pm_export_xml($message_array, ZipArchive $zip, $options_array = array())
{
    if (!is_array($message_array)) {
        return false;
    }
    if (!is_array($options_array)) {
        $options_array = array();
    }
    if (!isset($options_array['PM_EXPORT_FILE'])) {
        if (isset($_SESSION['PM_EXPORT_FILE']) && in_array($_SESSION['PM_EXPORT_FILE'], array(PM_EXPORT_SINGLE, PM_EXPORT_MANY))) {
            $options_array['PM_EXPORT_FILE'] = $_SESSION['PM_EXPORT_FILE'];
        } else {
            $options_array['PM_EXPORT_FILE'] = PM_EXPORT_HTML;
        }
    }
    if (!isset($options_array['PM_EXPORT_WORDFILTER'])) {
        if (isset($_SESSION['PM_EXPORT_WORDFILTER']) && in_array($_SESSION['PM_EXPORT_WORDFILTER'], array('Y', 'N'))) {
            $options_array['PM_EXPORT_WORDFILTER'] = $_SESSION['PM_EXPORT_WORDFILTER'];
        } else {
            $options_array['PM_EXPORT_WORDFILTER'] = 'Y';
        }
    }
    if (sizeof($message_array) == 0) {
        return false;
    }
    $root_xml = new SimpleXMLElement('<beehiveforum>');
    $messages_xml = $root_xml->addChild('messages');
    foreach ($message_array as $message) {
        $message['CONTENT'] = pm_get_content($message['MID']);
        if ($options_array['PM_EXPORT_WORDFILTER'] == 'Y') {
            $message = array_map('pm_export_word_filter_apply', $message);
        }
        $message_xml = $messages_xml->addChild('message');
        $message_xml->addChild('mid', $message['CREATED']);
        $message_xml->addChild('reply_to_mid', $message['REPLY_TO_MID']);
        $message_xml->addChild('subject', $message['SUBJECT']);
        $message_xml->addChild('created', $message['CREATED']);
        $content_xml = dom_import_simplexml($message_xml);
        $content_xml->appendChild($content_xml->ownerDocument->createCDATASection($message['CONTENT']));
        $from_xml = $message_xml->addChild('from');
        $from_xml->addChild('uid', $message['FROM_UID']);
        $from_xml->addChild('logon', $message['FROM_LOGON']);
        $recipients_xml = $message_xml->addChild('recipients');
        if (isset($message['RECIPIENTS']) && sizeof($message['RECIPIENTS']) > 0) {
            foreach ($message['RECIPIENTS'] as $recipient) {
                $recipient_xml = $recipients_xml->addChild('recipient');
                $recipient_xml->addChild('uid', $recipient['UID']);
                $recipient_xml->addChild('logon', $recipient['LOGON']);
            }
        }
        if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_MANY) {
            $zip->addFromString(sprintf("message_%s.xml", $message['MID']), $root_xml->asXML());
            $root_xml = new SimpleXMLElement('<beehiveforum>');
            $messages_xml = $root_xml->addChild('messages');
        }
    }
    if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_SINGLE) {
        $zip->addFromString("messages.xml", $root_xml->asXML());
    }
    return true;
}
Exemplo n.º 7
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!"));
        }
    }
}
Exemplo n.º 8
0
function pm_export_csv($messages_array, &$zip_file, $options_array = array())
{
    if (!is_array($messages_array)) {
        return false;
    }
    if (!is_object($zip_file)) {
        return false;
    }
    if (!is_array($options_array)) {
        $options_array = array();
    }
    if (!isset($options_array['PM_EXPORT_FILE'])) {
        $options_array['PM_EXPORT_FILE'] = session::get_value('PM_EXPORT_FILE');
    }
    if (!isset($options_array['PM_EXPORT_ATTACHMENTS'])) {
        $options_array['PM_EXPORT_ATTACHMENTS'] = session::get_value('PM_EXPORT_ATTACHMENTS');
    }
    if (!isset($options_array['PM_EXPORT_WORDFILTER'])) {
        $options_array['PM_EXPORT_WORDFILTER'] = session::get_value('PM_EXPORT_WORDFILTER');
    }
    if (sizeof($messages_array) == 0) {
        return false;
    }
    $pm_csv_export = fopen('php://temp', 'w');
    $pm_csv_header = array('MID', 'TYPE', 'FROM_UID', 'TO_UID', 'SUBJECT', 'RECIPIENTS', 'CREATED', 'FLOGON', 'TLOGON', 'FNICK', 'TNICK', 'FOLDER', 'CONTENT');
    if (!fputcsv($pm_csv_export, $pm_csv_header)) {
        return false;
    }
    foreach ($messages_array as $mid) {
        if (!($message = pm_message_get($mid))) {
            return false;
        }
        if (isset($message['AID']) && $options_array['PM_EXPORT_ATTACHMENTS'] == 'Y') {
            pm_export_attachments($message['AID'], $message['FROM_UID'], $zip_file);
        }
        $message['FOLDER'] = pm_message_get_folder($message['MID']);
        $message['CONTENT'] = preg_replace("[\r\n|\r|\n]", '\\n', pm_get_content($message['MID']));
        $message['CREATED'] = date('Y-m-d H:i:s', $message['CREATED']);
        if ($options_array['PM_EXPORT_WORDFILTER'] == 'Y') {
            $message = array_map('pm_export_word_filter_apply', $message);
        }
        unset($message['AID']);
        if (!fputcsv($pm_csv_export, $message)) {
            return false;
        }
        if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_MANY) {
            rewind($pm_csv_export);
            $pm_csv_contents = '';
            while (!feof($pm_csv_export)) {
                $pm_csv_contents .= fgets($pm_csv_export);
            }
            $zip_file->add_file($pm_csv_contents, sprintf("message_%s.csv", $message['MID']));
            fclose($pm_csv_export);
            $pm_csv_export = fopen('php://temp', 'r+');
            if (!fputcsv($pm_csv_export, $pm_csv_header)) {
                return false;
            }
        }
    }
    if ($options_array['PM_EXPORT_FILE'] == PM_EXPORT_SINGLE) {
        rewind($pm_csv_export);
        $pm_csv_contents = '';
        while (!feof($pm_csv_export)) {
            $pm_csv_contents .= fgets($pm_csv_export);
        }
        $zip_file->add_file($pm_csv_contents, 'messages.csv');
    }
    fclose($pm_csv_export);
    return true;
}