$_mmurl = 'http://example.co.uk/mailman/admin'; $_mmlist = 'newsletter_example.co.uk'; $_mmpw = 'password-cannot-have-spaces'; $_mmsub = 'Yey! Thanks for joining our newsletter.'; $_mmunsub = 'Sorry to see you go :('; $_mmerror = 'There was some kind of error, check and try again.'; //Logic if ($_POST) { $_email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL); if ($_email) { require 'Services/Mailman.php'; $mm = new Services_Mailman($_mmurl, $_mmlist, $_mmpw); $notice = $_mmsub; if ($_POST['sub'] == 1) { try { $mm->subscribe($_email); } catch (Services_Mailman_Exception $e) { $notice = $_mmerror; } } elseif ($_POST['sub'] == 0) { try { $mm->unsubscribe($_email); } catch (Services_Mailman_Exception $e) { $notice = $_mmerror; } } } else { $notice = $_mmerror; } } unset($_mmpw);
function scoutbook_adults() { $scoutmasters_list = new Services_Mailman('http://troop351.org/mailman/admin', 'scoutmasters_troop351.org', 'Stella12'); $committee_list = new Services_Mailman('http://troop351.org/mailman/admin', 'committee_troop351.org', 'Stella12'); $all_list = new Services_Mailman('http://troop351.org/mailman/admin', 'all_troop351.org', 'Stella12'); $cmd = 'curl -b cookies.txt "https://www.scoutbook.com/mobile/dashboard/admin/unit.asp?UnitID=25739&Action=ExportAdults" -o troop_351_adults.csv'; exec($cmd, $result); $i = 0; $file = 'troop_351_adults.csv'; $handle = fopen($file, 'r'); $troop_adult_ldr_array = array_map('str_getcsv', file($file)); unset($troop_adult_ldr_array[0]); $troop_adult_ldr_array = array_values($troop_adult_ldr_array); foreach ($troop_adult_ldr_array as $adult_ldr) { $adults[$i]['f_name'] = $adult_ldr[1]; $adults[$i]['l_name'] = $adult_ldr[3]; $adults[$i]['email'] = $adult_ldr[7]; $j = 0; if (!empty($adult_ldr[22])) { $adults[$i]['position'][$j++] = $adult_ldr[22]; } if (!empty($adult_ldr[24])) { $adults[$i]['position'][$j++] = $adult_ldr[24]; } if (!empty($adult_ldr[26])) { $adults[$i]['position'][$j++] = $adult_ldr[26]; } if (!empty($adult_ldr[28])) { $adults[$i]['position'][$j++] = $adult_ldr[28]; } if (!empty($adult_ldr[30])) { $adults[$i]['position'][$j++] = $adult_ldr[30]; } $i++; } foreach ($adults as $adult) { if (array_key_exists('position', $adult)) { adult_leader($adult); foreach ($adult['position'] as $position) { switch ($position) { case stristr($position, 'Committee'): echo 'Adding ' . $adult['email'] . ' to committee list</br>'; try { $committee_list->subscribe($adult['email']); } catch (Services_Mailman_Exception $e) { } break; case "Scoutmaster": echo 'Adding ' . $adult['email'] . ' to scoutmaster & committee list</br>'; try { $committee_list->subscribe($adult['email']); $scoutmasters_list->subscribe($adult['email']); } catch (Services_Mailman_Exception $e) { } break; case "Assistant Scoutmaster": echo 'Adding ' . $adult['email'] . ' to scoutmaster list</br>'; try { $scoutmasters_list->subscribe($adult['email']); } catch (Services_Mailman_Exception $e) { } break; } } } echo 'Adding ' . $adult['email'] . ' to all list</br>'; try { $all_list->subscribe($adult['email']); } catch (Services_Mailman_Exception $e) { } // Add adult_leader content type // Check all to ensure roles haven't changed } }