예제 #1
0
/**
 *
 */
function messages_mailAndDeleteMessages($messageIDs)
{
    global $db, $params;
    // get valid messages
    $IDs = implode($messageIDs, ", ");
    $sql = 'SELECT m.recipientID, m.senderID, p.name, m.messageSubject, m.messageText, ' . 'DATE_FORMAT(m.messageTime, "%d.%m.%Y %H:%i:%s") AS messageTime ' . 'FROM `Message` m ' . 'LEFT JOIN Player p ON ' . 'IF (m.recipientID = ' . $params->SESSION->user['playerID'] . ', m.senderID = p.playerID, m.recipientID = p.playerID) ' . 'WHERE messageID IN (' . $IDs . ') AND ' . 'IF (recipientDeleted = ' . $params->SESSION->user['playerID'] . ', recipientDeleted = 0, senderDeleted = 0)';
    $dbresult = $db->query($sql);
    if (!$dbresult || $dbresult->isEmpty()) {
        return 0;
    }
    // nun zusammen schreiben
    $mail = "";
    while ($row = $dbresult->nextRow(MYSQL_ASSOC)) {
        $mail .= sprintf("Von:     %s<br>An:      %s<br>Betreff: %s<br>Datum: %s<p>%s<p>" . "----------------------------------------------------------------------------------------<p>", $row['senderID'] == $params->SESSION->user['playerID'] ? $params->SESSION->user['name'] : $row['name'], $row['recipientID'] == $params->SESSION->user['playerID'] ? $params->SESSION->user['name'] : $row['name'], $row['messageSubject'], $row['messageTime'], $row['messageText']);
    }
    if ($mail != "") {
        $mail = "<html><body>" . $mail . "</body></html>";
        // zip it
        require_once "zip.lib.php";
        $time_now = date("YmdHis", time());
        $zipfile = new zipfile();
        $zipfile->addFile($mail, "mail." . $time_now . ".html");
        $mail = $zipfile->file();
        // put mail together
        $mail_from = "*****@*****.**";
        $mail_subject = "Deine Uga-Agga InGame Nachrichten";
        $mail_text = "Hallo,\n\n" . "du hast im Nachrichten Fenster auf den Knopf 'Mailen&löschen' " . "gedrückt. Die dabei markierten Nachrichten werden dir nun mit dieser " . "Email zugesandt. Um den Datenverkehr gering zu halten, " . "wurden dabei deine Nachrichten komprimiert. Mit einschlägigen " . "Programmen wie WinZip lässt sich diese Datei entpacken." . "\n\nGruß, dein UA-Team";
        $filename = "mail." . $time_now . ".zip";
        $filedata = chunk_split(base64_encode($mail));
        $mail_boundary = '=_' . md5(uniqid(rand()) . microtime());
        // create header
        $mime_type = "application/zip-compressed";
        $mail_headers = "From: {$mail_from}\n" . "MIME-version: 1.0\n" . "Content-type: multipart/mixed; " . "boundary=\"{$mail_boundary}\"\n" . "Content-transfer-encoding: 7BIT\n" . "X-attachments: {$filename};\n\n";
        // hier fängt der normale mail-text an
        $mail_headers .= "--{$mail_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n\n" . $mail_text . "\n";
        // hier fängt der datei-anhang an
        $mail_headers .= "--{$mail_boundary}\n" . "Content-type: {$mime_type}; name=\"{$filename}\";\n" . "Content-Transfer-Encoding: base64\n" . "Content-disposition: attachment; filename=\"{$filename}\"\n\n" . $filedata;
        // gibt das ende der email aus
        $mail_headers .= "\n--{$mail_boundary}--\n";
        // und abschicken
        mail($params->SESSION->user['email2'], $mail_subject, "", $mail_headers);
    }
    return messages_deleteMessages($messageIDs);
}
예제 #2
0
function messages_getMessages($caveID, $deletebox, $box)
{
    global $params, $config;
    $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'messagebox.ihtml');
    // Nachrichten löschen
    $deleted = 0;
    // checkboxes checked
    if (is_array($deletebox)) {
        // mail and delete
        if (isset($params->POST->mail_and_delete)) {
            $deleted = messages_mailAndDeleteMessages($deletebox);
        } else {
            if (isset($params->POST->delete)) {
                $deleted = messages_deleteMessages($deletebox);
            }
        }
    }
    // delete all
    if (isset($params->POST->delete_all)) {
        $deleted = messages_deleteAllMessages($box, $params->POST->messageClass);
    }
    // show number of deleted messages
    if ($deleted > 0) {
        tmpl_set($template, '/STATUS_MESSAGE/status_message', sprintf(_('%d Nachricht(en) erfolgreich gelöscht.'), $deleted));
    }
    // flag messages
    if (isset($params->POST->flag)) {
        messages_flag($params->POST->id);
    }
    // unflag messages
    if (isset($params->POST->unflag)) {
        messages_unflag($params->POST->id);
    }
    // verschiedene Boxes werden hier behandelt... //
    $boxes = array(BOX_INCOMING => array('boxname' => _('Posteingang'), 'von_an' => _('Absender')), BOX_OUTGOING => array('boxname' => _('Postausgang'), 'von_an' => _('Empfänger')));
    if (!isset($boxes[$box])) {
        $box = BOX_INCOMING;
    }
    $classes = array();
    foreach (MessageClass::getMessageClasses() as $id => $text) {
        if ($id != 1001) {
            $classes[] = array('id' => $id, 'text' => $text);
        }
    }
    tmpl_set($template, array('/boxname' => $boxes[$box]['boxname'], '/von_an' => $boxes[$box]['von_an'], '/MESSAGECLASS' => $classes));
    /////////////////////////////////////////////////
    // get row_count
    $row_count = 50;
    // errechne offset
    $offset = isset($params->POST->offset) ? intval($params->POST->offset) : 0;
    switch ($box) {
        default:
        case BOX_INCOMING:
            $message_count = messages_getIncomingMessagesCount();
            break;
        case BOX_OUTGOING:
            $message_count = messages_getOutgoingMessagesCount();
            break;
    }
    // offset "normalisieren"
    if ($offset < 0) {
        $offset = 0;
    }
    if ($offset > $message_count - 1) {
        $offset = $message_count;
    }
    // Nachrichten einlesen und ausgeben
    $nachrichten = array();
    switch ($box) {
        default:
        case BOX_INCOMING:
            $nachrichten = messages_getIncomingMessages($offset, $row_count);
            break;
        case BOX_OUTGOING:
            $nachrichten = messages_getOutgoingMessages($offset, $row_count);
            break;
    }
    tmpl_set($template, '/MESSAGE', $nachrichten);
    // vor-zurück Knopf
    if ($offset - $row_count >= 0) {
        tmpl_set($template, '/PREVIOUS', array('offset' => $offset - $row_count, 'box' => $box, 'modus' => MESSAGES));
    } else {
        tmpl_set($template, '/PREVIOUS_DEACTIVATED/dummy', ' ');
    }
    if ($offset + $row_count <= $message_count - 1) {
        tmpl_set($template, '/NEXT', array('offset' => $offset + $row_count, 'box' => $box, 'modus' => MESSAGES));
    } else {
        tmpl_set($template, '/NEXT_DEACTIVATED/dummy', ' ');
    }
    // Anzeige welche Nachrichten man sieht
    tmpl_set($template, array('message_min' => $message_count == 0 ? 0 : $offset + 1, 'message_max' => min($offset + $row_count, $message_count), 'message_count' => $message_count));
    /////////////////////////////////////////////////
    tmpl_set($template, '/HIDDEN', array(array('arg' => "modus", 'value' => MESSAGES), array('arg' => "box", 'value' => $box)));
    return tmpl_parse($template);
}
예제 #3
0
function messages_getMessages($caveID, $deletebox, $box)
{
    global $params, $config;
    $template = @tmpl_open('templates/' . $config->template_paths[$params->SESSION->user['template']] . '/messagebox.ihtml');
    // Nachrichten löschen
    $deleted = 0;
    if (is_array($deletebox)) {
        if (!empty($params->POST->mail_and_delete)) {
            $deleted = messages_mailAndDeleteMessages($deletebox);
        } else {
            $deleted = messages_deleteMessages($deletebox);
        }
    }
    if ($deleted > 0) {
        tmpl_set($template, '/STATUS_MESSAGE/status_message', $deleted . " Nachricht(en) erfolgreich gelöscht.");
    }
    // verschiedene Boxes werden hier behandelt... //
    $boxes = array(BOX_INCOMING => array('boxname' => "Posteingang", 'von_an' => "Absender"), BOX_OUTGOING => array('boxname' => "Postausgang", 'von_an' => "Empf&auml;nger"));
    if (!isset($boxes[$box])) {
        $box = BOX_INCOMING;
    }
    tmpl_set($template, 'CHANGEBOX/BOX', array(array('name' => "Posteingang", 'value' => BOX_INCOMING, 'selected' => $box == BOX_INCOMING ? "selected" : ""), array('name' => "Postausgang", 'value' => BOX_OUTGOING, 'selected' => $box == BOX_OUTGOING ? "selected" : "")));
    tmpl_set($template, 'CHANGEBOX/HIDDEN', array(array('arg' => "modus", 'value' => MESSAGES)));
    tmpl_set($template, 'boxname', $boxes[$box]['boxname']);
    tmpl_set($template, '/von_an', $boxes[$box]['von_an']);
    /////////////////////////////////////////////////
    tmpl_set($template, 'newmessagelinkparams', "?modus=" . NEW_MESSAGE . "&box=" . $box);
    // get row_count
    $row_count = 50;
    // errechne offset
    $offset = isset($params->POST->offset) ? intval($params->POST->offset) : 0;
    switch ($box) {
        default:
        case BOX_INCOMING:
            $message_count = messages_getIncomingMessagesCount();
            break;
        case BOX_OUTGOING:
            $message_count = messages_getOutgoingMessagesCount();
            break;
    }
    // offset "normalisieren"
    if ($offset < 0) {
        $offset = 0;
    }
    if ($offset > $message_count - 1) {
        $offset = $message_count;
    }
    // Nachrichten einlesen und ausgeben
    $nachrichten = array();
    switch ($box) {
        default:
        case BOX_INCOMING:
            $nachrichten = messages_getIncomingMessages($offset, $row_count);
            break;
        case BOX_OUTGOING:
            $nachrichten = messages_getOutgoingMessages($offset, $row_count);
            break;
    }
    tmpl_set($template, '/MESSAGE', $nachrichten);
    // vor-zurück Knopf
    if ($offset - $row_count >= 0) {
        tmpl_set($template, '/PREVIOUS', array('offset' => $offset - $row_count, 'box' => $box, 'modus' => MESSAGES));
    } else {
        tmpl_set($template, '/PREVIOUS_DEACTIVATED/dummy', ' ');
    }
    if ($offset + $row_count <= $message_count - 1) {
        tmpl_set($template, '/NEXT', array('offset' => $offset + $row_count, 'box' => $box, 'modus' => MESSAGES));
    } else {
        tmpl_set($template, '/NEXT_DEACTIVATED/dummy', ' ');
    }
    // Anzeige welche Nachrichten man sieht
    tmpl_set($template, array('message_min' => $offset + 1, 'message_max' => min($offset + $row_count, $message_count), 'message_count' => $message_count));
    /////////////////////////////////////////////////
    tmpl_set($template, '/HIDDEN', array(array('arg' => "modus", 'value' => MESSAGES), array('arg' => "box", 'value' => $box)));
    return tmpl_parse($template);
}
예제 #4
0
/**
 *
 */
function messages_mailAndDeleteMessages($messageIDs)
{
    global $db, $params;
    // get valid messages
    $IDs = implode($messageIDs, ", ");
    $sql = 'SELECT m.recipientID, m.senderID, p.name, m.messageSubject, m.messageText, ' . 'DATE_FORMAT(m.messageTime, "%d.%m.%Y %H:%i:%s") AS messageTime ' . 'FROM `Message` m ' . 'LEFT JOIN Player p ON ' . 'IF (m.recipientID = ' . $params->SESSION->player->playerID . ', m.senderID = p.playerID, m.recipientID = p.playerID) ' . 'WHERE messageID IN (' . $IDs . ') AND ' . 'IF (recipientDeleted = ' . $params->SESSION->player->playerID . ', recipientDeleted = 0, senderDeleted = 0)';
    $dbresult = $db->query($sql);
    if (!$dbresult || $dbresult->isEmpty()) {
        return 0;
    }
    $exporter = new MessageExporter();
    while ($record = $dbresult->nextRow(MYSQL_ASSOC)) {
        $exporter->add(new Message($record));
    }
    $exporter->send($params->SESSION->player->email2);
    return messages_deleteMessages($messageIDs);
}