function validate_fields($config_data, &$response_array) { $valid = true; foreach ($this->data as $field_id => $field_value) { if (substr($field_id, 0, 5) != 'field') { // we only look at user defined fields here continue; } $field_index = intval(substr($field_id, 5, 3)); // field id's are 'fieldnnn' or 'fieldnnnmm' for multiple checkboxes $field =& $config_data->all_fields[$field_index]; // point to the field configuration $error_id = sprintf('fcp_err%03d', $field_index); if (FCP_trace::tracing()) { if (strlen($field_id) == 8) { $trace_field_id = $field_id; } else { $trace_field_id = substr($field_id, 0, 8) . '-' . substr($field_id, 8); } // multiple checkbox FCP_trace::trace(" validating {$trace_field_id} ({$field->prompt}) => [{$field_value}]"); } // don't validate hidden fields if (!$field->visible) { continue; } // valid unless found otherwise $response = array(); $response['f_valid'] = $field_id; $response['e_valid'] = $error_id; // if the field is mandatory and empty, that's the only error we will report for this field if ($field->mandatory and empty($field_value)) { $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, JText::_('COM_FLEXICONTACT_REQUIRED')); $valid = false; $response_array[] = $response; continue; } // if the field is mandatory and not empty, we must clear its error if ($field->mandatory and !empty($field_value)) { $response_array[] = $response; } // if the field is not mandatory and is empty, we must not validate it and we must clear its error if (!$field->mandatory and empty($field_value)) { $response_array[] = $response; continue; } // checkboxes and radio buttons don't need to be validated if (in_array($field->field_type, array(LAFC_FIELD_CHECKBOX_L, LAFC_FIELD_CHECKBOX_H, LAFC_FIELD_CHECKBOX_R, LAFC_FIELD_CHECKBOX_M, LAFC_FIELD_RADIO_V, LAFC_FIELD_RADIO_H))) { continue; } // now the field type specific validation switch ($field->field_type) { case LAFC_FIELD_SUBJECT: $bad_subject_chars = "|<>`"; // characters we don't allow if (strpbrk($field_value, $bad_subject_chars) === false) { break; } $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, JText::_('COM_FLEXICONTACT_INVALID')); $valid = false; break; case LAFC_FIELD_FROM_ADDRESS: jimport('joomla.mail.helper'); if (JMailHelper::isEmailAddress($field_value)) { break; } $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, JText::_('COM_FLEXICONTACT_BAD_EMAIL')); $valid = false; break; case LAFC_FIELD_TEXT_NUMERIC: if (FCP_Common::is_posint($field_value)) { break; } $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, JText::_('COM_FLEXICONTACT_INVALID')); $valid = false; break; case LAFC_FIELD_DATE: $yyyy_mm_dd = self::reformat_date($field_value, $config_data->date_format); if (!self::validate_date($yyyy_mm_dd)) { $date_string = self::get_date_string($config_data->date_format); $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, JText::_('COM_FLEXICONTACT_INVALID') . ' (' . $date_string . ')'); $valid = false; break; } switch ($field->validation_type) { case VALTYPE_PAST: FCP_trace::trace(" must be in the past"); $today = date('Y-m-d'); if ($yyyy_mm_dd > $today) { $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, JText::_('COM_FLEXICONTACT_DATE_PAST')); $valid = false; FCP_trace::trace(" - invalid, not in the past"); } break; case VALTYPE_FUTURE: FCP_trace::trace(" must be in the future"); $today = date('Y-m-d'); if ($yyyy_mm_dd < $today) { $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, JText::_('COM_FLEXICONTACT_DATE_FUTURE')); $valid = false; FCP_trace::trace(" - invalid, not in the future"); } break; case VALTYPE_GREATER: FCP_trace::trace(" must be greater than the previous field"); if ($field_index == 0) { break; } // no previous field - forget it $previous_field_index = $field_index - 1; // previous field index $previous_field_config =& $config_data->all_fields[$previous_field_index]; if ($previous_field_config->field_type != LAFC_FIELD_DATE) { break; } // not a date field - forget it $previous_field_id = sprintf('field%03d', $previous_field_index); // form the ID of the previous field FCP_trace::trace(" previous field ID:" . $previous_field_id); if (!isset($this->data[$previous_field_id])) { break; } // no value - forget it $previous_field_value = $this->data[$previous_field_id]; $previous_field_yyyy_mm_dd = self::reformat_date($previous_field_value, $config_data->date_format); $previous_field_prompt = $previous_field_config->prompt; FCP_trace::trace(" previous field [" . $previous_field_prompt . '] value: ' . $previous_field_value . ' (current field value: ' . $yyyy_mm_dd . ')'); if ($yyyy_mm_dd <= $previous_field_yyyy_mm_dd) { $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, JText::sprintf('COM_FLEXICONTACT_DATE_GREATER', $previous_field_prompt)); $valid = false; FCP_trace::trace(" - invalid, not greater than previous field"); } break; } break; case LAFC_FIELD_ADVANCED: if (!empty($field->regex)) { FCP_trace::trace(" validate regex: " . $field->regex); if (@preg_match($field->regex, $field_value) == 0) { $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; if ($field->error_msg == '') { $response[$error_id] = $this->make_error($config_data, JText::_('COM_FLEXICONTACT_INVALID')); } else { $response[$error_id] = $this->make_error($config_data, $field->error_msg); } $valid = false; } } if (!empty($field->sql)) { $escaped_value = $this->_db->escape($field_value); $query = str_replace('%VALUE%', $escaped_value, $field->sql); $result = $this->ladb_loadResult($query); FCP_trace::trace(" validate sql: " . $query); FCP_trace::trace(" sql result: " . $result); if ($result === false) { FCP_trace::trace(" " . $this->ladb_error_text); } if ($result == 0) { $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; if ($field->error_msg == '') { $response[$error_id] = $this->make_error($config_data, JText::_('COM_FLEXICONTACT_INVALID')); } else { $response[$error_id] = $this->make_error($config_data, $field->error_msg); } $valid = false; } } break; case LAFC_FIELD_ATTACHMENT: FCP_trace::trace(" validate file: " . $field_value); // it's ok, we won't get here if the filename is blank (the field size variable would not be set) ... $file_size_variable_name = sprintf('filesize%03d', $field_index); $jinput = JFactory::getApplication()->input; $file_size = $jinput->get($file_size_variable_name, '0', 'STRING'); $file_extension = pathinfo($field_value, PATHINFO_EXTENSION); FCP_trace::trace(" file_size: " . $file_size . ", extension = " . $file_extension); $white_list_array = explode(',', $config_data->white_list); if (!in_array(strtolower($file_extension), $white_list_array)) { $error_message = JText::sprintf('COM_FLEXICONTACT_FILES_ALLOWED', $config_data->white_list); $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, $error_message); $valid = false; } if ($file_size > $config_data->max_file_size * 1024) { $error_message = JText::sprintf('COM_FLEXICONTACT_FILE_TOO_BIG', $config_data->max_file_size); $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, $error_message); $valid = false; } if ($file_size == 0) { $error_message = JText::_('COM_FLEXICONTACT_FILE_EMPTY'); $response = array(); $response['f_error'] = $field_id; $response['e_error'] = $error_id; $response[$error_id] = $this->make_error($config_data, $error_message); $valid = false; } break; } // end switch $response_array[] = $response; } // end foreach return $valid; }
function display_modal($params) { $modal_param = strstr($params, 'modal'); $modal_x_size = substr($modal_param, 6, 3); $modal_y_size = substr($modal_param, 10, 3); $modal_text = substr($modal_param, 14); FCP_Common::strip_quotes($modal_text, false); // Remove quotes from the start and end of the string if ($modal_param[9] != ',' or $modal_param[13] != ',' or !FCP_Common::is_posint($modal_x_size, false) or !FCP_Common::is_posint($modal_y_size, false)) { return "{flexicontactplus: Invalid modal parameter: {$modal_param}}"; } $pos_modal = strpos($params, 'modal'); $config_name = substr_replace($params, '', $pos_modal); // what's left is just the config name $config_name = trim($config_name); // load Joomla's modal window support JHtml::_('behavior.modal', 'a.fcp_modal'); $html = ''; if (strlen($modal_text) == 0) { // if there is no link text that's all we do on this call return ''; } // class="modal" invokes the modal lightbox - see media/system/js/modal.js for more options $link = "index.php?option=" . LAFC_COMPONENT . "&view=contact&tmpl=component&config_name=" . $config_name; $html = '<a class="fcp_modal" href="' . $link . '" rel="{handler: \'iframe\', size: {x: ' . $modal_x_size . ', y: ' . $modal_y_size . '}}">' . $modal_text . '</a>'; FCP_trace::trace("Plugin drawing modal link: " . $html); return $html; }
function check($view) { $ret = true; switch ($view) { case 'config_confirm': if ($this->_data->config_data->confirm_link == '' and $this->_data->config_data->confirm_text == '') { $msg = JText::_('COM_FLEXICONTACT_ALL_BLANK'); $this->_app->enqueueMessage($msg, 'error'); return false; } break; // case 'config_confirm' // case 'config_confirm' case 'config_text': if (stristr($this->_data->config_data->top_text, "{flexicontactplus") != false) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' - {flexicontactplus...}'; $this->_app->enqueueMessage($msg, 'error'); return false; } if (stristr($this->_data->config_data->bottom_text, "{flexicontactplus") != false) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' - {flexicontactplus...}'; $this->_app->enqueueMessage($msg, 'error'); return false; } break; // case 'config_text' if ($this->_data->config_data->confirm_link == '' and $this->_data->config_data->confirm_text == '') { $msg = JText::_('COM_FLEXICONTACT_ALL_BLANK'); $this->_app->enqueueMessage($msg, 'error'); return false; } break; // case 'config_text' // case 'config_text' case 'config_edit': FCP_Common::strip_quotes($this->_data->name); if (!FCP_Common::clean_string($this->_data->name, false)) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' (' . JText::_('COM_FLEXICONTACT_CONFIG_NAME') . ')'; $this->_app->enqueueMessage($msg, 'error'); return false; } if (strstr($this->_data->name, ' ') != false) { $msg = JText::_('COM_FLEXICONTACT_NO_SPACE') . ' (' . JText::_('COM_FLEXICONTACT_CONFIG_NAME') . ')'; $this->_app->enqueueMessage($msg, 'error'); return false; } if ($this->_exists($this->_data->name, $this->_data->language, $this->_data->id)) { $msg = JText::_('COM_FLEXICONTACT_CONFIG_DUP'); $this->_app->enqueueMessage($msg, 'error'); return false; } break; // case 'config_edit' // case 'config_edit' case 'config_general': $msg = JText::_('COM_FLEXICONTACT_INVALID'); if (!FCP_Common::clean_string($this->_data->config_data->send_text)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_SEND_TEXT') . ')'; $ret = false; } if (!FCP_Common::clean_string($this->_data->config_data->email_from)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_FIELD_FROM_ADDRESS') . ')'; $ret = false; } else { $check_msg = FCP_Admin::validate_email_address($this->_data->config_data->email_from, true); if ($check_msg != '') { $msg .= ' (' . JText::_('COM_FLEXICONTACT_FIELD_FROM_ADDRESS') . ' ' . $check_msg . ')'; $ret = false; } } if (!FCP_Common::clean_string($this->_data->config_data->email_to)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_TO') . ')'; $ret = false; } else { $check_msg = FCP_Admin::validate_email_address($this->_data->config_data->email_to, false); if ($check_msg != '') { $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_TO') . ' ' . $check_msg . ')'; $ret = false; } } if (!FCP_Common::clean_string($this->_data->config_data->email_cc)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_CC') . ')'; $ret = false; } else { $check_msg = FCP_Admin::validate_email_list($this->_data->config_data->email_cc); if ($check_msg != '') { $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_CC') . ' ' . $check_msg . ')'; $ret = false; } } if (!FCP_Common::clean_string($this->_data->config_data->email_bcc)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_BCC') . ')'; $ret = false; } else { $check_msg = FCP_Admin::validate_email_list($this->_data->config_data->email_bcc); if ($check_msg != '') { $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_EMAIL_BCC') . ' ' . $check_msg . ')'; $ret = false; } } if (!FCP_Common::clean_string($this->_data->config_data->email_from_name)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_FIELD_FROM_NAME') . ')'; $ret = false; } if (!FCP_Common::clean_string($this->_data->config_data->agreement_prompt)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_AGREEMENT_REQUIRED') . ' ' . JText::_('COM_FLEXICONTACT_V_PROMPT') . ')'; $ret = false; } if (!FCP_Common::clean_string($this->_data->config_data->agreement_name)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_AGREEMENT_REQUIRED') . ' ' . JText::_('COM_FLEXICONTACT_NAME') . ')'; $ret = false; } if (!FCP_Common::clean_string($this->_data->config_data->white_list)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_ATTACHMENT_WHITE_LIST') . ' (' . $this->_data->config_data->white_list . ')'; $ret = false; } if (!FCP_Common::is_posint($this->_data->config_data->max_file_size) or $this->_data->config_data->max_file_size == 0) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_ATTACHMENT_MAX_SIZE') . ' (' . $this->_data->config_data->max_file_size . ')'; $ret = false; } $max_size = FCP_Admin::get_max_file_size(); if ($max_size > LAFC_MAX_FILE_SIZE) { // Maximum file size must be the lesser of our constant or PHP INI setting $max_size = LAFC_MAX_FILE_SIZE; } if ($this->_data->config_data->max_file_size > $max_size) { $msg .= ' (' . JText::sprintf('COM_FLEXICONTACT_MAX_SIZE_EXCEEDED', $max_size) . ' (' . $this->_data->config_data->max_file_size . ')'; $ret = false; } if (!$ret) { $this->_app->enqueueMessage($msg, 'error'); return false; } break; // case 'config_general' // case 'config_general' case 'config_captcha': $ret = true; $check_string = JText::_('COM_FLEXICONTACT_INVALID'); $msg = $check_string; if (!FCP_Common::clean_string($this->_data->config_data->magic_word)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_MAGIC_WORD') . ')'; $ret = false; } if (!FCP_Common::clean_string($this->_data->config_data->magic_word_prompt)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_MAGIC_WORD_LABEL') . ')'; $ret = false; } if ($this->_data->config_data->magic_word != '' and $this->_data->config_data->magic_word_prompt == '') { $this->_app->enqueueMessage(JText::_('COM_FLEXICONTACT_REQUIRED') . ' (' . JText::_('COM_FLEXICONTACT_MAGIC_WORD_LABEL') . ')', 'error'); $ret = false; } if (!FCP_Common::is_posint($this->_data->config_data->num_images)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_CAPTCHA_NUMBER') . ')'; $ret = false; } if (!FCP_Common::is_posint($this->_data->config_data->image_height, true)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_HEIGHT') . ')'; $ret = false; } elseif ($this->_data->config_data->image_height > 150) { $this->_data->config_data->image_height = 150; } if (!FCP_Common::is_posint($this->_data->config_data->image_width, true)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_V_WIDTH') . ')'; $ret = false; } elseif ($this->_data->config_data->image_width > 150) { $this->_data->config_data->image_width = 150; } if (!FCP_Common::is_posint($this->_data->config_data->captcha_height, true)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_SECURE_CAPTCHA') . ' ' . JText::_('COM_FLEXICONTACT_V_HEIGHT') . ')'; $ret = false; } if (!FCP_Common::is_posint($this->_data->config_data->captcha_width, true)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_SECURE_CAPTCHA') . ' ' . JText::_('COM_FLEXICONTACT_V_WIDTH') . ')'; $ret = false; } if (!FCP_Common::clean_string($this->_data->config_data->secure_captcha_prompt)) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_SECURE_CAPTCHA_LABEL') . ')'; $ret = false; } if ($this->_data->config_data->recaptcha_theme != 0) { if (strlen($this->_data->config_data->recaptcha_public_key) != 40) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_RECAPTCHA') . ' ' . JText::_('COM_FLEXICONTACT_RECAPTCHA_PUBLIC_KEY') . ')'; $ret = false; } if (strlen($this->_data->config_data->recaptcha_private_key) != 40) { $msg .= ' (' . JText::_('COM_FLEXICONTACT_RECAPTCHA') . ' ' . JText::_('COM_FLEXICONTACT_RECAPTCHA_PRIVATE_KEY') . ')'; $ret = false; } } if (!$ret) { if ($msg != $check_string) { $this->_app->enqueueMessage($msg, 'error'); } return false; } break; // case 'config_captcha' // case 'config_captcha' case 'config_field': $field =& $this->_data->config_data->all_fields[$this->_data->field_index]; if ($field->field_type == LAFC_FIELD_CHECKBOX_H) { $msg = JText::sprintf('COM_FLEXICONTACT_FIELD_TYPE_DEPRECATED', JText::_('COM_FLEXICONTACT_FIELD_CHECKBOX_M')); $this->_app->enqueueMessage($msg, 'error'); return false; } if ($field->field_type == LAFC_FIELD_NONE) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' (' . JText::_('COM_FLEXICONTACT_FIELD_TYPE') . ')'; $this->_app->enqueueMessage($msg, 'error'); return false; } if (!FCP_Common::clean_string($field->prompt)) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' (' . JText::_('COM_FLEXICONTACT_V_PROMPT') . ')'; $this->_app->enqueueMessage($msg, 'error'); return false; } if (strlen($field->prompt) > LAFC_MAX_PROMPT_LENGTH) { $msg = JText::_('COM_FLEXICONTACT_MAX_LENGTH') . ' (' . JText::_('COM_FLEXICONTACT_V_PROMPT') . ')'; $this->_app->enqueueMessage($msg, 'error'); return false; } if (!FCP_Common::clean_string($field->css_class)) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' (' . JText::_('COM_FLEXICONTACT_CSS_CLASS') . ')'; $this->_app->enqueueMessage($msg, 'error'); return false; } // Default value does not need to be verified at all since this allows for default to be a POST data variable // If the subject contains a variable, then the subject MUST be invisible. if ($field->field_type == LAFC_FIELD_SUBJECT) { $num_vars = substr_count(strtoupper($field->default_value), "%V_"); $ret_title = true; // Visible? if ($num_vars > 0 and $field->visible == 1) { $ret_title = false; } if (!$ret_title) { $msg = JText::_('COM_FLEXICONTACT_PAGE_TITLE_ERROR'); $this->_app->enqueueMessage($msg, 'error'); return false; } } if ($field->field_type == LAFC_FIELD_SUBJECT or $field->field_type == LAFC_FIELD_FROM_NAME or $field->field_type == LAFC_FIELD_FROM_ADDRESS or $field->field_type == LAFC_FIELD_RECIPIENT) { $count = 0; foreach ($this->_data->config_data->all_fields as $one_field) { if ($one_field->field_type == $field->field_type) { $count++; } } if ($count > 1) { switch ($field->field_type) { case LAFC_FIELD_SUBJECT: $fieldname = JText::_('COM_FLEXICONTACT_FIELD_SUBJECT'); break; case LAFC_FIELD_FROM_NAME: $fieldname = JText::_('COM_FLEXICONTACT_FIELD_FROM_NAME'); break; case LAFC_FIELD_FROM_ADDRESS: $fieldname = JText::_('COM_FLEXICONTACT_FIELD_FROM_ADDRESS'); break; case LAFC_FIELD_RECIPIENT: $fieldname = JText::_('COM_FLEXICONTACT_FIELD_RECIPIENT'); break; default: $fieldname = ''; } $msg = JText::sprintf('COM_FLEXICONTACT_ONLY_ONE_FIELD', $fieldname); $this->_app->enqueueMessage($msg, 'error'); return false; } } if ($field->field_type == LAFC_FIELD_LIST) { if ($field->delimiter == '') { $field->delimiter = ','; } return true; } if ($field->field_type == LAFC_FIELD_RECIPIENT) { $list_array = FCP_Common::split_list($field->list_list, ';', $field->delimiter); foreach ($list_array['RAW'] as $raw_string) { if (substr_count($raw_string, ',') != 1) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ': ' . htmlentities($raw_string); $this->_app->enqueueMessage($msg, 'error'); return false; // must return here to avoid "Undefined offset" errors } } foreach ($list_array['LEFT'] as $recipient_name) { if (!FCP_Common::clean_string($recipient_name, false)) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_NAME') . ': ' . $recipient_name; $this->_app->enqueueMessage($msg, 'error'); $ret = false; } } foreach ($list_array['RIGHT'] as $email_address) { $check_msg = FCP_Admin::validate_email_address($email_address, false); if ($check_msg != '') { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_EMAIL') . ': ' . htmlentities($email_address); $this->_app->enqueueMessage($msg, 'error'); $ret = false; } } if (!$ret) { return false; } } if ($field->field_type == LAFC_FIELD_RADIO_V or $field->field_type == LAFC_FIELD_RADIO_H) { if ($field->delimiter == '') { $field->delimiter = ','; } $list_array = FCP_Common::split_list($field->list_list, ';', $field->delimiter); foreach ($list_array['RAW'] as $raw_string) { if (substr_count($raw_string, $field->delimiter) > 1) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ': ' . htmlentities($raw_string); $this->_app->enqueueMessage($msg, 'error'); return false; // must return here to avoid "Undefined offset" errors } } foreach ($list_array['RIGHT'] as $description) { if (!FCP_Common::clean_string($description)) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_TEXT') . ': ' . htmlentities($description); $this->_app->enqueueMessage($msg, 'error'); $ret = false; } } $num_buttons = count($list_array['LEFT']); if (!FCP_Common::is_posint($field->default_button) or $field->default_button > $num_buttons) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_DEFAULT_BUTTON') . ' (' . $field->default_button . ')'; $this->_app->enqueueMessage($msg, 'error'); $ret = false; } if (!$ret) { return false; } } if ($field->field_type == LAFC_FIELD_CHECKBOX_M) { if ($field->delimiter == '') { $field->delimiter = ','; } } if ($field->field_type == LAFC_FIELD_ADVANCED) { if (!empty($field->regex)) { if (@preg_match($field->regex, 'x') === false) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_REGEX'); $this->_app->enqueueMessage($msg, 'error'); return false; } } if (!empty($field->sql)) { $result = $this->ladb_loadResult($field->sql); if ($result === false) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_SQL_QUERY') . '<br />' . $this->ladb_error_text; $this->_app->enqueueMessage($msg, 'error'); return false; } if (!is_numeric($result)) { $msg = JText::_('COM_FLEXICONTACT_INVALID') . ' ' . JText::_('COM_FLEXICONTACT_SQL_QUERY') . '<br />' . JText::_('COM_FLEXICONTACT_SQL_NUMERIC'); $this->_app->enqueueMessage($msg, 'error'); return false; } } } // Visible property ONLY applies to the Subject field if ($field->field_type != LAFC_FIELD_SUBJECT) { $field->visible = 1; } if ($field->height < LAFC_FIELD_HEIGHT_MIN) { $field->height = LAFC_FIELD_HEIGHT_MIN; } if ($field->height > LAFC_FIELD_HEIGHT_MAX) { $field->height = LAFC_FIELD_HEIGHT_MAX; } // don't allow the tooltip field to include double quotes - change them to single quotes $field->tooltip = str_replace('"', "'", $field->tooltip); // don't allow the default_value field to include double quotes - change them to single quotes $field->default_value = str_replace('"', "'", $field->default_value); break; //case 'config_field' } return true; }
function email_resolve($config_data, $variable) { // field prompts if (strncmp($variable, LAFC_T_FIELD_PROMPT, LAFC_T_OFFSET_P_XX) == 0) { $field_number = substr($variable, LAFC_T_OFFSET_P_XX, 2); // 1-based field number if (!FCP_Common::is_posint($field_number, false)) { return ''; } $field_index = $field_number - 1; // 0-based array index if (!isset($config_data->all_fields[$field_index]->prompt)) { return ''; } return $config_data->all_fields[$field_index]->prompt; // get the prompt from the config data } // field values if (strncmp($variable, LAFC_T_FIELD_VALUE, LAFC_T_OFFSET_V_XX) == 0) { $field_number = substr($variable, LAFC_T_OFFSET_V_XX, 2); // 1-based field number if (!FCP_Common::is_posint($field_number, false)) { return ''; } $field_index = $field_number - 1; // 0-based array index return $this->get_field_value($config_data, $field_index); } // other variables switch ($variable) { case LAFC_T_FROM_NAME: if (isset($this->data->from_name)) { return $this->data->from_name; } else { return ''; } case LAFC_T_FROM_EMAIL: if (isset($this->data->from_email)) { return $this->data->from_email; } else { return ''; } case LAFC_T_SUBJECT: return $this->data->subject; case LAFC_T_ALL_DATA: return $this->data->all_data; case LAFC_T_OTHER_DATA: return $this->data->other_data; case LAFC_T_BROWSER: return $this->data->browser_string; case LAFC_T_IP_ADDRESS: return $this->data->ip; case LAFC_T_URL_PATH: $app = JFactory::getApplication(); return $app->getUserState(LAFC_COMPONENT . "_url_path", ''); // we stored it earlier // we stored it earlier case LAFC_T_SITE_URL: return $this->data->site_url; case LAFC_T_SITE_NAME: return $this->data->site_name; case LAFC_T_PAGE_TITLE: $app = JFactory::getApplication(); return $app->getUserState(LAFC_COMPONENT . "_page_title", ''); // we stored it earlier // we stored it earlier default: return ''; } }