email2.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:8k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: email2.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.17 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Facility to send e-mail to all (or some) users
- // | (administration interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- require_once('./global.php');
- //Nullify WTN-WDYL Team
- admin_header('Email Users', 'Email Users');
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "step1";
- }
- if ($_REQUEST['do'] == "step2" OR $_REQUEST['do'] == "step3") {
- if ($_REQUEST['do'] == "step3") {
- $_REQUEST = array_merge($_REQUEST, unserialize($_REQUEST['variables']));
- $_REQUEST['do'] = "step3";
- }
- //////////////////// USERID RANGE ////////////////////
- give_default($_REQUEST[greater], 0);
- $where .= " WHERE id >= '" . mysql_escape_string($_REQUEST[greater]) . "'";
- if ($_REQUEST[lessthan]) {
- $where .= " AND id <= '" . mysql_escape_string($_REQUEST[lessthan]) . "'";
- }
- //////////////////// CUSTOM FIELDS ////////////////////
-
- $db->query("SELECT * FROM user_def ORDER BY displayorder");
- while ($result = $db->row_array()) {
-
- $where .= field_search($result,
- $_REQUEST[custom_fields][$result[name]],
- $_REQUEST[custom_fields]['extra' . $result[name]],
- 'user',
- $_REQUEST[custom_fields][$result[name]."_match"],
- $_REQUEST[custom_fields][$result[name]."_not"]);
- }
- //////////////////// EMAIL / USERNAME ////////////////////
- if (trim($_REQUEST[username]) != '') {
- $where .= " AND username LIKE '" . mysql_escape_string($_REQUEST[username]) . "'";
- }
- if (trim($_REQUEST[email]) != '') {
- $where .= " AND email LIKE '" . mysql_escape_string($_REQUEST[email]) . "'";
- }
- //////////////////// DATES ////////////////////
- // earliest date registered
- if ($_REQUEST['ydate_registered_start']) {
- $time = mktime(0, 0, 0, $_REQUEST['mdate_registered_start'], $_REQUEST['ddate_registered_start'], $_REQUEST['ydate_registered_start']);
- $where .= " AND date_registered >= '$time'";
- }
- // lastest date registered
- if ($_REQUEST['ydate_registered_end']) {
- $time = mktime(0, 0, 0, $_REQUEST['mdate_registered_end'], $_REQUEST['ddate_registered_end'], $_REQUEST['ydate_registered_end']);
- $where .= " AND date_registered <= '$time'";
- }
- if ($_REQUEST['do'] == 'step2') {
- //////////////////// GET RESULTS ////////////////////
- $db->query("SELECT * FROM user $where");
- $total = $db->num_rows();
- echo table_border("<b>Your email will be sent to <u>$total</u> users who matched the criteria you specified.</b><br />If you were expecting a different number of users please check your <a href="email2.php?variables_serialized=" . urlencode(serialize($_REQUEST)) . "">search settings</a> were entered correctly.");
- $table[] = array('<b>From Email Address</b>', form_input('from'));
- $table[] = array('<b>From Name</b>', form_input('name'));
- $table[] = array('<b>Email Subject</b>', form_input('subject'));
- $table[] = array('<b>Email Body</b><br /><br />You can use $user_fields[username], $user_fields[id], $user_fields[customX] etc. to have specific user values placed<br />in the email body.', form_textarea('body', 100, 20));
- table_header('STEP 2 : SEND EMAIL', 'email2.php', array('do' => 'step3', 'variables' => serialize($_REQUEST)), '', 'searchform');
- table_content('', $table);
- table_footer('Send Email');
- unset($columns, $table);
- } elseif ($_REQUEST['do'] == 'step3') {
- $db->query("SELECT * FROM user $where");
- $total = $db->num_rows();
- echo table_border("<b>Your email is currently being sent to <u>$total</u> users who matched the criteria you specified.</b><br />Please be patient while the system finishes emailing.");
- // time to start emailing!
- while ($user_fields = $db->row_array()) {
- if (validate_email($user_fields[email])) {
- foreach(array_keys($user_fields) AS $name) {
- if (stristr($name, 'custom')) {
- $user_fields[$name] = field_display($fielddata[$name], $user_fields[$name], 1);
- $_REQUEST['body'] = str_replace("$user_fields[$name]", $user_fields[$name], $_REQUEST['body']);
- }
- }
- dp_mail($user_fields[email], $_REQUEST[subject], $_REQUEST[body], $_REQUEST[from]);
- echo "Email sent to $user_fields[email]<br />";
- }
- }
- }
- }
- ############################################# EMAIL USERS #############################################
- if ($_REQUEST['do'] == "step1") {
- $table[] = table_midheader('User Properties');
- if ($_REQUEST[variables_serialized]) {
- $_REQUEST = array_merge($_REQUEST, unserialize($_REQUEST['variables_serialized']));
- }
- // id range
- $bit = form_input('greater', $_REQUEST['greater'], 3) . " < <b>ID</b> > " . form_input('lessthan', $_REQUEST['lessthan'], 3);
- $table[] = array('<b>User ID Range</b>', $bit);
- // user owner
- $bit = form_input('username', $_REQUEST['username'], 30);
- $table[] = array('<b>Username</b><br />% wildcard may be used', $bit);
- $bit = form_input('email', $_REQUEST['email'], 30);
- $table[] = array('<b>Email</b><br />% wildcard may be used', $bit);
- // sort dates for display
- if ($_REQUEST['ydate_registered_start']) {
- $date = "$_REQUEST[ydate_registered_start]-$_REQUEST[mdate_registered_start]-$_REQUEST[ddate_registered_start]";
- } else {
- $date = "2001-01-01";
- }
- if ($_REQUEST['ydate_registered_end']) {
- $date2 = "$_REQUEST[ydate_registered_end]-$_REQUEST[mdate_registered_end]-$_REQUEST[ddate_registered_end]";
- } else {
- $date2 = date('Y-m-d', (mktime() + 3400));
- }
- // date of registration
- $bit = 'From ' . form_date('date_registered_start', '', '', '', 1, $date) . "<a href="#" onClick="datePop('searchform', 'date_registered_start')">".html_image('tech/pribut020.gif')."</a> To " . form_date('date_registered_end', '', '', '', 1, $date2) .
-
- "<a href="#" onClick="datePop('searchform', 'date_registered_end')">".html_image('tech/pribut020.gif')."</a>";
- $table[] = array('<b>Date Registered</b>', $bit);
- unset($date, $date2);
- $db->query("SELECT * FROM user_def WHERE tech_viewable = 1");
- if ($db->num_rows()) {
- $table[] = table_midheader('Custom User Fields');
- }
- while ($result = $db->row_array()) {
- $display_name = unserialize($result[display_name]);
- $display_name = $display_name[$settings[default_language]];
- $array_fields[$result[name]] = $display_name;
- $bit = field_def($result, 'redo', $_REQUEST[custom_fields][$result[name]], $_REQUEST[custom_fields]["extra" . $result[name]], '', 'custom_fields', 1);
- $table[] = array("<b>$display_name</b>", $bit);
- }
- table_header('STEP 1 : SELECT USERS', 'email2.php', array('do' => 'step2'), '', 'searchform');
- table_content($columns, $table);
- table_footer('Search');
- unset($columns, $table);
- }
- #############################################
- admin_footer();
- ?>