'; $POPOUTPUT=1; include('includes/do_export.inc.php'); } if ($Action == 'ExportFinished') { $OUTPUT .= MakeSuccessBox("Export Subscribers (Step 4 of 4)", "The export has been completed successfully. " . number_format($_GET['MemberCount'], 0) . " member(s) were exported. Click here to download the export file.", MakeAdminLink("export"), "", "", false); } if($Action=='CreateFile') { $MemberCount = $_GET['MemberCount']; $fq = urlencode(stripslashes($_REQUEST['FieldQuotes'])); $link = MakeAdminLink("export?ExportID=$ExportID&Action=DoExport&MemberCount=$MemberCount&FieldQuotes=$fq&StartTime=$SYSTEMTIME"); $field_list = array('Status', 'Confirmed', 'Format', 'Email', 'Fields', 'HaveClickedLink', 'Headers', 'ExportField', 'RecordSep', 'FieldSep'); foreach($field_list as $f) { if (!isset($_REQUEST[$f])) continue; if (!is_array($_REQUEST[$f])) { $link .= "&" . $f . "=" . urlencode($_REQUEST[$f]); continue; } if (is_array($_REQUEST[$f])) { $link .= "&" . $f . "=" . urlencode(serialize($_REQUEST[$f])); } } if(!is_writable($ROOTDIR.'/temp')) { $Error = "The '" . $ROOTDIR . "temp' folder does not have write permissions. Please CHMOD this folder to 777."; $OUTPUT .= MakeErrorBox("An Error Occurred", $Error); } else { $error = false; $exfile = $ROOTDIR.'/temp/export-' . $ExportID . '.txt'; if (!$f = fopen($exfile,"w")) { $error = 'Unable to open export file for saving: ' . $php_errormsg; $OUTPUT .= MakeErrorBox("An Error Occurred", $error); $error = true; } else { fclose($f); } if (!$error) { $OUTPUT .= 'Click OK to start exporting your ' . number_format($MemberCount, 0) . ' subscribers ...
'; $OUTPUT .= ' 0) { $custom_fields = FetchCustomFields(); $nf = sizeof($custom_fields); $nf+=5; $allfields='->----- NONE;EMAIL->Users Email;STATUS->Users Status;CONFIRM->Users Confirmation Status;FORMAT->Users Chosen Format;SUBSCRIBEDATE->Users Subscribe Date;'; $x=5; $af['1']='EMAIL'; $af['2']='STATUS'; $af['3']='CONFIRM'; $af['4']='FORMAT'; $af['5'] = 'SUBSCRIBEDATE'; foreach($custom_fields as $pos => $f) { $x++; $allfields.=$f["FieldID"].'->'.$f["FieldName"].';'; $af[$x]=$f["FieldID"]; } for($i=1;$i<=$nf;$i++){ $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Field #$i Content"]="select|ExportField[$i]:1:$allfields:".($af[$i]); $HELP_ITEMS["ExportField[$i]"]["Title"] = "Field #$i Content"; $HELP_ITEMS["ExportField[$i]"]["Content"] = "Which subscriber field should be exported into field #$i?"; } $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Include Headers?"]="select|Headers:1:0->No;1->Yes:1"; $HELP_ITEMS["Headers"]["Title"] = "Include Headers?"; $HELP_ITEMS["Headers"]["Content"] = "Should this export include field headers? If so, the first line of the file will look something like this: email, status, format."; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Field Separator"]="textfield|FieldSep:100:10:,"; $HELP_ITEMS["FieldSep"]["Title"] = "Field Separator"; $HELP_ITEMS["FieldSep"]["Content"] = "Which character should be added to this export file to separate the contents of each new field in a record?"; $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "Field Enclosed by"]="textfield|FieldQuotes:100:10:"; $HELP_ITEMS["FieldQuotes"]["Title"] = "Enclose Fields"; $HELP_ITEMS["FieldQuotes"]["Content"] = "What should we enclose the fields with? eg \'"; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Record Separator"]="textfield|RecordSep:100:10:NEWLINE"; $HELP_ITEMS["RecordSep"]["Title"] = "Record Separator"; $HELP_ITEMS["RecordSep"]["Content"] = "Which character should be added to this export file to separate one record from the next?"; $FORM_ITEMS["-1"]="submit|Next »:1-members"; $FORM=new AdminForm; $FORM->title="SearchMembers"; $FORM->items=$FORM_ITEMS; $FORM->action=MakeAdminLink("export?ExportID=$ExportID&Action=CreateFile&MemberCount=$Members"); $FORM->MakeForm("Export Field Details"); $FORM->output = "You will be exporting " . number_format($Members, 0) . " subscribers.
Complete the form below to choose which subscriber fields will be included in the export." . $FORM->output; $OUTPUT.=MakeBox("Export Subscribers (Step 3 of 4)",$FORM->output); $OUTPUT .= ' '; } else { // No members were found! $OUTPUT .= MakeErrorBox("No Subscribers Found", "No subscribers matched the search details that you specified."); } } if($Action=="SelectMembers") { //create the export! mysql_query("INSERT INTO " . $TABLEPREFIX . "exports SET ListID='".addslashes($ListID)."', DateStarted='".addslashes($SYSTEMTIME)."'"); $ExportID=mysql_insert_id(); //search for members form! $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Status"]="select|Status:1:ALL->View All;0->Inactive;1->Active:1"; $HELP_ITEMS["Status"]["Title"] = "Status"; $HELP_ITEMS["Status"]["Content"] = "Should active, inactive or all subscribers be exported?"; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Confirmed"]="select|Confirmed:1:ALL->Either;0->Not Confirmed;1->Confirmed:1"; $HELP_ITEMS["Confirmed"]["Title"] = "Confirmed"; $HELP_ITEMS["Confirmed"]["Content"] = "Should confirmed, unconfirmed or all subscribers be exported?"; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Format"]="select|Format:1:ALL->Either;1->Text;2->HTML"; $HELP_ITEMS["Format"]["Title"] = "Format"; $HELP_ITEMS["Format"]["Content"] = "Should subscribers flagged to receive text, HTML, or all email types be exported?"; $links = FetchLinks(); $alllinks = '0->Not Applicable;A->Any Link;'; foreach($links as $pos => $details) { $alllinks .= $details['LinkID'] . '->' . $details['URL'] . ';'; } $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "Clicked on Link"]="select|HaveClickedLink:1:" . str_replace(':', '$$COLON$$', $alllinks); $HELP_ITEMS["HaveClickedLink"]["Title"] = "Have Clicked Link"; $HELP_ITEMS["HaveClickedLink"]["Content"] = "Should this report only include subscribers who have clicked on a particular link from a newsletter that you sent out?"; $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "Match Email"]="textfield|Email:100:44:"; $HELP_ITEMS["Email"]["Title"] = "Match Email"; $HELP_ITEMS["Email"]["Content"] = "If you only want to export subscribers based on the content of their email address, then enter the complete or partial email address to filter on here."; $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "Filter by Date"]="dateboxsearch|SubscribeDate:"; $HELP_ITEMS["SubscribeDate"]["Title"] = "Filter by Date"; $HELP_ITEMS["SubscribeDate"]["Content"] = "If you would like to filter your search by date subscribed, select this and select your date range"; $size = $min = $max = $Width = $Height = 0; //extra fields $custom_fields = FetchCustomFields(); if (!empty($custom_fields)) { $FORM_ITEMS['-100'] = 'spacer|
  Filter by Custom Fields
'; } foreach($custom_fields as $pos => $f) { $f = stripslashes_array($f); switch($f['FieldType']){ case 'shorttext': $fieldvals = explode(',', $f['AllValues']); $size = (isset($fieldvals[0])) ? $fieldvals[0] : 10; $min = (isset($fieldvals[1])) ? $fieldvals[1] : 10; $max = (isset($fieldvals[2])) ? $fieldvals[2] : 0; $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "Match ".$f['FieldName']]="textfield|Fields[".$f['FieldID']."]:$max:44"; break; case 'longtext': list($Width,$Height)=explode(',',$f['AllValues']); $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "Match ".$f['FieldName']]="textfield|Fields[".$f['FieldID']."]:500:44"; break; case 'checkbox': $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "Match " . $f['FieldName']]="select|Fields[".$f['FieldID']."]:1:y->Yes;n->No;all->All:all"; break; case 'multicheckbox': $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "Match " . $f["FieldName"]]="checkboxes|Fields[".$f["FieldID"]."]:" . $f['AllValues']; break; case 'dropdown': $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "Match " . $f['FieldName']]="select|Fields[".$f['FieldID']."]:1:->All Values;".str_replace(':', '$$COLON$$', $f["AllValues"]).":"; break; case 'datebox': $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "Match " . $f["FieldName"]]="dateboxsearch|Fields[".$f["FieldID"]."]:" . $f['AllValues'] . ":"; break; case 'number': $fieldvals = explode(',', $f['AllValues']); $size = (isset($fieldvals[0])) ? $fieldvals[0] : 10; $min = (isset($fieldvals[1])) ? $fieldvals[1] : 10; $max = (isset($fieldvals[2])) ? $fieldvals[2] : 0; $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . $f["FieldName"]]="number|Fields[".$f["FieldID"]."]:$max:44:"; $HELP_ITEMS['Fields['.$f['FieldID'].']']['Title'] = 'Match Numbers'; $HELP_ITEMS['Fields['.$f['FieldID'].']']['Content'] = 'You can use operators like >, <, <=, >= in this field'; break; } } $FORM_ITEMS["-1"]="submit|Next »:1-members"; $FORM=new AdminForm; $FORM->title="SearchMembers"; $FORM->items=$FORM_ITEMS; $FORM->action=MakeAdminLink("export?ExportID=$ExportID&Action=LogMembers"); $FORM->MakeForm("Subscriber Details"); $FORM->output = "Complete the form below to filter subscribers that should be exported." . $FORM->output; $OUTPUT.=MakeBox("Export Subscribers (Step 2 of 4)", $FORM->output); $OUTPUT .= ' '; } if(!$ListID && !$ExportID){ //select ListID form! $lists=mysql_query("SELECT * FROM " . $TABLEPREFIX . "lists ORDER BY ListName ASC"); while($l=mysql_fetch_assoc($lists)) { $l = stripslashes_array($l); if(AllowList($l['ListID'])) { if ($CURRENTADMIN['DisplaySummaries']) { $numSubs = (int)mysql_result(mysql_query("SELECT COUNT(*) from " . $TABLEPREFIX . "members where ListID=" . addslashes($l['ListID'])), 0, 0); if($numSubs == 1) $subs = "1 subscriber"; else $subs = number_format($numSubs, 0) . " subscribers"; $subs = " (" . $subs . ")"; } else { $subs = ""; } $alllists.=$l["ListID"]."->".str_replace(';', '$$SEMI$$', str_replace(':', '$$COLON$$', $l["ListName"]))."$subs;"; } } if ($alllists == '') { $OUTPUT = MakeBox("Export Subscribers",'No mailing lists have been created. Please click on the "Create Mailing List" button below to create one.



'); } else { $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Mailing List"]="select|ListID:5:$alllists"; $FORM_ITEMS["-1"]="submit|Next »:1-members"; $FORM=new AdminForm; $FORM->title="SelectList"; $FORM->items=$FORM_ITEMS; $FORM->action=MakeAdminLink("export?Action=SelectMembers"); $FORM->MakeForm("Mailing List Details"); $FORM->output = "Before you can export subscribers, please choose a mailing list to work with." . $FORM->output; $OUTPUT.=MakeBox("Export Subscribers (Step 1 of 4)",$FORM->output); $OUTPUT .= ' '; } } ?>