Beispiel #1
0
           Sql_Query("update {$tables['user']} set htmlemail = 0");
           $total = Sql_Affected_Rows();
           $action_result .= "<br/>{$total} " . $GLOBALS['I18N']->get('subscribers apply') . '<br/>';
           break;
       case 'nolists':
           $action_result .= $GLOBALS['I18N']->get('Deleting subscribers who are not on any list');
           $req = Sql_Query(sprintf('select %s.id from %s
 left join %s on %s.id = %s.userid
 where userid is NULL', $tables['user'], $tables['user'], $tables['listuser'], $tables['user'], $tables['listuser']));
           $total = Sql_Affected_Rows();
           $action_result .= "<br/>{$total} " . $GLOBALS['I18N']->get('subscribers apply') . '<br/>';
           $todo = 'deleteUser';
           break;
       case 'nolistsnewlist':
           $list = sprintf('%d', $_GET['list']);
           $action_result .= $GLOBALS['I18N']->get('Moving subscribers who are not on any list to') . ' ' . ListName($list);
           $req = Sql_Query(sprintf('select %s.id from %s
 left join %s on %s.id = %s.userid
 where userid is NULL', $tables['user'], $tables['user'], $tables['listuser'], $tables['user'], $tables['listuser']));
           $total = Sql_Affected_Rows();
           $action_result .= "<br/>{$total} " . $GLOBALS['I18N']->get('subscribers apply') . '<br/>';
           $todo = 'moveUser';
           break;
       case 'bounces':
           $action_result .= $GLOBALS['I18N']->get('Deleting subscribers with more than') . ' ' . $num . ' ' . $GLOBALS['I18N']->get('bounces');
           $req = Sql_Query(sprintf('select id from %s
 where bouncecount > %d', $tables['user'], $num));
           $total = Sql_Affected_Rows();
           $action_result .= "<br/>{$total} " . $GLOBALS['I18N']->get('subscribers apply') . '<br/>';
           $todo = 'deleteUser';
           break;
Beispiel #2
0
if ($_SESSION['export']['column'] == 'nodate') {
    ## fetch dates as min and max from user table
    if ($list) {
        $dates = Sql_Fetch_Row_Query(sprintf('select date(min(user.modified)),date(max(user.modified)) from %s where listid = %d %s', $querytables, $list, $subselect));
    } else {
        ## this takes begin and end of all users, regardless of whether they are on the list of this admin @TODO
        $dates = Sql_Fetch_Row_Query(sprintf('select date(min(user.modified)),date(max(user.modified)) from %s ', $querytables));
    }
    $fromdate = $dates[0];
    $todate = $dates[1];
} else {
    $fromdate = $_SESSION['export']['fromdate'];
    $todate = $_SESSION['export']['todate'];
}
if ($list) {
    $filename = s('phpList Export on %s from %s to %s (%s).csv', ListName($list), $fromdate, $todate, date('Y-M-d'));
} else {
    $filename = s('phpList Export from %s to %s (%s).csv', $fromdate, $todate, date('Y-M-d'));
}
ob_end_clean();
$filename = trim(strip_tags($filename));
if (!empty($_SESSION['export']['fileready']) && is_file($_SESSION['export']['fileready'])) {
    header('Content-type: ' . $GLOBALS['export_mimetype'] . '; charset=UTF-8');
    header("Content-disposition:  attachment; filename=\"{$filename}\"");
    $fp = fopen($_SESSION['export']['fileready'], 'r');
    while (!feof($fp)) {
        print fgets($fp);
    }
    fclose($fp);
    unlink($_SESSION['export']['fileready']);
    unset($_SESSION['export']);
Beispiel #3
0
    }
    $_SESSION['export'] = array();
    $_SESSION['export']['column'] = $_POST['column'];
    $_SESSION['export']['cols'] = $_POST['cols'];
    $_SESSION['export']['attrs'] = $_POST['attrs'];
    $_SESSION['export']['fromdate'] = $from->getDate("from");
    $_SESSION['export']['todate'] = $to->getDate("to");
    $_SESSION['export']['list'] = $list;
    print '<p>' . s('Processing export, this may take a while. Please wait') . '</p>';
    print $GLOBALS['img_busy'];
    print '<div id="progresscount" style="width: 200; height: 50;">Progress</div>';
    print '<br/> <iframe id="export" src="./?page=pageaction&action=export&ajaxed=true' . addCsrfGetToken() . '" scrolling="no" height="50"></iframe>';
    return;
}
if ($list) {
    print sprintf($GLOBALS['I18N']->get('Export subscribers on %s'), ListName($list));
}
print formStart();
$checked = 'entered';
if (isset($_GET['list']) && $_GET['list'] == 'all') {
    $checked = 'nodate';
}
?>

<?php 
echo $GLOBALS['I18N']->get('What date needs to be used:');
?>
<br/>
<input type="radio" name="column" value="nodate" <?php 
echo $checked == 'nodate' ? ' checked="checked"' : '';
?>
Beispiel #4
0
            return;
        }
        $subselect = " where id = 0";
        break;
}
function addUserForm($listid)
{
    //nizar 'value'
    $html = formStart() . '<input type=hidden name=listid value="' . $listid . '">
  ' . $GLOBALS['I18N']->get("Add a user") . ': <input type=text name=new value="" size=40><input type=submit
 name=add value="' . $GLOBALS['I18N']->get('Add') . '">
  </form>';
    return $html;
}
if (isset($id)) {
    print "<h3>" . $GLOBALS['I18N']->get("Members of") . " " . ListName($id) . "</h3>";
    echo "<br />" . PageLink2("editlist", $GLOBALS['I18N']->get("back to this list"), "id={$id}");
    echo "<br />" . PageLink2("export&list={$id}", $GLOBALS['I18N']->get("Download users on this list as a CSV file"));
    print addUserForm($id);
} else {
    Fatal_Error($GLOBALS['I18N']->get("Please enter a listid"));
}
if (isset($_REQUEST["processtags"]) && $access != "view") {
    print $GLOBALS['I18N']->get("Processing") . " .... <br/>";
    if ($_POST["tagaction"] && is_array($_POST["user"])) {
        switch ($_POST["tagaction"]) {
            case "move":
                $cnt = 0;
                foreach ($_POST["user"] as $key => $val) {
                    Sql_query("delete from {$tables["listuser"]} where listid = {$id} and userid =\n            {$key}");
                    Sql_query("replace into {$tables["listuser"]} (listid,userid)\n            values({$_POST["movedestination"]},{$key})");
Beispiel #5
0
    }
    $_SESSION['export'] = array();
    $_SESSION['export']['column'] = $_POST['column'];
    $_SESSION['export']['cols'] = $_POST['cols'];
    $_SESSION['export']['attrs'] = $_POST['attrs'];
    $_SESSION['export']['fromdate'] = $from->getDate('from');
    $_SESSION['export']['todate'] = $to->getDate('to');
    $_SESSION['export']['list'] = $list;
    print '<p>' . s('Processing export, this may take a while. Please wait') . '</p>';
    print $GLOBALS['img_busy'];
    print '<div id="progresscount" style="width: 200; height: 50;">Progress</div>';
    print '<br/> <iframe id="export" src="./?page=pageaction&action=export&ajaxed=true' . addCsrfGetToken() . '" scrolling="no" height="50"></iframe>';
    return;
}
if ($list) {
    print s('Export subscribers on %s', ListName($list));
}
print formStart();
$checked = 'entered';
if (isset($_GET['list']) && $_GET['list'] == 'all') {
    $checked = 'nodate';
}
?>

<?php 
echo $GLOBALS['I18N']->get('What date needs to be used:');
?>
<br/>
    <input type="radio" name="column"
           value="nodate" <?php 
echo $checked == 'nodate' ? ' checked="checked"' : '';
Beispiel #6
0
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;
}
           Sql_Query("update {$tables["user"]} set htmlemail = 0");
           $total = Sql_Affected_Rows();
           print "{$total} " . $GLOBALS['I18N']->get('users apply') . "<br/>";
           break;
       case "nolists":
           info($GLOBALS['I18N']->get("Deleting users who are not on any list"));
           $req = Sql_Query(sprintf('select %s.id from %s
 left join %s on %s.id = %s.userid
 where userid is NULL', $tables["user"], $tables["user"], $tables["listuser"], $tables["user"], $tables["listuser"]));
           $total = Sql_Affected_Rows();
           print "{$total} " . $GLOBALS['I18N']->get('users apply') . "<br/>";
           $todo = "deleteUser";
           break;
       case "nolistsnewlist":
           $list = sprintf('%d', $_GET["list"]);
           info($GLOBALS['I18N']->get("Moving users who are not on any list to") . " " . ListName($list));
           $req = Sql_Query(sprintf('select %s.id from %s
 left join %s on %s.id = %s.userid
 where userid is NULL', $tables["user"], $tables["user"], $tables["listuser"], $tables["user"], $tables["listuser"]));
           $total = Sql_Affected_Rows();
           print "{$total} " . $GLOBALS['I18N']->get('users apply') . "<br/>";
           $todo = "moveUser";
           break;
       case "bounces":
           info($GLOBALS['I18N']->get("Deleting users with more than") . " " . $_REQUEST["num"] . " " . $GLOBALS['I18N']->get('bounces'));
           $req = Sql_Query(sprintf('select id from %s
 where bouncecount > %d', $tables["user"], $_REQUEST["num"]));
           $total = Sql_Affected_Rows();
           print "{$total} " . $GLOBALS['I18N']->get('users apply') . "<br/>";
           $todo = "deleteUser";
           break;
     }
 }
 # submitting page now saves everything, so check is not necessary
 if ($subselect == "") {
     Sql_Query("delete from {$tables["listuser"]} where userid = {$id}");
 } else {
     # only unsubscribe from the lists of this admin
     $req = Sql_Query("select id from {$tables["list"]} {$subselect_where}");
     while ($row = Sql_Fetch_Row($req)) {
         Sql_Query("delete from {$tables["listuser"]} where userid = {$id} and listid = {$row['0']}");
     }
 }
 if (is_array($_POST["subscribe"])) {
     foreach ($_POST["subscribe"] as $ind => $lst) {
         Sql_Query("insert into {$tables["listuser"]} (userid,listid) values({$id},{$lst})");
         print '<br/>' . sprintf($GLOBALS['I18N']->get('User added to list %s'), ListName($lst));
     }
     print "<br/>";
 }
 $history_entry = '';
 $current_data = Sql_Fetch_Array_Query(sprintf('select * from %s where id = %d', $tables["user"], $id));
 $current_data = array_merge($current_data, getUserAttributeValues('', $id));
 foreach ($current_data as $key => $val) {
     if (!is_numeric($key)) {
         if ($old_data[$key] != $val && $key != "modified") {
             $history_entry .= "{$key} = {$val}\nchanged from {$old_data[$key]}\n";
         }
     }
 }
 if (!$history_entry) {
     $history_entry = "\nNo userdata changed";
            break;
        case "all":
            $subselect = "";
            break;
        case "none":
        default:
            $subselect = "where " . $tables["rssitem"] . ".list = " . $tables["list"] . ".id and " . $tables["list"] . ".owner = 0";
            break;
    }
} else {
    $querytables = $tables["rssitem"];
    $subselect = "";
    if ($_GET["id"]) {
        $pagingurl = '&id=' . $_GET["id"];
        $subselect = "where " . $tables["rssitem"] . ".list = " . $_GET["id"];
        print "RSS items for " . ListName($_GET["id"]) . "<br/>";
    }
}
$req = Sql_query("SELECT count(*) FROM {$querytables} {$subselect}");
$total_req = Sql_Fetch_Row($req);
$total = $total_req[0];
if (isset($start) && $start > 0) {
    $listing = "Listing item {$start} to " . ($start + MAX_MSG_PP);
    $limit = "limit {$start}," . MAX_MSG_PP;
} else {
    $listing = "Listing item 1 to " . MAX_MSG_PP;
    $limit = "limit 0," . MAX_MSG_PP;
    $start = 0;
}
print $total . " RSS Items</p>";
if ($total) {
Beispiel #10
0
            }
            print $value . $col_delim;
        }
        $lists = Sql_query("select listid,name from\n      {$tables['listuser']},{$tables['list']} where userid = " . $user["id"] . " and\n      {$tables['listuser']}.listid = {$tables['list']}.id {$listselect_and}");
        if (!Sql_Affected_rows($lists)) {
            print "No Lists";
        }
        while ($list = Sql_fetch_array($lists)) {
            print stripslashes($list["name"]) . " ";
        }
        print $row_delim;
    }
    exit;
}
if ($list) {
    print sprintf($GLOBALS['I18N']->get('ExportOn'), ListName($list));
}
?>
<form method=post>

<br/><br/>
<table>

<tr><td><?php 
echo $GLOBALS['I18N']->get('DateFrom');
?>
</td><td><?php 
echo $from->showInput("", "", $fromval);
?>
</td></tr>
<tr><td><?php 
Beispiel #11
0
            return;
        }
        $subselect = ' where id = 0';
        break;
}
function addUserForm($listid)
{
    //nizar 'value'
    $html = formStart(' class="membersAdd" ') . '<input type="hidden" name="listid" value="' . $listid . '" />
  ' . $GLOBALS['I18N']->get('Add a user') . ': <input type="text" name="new" value="" size="40" id="emailsearch"/>
     <input class="submit" type="submit" name="add" value="' . $GLOBALS['I18N']->get('Add') . '" />
  </form>';
    return $html;
}
if (!empty($id)) {
    print '<h3>' . $GLOBALS['I18N']->get('Members of') . ' ' . ListName($id) . '</h3>';
    print '<div class="actions">';
    echo PageLinkButton('editlist', $GLOBALS['I18N']->get('edit list details'), "id={$id}", 'pill-l');
    echo PageLinkButton("export&amp;list={$id}", $GLOBALS['I18N']->get('Download subscribers'), '', 'pill-c');
    echo PageLinkDialog("importsimple&amp;list={$id}", $GLOBALS['I18N']->get('Import Subscribers to this list'), '', 'pill-r');
    print '</div>';
} else {
    if ($_REQUEST['id'] != 'all') {
        Redirect('list');
    } else {
        $id = 'all';
        $listAll = true;
    }
    print '<div class="actions">';
    echo PageLinkButton('export&list=all', $GLOBALS['I18N']->get('Download subscribers'), '', 'pill-c');
    print '</div>';
Beispiel #12
0
			return;
		}
		$subselect = " where id = 0";
		break;
}

function addUserForm ($listid) {
  $html = formStart().'<input type=hidden name=listid value="'.$listid.'">
  Add a user: <input type=text name=new value="" size=40><input type=submit
 name=add value="Add">
  </form>';
  return $html;
}

if (isset($id)) {
	print "<h3>Members of ".ListName($id)."</h3>";
  echo "<br />".PageLink2("editlist","back to this list","id=$id");
  echo "<br />".PageLink2("export&list=$id","Download users on this list as a CSV
 file");
  print addUserForm($id);
} else {
  Fatal_Error("Please enter a listid");
}

if (isset($processtags) && $access != "view") {
	print "Processing .... <br/>";
	if ($tagaction && is_array($user)) {
		switch ($tagaction) {
			case "move":
				$cnt = 0;
				while (list($key,$val) = each ($user)) {
Beispiel #13
0
                }
                $value = join(",", $newval);
            } else {
                $value = "";
            }
            Sql_Query(sprintf('replace into %s (userid,attributeid,value)
				values(%d,%d,"%s")', $tables["user_attribute"], $id, $val, $value));
        }
    }
    # submitting page now saves everything, so check is not necessary
    #  if (is_array($subscribe)) {
    Sql_Query("delete from {$tables["listuser"]} where userid = {$id}");
    if (is_array($subscribe)) {
        foreach ($subscribe as $ind => $lst) {
            Sql_Query("insert into {$tables["listuser"]} (userid,listid) values({$id},{$lst})");
            print "User added to " . ListName($lst) . "<br/>";
        }
    }
    #  }
    Info("Changes saved");
}
if (isset($delete) && $delete && $access != "view") {
    # delete the index in delete
    print "Deleting {$delete} ..\n";
    if ($require_login && !isSuperUser()) {
        $lists = Sql_query("SELECT listid FROM {$tables["listuser"]},{$tables["list"]} where userid = " . $delete . " and {$tables['listuser']}.listid = {$tables['list']}.id {$subselect} ");
        while ($lst = Sql_fetch_array($lists)) {
            Sql_query("delete from {$tables["listuser"]} where userid = {$delete} and listid = {$lst['0']}");
        }
    } else {
        deleteUser($delete);
Beispiel #14
0
 switch ($access) {
     case "all":
         if ($option) {
             set_time_limit(600);
             switch ($option) {
                 case "nolists":
                     info("Deleting users who are not on any list");
                     $req = Sql_Query(sprintf('select %s.id from %s
           left join %s on %s.id = %s.userid
           where userid is NULL', $tables["user"], $tables["user"], $tables["listuser"], $tables["user"], $tables["listuser"]));
                     $total = Sql_Affected_Rows();
                     print "{$total} users apply<br/>";
                     $todo = "deleteUser";
                     break;
                 case "nolistsnewlist":
                     info("Moving users who are not on any list to " . ListName($list));
                     $req = Sql_Query(sprintf('select %s.id from %s
           left join %s on %s.id = %s.userid
           where userid is NULL', $tables["user"], $tables["user"], $tables["listuser"], $tables["user"], $tables["listuser"]));
                     $total = Sql_Affected_Rows();
                     print "{$total} users apply<br/>";
                     $todo = "moveUser";
                     break;
                 case "bounces":
                     info("Deleting users with more than " . $_REQUEST["num"] . " bounces");
                     $req = Sql_Query(sprintf('select id from %s
           where bouncecount > %d', $tables["user"], $_REQUEST["num"]));
                     $total = Sql_Affected_Rows();
                     print "{$total} users apply<br/>";
                     $todo = "deleteUser";
                     break;
            break;
        case "all":
            $subselect = "";
            break;
        case "none":
        default:
            $subselect = "where " . $tables["rssitem"] . ".list = " . $tables["list"] . ".id and " . $tables["list"] . ".owner = 0";
            break;
    }
} else {
    $querytables = $tables["rssitem"];
    $subselect = "";
    if ($id) {
        $pagingurl = '&id=' . $id;
        $subselect = "where " . $tables["rssitem"] . ".list = " . $id;
        print "RSS items for " . ListName($id) . "<br/>";
    }
}
$req = Sql_query("SELECT count(*) FROM {$querytables} {$subselect}");
$total_req = Sql_Fetch_Row($req);
$total = $total_req[0];
if (isset($start) && $start > 0) {
    $listing = "Listing item {$start} to " . ($start + MAX_MSG_PP);
    $limit = "limit {$start}," . MAX_MSG_PP;
} else {
    $listing = "Listing item 1 to " . MAX_MSG_PP;
    $limit = "limit 0," . MAX_MSG_PP;
    $start = 0;
}
print $total . " RSS Items</p>";
if ($total) {