예제 #1
0
if (!defined('PHPLISTINIT')) {
    exit;
}
ignore_user_abort();
set_time_limit(500);
$illegal_cha = array(",", ";", ":", "#", "\t");
$email_list = array();
$attributes = array();
if (!isset($everyone_groupid)) {
    $everyone_groupid = -1;
}
if (!is_dir($GLOBALS["tmpdir"]) || !is_writable($GLOBALS["tmpdir"])) {
    Warn(sprintf($GLOBALS['I18N']->get('The temporary directory for uploading (%s) is not writable, so import will fail'), $GLOBALS["tmpdir"]));
}
$post_max_size = phpcfgsize2bytes(ini_get("post_max_size"));
$file_max_size = phpcfgsize2bytes(ini_get("upload_max_filesize"));
if ($post_max_size < $file_max_size && WARN_ABOUT_PHP_SETTINGS) {
    Warn(sprintf(s('The maximum POST size is smaller than the maximum upload filesize. If your upload file is too large, import will fail. See the PHP documentation at <a href="%s">%s</a>', 'http://php.net/post_max_size', 'http://php.net/post_max_size')));
}
require dirname(__FILE__) . "//structure.php";
require dirname(__FILE__) . '/inc/importlib.php';
register_shutdown_function("my_shutdown");
if (!defined('WEBBLER')) {
    ob_end_flush();
}
if (!empty($_GET["reset"]) && $_GET["reset"] == "yes") {
    clearImport();
    print '<h3>' . $GLOBALS['I18N']->get('Import cleared') . '</h3>';
    print PageLinkButton('import2', s('Continue'));
    return;
} else {
예제 #2
0
function addAttachments($msgid, &$mail, $type)
{
    global $attachment_repository, $website;
    $hasError = false;
    $totalSize = 0;
    $memlimit = phpcfgsize2bytes(ini_get('memory_limit'));
    if (ALLOW_ATTACHMENTS) {
        $req = Sql_Query("select * from {$GLOBALS["tables"]["message_attachment"]},{$GLOBALS["tables"]["attachment"]}\n      where {$GLOBALS["tables"]["message_attachment"]}.attachmentid = {$GLOBALS["tables"]["attachment"]}.id and\n      {$GLOBALS["tables"]["message_attachment"]}.messageid = {$msgid}");
        if (!Sql_Affected_Rows()) {
            return true;
        }
        if ($type == "text") {
            $mail->append_text($GLOBALS["strAttachmentIntro"] . "\n");
        }
        while ($att = Sql_Fetch_array($req)) {
            $totalSize += $att['size'];
            if ($memlimit > 0 && 3 * $totalSize > $memlimit) {
                ## the 3 is roughly the size increase to encode the string
                #   $_SESSION['action_result'] = s('Insufficient memory to add attachment');
                logEvent(s("Insufficient memory to add attachment to campaign %d %d - %d", $msgid, $totalSize, $memlimit));
                $hasError = true;
            }
            if (!$hasError) {
                switch ($type) {
                    case "HTML":
                        if (is_file($GLOBALS["attachment_repository"] . "/" . $att["filename"]) && filesize($GLOBALS["attachment_repository"] . "/" . $att["filename"])) {
                            $fp = fopen($GLOBALS["attachment_repository"] . "/" . $att["filename"], "r");
                            if ($fp) {
                                $contents = fread($fp, filesize($GLOBALS["attachment_repository"] . "/" . $att["filename"]));
                                fclose($fp);
                                $mail->add_attachment($contents, basename($att["remotefile"]), $att["mimetype"]);
                            }
                        } elseif (is_file($att["remotefile"]) && filesize($att["remotefile"])) {
                            # handle local filesystem attachments
                            $fp = fopen($att["remotefile"], "r");
                            if ($fp) {
                                $contents = fread($fp, filesize($att["remotefile"]));
                                fclose($fp);
                                $mail->add_attachment($contents, basename($att["remotefile"]), $att["mimetype"]);
                                list($name, $ext) = explode(".", basename($att["remotefile"]));
                                # create a temporary file to make sure to use a unique file name to store with
                                $newfile = tempnam($GLOBALS["attachment_repository"], $name);
                                $newfile .= "." . $ext;
                                $newfile = basename($newfile);
                                $fd = fopen($GLOBALS["attachment_repository"] . "/" . $newfile, "w");
                                fwrite($fd, $contents);
                                fclose($fd);
                                # check that it was successful
                                if (filesize($GLOBALS["attachment_repository"] . "/" . $newfile)) {
                                    Sql_Query(sprintf('update %s set filename = "%s" where id = %d', $GLOBALS["tables"]["attachment"], $newfile, $att["attachmentid"]));
                                } else {
                                    # now this one could be sent many times, so send only once per run
                                    if (!isset($GLOBALS[$att["remotefile"] . "_warned"])) {
                                        logEvent("Unable to make a copy of attachment " . $att["remotefile"] . " in repository");
                                        $msg = s("Error, when trying to send campaign %d the attachment (%s) could not be copied to the repository. Check for permissions.", $msgid, $att["remotefile"]);
                                        sendMail(getConfig("report_address"), s("phpList system error"), $msg, "");
                                        $GLOBALS[$att["remotefile"] . "_warned"] = time();
                                    }
                                }
                            } else {
                                logEvent(s("failed to open attachment (%s) to add to campaign %d", $att["remotefile"], $msgid));
                                $hasError = true;
                            }
                        } else {
                            ## as above, avoid sending it many times
                            if (!isset($GLOBALS[$att["remotefile"] . "_warned"])) {
                                logEvent(s("Attachment %s does not exist", $att["remotefile"]));
                                $msg = s("Error, when trying to send campaign %d the attachment (%s) could not be found in the repository", $msgid, $att["remotefile"]);
                                sendMail(getConfig("report_address"), s("phpList system error"), $msg, "");
                                $GLOBALS[$att["remotefile"] . "_warned"] = time();
                            }
                            $hasError = true;
                        }
                        break;
                    case "text":
                        $viewurl = $GLOBALS["public_scheme"] . "://" . $website . $GLOBALS["pageroot"] . '/dl.php?id=' . $att["id"];
                        $mail->append_text($att["description"] . "\n" . $GLOBALS["strLocation"] . ": " . $viewurl . "\n");
                        break;
                }
            }
        }
    }
    ## keep track of an error count, when sending the queue
    if ($GLOBALS['counters']['add attachment error'] > 20) {
        Sql_Query(sprintf('update %s set status = "suspended" where id = %d', $GLOBALS['tables']['message'], $msgid));
        logEvent(s('Campaign %d suspended for too many errors with attachments', $msgid));
        foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
            $plugin->processError(s('Campaign %d suspended for too many errors with attachments', $msgid));
        }
    }
    if ($hasError) {
        $GLOBALS['counters']['add attachment error']++;
    }
    return !$hasError;
}
예제 #3
0
if (!defined('PHPLISTINIT')) {
    exit;
}
ignore_user_abort();
set_time_limit(500);
$illegal_cha = array(',', ';', ':', '#', "\t");
$email_list = array();
$attributes = array();
if (!isset($everyone_groupid)) {
    $everyone_groupid = -1;
}
if (!is_dir($GLOBALS['tmpdir']) || !is_writable($GLOBALS['tmpdir'])) {
    Warn(sprintf($GLOBALS['I18N']->get('The temporary directory for uploading (%s) is not writable, so import will fail'), $GLOBALS['tmpdir']));
}
$post_max_size = phpcfgsize2bytes(ini_get('post_max_size'));
$file_max_size = phpcfgsize2bytes(ini_get('upload_max_filesize'));
if ($post_max_size < $file_max_size && WARN_ABOUT_PHP_SETTINGS) {
    Warn(sprintf(s('The maximum POST size is smaller than the maximum upload filesize. If your upload file is too large, import will fail. See the PHP documentation at <a href="%s">%s</a>', 'http://php.net/post_max_size', 'http://php.net/post_max_size')));
}
require dirname(__FILE__) . '//structure.php';
require dirname(__FILE__) . '/inc/importlib.php';
register_shutdown_function('my_shutdown');
if (!defined('WEBBLER')) {
    ob_end_flush();
}
if (!empty($_GET['reset']) && $_GET['reset'] == 'yes') {
    clearImport();
    print '<h3>' . $GLOBALS['I18N']->get('Import cleared') . '</h3>';
    print PageLinkButton('import2', s('Continue'));
    return;
} else {