\n"); $error_message = getLanguageText('ERRORMSG-ACCESS-DENIED'); include "form.messages.php"; return; } // // Build a database query based on the input data provided // if (!$_POST) return; extract($_POST); $PrimaryTable = "contacts"; // // Define the default query to be used // $Parameters = ""; $EmailField = "email"; $Recipients = array("email","name","active"); // Define email category and description $Category = "Contacts Broadcast"; $Description = "Broadcast to contacts"; $Where = ""; $Join = ""; if (array_key_exists('sel',$_POST)) { if (is_array($_POST['sel'])) { $_POST['sel'] = join(",", $_POST['sel']); } $Where = " and record_num IN ({$_POST['sel']})"; $Description .= " (custom recipient list)"; } else { // creates the join condition if ($campaign_num) { $Join .= " LEFT JOIN campaign_contacts AS cc ON cc.contact_id = c.record_num"; $Where .= " and cc.campaign_id = '$campaign_num'"; $query = "select campaign from campaigns where record_num = '$campaign_num'"; $campaign = db_getVal($query); if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " campaign = '$campaign'"; } // creates the where conditions if ($group_num > 0) { $Where .= " and c.group_num = '$group_num'"; $query = "select group_name from groups where record_num = '$group_num'"; $group = db_getVal($query); if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " group = '$group'"; } elseif ($group_num == 0) { $Where .= " and c.group_num = '0'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " group = 'Public'"; } if ($salesperson_num) { $Where .= " and c.salesperson_num = '$salesperson_num'"; $query = "select userid from users where record_num = '$salesperson_num'"; $salesperson = db_getVal($query); if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " salesperson = '$salesperson'"; } if ($category_num) { $Where .= " and c.category_num = '$category_num'"; $query = "select category from categories where record_num = '$category_num'"; $category = db_getVal($query); if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " category = '$category'"; } if ($industry_num) { $Where .= " and c.industry_num = '$industry_num'"; $query = "select industry from industries where record_num = '$industry_num'"; $industry = db_getVal($query); if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " industry = '$industry'"; } if ($region_num) { $Where .= " and c.region_num = '$region_num'"; $query = "select region from regions where record_num = '$region_num'"; $region = db_getVal($query); if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " region = '$region'"; } if ($name || $name_sel) { if (!$name) $name = $name_sel; $name = str_replace('*','%',$name); $Where .= " and c.name like '$name'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " name like '$name'"; } if ($title) { $title = str_replace("*","%",$title); $Where .= " and c.title like '$title'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " title like '$title'"; } if ($phone) { $phone = str_replace("*","%",$phone); $Where .= " and c.phone like '$phone'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " phone like '$phone'"; } if ($email) { $email = str_replace("*","%",$email); $Where .= " and c.email like '$email'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " email like '$email'"; } if ($company) { $company = str_replace("*","%",$company); $Where .= " and c.company like '$company'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " company like '$company'"; } if ($address) { $address = str_replace("*","%",$address); $Where .= " and c.address like '$address'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " address like '$address'"; } if ($city) { $city = str_replace("*","%",$city); $Where .= " and c.city like '$city'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " city like '$city'"; } if ($province) { $province = str_replace("*","%",$province); $Where .= " and c.province like '$province'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " province like '$province'"; } if ($country) { $country = str_replace("*","%",$country); $Where .= " and c.country like '$country'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " country like '$country'"; } if ($postal) { $postal = str_replace("*","%",$postal); $Where .= " and c.postal like '$postal'"; if (strpos($Description, " where") === false) $Description .= " where"; else $Description .= " and"; $Description .= " postal like '$postal'"; } } // create attachment list if (array_key_exists('attachments',$_POST)) { if (is_array($_POST['attachments'])) { $attachments = $_POST['attachments'] = join(",", $_POST['attachments']); } } $Query = "SELECT * FROM $PrimaryTable AS c $Join ". "WHERE c.$EmailField is not null and c.$EmailField != '' and c.active != 'N' $Where {$permissions} ". "ORDER BY c.$EmailField, c.record_num"; $Count = "SELECT count(*) FROM $PrimaryTable AS c $Join ". "WHERE c.$EmailField is not null and c.$EmailField != '' and c.active != 'N' $Where {$permissions}"; // // Determine how many emails will be sent // $results = db_query($Count); $row = db_fetch_array($results); $num_rows = $row[0]; ?>

Confirm Email Send

0) { echo("$Category:
"); echo("$Description:
\n"); ?>

record(s) found

Send Emails:

\n"); } } ?>
$b) { echo(" \n"); } } else { echo(" \n"); } } ?>

Recipient List



$field\n"); } ?> \n"); for ($i = 0; $i < count($Recipients); $i++) { $field = $Recipients[$i]; echo(" \n"); } echo(""); echo(" \n"); } ?>
All  None
$row[$field]