function precacheMessage($messageid, $forwardContent = 0)
{
global $cached, $tables;
$domain = getConfig('domain');
# $message = Sql_query("select * from {$GLOBALS["tables"]["message"]} where id = $messageid");
# $cached[$messageid] = array();
# $message = Sql_fetch_array($message);
$message = loadMessageData($messageid);
## the reply to is actually not in use
if (preg_match('/([^ ]+@[^ ]+)/', $message['replyto'], $regs)) {
# if there is an email in the from, rewrite it as "name <email>"
$message['replyto'] = str_replace($regs[0], '', $message['replyto']);
$cached[$messageid]['replytoemail'] = $regs[0];
# if the email has < and > take them out here
$cached[$messageid]['replytoemail'] = str_replace('<', '', $cached[$messageid]['replytoemail']);
$cached[$messageid]['replytoemail'] = str_replace('>', '', $cached[$messageid]['replytoemail']);
# make sure there are no quotes around the name
$cached[$messageid]['replytoname'] = str_replace('"', '', ltrim(rtrim($message['replyto'])));
} elseif (strpos($message['replyto'], ' ')) {
# if there is a space, we need to add the email
$cached[$messageid]['replytoname'] = $message['replyto'];
$cached[$messageid]['replytoemail'] = "listmaster@{$domain}";
} else {
if (!empty($message['replyto'])) {
$cached[$messageid]['replytoemail'] = $message['replyto'] . "@{$domain}";
## makes more sense not to add the domain to the word, but the help says it does
## so let's keep it for now
$cached[$messageid]['replytoname'] = $message['replyto'] . "@{$domain}";
}
}
$cached[$messageid]['fromname'] = $message['fromname'];
$cached[$messageid]['fromemail'] = $message['fromemail'];
$cached[$messageid]['to'] = $message['tofield'];
#0013076: different content when forwarding 'to a friend'
$cached[$messageid]['subject'] = $forwardContent ? stripslashes($message['forwardsubject']) : $message['subject'];
#0013076: different content when forwarding 'to a friend'
$cached[$messageid]['content'] = $forwardContent ? stripslashes($message['forwardmessage']) : $message['message'];
if (USE_MANUAL_TEXT_PART && !$forwardContent) {
$cached[$messageid]['textcontent'] = $message['textmessage'];
} else {
$cached[$messageid]['textcontent'] = '';
}
# var_dump($cached);exit;
#0013076: different content when forwarding 'to a friend'
$cached[$messageid]['footer'] = $forwardContent ? stripslashes($message['forwardfooter']) : $message['footer'];
if (strip_tags($cached[$messageid]['footer']) != $cached[$messageid]['footer']) {
$cached[$messageid]['textfooter'] = HTML2Text($cached[$messageid]['footer']);
$cached[$messageid]['htmlfooter'] = $cached[$messageid]['footer'];
} else {
$cached[$messageid]['textfooter'] = $cached[$messageid]['footer'];
$cached[$messageid]['htmlfooter'] = parseText($cached[$messageid]['footer']);
}
$cached[$messageid]['htmlformatted'] = strip_tags($cached[$messageid]['content']) != $cached[$messageid]['content'];
$cached[$messageid]['sendformat'] = $message['sendformat'];
if ($message['template']) {
$req = Sql_Fetch_Row_Query("select template from {$GLOBALS['tables']['template']} where id = {$message['template']}");
$cached[$messageid]['template'] = stripslashes($req[0]);
$cached[$messageid]['templateid'] = $message['template'];
# dbg("TEMPLATE: ".$req[0]);
} else {
$cached[$messageid]['template'] = '';
$cached[$messageid]['templateid'] = 0;
}
## @@ put this here, so it can become editable per email sent out at a later stage
$cached[$messageid]['html_charset'] = 'UTF-8';
#getConfig("html_charset");
## @@ need to check on validity of charset
if (!$cached[$messageid]['html_charset']) {
$cached[$messageid]['html_charset'] = 'UTF-8';
#'iso-8859-1';
}
$cached[$messageid]['text_charset'] = 'UTF-8';
#getConfig("text_charset");
if (!$cached[$messageid]['text_charset']) {
$cached[$messageid]['text_charset'] = 'UTF-8';
#'iso-8859-1';
}
## if we are sending a URL that contains user attributes, we cannot pre-parse the message here
## but that has quite some impact on speed. So check if that's the case and apply
$cached[$messageid]['userspecific_url'] = preg_match('/\\[.+\\]/', $message['sendurl']);
if (!$cached[$messageid]['userspecific_url']) {
## Fetch external content here, because URL does not contain placeholders
if ($GLOBALS['can_fetchUrl'] && preg_match("/\\[URL:([^\\s]+)\\]/i", $cached[$messageid]['content'], $regs)) {
$remote_content = fetchUrl($regs[1], array());
# $remote_content = fetchUrl($message['sendurl'],array());
# @@ don't use this
# $remote_content = includeStyles($remote_content);
if ($remote_content) {
$cached[$messageid]['content'] = str_replace($regs[0], $remote_content, $cached[$messageid]['content']);
# $cached[$messageid]['content'] = $remote_content;
$cached[$messageid]['htmlformatted'] = strip_tags($remote_content) != $remote_content;
## 17086 - disregard any template settings when we have a valid remote URL
$cached[$messageid]['template'] = null;
$cached[$messageid]['templateid'] = null;
} else {
#print Error(s('unable to fetch web page for sending'));
logEvent('Error fetching URL: ' . $message['sendurl'] . ' cannot proceed');
return false;
}
}
//.........这里部分代码省略.........
//.........这里部分代码省略.........
/*
We request you retain the signature below in your emails including the links.
This not only gives respect to the large amount of time given freely
by the developers but also helps build interest, traffic and use of
PHPlist, which is beneficial to it's future development.
You can configure how the credits are added to your pages and emails in your
config file.
Michiel Dethmers, Tincan Ltd 2003, 2004, 2005, 2006
*/
if (!EMAILTEXTCREDITS) {
$html["signature"] = $PoweredByImage;
#'<div align="center" id="signature"><a href="http://www.phplist.com"><img src="powerphplist.png" width=88 height=31 title="Powered by PHPlist" alt="Powered by PHPlist" border="0"></a></div>';
# oops, accidentally became spyware, never intended that, so take it out again :-)
$html["signature"] = preg_replace('/src=".*power-phplist.png"/', 'src="powerphplist.png"', $html["signature"]);
} else {
$html["signature"] = $PoweredByText;
}
$content = $cached[$messageid]["content"];
if (preg_match("/##LISTOWNER=(.*)/", $content, $regs)) {
$listowner = $regs[1];
$content = ereg_replace($regs[0], "", $content);
} else {
$listowner = 0;
}
## Fetch external content
if ($GLOBALS["has_pear_http_request"] && preg_match("/\\[URL:([^\\s]+)\\]/i", $content, $regs)) {
while (isset($regs[1]) && strlen($regs[1])) {
$url = $regs[1];
if (!preg_match('/^http/i', $url)) {
$url = 'http://' . $url;
}
$remote_content = fetchUrl($url, $userdata);
if ($remote_content) {
$content = eregi_replace(preg_quote($regs[0]), $remote_content, $content);
$cached[$messageid]["htmlformatted"] = strip_tags($content) != $content;
} else {
logEvent("Error fetching URL: {$regs['1']} to send to {$email}");
return 0;
}
preg_match("/\\[URL:([^\\s]+)\\]/i", $content, $regs);
}
}
#~Bas 0008857
// @@ Switched off for now, needs rigid testing, or config setting
// $content = mailto2href($content);
// $content = encodeLinks($content);
## Fill text and html versions depending on given versions.
if ($cached[$messageid]["htmlformatted"]) {
if (!$cached[$messageid]["textcontent"]) {
$textcontent = stripHTML($content);
} else {
$textcontent = $cached[$messageid]["textcontent"];
}
$htmlcontent = $content;
} else {
# $textcontent = $content;
if (!$cached[$messageid]["textcontent"]) {
$textcontent = $content;
} else {
$textcontent = $cached[$messageid]["textcontent"];
}
$htmlcontent = parseText($content);
}
$defaultstyle = getConfig("html_email_style");
$bRemovalConfirmed = false;
if ($gRurl) {
// Do some basic validation
$is_valid_url = preg_match("/^(http|https):\\/\\/([A-Z0-9][A-Z0-9_-]*(?:\\.[A-Z0-9][A-Z0-9_-]*)+):?(\\d+)?\\/?/i", $gRurl);
if (!$is_valid_url) {
echo "<p class=warning>The URL entered is invalid: {$gRurl}</p>\n";
} else {
$existingUrl = urlExists($gRurl);
if (!$existingUrl) {
echo "<p class=warning>Nothing to remove - the URL \"{$gRurl}\" doesn't exist in the HTTP Archive.</p>\n";
} else {
// make sure we have a trailing slash
$url_to_fetch = substr($gRurl, -1) == '/' ? $gRurl : $gRurl . '/';
$url_to_fetch .= 'removehttparchive.txt';
// This requires setting this in php.ini: allow_url_fopen = On
$bRemovalConfirmed = FALSE === @fetchUrl($url_to_fetch) ? false : true;
if (!$bRemovalConfirmed) {
echo "<p class=warning><a href='{$url_to_fetch}' style='text-decoration: underline; color: #870E00;'>{$url_to_fetch}</a> was not found.<br>{$gRurl} is still archived.</p>\n";
} else {
removeSite($gRurl);
// queue it for removal
echo "<p class=warning style='margin-bottom: 0;'>{$gRurl} will be removed within five business days.</p>\n<p style='margin-top: 0;'>You can remove removehttparchive.txt now.</p>";
}
}
}
}
?>
<script type="text/javascript">
function confirmRemove() {
var url = document.getElementById("rurl").value;
请发表评论