Example #1
42
function fill($prefix, $listid)
{
    global $server_name, $tables, $table_prefix;
    # check for not too many
    $domain = getConfig('domain');
    $res = Sql_query("select count(*) from {$tables['user']}");
    $row = Sql_fetch_row($res);
    if ($row[0] > 50000) {
        error('Hmm, I think 50 thousand users is quite enough for a test<br/>This machine does need to do other things you know.');
        print '<script language="Javascript" type="text/javascript"> document.forms[0].output.value="Done. Now there are ' . $row[0] . ' users in the database";</script>' . "\n";
        return 0;
    }
    # fill the database with "users" who have any combination of attribute values
    $attributes = array();
    $res = Sql_query("select * from {$tables['attribute']} where type = \"select\" or type = \"checkbox\" or type=\"radio\"");
    $num_attributes = Sql_Affected_rows();
    $total_attr = 0;
    $total_val = 0;
    while ($row = Sql_fetch_array($res)) {
        array_push($attributes, $row['id']);
        ++$total_attr;
        $values[$row['id']] = array();
        $res2 = Sql_query("select * from {$table_prefix}" . 'listattr_' . $row['tablename']);
        while ($row2 = Sql_fetch_array($res2)) {
            array_push($values[$row['id']], $row2['id']);
            ++$total_val;
        }
    }
    $total = $total_attr * $total_val;
    if (!$total) {
        Fatal_Error('Can only do stress test when some attributes exist');
        return 0;
    }
    for ($i = 0; $i < $total; ++$i) {
        $data = array();
        reset($attributes);
        while (list($key, $val) = each($attributes)) {
            $data[$val] = current($values[$val]);
            if (!$data[$val]) {
                reset($values[$val]);
                $data[$val] = current($values[$val]);
            }
            next($values[$val]);
        }
        $query = sprintf('insert into %s (email,entered,confirmed) values("testuser%s",now(),1)', $tables['user'], $prefix . '-' . $i . '@' . $domain);
        $result = Sql_query($query, 0);
        $userid = Sql_insert_id();
        if ($userid) {
            $result = Sql_query("replace into {$tables['listuser']} (userid,listid,entered) values({$userid},{$listid},now())");
            reset($data);
            while (list($key, $val) = each($data)) {
                if ($key && $val) {
                    Sql_query("replace into {$tables['user_attribute']} (attributeid,userid,value) values(" . $key . ",{$userid}," . $val . ')');
                }
            }
        }
    }
    return 1;
}
Example #2
0
$res_outbound = Sql_exec($cn, $qry_outbound);
$data = array();
$data1 = array();
$data2 = array();
$i = 0;
while ($row_inbound = Sql_fetch_array($res_inbound)) {
    $j = 0;
    $data[$i][$j++] = Sql_Result($row_inbound, "ep_type");
    $data[$i][$j++] = Sql_Result($row_inbound, "ip_address");
    $data[$i][$j++] = Sql_Result($row_inbound, "port");
    $data[$i][$j++] = Sql_Result($row_inbound, "user_name");
    $data[$i][$j++] = Sql_Result($row_inbound, "password");
    $i++;
}
$i = 0;
while ($row_outbound = Sql_fetch_array($res_outbound)) {
    $j = 0;
    $data1[$i][$j++] = Sql_Result($row_outbound, "ip_address");
    $data1[$i][$j++] = Sql_Result($row_outbound, "port");
    $data1[$i][$j++] = Sql_Result($row_outbound, "auth");
    $i++;
}
$i = 0;
$j = 0;
$data2[$i][$j++] = $soft_ano_max;
$data2[$i][$j++] = $soft_ano_min;
$data2[$i][$j++] = $soft_bno_max;
$data2[$i][$j++] = $soft_bno_min;
$new_array = array();
$ii = 0;
$d = 0;
Example #3
0
">
            <?php 
echo $GLOBALS['I18N']->get('Find an admin');
?>
: <input type=text name="find"
                                                                         value="<?php 
echo htmlspecialchars($find);
?>
"
                                                                         size="40"><input type="submit"
                                                                                          value="<?php 
echo $GLOBALS['I18N']->get('Go');
?>
">
            </form></td>
    </tr>
</table>
<?php 
$ls = new WebblerListing($GLOBALS['I18N']->get('Administrators'));
$ls->usePanel($paging);
while ($admin = Sql_fetch_array($result)) {
    $delete_url = sprintf("<a href=\"javascript:deleteRec('%s');\">" . $GLOBALS['I18N']->get('del') . '</a>', PageURL2('admins', 'Delete', "start={$start}&amp;delete=" . $admin['id']));
    $ls->addElement($admin['loginname'], PageUrl2('admin', $GLOBALS['I18N']->get('Show'), "start={$start}&amp;id=" . $admin['id'] . $remember_find));
    if (!$external && $admin['id'] != $_SESSION['logindetails']['id']) {
        $ls->addColumn($admin['loginname'], $GLOBALS['I18N']->get('Del'), $delete_url);
    }
}
print $ls->display();
print '<br/><hr/>';
print PageLinkButton('admin', $GLOBALS['I18N']->get('Add a new administrator'), "start={$start}" . $remember_find);
print '<p class="button">' . PageLink2('importadmin', $GLOBALS['I18N']->get('Import list of admins')) . '</p>';
Example #4
0
 <textarea name="footer" cols="65" rows="5">' . htmlspecialchars($messagedata['footer']) . '</textarea></div>';
  $forwardcontent .= '<div class="field"><label for="forwardfooter">' . $GLOBALS['I18N']->get('forwardfooter') . Help('forwardfooter') . '</label>' . '
  <textarea name="forwardfooter" cols="65" rows="5">' . htmlspecialchars($messagedata['forwardfooter']) . '</textarea></div>';
  if (ALLOW_ATTACHMENTS) {
      // If we have a message id saved, we want to query the attachments that are associated with this
      // message and display that (and allow deletion of!)
      $att_content = '<div class="field"><label for="attach">' . $GLOBALS['I18N']->get('Add attachments to your campaign') . Help('attachments') . '</label>';
      $att_content .= '<div class="info">
    ' . $GLOBALS['I18N']->get('The upload has the following limits set by the server') . ':<br/>
    ' . $GLOBALS['I18N']->get('Maximum size of total data being sent to the server') . ': ' . ini_get('post_max_size') . '<br/>
    ' . $GLOBALS['I18N']->get('Maximum size of each individual file') . ': ' . ini_get('upload_max_filesize') . '</div>';
      if ($id) {
          $result = Sql_Query(sprintf('Select Att.id, Att.filename, Att.remotefile, Att.mimetype, Att.description, Att.size, MsgAtt.id linkid' . ' from %s Att, %s MsgAtt where Att.id = MsgAtt.attachmentid and MsgAtt.messageid = %d', $tables['attachment'], $tables['message_attachment'], $id));
          $ls = new WebblerListing($GLOBALS['I18N']->get('Current Attachments'));
          $totalSize = 0;
          while ($row = Sql_fetch_array($result)) {
              $ls->addElement($row['id']);
              $ls->addColumn($row['id'], $GLOBALS['I18N']->get('filename'), $row['remotefile']);
              $ls->addColumn($row['id'], $GLOBALS['I18N']->get('desc'), $row['description']);
              $ls->addColumn($row['id'], $GLOBALS['I18N']->get('size'), formatBytes($row['size']));
              $totalSize += $row['size'];
              $phys_file = $GLOBALS['attachment_repository'] . '/' . $row['filename'];
              if (is_file($phys_file) && filesize($phys_file)) {
                  $ls->addColumn($row['id'], $GLOBALS['I18N']->get('file'), $GLOBALS['img_tick']);
              } else {
                  $ls->addColumn($row['id'], $GLOBALS['I18N']->get('file'), $GLOBALS['img_cross']);
              }
              $ls->addColumn($row['id'], $GLOBALS['I18N']->get('del'), sprintf('<input type="checkbox" name="deleteattachments[]" value="%s"/>', $row['linkid']));
          }
          $ls->addButton(s('Delete checked'), 'javascript:document.sendmessageform.submit()');
          $att_content .= '<div>' . $ls->display() . '</div>';
Example #5
0
function deleteItem($table, $attributeid, $delete)
{
    global $tables, $replace;
    # delete the index in delete
    $valreq = Sql_Fetch_Row_query("select name from {$table} where id = {$delete}");
    $val = $valreq[0];
    # check dependencies
    $dependencies = array();
    $result = Sql_query("select distinct userid from {$tables['user_attribute']} where\n  attributeid = {$attributeid} and value = {$delete}");
    while ($row = Sql_fetch_array($result)) {
        array_push($dependencies, $row["userid"]);
    }
    if (sizeof($dependencies) == 0) {
        $result = Sql_query("delete from {$table} where id = {$delete}");
    } else {
        if ($replace) {
            $result = Sql_Query("update {$tables['user_attribute']} set value = {$replace} where value = {$delete}");
            $result = Sql_query("delete from {$table} where id = {$delete}");
        } else {
            ?>
    Cannot delete <b><?php 
            echo $val;
            ?>
</b><br />
    The Following record(s) are dependent on this value<br />
    Update the record(s) to not use this attribute value and try again<p>
    <?php 
            for ($i = 0; $i < sizeof($dependencies); $i++) {
                print PageLink2("user", "User " . $dependencies[$i], "id={$dependencies[$i]}") . "<br />\n";
                if ($i > 10) {
                    print "* Too many to list, total dependencies:\n " . sizeof($dependencies) . "<br /><br />";
                    giveAlternative($table, $delete, $attributeid);
                    return 0;
                }
            }
            print "</p><br />";
            giveAlternative($table, $delete, $attributeid);
        }
    }
    return 1;
}
Example #6
0
   # split personal in first and last name
   list($importuser["firstname"], $importuser["lastname"]) = explode(" ", $importuser["personal"], 2);
   $x++;
   if ($x % 25 == 0) {
       print $x . "/{$num} " . $GLOBALS['I18N']->get('done') . "<br/>";
       flush();
   }
   # check for full email
   if ($_POST["onlyfull"] != "yes" || $_POST["onlyfull"] == "yes" && strpos($importuser["personal"], "@") === false && strlen($importuser["email"]) > 4) {
       $new = 0;
       $result = Sql_query(sprintf('SELECT id,uniqid FROM %s
 WHERE email = "%s"', $tables["user"], $importuser["email"]));
       if (Sql_affected_rows()) {
           // Email exist, remember some values to add them to the lists
           $count_exist++;
           $user = Sql_fetch_array($result);
           $userid = $user["id"];
           $uniqid = $user["uniqid"];
           Sql_Query(sprintf('update %s set htmlemail = %d where id = %d', $tables["user"], $_POST["markhtml"] ? "1" : "0", $userid));
       } else {
           // Email does not exist
           $new = 1;
           // Create unique number
           mt_srand((double) microtime() * 1000000);
           $randval = mt_rand();
           $uniqid = getUniqid();
           $query = sprintf('INSERT INTO %s (email,entered,confirmed,uniqid,htmlemail)
    values("%s",current_timestamp,%d,"%s",%d)', $tables["user"], $importuser["email"], $_POST["notify"] != "yes", $uniqid, $_POST["markhtml"] ? "1" : "0");
           $result = Sql_query($query);
           $userid = Sql_Insert_Id($tables['user'], 'id');
           $count_email_add++;
Example #7
0
function ListofLists($current, $fieldname, $subselect)
{
    ## @@TODO, this is slow on more than 150 lists. We should add caching or optimise
    $GLOBALS['systemTimer']->interval();
    $categoryhtml = array();
    ## add a hidden field, so that all checkboxes can be unchecked while keeping the field in POST to process it
    # $categoryhtml['unselect'] = '<input type="hidden" name="'.$fieldname.'[unselect]" value="1" />';
    $categoryhtml['selected'] = '';
    $categoryhtml['all'] = '
  <li><input type="hidden" name="' . $fieldname . '[unselect]" value="-1" /><input type="checkbox" name="' . $fieldname . '[all]"';
    if (!empty($current['all'])) {
        $categoryhtml['all'] .= 'checked';
    }
    $categoryhtml['all'] .= ' />' . s('All Lists') . '</li>';
    $categoryhtml['all'] .= '<li><input type="checkbox" name="' . $fieldname . '[allactive]"';
    if (!empty($current['allactive'])) {
        $categoryhtml['all'] .= 'checked="checked"';
    }
    $categoryhtml['all'] .= ' />' . s('All Public Lists') . '</li>';
    ## need a better way to suppress this
    if ($_GET['page'] != 'send') {
        $categoryhtml['all'] .= '<li>' . PageLinkDialog('addlist', s('Add a list')) . '</li>';
    }
    $result = Sql_query('select * from ' . $GLOBALS['tables']['list'] . $subselect . ' order by category, name');
    $numLists = Sql_Affected_Rows();
    while ($list = Sql_fetch_array($result)) {
        if (empty($list['category'])) {
            if ($numLists < 5) {
                ## for a small number of lists, add them to the @ tab
                $list['category'] = 'all';
            } else {
                $list['category'] = s('Uncategorised');
            }
        }
        if (!isset($categoryhtml[$list['category']])) {
            $categoryhtml[$list['category']] = '';
        }
        if (isset($current[$list['id']]) && $current[$list['id']]) {
            $list['category'] = 'selected';
        }
        $categoryhtml[$list['category']] .= sprintf('<li><input type="checkbox" name="' . $fieldname . '[%d]" value="%d" ', $list['id'], $list['id']);
        # check whether this message has been marked to send to a list (when editing)
        if (isset($current[$list['id']]) && $current[$list['id']]) {
            $categoryhtml[$list['category']] .= 'checked';
        }
        $categoryhtml[$list['category']] .= ' />' . htmlspecialchars(stripslashes($list['name']));
        if ($list['active']) {
            $categoryhtml[$list['category']] .= ' <span class="activelist">' . s('Public list') . '</span>';
        } else {
            $categoryhtml[$list['category']] .= ' <span class="inactivelist">' . s('Private list') . '</span>';
        }
        if (!empty($list['description'])) {
            $desc = nl2br(stripslashes($list['description']));
            $categoryhtml[$list['category']] .= "<br />{$desc}";
        }
        $categoryhtml[$list['category']] .= '</li>';
        $some = 1;
    }
    if (empty($categoryhtml['selected'])) {
        unset($categoryhtml['selected']);
    }
    #  file_put_contents('/tmp/timer.log','ListOfLists '.$GLOBALS['systemTimer']->interval(). "\n",FILE_APPEND);
    return $categoryhtml;
}
Example #8
0
             Sql_Query(sprintf('update %s set email = "%s" where email = "%s"', $tables["user"], "duplicate{$c} " . $user["systemvalues"]["email"], $user["systemvalues"]["email"]));
             addUserHistory("duplicate{$c} " . $user["systemvalues"]["email"], "Duplication clash ", ' User marked duplicate email after clash with imported record');
         } else {
             if ($_SESSION["show_warnings"]) {
                 print Warn($GLOBALS['I18N']->get('Duplicate Email') . ' ' . $user["systemvalues"]["email"] . $GLOBALS['I18N']->get(' user imported as ') . '&quot;' . $GLOBALS['I18N']->get('duplicate') . "{$c} " . $user["systemvalues"]["email"] . "&quot;");
             }
             $user["systemvalues"]["email"] = $GLOBALS['I18N']->get('duplicate') . "{$c} " . $user["systemvalues"]["email"];
         }
     }
 } else {
     dbg('Importing on email ' . $user["systemvalues"]["email"]);
     $result = Sql_query(sprintf('select id,uniqid from %s where email = "%s"', $tables["user"], $user["systemvalues"]["email"]));
     # print "<br/>Using email for matching: ".$user["systemvalues"]["email"];
     $count["emailmatch"]++;
     $exists = Sql_Affected_Rows();
     $existing_user = Sql_fetch_array($result);
 }
 if ($exists) {
     // User exist, remember some values to add them to the lists
     $count["exist"]++;
     $userid = $existing_user["id"];
     $uniqid = $existing_user["uniqid"];
 } else {
     // user does not exist
     $new = 1;
     // Create unique number
     mt_srand((double) microtime() * 1000000);
     $randval = mt_rand();
     # this is very time consuming when importing loads of users as it does a lookup
     # needs speeding up if possible
     $uniqid = getUniqid();
Example #9
0
<?php

/**
 * Created by PhpStorm.
 * User: Danial
 * Date: 5/10/2015
 * Time: 3:02 PM
 */
require_once "../lib/common.php";
$cn = connectDB();
$qry = "SELECT `id`,`interface_name` \n\t\tFROM `tbl_interface` \n\t\tWHERE `bridge`='no' AND `is_active`='active' \n\t\tORDER BY `interface_name` ASC";
$res = Sql_exec($cn, $qry);
$interface_options = "";
while ($dt = Sql_fetch_array($res)) {
    $full_name = "";
    $name_parts = "";
    $interface_name = "";
    $full_name = trim($dt['interface_name']);
    $name_parts = explode("-", $full_name);
    $interface_name = $name_parts[1];
    $interface_options .= '<option value="' . $full_name . '">' . $interface_name . '</option>';
}
ClosedDBConnection($cn);
echo $interface_options;
function deleteItem($table, $attributeid, $delete)
{
    global $tables, $replace;
    # delete the index in delete
    $valreq = Sql_Fetch_Row_query("select name from {$table} where id = {$delete}");
    $val = $valreq[0];
    # check dependencies
    $dependencies = array();
    $result = Sql_query("select distinct userid from {$tables['user_attribute']} where\n  attributeid = {$attributeid} and value = {$delete}");
    while ($row = Sql_fetch_array($result)) {
        array_push($dependencies, $row["userid"]);
    }
    if (sizeof($dependencies) == 0) {
        $result = Sql_query("delete from {$table} where id = {$delete}");
    } else {
        if ($replace) {
            $result = Sql_Query("update {$tables['user_attribute']} set value = {$replace} where value = {$delete}");
            $result = Sql_query("delete from {$table} where id = {$delete}");
        } else {
            print $GLOBALS["I18N"]->get("cannotdelete");
            print " <b>{$val}</b><br />";
            print $GLOBALS["I18N"]->get("dependentrecords") . '<p></p>';
            for ($i = 0; $i < sizeof($dependencies); $i++) {
                print PageLink2("user", $GLOBALS["I18N"]->get("user") . " " . $dependencies[$i], "id={$dependencies[$i]}") . "<br />\n";
                if ($i > 10) {
                    print $GLOBALS['I18N']->get('TooManyToList') . "\n " . sizeof($dependencies) . "<br /><br />";
                    giveAlternative($table, $delete, $attributeid);
                    return 0;
                }
            }
            print "</p><br />";
            giveAlternative($table, $delete, $attributeid);
        }
    }
    return 1;
}
Example #11
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;
}
Example #12
0
} else {
    $content .= '<tr><td colspan="2"><h4>' . $GLOBALS['I18N']->get('This campaign has been sent to subscribers, who are member of the following lists') . ':</h4></td></tr>';
}
$lists_done = array();
$result = Sql_Query(sprintf('select l.name, l.id from %s lm, %s l where lm.messageid = %d and lm.listid = l.id', $tables['listmessage'], $tables['list'], $id));
if (!Sql_Affected_Rows()) {
    $content .= '<tr><td colspan="2">' . $GLOBALS['I18N']->get('None yet') . '</td></tr>';
}
while ($lst = Sql_fetch_array($result)) {
    array_push($lists_done, $lst['id']);
    $content .= sprintf('<tr><td><!--%d--></td><td>%s</td></tr>', $lst['id'], stripslashes($lst['name']));
}
if ($msgdata['excludelist']) {
    $content .= '<tr><td colspan="2"><h4>' . $GLOBALS['I18N']->get('Except when they were also member of these lists') . ':</h4></td></tr>';
    $result = Sql_Query(sprintf('select l.name, l.id from %s l where id in (%s)', $tables['list'], join(',', $msgdata['excludelist'])));
    while ($lst = Sql_fetch_array($result)) {
        $content .= sprintf('<tr><td><!--%d--></td><td>%s</td></tr>', $lst['id'], stripslashes($lst['name']));
    }
}
$content .= '</table>';
$panel = new UIPanel(htmlspecialchars($campaignTitle), $content);
print $panel->display();
?>

<a name="resend"></a><p class="information"><?php 
echo s('Send this campaign to another list');
?>
:</p>
<?php 
echo formStart(' class="messageResend" ');
?>
Example #13
0
header("Content-Disposition: attachment; filename=\"{$filename}\"");
header("Content-Type: application/vnd.ms-excel");
$user_id = $_SESSION['USER_ID'];
//	$server_id = $_GET['action_id'];
$action_id = $_GET['action_id'];
$arr = explode("S", $action_id);
$server_id = $arr[1];
$arr[0] = str_replace('D', '-', $arr[0]);
$arr[0] = str_replace('T', ' ', $arr[0]);
$time_stamp = str_replace('C', ':', $arr[0]);
// 	$qry = "SELECT `msisdn` FROM `tbl_obd_dnd_list` WHERE `user_id`='".$user_id."' AND `server_id` ='".$server_id."'";
$qry = "SELECT `msisdn` FROM `tbl_obd_white_list` WHERE `server_id` ='" . $server_id . "' AND `time_stamp`='" . $time_stamp . "'";
$count = 0;
try {
    $data = Sql_exec($cn, $qry);
    while ($dt = Sql_fetch_array($data)) {
        $arr = array();
        $arr[0] = $dt[0];
        $v_arr[$count] = $arr;
        $count++;
    }
} catch (Exception $e) {
    $is_error = 1;
    array_push($err_field, $qry);
}
ClosedDBConnection($cn);
//$fp = fopen('php://output', 'w');
if ($v_arr != null && $v_arr != "") {
    foreach ($v_arr as $row) {
        echo implode("\t", $row) . "\r\n";
        //fputcsv($fp, array_values($row));
Example #14
0
function loadUser($loginname = '')
{
    if (!Sql_Table_exists('user')) {
        return;
    }
    initialiseUserSession();
    if (!$loginname) {
        if ($_SESSION['userloggedin'] != '' && $_SESSION['username'] != '') {
            $loginname = $_SESSION['username'];
        } else {
            return '';
        }
    }
    $att_req = Sql_Query(sprintf('select attribute.id,
    %s.name,%s.type,
    %s.value,%s.tablename from %s,%s,%s
    where %s.userid = %s.id and %s.email = "%s" and %s.id = %s.attributeid', 'attribute', 'attribute', 'user_attribute', 'attribute', 'user', 'user_attribute', 'attribute', 'user_attribute', 'user', 'user', addslashes($loginname), 'attribute', 'user_attribute'));
    while ($att = Sql_fetch_array($att_req)) {
        #   if (!defined($_SESSION["userdata"]["attribute".$att["id"]])) {
        $_SESSION['userdata']['attribute' . $att['id']] = array('name' => $att['name'], 'value' => $att['value'], 'type' => $att['type'], 'attid' => $att['id'], 'displayvalue' => $att['value']);
        switch ($att['type']) {
            case 'textline':
            case 'hidden':
                $_SESSION['userdata']['attribute' . $att['id']]['displayvalue'] = $att['value'];
                break;
            case 'creditcardno':
                $_SESSION['userdata']['attribute' . $att['id']]['displayvalue'] = obscureCreditCard($att['value']);
                break;
            case 'select':
                $_SESSION['userdata']['attribute' . $att['id']]['displayvalue'] = AttributeValue($att['tablename'], $att['value']);
                break;
            case 'date':
                $_SESSION['userdata']['attribute' . $att['id']]['displayvalue'] = formatDate($att['value']);
                break;
        }
        #    }
    }
    $d_req = Sql_Fetch_Array_Query("select * from user where email = \"{$loginname}\"");
    $_SESSION['userid'] = $d_req['id'];
    foreach (array('email', 'disabled', 'confirmed', 'htmlemail', 'uniqid', 'password', 'foreignkey') as $field) {
        #   if (!defined($_SESSION["userdata"][$field])) {
        $_SESSION['userdata'][$field] = array('name' => $field, 'value' => $d_req[$field], 'type' => 'static', 'displayvalue' => $d_req[$field]);
        #     }
    }
    $_SESSION['usergroups'] = userGroups($loginname);
    if (is_array($GLOBALS['config']['usergreeting'])) {
        $_SESSION['usergreeting'] = '';
        foreach ($GLOBALS['config']['usergreeting'] as $att) {
            $_SESSION['usergreeting'] .= $_SESSION['userdata'][$att]['displayvalue'] . ' ';
        }
        $_SESSION['usergreeting'] = rtrim($_SESSION['usergreeting']);
    }
    dbg('done loading user');
    return 1;
}
Example #15
0
function confirmPage($id)
{
    global $tables, $envelope;
    if (!$_GET['uid']) {
        FileNotFound();
    }
    $req = Sql_Query(sprintf('select * from %s where uniqid = "%s"', $tables['user'], sql_escape($_GET['uid'])));
    $userdata = Sql_Fetch_Array($req);
    if ($userdata['id']) {
        $html = '<ul>';
        $lists = '';
        $currently = Sql_Fetch_Assoc_Query("select confirmed from {$tables['user']} where id = " . $userdata['id']);
        $blacklisted = isBlackListed($userdata['email']);
        foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
            $plugin->subscriberConfirmation($id, $userdata);
        }
        Sql_Query("update {$tables['user']} set confirmed = 1,blacklisted = 0, optedin = 1 where id = " . $userdata['id']);
        $subscriptions = array();
        $req = Sql_Query(sprintf('select list.id,name,description from %s list, %s listuser where listuser.userid = %d and listuser.listid = list.id and list.active', $tables['list'], $tables['listuser'], $userdata['id']));
        if (!Sql_Affected_Rows()) {
            $lists = "\n * " . $GLOBALS['strNoLists'];
            $html .= '<li>' . $GLOBALS['strNoLists'] . '</li>';
        }
        while ($row = Sql_fetch_array($req)) {
            array_push($subscriptions, $row['id']);
            $lists .= "\n *" . stripslashes($row['name']);
            $html .= '<li class="list">' . stripslashes($row['name']) . '<div class="listdescription">' . stripslashes($row['description']) . '</div></li>';
        }
        $html .= '</ul>';
        if ($blacklisted) {
            unBlackList($userdata['id']);
            addUserHistory($userdata['email'], 'Confirmation', s('Subscriber removed from Blacklist for manual confirmation of subscription'));
        }
        if (empty($_SESSION['subscriberConfirmed'])) {
            $_SESSION['subscriberConfirmed'] = array();
        }
        ## 17513 - don't process confirmation if the subscriber is already confirmed
        if (empty($currently['confirmed']) && empty($_SESSION['subscriberConfirmed'][$userdata['email']])) {
            addUserHistory($userdata['email'], 'Confirmation', "Lists: {$lists}");
            $confirmationmessage = str_ireplace('[LISTS]', $lists, getUserConfig("confirmationmessage:{$id}", $userdata['id']));
            if (!TEST) {
                sendMail($userdata['email'], getConfig("confirmationsubject:{$id}"), $confirmationmessage, system_messageheaders(), $envelope);
                $adminmessage = $userdata['email'] . ' has confirmed their subscription';
                if ($blacklisted) {
                    $adminmessage .= "\n\n" . s('Subscriber has been removed from blacklist');
                }
                sendAdminCopy('List confirmation', $adminmessage, $subscriptions);
                addSubscriberStatistics('confirmation', 1);
            }
        } else {
            $html = $GLOBALS['strAlreadyConfirmed'];
        }
        $_SESSION['subscriberConfirmed'][$userdata['email']] = time();
        $info = $GLOBALS['strConfirmInfo'];
    } else {
        logEvent('Request for confirmation for invalid user ID: ' . substr($_GET['uid'], 0, 150));
        $html = 'Error: ' . $GLOBALS['strUserNotFound'];
        $info = $GLOBALS['strConfirmFailInfo'];
    }
    $res = '<title>' . $GLOBALS['strConfirmTitle'] . '</title>';
    $res .= $GLOBALS['pagedata']['header'];
    $res .= '<h3>' . $info . '</h3>';
    $res .= $html;
    $res .= '<p>' . $GLOBALS['PoweredBy'] . '</p>';
    $res .= $GLOBALS['pagedata']['footer'];
    return $res;
}
Example #16
0
<?php

//session_start();
header('Access-Control-Allow-Origin: *');
require_once "../lib/common.php";
//require_once "../Lib/filewriter.php";
//print_r($info);
//print_r($_SESSION);
//exit;
//
$cid = $_POST["info"];
//echo $cid;
$cn = connectDB();
//$qry = "select * from `bwc_ruleinfo`";
$qry = "select * from `bwc_ruleinfo` where `clientId`='{$cid}'";
$rs = Sql_exec($cn, $qry);
$data = array();
$i = 0;
while ($row = Sql_fetch_array($rs)) {
    $j = 0;
    $data[$i][$j++] = Sql_Result($row, "ruleId");
    $data[$i][$j++] = Sql_Result($row, "src");
    $data[$i][$j++] = Sql_Result($row, "dst");
    $data[$i][$j++] = Sql_Result($row, "port");
    $data[$i][$j++] = Sql_Result($row, "mac");
    $data[$i][$j++] = Sql_Result($row, "percentage");
    $i++;
}
echo json_encode($data);
ClosedDBConnection($cn);
<?php

require_once "../lib/common.php";
$info = $_POST['info'];
$remoteCn = remote_connectDB('ISMP');
$id = mysql_real_escape_string(htmlspecialchars($info['acc_name']));
$amount_credit = mysql_real_escape_string(htmlspecialchars($info['amount_credit']));
$is_error = 0;
$check_balance_qry = "select `balance` from `tbl_smsgw_account` where `is_active`='active'";
$check_balance_rs = Sql_fetch_array(Sql_exec($remoteCn, $check_balance_qry));
if (doubleval($check_balance_rs['balance']) >= doubleval($amount_credit)) {
    $qry = "update tbl_smsgw_account set balance=balance+{$amount_credit} where id='{$id}' and is_active='active'";
    $qry_admin = "update tbl_smsgw_account set balance=balance-{$amount_credit} where acc_type='admin' and is_active='active'";
    try {
        $res = Sql_exec($remoteCn, $qry_admin);
        $rs = Sql_exec($remoteCn, $qry);
    } catch (Exception $e) {
        $is_error = 1;
    }
} else {
    $is_error = 2;
}
echo $is_error;
ClosedDBConnection($remoteCn);
Example #18
0
function ListAvailableLists($userid = 0, $lists_to_show = "")
{
    global $tables;
    if (isset($_POST['list'])) {
        $list = $_POST["list"];
    } else {
        $list = '';
    }
    $subselect = "";
    $listset = array();
    $subscribed = array();
    $showlists = explode(",", $lists_to_show);
    if (PREFERENCEPAGE_SHOW_PRIVATE_LISTS && !empty($userid)) {
        ## merge with the subscribed lists, regardless of public state
        $req = Sql_Query(sprintf('select listid from %s where userid = %d', $tables['listuser'], $userid));
        while ($row = Sql_Fetch_Row($req)) {
            $subscribed[] = $row[0];
        }
        $showlists = array_unique(array_merge($showlists, $subscribed));
    }
    foreach ($showlists as $listid) {
        if (preg_match("/^\\d+\$/", $listid)) {
            array_push($listset, $listid);
        }
    }
    if (sizeof($listset) >= 1) {
        $subselect = "where id in (" . join(",", $listset) . ") ";
    }
    $some = 0;
    $html = '<ul class="list">';
    $result = Sql_query("SELECT * FROM {$GLOBALS["tables"]["list"]} {$subselect} order by listorder, name");
    while ($row = Sql_fetch_array($result)) {
        if ($row["active"] || in_array($row['id'], $subscribed)) {
            $html .= '<li class="list"><input type="checkbox" name="list[' . $row["id"] . ']" value="signup" ';
            if (isset($list[$row["id"]]) && $list[$row['id']] == "signup") {
                $html .= 'checked="checked"';
            }
            if ($userid) {
                $req = Sql_Fetch_Row_Query(sprintf('select userid from %s where userid = %d and listid = %d', $GLOBALS["tables"]["listuser"], $userid, $row["id"]));
                if (Sql_Affected_Rows()) {
                    $html .= 'checked="checked"';
                }
            }
            $html .= " /><b>" . stripslashes($row["name"]) . '</b><div class="listdescription">';
            $desc = nl2br(stripslashes($row["description"]));
            #     $html .= '<input type="hidden" name="listname['.$row["id"] . ']" value="'.htmlspecialchars(stripslashes($row["name"])).'"/>';
            $html .= $desc . '</div></li>';
            $some++;
            if ($some == 1) {
                $singlelisthtml = sprintf('<input type="hidden" name="list[%d]" value="signup" />', $row["id"]);
                $singlelisthtml .= '<input type="hidden" name="listname[' . $row["id"] . ']" value="' . htmlspecialchars(stripslashes($row["name"])) . '"/>';
            }
        }
    }
    $html .= '</ul>';
    $hidesinglelist = getConfig("hide_single_list");
    if (!$some) {
        global $strNotAvailable;
        return '<p class="information">' . $strNotAvailable . '</p>';
    } elseif ($some == 1 && ($hidesinglelist == "true" || $hidesinglelist === true || $hidesinglelist === "1")) {
        return $singlelisthtml;
    } else {
        global $strPleaseSelect;
        return '<p class="information">' . $strPleaseSelect . ':</p>' . $html;
    }
}
Example #19
0
    }
    reset($attributes);
    while (list($key, $val) = each($attributes)) {
        $value = UserAttributeValue($user['id'], $val['id']);
        fwrite($exportfile, quoteEnclosed($value, $col_delim, $row_delim) . $col_delim);
    }
    if ($exporthistory) {
        fwrite($exportfile, quoteEnclosed($user['ip'], $col_delim, $row_delim) . $col_delim);
        fwrite($exportfile, quoteEnclosed($user['summary'], $col_delim, $row_delim) . $col_delim);
        fwrite($exportfile, quoteEnclosed($user['detail'], $col_delim, $row_delim) . $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)) {
        fwrite($exportfile, 'No Lists');
    }
    while ($list = Sql_fetch_array($lists)) {
        fwrite($exportfile, stripslashes($list['name']) . '; ');
    }
    fwrite($exportfile, $row_delim);
}
print '<script type="text/javascript">
var parentJQuery = window.parent.jQuery;
parentJQuery("#progressbar").updateProgress("' . $todo . ',' . $todo . '");
parentJQuery("#busyimage").hide();
parentJQuery("#progresscount").html("' . s('All done') . '");
</script>';
flush();
$_SESSION['export']['fileready'] = $exportfileName;
print '<script type="text/javascript">
document.location = document.location;
</script>';
Example #20
0
    $query = 'select * from %s %s order by entered desc, id desc %s';
    $query = sprintf($query, $tables['eventlog'], $where, $limit);
    $result = Sql_query($query);
} else {
    $query = 'select * from %s %s order by entered desc, id desc';
    $query = sprintf($query, $tables['eventlog'], $where);
    $result = Sql_Query($query);
}
$buttons = new ButtonGroup(new Button(PageURL2("eventlog"), 'delete'));
$buttons->addButton(new ConfirmButton($GLOBALS['I18N']->get('Are you sure you want to delete all events older than 2 months?'), PageURL2("eventlog", "Delete", "start={$start}&action=deleteprocessed"), $GLOBALS['I18N']->get('Delete all (&gt; 2 months old)')));
$buttons->addButton(new ConfirmButton($GLOBALS['I18N']->get('Are you sure you want to delete all events matching this filter?'), PageURL2("eventlog", "Delete", "start={$start}&action=deleteall{$find_url}"), $GLOBALS['I18N']->get('Delete all')));
print $buttons->show();
if (!Sql_Num_Rows($result)) {
    print '<p class="information">' . $GLOBALS['I18N']->get('No events available') . '</p>';
}
printf('<form method="get" action="">
<input type="hidden" name="page" value="eventlog" />
<input type="hidden" name="start" value="%d" />
%s: <input type="text" name="filter" value="%s" /> %s <input type="checkbox" name="exclude" value="1" %s />
</form><br/>', $start, $GLOBALS['I18N']->get('Filter'), htmlspecialchars(stripslashes($filter)), $GLOBALS['I18N']->get('Exclude filter'), $exclude == 1 ? 'checked="checked"' : '');
$ls = new WebblerListing($GLOBALS['I18N']->get('Events'));
# @@@@ Looks like there are a few del, page, date, message which may not be i18nable.
while ($event = Sql_fetch_array($result)) {
    $ls->addElement($event["id"]);
    $ls->setClass($event["id"], 'row1');
    $ls->addColumn($event["id"], $GLOBALS['I18N']->get('date'), $event["entered"]);
    $ls->addColumn($event["id"], $GLOBALS['I18N']->get('message'), strip_tags($event["entry"]));
    $delete_url = sprintf('<a href="javascript:deleteRec(\'%s\');" class="del" >%s</a>', PageURL2("eventlog", "delete", "start={$start}&amp;delete=" . $event["id"]), $GLOBALS['I18N']->get('del'));
    $ls->addRow($event['id'], '<div class="listingsmall">' . $GLOBALS['I18N']->get('page') . ': ' . $event["page"] . '</div>', '<div class="fright">' . $delete_url . '&nbsp;&nbsp;</div>');
}
print $ls->display();
Example #21
0
$offset = 0;
if (isset($start) && $start > 0) {
    $offset = $start;
} else {
    $start = 0;
}
$paging = '';
if ($total > $_SESSION['messagenumpp']) {
    $paging = simplePaging("messages{$url_keep}", $start, $total, $_SESSION['messagenumpp'], $GLOBALS['I18N']->get('Campaigns'));
}
$ls = new WebblerListing(s('Campaigns'));
$ls->usePanel($paging);
## messages table
if ($total) {
    $result = Sql_query('SELECT * FROM ' . $tables['message'] . " {$whereClause} {$sortBySql} limit {$limit} offset {$offset}");
    while ($msg = Sql_fetch_array($result)) {
        $editlink = '';
        $messagedata = loadMessageData($msg['id']);
        if ($messagedata['subject'] != $messagedata['campaigntitle']) {
            $listingelement = '<!--' . $msg['id'] . '-->' . stripslashes($messagedata['campaigntitle']) . '<br/><strong>' . stripslashes($messagedata['subject']) . '</strong>';
        } else {
            $listingelement = '<!--' . $msg['id'] . '-->' . stripslashes($messagedata['subject']);
        }
        #   $listingelement = '<!--'.$msg['id'].'-->'.stripslashes($messagedata["campaigntitle"]);
        if ($msg['status'] == 'draft') {
            $editlink = PageUrl2('send&id=' . $msg['id']);
        }
        $ls->addElement($listingelement, $editlink);
        $ls->setClass($listingelement, 'row1');
        $uniqueviews = Sql_Fetch_Row_Query("select count(userid) from {$tables['usermessage']} where viewed is not null and status = 'sent' and messageid = " . $msg['id']);
        $clicks = Sql_Fetch_Row_Query("select sum(clicked) from {$tables['linktrack_ml']} where messageid = " . $msg['id']);
Example #22
0
function loadMessageData($msgid)
{
    $default = array('from' => getConfig('message_from_address'), 'google_track' => getConfig('always_add_googletracking'));
    if (empty($default['from'])) {
        $default['from'] = getConfig('admin_address');
    }
    if (!isset($GLOBALS['MD']) || !is_array($GLOBALS['MD'])) {
        $GLOBALS['MD'] = array();
    }
    if (isset($GLOBALS['MD'][$msgid])) {
        return $GLOBALS['MD'][$msgid];
    }
    ## when loading an old message that hasn't got data stored in message data, load it from the message table
    $prevMsgData = Sql_Fetch_Assoc_Query(sprintf('select * from %s where id = %d', $GLOBALS['tables']['message'], $msgid));
    $finishSending = time() + DEFAULT_MESSAGEAGE;
    $messagedata = array('template' => getConfig('defaultmessagetemplate'), 'sendformat' => 'HTML', 'message' => '', 'forwardmessage' => '', 'textmessage' => '', 'rsstemplate' => '', 'embargo' => array('year' => date('Y'), 'month' => date('m'), 'day' => date('d'), 'hour' => date('H'), 'minute' => date('i')), 'repeatinterval' => 0, 'repeatuntil' => array('year' => date('Y'), 'month' => date('m'), 'day' => date('d'), 'hour' => date('H'), 'minute' => date('i')), 'requeueinterval' => 0, 'requeueuntil' => array('year' => date('Y'), 'month' => date('m'), 'day' => date('d'), 'hour' => date('H'), 'minute' => date('i')), 'finishsending' => array('year' => date('Y', $finishSending), 'month' => date('m', $finishSending), 'day' => date('d', $finishSending), 'hour' => date('H', $finishSending), 'minute' => date('i', $finishSending)), 'fromfield' => '', 'subject' => '', 'forwardsubject' => '', 'footer' => getConfig('messagefooter'), 'forwardfooter' => getConfig('forwardfooter'), 'status' => '', 'tofield' => '', 'replyto' => '', 'targetlist' => '', 'criteria_match' => '', 'sendurl' => '', 'sendmethod' => 'inputhere', 'testtarget' => '', 'notify_start' => getConfig('notifystart_default'), 'notify_end' => getConfig('notifyend_default'), 'google_track' => $default['google_track'] == 'true' || $default['google_track'] === true || $default['google_track'] == '1', 'excludelist' => array(), 'sentastest' => 0);
    if (is_array($prevMsgData)) {
        foreach ($prevMsgData as $key => $val) {
            $messagedata[$key] = $val;
        }
    }
    if (!empty($GLOBALS['commandline']) && $_GET['page'] == 'send') {
        $messagedata['fromfield'] = $_POST['from'];
        $messagedata['subject'] = $_POST['subject'];
        $messagedata['message'] = $_POST['message'];
        $messagedata['targetlist'] = $_POST['targetlist'];
    }
    if ($messagedata['subject'] == '(no title)') {
        $messagedata['subject'] = '(no subject)';
    }
    $msgdata_req = Sql_Query(sprintf('select * from %s where id = %d', $GLOBALS['tables']['messagedata'], $msgid));
    while ($row = Sql_Fetch_Assoc($msgdata_req)) {
        if (strpos($row['data'], 'SER:') === 0) {
            $data = stripSlashesArray(unserialize(substr($row['data'], 4)));
        } else {
            $data = stripslashes($row['data']);
        }
        if (!in_array($row['name'], array('astext', 'ashtml', 'astextandhtml', 'aspdf', 'astextandpdf'))) {
            ## don't overwrite counters in the message table from the data table
            $messagedata[stripslashes($row['name'])] = $data;
        }
    }
    foreach (array('embargo', 'repeatuntil', 'requeueuntil') as $datefield) {
        if (!is_array($messagedata[$datefield])) {
            $messagedata[$datefield] = array('year' => date('Y'), 'month' => date('m'), 'day' => date('d'), 'hour' => date('H'), 'minute' => date('i'));
        }
    }
    // Load lists that were targetted with message...
    $result = Sql_Query(sprintf('select list.name,list.id 
    from ' . $GLOBALS['tables']['listmessage'] . ' listmessage,' . $GLOBALS['tables']['list'] . ' list
     where listmessage.messageid = %d and listmessage.listid = list.id', $msgid));
    while ($lst = Sql_fetch_array($result)) {
        $messagedata['targetlist'][$lst['id']] = 1;
    }
    ## backwards, check that the content has a url and use it to fill the sendurl
    if (empty($messagedata['sendurl'])) {
        ## can't do "ungreedy matching, in case the URL has placeholders, but this can potentially
        ## throw problems
        if (preg_match('/\\[URL:(.*)\\]/i', $messagedata['message'], $regs)) {
            $messagedata['sendurl'] = $regs[1];
        }
    }
    if (empty($messagedata['sendurl']) && !empty($messagedata['message'])) {
        # if there's a message and no url, make sure to show the editor, and not the URL input
        $messagedata['sendmethod'] = 'inputhere';
    }
    ### parse the from field into it's components - email and name
    if (preg_match('/([^ ]+@[^ ]+)/', $messagedata['fromfield'], $regs)) {
        # if there is an email in the from, rewrite it as "name <email>"
        $messagedata['fromname'] = str_replace($regs[0], '', $messagedata['fromfield']);
        $messagedata['fromemail'] = $regs[0];
        # if the email has < and > take them out here
        $messagedata['fromemail'] = str_replace('<', '', $messagedata['fromemail']);
        $messagedata['fromemail'] = str_replace('>', '', $messagedata['fromemail']);
        # make sure there are no quotes around the name
        $messagedata['fromname'] = str_replace('"', '', ltrim(rtrim($messagedata['fromname'])));
    } elseif (strpos($messagedata['fromfield'], ' ')) {
        # if there is a space, we need to add the email
        $messagedata['fromname'] = $messagedata['fromfield'];
        #  $cached[$messageid]["fromemail"] = "listmaster@$domain";
        $messagedata['fromemail'] = $default['from'];
    } else {
        $messagedata['fromemail'] = $default['from'];
        $messagedata['fromname'] = $messagedata['fromfield'];
    }
    // disallow an email address in the name
    if (preg_match('/([^ ]+@[^ ]+)/', $messagedata['fromname'], $regs)) {
        $messagedata['fromname'] = str_replace($regs[0], '', $messagedata['fromname']);
    }
    // clean up
    $messagedata['fromemail'] = str_replace(',', '', $messagedata['fromemail']);
    $messagedata['fromname'] = str_replace(',', '', $messagedata['fromname']);
    $messagedata['fromname'] = trim($messagedata['fromname']);
    # erase double spacing
    while (strpos($messagedata['fromname'], '  ')) {
        $messagedata['fromname'] = str_replace('  ', ' ', $messagedata['fromname']);
    }
    ## if the name ends up being empty, copy the email
    if (empty($messagedata['fromname'])) {
        $messagedata['fromname'] = $messagedata['fromemail'];
    }
    if (isset($messagedata['targetlist']['unselect'])) {
        unset($messagedata['targetlist']['unselect']);
    }
    if (isset($messagedata['excludelist']['unselect'])) {
        unset($messagedata['excludelist']['unselect']);
    }
    if (empty($messagedata['campaigntitle'])) {
        if ($messagedata['subject'] != '(no subject)') {
            $messagedata['campaigntitle'] = $messagedata['subject'];
        } else {
            $messagedata['campaigntitle'] = '(no title)';
        }
    }
    ## copy subject to title
    if ($messagedata['campaigntitle'] == '(no title)' && $messagedata['subject'] != '(no subject)') {
        $messagedata['campaigntitle'] = $messagedata['subject'];
    }
    $GLOBALS['MD'][$msgid] = $messagedata;
    #  var_dump($messagedata);
    return $messagedata;
}
Example #23
0
$filterpanel .= '</form></div>';
//$filterpanel .= '<tr><td colspan="4"></td></tr>
//</table>';
print Info($countpanel);
$panel = new UIPanel($GLOBALS['I18N']->get('Find subscribers'), $filterpanel);
print $panel->display();
#if (($require_login && isSuperUser()) || !$require_login)
print '<div class="actions">';
print '<div id="add-csv-button">' . PageLinkButton('dlusers', $GLOBALS['I18N']->get('Download all users as CSV file'), 'nocache=' . uniqid('')) . '</div>';
print '<div id="add-user-button">' . PageLinkButton('adduser', $GLOBALS['I18N']->get('Add a User')) . '</div>';
print '</div>';
$some = 0;
$ls = new WebblerListing(s('users'));
$ls->usePanel($paging);
if ($result) {
    while ($user = Sql_fetch_array($result)) {
        $some = 1;
        $ls->addElement($user['email'], PageURL2("user&amp;start={$start}&amp;id=" . $user['id'] . $find_url));
        $ls->setClass($user['email'], 'row1');
        ## we make one column with the subscriber status being "on" or "off"
        ## two columns are too confusing and really unnecessary
        # ON = confirmed &&  !blacklisted
        #    $ls->addColumn($user["email"], $GLOBALS['I18N']->get('confirmed'), $user["confirmed"] ? $GLOBALS["img_tick"] : $GLOBALS["img_cross"]);
        #   if (in_array("blacklist", $columns)) {
        $onblacklist = isBlackListed($user['email']);
        #    $ls->addColumn($user["email"], $GLOBALS['I18N']->get('bl l'), $onblacklist ? $GLOBALS["img_tick"] : $GLOBALS["img_cross"]);
        #  }
        if ($user['confirmed'] && !$onblacklist) {
            $ls_confirmed = $GLOBALS['img_tick'];
        } else {
            $ls_confirmed = $GLOBALS['img_cross'];
            } else {
                output($GLOBALS['I18N']->get('Please leave this window open. You have batch processing enabled, so it will reload several times to send the messages. Reports will be sent by email to') . ' ' . getConfig("report_address"));
            }
        } else {
            output($GLOBALS['I18N']->get('Your webserver is running in safe_mode. Please keep this window open. It may reload several times to make sure all messages are sent.') . ' ' . $GLOBALS['I18N']->get('Reports will be sent by email to') . ' ' . getConfig("report_address"));
        }
    }
}
Sql_query("SET SQL_BIG_TABLES=1");
$script_stage = 2;
# we know the messages to process
include_once "footer.inc";
if (!$num_per_batch) {
    $num_per_batch = 1000000;
}
while ($message = Sql_fetch_array($messages)) {
    $failed_sent = 0;
    $throttlecount = 0;
    $messageid = $message["id"];
    $userselection = $message["userselection"];
    $rssmessage = $message["rsstemplate"];
    $msgdata = loadMessageData($messageid);
    if (!empty($msgdata['notify_start']) && !isset($msgdata['start_notified'])) {
        $notifications = explode(',', $msgdata['notify_start']);
        foreach ($notifications as $notification) {
            sendMail($notification, $GLOBALS['I18N']->get('Message Sending has started'), sprintf($GLOBALS['I18N']->get('phplist has started sending the message with subject %s'), $message['subject'] . "\n" . sprintf($GLOBALS['I18N']->get('to view the progress of this message, go to %s'), getConfig('website') . $GLOBALS['adminpages'] . '/?page=messages&type=sent')));
        }
        Sql_Query(sprintf('insert ignore into %s (name,id,data) values("start_notified",%d,now())', $GLOBALS['tables']['messagedata'], $messageid));
    }
    output($GLOBALS['I18N']->get('Processing message') . ' ' . $messageid);
    if (ENABLE_RSS && $message["rsstemplate"]) {
Example #25
0
function loadUser($loginname = "") {
	dbg("Loading User");
  if (!Sql_Table_exists("user")) return;
	initialiseUserSession();
  if (!$loginname) {
  	if ($_SESSION["userloggedin"] != "" && $_SESSION["username"] != "") {
    	$loginname = $_SESSION["username"];
    } else {
    	return "";
    }
  }
  $att_req = Sql_Query(sprintf('select attribute.id,
  	%s.name,%s.type,
  	%s.value,%s.tablename from %s,%s,%s
    where %s.userid = %s.id and %s.email = "%s" and %s.id = %s.attributeid',
    "attribute",
    "attribute",
    "user_attribute",
    "attribute",
    "user",
    "user_attribute",
    "attribute",
    "user_attribute",
    "user",
		"user",
		$loginname,
		"attribute",
		"user_attribute"
	));
  while ($att = Sql_fetch_array($att_req)) {
#  	if (!defined($_SESSION["userdata"]["attribute".$att["id"]])) {
      $_SESSION["userdata"]["attribute".$att["id"]] = array(
        "name" => $att["name"],
        "value" => $att["value"],
        "type" => $att["type"],
        "attid" => $att["id"]
        );
      switch ($att["type"]) {
        case "textline":
        case "hidden":
          $_SESSION["userdata"]["attribute".$att["id"]]["displayvalue"] =
            $att["value"];
          break;
        case "creditcardno":
          $_SESSION["userdata"]["attribute".$att["id"]]["displayvalue"] =
            obscureCreditCard($att["value"]);
          break;
        case "select":
          $_SESSION["userdata"]["attribute".$att["id"]]["displayvalue"] =
            AttributeValue($att["tablename"],$att["value"]);
          break;
      }
#    }
  }
  $d_req = Sql_Fetch_Array_Query("select * from user where email = \"$loginname\"");
  $_SESSION["userid"] = $d_req["id"];
  foreach (array("email","disabled","confirmed","htmlemail","uniqid") as $field) {
#  	if (!defined($_SESSION["userdata"][$field])) {
      $_SESSION["userdata"][$field] = array(
        "name" => $field,
        "value" => $d_req[$field],
        "type" => "static",
        "displayvalue" => $d_req[$field]
      );
#   	}
	}
  dbg("done loading user");
  $_SESSION["groups"] = userGroups($loginname);
  return 1;
}
Example #26
0
function ListAvailableLists($userid = 0,$lists_to_show = "") {
  global $tables;
  $list = $_POST["list"];
	$subselect = "";$listset = array();

	$showlists = explode(",",$lists_to_show);
	foreach ($showlists as $listid)
		if (preg_match("/^\d+$/",$listid))
			array_push($listset,$listid);
	if (sizeof($listset) >= 1) {
		$subselect = "where id in (".join(",",$listset).") ";
	}

	$some = 0;
	$html = '<ul class="list">';
  $result = Sql_query("SELECT * FROM {$tables["list"]} $subselect order by listorder");
  while ($row = Sql_fetch_array($result)) {
    if ($row["active"]) {
      $html .= '<li class="list"><input type="checkbox" name="list['.$row["id"] . ']" value=signup ';
      if ($list[$row["id"]] == "signup")
        $html .= "checked";
      if ($userid) {
        $req = Sql_Fetch_Row_Query(sprintf('select userid from %s where userid = %d and listid = %d',
          $tables["listuser"],$userid,$row["id"]));
        if (Sql_Affected_Rows())
          $html .= "checked";
      }
      $html .= "/><b>".$row["name"].'</b><div class="listdescription">';
      $desc = nl2br(StripSlashes($row["description"]));
      $html .= '<input type=hidden name="listname['.$row["id"] . ']" value="'.$row["name"].'"/>';
      $html .= $desc.'</div></li>';
			$some++;
			if ($some == 1) {
				$singlelisthtml = sprintf('<input type="hidden" name="list[%d]" value="signup">',$row["id"]);
      	$singlelisthtml .= '<input type="hidden" name="listname['.$row["id"] . ']" value="'.$row["name"].'"/>';
			}
    }
  }
  $html .= '</ul>';
	$hidesinglelist = getConfig("hide_single_list");
  if (!$some) {
    global $strNotAvailable;
    return '<p>'.$strNotAvailable.'</p>';
  } elseif ($some == 1 && $hidesinglelist == "true") {
		return $singlelisthtml;
	} else {
		global $strPleaseSelect;
		return '<p>'.$strPleaseSelect .':</p>'.$html;
	}
}
Example #27
0
<?php

require_once "../lib/common.php";
$remoteCn = remote_connectDB('ISMP');
$qry = "SELECT \t`app_id`,`app_name`,`config` FROM `tbl_smsgw_config` WHERE `app_id` = 1 AND `app_name` = 'smsgw'";
$res = Sql_exec($remoteCn, $qry);
$dt = Sql_fetch_array($res);
$decode = $dt['config'];
$decode = json_decode($decode, true);
$data = array();
foreach ($decode as $key => $val) {
    $data[$key] = $val;
}
$data['action_id'] = $dt['app_id'];
echo json_encode($data);
ClosedDBConnection($remoteCn);
Example #28
0
    print '<div class="fright">' . $buttons->show() . '</div>';
}
print "</div><!-- .actions div-->\n";
if (!Sql_Num_Rows($result)) {
    switch ($status) {
        case 'unidentified':
            print '<p class="information">' . s('no unidentified bounces available') . '</p>';
            break;
        case 'processed':
            print '<p class="information">' . s('no processed bounces available') . '</p>';
            break;
    }
}
$ls = new WebblerListing(s($status) . ' ' . s('bounces'));
$ls->usePanel($paging);
while ($bounce = Sql_fetch_array($result)) {
    #@@@ not sure about these ones - bounced list message
    $element = $bounce['id'];
    $ls->addElement($element, PageUrl2('bounce&type=' . $status . '&id=' . $bounce['id']));
    if (preg_match("#bounced list message ([\\d]+)#", $bounce['status'], $regs)) {
        $messageid = PageLink2('message&id=' . $regs[1], shortenTextDisplay(campaignTitle($regs[1]), 30));
        #sprintf('<a href="./?page=message&amp;id=%d">%d</a>',$regs[1],$regs[1]);
    } elseif ($bounce['status'] == 'bounced system message') {
        $messageid = $GLOBALS['I18N']->get('System Message');
    } else {
        $messageid = $GLOBALS['I18N']->get('Unknown');
    }
    /*  if (preg_match('/Action: delayed\s+Status: 4\.4\.7/im',$bounce["data"])) {
            $ls->addColumn($element,'delayed',$GLOBALS['img_tick']);
          } else {
            $ls->addColumn($element,'delayed',$GLOBALS['img_cross']);
Example #29
0
            case 'owner':
                $subselect = ' where owner = ' . $_SESSION['logindetails']['id'];
                break;
            case 'all':
                $subselect = '';
                break;
            case 'none':
            default:
                $subselect = ' where id = 0';
                break;
        }
    }
    $result = Sql_query('SELECT id,name FROM ' . $tables['list'] . "{$subselect} ORDER BY listorder");
    $c = 0;
    if (Sql_Affected_Rows() == 1) {
        $row = Sql_fetch_array($result);
        printf('<input type="hidden" name="listname[%d]" value="%s"><input type="hidden" name="importlists[%d]" value="%d">' . $GLOBALS['I18N']->get('adding_users') . ' <b>%s</b>', $c, stripslashes($row['name']), $c, $row['id'], stripslashes($row['name']));
    } else {
        print '<h3>' . s('Select the lists to add the emails to') . '</h3>';
        print ListSelectHTML($import_lists, 'importlists', $subselect);
    }
    ?>


<script language="Javascript" type="text/javascript">

var fieldstocheck = new Array();
var fieldnames = new Array();
function addFieldToCheck(value,name) {
  fieldstocheck[fieldstocheck.length] = value;
  fieldnames[fieldnames.length] = name;
Example #30
0
function confirmPage($id)
{
    global $tables, $envelope;
    if (!$_GET["uid"]) {
        FileNotFound();
    }
    $req = Sql_Query(sprintf('select * from %s where uniqid = "%s"', $tables["user"], sql_escape($_GET["uid"])));
    $userdata = Sql_Fetch_Array($req);
    if ($userdata["id"]) {
        $blacklisted = isBlackListed($userdata["email"]);
        foreach ($GLOBALS['plugins'] as $pluginname => $plugin) {
            $plugin->subscriberConfirmation($id, $userdata);
        }
        $html = '<ul>';
        $lists = '';
        Sql_Query("update {$tables["user"]} set confirmed = 1,blacklisted = 0 where id = " . $userdata["id"]);
        # just in case the DB is not updated, should be merged with the above later
        Sql_Query("update {$tables["user"]} set optedin = 1 where id = " . $userdata["id"], 1);
        $subscriptions = array();
        $req = Sql_Query(sprintf('select list.id,name,description from %s list, %s listuser where listuser.userid = %d and listuser.listid = list.id and list.active', $tables['list'], $tables['listuser'], $userdata['id']));
        if (!Sql_Affected_Rows()) {
            $lists = "\n * " . $GLOBALS["strNoLists"];
            $html .= '<li>' . $GLOBALS["strNoLists"] . '</li>';
        }
        while ($row = Sql_fetch_array($req)) {
            array_push($subscriptions, $row['id']);
            $lists .= "\n *" . stripslashes($row["name"]);
            $html .= '<li class="list">' . stripslashes($row["name"]) . '<div class="listdescription">' . stripslashes($row["description"]) . '</div></li>';
        }
        $html .= '</ul>';
        if ($blacklisted) {
            unBlackList($userdata['id']);
            addUserHistory($userdata["email"], "Confirmation", s("Subscriber removed from Blacklist for manual confirmation of subscription"));
        }
        if (empty($_SESSION['subscriberConfirmed'])) {
            addUserHistory($userdata["email"], "Confirmation", "Lists: {$lists}");
            $confirmationmessage = str_ireplace('[LISTS]', $lists, getUserConfig("confirmationmessage:{$id}", $userdata["id"]));
            if (!TEST) {
                sendMail($userdata["email"], getConfig("confirmationsubject:{$id}"), $confirmationmessage, system_messageheaders(), $envelope);
                $adminmessage = $userdata["email"] . " has confirmed their subscription";
                if ($blacklisted) {
                    $adminmessage .= "\n\n" . s("Subscriber has been removed from blacklist");
                }
                sendAdminCopy("List confirmation", $adminmessage, $subscriptions);
                addSubscriberStatistics('confirmation', 1);
            }
        }
        $_SESSION['subscriberConfirmed'] = time();
        $info = $GLOBALS["strConfirmInfo"];
    } else {
        logEvent("Request for confirmation for invalid user ID: " . substr($_GET["uid"], 0, 150));
        $html .= 'Error: ' . $GLOBALS["strUserNotFound"];
        $info = $GLOBALS["strConfirmFailInfo"];
    }
    $res = '<title>' . $GLOBALS["strConfirmTitle"] . '</title>';
    $res .= $GLOBALS['pagedata']["header"];
    $res .= '<h3>' . $info . '</h3>';
    $res .= $html;
    $res .= "<p>" . $GLOBALS["PoweredBy"] . '</p>';
    $res .= $GLOBALS['pagedata']["footer"];
    return $res;
}