$listRow) { $listRow = stripslashes_array($listRow); $fields_list[$listRow['FieldID']] = $listRow; if($listRow['Required'] == 1) { // Make sure the user has specified a value for this field. // If they haven't, build an error list if(!isset($Fields[$listRow['FieldID']]) || $Fields[$listRow['FieldID']] == '') $fieldErr .= "
  • The field '" . $listRow['FieldName'] . "' can't be left empty
  • "; } } // Are there any incomplete fields? if($fieldErr != '') { // Some of the fields weren't completed $OUTPUT .= MakeErrorBox("Subscriber Fields Incomplete", "Some errors occurred while trying to add this subscriber:"); } else { // All of the required fields are completed. Firstly, add // this subscriber to the members table if($AbFormat == 'text') $Format = '1'; else $Format = '2'; if(mysql_query("INSERT INTO " . $TABLEPREFIX . "members(ListID, Email, SubscribeDate, Format, Status, Confirmed) VALUES('".addslashes($ListID)."', '".addslashes($Email)."', '" . addslashes($SYSTEMTIME) . "', '" . addslashes($Format) . "', '" . addslashes($Status) . "', '" . addslashes($ConfStatus) . "')")) { // Subscriber added to members table OK. Let's now add the custom fields to the list_field_values table $memberId = mysql_insert_id(); $error = false; if(isset($_POST['Fields']) && sizeof($_POST['Fields']) > 0) { // Add the values for the custom fields foreach($_POST['Fields'] as $k=>$v) { // Is this field a checkbox? If yes, change its value accordingly $fType = mysql_result(mysql_query("SELECT FieldType FROM " . $TABLEPREFIX . "list_fields where FieldID = '".addslashes($k)."'"), 0, 0); if($fType == 'checkbox' && $v == 'y') $v = 'checked'; // if it's the datebox, we want the format the same all the time! if ($fields_list[$k]['FieldType'] == 'datebox') { $v = $v['dd_start'] . ':' . $v['mm_start'] . ':' . $v['yy_start']; } else { if (is_array($v)) $v = implode(':', $v); } if (!mysql_query("INSERT INTO " . $TABLEPREFIX . "list_field_values(FieldID, ListID, UserID, Value) values('".addslashes($k)."', '".addslashes($ListID)."', '".addslashes($memberId)."', '".addslashes($v)."')")) $error = true; } } // Output a success message if(!$error) { $OUTPUT .= MakeSuccessBox("Subscriber Added Successfully", "'$Email' has been added successfully. Click here to add another subscriber to the same mailing list. Click 'OK' to continue.", MakeAdminLink("members")); } else { $OUTPUT .= MakeErrorBox("Couldn't Add Subscriber", "An error occurred while trying to add this subscriber."); } } else { // An error occurred while trying to add this subscriber $OUTPUT .= MakeErrorBox("Couldn't Add Subscriber", "An error occurred while trying to add this subscriber."); } } } } if($Action == "ViaForm") { $FORM_ITEMS["-3"]="hidden|ListID:$ListID"; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Email"]="textfield|Email:100:44:"; $HELP_ITEMS["Email"]["Title"] = "Email"; $HELP_ITEMS["Email"]["Content"] = "This subscribers email address."; $list = mysql_fetch_assoc(mysql_query("SELECT * FROM " . $TABLEPREFIX . "lists WHERE ListID = '".addslashes($ListID)."' ORDER BY ListName ASC")); switch($list['Formats']) { case 1: $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Format"] = "select|AbFormat:text:text->Text Only"; break; case 2: $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Format"] = "select|AbFormat:html:html->HTML Only"; break; default: $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Format"] = "select|AbFormat:1:text->Text;html->HTML:"; } $HELP_ITEMS["AbFormat"]["Title"] = "Format"; $HELP_ITEMS["AbFormat"]["Content"] = "Which newsletter format should this subscriber be \'flagged\' to receive? Text or HTML?"; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Status"]="select|Status:1:0->Inactive;1->Active:1"; $HELP_ITEMS["Status"]["Title"] = "Status"; $HELP_ITEMS["Status"]["Content"] = "When this subscriber is added, should he/she be marked as active or inactive?"; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Confirmed"] = "select|ConfStatus:1:1->Confirmed;0->Unconfirmed"; $HELP_ITEMS["ConfStatus"]["Title"] = "Status"; $HELP_ITEMS["ConfStatus"]["Content"] = "If a subscriber was to join your list using a normal subscription form with \'Requires Confirmation\' enabled, then they would be marked as unconfirmed until they click on the confirmation link inside the email automatically sent to them."; $size = $min = $max = $Width = $Height = 0; //extra fields $custom_fields = FetchCustomFields(); if (!empty($custom_fields)) { $FORM_ITEMS['-100'] = 'spacer|
      Custom Fields
    '; } foreach($custom_fields as $pos => $f) { $f = stripslashes_array($f); if($f['Required'] == 1) $req = $FORM_REQUIRED_ITEM; else $req = $FORM_NOT_REQUIRED_ITEM; switch($f['FieldType']){ case 'shorttext': if (strpos($f['AllValues'], ',') === false) { $size = 30; $min = 30; $max = 100; } else { list($size,$min,$max)=explode(',',$f['AllValues']); } $FORM_ITEMS[$req . $f["FieldName"]]="textfield|Fields[".$f["FieldID"]."]:$max:44"; break; case 'longtext': if (strpos(',', $f['AllValues']) === false) { $Width = 100; $Height = 5; } else { list($Width,$Height)=explode(',',$f['AllValues']); } $FORM_ITEMS[$req . $f["FieldName"]]="textfield|Fields[".$f["FieldID"]."]:500:44"; break; case 'checkbox': $FORM_ITEMS[$req . $f["FieldName"]]="select|Fields[".$f["FieldID"]."]:1:y->Yes;n->No:n"; break; case 'dropdown': $FORM_ITEMS[$req . $f["FieldName"]]="select|Fields[".$f["FieldID"]."]:1:".$f["AllValues"].":"; break; case 'multicheckbox': $FORM_ITEMS[$req . $f["FieldName"]]="checkboxes|Fields[".$f["FieldID"]."]:" . $f['AllValues'] . ":"; break; case 'datebox': $FORM_ITEMS[$req . $f["FieldName"]]="dateboxes|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[$req . $f["FieldName"]]="number|Fields[".$f["FieldID"]."]:$max:44:"; break; } } $FORM_ITEMS["-1"]="submit|Finish:1-members"; //make the form $FORM=new AdminForm; $FORM->title="ViaForm"; $FORM->items=$FORM_ITEMS; $FORM->action=MakeAdminLink("addsub?Action=AddFromForm"); $FORM->MakeForm("New Subscriber Details"); $FORM->output = "Complete the form below to add a single subscriber to your mailing list." . $FORM->output; $OUTPUT.=MakeBox("Add Subscriber (Step 2 of 2)",$FORM->output); $OUTPUT .= ' '; } if($Action == '') { //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("Add Subscriber",'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("addsub?Action=ViaForm"); $FORM->MakeForm("Import Details"); $FORM->output = "Before you can add a subscriber, please choose a mailing list to work with." . $FORM->output; $OUTPUT.=MakeBox("Add Subscriber (Step 1 of 2)",$FORM->output); $OUTPUT .= ' '; } } ?>