function mergeUser($userid) { $duplicate = Sql_Fetch_Array_Query("select * from {$GLOBALS["tables"]["user"]} where id = {$userid}"); printf('<br/>%s', $duplicate["email"]); if (preg_match("/^duplicate[^ ]* (.*)/", $duplicate["email"], $regs)) { print "-> " . $regs[1]; $email = $regs[1]; } elseif (preg_match("/^([^ ]+@[^ ]+) \\(\\d+\\)/", $duplicate["email"], $regs)) { print "-> " . $regs[1]; $email = $regs[1]; } else { $email = ""; } if ($email) { $orig = Sql_Fetch_Row_Query(sprintf('select id from %s where email = "%s"', $GLOBALS["tables"]["user"], $email)); if ($orig[0]) { print " " . $GLOBALS['I18N']->get("user found"); $umreq = Sql_Query("select * from {$GLOBALS["tables"]["usermessage"]} where userid = " . $duplicate["id"]); while ($um = Sql_Fetch_Array($umreq)) { Sql_Query(sprintf('update %s set userid = %d, entered = "%s" where userid = %d and entered = "%s"', $GLOBALS["tables"]["usermessage"], $orig[0], $um["entered"], $duplicate["id"], $um["entered"])); } $bncreq = Sql_Query("select * from {$GLOBALS["tables"]["user_message_bounce"]} where user = "******"id"]); while ($bnc = Sql_Fetch_Array($bncreq)) { Sql_Query(sprintf('update %s set user = %d, time = "%s" where user = %d and time = "%s"', $GLOBALS["tables"]["user_message_bounce"], $orig[0], $bnc["time"], $duplicate["id"], $bnc["time"])); } Sql_Query("delete from {$GLOBALS["tables"]["listuser"]} where userid = " . $duplicate["id"]); } else { print " " . $GLOBALS['I18N']->get("no user found"); } flush(); } else { print "-> " . $GLOBALS['I18N']->get("unable to find original email"); } }
function rssUserHasContent($userid,$messageid,$frequency) { global $tables; switch ($frequency) { case "weekly": $interval = 'interval 7 day';break; case "monthly": $interval = 'interval 1 month';break; case "daily": default: $interval = 'interval 1 day';break; } $cansend_req = Sql_Query(sprintf('select date_add(last,%s) < now() from %s where userid = %d', $interval,$tables["user_rss"],$userid)); $exists = Sql_Affected_Rows(); $cansend = Sql_Fetch_Row($cansend_req); if (!$exists || $cansend[0]) { # we can send this user as far as the frequency is concerned # now check whether there is actually some content # check what lists to use. This is the intersection of the lists for the # user and the lists for the message $lists = array(); $listsreq = Sql_Query(sprintf(' select %s.listid from %s,%s where %s.listid = %s.listid and %s.userid = %d and %s.messageid = %d', $tables["listuser"],$tables["listuser"],$tables["listmessage"], $tables["listuser"],$tables["listmessage"], $tables["listuser"],$userid,$tables["listmessage"],$messageid)); while ($row = Sql_Fetch_Row($listsreq)) { array_push($lists,$row[0]); } if (!sizeof($lists)) return 0; $liststosend = join(",",$lists); # request the rss items that match these lists and that have not been sent to this user $itemstosend = array(); $max = sprintf('%d',getConfig("rssmax")); if (!$max) { $max = 30; } $itemreq = Sql_Query("select {$tables["rssitem"]}.* from {$tables["rssitem"]} where {$tables["rssitem"]}.list in ($liststosend) order by added desc, list,title limit $max"); while ($item = Sql_Fetch_Array($itemreq)) { Sql_Query("select * from {$tables["rssitem_user"]} where itemid = {$item["id"]} and userid = $userid"); if (!Sql_Affected_Rows()) { array_push($itemstosend,$item["id"]); } } # print "<br/>Items to send for user $userid: ".sizeof($itemstosend); # if it is less than the treshold return nothing $treshold = getConfig("rsstheshold"); if (sizeof($itemstosend) >= $treshold) return $itemstosend; else return array(); } return array(); }
function userSelect($fieldname, $current = '') { $html = sprintf('<select name="%s">', $fieldname); $req = Sql_Query(sprintf('select id,email from user order by email')); while ($row = Sql_Fetch_Array($req)) { $html .= sprintf('<option value="%d" %s>%s</option>', $row['id'], $current == $row['id'] ? 'selected="selected"' : '', $row['email']); } $html .= '</select>'; return $html; }
function adminMenu() { global $adminlevel, $config; if ($adminlevel == "superuser") { $html .= menuLink("admins", "administrators"); $html .= menuLink("groups", "groups"); $html .= menuLink("users", "users"); $html .= menuLink("userattributes", "user attributes"); $req = Sql_Query('select * from attribute where type = "select" or type = "radio" or type = "checkboxgroup"'); while ($row = Sql_Fetch_Array($req)) { $html .= menuLink("editattributes&id=" . $row["id"], "> " . $row["name"]); } $html .= menuLink("branches", "branch fields", "option=branchfields"); $html .= menuLink("templates", "templates"); } return $html; }
function mergeUsers($original, $duplicate) { set_time_limit(60); print '<br/>Merging ' . $duplicate . ' into ' . $original; $umreq = Sql_Query(sprintf('select * from %s where userid = %d', $GLOBALS["tables"]["usermessage"], $duplicate)); while ($um = Sql_Fetch_Array($umreq)) { Sql_Query(sprintf('update %s set userid = %d, entered = "%s" where userid = %d and entered = "%s"', $GLOBALS["tables"]["usermessage"], $original, $um["entered"], $duplicate, $um["entered"]), 1); } $bncreq = Sql_Query(sprintf('select * from %s where user = %d', $GLOBALS["tables"]["user_message_bounce"], $duplicate)); while ($bnc = Sql_Fetch_Array($bncreq)) { Sql_Query(sprintf('update %s set user = %d, time = "%s" where user = %d and time = "%s"', $GLOBALS["tables"]["user_message_bounce"], $original, $bnc["time"], $duplicate, $bnc["time"]), 1); } $listreq = Sql_Query(sprintf('select * from %s where userid = %d', $GLOBALS["tables"]["listuser"], $duplicate)); while ($list = Sql_Fetch_Array($listreq)) { Sql_Query(sprintf('update %s set userid = %d, entered = "%s" where userid = %d and entered = "%s" and listid = %d', $GLOBALS["tables"]["listuser"], $original, $list["entered"], $duplicate, $list["entered"], $list['listid']), 1); } Sql_Query(sprintf('delete from %s where userid = %d', $GLOBALS["tables"]["listuser"], $duplicate)); Sql_Query(sprintf('delete from %s where user = %d', $GLOBALS["tables"]["user_message_bounce"], $duplicate)); Sql_Query(sprintf('delete from %s where userid = %d', $GLOBALS["tables"]["usermessage"], $duplicate)); # if (MERGE_DUPLICATES_DELETE_DUPLICATE) { deleteUser($duplicate); # } flush(); }
function ListAllAttributes() { global $tables; $attributes = array(); $attributedata = array(); $res = Sql_Query("select * from {$tables["attribute"]} order by listorder"); while ($row = Sql_Fetch_Array($res)) { # print $row["id"]. " ".$row["name"]; $attributes[$row["id"]] = $row["listorder"]; $attributedata[$row["id"]]["id"] = $row["id"]; $attributedata[$row["id"]]["default_value"] = $row["default_value"]; $attributedata[$row["id"]]["listorder"] = $row["listorder"]; $attributedata[$row["id"]]["required"] = $row["required"]; $attributedata[$row["id"]]["default_value"] = $row["default_value"]; } return ListAttributes($attributes,$attributedata,"checkforhtml"); }
function forwardPage($id) { global $tables; $ok = true; $subtitle = ''; $info = ''; $html = ''; $form = ''; $personalNote = ''; ## Check requirements # message $mid = 0; if (isset($_REQUEST['mid'])) { $mid = sprintf('%d', $_REQUEST['mid']); $messagedata = loadMessageData($mid); $mid = $messagedata['id']; if ($mid) { $subtitle = $GLOBALS['strForwardSubtitle'] . ' ' . stripslashes($messagedata['subject']); } } #mid set # user if (!isset($_REQUEST['uid']) || !$_REQUEST['uid']) { FileNotFound(); } ## get userdata $req = Sql_Query(sprintf('select * from %s where uniqid = "%s"', $tables['user'], sql_escape($_REQUEST['uid']))); $userdata = Sql_Fetch_Array($req); ## verify that this subscriber actually received this message to forward, otherwise they're not allowed $allowed = Sql_Fetch_Row_Query(sprintf('select userid from %s where userid = %d and messageid = %d', $GLOBALS['tables']['usermessage'], $userdata['id'], $mid)); if (empty($userdata['id']) || $allowed[0] != $userdata['id']) { ## when sending a test email as an admin, the entry isn't there yet if (empty($_SESSION['adminloggedin']) || $_SESSION['adminloggedin'] != $_SERVER['REMOTE_ADDR']) { FileNotFound('<br/><i>' . $GLOBALS['I18N']->get('When testing the phpList forward functionality, you need to be logged in as an administrator.') . '</i><br/>'); } } $firstpage = 1; ## is this the initial page or a followup # forward addresses $forwardemail = ''; if (isset($_REQUEST['email']) && !empty($_REQUEST['email'])) { $firstpage = 0; $forwardPeriodCount = Sql_Fetch_Array_Query(sprintf('select count(user) from %s where date_add(time,interval %s) >= now() and user = %d and status ="sent" ', $tables['user_message_forward'], FORWARD_EMAIL_PERIOD, $userdata['id'])); $forwardemail = stripslashes($_REQUEST['email']); $emails = explode("\n", $forwardemail); $emails = trimArray($emails); $forwardemail = implode("\n", $emails); #0011860: forward to friend, multiple emails $emailCount = $forwardPeriodCount[0]; foreach ($emails as $index => $email) { $emails[$index] = trim($email); if (is_email($email)) { ++$emailCount; } else { $info .= sprintf('<br />' . $GLOBALS['strForwardInvalidEmail'], $email); $ok = false; } } if ($emailCount > FORWARD_EMAIL_COUNT) { $info .= '<br />' . $GLOBALS['strForwardCountReached']; $ok = false; } } else { $ok = false; } #0011996: forward to friend - personal message # text cannot be longer than max, to prevent very long text with only linefeeds total cannot be longer than twice max if (FORWARD_PERSONAL_NOTE_SIZE && isset($_REQUEST['personalNote'])) { if (strlen(strip_newlines($_REQUEST['personalNote'])) > FORWARD_PERSONAL_NOTE_SIZE || strlen($_REQUEST['personalNote']) > FORWARD_PERSONAL_NOTE_SIZE * 2) { $info .= '<BR />' . $GLOBALS['strForwardNoteLimitReached']; $ok = false; } $personalNote = strip_tags(htmlspecialchars_decode(stripslashes($_REQUEST['personalNote']))); $userdata['personalNote'] = $personalNote; } if ($userdata['id'] && $mid) { if ($ok && count($emails)) { ## All is well, send it require_once 'admin/sendemaillib.php'; #0013845 Lead Ref Scheme if (FORWARD_FRIEND_COUNT_ATTRIBUTE) { $iCountFriends = FORWARD_FRIEND_COUNT_ATTRIBUTE; } else { $iCountFriends = 0; } if ($iCountFriends) { $nFriends = intval(UserAttributeValue($userdata['id'], $iCountFriends)); } ## remember the lists for this message in order to notify only those admins ## that own them $messagelists = array(); $messagelistsreq = Sql_Query(sprintf('select listid from %s where messageid = %d', $GLOBALS['tables']['listmessage'], $mid)); while ($row = Sql_Fetch_Row($messagelistsreq)) { array_push($messagelists, $row[0]); } foreach ($emails as $index => $email) { #0011860: forward to friend, multiple emails $done = Sql_Fetch_Array_Query(sprintf('select user,status,time from %s where forward = "%s" and message = %d', $tables['user_message_forward'], $email, $mid)); $info .= '<br />' . $email . ': '; if ($done['status'] === 'sent') { $info .= $GLOBALS['strForwardAlreadyDone']; } elseif (isBlackListed($email)) { $info .= $GLOBALS['strForwardBlacklistedEmail']; } else { if (!TEST) { # forward the message # sendEmail will take care of blacklisting ### CHECK $email vs $forwardemail if (sendEmail($mid, $email, 'forwarded', $userdata['htmlemail'], array(), $userdata)) { $info .= $GLOBALS['strForwardSuccessInfo']; sendAdminCopy(s('Message Forwarded'), s('%s has forwarded message %d to %s', $userdata['email'], $mid, $email), $messagelists); Sql_Query(sprintf('insert into %s (user,message,forward,status,time) values(%d,%d,"%s","sent",now())', $tables['user_message_forward'], $userdata['id'], $mid, $email)); if ($iCountFriends) { ++$nFriends; } } else { $info .= $GLOBALS['strForwardFailInfo']; sendAdminCopy(s('Message Forwarded'), s('%s tried forwarding message %d to %s but failed', $userdata['email'], $mid, $email), $messagelists); Sql_Query(sprintf('insert into %s (user,message,forward,status,time) values(%d,%d,"%s","failed",now())', $tables['user_message_forward'], $userdata['id'], $mid, $email)); $ok = false; } } } } # foreach friend if ($iCountFriends) { saveUserAttribute($userdata['id'], $iCountFriends, array('name' => FORWARD_FRIEND_COUNT_ATTRIBUTE, 'value' => $nFriends)); } } #ok & emails } else { # no valid sender logEvent(s('Forward request from invalid user ID: %s', substr($_REQUEST['uid'], 0, 150))); $info .= '<BR />' . $GLOBALS['strForwardFailInfo']; $ok = false; } /* $data = PageData($id); if (isset($data['language_file']) && is_file(dirname(__FILE__).'/texts/'.basename($data['language_file']))) { @include dirname(__FILE__).'/texts/'.basename($data['language_file']); } */ ## BAS Multiple Forward ## build response page $form = '<form method="post" action="">'; $form .= sprintf('<input type=hidden name="mid" value="%d">', $mid); $form .= sprintf('<input type=hidden name="id" value="%d">', $id); $form .= sprintf('<input type=hidden name="uid" value="%s">', $userdata['uniqid']); $form .= sprintf('<input type=hidden name="p" value="forward">'); if (!$ok) { #0011860: forward to friend, multiple emails if (FORWARD_EMAIL_COUNT == 1) { $form .= '<br /><h2>' . $GLOBALS['strForwardEnterEmail'] . '</h2>'; $form .= sprintf('<input type=text name="email" value="%s" size=50 class="attributeinput">', $forwardemail); } else { $form .= '<br /><h2>' . sprintf($GLOBALS['strForwardEnterEmails'], FORWARD_EMAIL_COUNT) . '</h2>'; $form .= sprintf('<textarea name="email" rows="10" cols="50" class="attributeinput">%s</textarea>', $forwardemail); } #0011996: forward to friend - personal message if (FORWARD_PERSONAL_NOTE_SIZE) { $form .= sprintf('<h2>' . $GLOBALS['strForwardPersonalNote'] . '</h2>', FORWARD_PERSONAL_NOTE_SIZE); $cols = 50; $rows = min(10, ceil(FORWARD_PERSONAL_NOTE_SIZE / 40)); $form .= sprintf('<br/><textarea type="text" name="personalNote" rows="%d" cols="%d" class="attributeinput">%s</textarea>', $rows, $cols, $personalNote); } $form .= sprintf('<br /><input type="submit" value="%s"></form>', $GLOBALS['strContinue']); } ### END BAS ### Michiel, remote response page $remote_content = ''; if (preg_match("/\\[URL:([^\\s]+)\\]/i", $messagedata['message'], $regs)) { if (isset($regs[1]) && strlen($regs[1])) { $url = $regs[1]; if (!preg_match('/^http/i', $url)) { $url = 'http://' . $url; } $remote_content = fetchUrl($url); } } if (!empty($remote_content) && preg_match('/\\[FORWARDFORM\\]/', $remote_content, $regs)) { if ($firstpage) { ## this is the initial page, not a follow up one. $remote_content = str_replace($regs[0], $info . $form, $remote_content); } else { $remote_content = str_replace($regs[0], $info, $remote_content); } $res = $remote_content; } else { $res = '<title>' . $GLOBALS['strForwardTitle'] . '</title>'; $res .= $GLOBALS['pagedata']['header']; $res .= '<h3>' . $subtitle . '</h3>'; if ($ok) { $res .= '<h4>' . $info . '</h4>'; } elseif (!empty($info)) { $res .= '<div class="error missing">' . $info . '</div>'; } $res .= $form; $res .= '<p>' . $GLOBALS['PoweredBy'] . '</p>'; $res .= $GLOBALS['pagedata']['footer']; } ### END MICHIEL return $res; }
print '<label>' . s('Name') . ':</label> <input type="text" name="name[' . $row['id'] . ']" value="' . htmlspecialchars(stripslashes(strip_tags($row['name']))) . '" size="40" />'; print '<label>' . s('Type') . ': </label> <!--<input type="hidden" name="type[' . $row['id'] . ']" value="' . $row['type'] . '">' . $row['type'] . '-->'; print '<select name="type[' . $row['id'] . ']" onchange="warn();">'; foreach ($types as $key => $val) { printf('<option value="%s" %s>%s</option>', $val, $val == $row['type'] ? 'selected="selected"' : '', $GLOBALS['I18N']->get($val)); } print ' </select>'; if (defined('IN_WEBBLER') && IN_WEBBLER || defined('WEBBLER') && WEBBLER) { if ($row['type'] == 'select' || $row['type'] == 'radio' || $row['type'] == 'checkboxgroup') { print ' ' . $I18N->get('authoritative list') . ' '; printf('<select name="keywordlib[%d]"><option value="">-- select</option>', $row['id']); $req = Sql_Query(sprintf('select id,name from keywordlib order by listorder,name')); while ($kwlib = Sql_Fetch_Array($req)) { printf('<option value="%d" %s>%s</option>', $kwlib['id'], $row['keywordlib'] == $kwlib['id'] ? 'selected="selected"' : '', htmlspecialchars($kwlib['name'])); } print '</select>'; } } if ((!defined('IN_WEBBLER') || !IN_WEBBLER) && (!defined('WEBBLER') || !WEBBLER)) { if ($row['type'] == 'select' || $row['type'] == 'radio' || $row['type'] == 'checkboxgroup') { print PageLinkButton('editattributes&id=' . $row['id'], $I18N->get('edit values')); } } print '<label>' . $GLOBALS['I18N']->get('Default Value') . ':</label> <input type="text" name="default[' . $row['id'] . ']" value="' . htmlspecialchars(stripslashes($row['default_value'])) . '" size="40" />'; print '<label>' . $GLOBALS['I18N']->get('Order of Listing') . ':</label> <input type="text" name="listorder[' . $row['id'] . ']" value="' . $row['listorder'] . '" size="5" />'; print '<label>' . $GLOBALS['I18N']->get('Is this attribute required ?') . '<input type="checkbox" name="required[' . $row['id'] . ']" value="1" ';
function mergeUser($userid) { $duplicate = Sql_Fetch_Array_Query("select * from {$GLOBALS['tables']['user']} where id = {$userid}"); printf('<br/>%s', $duplicate['email']); if (preg_match('/^duplicate[^ ]* (.*)/', $duplicate['email'], $regs)) { print '-> ' . $regs[1]; $email = $regs[1]; } elseif (preg_match("/^([^ ]+@[^ ]+) \\(\\d+\\)/", $duplicate['email'], $regs)) { print '-> ' . $regs[1]; $email = $regs[1]; } else { $email = ''; } if ($email) { $orig = Sql_Fetch_Row_Query(sprintf('select id from %s where email = "%s"', $GLOBALS['tables']['user'], $email)); if ($orig[0]) { print ' ' . $GLOBALS['I18N']->get('user found'); $umreq = Sql_Query("select * from {$GLOBALS['tables']['usermessage']} where userid = " . $duplicate['id']); while ($um = Sql_Fetch_Array($umreq)) { Sql_Query(sprintf('update %s set userid = %d, entered = "%s" where userid = %d and entered = "%s"', $GLOBALS['tables']['usermessage'], $orig[0], $um['entered'], $duplicate['id'], $um['entered']), 1); } $bncreq = Sql_Query("select * from {$GLOBALS['tables']['user_message_bounce']} where user = "******"%s" where user = %d and time = "%s"', $GLOBALS['tables']['user_message_bounce'], $orig[0], $bnc['time'], $duplicate['id'], $bnc['time']), 1); } Sql_Query("delete from {$GLOBALS['tables']['listuser']} where userid = " . $duplicate['id']); Sql_Query("delete from {$GLOBALS['tables']['user_message_bounce']} where user = "******"delete from {$GLOBALS['tables']['usermessage']} where userid = " . $duplicate['id']); if (MERGE_DUPLICATES_DELETE_DUPLICATE) { deleteUser($duplicate['id']); } } else { print ' ' . $GLOBALS['I18N']->get('no user found'); # so it must be save to rename the original to the actual email Sql_Query(sprintf('update %s set email = "%s" where id = %d', $GLOBALS['tables']['user'], $email, $userid)); } flush(); } else { print '-> ' . $GLOBALS['I18N']->get('unable to find original email'); } }
$att_content .= sprintf('<div><b>%s</b> %s:</div><div><input type="text" name="localattachment%d" size="50"/></div>', $GLOBALS['I18N']->get('or'), $GLOBALS['I18N']->get('Path to file on server'), $att_cnt, $att_cnt); } $att_content .= sprintf('<div>%s:</div> <div><textarea name="attachment%d_description" cols="65" rows="3" wrap="virtual"></textarea></div>', $GLOBALS['I18N']->get('Description of attachment'), $att_cnt); } $att_content .= '</div>'; # $shader = new WebblerShader("Attachments"); # $shader->addContent($att_content); # $shader->initialstate = 'closed'; # print $shader->display(); } // Load the email address for the admin user so we can use that as the default value in the testtarget field # @@@ this only works with phplist authentication, needs to be abstracted if (!isset($messagedata['testtarget'])) { $res = Sql_Query(sprintf('Select email from %s where id = %d', $tables['admin'], $_SESSION['logindetails']['id'])); $admin_details = Sql_Fetch_Array($res); $messagedata['testtarget'] = $admin_details['email']; } // if there isn't one, load the developer one, just being lazy here :-) if (empty($messagedata['testtarget']) && isset($GLOBALS['developer_email'])) { $messagedata['testtarget'] = $GLOBALS['developer_email']; } // Display the HTML for the "Send Test" button, and the input field for the email addresses $sendtest_content = '<div class="sendTest" id="sendTest"> ' . $sendtestresult . ' <input class="submit" type="submit" name="sendtest" value="' . s('Send Test') . '" /> ' . Help('sendtest') . ' ' . s('to email address(es)') . ':' . '<input type="text" name="testtarget" size="40" value="' . $messagedata['testtarget'] . '"/><br />' . s('(comma separate addresses - all must be existing subscribers)') . ' </div>'; # notification of progress of message sending # defaulting to admin_details['email'] gives the wrong impression that this is the # value in the database, so it is better to leave that empty instead $notify_start = isset($messagedata['notify_start']) ? $messagedata['notify_start'] : '';
function repeatMessage($msgid) { # if (!USE_REPETITION && !USE_rss) return; $data = loadMessageData($msgid); ## do not repeat when it has already been done if (!empty($data['repeatedid'])) { return; } # get the future embargo, either "repeat" minutes after the old embargo # or "repeat" after this very moment to make sure that we're not sending the # message every time running the queue when there's no embargo set. $msgdata = Sql_Fetch_Array_Query(sprintf('select *,date_add(embargo,interval repeatinterval minute) as newembargo, date_add(now(),interval repeatinterval minute) as newembargo2, date_add(embargo,interval repeatinterval minute) > now() as isfuture from %s where id = %d and repeatuntil > now()', $GLOBALS["tables"]["message"], $msgid)); if (!$msgdata["id"] || !$msgdata["repeatinterval"]) { return; } # copy the new message $query = ' insert into ' . $GLOBALS['tables']['message'] . ' (entered)' . ' values' . ' (current_timestamp)'; Sql_Query($query); $newid = Sql_Insert_Id($GLOBALS['tables']['message'], 'id'); require dirname(__FILE__) . '/structure.php'; if (!is_array($DBstruct["message"])) { logEvent("Error including structure when trying to duplicate message {$msgid}"); return; } foreach ($DBstruct["message"] as $column => $rec) { if ($column != "id" && $column != "entered" && $column != "sendstart") { Sql_Query(sprintf('update %s set %s = "%s" where id = %d', $GLOBALS["tables"]["message"], $column, addslashes($msgdata[$column]), $newid)); } } $req = Sql_Query(sprintf('select * from %s where id = %d', $GLOBALS['tables']['messagedata'], $msgid)); while ($row = Sql_Fetch_Array($req)) { setMessageData($newid, $row['name'], $row['data']); } # check whether the new embargo is not on an exclusion if (isset($GLOBALS["repeat_exclude"]) && is_array($GLOBALS["repeat_exclude"])) { $repeatinterval = $msgdata["repeatinterval"]; $loopcnt = 0; while (excludedDateForRepetition($msgdata["newembargo"])) { $repeat += $msgdata["repeatinterval"]; $loopcnt++; $msgdata = Sql_Fetch_Array_Query(sprintf('select *,date_add(embargo,interval %d minute) as newembargo, date_add(current_timestamp,interval %d minute) as newembargo2, date_add(embargo,interval %d minute) > current_timestamp as isfuture from %s where id = %d and repeatuntil > current_timestamp', $repeatinterval, $repeatinterval, $repeatinterval, $GLOBALS["tables"]["message"], $msgid)); if ($loopcnt > 15) { logEvent("Unable to find new embargo date too many exclusions? for message {$msgid}"); return; } } } # correct some values if (!$msgdata["isfuture"]) { $msgdata["newembargo"] = $msgdata["newembargo2"]; } Sql_Query(sprintf('update %s set embargo = "%s",status = "submitted",sent = "" where id = %d', $GLOBALS["tables"]["message"], $msgdata["newembargo"], $newid)); list($e['year'], $e['month'], $e['day'], $e['hour'], $e['minute'], $e['second']) = sscanf($msgdata["newembargo"], '%04d-%02d-%02d %02d:%02d:%02d'); unset($e['second']); setMessageData($newid, 'embargo', $e); foreach (array("processed", "astext", "ashtml", "astextandhtml", "aspdf", "astextandpdf", "viewed", "bouncecount") as $item) { Sql_Query(sprintf('update %s set %s = 0 where id = %d', $GLOBALS["tables"]["message"], $item, $newid)); } # lists $req = Sql_Query(sprintf('select listid from %s where messageid = %d', $GLOBALS["tables"]["listmessage"], $msgid)); while ($row = Sql_Fetch_Row($req)) { Sql_Query(sprintf('insert into %s (messageid,listid,entered) values(%d,%d,current_timestamp)', $GLOBALS["tables"]["listmessage"], $newid, $row[0])); } # attachments $req = Sql_Query(sprintf('select * from %s,%s where %s.messageid = %d and %s.attachmentid = %s.id', $GLOBALS["tables"]["message_attachment"], $GLOBALS["tables"]["attachment"], $GLOBALS["tables"]["message_attachment"], $msgid, $GLOBALS["tables"]["message_attachment"], $GLOBALS["tables"]["attachment"])); while ($row = Sql_Fetch_Array($req)) { if (is_file($row["remotefile"])) { # if the "remote file" is actually local, we want to refresh the attachment, so we set # filename to nothing $row["filename"] = ""; } Sql_Query(sprintf('insert into %s (filename,remotefile,mimetype,description,size) values("%s","%s","%s","%s",%d)', $GLOBALS["tables"]["attachment"], addslashes($row["filename"]), addslashes($row["remotefile"]), addslashes($row["mimetype"]), addslashes($row["description"]), $row["size"])); $attid = Sql_Insert_Id($GLOBALS['tables']['attachment'], 'id'); Sql_Query(sprintf('insert into %s (messageid,attachmentid) values(%d,%d)', $GLOBALS["tables"]["message_attachment"], $newid, $attid)); } logEvent("Message {$msgid} was successfully rescheduled as message {$newid}"); ## remember we duplicated, in order to avoid doing it again (eg when requeuing) setMessageData($msgid, 'repeatedid', $newid); }
function repeatMessage($msgid) { # if (!USE_REPETITION && !USE_RSS) return; # get the future embargo, either "repeat" minutes after the old embargo # or "repeat" after this very moment to make sure that we're not sending the # message every time running the queue when there's no embargo set. $msgdata = Sql_Fetch_Array_Query(sprintf('select *,date_add(embargo,interval repeatinterval minute) as newembargo, date_add(now(),interval repeatinterval minute) as newembargo2, date_add(embargo,interval repeatinterval minute) > now() as isfuture from %s where id = %d and repeatuntil > now()', $GLOBALS["tables"]["message"], $msgid)); if (!$msgdata["id"] || !$msgdata["repeatinterval"]) { return; } # copy the new message Sql_Query(sprintf(' insert into %s (entered) values(now())', $GLOBALS["tables"]["message"])); $id = Sql_Insert_id(); require dirname(__FILE__) . '/structure.php'; if (!is_array($DBstruct["message"])) { logEvent("Error including structure when trying to duplicate message {$msgid}"); return; } foreach ($DBstruct["message"] as $column => $rec) { if ($column != "id" && $column != "entered" && $column != "sendstart") { Sql_Query(sprintf('update %s set %s = "%s" where id = %d', $GLOBALS["tables"]["message"], $column, addslashes($msgdata[$column]), $id)); } } $req = Sql_Query(sprintf('select * from %s where id = %d', $GLOBALS['tables']['messagedata'], $msgid)); while ($row = Sql_Fetch_Array($req)) { Sql_Query(sprintf('insert into %s (name,id,data) values("%s",%d,"%s")', $GLOBALS['tables']['messagedata'], $row['name'], $id, addslashes($row['data']))); } # check whether the new embargo is not on an exclusion if (is_array($GLOBALS["repeat_exclude"])) { $repeatinterval = $msgdata["repeatinterval"]; $loopcnt = 0; while (excludedDateForRepetition($msgdata["newembargo"])) { $repeatinterval += $msgdata["repeatinterval"]; $loopcnt++; $msgdata = Sql_Fetch_Array_Query(sprintf('select *,date_add(embargo,interval %d minute) as newembargo, date_add(now(),interval %d minute) as newembargo2, date_add(embargo,interval %d minute) > now() as isfuture from %s where id = %d and repeatuntil > now()', $repeatinterval, $repeatinterval, $repeatinterval, $GLOBALS["tables"]["message"], $msgid)); if ($loopcnt > 15) { logEvent("Unable to find new embargo date too many exclusions? for message {$msgid}"); return; } } } # correct some values if (!$msgdata["isfuture"]) { $msgdata["newembargo"] = $msgdata["newembargo2"]; } Sql_Query(sprintf('update %s set embargo = "%s",status = "submitted",sent = "" where id = %d', $GLOBALS["tables"]["message"], $msgdata["newembargo"], $id)); // bug 0009687: maybe add "ashtml","astextandhtml" and put them in ashtml? foreach (array("processed", "astext", "ashtml", "astextandhtml", "aspdf", "astextandpdf", "viewed", "bouncecount") as $item) { Sql_Query(sprintf('update %s set %s = 0 where id = %d', $GLOBALS["tables"]["message"], $item, $id)); } # lists $req = Sql_Query(sprintf('select listid from %s where messageid = %d', $GLOBALS["tables"]["listmessage"], $msgid)); while ($row = Sql_Fetch_Row($req)) { Sql_Query(sprintf('insert into %s (messageid,listid,entered) values(%d,%d,now())', $GLOBALS["tables"]["listmessage"], $id, $row[0])); } # attachments $req = Sql_Query(sprintf('select * from %s,%s where %s.messageid = %d and %s.attachmentid = %s.id', $GLOBALS["tables"]["message_attachment"], $GLOBALS["tables"]["attachment"], $GLOBALS["tables"]["message_attachment"], $msgid, $GLOBALS["tables"]["message_attachment"], $GLOBALS["tables"]["attachment"])); while ($row = Sql_Fetch_Array($req)) { if (is_file($row["remotefile"])) { # if the "remote file" is actually local, we want to refresh the attachment, so we set # filename to nothing $row["filename"] = ""; } Sql_Query(sprintf('insert into %s (filename,remotefile,mimetype,description,size) values("%s","%s","%s","%s",%d)', $GLOBALS["tables"]["attachment"], addslashes($row["filename"]), addslashes($row["remotefile"]), addslashes($row["mimetype"]), addslashes($row["description"]), $row["size"])); $attid = Sql_Insert_id(); Sql_Query(sprintf('insert into %s (messageid,attachmentid) values(%d,%d)', $GLOBALS["tables"]["message_attachment"], $id, $attid)); } logEvent("Message {$msgid} was successfully rescheduled as message {$id}"); }
$att_value = $val[0]; break; default: $att_value = $value; break; } Sql_query(sprintf('replace into %s (adminattributeid,adminid,value) values("%s","%s","%s")', $tables["admin_attribute"], $attribute_index, $adminid, $att_value)); } } if ($createlist) { Sql_Query(sprintf('insert into %s (name,description,active,owner) values("%s","%s",1,%d)', $tables["list"], $loginname, $GLOBALS['I18N']->get('List for') . " {$loginname}", $adminid)); } # copy permissions from the default set $req = Sql_Query(sprintf('select * from %s where adminid = 0', $tables["admin_task"])); while ($task = Sql_Fetch_Array($req)) { Sql_Query(sprintf('insert into %s (adminid,taskid,level) values(%d,%d,%d)', $tables["admin_task"], $adminid, $task["taskid"], $task["level"])); } } // end if } } // end while print '<script language="Javascript" type="text/javascript"> finish(); </script>'; # let's be grammatically correct :-) $dispemail = $count_email_add == 1 ? $GLOBALS['I18N']->get('new email was') . " " : $GLOBALS['I18N']->get('new emails were') . " "; $dispemail2 = $additional_emails == 1 ? $GLOBALS['I18N']->get('email was') . " " : $GLOBALS['I18N']->get('emails were') . " "; if (!$some && !$additional_emails) { print "<br>" . $GLOBALS['I18N']->get("All the emails already exist in the database"); } else {
break; case "checkboxgroup": $valreq = Sql_Query(sprintf('select name from %slistattr_%s where id in (%s)', sql_escape($_POST["remote_prefix"]), $att["tablename"], $att["value"])); while ($vals = Sql_fetch_Row($valreq)) { $value .= $vals[0] . ','; } break; } $att["displayvalue"] = $value; array_push($useratt, $att); } $userlists = array(); $userlists = array_merge($_POST["lists"], $userlists); if ($_POST["copyremotelists"]) { $req = Sql_Query("select * from {$remote_tables["listuser"]},\n {$remote_tables["list"]} where {$remote_tables["listuser"]}.listid =\n {$remote_tables["list"]}.id and {$remote_tables["listuser"]}.userid = {$user['0']}"); while ($list = Sql_Fetch_Array($req)) { # print $list["name"]."<br/>"; array_push($userlists, $list); } } connectLocal(); foreach ($useratt as $att) { $localattid = $attributemap[$att["attributeid"]]; if (!localattid) { print $GLOBALS['I18N']->get('Error, no mapped attribute for') . " " . $att["name"] . "<br/>"; } else { $tname = Sql_Fetch_Row_Query("select tablename from {$tables["attribute"]} where id = {$localattid}"); switch ($att["type"]) { case "select": case "radio": $valueid = Sql_Fetch_Row_Query(sprintf('select id from %slistattr_%s where name = "%s"', $table_prefix, $tname[0], $att["displayvalue"]));
function precacheMessage($messageid, $forwardContent = 0) { global $cached; $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; } } if (VERBOSE && !empty($GLOBALS['getspeedstats'])) { output('fetch URL end'); } /* print $message['sendurl']; print $remote_content;exit; */ } // end if not userspecific url if ($cached[$messageid]["htmlformatted"]) { # $cached[$messageid]["content"] = compressContent($cached[$messageid]["content"]); } $cached[$messageid]['google_track'] = $message['google_track']; /* else { print $message['sendurl']; exit; } */ if (VERBOSE && !empty($GLOBALS['getspeedstats'])) { output('parse config start'); } /* * this is not a good idea, as it'll replace eg "unsubscribeurl" with a general one instead of personalised * if (is_array($GLOBALS["default_config"])) { foreach($GLOBALS["default_config"] as $key => $val) { if (is_array($val)) { $cached[$messageid]['content'] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]['content']); $cached[$messageid]["textcontent"] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]["textcontent"]); $cached[$messageid]["textfooter"] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]['textfooter']); $cached[$messageid]["htmlfooter"] = str_ireplace("[$key]",getConfig($key),$cached[$messageid]['htmlfooter']); } } } */ if (VERBOSE && !empty($GLOBALS['getspeedstats'])) { output('parse config end'); } ## ##17233 not that many fields are actually useful, so don't blatantly use all # foreach($message as $key => $val) { foreach (array('subject', 'id', 'fromname', 'fromemail') as $key) { $val = $message[$key]; if (!is_array($val)) { $cached[$messageid]['content'] = str_ireplace("[{$key}]", $val, $cached[$messageid]['content']); $cached[$messageid]["textcontent"] = str_ireplace("[{$key}]", $val, $cached[$messageid]["textcontent"]); $cached[$messageid]["textfooter"] = str_ireplace("[{$key}]", $val, $cached[$messageid]['textfooter']); $cached[$messageid]["htmlfooter"] = str_ireplace("[{$key}]", $val, $cached[$messageid]['htmlfooter']); } } if (preg_match("/##LISTOWNER=(.*)/", $cached[$messageid]['content'], $regs)) { $cached[$messageid]['listowner'] = $regs[1]; $cached[$messageid]['content'] = str_replace($regs[0], "", $cached[$messageid]['content']); } else { $cached[$messageid]['listowner'] = 0; } if (!empty($cached[$messageid]['listowner'])) { $att_req = Sql_Query("select name,value from {$GLOBALS["tables"]["adminattribute"]},{$GLOBALS["tables"]["admin_attribute"]} where {$GLOBALS["tables"]["adminattribute"]}.id = {$GLOBALS["tables"]["admin_attribute"]}.adminattributeid and {$GLOBALS["tables"]["admin_attribute"]}.adminid = " . $cached[$messageid]['listowner']); while ($att = Sql_Fetch_Array($att_req)) { $cached[$messageid]['content'] = preg_replace("#\\[LISTOWNER." . strtoupper(preg_quote($att["name"])) . "\\]#", $att["value"], $cached[$messageid]['content']); } } $baseurl = $GLOBALS['website']; if (defined('UPLOADIMAGES_DIR') && UPLOADIMAGES_DIR) { ## escape subdirectories, otherwise this renders empty $dir = str_replace('/', '\\/', UPLOADIMAGES_DIR); $cached[$messageid]['content'] = preg_replace('/<img(.*)src="\\/' . $dir . '(.*)>/iU', '<img\\1src="' . $GLOBALS['public_scheme'] . '://' . $baseurl . '/' . UPLOADIMAGES_DIR . '\\2>', $cached[$messageid]['content']); } //if (defined('FCKIMAGES_DIR') && FCKIMAGES_DIR) { //$cached[$messageid]['content'] = preg_replace('/<img(.*)src="\/lists\/'.FCKIMAGES_DIR.'(.*)>/iU','<img\\1src="'.$GLOBALS['public_scheme'].'://'.$baseurl.'/lists/'.FCKIMAGES_DIR.'\\2>',$cached[$messageid]['content']); //} return 1; }
function ListAllAttributes() { global $tables; $attributes = array(); $attributedata = array(); $res = Sql_Query("select * from {$GLOBALS['tables']['attribute']} order by listorder"); while ($row = Sql_Fetch_Array($res)) { # print $row["id"]. " ".$row["name"]; $attributes[$row['id']] = $row['listorder']; $attributedata[$row['id']]['id'] = $row['id']; $attributedata[$row['id']]['default_value'] = $row['default_value']; $attributedata[$row['id']]['listorder'] = $row['listorder']; $attributedata[$row['id']]['required'] = $row['required']; $attributedata[$row['id']]['default_value'] = $row['default_value']; } return ListAttributes($attributes, $attributedata, 'checkforhtml'); }
function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array(), $forwardedby = array()) { global $strThisLink, $PoweredByImage, $PoweredByText, $cached, $website; if ($email == "") { return 0; } #0013076: different content when forwarding 'to a friend' if (FORWARD_ALTERNATIVE_CONTENT) { $forwardContent = sizeof($forwardedby) > 0; $messagedata = loadMessageData($messageid); } else { $forwardContent = 0; } if (empty($cached[$messageid])) { $domain = getConfig("domain"); $message = Sql_query("select * from {$GLOBALS["tables"]["message"]} where id = {$messageid}"); $cached[$messageid] = array(); $message = Sql_fetch_array($message); if (ereg("([^ ]+@[^ ]+)", $message["fromfield"], $regs)) { # if there is an email in the from, rewrite it as "name <email>" $message["fromfield"] = ereg_replace($regs[0], "", $message["fromfield"]); $cached[$messageid]["fromemail"] = $regs[0]; # if the email has < and > take them out here $cached[$messageid]["fromemail"] = ereg_replace("<", "", $cached[$messageid]["fromemail"]); $cached[$messageid]["fromemail"] = ereg_replace(">", "", $cached[$messageid]["fromemail"]); # make sure there are no quotes around the name $cached[$messageid]["fromname"] = ereg_replace('"', "", ltrim(rtrim($message["fromfield"]))); } elseif (ereg(" ", $message["fromfield"], $regs)) { # if there is a space, we need to add the email $cached[$messageid]["fromname"] = $message["fromfield"]; $cached[$messageid]["fromemail"] = "listmaster@{$domain}"; } else { $cached[$messageid]["fromemail"] = $message["fromfield"] . "@{$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]["fromname"] = $message["fromfield"] . "@{$domain}"; } # erase double spacing while (ereg(" ", $cached[$messageid]["fromname"])) { $cached[$messageid]["fromname"] = eregi_replace(" ", " ", $cached[$messageid]["fromname"]); } ## this has weird effects when used with only one word, so take it out for now # $cached[$messageid]["fromname"] = eregi_replace("@","",$cached[$messageid]["fromname"]); $cached[$messageid]["fromname"] = trim($cached[$messageid]["fromname"]); $cached[$messageid]["to"] = $message["tofield"]; #0013076: different content when forwarding 'to a friend' $cached[$messageid]["subject"] = $forwardContent ? stripslashes($messagedata["forwardsubject"]) : $message["subject"]; $cached[$messageid]["replyto"] = $message["replyto"]; #0013076: different content when forwarding 'to a friend' $cached[$messageid]["content"] = $forwardContent ? stripslashes($messagedata["forwardmessage"]) : $message["message"]; if (USE_MANUAL_TEXT_PART && !$forwardContent) { $cached[$messageid]["textcontent"] = $message["textmessage"]; } else { $cached[$messageid]["textcontent"] = ''; } #0013076: different content when forwarding 'to a friend' $cached[$messageid]["footer"] = $forwardContent ? stripslashes($messagedata["forwardfooter"]) : $message["footer"]; $cached[$messageid]["htmlformatted"] = $message["htmlformatted"]; $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"] = getConfig("html_charset"); ## @@ need to check on validity of charset if (!$cached[$messageid]["html_charset"]) { $cached[$messageid]["html_charset"] = 'iso-8859-1'; } $cached[$messageid]["text_charset"] = getConfig("text_charset"); if (!$cached[$messageid]["text_charset"]) { $cached[$messageid]["text_charset"] = 'iso-8859-1'; } } # else # dbg("Using cached {$cached[$messageid]["fromemail"]}"); if (VERBOSE) { output($GLOBALS['I18N']->get('sendingmessage') . ' ' . $messageid . ' ' . $GLOBALS['I18N']->get('withsubject') . ' ' . $cached[$messageid]["subject"] . ' ' . $GLOBALS['I18N']->get('to') . ' ' . $email); } # erase any placeholders that were not found # $msg = ereg_replace("\[[A-Z ]+\]","",$msg); #0011857: forward to friend, retain attributes if ($hash == 'forwarded' && defined('KEEPFORWARDERATTRIBUTES') && KEEPFORWARDERATTRIBUTES) { $user_att_values = getUserAttributeValues($forwardedby['email']); } else { $user_att_values = getUserAttributeValues($email); } $userdata = Sql_Fetch_Assoc_Query(sprintf('select * from %s where email = "%s"', $GLOBALS["tables"]["user"], $email)); $url = getConfig("unsubscribeurl"); $sep = ereg('\\?', $url) ? '&' : '?'; $html["unsubscribe"] = sprintf('<a href="%s%suid=%s">%s</a>', $url, $sep, $hash, $strThisLink); $text["unsubscribe"] = sprintf('%s%suid=%s', $url, $sep, $hash); $html["unsubscribeurl"] = sprintf('%s%suid=%s', $url, $sep, $hash); $text["unsubscribeurl"] = sprintf('%s%suid=%s', $url, $sep, $hash); #0013076: Blacklisting posibility for unknown users $url = getConfig("blacklisturl"); $sep = ereg('\\?', $url) ? '&' : '?'; $html["blacklist"] = sprintf('<a href="%s%semail=%s">%s</a>', $url, $sep, $email, $strThisLink); $text["blacklist"] = sprintf('%s%semail=%s', $url, $sep, $email); $html["blacklisturl"] = sprintf('%s%semail=%s', $url, $sep, $email); $text["blacklisturl"] = sprintf('%s%semail=%s', $url, $sep, $email); #0013076: Problem found during testing: mesage part must be parsed correctly as well. if ($forwardContent) { $html["unsubscribe"] = $html["blacklist"]; $text["unsubscribe"] = $text["blacklist"]; } $url = getConfig("subscribeurl"); $sep = ereg('\\?', $url) ? '&' : '?'; $html["subscribe"] = sprintf('<a href="%s">%s</a>', $url, $strThisLink); $text["subscribe"] = sprintf('%s', $url); $html["subscribeurl"] = sprintf('%s', $url); $text["subscribeurl"] = sprintf('%s', $url); #?mid=1&id=1&uid=a9f35f130593a3d6b89cfe5cfb32a0d8&p=forward&email=michiel%40tincan.co.uk& $url = getConfig("forwardurl"); $sep = ereg('\\?', $url) ? '&' : '?'; $html["forward"] = sprintf('<a href="%s%suid=%s&mid=%d">%s</a>', $url, $sep, $hash, $messageid, $strThisLink); $text["forward"] = sprintf('%s%suid=%s&mid=%d', $url, $sep, $hash, $messageid); $html["forwardurl"] = sprintf('%s%suid=%s&mid=%d', $url, $sep, $hash, $messageid); $text["forwardurl"] = $text["forward"]; $url = getConfig("forwardurl"); # make sure there are no newlines, otherwise they get turned into <br/>s $html["forwardform"] = sprintf('<form method="get" action="%s" name="forwardform" class="forwardform"><input type=hidden name="uid" value="%s" /><input type=hidden name="mid" value="%d" /><input type=hidden name="p" value="forward" /><input type=text name="email" value="" class="forwardinput" /><input name="Send" type="submit" value="%s" class="forwardsubmit"/></form>', $url, $hash, $messageid, $GLOBALS['strForward']); $text["signature"] = "\n\n--\nPowered by PHPlist, www.phplist.com --\n\n"; $url = getConfig("preferencesurl"); $sep = ereg('\\?', $url) ? '&' : '?'; $html["preferences"] = sprintf('<a href="%s%suid=%s">%s</a>', $url, $sep, $hash, $strThisLink); $text["preferences"] = sprintf('%s%suid=%s', $url, $sep, $hash); $html["preferencesurl"] = sprintf('%s%suid=%s', $url, $sep, $hash); $text["preferencesurl"] = sprintf('%s%suid=%s', $url, $sep, $hash); /* 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"); $adddefaultstyle = 0; if ($cached[$messageid]["template"]) { # template used $htmlmessage = eregi_replace("\\[CONTENT\\]", $htmlcontent, $cached[$messageid]["template"]); } else { # no template used $htmlmessage = $htmlcontent; $adddefaultstyle = 1; } $textmessage = $textcontent; ## Parse placeholders #0013076: Blacklisting posibility for unknown users foreach (array("forwardform", "subscribe", "preferences", "unsubscribe", "signature", 'blacklist') as $item) { if (eregi('\\[' . $item . '\\]', $htmlmessage, $regs)) { $htmlmessage = eregi_replace('\\[' . $item . '\\]', $html[$item], $htmlmessage); // unset($html[$item]); //ASK: Why was this done? It breaks placeholders in the footer } if (eregi('\\[' . $item . '\\]', $textmessage, $regs)) { $textmessage = eregi_replace('\\[' . $item . '\\]', $text[$item], $textmessage); // unset($text[$item]); } } #0013076: Blacklisting posibility for unknown users foreach (array("forward", "forwardurl", "subscribeurl", "preferencesurl", "unsubscribeurl", 'blacklisturl') as $item) { if (eregi('\\[' . $item . '\\]', $htmlmessage, $regs)) { $htmlmessage = eregi_replace('\\[' . $item . '\\]', $html[$item], $htmlmessage); } if (eregi('\\[' . $item . '\\]', $textmessage, $regs)) { $textmessage = eregi_replace('\\[' . $item . '\\]', $text[$item], $textmessage); } } if ($hash != 'forwarded') { $text['footer'] = $cached[$messageid]["footer"]; $html['footer'] = $cached[$messageid]["footer"]; } else { #0013076: different content when forwarding 'to a friend' if (FORWARD_ALTERNATIVE_CONTENT) { $text['footer'] = stripslashes($messagedata["forwardfooter"]); } else { $text['footer'] = getConfig('forwardfooter'); } $html['footer'] = $text['footer']; } $text["footer"] = eregi_replace("\\[SUBSCRIBE\\]", $text["subscribe"], $text['footer']); $html["footer"] = eregi_replace("\\[SUBSCRIBE\\]", $html["subscribe"], $html['footer']); $text["footer"] = eregi_replace("\\[PREFERENCES\\]", $text["preferences"], $text["footer"]); $html["footer"] = eregi_replace("\\[PREFERENCES\\]", $html["preferences"], $html["footer"]); $text["footer"] = eregi_replace("\\[FORWARD\\]", $text["forward"], $text["footer"]); $html["footer"] = eregi_replace("\\[FORWARD\\]", $html["forward"], $html["footer"]); $html["footer"] = eregi_replace("\\[FORWARDFORM\\]", $html["forwardform"], $html["footer"]); if (sizeof($forwardedby) && isset($forwardedby['email'])) { $htmlmessage = eregi_replace("\\[FORWARDEDBY]", $forwardedby["email"], $htmlmessage); $textmessage = eregi_replace("\\[FORWARDEDBY]", $forwardedby["email"], $textmessage); $html["footer"] = eregi_replace("\\[FORWARDEDBY]", $forwardedby["email"], $html["footer"]); $text["footer"] = eregi_replace("\\[FORWARDEDBY]", $forwardedby["email"], $text["footer"]); $text["footer"] = eregi_replace("\\[BLACKLIST\\]", $text["blacklist"], $text['footer']); $html["footer"] = eregi_replace("\\[BLACKLIST\\]", $html["blacklist"], $html['footer']); $text["footer"] = eregi_replace("\\[UNSUBSCRIBE\\]", $text["blacklist"], $text['footer']); $html["footer"] = eregi_replace("\\[UNSUBSCRIBE\\]", $html["blacklist"], $html['footer']); } else { $text["footer"] = eregi_replace("\\[UNSUBSCRIBE\\]", $text["unsubscribe"], $text['footer']); $html["footer"] = eregi_replace("\\[UNSUBSCRIBE\\]", $html["unsubscribe"], $html['footer']); } $html["footer"] = '<div class="emailfooter">' . nl2br($html["footer"]) . '</div>'; if (eregi("\\[FOOTER\\]", $htmlmessage)) { $htmlmessage = eregi_replace("\\[FOOTER\\]", $html["footer"], $htmlmessage); } elseif ($html["footer"]) { $htmlmessage = addHTMLFooter($htmlmessage, '<br /><br />' . $html["footer"]); } if (eregi("\\[SIGNATURE\\]", $htmlmessage)) { $htmlmessage = eregi_replace("\\[SIGNATURE\\]", $html["signature"], $htmlmessage); } elseif ($html["signature"]) { $htmlmessage .= '<br />' . $html["signature"]; } if (eregi("\\[FOOTER\\]", $textmessage)) { $textmessage = eregi_replace("\\[FOOTER\\]", $text["footer"], $textmessage); } else { $textmessage .= "\n\n" . $text["footer"]; } if (eregi("\\[SIGNATURE\\]", $textmessage)) { $textmessage = eregi_replace("\\[SIGNATURE\\]", $text["signature"], $textmessage); } else { $textmessage .= "\n" . $text["signature"]; } # $req = Sql_Query(sprintf('select filename,data from %s where template = %d', # $GLOBALS["tables"]["templateimage"],$cached[$messageid]["templateid"])); $htmlmessage = eregi_replace("\\[USERID\\]", $hash, $htmlmessage); $textmessage = eregi_replace("\\[USERID\\]", $hash, $textmessage); $htmlmessage = preg_replace("/\\[USERTRACK\\]/i", '<img src="' . $GLOBALS['scheme'] . '://' . $website . $GLOBALS["pageroot"] . '/ut.php?u=' . $hash . '&m=' . $messageid . '" width="1" height="1" border="0">', $htmlmessage, 1); $htmlmessage = eregi_replace("\\[USERTRACK\\]", '', $htmlmessage); if ($listowner) { $att_req = Sql_Query("select name,value from {$GLOBALS["tables"]["adminattribute"]},{$GLOBALS["tables"]["admin_attribute"]} where {$GLOBALS["tables"]["adminattribute"]}.id = {$GLOBALS["tables"]["admin_attribute"]}.adminattributeid and {$GLOBALS["tables"]["admin_attribute"]}.adminid = {$listowner}"); while ($att = Sql_Fetch_Array($att_req)) { $htmlmessage = preg_replace("#\\[LISTOWNER." . strtoupper(preg_quote($att["name"])) . "\\]#", $att["value"], $htmlmessage); } } if (is_array($GLOBALS["default_config"])) { foreach ($GLOBALS["default_config"] as $key => $val) { if (is_array($val)) { $htmlmessage = eregi_replace("\\[{$key}\\]", getConfig($key), $htmlmessage); $textmessage = eregi_replace("\\[{$key}\\]", getConfig($key), $textmessage); } } } ## RSS if (ENABLE_RSS && sizeof($rssitems)) { $rssentries = array(); $request = join(",", $rssitems); $texttemplate = getConfig("rsstexttemplate"); $htmltemplate = getConfig("rsshtmltemplate"); $textseparatortemplate = getConfig("rsstextseparatortemplate"); $htmlseparatortemplate = getConfig("rsshtmlseparatortemplate"); $req = Sql_Query("select * from {$GLOBALS["tables"]["rssitem"]} where id in ({$request}) order by list,added"); $curlist = ""; while ($row = Sql_Fetch_array($req)) { if ($curlist != $row["list"]) { $row["listname"] = ListName($row["list"]); $curlist = $row["list"]; $rssentries["text"] .= parseRSSTemplate($textseparatortemplate, $row); $rssentries["html"] .= parseRSSTemplate($htmlseparatortemplate, $row); } $data_req = Sql_Query("select * from {$GLOBALS["tables"]["rssitem_data"]} where itemid = {$row["id"]}"); while ($data = Sql_Fetch_Array($data_req)) { $row[$data["tag"]] = $data["data"]; } $rssentries["text"] .= stripHTML(parseRSSTemplate($texttemplate, $row)); $rssentries["html"] .= parseRSSTemplate($htmltemplate, $row); } $htmlmessage = eregi_replace("\\[RSS\\]", $rssentries["html"], $htmlmessage); $textmessage = eregi_replace("\\[RSS\\]", $rssentries["text"], $textmessage); } if (is_array($userdata)) { foreach ($userdata as $name => $value) { if (eregi("\\[" . $name . "\\]", $htmlmessage, $regs)) { $htmlmessage = eregi_replace("\\[" . $name . "\\]", $value, $htmlmessage); } if (eregi("\\[" . $name . "\\]", $textmessage, $regs)) { $textmessage = eregi_replace("\\[" . $name . "\\]", $value, $textmessage); } } } $destinationemail = ''; if (is_array($user_att_values)) { foreach ($user_att_values as $att_name => $att_value) { if (eregi("\\[" . $att_name . "\\]", $htmlmessage, $regs)) { # the value may be a multiline textarea field $htmlatt_value = str_replace("\n", "<br/>\n", $att_value); $htmlmessage = eregi_replace("\\[" . $att_name . "\\]", $htmlatt_value, $htmlmessage); } if (eregi("\\[" . $att_name . "\\]", $textmessage, $regs)) { $textmessage = eregi_replace("\\[" . $att_name . "\\]", $att_value, $textmessage); } # @@@ undocumented, use alternate field for real email to send to if (isset($GLOBALS["alternate_email"]) && strtolower($att_name) == strtolower($GLOBALS["alternate_email"])) { $destinationemail = $att_value; } } } if (!$destinationemail) { $destinationemail = $email; } if (!ereg('@', $destinationemail) && isset($GLOBALS["expand_unqualifiedemail"])) { $destinationemail .= $GLOBALS["expand_unqualifiedemail"]; } if (eregi("\\[LISTS\\]", $htmlmessage)) { $lists = ""; $listsarr = array(); $req = Sql_Query(sprintf('select list.name from %s as list,%s as listuser where list.id = listuser.listid and listuser.userid = %d', $GLOBALS["tables"]["list"], $GLOBALS["tables"]["listuser"], $user_system_values["id"])); while ($row = Sql_Fetch_Row($req)) { array_push($listsarr, $row[0]); } $lists_html = join('<br/>', $listsarr); $lists_text = join("\n", $listsarr); $htmlmessage = ereg_replace("\\[LISTS\\]", $lists_html, $htmlmessage); $textmessage = ereg_replace("\\[LISTS\\]", $lists_text, $textmessage); } ## click tracking # for now we won't click track forwards, as they are not necessarily users, so everything would fail if (CLICKTRACK && $hash != 'forwarded') { $urlbase = ''; # let's leave this for now /* if (preg_match('/<base href="(.*)"([^>]*)>/Umis',$htmlmessage,$regs)) { $urlbase = $regs[1]; } else { $urlbase = ''; } # print "URLBASE: $urlbase<br/>"; */ # convert html message # preg_match_all('/<a href="?([^> "]*)"?([^>]*)>(.*)<\/a>/Umis',$htmlmessage,$links); preg_match_all('/<a(.*)href=["\'](.*)["\']([^>]*)>(.*)<\\/a>/Umis', $htmlmessage, $links); # to process the Yahoo webpage with base href and link like <a href=link> we'd need this one # preg_match_all('/<a href=([^> ]*)([^>]*)>(.*)<\/a>/Umis',$htmlmessage,$links); $clicktrack_root = sprintf('%s://%s/lt.php', $GLOBALS["scheme"], $website . $GLOBALS["pageroot"]); for ($i = 0; $i < count($links[2]); $i++) { $link = cleanUrl($links[2][$i]); $link = str_replace('"', '', $link); if (preg_match('/\\.$/', $link)) { $link = substr($link, 0, -1); } $linkid = 0; # print "LINK: $link<br/>"; if ((preg_match('/^http|ftp/', $link) || preg_match('/^http|ftp/', $urlbase)) && $link != 'http://www.phplist.com' && !strpos($link, $clicktrack_root)) { # take off personal uids $url = cleanUrl($link, array('PHPSESSID', 'uid')); # $url = preg_replace('/&uid=[^\s&]+/','',$link); # if (!strpos('http:',$link)) { # $link = $urlbase . $link; # } $req = Sql_Query(sprintf('insert ignore into %s (messageid,userid,url,forward) values(%d,%d,"%s","%s")', $GLOBALS['tables']['linktrack'], $messageid, $userdata['id'], $url, addslashes($link))); $req = Sql_Fetch_Row_Query(sprintf('select linkid from %s where messageid = %s and userid = %d and forward = "%s" ', $GLOBALS['tables']['linktrack'], $messageid, $userdata['id'], $link)); $linkid = $req[0]; $masked = "H|{$linkid}|{$messageid}|" . $userdata['id'] ^ XORmask; $masked = urlencode(base64_encode($masked)); $newlink = sprintf('<a%shref="%s://%s/lt.php?id=%s" %s>%s</a>', $links[1][$i], $GLOBALS["scheme"], $website . $GLOBALS["pageroot"], $masked, $links[3][$i], $links[4][$i]); $htmlmessage = str_replace($links[0][$i], $newlink, $htmlmessage); } } # convert Text message # first find occurances of our top domain, to avoid replacing them later # hmm, this is no point, it's not just *our* topdomain, but any if (0) { preg_match_all('#(https?://' . $GLOBALS['website'] . '/?)\\s+#mis', $textmessage, $links); # preg_match_all('#(https?://[a-z0-9\./\#\?&:@=%\-]+)#ims',$textmessage,$links); # preg_match_all('!(https?:\/\/www\.[a-zA-Z0-9\.\/#~\?+=&%@-_]+)!mis',$textmessage,$links); for ($i = 0; $i < count($links[1]); $i++) { # not entirely sure why strtolower was used, but it seems to break things http://mantis.tincan.co.uk/view.php?id=4406 # $link = strtolower(cleanUrl($links[1][$i])); $link = cleanUrl($links[1][$i]); if (preg_match('/\\.$/', $link)) { $link = substr($link, 0, -1); } $linkid = 0; if (preg_match('/^http|ftp/', $link) && $link != 'http://www.phplist.com' && !strpos($link, $clicktrack_root)) { $url = cleanUrl($link, array('PHPSESSID', 'uid')); $req = Sql_Query(sprintf('insert ignore into %s (messageid,userid,url,forward) values(%d,%d,"%s","%s")', $GLOBALS['tables']['linktrack'], $messageid, $userdata['id'], $url, $link)); $req = Sql_Fetch_Row_Query(sprintf('select linkid from %s where messageid = %s and userid = %d and forward = "%s" ', $GLOBALS['tables']['linktrack'], $messageid, $userdata['id'], $link)); $linkid = $req[0]; $masked = "T|{$linkid}|{$messageid}|" . $userdata['id'] ^ XORmask; $masked = urlencode(base64_encode($masked)); $newlink = sprintf('%s://%s/lt.php?id=%s', $GLOBALS["scheme"], $website . $GLOBALS["pageroot"], $masked); $textmessage = str_replace($links[0][$i], '<' . $newlink . '>', $textmessage); } } } #now find the rest # @@@ needs to expand to find complete urls like: #http://user:password@www.web-site.com:1234/document.php?parameter=something&otherpar=somethingelse#anchor # or secure #https://user:password@www.website.com:2345/document.php?parameter=something%20&otherpar=somethingelse#anchor preg_match_all('#(https?://[^\\s\\>\\}\\,]+)#mis', $textmessage, $links); # preg_match_all('#(https?://[a-z0-9\./\#\?&:@=%\-]+)#ims',$textmessage,$links); # preg_match_all('!(https?:\/\/www\.[a-zA-Z0-9\.\/#~\?+=&%@-_]+)!mis',$textmessage,$links); ## sort the results in reverse order, so that they are replaced correctly rsort($links[1]); $newlinks = array(); for ($i = 0; $i < count($links[1]); $i++) { $link = cleanUrl($links[1][$i]); if (preg_match('/\\.$/', $link)) { $link = substr($link, 0, -1); } $linkid = 0; if (preg_match('/^http|ftp/', $link) && $link != 'http://www.phplist.com') { # && !strpos($link,$clicktrack_root)) { $url = cleanUrl($link, array('PHPSESSID', 'uid')); $req = Sql_Query(sprintf('insert ignore into %s (messageid,userid,url,forward) values(%d,%d,"%s","%s")', $GLOBALS['tables']['linktrack'], $messageid, $userdata['id'], $url, $link)); $req = Sql_Fetch_Row_Query(sprintf('select linkid from %s where messageid = %s and userid = %d and forward = "%s" ', $GLOBALS['tables']['linktrack'], $messageid, $userdata['id'], $link)); $linkid = $req[0]; $masked = "T|{$linkid}|{$messageid}|" . $userdata['id'] ^ XORmask; $masked = urlencode(base64_encode($masked)); $newlinks[$linkid] = sprintf('%s://%s/lt.php?id=%s', $GLOBALS["scheme"], $website . $GLOBALS["pageroot"], $masked); # print $links[0][$i] .' -> '.$newlink.'<br/>'; $textmessage = str_replace($links[1][$i], '[%%%' . $linkid . '%%%]', $textmessage); } } foreach ($newlinks as $linkid => $newlink) { $textmessage = str_replace('[%%%' . $linkid . '%%%]', $newlink, $textmessage); } } # if (eregi("\\[LISTS\\]", $htmlmessage)) { $lists = ""; $listsarr = array(); $req = Sql_Query(sprintf('select list.name from %s as list,%s as listuser where list.id = listuser.listid and listuser.userid = %d', $tables["list"], $tables["listuser"], $user_system_values["id"])); while ($row = Sql_Fetch_Row($req)) { array_push($listsarr, $row[0]); } $lists_html = join('<br/>', $listsarr); $lists_text = join("\n", $listsarr); $htmlmessage = ereg_replace("\\[LISTS\\]", $lists_html, $htmlmessage); $textmessage = ereg_replace("\\[LISTS\\]", $lists_text, $textmessage); } #0011996: forward to friend - personal message if (FORWARD_PERSONAL_NOTE_SIZE && ($hash = 'forwarded' && !empty($forwardedby['personalNote']))) { $htmlmessage = nl2br($forwardedby['personalNote']) . '<br/>' . $htmlmessage; $textmessage = $forwardedby['personalNote'] . "\n" . $textmessage; } ## remove any existing placeholders $htmlmessage = eregi_replace("\\[[A-Z\\. ]+\\]", "", $htmlmessage); $textmessage = eregi_replace("\\[[A-Z\\. ]+\\]", "", $textmessage); ## check that the HTML message as proper <head> </head> and <body> </body> tags # some readers fail when it doesn't if (!preg_match("#<body.*</body>#ims", $htmlmessage)) { $htmlmessage = '<body>' . $htmlmessage . '</body>'; } if (!preg_match("#<head>.*</head>#ims", $htmlmessage)) { if (!$adddefaultstyle) { $defaultstyle = ""; } $htmlmessage = '<head> <meta content="text/html;charset=' . $cached[$messageid]["html_charset"] . '" http-equiv="Content-Type"> <title></title>' . $defaultstyle . '</head>' . $htmlmessage; } if (!preg_match("#<html>.*</html>#ims", $htmlmessage)) { $htmlmessage = '<html>' . $htmlmessage . '</html>'; } # particularly Outlook seems to have trouble if it is not \r\n # reports have come that instead this creates lots of trouble # this is now done in the global sendMail function, so it is not # necessary here # if (USE_CARRIAGE_RETURNS) { # $htmlmessage = preg_replace("/\r?\n/", "\r\n", $htmlmessage); # $textmessage = preg_replace("/\r?\n/", "\r\n", $textmessage); # } ## build the email if (!PHPMAILER) { $mail = new html_mime_mail(array('X-Mailer: PHPlist v' . VERSION, "X-MessageId: {$messageid}", "X-ListMember: {$email}", "Precedence: bulk", "List-Help: <" . $text["preferences"] . ">", "List-Unsubscribe: <" . $text["unsubscribe"] . ">", "List-Subscribe: <" . getConfig("subscribeurl") . ">", "List-Owner: <mailto:" . getConfig("admin_address") . ">")); } else { $mail = new PHPlistMailer($messageid, $destinationemail); if ($forwardedby) { $mail->add_timestamp(); } #$mail->IsSMTP(); } list($dummy, $domaincheck) = split('@', $destinationemail); $text_domains = explode("\n", trim(getConfig("alwayssendtextto"))); if (in_array($domaincheck, $text_domains)) { $htmlpref = 0; if (VERBOSE) { output($GLOBALS['I18N']->get('sendingtextonlyto') . " {$domaincheck}"); } } list($dummy, $domaincheck) = split('@', $email); $text_domains = explode("\n", trim(getConfig("alwayssendtextto"))); if (in_array($domaincheck, $text_domains)) { $htmlpref = 0; if (VERBOSE) { output("Sending text only to {$domaincheck}"); } } # so what do we actually send? switch ($cached[$messageid]["sendformat"]) { case "HTML": // # send html to users who want it and text to everyone else // if ($htmlpref) { // Sql_Query("update {$GLOBALS["tables"]["message"]} set ashtml = ashtml + 1 where id = $messageid"); // if (ENABLE_RSS && sizeof($rssitems)) // updateRSSStats($rssitems,"ashtml"); // # dbg("Adding HTML ".$cached[$messageid]["templateid"]); // $mail->add_html($htmlmessage,"",$cached[$messageid]["templateid"]); // addAttachments($messageid,$mail,"HTML"); // } else { // Sql_Query("update {$GLOBALS["tables"]["message"]} set astext = astext + 1 where id = $messageid"); // if (ENABLE_RSS && sizeof($rssitems)) // updateRSSStats($rssitems,"astext"); // $mail->add_text($textmessage); // addAttachments($messageid,$mail,"text"); // } // break; // # send html to users who want it and text to everyone else // if ($htmlpref) { // Sql_Query("update {$GLOBALS["tables"]["message"]} set ashtml = ashtml + 1 where id = $messageid"); // if (ENABLE_RSS && sizeof($rssitems)) // updateRSSStats($rssitems,"ashtml"); // # dbg("Adding HTML ".$cached[$messageid]["templateid"]); // $mail->add_html($htmlmessage,"",$cached[$messageid]["templateid"]); // addAttachments($messageid,$mail,"HTML"); // } else { // Sql_Query("update {$GLOBALS["tables"]["message"]} set astext = astext + 1 where id = $messageid"); // if (ENABLE_RSS && sizeof($rssitems)) // updateRSSStats($rssitems,"astext"); // $mail->add_text($textmessage); // addAttachments($messageid,$mail,"text"); // } // break; case "both": case "text and HTML": # send one big file to users who want html and text to everyone else if ($htmlpref) { Sql_Query("update {$GLOBALS["tables"]["message"]} set ashtml = ashtml + 1 where id = {$messageid}"); if (ENABLE_RSS && sizeof($rssitems)) { updateRSSStats($rssitems, "ashtml"); } # dbg("Adding HTML ".$cached[$messageid]["templateid"]); $mail->add_html($htmlmessage, $textmessage, $cached[$messageid]["templateid"]); addAttachments($messageid, $mail, "HTML"); } else { Sql_Query("update {$GLOBALS["tables"]["message"]} set astext = astext + 1 where id = {$messageid}"); if (ENABLE_RSS && sizeof($rssitems)) { updateRSSStats($rssitems, "astext"); } $mail->add_text($textmessage); addAttachments($messageid, $mail, "text"); } break; case "PDF": # send a PDF file to users who want html and text to everyone else if (ENABLE_RSS && sizeof($rssitems)) { updateRSSStats($rssitems, "astext"); } if ($htmlpref) { Sql_Query("update {$GLOBALS["tables"]["message"]} set aspdf = aspdf + 1 where id = {$messageid}"); $pdffile = createPdf($textmessage); if (is_file($pdffile) && filesize($pdffile)) { $fp = fopen($pdffile, "r"); if ($fp) { $contents = fread($fp, filesize($pdffile)); fclose($fp); unlink($pdffile); $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <embed src="message.pdf" width="450" height="450" href="message.pdf"></embed> </body> </html>'; # $mail->add_html($html,$textmessage); # $mail->add_text($textmessage); $mail->add_attachment($contents, "message.pdf", "application/pdf"); } } addAttachments($messageid, $mail, "HTML"); } else { Sql_Query("update {$GLOBALS["tables"]["message"]} set astext = astext + 1 where id = {$messageid}"); $mail->add_text($textmessage); addAttachments($messageid, $mail, "text"); } break; case "text and PDF": if (ENABLE_RSS && sizeof($rssitems)) { updateRSSStats($rssitems, "astext"); } # send a PDF file to users who want html and text to everyone else if ($htmlpref) { Sql_Query("update {$GLOBALS["tables"]["message"]} set astextandpdf = astextandpdf + 1 where id = {$messageid}"); $pdffile = createPdf($textmessage); if (is_file($pdffile) && filesize($pdffile)) { $fp = fopen($pdffile, "r"); if ($fp) { $contents = fread($fp, filesize($pdffile)); fclose($fp); unlink($pdffile); $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <embed src="message.pdf" width="450" height="450" href="message.pdf"></embed> </body> </html>'; # $mail->add_html($html,$textmessage); $mail->add_text($textmessage); $mail->add_attachment($contents, "message.pdf", "application/pdf"); } } addAttachments($messageid, $mail, "HTML"); } else { Sql_Query("update {$GLOBALS["tables"]["message"]} set astext = astext + 1 where id = {$messageid}"); $mail->add_text($textmessage); addAttachments($messageid, $mail, "text"); } break; case "text": default: # send as text if (ENABLE_RSS && sizeof($rssitems)) { updateRSSStats($rssitems, "astext"); } Sql_Query("update {$GLOBALS["tables"]["message"]} set astext = astext + 1 where id = {$messageid}"); $mail->add_text($textmessage); addAttachments($messageid, $mail, "text"); break; } $mail->build_message(array("html_charset" => $cached[$messageid]["html_charset"], "html_encoding" => HTMLEMAIL_ENCODING, "text_charset" => $cached[$messageid]["text_charset"], "text_encoding" => TEXTEMAIL_ENCODING)); if (!TEST) { if ($hash != 'forwarded' || !sizeof($forwardedby)) { $fromname = $cached[$messageid]["fromname"]; $fromemail = $cached[$messageid]["fromemail"]; $subject = $cached[$messageid]["subject"]; } else { $fromname = ''; $fromemail = $forwardedby['email']; $subject = $GLOBALS['strFwd'] . ': ' . $cached[$messageid]["subject"]; } if (!$mail->send("", $destinationemail, $fromname, $fromemail, $subject)) { logEvent("Error sending message {$messageid} to {$email} ({$destinationemail})"); return 0; } else { return 1; } } return 0; }
require_once dirname(__FILE__) . '/accesscheck.php'; $content = ''; if (isset($_POST['usercheck'])) { $lsexist = new WebblerListing(s('Existing subscribers')); $lsnonexist = new WebblerListing(s('Non existing subscribers ')); $users = explode("\n", $_POST['usercheck']); foreach ($users as $user) { $user = trim($user); if (isset($_POST['check']) && $_POST['check'] == 'foreignkey') { $exists = Sql_Query(sprintf('select id,foreignkey,email from %s where foreignkey = "%s"', $tables['user'], sql_escape($user))); } else { $exists = Sql_Query(sprintf('select id,foreignkey,email from %s where email = "%s"', $tables['user'], sql_escape($user))); } if (Sql_Num_Rows($exists)) { $id = Sql_Fetch_Array($exists); $element = strip_tags($user); $lsexist->addElement($element, PageUrl2('user&id=' . $id['id'])); $lsexist->addColumn($element, $GLOBALS['I18N']->get('email'), $id['email']); $lsexist->addColumn($element, $GLOBALS['I18N']->get('key'), $id['foreignkey']); } else { $lsnonexist->addElement(strip_tags($user)); } } print $lsexist->display(); print $lsnonexist->display(); } else { $_POST['usercheck'] = ''; } /* print $GLOBALS["I18N"]->get("Page to check the existence of users in the database");
function repeatMessage($msgid) { # if (!USE_REPETITION && !USE_rss) return; $data = loadMessageData($msgid); ## do not repeat when it has already been done if ($data['repeatinterval'] == 0 || !empty($data['repeatedid'])) { return; } # calculate the future embargo, a multiple of repeatinterval minutes after the current embargo $msgdata = Sql_Fetch_Array_Query(sprintf('SELECT *, embargo + INTERVAL (FLOOR(TIMESTAMPDIFF(MINUTE, embargo, GREATEST(embargo, NOW())) / repeatinterval) + 1) * repeatinterval MINUTE AS newembargo FROM %s WHERE id = %d AND now() < repeatuntil', $GLOBALS['tables']['message'], $msgid)); if (!$msgdata) { logEvent("Message {$msgid} not repeated due to reaching the repeatuntil date"); return; } # check whether the new embargo is not on an exclusion if (isset($GLOBALS['repeat_exclude']) && is_array($GLOBALS['repeat_exclude'])) { $loopcnt = 0; while (excludedDateForRepetition($msgdata['newembargo'])) { if (++$loopcnt > 15) { logEvent("Unable to find new embargo date too many exclusions? for message {$msgid}"); return; } $result = Sql_Fetch_Array_Query(sprintf("SELECT '%s' + INTERVAL repeatinterval MINUTE AS newembargo\n FROM %s\n WHERE id = %d", $msgdata['newembargo'], $GLOBALS['tables']['message'], $msgid)); $msgdata['newembargo'] = $result['newembargo']; } } # copy the new message Sql_Query(sprintf(' insert into %s (entered) values(now())', $GLOBALS['tables']['message'])); $newid = Sql_Insert_id(); require dirname(__FILE__) . '/structure.php'; if (!is_array($DBstruct['message'])) { logEvent("Error including structure when trying to duplicate message {$msgid}"); return; } foreach ($DBstruct['message'] as $column => $rec) { if ($column != 'id' && $column != 'entered' && $column != 'sendstart') { Sql_Query(sprintf('update %s set %s = "%s" where id = %d', $GLOBALS['tables']['message'], $column, addslashes($msgdata[$column]), $newid)); } } $req = Sql_Query(sprintf("SELECT *\n FROM %s\n WHERE id = %d AND name NOT IN ('id')", $GLOBALS['tables']['messagedata'], $msgid)); while ($row = Sql_Fetch_Array($req)) { setMessageData($newid, $row['name'], $row['data']); } Sql_Query(sprintf('update %s set embargo = "%s",status = "submitted",sent = "" where id = %d', $GLOBALS['tables']['message'], $msgdata['newembargo'], $newid)); list($e['year'], $e['month'], $e['day'], $e['hour'], $e['minute'], $e['second']) = sscanf($msgdata['newembargo'], '%04d-%02d-%02d %02d:%02d:%02d'); unset($e['second']); setMessageData($newid, 'embargo', $e); foreach (array('processed', 'astext', 'ashtml', 'astextandhtml', 'aspdf', 'astextandpdf', 'viewed', 'bouncecount') as $item) { Sql_Query(sprintf('update %s set %s = 0 where id = %d', $GLOBALS['tables']['message'], $item, $newid)); } # lists $req = Sql_Query(sprintf('select listid from %s where messageid = %d', $GLOBALS['tables']['listmessage'], $msgid)); while ($row = Sql_Fetch_Row($req)) { Sql_Query(sprintf('insert into %s (messageid,listid,entered) values(%d,%d,now())', $GLOBALS['tables']['listmessage'], $newid, $row[0])); } # attachments $req = Sql_Query(sprintf('select * from %s,%s where %s.messageid = %d and %s.attachmentid = %s.id', $GLOBALS['tables']['message_attachment'], $GLOBALS['tables']['attachment'], $GLOBALS['tables']['message_attachment'], $msgid, $GLOBALS['tables']['message_attachment'], $GLOBALS['tables']['attachment'])); while ($row = Sql_Fetch_Array($req)) { if (is_file($row['remotefile'])) { # if the "remote file" is actually local, we want to refresh the attachment, so we set # filename to nothing $row['filename'] = ''; } Sql_Query(sprintf('insert into %s (filename,remotefile,mimetype,description,size) values("%s","%s","%s","%s",%d)', $GLOBALS['tables']['attachment'], addslashes($row['filename']), addslashes($row['remotefile']), addslashes($row['mimetype']), addslashes($row['description']), $row['size'])); $attid = Sql_Insert_id(); Sql_Query(sprintf('insert into %s (messageid,attachmentid) values(%d,%d)', $GLOBALS['tables']['message_attachment'], $newid, $attid)); } logEvent("Message {$msgid} was successfully rescheduled as message {$newid}"); ## remember we duplicated, in order to avoid doing it again (eg when requeuing) setMessageData($msgid, 'repeatedid', $newid); if (getConfig('pqchoice') == 'phplistdotcom') { activateRemoteQueue(); } }
function matchedBounceRule($text, $activeonly = 0) { if ($activeonly) { $status = ' where status = "active"'; } else { $status = ''; } $req = Sql_Query(sprintf('select * from %s %s order by listorder', $GLOBALS['tables']['bounceregex'], $status)); while ($row = Sql_Fetch_Array($req)) { $pattern = str_replace(' ', '\\s+', $row['regex']); # print "Trying to match ".$pattern; #print ' with '.$text; # print '<br/>'; if (@preg_match('/' . preg_quote($pattern) . '/iUm', $text)) { return $row['id']; } elseif (@preg_match('/' . $pattern . '/iUm', $text)) { return $row['id']; } } return ''; }
} else { ## Sending test emails of non system templates to be added. $actionresult .= '<p>' . s('Sending a test from templates only works for the system template.') . ' ' . s('To test your template, go to campaigns and send a test campaign using the template.') . '</p>'; } if (empty($testtarget)) { $testtarget = getConfig('admin_address'); } $testtarget = preg_replace('/, $/', '', $testtarget); } } if (!empty($actionresult)) { print '<div class="actionresult">' . $actionresult . '</div>'; } if ($id) { $req = Sql_Query("select * from {$tables["template"]} where id = {$id}"); $data = Sql_Fetch_Array($req); ## keep POSTED data, even if not saved if (!empty($_POST['template'])) { $data['template'] = $content; } } else { $data = array(); $data["title"] = ''; $data["template"] = ''; } ?> <p class="information"><?php echo $msg; ?> </p>
/** * listAdmins. * * Return array of admins in the system * Used in the list page to allow assigning ownership to lists * * @param none * * @return array of admins * id => name */ public function listAdmins() { $result = array(); $req = Sql_Query("select id,loginname from {$GLOBALS['tables']['admin']} order by loginname"); while ($row = Sql_Fetch_Array($req)) { $result[$row['id']] = $row['loginname']; } return $result; }
function displayConfig($name) { ## displayConfig # purpose: display input for a config variable in the backend # parameters: # name -> name of the config variable, as found in $this->configvars # return, HTML snippet of input to slot into a form $name = trim(strtolower($name)); $name = preg_replace('/\\W/', '', $name); $type = $this->configvars[$name][0]; $label = $this->configvars[$name][1]; $currentvalue = $this->getConfig($name); $html = ''; switch ($type) { case 'attributeselect': $html = sprintf('<select name="%s"><option value=""> --%s</option>', $name, $GLOBALS['I18N']->get('choose')); $req = Sql_Query(sprintf('select * from %s', $GLOBALS['tables']['attribute'])); while ($row = Sql_Fetch_Array($req)) { $html .= sprintf('<option value="%d" %s>%s</option>', $row['id'], $row['id'] == $currentvalue ? 'selected="selected"' : '', substr(htmlspecialchars($row['name']), 0, 25)); } $html .= '</select>'; return $html; case 'radio': $values = $this->configvars[$name][2]; foreach ($values as $key => $label) { $html .= sprintf('<input type="radio" name="%s" value="%s" %s> %s', $name, $key, $currentvalue == $key ? 'checked="checked"' : '', $label); } return $html; case 'textarea': $html = sprintf('<textarea name="%s" rows="10" cols="40" wrap="virtual">%s </textarea>', $name, htmlspecialchars($currentvalue)); return $html; case 'text': default: $html = sprintf('<input type="text" name="%s" value="%s" size="45">', $name, htmlspecialchars($currentvalue)); return $html; } }
function display($subtype, $name, $value, $docid = 0) { global $config; $data = parseDelimitedData($value); $html = sprintf('<input type=hidden name="%s" value="%d">', $name, $subtype, $subtype); switch ($subtype) { case "1": $html .= '<p>Select the form to use for users to subscribe</p>'; $req = Sql_Query(sprintf('select * from %s where active', $this->tables["subscribepage"])); $html .= sprintf('<select name="%s_spage">', $name); $html .= sprintf('<option value="0"> -- select one</option>'); while ($row = Sql_Fetch_Array($req)) { $selected = $data["spage"] == $row["id"] ? "selected" : ""; $html .= sprintf('<option value="%s" %s> %s</option>', $row["id"], $selected, $row["title"]); } return $html; } return "Invalid subtype: {$subtype}"; }
## allow plugins to save their fields foreach ($GLOBALS['plugins'] as $plugin) { $result = $result && $plugin->processEditList($id); } print '<div class="actionresult">' . $_SESSION['action_result'] . '</div>'; if ($_GET['page'] == 'editlist') { print '<div class="actions">' . PageLinkButton('importsimple&list=' . $id, s('Add some subscribers')) . ' ' . PageLinkButton('editlist', s('Add another list')) . '</div>'; } unset($_SESSION['action_result']); return; ## doing this, the action result disappears, which we don't want Redirect('list'); } if (!empty($id)) { $result = Sql_Query("SELECT * FROM " . $GLOBALS['tables']['list'] . " where id = {$id}"); $list = Sql_Fetch_Array($result); } else { $list = array('name' => '', 'active' => 0, 'listorder' => 0, 'description' => ''); } if (empty($list['category'])) { $list['category'] = ''; } @ob_end_flush(); ?> <?php echo formStart(' class="editlistSave" '); ?> <input type="hidden" name="id" value="<?php echo $id; ?>
addUserHistory($emailreq[0],$GLOBALS['I18N']->get("Auto Unsubscribed"),$GLOBALS['I18N']->get("User auto unsubscribed for")." $cnt ".$GLOBALS['I18N']->get("consecutive bounces")); Sql_Query(sprintf('update %s set confirmed = 0 where id = %d',$tables["user"],$user[0])); addSubscriberStatistics('auto unsubscribe',1); $email_req = Sql_Fetch_Row_Query(sprintf('select email from %s where id = %d',$tables["user"],$user[0])); $unsubscribed_users .= $email_req[0] . " [$user[0]] ($cnt)\n"; } } elseif ($bounce["bounce"] == "") { $cnt = 0; } }*/ #$alive = 1;$removed = 0; DT 051105 $cnt = 0; $alive = 1; $removed = $msgokay = $unconfirmed = $unsubscribed = 0; #while ($alive && !$removed && $bounce = Sql_Fetch_Array($msg_req)) { DT 051105 while ($alive && !$removed && !$msgokay && ($bounce = Sql_Fetch_Array($msg_req))) { $alive = checkLock($process_id); if ($alive) { keepLock($process_id); } else { bounceProcessError("Process Killed by other process"); } if (stripos($bounce['status'], 'duplicate') === false && stripos($bounce['comment'], 'duplicate') === false) { if (sprintf('%d', $bounce["bounce"]) == $bounce["bounce"]) { $cnt++; if ($cnt >= $bounce_unsubscribe_threshold) { if (!$unsubscribed) { outputProcessBounce(sprintf('unsubscribing %d -> %d bounces', $user[0], $cnt)); $userurl = PageLink2("user&id={$user['0']}", $user[0]); logEvent(s('User (url:%s) has consecutive bounces (%d) over threshold (%d), user marked unconfirmed', $userurl, $cnt, $bounce_unsubscribe_threshold)); $emailreq = Sql_Fetch_Row_Query("select email from {$tables["user"]} where id = {$user['0']}");
$attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox") %s', $tables["attribute"], $already_used)); while ($att = Sql_Fetch_array($attreq)) { $att_drop .= sprintf('<option value="%d" %s>%s</option>', $att["id"], "", $att["name"]); $num = Sql_Affected_Rows(); switch ($att["type"]) { case "select": case "radio": case "checkboxgroup": $att_js .= sprintf('value_divs[%d] = "criteria_values_select";' . "\n", $att["id"]); $att_js .= sprintf('value_default[%d] = "";' . "\n", $att["id"]); $value_req = Sql_Query(sprintf('select * from %s order by listorder,name', $GLOBALS["table_prefix"] . "listattr_" . $att["tablename"])); $num = Sql_Num_Rows($value_req); $att_js .= sprintf('values[%d] = new Array(%d);' . "\n", $att["id"], $num + 1); #$att_js .= sprintf('values[%d][0] = new Option("[choose]","0",false,true);'."\n",$att["id"]); $c = 0; while ($value = Sql_Fetch_Array($value_req)) { $att_js .= sprintf('values[%d][%d] = new Option("%s","%d",false,false);' . "\n", $att["id"], $c, $value["name"], $value["id"]); $c++; } $att_js .= sprintf('operators[%d] = new Array(2);' . "\n", $att["id"]); $att_js .= sprintf('operators[%d][0] = new Option("%s","is",false,true);' . "\n", $att["id"], $GLOBALS['I18N']->get('is')); $att_js .= sprintf('operators[%d][1] = new Option("%s","isnot",false,true);' . "\n", $att["id"], $GLOBALS['I18N']->get('isnot')); break; case "checkbox": $att_js .= sprintf('value_divs[%d] = "criteria_values_select";' . "\n", $att["id"]); $att_js .= sprintf('value_default[%d] = "";' . "\n", $att["id"]); $att_js .= sprintf('values[%d] = new Array(%d);' . "\n", $att["id"], 2); $att_js .= sprintf('values[%d][0] = new Option("%s",0,false,true);' . "\n", $att["id"], $GLOBALS['I18N']->get('unchecked')); $att_js .= sprintf('values[%d][1] = new Option("%s",1,false,true);' . "\n", $att["id"], $GLOBALS['I18N']->get('checked')); $att_js .= sprintf('operators[%d] = new Array(2);' . "\n", $att["id"]); $att_js .= sprintf('operators[%d][0] = new Option("%s","is",false,true);' . "\n", $att["id"], $GLOBALS['I18N']->get('is'));
?> Please select a message<br/> <?php } elseif ($send && !$list) { ?> Please select a list to send to<br/> <?php } if (!$done) { print "To send a prepared message, check the radio button next to the message you want to send and click \"Send\""; print formStart('name="sendpreparedform" class="sendpreparedSend" '); $req = Sql_Query("select * from {$tables["message"]} where status = 'prepared'"); if (!Sql_Affected_Rows()) { Error("No prepared messages found. You need to " . PageLink2("preparesend", "Prepare") . " one first"); } while ($message = Sql_Fetch_Array($req)) { print "<hr/>Subject: <b>" . $message["subject"] . "</b>, "; print "From: <b>" . $message["fromfield"] . "</b> <br/>"; print 'Send this message <input type="radio" name="message" value="' . $message["id"] . '" /><br/><br/>'; print '<p class="information">[start of message]</p>'; print '<iframe src="?page=viewmessage&embed=yes&omitall=yes&id=' . $message["id"] . '" scrolling="auto" width=100% height=450 margin=0 frameborder=0> </iframe>'; print '<p class="information">[end of message]</p>'; } $html = '<hr/><p class="information">Please select the lists you want to send it to: <ul> <li><input type="checkbox" name="list[all]" value="signup" />All Lists</li> '; $result = Sql_query("SELECT * FROM {$tables["list"]} {$subselect}"); $num = 0;
if ($id) { $url_keep = '&id=' . $id; } else { $url_keep = ''; } if ($total) { $paging = simplePaging("mviews{$url_keep}", $start, $total, MAX_USER_PP, $GLOBALS['I18N']->get("Entries")); $ls->usePanel($paging); } $req = Sql_Query(sprintf('select userid,email,um.entered as sent,min(um.viewed) as firstview, max(um.viewed) as lastview, count(um.viewed) as viewcount, abs(unix_timestamp(um.entered) - unix_timestamp(um.viewed)) as responsetime from %s um, %s user, %s msg where um.messageid = %d and um.messageid = msg.id and um.userid = user.id and um.status = "sent" and um.viewed is not null %s group by userid %s', $GLOBALS['tables']['usermessage'], $GLOBALS['tables']['user'], $GLOBALS['tables']['message'], $id, $subselect, $limit)); $summary = array(); while ($row = Sql_Fetch_Array($req)) { if ($download) { ## with download, the 50 per page limit is not there. set_time_limit(60); $element = $row['email']; } else { $element = shortenTextDisplay($row['email'], 15); } $ls->addElement($element, PageUrl2('userhistory&id=' . $row['userid'])); $ls->setClass($element, 'row1'); $ls->addRow($element, '<div class="listingsmall gray">' . $GLOBALS['I18N']->get('sent') . ': ' . formatDateTime($row['sent'], 1) . '</div>', ''); if ($row['viewcount'] > 1) { $ls->addColumn($element, $GLOBALS['I18N']->get('firstview'), formatDateTime($row['firstview'], 1)); $ls->addColumn($element, $GLOBALS['I18N']->get('lastview'), formatDateTime($row['lastview'])); $ls->addColumn($element, $GLOBALS['I18N']->get('views'), $row['viewcount']); } else {
if (isset($_REQUEST['delete'])) { $delete = sprintf('%d', $_REQUEST['delete']); } else { $delete = 0; } if ($delete) { Sql_Query(sprintf('delete from %s where id = %d', $tables["subscribepage"], $delete)); Sql_Query(sprintf('delete from %s where id = %d', $tables["subscribepage_data"], $delete)); Info($GLOBALS['I18N']->get('Deleted') . " {$delete}"); } print formStart('name="pagelist" class="spageEdit" '); print '<input type="hidden" name="active[-1]" value="1" />'; ## to force the active array to exist $ls = new WebblerListing($GLOBALS['I18N']->get('subscribe pages')); $req = Sql_Query(sprintf('select * from %s %s order by title', $tables["subscribepage"], $subselect)); while ($p = Sql_Fetch_Array($req)) { $ls->addElement($p["id"]); $ls->setClass($p["id"], 'row1'); $ls->addColumn($p["id"], $GLOBALS['I18N']->get('title'), stripslashes($p["title"])); if ($require_login && isSuperUser() || !$require_login) { $ls->addColumn($p["id"], $GLOBALS['I18N']->get('owner'), adminName($p["owner"])); if ($p["id"] == $default) { $checked = 'checked="checked"'; } else { $checked = ""; } $ls->addColumn($p["id"], $GLOBALS['I18N']->get('default'), sprintf('<input type="radio" name="default" value="%d" %s onchange="document.pagelist.submit()" />', $p["id"], $checked)); } else { $adminname = ""; $isdefault = ""; }