Exemple #1
0
function holeMailHeader($usr, $Flag)
{
    $srv = getUsrMailData($usr);
    $m = array();
    if ($srv["msrv"] && $srv["postf"]) {
        // Mailserver/Postfach eingetragen
        $mbox = mail_login($srv["msrv"], $srv["port"], $srv["postf"], $srv["mailuser"], $srv["kennw"], $srv["proto"], $srv["ssl"]);
        if ($mbox) {
            $status = mail_stat($mbox);
            $anzahl = $status["Nmsgs"] - $status["Deleted"];
            if ($anzahl > 0) {
                $overview = mail_list($mbox);
                $m = false;
                if (is_array($overview)) {
                    foreach ($overview as $mail) {
                        if (!$mail["deleted"] && !$mail[strtolower($Flag)]) {
                            $gelesen = $mail["seen"] ? "-" : "+";
                            $m[] = array("Nr" => $mail["msgno"], "Datum" => $mail["date"] . " " . $mail["time"], "Betreff" => $mail["subject"], "Abs" => $mail["from"], "Gelesen" => $gelesen, "sel" => $mail["flagged"]);
                        }
                    }
                    if (empty($m)) {
                        $m[] = array("Nr" => 0, "Datum" => "", "Betreff" => "Keine Mails", "Abs" => "", "Gelesen" => "");
                    }
                }
                imap_close($mbox);
            } else {
                $m[] = array("Nr" => 0, "Datum" => "", "Betreff" => "Keine Mails", "Abs" => "", "Gelesen" => "");
            }
            mail_close($mbox);
        } else {
            // Mailserver nicht erreicht
            $m[] = array("Nr" => 0, "Datum" => "", "Betreff" => "can't connect to Mailserver ", "Abs" => "", "Gelesen" => "");
        }
        return $m;
    } else {
        return false;
    }
}
function mail_delete()
{
    global $smarty;
    if (!empty($_REQUEST['mail_id'])) {
        if (is_array($_REQUEST['mail_id'])) {
            foreach ($_REQUEST['mail_id'] as $mail_id) {
                $mail[] = abs((int) $mail_id);
            }
        } else {
            $mail[] = abs((int) $_REQUEST['mail_id']);
        }
    } else {
        $status[] = 'No mail selected for deletion.';
        $smarty->append('status', $status);
        mail_list();
        exit;
    }
    $db_query = "\n\t\t\tUPDATE `mail`\n\t\t\tSET `status` = '" . MAILSTATUS_DELETED . "' \n\t\t\tWHERE \n\t\t\t\t`mail_id` IN ('" . implode("', '", $mail) . "') AND \n\t\t\t\t`to_player_id` = '" . $_SESSION['player_id'] . "'";
    $db_result = mysql_query($db_query);
    $status[] = 'Successfully deleted selected message(s).';
    $smarty->append('status', $status);
    mail_list();
    exit;
}