0byt3m1n1
Path:
/
data
/
17
/
1
/
18
/
11
/
1670011
/
user
/
1801231
/
htdocs
/
marketting
/
system
/
application
/
controllers
/
[
Home
]
File: forms.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /* | ------------------------------------------------------------------------- | COPYRIGHT NOTICE | Copyright 2008 JROX Technologies, Inc. All Rights Reserved. | ------------------------------------------------------------------------- | This script may be only used and modified in accordance to the license | agreement attached (license.txt) except where expressly noted within | commented areas of the code body. This copyright notice and the | comments above and below must remain intact at all times. By using this | code you agree to indemnify JROX Technologies, Inc, its corporate agents | and affiliates from any liability that might arise from its use. | | Selling the code for this program without prior written consent is | expressly forbidden and in violation of Domestic and International | copyright laws. | | ------------------------------------------------------------------------- | FILENAME -forms.php | ------------------------------------------------------------------------- | | This controller file is used to generate the forms for signing up | */ class Forms extends Public_Controller { function __construct() { parent::Public_Controller(); //load css body style $this->config->set_item('css_body', 'jroxForms'); //load required models $this->load->model('init_model', 'init'); $this->load->model('forms_model', 'forms'); //create pagination links $this->config->set_item('uri', $this->config->item('base_folder_path') . '/' . $this->uri->segment(1)); $this->load->helper('country'); } // ------------------------------------------------------------------------ function index() { redirect('/forms/registration'); } function registration() //sts_form_enable_custom_fields_registration { //show default registration echo $this->uri->segment(2); } // ------------------------------------------------------------------------ function contact_us() //sts_form_enable_custom_fields_contact_us { //set data array $data = $this->security_model->_load_config('public'); //initialize site with required db config $sdata = $this->init->_initialize(__CLASS__, __FUNCTION__); //set up the languages array $data['languages'] = $sdata['languages']; //set all text foreach ($sdata['text'] as $key => $val) { $data[$key] = $val; } //set referral info foreach ($sdata['aff_cfg'] as $key => $val) { $data[$key] = $val; } $data['store_country'] = _get_country_name($data['sts_store_shipping_country'], 'country_name'); $data['store_email'] = safe_mailto($data['sts_store_email']); $data['lang_contact_us'] = $this->lang->line('contact_us'); $data['lang_name'] = $this->lang->line('name'); $data['lang_email'] = $this->lang->line('email'); $data['lang_message'] = $this->lang->line('message'); $data['page_title'] = $data['layout_design_header_tag_line'] . ' - ' . $this->lang->line('contact_us'); $data['meta_keywords'] = $data['sts_store_default_keywords']; $data['meta_description'] = $data['sts_store_description']; $data['show_message'] = ''; $data['cc_one'] = ''; $data['cc_two'] = ''; $data['cc_three'] = ''; //get custom form fields if ($this->_check_contact_us() == false) { if(!empty($_POST)) { $data['show_message'] = '<div class="errorMessage">' . $this->validation->error_string . '</div>'; $data['cc_one'] = $this->validation->cc_one; $data['cc_two'] = $this->validation->cc_two; $data['cc_three'] = $this->validation->cc_three; $this->security_model->_auto_block_ip('block', $this->input->ip_address()); } } else { $this->load->model('emailing_model'); $form = $this->db_validation_model->_clean_data($_POST); $sdata = array(); $sdata['contact_message_html'] = nl2br($form['cc_three']) . '<br /><br />'; $sdata['contact_message_text'] = $form['cc_three'] . "\n\n"; $sdata['primary_email'] = $this->config->item('sts_store_email'); $sdata['fname'] = $this->config->item('sts_store_name'); foreach ($form as $k => $v) { if ($k == 'cc_one') { $sdata['contact_name'] = $form['cc_one']; } elseif ($k == 'cc_two') { $sdata['contact_email'] = $form['cc_two']; $sdata['reply_to_email'] = $form['cc_two']; } else { if ($k != 'cc_three') { $sdata['contact_message_html'] .= $k . ': ' . $v . '<br />'; $sdata['contact_message_text'] .= $k . ': ' . $v . "\n"; } } } if ($this->emailing_model->_send_template_email('admin', $sdata, 'admin_alert_contact_us_template', false)) { //log success log_message('info', 'contact form sent to ' . $sdata['primary_email']); } else { show_error($this->lang->line('could_not_send_email') . '. ' . $this->lang->line('check_email_settings')); log_message('error', 'Could not send email to ' . $sdata['primary_email'] . '. Check email settings.'); } $data['show_message'] = '<div class="successMessage">' . $this->lang->line('email_sent_successfully') . '</div>'; $this->security_model->_auto_block_ip('remove', $this->input->ip_address()); } $data['show_custom_fields'] = 0; if ($this->config->item('sts_form_enable_custom_fields_contact_us') == 1) { $sdata = $this->forms->_get_forms('custom_contact_fields', '1'); if (!empty($sdata)) { $data['show_custom_fields'] = 1; $data['custom_fields'] = array(); foreach ($sdata as $v) { $v['form_id'] = $v['form_field_name']; $v['field_name'] = $v['form_field_description']; $v['form_html_value'] = url_title($v['form_field_description'], '_'); $v['form_field_name'] = $v['form_html_value']; $v['required'] = $v['form_field_required'] == 1 ? 'required' : ''; $v['form_html'] = load_field_type($v['form_field_type'], $v, $v['form_field_values'], 'jroxContactFormInput ' . $v['required']); array_push($data['custom_fields'], $v); } } //echo '<pre>'; print_r($data['custom_fields']); exit(); } //check captcha $this->load->helper('captcha'); $captcha = _generate_captcha(); $data = array_merge($data, $captcha); $this->parser->_JROX_load_view('tpl_contact', 'forms', $data); } // ------------------------------------------------------------------------ /* | ------------------------------------------------------------------------- | supporting functions - these are used to support the main functions above | ------------------------------------------------------------------------- */ // ------------------------------------------------------------------------ function _check_contact_us() { $rules['cc_one'] = 'trim|required|min_length[2]|max_length[100]'; $rules['cc_two'] = 'trim|required|valid_email'; $rules['cc_three'] = 'trim|required|min_length[5]'; if ($this->config->item('sts_sec_enable_captcha') == 1) { $rules['jroxVerifyField'] = 'trim|required|callback__check_captcha'; } $this->validation->set_rules($rules); //repopulate form $fields['cc_one'] = $this->lang->line('name'); $fields['cc_two'] = $this->lang->line('email'); $fields['cc_three'] = $this->lang->line('message'); $this->validation->set_fields($fields); if ($this->validation->run() == FALSE) { return false; } return true; } // ------------------------------------------------------------------------ function _check_captcha() { if ($this->session->userdata('user_captcha_set') != $this->validation->jroxVerifyField) { $this->validation->set_message('_check_captcha', $this->lang->line('invalid_verification_code')); return false; } } } ?>