static function get_contact_list($frm_id, $email_to) { // Returns a list of email contacts for display // $email_to = email to list from form settings if (!self::$global_options) { self::$global_options = FSCF_Util::get_global_options(); } $contacts = array(); $contacts[] = ''; // dummy entry to take up key 0 // Check for a shortcode mail-to value. Allowed shortcode email_to: // Webmaster,user1@example.com (must have name,email) // multiple emails allowed // Webmaster,user1@example.com;user2@example.com if (self::$global_options['enable_php_sessions'] == 'true') { // this feature only works when PHP sessions are enabled if (!empty($_SESSION["fsc_shortcode_email_to_{$frm_id}"]) && preg_match("/,/", $_SESSION["fsc_shortcode_email_to_{$frm_id}"])) { list($key, $value) = preg_split('#(?<!\\\\)\\,#', $_SESSION["fsc_shortcode_email_to_{$frm_id}"]); //string will be split by "," but "\," will be ignored $key = trim(str_replace('\\,', ',', $key)); // "\," changes to "," $value = trim(str_replace(';', ',', $value)); // ";" changes to "," if ($key != '' && $value != '') { $contacts[] = array('CONTACT' => FSCF_Util::clean_input($key), 'EMAIL' => FSCF_Util::clean_input($value)); } } else { unset($_SESSION["fsc_shortcode_email_to_{$frm_id}"]); } } if (count($contacts) == 1) { // Nothing from shortcode, so generate the mail-to list from the settings. // The drop down list array will be made automatically by this code // checks for properly configured Email To: addresses in options. $contacts_test = trim($email_to); if (!preg_match("/,/", $contacts_test)) { if (FSCF_Util::validate_email($contacts_test)) { // user1@example.com $contacts[] = array('CONTACT' => __('Webmaster', 'si-contact-form'), 'EMAIL' => $contacts_test); } } else { $ctf_ct_arr = explode("\n", $contacts_test); if (is_array($ctf_ct_arr)) { foreach ($ctf_ct_arr as $line) { // echo '|'.$line.'|' ; list($key, $value) = preg_split('#(?<!\\\\)\\,#', $line); //string will be split by "," but "\," will be ignored $key = trim(str_replace('\\,', ',', $key)); // "\," changes to "," $value = trim($value); if ($key != '' && $value != '') { if (!preg_match("/;/", $value)) { // just one email here // Webmaster,user1@example.com $value = str_replace('[cc]', '', $value); $value = str_replace('[bcc]', '', $value); if (FSCF_Util::validate_email($value)) { $contacts[] = array('CONTACT' => esc_html($key), 'EMAIL' => $value); } } else { // multiple emails here // Webmaster,user1@example.com;user2@example.com;user3@example.com;[cc]user4@example.com;[bcc]user5@example.com $multi_cc_arr = explode(";", $value); $multi_cc_string = ''; foreach ($multi_cc_arr as $multi_cc) { $multi_cc_t = str_replace('[cc]', '', $multi_cc); $multi_cc_t = str_replace('[bcc]', '', $multi_cc_t); if (FSCF_Util::validate_email($multi_cc_t)) { $multi_cc_string .= "{$multi_cc},"; } } if ($multi_cc_string != '') { // multi cc emails $contacts[] = array('CONTACT' => esc_html($key), 'EMAIL' => rtrim($multi_cc_string, ',')); } } } } // end foreach } // end if (is_array($ctf_ct_arr) ) { } // end else } // end outer if unset($contacts[0]); // remove dummy entry.. the array keys now start with 1 return $contacts; }