コード例 #1
0
ファイル: config.php プロジェクト: vstorm83/propertease
 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;
 }
コード例 #2
0
 function display_embedded($config_name)
 {
     // get the specified configuration
     $config_name = trim($config_name);
     $config_name = htmlspecialchars_decode($config_name, ENT_QUOTES);
     // convert html entities to characters
     FCP_Common::strip_quotes($config_name);
     // remove all quotes
     jimport('joomla.application.component.model');
     $config_data = $this->config_model->getConfigData($config_name);
     if ($config_data === false) {
         JPlugin::loadLanguage();
         // load the plugin's own language file
         $html = JText::_('PLG_CONTENT_FLEXICONTACTPLUS_NO_CONFIG');
         FCP_trace::trace("PLUGIN: No config data");
         return $html;
     }
     $this->data_model->init_data($config_data);
     $html = FlexicontactplusViewContact::draw_page($config_data, $this->data_model->data);
     return $html;
 }