Exemplo n.º 1
0
                ?>
[btqc_f_sendcopy]" value="1"/>
                            </div>    
                <?php 
            }
            //Check captcha
            if ($params->get('captcha') || $params->get('captcha') === null && JFactory::getConfig()->get('captcha')) {
                ?>
                            <div class="btqc-field-container btqc-field-captcha">
                                <label for=""><?php 
                echo JText::_('FIELD_CAPTCHA_LABEL');
                ?>
</label>

                            <?php 
                echo BTQuickContactHelper::createCaptcha($params, 'btqc_f_captcha', 'btqc_f_captcha', 'btqc-captcha');
                ?>

                            </div>     
                                <?php 
            }
            ?>

                        <div class="btqc-field-container btqc-field-submit">
                           
                            <?php 
            if (count($forms) > 1) {
                ?>
                            <button class="button btqc_prev" type="button" /><?php 
                echo JText::_('PREV_STEP');
                ?>
Exemplo n.º 2
0
<?php

/**
 * @package 	BT Quick Contact
 * @version		1.1
 * @created		Aug 2012
 * @author		BowThemes
 * @email		support@bowthems.com
 * @website		http://bowthemes.com
 * @support     Forum - http://bowthemes.com/forum/
 * @copyright   Copyright (C) 2012 Bowthemes. All rights reserved.
 * @license		http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 *
 */
defined('_JEXEC') or die;
require_once 'helpers/helper.php';
//inital params
$moduleID = $module->id;
$layout = $params->get('layout', 'default');
$moduleClassSuffix = $params->get('module_class_suffix');
$fields = json_decode(base64_decode($params->get('fields')));
$helper = new BTQuickContactHelper();
BTQuickContactHelper::fetchHead($params);
require JModuleHelper::getLayoutPath('mod_btquickcontact', '/layouts/' . $layout . '/' . $layout);
Exemplo n.º 3
0
 /**
  * Process posted data and send email
  * @param type $module
  * @param type $params Back-end params
  * @param type $fields All fields of contact form
  */
 public function doPost($module, $params, $fields)
 {
     //xu ly page break và post
     if (JRequest::get('post') && JRequest::getVar('btqc' . $module->id)) {
         $data = JRequest::getVar('btqc' . $module->id);
         //get submitted data
         //validate data by PHP
         foreach ($fields as $field) {
             if ($field->type == 'pagebreak' || $field->type == 'separator') {
                 continue;
             }
             //nếu là checkbox và radio được required mà không được submit hoặc không có giá trị nào
             if ($field->type == 'checkbox' && $field->type == 'radio' && $field->required) {
                 if ($data[$field->alias] && !count($data[$field->alias])) {
                     $this->_result = false;
                     $this->_errorMessages[] = JText::_('ERROR_REQUIRED');
                 }
                 continue;
             } else {
                 if ($field->type == 'file') {
                     //nếu file required thì bắt buộc file check
                     if ($field->required) {
                         if (empty($_FILES) || !$_FILES['btqc' . $module->id]['tmp_name']['btqc_f_' . $field->alias]) {
                             $this->_result = false;
                             $this->_errorMessages[] = JText::_('ERROR_FILE_REQUIRED');
                             continue;
                         }
                     }
                     if (!empty($_FILES)) {
                         if (!key_exists('btqc_f_' . $field->alias, $_FILES['btqc' . $module->id]['tmp_name'])) {
                             continue;
                         }
                         $file = $_FILES['btqc' . $module->id]['tmp_name']['btqc_f_' . $field->alias];
                         if ($file) {
                             $fileExt = explode('.', $_FILES['btqc' . $module->id]['name']['btqc_f_' . $field->alias]);
                             $fileExt = strtolower($fileExt[1]);
                             //check ext
                             if ($field->ext && strpos($field->ext, $fileExt) === false) {
                                 $this->_result = false;
                                 $this->_errorMessages[] = sprintf(JText::_('ERROR_EXT'), str_replace('|', ',', $field->ext));
                             }
                             //check size
                             if (filesize($file) > $field->maxSize * 1024 * 1024) {
                                 $this->_result = false;
                                 $this->_errorMessages[] = sprintf(JText::_('ERROR_MAXSIZE'), $field->maxSize . 'MB');
                             }
                             //neu file khong được sumbit mà được required
                         }
                     }
                     continue;
                 } else {
                     if ($field->required && (!key_exists('btqc_f_' . $field->alias, $data) || !$data['btqc_f_' . $field->alias])) {
                         $this->_result = false;
                         $this->_errorMessages[] = JText::_('ERROR_REQUIRED');
                         continue;
                     }
                     if (!$field->required && (!key_exists('btqc_f_' . $field->alias, $data) || $data['btqc_f_' . $field->alias] == '')) {
                         continue;
                     }
                     //kiểu số
                     if ($field->type == 'number' && $data['btqc_f_' . $field->alias] && !is_numeric($data['btqc_f_' . $field->alias])) {
                         $this->_result = false;
                         $this->_errorMessages[] = JText::_('ERROR_NUMBER');
                     }
                     //kiểu email
                     if ($field->type == 'email' && $data['btqc_f_' . $field->alias]) {
                         $preg = "/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\\._-] +)+\$/";
                         if (preg_match($preg, $data['btqc_f_' . $field->alias])) {
                             $this->_result = false;
                             $this->_errorMessages[] = JText::_('ERROR_EMAIL');
                         }
                     }
                     //kiểu ngày
                     if ($field->type == 'date' && $data['btqc_f_' . $field->alias] && !strtotime($data['btqc_f_' . $field->alias])) {
                         $this->_result = false;
                         $this->_errorMessages[] = JText::_('ERROR_DATE');
                     }
                     continue;
                 }
             }
         }
         //nếu không có lỗi post và có sài captcha thì kiểm tra captcha
         if ($this->_result) {
             if ($params->get('captcha') != '0') {
                 $plugin = BTQuickContactHelper::getCaptchaPlugin($params);
                 if ($plugin) {
                     $captcha = JCaptcha::getInstance($plugin);
                     if (!$captcha->checkAnswer('')) {
                         $this->_result = false;
                         $this->_errorMessages[] = JText::_('ERROR_CAPTCHA');
                         $this->_jsonResponse['captchaError'] = true;
                     }
                 }
             }
         }
         if ($this->_result) {
             //send mail
             if (self::sendMail($data, $fields, $params, $module)) {
                 //show thank you msg
                 $this->_thanksMessage = $params->get('thank_message');
                 //redirect
                 if ($params->get('redirect_url')) {
                     $this->_jsonResponse['redirectUrl'] = $params->get('redirect_url');
                     $this->_jsonResponse['timeOut'] = 3000;
                 }
             } else {
                 $this->_result = false;
                 $this->_errorMessages[] = jText::_('ERROR_SEND_EMAIL');
             }
         }
         if ($this->_result) {
             $this->_jsonResponse['success'] = true;
             $this->_jsonResponse['messages'] = json_encode(array($this->_thanksMessage));
         } else {
             $this->_jsonResponse['success'] = false;
             $this->_jsonResponse['messages'] = json_encode($this->_errorMessages);
         }
         $level = ob_get_level();
         while ($level > 0) {
             ob_end_clean();
             $level--;
         }
         echo json_encode($this->_jsonResponse);
         exit;
     }
 }