コード例 #1
0
ファイル: pastebin.php プロジェクト: jorik041/pastebin
function retrieve_post($urlKey)
{
    $id = mysql_real_escape_string(get_database_id($urlKey));
    $query = mysql_query("SELECT * FROM `pastes` WHERE token='{$id}'");
    if (mysql_num_rows($query) > 0) {
        $cols = mysql_fetch_array($query);
        $postInfo = array();
        $postInfo['timeleft'] = $cols['time'] - time();
        $postInfo['jscrypt'] = $cols['jscrypt'] == "1";
        $encryptionKey = get_encryption_key($urlKey);
        $ciphertext = SafeDecode($cols['data']);
        $iv = substr($ciphertext, 0, IV_BYTES);
        $encryptedText = substr($ciphertext, IV_BYTES);
        $postInfo['text'] = str_replace("", "", mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $encryptionKey, $encryptedText, MCRYPT_MODE_CBC, $iv));
        return $postInfo;
    } else {
        return false;
    }
}
コード例 #2
0
function rescue_item($user_id, $mail_id, $resend = false)
{
    global $dbh, $logger;
    $sth = $dbh->prepare("SELECT sender_email, contents, " . "envelope_to, maia_mail_recipients.type " . "FROM maia_mail, maia_mail_recipients " . "WHERE maia_mail.id = maia_mail_recipients.mail_id " . "AND maia_mail_recipients.recipient_id = ? " . "AND maia_mail_recipients.mail_id = ?");
    $res = $sth->execute(array($user_id, $mail_id));
    if (PEAR::isError($sth)) {
        die($sth->getMessage());
    }
    if ($row = $res->fetchrow()) {
        $sender_email = $row["sender_email"];
        $body = $row["contents"];
        $type = $row["type"];
        if (extension_loaded('mcrypt')) {
            if (text_is_encrypted($body)) {
                $key = get_encryption_key();
                $body = decrypt_text($key, $body);
            }
        }
        if (is_a_domain_default_user($user_id)) {
            // System default user (@.) or domain-class user (e.g. @domain)
            $my_email_address = $row["envelope_to"];
        } else {
            // Regular user (e.g. user@domain)
            $rlist = explode(" ", trim($row["envelope_to"]));
            $sth2 = $dbh->prepare("SELECT email FROM users " . "WHERE maia_user_id = ? " . "AND email = ?");
            $my_email_address = "";
            foreach ($rlist as $rmail) {
                $res2 = $sth2->execute(array($user_id, $rmail));
                if (PEAR::isError($sth2)) {
                    die($sth2->getMessage());
                }
                if ($row2 = $res2->fetchrow()) {
                    $my_email_address = $row2["email"];
                    break;
                }
            }
            $sth2->free();
        }
        if (!empty($my_email_address)) {
            if ($resend || $type != 'P') {
                // don't send if it is a labeled fp
                $smtp_result = smtp_send($sender_email, $my_email_address, $body);
            } else {
                $smtp_result = "200 no delivery needed";
            }
            if (($succeeded = strncmp($smtp_result, "2", 1) == 0) || $type == 'P') {
                if (!$resend) {
                    if ($type == 'S' || $type == 'P') {
                        record_mail_stats($user_id, $mail_id, "fp");
                        if (get_user_value($user_id, "auto_whitelist") == "Y") {
                            add_address_to_wb_list($user_id, $sender_email, "W");
                        }
                    }
                    set_item_confirmations('G', $user_id, $mail_id);
                }
            } else {
                $logger->err("rescue attempt failed! " . $smtp_result);
            }
        } else {
            $smtp_result = $lang['text_rescue_error'] . "(EmptyAddress)";
            // code really shouldn't be here.
        }
    } else {
        $smtp_result = $lang['text_rescue_error'] . "(MessageNotFound)";
        // code really shouldn't be here.
    }
    $sth->free();
    $logger->info($smtp_result);
    return $smtp_result;
}
コード例 #3
0
ファイル: view.php プロジェクト: tenshi3/maia_mailguard
//
// Decoding is provided for common formats:
//
//    base64
//    quoted-printable
//    8bit
//    7bit
//
$sth = $dbh->prepare("SELECT maia_mail.contents, maia_mail.sender_email " . "FROM maia_mail, maia_mail_recipients " . "WHERE maia_mail.id = maia_mail_recipients.mail_id " . "AND maia_mail.id = ? " . "AND maia_mail_recipients.recipient_id = ?");
$res = $sth->execute(array($id, $euid));
if ($row = $res->fetchrow()) {
    $contents = $row["contents"];
    $sender_email = $row['sender_email'];
    if (extension_loaded('mcrypt')) {
        if (text_is_encrypted($contents)) {
            $key = get_encryption_key();
            $contents = decrypt_text($key, $contents);
        }
    }
    $smarty->assign("spamreport_rows", display_spam_report($id));
    if (!$raw) {
        // Try to decode the mail and display all of its parts.
        $mail = new Mail_mimeDecode(get_magic_quotes_gpc() ? stripslashes($contents) : $contents);
        $args['include_bodies'] = true;
        $args['decode_bodies'] = true;
        $args['decode_headers'] = false;
        // the inconv decoding will handle the headers
        $structure = $mail->decode($args);
        $smarty->assign("message", display_parts($structure));
        $headers = $structure->headers;
        foreach ($headers as $key => $value) {