コード例 #1
0
 function store()
 {
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'language.php';
     // load basic stuff:
     OPCLang::loadLang();
     $user = JFactory::getUser();
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.archive');
     jimport('joomla.archive.archive');
     $msg = '';
     $db = JFactory::getDBO();
     $data = JRequest::get('post');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     foreach ($data as $k => $d) {
         if (strpos($k, 'tid_') !== false && strpos($k, 'payment_contentid') === false) {
             /* we have a standard variable:
             	  tid_special_, tid_ai_, tid_num_, tid_back_,  tid_forward_
             	  tid_nummax_, tid_itemmax_
             	  tid_type_
             	  */
             if (!defined($k)) {
                 $this->setTemplateSetting($k, $data[$k]);
                 //echo 'template setting: '.$k.'value: '.$data[$k];
                 define($k, $data[$k]);
             }
             $a = explode('_', $k);
             if (count($a) == 3) {
                 $tid = $a[2];
                 $checkboxes = array('tid_special_', 'tid_ai_', 'tid_num_', 'tid_forward_', 'tid_back_', 'tid_enabled_', 'tid_foreign_', 'tid_email_', 'tid_autocreate_');
                 foreach ($checkboxes as $ch) {
                     if (!isset($data[$ch . $tid]) && !defined($ch . $tid)) {
                         $this->setTemplateSetting($ch . $tid, 0);
                         define($ch . $tid, '0');
                         //echo ':'.$ch.$tid.' val: 0';
                     }
                 }
             }
         }
     }
     return true;
 }
コード例 #2
0
ファイル: plugin.php プロジェクト: aldegtyarev/stelsvelo
 public static function checkLoad()
 {
     $app = JFactory::getApplication();
     // if we are not at FE, do not alter anything
     if ($app->getName() != 'site') {
         return false;
     }
     require_once JPATH_SITE . DIRECTORY_SEPARATOR . 'administrator' . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'compatibility.php';
     // if (!class_exists('VmConfig'))
     //	  require(JPATH_ADMINISTRATOR.DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_virtuemart'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'config.php');
     if (!file_exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php')) {
         return false;
     }
     // test format:
     $format = JRequest::getVar('format', 'html');
     $option = JRequest::getCmd('option');
     $tmpl = JRequest::getVar('tmpl', '');
     if ($tmpl == 'component' && $format != 'opchtml') {
         return false;
     }
     // speed up json requests
     $okformat = array('opchtml', 'html');
     if (!in_array($format, $okformat)) {
         return false;
     }
     $doc = JFactory::getDocument();
     $class = get_class($doc);
     $class = strtolower($class);
     $format = str_replace('jdocument', '', $class);
     if (!in_array($format, $okformat)) {
         return;
     }
     if ($app->isAdmin()) {
         return false;
     }
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php';
     // load basic stuff:
     OPCLang::loadLang();
     if (!defined('DS')) {
         define('DS', DIRECTORY_SEPARATOR);
     }
     if (!defined('JPATH_OPC')) {
         define('JPATH_OPC', JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage');
     }
     //VmConfig::loadConfig();
     return true;
 }
コード例 #3
0
ファイル: config.php プロジェクト: aldegtyarev/stelsvelo
    function store()
    {
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'language.php';
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
        // load basic stuff:
        OPCLang::loadLang();
        $this->removeCache();
        $this->loadVmConfig();
        $user = JFactory::getUser();
        $this->storeRegistration();
        $opc_load_jquery = JRequest::getVar('opc_load_jquery', false);
        if (!empty($opc_load_jquery)) {
            $opc_load_jquery = true;
        }
        OPCConfig::store('opc_load_jquery', '', 0, $opc_load_jquery);
        if (!class_exists('JFile')) {
            require JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'filesystem' . DIRECTORY_SEPARATOR . 'file.php';
        }
        if (!class_exists('JFolder')) {
            require JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'filesystem' . DIRECTORY_SEPARATOR . 'folder.php';
        }
        $msg = '';
        $rename = JRequest::getVar('rename_to_custom', false);
        if ($rename) {
            $msg .= $this->renameTheme();
        }
        $db = JFactory::getDBO();
        $data = JRequest::get('post');
        $this->storeTY($data);
        $cfg = urldecode('%3C%3Fphp') . '
if( !defined( \'_VALID_MOS\' ) && !defined( \'_JEXEC\' ) ) die( \'Direct Access to \'.basename(__FILE__).\' is not allowed.\' );
/*
*      One Page Checkout configuration file
*      Copyright RuposTel s.r.o. under GPL license
*      Version 2 of date 31.March 2012
*      Feel free to modify this file according to your needs
*
*
*     @copyright Copyright (C) 2007 - 2012 RuposTel - All rights reserved.
*     @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*     One Page checkout is free software released under GNU/GPL and uses code from VirtueMart
*     VirtueMart is free software. This version may have been modified pursuant
*     to the GNU General Public License, and as distributed it includes or
*     is derivative of works licensed under the GNU General Public License or
*     other free or open source software licenses.
* 
*/




';
        $cfg .= '
		  if (!class_exists(\'VmConfig\'))
		  require(JPATH_ADMINISTRATOR.DS.\'components\'.DS.\'com_virtuemart\'.DS.\'helpers\'.DS.\'config.php\'); 
		  VmConfig::loadConfig(); 

';
        if (!empty($data['delete_ht'])) {
            if (JFile::delete(JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'assets' . DS . 'js' . DS . '.htaccess') === false) {
                $msg .= JText::sprintf('COM_VIRTUEMART_STRING_DELETED_ERROR', JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'assets' . DS . 'js' . DS . '.htaccess');
            }
        }
        if (!empty($data['opc_cr_type'])) {
            $cfg .= ' $opc_cr_type = \'' . $data['opc_cr_type'] . '\'; ';
        }
        $data['do_not_show_opcregistration'] = (int) $data['do_not_show_opcregistration'];
        if (!empty($data['do_not_show_opcregistration'])) {
            $cfg .= ' $do_not_show_opcregistration = 1; ';
        }
        if (isset($data['bt_fields_from'])) {
            $cfg .= ' $bt_fields_from = \'' . $data['bt_fields_from'] . '\'; ';
        }
        if (isset($data['op_default_shipping_search'])) {
            $cfg .= ' $op_default_shipping_search = array(); ';
            if (is_array($data['op_default_shipping_search'])) {
                $i = 0;
                foreach ($data['op_default_shipping_search'] as $key => $val) {
                    if (empty($val)) {
                        continue;
                    }
                    $cfg .= ' $op_default_shipping_search[' . $i . '] = "' . str_replace('"', '\\"', $val) . '"; ';
                    $i++;
                }
            } else {
                $cfg .= ' $op_default_shipping_search[0] = "' . str_replace('"', '\\"', $val) . '"; ';
            }
        }
        if (!empty($data['home_vat_countries'])) {
            $home = str_replace('"', '', $data['home_vat_countries']);
            $cfg .= ' $home_vat_countries = "' . $home . '"; ';
        }
        if (isset($data['opc_payment_refresh'])) {
            $cfg .= '$opc_payment_refresh = true;
    ';
        }
        if (isset($data['use_original_basket'])) {
            $cfg .= '$use_original_basket = true;
    ';
        } else {
            $cfg .= '$use_original_basket = false; 
    ';
        }
        //opc_php_js
        //theme_fix1
        if (isset($data['theme_fix1'])) {
            $cfg .= '$theme_fix1 = true;
    ';
        } else {
            $cfg .= '$theme_fix1 = false; 
    ';
        }
        if (isset($data['opc_override_registration'])) {
            $cfg .= '$opc_override_registration = true; 
    ';
            $this->enableOpcRegistration(true);
        } else {
            $this->enableOpcRegistration(false);
        }
        if (isset($data['opc_euvat'])) {
            $cfg .= '$opc_euvat = true;
    ';
            $coref = array();
            $ulist = $this->getUserFieldsLists($coref);
            $found = false;
            $published = 1;
            $datau = array();
            $datau2 = array();
            foreach ($ulist as $key => $val) {
                if ($val->name == 'opc_vat') {
                    $published = $val->published;
                    $found = true;
                    if (empty($published)) {
                        foreach ($val as $key2 => $v) {
                            $datau[$key2] = $v;
                        }
                    }
                }
                if ($val->name == 'opc_vat_info') {
                    $published2 = $val->published;
                    $found = true;
                    if (empty($published2)) {
                        foreach ($val as $key2 => $v) {
                            $datau2[$key2] = $v;
                        }
                    }
                }
            }
            if (!$found || (empty($published) || empty($published2))) {
                $modelu = new VirtueMartModelUserfields();
                if (empty($datau)) {
                    $datau = array('virtuemart_userfield_id' => '0', 'virtuemart_vendor_id' => '0', 'userfield_jplugin_id' => '0', 'name' => 'opc_vat', 'title' => 'COM_ONEPAGE_EUVAT_FIELD', 'description' => '', 'type' => 'text', 'maxlength' => '25', 'size' => '30', 'required' => '0', 'cols' => '0', 'rows' => '0', 'value' => '', 'default' => NULL, 'registration' => '1', 'shipment' => '0', 'account' => '1', 'readonly' => '0', 'calculated' => '0', 'sys' => '0', 'params' => '', 'ordering' => '99', 'shared' => '0', 'published' => '1', 'created_on' => '0000-00-00 00:00:00', 'created_by' => '0', 'modified_on' => '0000-00-00 00:00:00', 'modified_by' => '0', 'locked_on' => '0000-00-00 00:00:00', 'locked_by' => '0');
                } else {
                    $datau['published'] = 1;
                }
                if (empty($datau2)) {
                    $datau2 = array('virtuemart_userfield_id' => '0', 'virtuemart_vendor_id' => '0', 'userfield_jplugin_id' => '0', 'name' => 'opc_vat_info', 'title' => 'COM_ONEPAGE_EUVAT_FIELD_INFO', 'description' => '', 'type' => 'hidden', 'maxlength' => '1000', 'size' => NULL, 'required' => '0', 'cols' => '0', 'rows' => '0', 'value' => '', 'default' => NULL, 'registration' => '1', 'shipment' => '0', 'account' => '1', 'readonly' => '0', 'calculated' => '0', 'sys' => '0', 'params' => '', 'ordering' => '99', 'shared' => '0', 'published' => '1', 'created_on' => '0000-00-00 00:00:00', 'created_by' => '0', 'modified_on' => '0000-00-00 00:00:00', 'modified_by' => '0', 'locked_on' => '0000-00-00 00:00:00', 'locked_by' => '0');
                } else {
                    $datau2['published'] = 1;
                }
                $modelu->store($datau);
                $modelu->store($datau2);
            }
        } else {
            $q = 'update #__virtuemart_userfields set published = 0 where name LIKE "opc_vat" or name LIKE "opc_vat_info"';
            $db = JFactory::getDBO();
            $db->setQuery($q);
            $db->query();
        }
        if (isset($data['opc_euvat_button'])) {
            $cfg .= '$opc_euvat_button = true;
    ';
        }
        if (isset($data['opc_euvat_contrymatch'])) {
            $cfg .= '$opc_euvat_contrymatch = true;
    ';
        }
        //disable_check
        if (isset($data['opc_no_activation'])) {
            $cfg .= '$opc_no_activation = true;
    ';
        } else {
            $cfg .= '$opc_no_activation = false; 
    ';
        }
        //disable_check
        if (isset($data['disable_check'])) {
            $cfg .= '$disable_check = true;
    ';
        } else {
            $cfg .= '$disable_check = false; 
    ';
        }
        if (isset($data['opc_php_js2'])) {
            $cfg .= '$opc_php_js2 = true;
    ';
        } else {
            $cfg .= '$opc_php_js2 = false; 
    ';
        }
        //only_one_shipping_address_hidden
        if (isset($data['only_one_shipping_address_hidden'])) {
            $cfg .= '$only_one_shipping_address_hidden = true;
    ';
        } else {
            $cfg .= '$only_one_shipping_address_hidden = false; 
    ';
        }
        if (isset($data['opc_only_parent_links'])) {
            $cfg .= '$opc_only_parent_links = true;
    ';
        } else {
            $cfg .= '$opc_only_parent_links = false; 
    ';
        }
        //opc_show_weight
        if (isset($data['opc_show_weight'])) {
            $cfg .= '$opc_show_weight = true;
    ';
        } else {
            $cfg .= '$opc_show_weight = false; 
    ';
        }
        if (isset($data['opc_dynamic_lines'])) {
            $cfg .= '$opc_dynamic_lines = true;
    ';
        } else {
            $cfg .= '$opc_dynamic_lines = false; 
    ';
        }
        if (isset($data['opc_editable_attributes'])) {
            $cfg .= '$opc_editable_attributes = true;
    ';
        } else {
            $cfg .= '$opc_editable_attributes = false; 
    ';
        }
        if (isset($data['op_customer_shipping'])) {
            $cfg .= '$op_customer_shipping = true;
    ';
        } else {
            $cfg .= '$op_customer_shipping = false; 
    ';
        }
        //allow_sg_update
        if (isset($data['allow_sg_update'])) {
            $cfg .= '$allow_sg_update = true;
    ';
        } else {
            $cfg .= '$allow_sg_update = false; 
    ';
        }
        if (isset($data['allow_sg_update_logged'])) {
            $cfg .= '$allow_sg_update_logged = true;
    ';
        } else {
            $cfg .= '$allow_sg_update_logged = false; 
    ';
        }
        if (isset($data['do_not_allow_gift_deletion'])) {
            $cfg .= '$do_not_allow_gift_deletion = true;
    ';
        } else {
            $cfg .= '$do_not_allow_gift_deletion = false; 
    ';
        }
        $gift_order_statuses = JRequest::getVar('gift_order_statuses', array());
        if (empty($gift_order_statuses)) {
            $cfg .= ' $gift_order_statuses = array(); ';
        } else {
            $str = var_export($gift_order_statuses, true);
            $cfg .= "\n" . ' $gift_order_statuses = ' . $str . ';' . "\n";
        }
        //opc_async
        if (isset($data['opc_async'])) {
            $cfg .= '$opc_async = true;
    ';
        } else {
            $cfg .= '$opc_async = false; 
    ';
        }
        if (isset($data['use_free_text'])) {
            $cfg .= '$use_free_text = true;
    ';
        } else {
            $cfg .= '$use_free_text = false; 
    ';
        }
        if (isset($data['disable_op'])) {
            $cfg .= '$disable_onepage = true;
    ';
        } else {
            $cfg .= '$disable_onepage = false; 
    ';
        }
        if (isset($data['opc_italian_checkbox'])) {
            $cfg .= '$opc_italian_checkbox = true;
    ';
        } else {
            $cfg .= '$opc_italian_checkbox = false; 
    ';
        }
        if (isset($data['opc_acymailing_checkbox'])) {
            $cfg .= '$opc_acymailing_checkbox = true;
    ';
        } else {
            $cfg .= '$opc_acymailing_checkbox = false; 
    ';
        }
        $data['opc_acy_id'] = (int) $data['opc_acy_id'];
        $cfg .= ' $opc_acy_id = (int)"' . $data['opc_acy_id'] . '"; ';
        //opc_do_not_alter_registration
        if (isset($data['opc_do_not_alter_registration'])) {
            $cfg .= '$opc_do_not_alter_registration = true;
    ';
        } else {
            $cfg .= '$opc_do_not_alter_registration = false; 
    ';
        }
        if (isset($data['opc_debug'])) {
            $cfg .= '$opc_debug = true;
    ';
        } else {
            $cfg .= '$opc_debug = false; 
    ';
        }
        if (isset($data['opc_debug2'])) {
            $cfg .= '$opc_debug2 = true;
    ';
        }
        if (!empty($data['blank_screens_email'])) {
            $cfg .= ' $blank_screens_email = \'' . addslashes($data['blank_screens_email']) . '\'; ';
        }
        if (isset($data['opc_memory'])) {
            $cfg .= ' $opc_memory = \'' . addslashes($data['opc_memory']) . '\'; ';
        }
        if (isset($data['rupostel_email'])) {
            $cfg .= ' $rupostel_email = \'' . addslashes($data['rupostel_email']) . '\'; ';
        }
        if (isset($data['opc_plugin_order']) && is_numeric($data['opc_plugin_order'])) {
            $cfg .= '$opc_plugin_order = \'' . $data['opc_plugin_order'] . '\';
    ';
        } else {
            $cfg .= '$opc_plugin_order = -9999; 
    ';
        }
        //
        if (isset($data['opc_disable_for_mobiles'])) {
            $cfg .= '$opc_disable_for_mobiles = true;
    ';
        } else {
            $cfg .= '$opc_disable_for_mobiles = false; 
    ';
        }
        if (isset($data['opc_request_cache'])) {
            $cfg .= '$opc_request_cache = true;
    ';
        } else {
            $cfg .= '$opc_request_cache = false; 
    ';
        }
        if (isset($data['opc_check_username'])) {
            $cfg .= '$opc_check_username = true;';
        } else {
            $cfg .= '$opc_check_username = false;';
        }
        if (isset($data['opc_rtl'])) {
            $cfg .= '$opc_rtl = true;';
        } else {
            $cfg .= '$opc_rtl = false;';
        }
        if (!empty($data['opc_no_duplicit_username']) && empty($data['op_usernameisemail'])) {
            $cfg .= '$opc_no_duplicit_username = true;
    ';
            $cfg .= '$opc_check_username = true;';
        } else {
            $cfg .= '$opc_no_duplicit_username = false; 
    ';
        }
        if (isset($data['klarna_se_get_address'])) {
            $cfg .= '$klarna_se_get_address = true;';
        } else {
            $cfg .= '$klarna_se_get_address = false;';
        }
        if (isset($data['ajaxify_cart'])) {
            $cfg .= '$ajaxify_cart = true;';
        } else {
            $cfg .= '$ajaxify_cart = false;';
        }
        if (isset($data['opc_check_email'])) {
            $cfg .= '$opc_check_email = true;';
        } else {
            $cfg .= '$opc_check_email = false;';
        }
        if (!empty($data['opc_no_duplicit_email'])) {
            $cfg .= '$opc_no_duplicit_email = true;
    ';
            $cfg .= '$opc_check_email = true;';
            $cfg .= '$allow_duplicit = false;';
        } else {
            $cfg .= '$opc_no_duplicit_email = false; 
    ';
        }
        //show_single_tax
        if (!empty($data['show_single_tax'])) {
            $cfg .= '$show_single_tax = true;
    ';
        } else {
            $cfg .= '$show_single_tax = false; 
    ';
        }
        if (!empty($data['opc_calc_cache'])) {
            $cfg .= '$opc_calc_cache = true;
    ';
        } else {
            $cfg .= '$opc_calc_cache = false; 
    ';
        }
        if (!empty($data['visitor_shopper_group'])) {
            $cfg .= '$visitor_shopper_group = "' . $data['visitor_shopper_group'] . '";
    ';
        } else {
            $cfg .= '$visitor_shopper_group = 0; 
    ';
        }
        if (!empty($data['no_coupon_ajax'])) {
            $cfg .= '$no_coupon_ajax = true;
    ';
        } else {
            $cfg .= '$no_coupon_ajax = false; 
    ';
        }
        if (!empty($data['business_shopper_group'])) {
            $cfg .= '$business_shopper_group = "' . $data['business_shopper_group'] . '";
    ';
        } else {
            $cfg .= '$business_shopper_group = 0; 
    ';
        }
        if (!empty($data['zero_total_status'])) {
            $cfg .= '$zero_total_status = "' . $data['zero_total_status'] . '";
    ';
        } else {
            $cfg .= '$zero_total_status = "C"; 
    ';
        }
        //op_never_log_in
        //option_sgroup
        if (!empty($data['option_sgroup'])) {
            $cfg .= '$option_sgroup = ' . (int) $data['option_sgroup'] . ';;
    ';
        } else {
            $cfg .= '$option_sgroup = false; 
    ';
        }
        if (!empty($data['op_never_log_in'])) {
            $cfg .= '$op_never_log_in = true;
    ';
        } else {
            $cfg .= '$op_never_log_in = false; 
    ';
        }
        //no_alerts
        if (!empty($data['no_alerts'])) {
            $cfg .= '$no_alerts = true;
    ';
        } else {
            $cfg .= '$no_alerts = false; 
    ';
        }
        if (!empty($data['disable_ship_to_on_zero_weight'])) {
            $cfg .= '$disable_ship_to_on_zero_weight = true;
    ';
        } else {
            $cfg .= '$disable_ship_to_on_zero_weight = false; 
    ';
        }
        //
        if (!empty($data['op_use_geolocator'])) {
            $cfg .= '$op_use_geolocator = true;
    ';
        } else {
            $cfg .= '$op_use_geolocator = false; 
    ';
        }
        if (!empty($data['append_details'])) {
            $cfg .= '$append_details = true;
    ';
        } else {
            $cfg .= '$append_details = false; 
    ';
        }
        if (!empty($data['op_redirect_joomla_to_vm'])) {
            $cfg .= '$op_redirect_joomla_to_vm = true;
    ';
        } else {
            $cfg .= '$op_redirect_joomla_to_vm = false; 
    ';
        }
        if (!empty($data['password_clear_text'])) {
            $cfg .= '$password_clear_text = true;
    ';
        } else {
            $cfg .= '$password_clear_text = false; 
    ';
        }
        $cfg .= ' $dpps_search = array(); $dpps_disable = array(); $dpps_default=array(); ' . "\n";
        if (!empty($data['disable_payment_per_shipping'])) {
            $search = JRequest::getVar('dpps_search');
            $cfg .= ' $disable_payment_per_shipping = true; ';
            foreach ($search as $i => $v) {
                if (!empty($data['dpps_disable'][$i]) && !empty($v)) {
                    $val = urlencode($v);
                    $val = str_replace("'", "\\'", $val);
                    $cfg .= ' $dpps_search[' . $i . '] = ' . "'" . $val . "';\n";
                    $cfg .= ' $dpps_disable[' . $i . '] = ' . "'" . $data['dpps_disable'][$i] . "';\n";
                    if ($data['dpps_default'][$i] != $data['dpps_disable'][$i]) {
                        $cfg .= ' $dpps_default[' . $i . '] = ' . "'" . $data['dpps_default'][$i] . "';\n";
                    } else {
                        $cfg .= ' $dpps_default[' . $i . '] = \'\'; ';
                    }
                }
            }
        } else {
            $cfg .= ' $disable_payment_per_shipping = false; ';
        }
        if (!empty($data['euvat_shopper_group'])) {
            $cfg .= '$euvat_shopper_group = "' . $data['euvat_shopper_group'] . '";
    ';
        } else {
            $cfg .= '$euvat_shopper_group = 0; 
    ';
        }
        if (!empty($data['payment_discount_before'])) {
            $cfg .= '$payment_discount_before = true;
    ';
        } else {
            $cfg .= '$payment_discount_before = false; 
    ';
        }
        if (!empty($data['only_one_shipping_address'])) {
            $cfg .= '$only_one_shipping_address = true;
    ';
        } else {
            $cfg .= '$only_one_shipping_address = false; 
    ';
        }
        if (isset($data['no_extra_product_info'])) {
            $cfg .= '$no_extra_product_info = true;
    ';
        } else {
            $cfg .= '$no_extra_product_info = false; 
    ';
        }
        if (isset($data['enable_captcha_unlogged'])) {
            $cfg .= '$enable_captcha_unlogged = true;
    ';
        } else {
            $cfg .= '$enable_captcha_unlogged = false; 
    ';
        }
        if (isset($data['send_pending_mail'])) {
            $cfg .= '$send_pending_mail = true;
    ';
        } else {
            $cfg .= '$send_pending_mail = false; 
    ';
        }
        if (isset($data['enable_captcha_logged'])) {
            $cfg .= '$enable_captcha_logged = true;
    ';
        } else {
            $cfg .= '$enable_captcha_logged = false; 
    ';
        }
        if (isset($data['hide_advertise'])) {
            $cfg .= '$hide_advertise = true;
    ';
        } else {
            $cfg .= '$hide_advertise = false; 
    ';
        }
        if (isset($data['hide_payment_if_one'])) {
            $cfg .= '$hide_payment_if_one = true;
    ';
        } else {
            $cfg .= '$hide_payment_if_one = false; 
    ';
        }
        if (!empty($data['disable_op'])) {
            if (version_compare(JVERSION, '1.7.0', 'ge') || version_compare(JVERSION, '1.6.0', 'ge') || version_compare(JVERSION, '2.5.0', 'ge')) {
                $q = "update #__extensions set enabled = 0 where element = 'opc' and type = 'plugin' limit 2 ";
            } else {
                $q = "update #__plugins set published = 0 where element = 'opc'  limit 2 ";
            }
            $db = JFactory::getDBO();
            $db->setQuery($q);
            $db->query();
            $e = $db->getErrorMsg();
            if (!empty($e)) {
                echo $msg .= $e;
            }
        } else {
            if (version_compare(JVERSION, '1.7.0', 'ge') || version_compare(JVERSION, '1.6.0', 'ge') || version_compare(JVERSION, '2.5.0', 'ge')) {
                $q = "update #__extensions set enabled = 1 where element = 'opc' and type = 'plugin' and folder = 'system' limit 2 ";
                // disable other opc solutions:
                $q2 = "update #__extensions set enabled = 0 where element = 'onestepcheckout' and type = 'plugin' and folder = 'system' ";
                $q3 = "update #__extensions set enabled = 0 where element = 'vponepagecheckout' and type = 'plugin' and folder = 'system' ";
            } else {
                $q = "update #__plugins set published = 1 where element = 'opc' and folder = 'system'  limit 2 ";
                $q2 = "update #__plugins set published = 0 where element = 'onestepcheckout' and folder = 'system' ";
                $q3 = "update #__plugins set published = 0 where element = 'vponepagecheckout' and folder = 'system' ";
            }
            $db = JFactory::getDBO();
            $db->setQuery($q);
            $db->query();
            $e = $db->getErrorMsg();
            if (!empty($e)) {
                echo $msg .= $e;
            }
            $db = JFactory::getDBO();
            $db->setQuery($q2);
            $db->query();
            $db = JFactory::getDBO();
            $db->setQuery($q3);
            $db->query();
        }
        $cfg .= "\n/* If user in Optional, normal, silent registration sets email which already exists and is registered \n* and you set this to true\n* his order details will be saved but he will not be added to joomla registration and checkout can continue\n* if registration type allows username and password which is already registered but his new password is not the same as in DB then checkout will return error\n*/\n";
        if (isset($data['email_after'])) {
            $cfg .= '$email_after = true;
      ';
        } else {
            $cfg .= '$email_after = false;
      ';
        }
        if (empty($data['opc_link_type'])) {
            $cfg .= '$opc_link_type = 0;
      ';
        } else {
            $cfg .= '$opc_link_type = ' . $data['opc_link_type'] . '; 
      ';
        }
        if (!empty($data['business_fields'])) {
            foreach ($data['business_fields'] as $k => $line) {
                $data['business_fields'][$k] = "'" . $line . "'";
            }
            // special cases
            if (in_array('password', $data['business_fields'])) {
                $data['business_fields'][] = 'opc_password';
            }
            if (in_array('username', $data['business_fields'])) {
                $data['business_fields'][] = 'opc_username';
            }
            $newa = implode(',', $data['business_fields']);
            $cfg .= ' $business_fields = array(' . $newa . '); ';
        } else {
            $cfg .= ' $business_fields = array(); ';
        }
        if (!empty($data['custom_rendering_fields'])) {
            foreach ($data['custom_rendering_fields'] as $k => $line) {
                $data['custom_rendering_fields'][$k] = "'" . $line . "'";
            }
            $newa = implode(',', $data['custom_rendering_fields']);
            $cfg .= ' $custom_rendering_fields = array(' . $newa . '); ';
        } else {
            $cfg .= ' $custom_rendering_fields = array(); ';
        }
        if (!empty($data['shipping_obligatory_fields'])) {
            foreach ($data['shipping_obligatory_fields'] as $k => $line) {
                $data['shipping_obligatory_fields'][$k] = "'" . $line . "'";
            }
            $newa = implode(',', $data['shipping_obligatory_fields']);
            $cfg .= ' $shipping_obligatory_fields = array(' . $newa . '); ';
        } else {
            $cfg .= ' $shipping_obligatory_fields = array(); ';
        }
        if (!empty($data['op_disable_shipping'])) {
            $cfg .= '$op_disable_shipping = true;
      ';
        } else {
            $cfg .= '$op_disable_shipping = false;
      ';
        }
        if (!empty($data['op_disable_shipto'])) {
            $cfg .= '$op_disable_shipto = true;
      ';
        } else {
            $cfg .= '$op_disable_shipto = false;
      ';
        }
        if (!empty($data['op_no_display_name'])) {
            $cfg .= '$op_no_display_name = true;
      ';
        } else {
            $cfg .= '$op_no_display_name = false;
      ';
        }
        if (!empty($data['op_create_account_unchecked'])) {
            $cfg .= '$op_create_account_unchecked = true;
      ';
        } else {
            $cfg .= '$op_create_account_unchecked = false;
      ';
        }
        /*	  
          	  if (!empty($data['tos_itemid']))
            $cfg .= ' $tos_itemid = "'.$data['tos_itemid'].'"; '; 
        */
        if (!empty($data['product_price_display'])) {
            $cfg .= ' $product_price_display = "' . $data['product_price_display'] . '";' . "\n";
        }
        if (!empty($data['subtotal_price_display'])) {
            $cfg .= ' $subtotal_price_display = "' . $data['subtotal_price_display'] . '";' . "\n";
        }
        if (!empty($data['opc_usmode'])) {
            $cfg .= ' $opc_usmode = true; ';
        } else {
            $cfg .= ' $opc_usmode = false; ';
        }
        if (!empty($data['full_tos_logged'])) {
            $cfg .= ' $full_tos_logged = true; ';
        } else {
            $cfg .= ' $full_tos_logged = false; ';
        }
        if (!empty($data['tos_scrollable'])) {
            $cfg .= ' $tos_scrollable = true; ';
        } else {
            $cfg .= ' $tos_scrollable = false; ';
        }
        $legal_info = VmConfig::get('oncheckout_show_legal_info', '1');
        if (!empty($data['full_tos_unlogged'])) {
            $cfg .= ' $full_tos_unlogged = true; ';
        } else {
            $cfg .= ' $full_tos_unlogged = false; ';
        }
        $tosx = VmConfig::get('agree_to_tos_onorder', '1');
        if (!empty($data['tos_logged'])) {
            $cfg .= ' $tos_logged = true; ';
        } else {
            $cfg .= ' $tos_logged = false; ';
        }
        if (!empty($data['tos_unlogged'])) {
            $cfg .= ' $tos_unlogged = true; ';
        } else {
            $cfg .= ' $tos_unlogged = false; ';
        }
        if (!empty($data['opc_email_in_bt'])) {
            $cfg .= ' $opc_email_in_bt = true; ';
        } else {
            $cfg .= ' $opc_email_in_bt = false; ';
        }
        if (!empty($data['double_email'])) {
            $cfg .= ' $double_email = true; ';
        } else {
            $cfg .= ' $double_email = false; ';
        }
        if (!empty($data['coupon_price_display'])) {
            $cfg .= ' $coupon_price_display = "' . $data['coupon_price_display'] . '";' . "\n";
        }
        if (!empty($data['other_discount_display'])) {
            $cfg .= ' $other_discount_display = "' . $data['other_discount_display'] . '";' . "\n";
        }
        if (isset($data['agreed_notchecked'])) {
            $cfg .= '$agreed_notchecked = true;
      ';
        } else {
            $cfg .= '$agreed_notchecked = false;
      ';
        }
        if ((int) $data['opc_default_shipping'] === 1) {
            $cfg .= '
	  $opc_default_shipping = 1; 
	  $op_default_shipping_zero = true;
	  $shipping_inside_choose = false; 
      ';
        } else {
            if ((int) $data['opc_default_shipping'] === 3) {
                $cfg .= ' $shipping_inside_choose = true; 
	    $opc_default_shipping = 3; 
	   ';
            } else {
                $cfg .= '
	   $op_default_shipping_zero = false;
	   $opc_default_shipping = ' . (int) $data['opc_default_shipping'] . ';
       $shipping_inside_choose = false;
	  ';
            }
        }
        if (!empty($data['never_count_tax_on_shipping'])) {
            $cfg .= '$never_count_tax_on_shipping = true;
      ';
        } else {
            $cfg .= '$never_count_tax_on_shipping = false;
      ';
        }
        if (!empty($data['save_shipping_with_tax'])) {
            $cfg .= '$save_shipping_with_tax = true;
      ';
        } else {
            $cfg .= '$save_shipping_with_tax = false;
      ';
        }
        if (isset($data['op_no_basket'])) {
            $cfg .= '$op_no_basket = true;
      ';
        } else {
            $cfg .= '$op_no_basket = false;
      ';
        }
        if (!empty($data['utm_payment'])) {
            $utm_p = (array) $data['utm_payment'];
        } else {
            $utm_p = array();
        }
        $utm_p2 = array();
        if (!empty($utm_p)) {
            foreach ($utm_p as $ku => $vu) {
                $utm_p2[(int) $ku] = (int) $vu;
            }
        }
        //$utm_p = OPCConfig::getValue('opc_config', 'utm_payments', 0, $default, false, false);
        OPCconfig::store('opc_config', 'utm_payments', 0, $utm_p2);
        if (isset($data['shipping_template'])) {
            $cfg .= '$shipping_template = true;
      ';
        } else {
            $cfg .= '$shipping_template = false;
      ';
        }
        $opclang = JRequest::getVar('opc_lang_orig', '');
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
        $currency_config = JRequest::getVar('country_currency', array());
        $aset = array();
        OPCconfig::clearConfig('currency_config');
        if (!empty($currency_config)) {
            foreach ($currency_config as $cid => $arr) {
                if (!empty($arr)) {
                    foreach ($arr as $country_id) {
                        if (!empty($aset[$country_id])) {
                            continue;
                        }
                        $aset[$country_id] = $country_id;
                        $q = 'select country_2_code from #__virtuemart_countries where virtuemart_country_id = ' . (int) $country_id . ' limit 0,1';
                        $db = JFactory::getDBO();
                        $db->setQuery($q);
                        $c2c = $db->loadResult();
                        if (!empty($c2c)) {
                            OPCconfig::store('currency_config', $c2c, 0, (int) $cid);
                        }
                    }
                }
            }
        }
        if (!empty($data['currency_plg_can_change'])) {
            OPCconfig::store('currency_config', 'can_change', 0, true);
        } else {
            OPCconfig::store('currency_config', 'can_change', 0, false);
        }
        if (!empty($data['currency_plg'])) {
            $this->setPluginEnabled('opc_currency', 'system', true);
        } else {
            $this->setPluginEnabled('opc_currency', 'system', false);
        }
        OPCconfig::store('opc_config', 'op_articleid' . $opclang, 0, $data['op_articleid']);
        OPCconfig::store('opc_config', 'adc_op_articleid' . $opclang, 0, $data['adc_op_articleid']);
        OPCconfig::store('opc_config', 'tos_itemid' . $opclang, 0, $data['tos_itemid']);
        OPCconfig::store('opc_config', 'newitemid' . $opclang, 0, $data['newitemid']);
        OPCconfig::store('opc_config', 'op_customitemidty' . $opclang, 0, $data['op_customitemidty']);
        /*
        	  if (!empty($data['op_customitemidty']))
         {
          $cfg .= '$op_customitemidty = "'.(int)trim($data['op_customitemidty']).'";
              ';
         }
        */
        /* 
        if (!empty($data['newitemid']))
         $cfg .= '$newitemid = "'.trim($data['newitemid']).'";
              ';
              else $cfg .= '$newitemid = "";
              ';
        */
        //
        /*
        	  if (!empty($data['op_articleid']))
         $cfg .= '$op_articleid = "'.$data['op_articleid'].'";
        	  ';
        	  else $cfg .= '$op_articleid = "";
        	  ';
        	  
        
        	  	  if (!empty($data['adc_op_articleid']))
         $cfg .= '$adc_op_articleid = "'.$data['adc_op_articleid'].'";
        	  ';
        	  else $cfg .= '$adc_op_articleid = "";
        	  ';
        */
        if (isset($data['op_sum_tax'])) {
            $cfg .= '$op_sum_tax = true;
      ';
        } else {
            $cfg .= '$op_sum_tax = false;
      ';
        }
        if (isset($data['op_last_field'])) {
            $cfg .= '$op_last_field = true;
      ';
        } else {
            $cfg .= '$op_last_field = false;
      ';
        }
        if (!empty($data['op_default_zip'])) {
            $cfg .= '$op_default_zip = "' . urlencode($data['op_default_zip']) . '"; 
	';
        } else {
            if ($data['op_default_zip'] === '0' || $data['op_default_zip'] === 0) {
                $cfg .= '$op_default_zip = 0; ';
            } else {
                $cfg .= '$op_default_zip = "99999";
	';
            }
        }
        if (!empty($data['op_numrelated']) && is_numeric($data['op_numrelated'])) {
            $cfg .= '$op_numrelated = "' . $data['op_numrelated'] . '"; 
      ';
        } else {
            $cfg .= '$op_numrelated = false;
      ';
        }
        $cfg .= '
// auto config by template
$cut_login = false;
      ';
        if (isset($data['op_delay_ship'])) {
            $cfg .= '$op_delay_ship = true;
      ';
        } else {
            $cfg .= '$op_delay_ship = false;
      ';
        }
        if (isset($data['op_loader'])) {
            $cfg .= '$op_loader = true;
      ';
        } else {
            $cfg .= '$op_loader = false;
      ';
        }
        if (isset($data['op_usernameisemail'])) {
            $cfg .= '$op_usernameisemail = true;
      ';
        } else {
            $cfg .= '$op_usernameisemail = false;
      ';
        }
        if (isset($data['no_continue_link_bottom'])) {
            $cfg .= '$no_continue_link_bottom = true;
      ';
        } else {
            $cfg .= '$no_continue_link_bottom = false;
      ';
        }
        if (isset($data['op_default_state'])) {
            $cfg .= '$op_default_state = true;
      ';
        } else {
            $cfg .= '$op_default_state = false;
      ';
        }
        if (isset($data['list_userfields_override'])) {
            $cfg .= '$list_userfields_override = true;
      ';
        } else {
            $cfg .= '$list_userfields_override = false;
      ';
        }
        if (isset($data['no_jscheck'])) {
            $cfg .= '$no_jscheck = true;
      ';
        } else {
            $cfg .= '$no_jscheck = true;
      ';
        }
        if (isset($data['op_dontloadajax'])) {
            $cfg .= '$op_dontloadajax = true;
      		   $no_jscheck = true;
      ';
        } else {
            $cfg .= '$op_dontloadajax = false;
      ';
        }
        if (isset($data['shipping_error_override'])) {
            $serr = urlencode($data['shipping_error_override']);
            $cfg .= '$shipping_error_override = "' . $serr . '";
      ';
        } else {
            $cfg .= '$shipping_error_override = "";
      ';
        }
        if (isset($data['op_zero_weight_override'])) {
            $cfg .= '$op_zero_weight_override = true;
      ';
        } else {
            $cfg .= '$op_zero_weight_override = false;
      ';
        }
        if (isset($data['email_after'])) {
            $cfg .= '$email_after = true;
      ';
        } else {
            $cfg .= '$email_after = false;
      ';
        }
        if (isset($data['override_basket'])) {
            $cfg .= '$override_basket = true;
      ';
        } else {
            $cfg .= '$override_basket = false;
      ';
        }
        if ($data['selected_template'] != 'default') {
            $data['selected_template'] = JFile::makeSafe($data['selected_template']);
            $cfg .= '$selected_template = "' . $data['selected_template'] . '";
	    if (empty($is_admin))
		{
		$selected_template_override = JRequest::getVar(\'opc_theme\', \'\'); 
		if (!empty($selected_template_override))
		{
		$test = str_replace(\'_\', \'\', $selected_template_override); 
		if (ctype_alnum($test))
		 {
		   $selected_template = $selected_template_override; 
		 }
		}
		}
		
      ';
        } else {
            $cfg .= '$selected_template = ""; 
       ';
        }
        if (!empty($data['mobile_template'])) {
            $data['mobile_template'] = JFile::makeSafe($data['mobile_template']);
            $cfg .= ' 
  $is_mobile = false; 
  $mobile_template = "' . $data['mobile_template'] . '";
  if (empty($is_admin))
  if (empty($selected_template_override))
  {
$app = JFactory::getApplication(); 
$jtouch = $app->getUserStateFromRequest(\'jtpl\', \'jtpl\', -1, \'int\');
if (($jtouch > 0) || (defined(\'OPC_DETECTED_DEVICE\') && ((constant(\'OPC_DETECTED_DEVICE\')==\'MOBILE\') || ((constant(\'OPC_DETECTED_DEVICE\')==\'TABLET\')))))
 {
   $is_mobile = true; 
   $selected_template = $mobile_template; 
 }
 
 
 }
  
  ';
        }
        if (!isset($data['adwords_timeout'])) {
            $data['adwords_timeout'] = 4;
        }
        $op_timeout = (int) $data['adwords_timeout'];
        $cfg .= ' $adwords_timeout = ' . $op_timeout . '; ';
        if (isset($data['dont_show_inclship'])) {
            $cfg .= '$dont_show_inclship = true;
      ';
        } else {
            $cfg .= '$dont_show_inclship = false;
      ';
        }
        if (isset($data['no_continue_link'])) {
            $cfg .= '$no_continue_link = true;
      ';
        } else {
            $cfg .= '$no_continue_link = false;
      ';
        }
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'models' . DS . 'tracking.php';
        $modelT = new JModelTracking();
        $modelT->setEnabled();
        // removed in 2.0.207
        /*
        	 if (false)
        if (isset($data['adwords_enabled_0']) && (!empty($_POST['adwords_code_0'])))
        {
          jimport('joomla.filesystem.folder');
          jimport('joomla.filesystem.file');
        	
         $code = JRequest::getVar('adwords_code_0', '', 'post', 'string', JREQUEST_ALLOWRAW); // $_POST['adwords_code_0']; $code = $_POST['adwords_code_0'];
          if (JFile::write(JPATH_ROOT.DS.'components'.DS.'com_onepage'.DS.'trackers'.DS.'body.html', $code) === false)
          {
               $msg .= 'Cannot write to: '.JPATH_ROOT.DS.'components'.DS.'com_onepage'.DS.'trackers'.DS.'body.html<br />';
          }
          else
          {
          $cfg .= '
          $adwords_name = array(); $adwords_code = array(); $adwords_amount = array();
        	$adwords_name[0] = "body.html";
        	
              
         		$adwords_amount[0] = "'.$data['adwords_amount_0'].'";
              $adwords_enabled[0] = true;
         	';
        }
        }
        else
        {
         $cfg .= '
         	$adwords_name = array(); $adwords_code = array(); $adwords_amount = array();
         	$adwords_name[0] = "body.html";
         	$adwords_amount[0] = "'.$data['adwords_amount_0'].'";
         	';
        	
        	jimport('joomla.filesystem.file');
        	$code = ""; 
        	if (JFile::write(JPATH_ROOT.DS.'components'.DS.'com_onepage'.DS.'trackers'.DS.'body.html', $code) === false)
          {
               $msg .= 'Cannot write to: '.JPATH_ROOT.DS.'components'.DS.'com_onepage'.DS.'trackers'.DS.'body.html';
          }
        	
        }
        */
        if (isset($data['no_login_in_template'])) {
            $cfg .= '$no_login_in_template = true;
      ';
        } else {
            $cfg .= '$no_login_in_template = false;
      ';
        }
        $cfg . '


/* Following variables are to change shipping or payment to select boxes
*/
';
        if (isset($data['shipping_inside'])) {
            $cfg .= '$shipping_inside = true;
      ';
        } else {
            $cfg .= '$shipping_inside = false;
      ';
        }
        if (isset($data['payment_inside'])) {
            $cfg .= '$payment_inside = true;
      ';
        } else {
            $cfg .= '$payment_inside = false;
      ';
        }
        if (isset($data['payment_saveccv'])) {
            $cfg .= '$payment_saveccv = true;
      ';
        } else {
            $cfg .= '$payment_saveccv = false;
      ';
        }
        if (isset($data['payment_advanced'])) {
            $cfg .= '$payment_advanced = true;
      ';
        } else {
            $cfg .= '$payment_advanced = false;
      ';
        }
        if (isset($data['fix_encoding'])) {
            $cfg .= '$fix_encoding = true;
      ';
        } else {
            $cfg .= '$fix_encoding = false;
      ';
        }
        if (isset($data['fix_encoding_utf8'])) {
            $cfg .= '$fix_encoding_utf8 = true;
$fix_encoding = false;
      ';
        } else {
            $cfg .= '$fix_encoding_utf8 = false;
      ';
        }
        if (isset($data['shipping_inside_basket'])) {
            $cfg .= '$shipping_inside_basket = true;
      ';
        } else {
            $cfg .= '$shipping_inside_basket = false;
      ';
        }
        if (isset($data['payment_inside_basket'])) {
            $cfg .= '$payment_inside_basket = true;
      ';
        } else {
            $cfg .= '$payment_inside_basket = false;
      ';
        }
        if (isset($data['email_only_pok'])) {
            $cfg .= '$email_only_pok = true;
      ';
        } else {
            $cfg .= '$email_only_pok = false;
      ';
        }
        if (!empty($data['no_taxes_show'])) {
            $cfg .= '$no_taxes_show = true;
      ';
        } else {
            $cfg .= '$no_taxes_show = false;
      ';
        }
        if (!empty($data['use_order_tax'])) {
            $cfg .= '$use_order_tax = true;
      ';
        } else {
            $cfg .= '$use_order_tax = false;
      ';
        }
        if (isset($data['no_taxes'])) {
            $cfg .= '$no_taxes = true;
      ';
        } else {
            $cfg .= '$no_taxes = false;
      ';
        }
        if (isset($data['never_show_total'])) {
            $cfg .= '$never_show_total = true;
      ';
        } else {
            $cfg .= '$never_show_total = false;
      ';
        }
        if (isset($data['email_dontoverride'])) {
            $cfg .= '$email_dontoverride = true;
      ';
        } else {
            $cfg .= '$email_dontoverride = false;
      ';
        }
        if (isset($data['allow_duplicit'])) {
            $cfg .= '$allow_duplicit = true;
      ';
        } else {
            $cfg .= '$allow_duplicit = false;
      ';
        }
        if (isset($data['show_only_total'])) {
            $cfg .= '$show_only_total = true;
      ';
        } else {
            $cfg .= '$show_only_total = false;
      ';
        }
        if (isset($data['show_andrea_view'])) {
            $cfg .= '$show_andrea_view = true;
      ';
        } else {
            $cfg .= '$show_andrea_view = false;
      ';
        }
        if (isset($data['always_show_tax'])) {
            $cfg .= '$always_show_tax = true;
';
        } else {
            $cfg .= '$always_show_tax = false;
';
        }
        if (isset($data['always_show_all'])) {
            $cfg .= '$always_show_all = true;
';
        } else {
            $cfg .= '$always_show_all = false;
';
        }
        if (isset($data['add_tax'])) {
            $cfg .= '$add_tax = true;
      ';
        } else {
            $cfg .= '$add_tax = false;
      ';
        }
        if (isset($data['add_tax_to_shipping_problem'])) {
            $cfg .= '$add_tax_to_shipping_problem = true;
      ';
        } else {
            $cfg .= '$add_tax_to_shipping_problem = false;
      ';
        }
        if (isset($data['add_tax_to_shipping'])) {
            $cfg .= '$add_tax_to_shipping = true;
      ';
        } else {
            $cfg .= '$add_tax_to_shipping = false;
      ';
        }
        if (isset($data['custom_tax_rate'])) {
            $cfg .= '$custom_tax_rate = "' . addslashes($data['custom_tax_rate']) . '"; 
      ';
        } else {
            $cfg .= '$custom_tax_rate = 0;
      ';
        }
        if (isset($data['opc_auto_coupon'])) {
            $cfg .= '$opc_auto_coupon = "' . addslashes($data['opc_auto_coupon']) . '"; 
      ';
        } else {
            $cfg .= '$opc_auto_coupon = \'\';
      ';
        }
        if (isset($data['no_decimals'])) {
            $cfg .= '$no_decimals = true;';
        } else {
            $cfg .= '$no_decimals = false;';
        }
        if (isset($data['curr_after'])) {
            $cfg .= '$curr_after = true;';
        } else {
            $cfg .= '$curr_after = false;';
        }
        //
        if (isset($data['load_min_bootstrap'])) {
            $cfg .= '$load_min_bootstrap = true;';
        } else {
            $cfg .= '$load_min_bootstrap = false;';
        }
        $cfg .= "\n/*\nSet this to true to unlog (from Joomla) all shoppers after purchase\n*/\n";
        if (isset($data['unlog_all_shoppers'])) {
            $cfg .= '$unlog_all_shoppers = true;
		$no_login_in_template = true; 
';
        } else {
            $cfg .= '$unlog_all_shoppers = false;
';
        }
        // vat_input_id, eu_vat_always_zero, move_vat_shopper_group, zerotax_shopper_group
        if (!empty($data['vat_input_id'])) {
            $cfg .= '$vat_input_id = "' . $data['vat_input_id'] . '"; ';
        } else {
            $cfg .= '$vat_input_id = ""; ';
        }
        if (!empty($data['eu_vat_always_zero'])) {
            $cfg .= '$eu_vat_always_zero = "' . $data['eu_vat_always_zero'] . '"; ';
        } else {
            $cfg .= '$eu_vat_always_zero = ""; ';
        }
        if (empty($data['vat_except'])) {
            $data['vat_except'] = '';
        }
        $te = strtoupper($data['vat_except']);
        $eu = array('AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK');
        if (!empty($data['vat_except'])) {
            if (!in_array($te, $eu)) {
                $msg .= 'Country code is not valid for EU ! Code used:' . $data['vat_except'] . '<br />';
                $msg .= "These are valid codes : 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK' without apostrophies <br />";
            }
            $cfg .= '$vat_except = "' . $data['vat_except'] . '"; ';
        } else {
            $cfg .= '$vat_except = ""; ';
        }
        if (!empty($data['move_vat_shopper_group'])) {
            $cfg .= '$move_vat_shopper_group = "' . $data['move_vat_shopper_group'] . '"; ';
        } else {
            $cfg .= '$move_vat_shopper_group = ""; ';
        }
        if (!empty($data['zerotax_shopper_group'])) {
            $str = '';
            foreach ($data['zerotax_shopper_group'] as $g) {
                if (!empty($str)) {
                    $str .= ',' . $g . '';
                } else {
                    $str = "" . $g . "";
                }
            }
            $cfg .= ' $zerotax_shopper_group = array(' . $str . '); ';
        } else {
            $cfg .= ' $zerotax_shopper_group = array(); ';
        }
        $cfg .= " \n/* set this to true if you don't accept other than valid EU VAT id */\n";
        if (!empty($data['must_have_valid_vat'])) {
            $cfg .= '$must_have_valid_vat = true; ';
        } else {
            $cfg .= '$must_have_valid_vat = false; ';
        }
        $cfg .= "\n/*\n* Set this to true to unlog (from Joomla) all shoppers after purchase\n*/\n";
        if (isset($data['unlog_all_shoppers'])) {
            $cfg .= ' $unlog_all_shoppers = true;
      ';
        } else {
            $cfg .= ' $unlog_all_shoppers = false;
     ';
        }
        $cfg .= "\n/* This will disable positive messages on Thank You page in system info box */\n\n";
        $cfg .= "\n/* please check your source code of your country list in your checkout and get exact virtuemart code for your country\n* all incompatible shipping methods will be hiddin until customer choses other country\n* this will also be preselected in registration and shipping forms\n* Your shipping method cannot have 0 index ! Otherwise it will not be set as default\n*/     \n";
        if (isset($data['default_country'])) {
            $cfg .= ' $default_shipping_country = "' . $data['default_country'] . '";
      ';
        } else {
            $cfg .= ' $default_shipping_country = "";
     ';
        }
        /*
        $cfg .= '
        if (!defined("DEFAULT_COUNTRY"))
        {
         if (file_exists(JPATH_SITE.DS."administrator".DS."components".DS."com_geolocator".DS."assets".DS."helper.php"))
         {
          require_once(JPATH_SITE.DS."administrator".DS."components".DS."com_geolocator".DS."assets".DS."helper.php"); 
          if (class_exists("geoHelper"))
           {
             $country_2_code = geoHelper::getCountry2Code(""); 
        	 if (!empty($country_2_code))
        	 {
        	 $db= JFactory::getDBO(); 
        	 $db->setQuery("select virtuemart_country_id from #__virtuemart_countries where country_2_code = \'".$country_2_code."\' "); 
        	 $r = $db->loadResult(); 
        	 if (!empty($r)) 
        	 $default_shipping_country = $r; 
        	 }
             //$default_shipping_country = 
           }
         }
          define("DEFAULT_COUNTRY", $default_shipping_country); 
         }
         else
         {
          $default_shipping_country = DEFAULT_COUNTRY; 
         
         }
        ';  
        */
        $cfg .= "\n/* since VM 1.1.5 there is paypal new api which can be clicked on image instead of using checkout process\n* therefore we can hide it from payments\n* These payments will be hidden all the time\n* example:  " . '$payments_to_hide = "4,3,5,2";
*/
';
        $cfg .= "\n/* default payment option id\n* leave commented or 0 to let VM decide\n*/\n";
        $pd = $data['default_payment'];
        if (!isset($data['default_payment']) || $pd == 'default') {
            $pd = '""';
        }
        $cfg .= '$payment_default = \'' . $pd . '\';
	';
        $cfg .= "\n/* turns on google analytics tracking, set to false if you don't use it */\n";
        /*
        	if ($data['g_analytics']=='1')
        	{
        	  $cfg .= ' $g_analytics = true;
        ';
        	}
        	else 
        	  $cfg .= ' $g_analytics = false;
        ';
        */
        $cfg .= "\n/* set this to false if you don't want to show full TOS\n* if you set show_full_tos, set this variable to one of theses:\n* use one of these values:\n* 'shop.tos' to read tos from your VirtueMart configuration\n* '25' if set to number it will search for article with this ID, extra lines will be removed automatically\n* both will be shown without any formatting\n*/\n";
        /* disabled, now differenciated between logged and unlogged within the loader file which is further sent to the template
         	if (isset($data['show_full_tos']))
         	{
         	  $cfg .= ' $show_full_tos = true; 
        ';
         	} else  	  $cfg .= ' $show_full_tos = false; 
        ';
        */
        //tos_config
        $opclang = JRequest::getVar('opc_lang_orig', '');
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
        OPCconfig::store('opc_config', 'tos_config' . $opclang, 0, $data['tos_config']);
        /*
        $t = $data['tos_config'];
        $t = trim(strtolower($t));
        $cfg .= ' $tos_config = "'.$t.'"; 
        ';
        */
        /*
         	if (isset($data['op_show_others']))
         	{
         	  $cfg .= ' $op_show_others = true; 
        ';
         	} else  	  $cfg .= ' $op_show_others = false; 
        
        
        
        ';
        */
        if (isset($data['op_fix_payment_vat'])) {
            $cfg .= ' $op_fix_payment_vat = true; 
';
        } else {
            $cfg .= ' $op_fix_payment_vat = false; 
';
        }
        if (isset($data['op_free_shipping'])) {
            $cfg .= ' $op_free_shipping = true; 
';
        } else {
            $cfg .= ' $op_free_shipping = false; 
';
        }
        $cfg .= "\n/* change this variable to your real css path of '>> Proceed to Checkout'\n* let's hide 'Proceed to checkout' by CSS\n* if it doesn't work, change css path accordingly, i recommend Firefox Firebug to get the path\n* but this works for most templates, but if you see 'Proceed to checkout' link, contact me at stan@rupostel.sk\n* for rt_mynxx_j15 template use '.cart-checkout-bar {display: none; }'\n*/\n";
        $cfg .= '
$payment_info = array();
$payment_button = array();
$default_country_array = array();
';
        $cfg .= "\n" . ' /* URLs fetched after checkout encoded by base64_encode */' . "\n";
        $cfg .= ' $curl_url = array(';
        $arr = array();
        foreach ($data as $key => $val) {
            if (strpos($key, 'curl_url_') !== false) {
                if (!empty($val)) {
                    $arr[] = "'" . base64_encode($val) . "'";
                }
            }
        }
        $arrt = implode(',', $arr);
        if (empty($arr)) {
            $arrt = '';
        }
        $cfg .= $arrt . ');' . "\n";
        $payment_info = array();
        $payment_button = array();
        // needs update:
        $langs = array();
        foreach ($langs as $l) {
            $langcfg[$l] = "";
        }
        $exts = $this->getExt();
        if (!class_exists('JFile')) {
            require JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'filesystem' . DIRECTORY_SEPARATOR . 'file.php';
        }
        if (!class_exists('JFolder')) {
            require JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'filesystem' . DIRECTORY_SEPARATOR . 'folder.php';
        }
        /*
        if (!empty($exts))
        foreach($exts as $ext)
        {
           if (isset($data['opext_'.$ext['name']]))
           {
             //if (!JFile::write($ext['path'].DS.'enabled.html')) 
               if (JFile::write($ext['path'].DS.'enabled.html', ' ')===false)
               {
                 $msg .= 'Cannot write to: '.$ext['path'].DS.'<br />';
               }
             
           }
           else 
            {
            if (file_exists($ext['path'].DS.'enabled.html'))
            {
              if (JFile::delete($ext['path'].DS.'enabled.html')===false)
              {
               $msg .= 'Delete file \'enabled.html\' manually: '.$ext['path'].DS.'enabled.html<br />';
              }
            }
            //else $msg .= 'Cannot find: '.$ext['path'].DS.'enabled.';
            }
           
        }
        */
        if (!class_exists('JFile')) {
            require JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'filesystem' . DIRECTORY_SEPARATOR . 'file.php';
        }
        if (!class_exists('JFolder')) {
            require JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'filesystem' . DIRECTORY_SEPARATOR . 'folder.php';
        }
        foreach ($data as $k => $d) {
            /*
             if (strpos($k, 'payment_contentid_')!==false)
             {
               $pid = str_replace('payment_contentid_', '', $k); 
               $ofolder = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'classes'.DS.'payment'.DS.'onepage';
               $filename = $ofolder.DS.$pid.'.part.html';
               if (is_numeric($pid))
               {
                $dt = JRequest::getVar('payment_content_'.$pid, '', 'post', 'string', JREQUEST_ALLOWRAW);
                $dt = str_replace('<p>', '', $dt); 
                $dt = str_replace('</p>', '<br />', $dt);
                if (!empty($dt))
                if (JFile::write($filename, $dt)===false)
                {
                 $msg .= 'Cannot save payment content to: '.$filename.'<br />';
                }
               }
             }
            */
            // ok we will add a default country for a lang
            if (strpos($k, 'op_lang_code_') !== false) {
                $id = str_replace('op_lang_code_', '', $k);
                if (!empty($data[$k]) && !empty($data['op_selc_' . $id])) {
                    $cfg .= '
$default_country_array["' . $data[$k] . '"] = "' . $data['op_selc_' . $id] . '"; 
';
                }
            }
            if (strpos($k, 'op_group_') !== false) {
                $id = str_replace('op_group_', '', $k);
                if (!empty($data[$k]) && !empty($data['op_group_' . $id])) {
                    if (!empty($data['op_lang_code2_' . $id])) {
                        $cfg .= '
$lang_shopper_group["' . $data['op_lang_code2_' . $id] . '"] = "' . $data['op_group_' . $id] . '"; 
';
                    }
                }
            }
            if (strpos($k, 'op_selc2_') !== false) {
                $id = str_replace('op_selc2_', '', $k);
                if (isset($data[$k]) && !empty($data['op_group_ip_' . $id])) {
                    if (isset($data['op_selc2_' . $id])) {
                        $cfg .= '
$lang_shopper_group_ip["' . $data['op_selc2_' . $id] . '"] = "' . $data['op_group_ip_' . $id] . '"; 
';
                    }
                }
            }
            if (strpos($k, 'hidepsid_') !== false) {
                $ida = explode('_', $k, 2);
                $ida = $ida[1];
                $id = $data[$k];
                //$id = $d;
                if ($id != 'del' && count($data["hidep_" . $ida]) > 0) {
                    $def = $data["hidepdef_" . $ida];
                    $cfg .= ' $hidep["' . $id . '"] = "';
                    if (isset($data["hidep_" . $ida])) {
                        foreach ($data["hidep_" . $ida] as $h) {
                            $cfg .= $h . '/' . $def . ',';
                        }
                    } else {
                    }
                    $cfg .= '";
';
                }
            }
            if (strpos($k, 'ONEPAGE_PAYMENT_EXTRA_INFO') !== false) {
                $arr = explode('_', $k);
                $lang = $arr[1];
                $id = $arr[count($arr) - 1];
                if (!isset($payment_info[$id])) {
                    $payment_info[$id] = $id;
                    $cfg .= '$payment_info["' . $id . '"] = JText::_("COM_ONEPAGE_PAYMENT_EXTRA_INFO_' . $id . '"); 
';
                }
            }
            if (strpos($k, 'ONEPAGE_PAYMENT_EXTRA_INFO_BUTTON') !== false) {
                $arr = explode('_', $k);
                $lang = $arr[1];
                $id = $arr[count($arr) - 1];
                if (!isset($payment_button[$id])) {
                    $payment_button[$id] = $id;
                    $cfg .= '$payment_button["' . $id . '"] = JText::_("COM_ONEPAGE_PAYMENT_EXTRA_INFO_BUTTON_' . $id . '"); 
';
                }
            }
            if (strpos($k, 'tid_') !== false && strpos($k, 'payment_contentid') === false) {
                /* we have a standard variable:
                	  tid_special_, tid_ai_, tid_num_, tid_back_,  tid_forward_
                	  tid_nummax_, tid_itemmax_
                	  tid_type_
                	  */
                if (!defined($k)) {
                    $this->setTemplateSetting($k, $data[$k]);
                    //echo 'template setting: '.$k.'value: '.$data[$k];
                    define($k, $data[$k]);
                }
                $a = explode('_', $k);
                if (count($a) == 3) {
                    $tid = $a[2];
                    $checkboxes = array('tid_special_', 'tid_ai_', 'tid_num_', 'tid_forward_', 'tid_back_', 'tid_enabled_', 'tid_foreign_', 'tid_email_', 'tid_autocreate_');
                    foreach ($checkboxes as $ch) {
                        if (!isset($data[$ch . $tid]) && !defined($ch . $tid)) {
                            $this->setTemplateSetting($ch . $tid, 0);
                            define($ch . $tid, '0');
                            //echo ':'.$ch.$tid.' val: 0';
                        }
                    }
                }
            }
        }
        $cfg .= '
if (defined(\'OPC_THEME_OVERRIDE\') && (constant(\'OPC_THEME_OVERRIDE\'))) include(OPC_THEME_OVERRIDE); 
else
if (!empty($selected_template) && (file_exists(JPATH_ROOT.DS."components".DS."com_onepage".DS."themes".DS.$selected_template.DS."overrides".DS."onepage.cfg.php")))
{
  define(\'OPC_THEME_OVERRIDE\', JPATH_ROOT.DS."components".DS."com_onepage".DS."themes".DS.$selected_template.DS."overrides".DS."onepage.cfg.php"); 
  include(JPATH_ROOT.DS."components".DS."com_onepage".DS."themes".DS.$selected_template.DS."overrides".DS."onepage.cfg.php");
 
}
else
if (!defined(\'OPC_THEME_OVERRIDE\'))
define(\'OPC_THEME_OVERRIDE\', false); 


';
        $conf_file = JPATH_ROOT . DS . "components" . DS . "com_onepage" . DS . "config" . DS . "onepage.cfg.php";
        $ret = true;
        if (!class_exists('JFile')) {
            require JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'filesystem' . DIRECTORY_SEPARATOR . 'file.php';
        }
        if (!class_exists('JFolder')) {
            require JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'filesystem' . DIRECTORY_SEPARATOR . 'folder.php';
        }
        if (JFile::write($conf_file, $cfg) === false) {
            $msg .= JText::_('COM_ONEPAGE_ACCESS_DENIED_CONFIG') . ' ' . $conf_file . '<br />';
            $ret = false;
            // lets test if it is php valid
        } else {
            //unset($disable_onepage);
            if (eval('?>' . file_get_contents($conf_file)) === false) {
                $msg .= JText::_('COM_ONEPAGE_CONFIG_VALIDATION_ERROR') . ' <br />';
                $ret = false;
                // we have a big problem here, generated file is not valid
                if (!JFile::copy(JPATH_ROOT . DS . "components" . DS . "com_onepage" . DS . "config" . DS . "onepage.cfg.php", JPATH_ROOT . DS . "components" . DS . "com_onepage" . DS . "config" . DS . "onepage.invalid.cfg.php")) {
                }
                if (!JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'default' . DS . 'onepage.cfg.php', JPATH_ROOT . DS . "components" . DS . "com_onepage" . DS . "config" . DS . "onepage.cfg.php")) {
                    $msg .= 'Copying of default onepage.cfg.php was not successfull <br />';
                }
            }
        }
        if (VmConfig::get('oncheckout_only_registered', 0)) {
            if (VmConfig::get('oncheckout_show_register', 0)) {
                define('VM_REGISTRATION_TYPE', 'NORMAL_REGISTRATION');
            } else {
                define('VM_REGISTRATION_TYPE', 'SILENT_REGISTRATION');
            }
        } else {
            if (VmConfig::get('oncheckout_show_register', 0)) {
                define('VM_REGISTRATION_TYPE', 'OPTIONAL_REGISTRATION');
            } else {
                define('VM_REGISTRATION_TYPE', 'NO_REGISTRATION');
            }
        }
        $reg_type = $data['opc_registraton_type'];
        $set = array();
        switch ($reg_type) {
            case 'NO_REGISTRATION':
                $set['oncheckout_only_registered'] = 0;
                $set['oncheckout_show_register'] = 0;
                break;
            case 'OPTIONAL_REGISTRATION':
                $set['oncheckout_only_registered'] = 0;
                $set['oncheckout_show_register'] = 1;
                break;
            case 'SILENT_REGISTRATION':
                $set['oncheckout_only_registered'] = 1;
                $set['oncheckout_show_register'] = 0;
                break;
            default:
                $set['oncheckout_only_registered'] = 1;
                $set['oncheckout_show_register'] = 1;
                break;
        }
        if (!empty($data['use_ssl'])) {
            $set['useSSL'] = 1;
        } else {
            $set['useSSL'] = 0;
        }
        if (!empty($data['full_tos_unlogged'])) {
            $set['oncheckout_show_legal_info'] = 1;
        } else {
            $set['oncheckout_show_legal_info'] = 0;
        }
        if (!empty($data['tos_logged']) && !empty($data['tos_unlogged'])) {
            $set['agree_to_tos_onorder'] = 1;
        } else {
            $set['agree_to_tos_onorder'] = 0;
        }
        if (!empty($data['op_disable_shipping'])) {
            $set['automatic_shipment'] = 0;
        }
        $this->updateVmConfig($set);
        /*
        require_once(JPATH_SITE.DS.'components'.DS.'com_onepage'.DS.'helpers'.DS.'mini.php'); 
        
        $configm = OPCmini::getModel('Config'); 
        
            $c = VmConfig::get('coupons_enable', true); 
        VmConfig::set('coupons_enable', 10); 
        
        
        
        $test = VmConfig::get('coupons_enable'); 
        VmConfig::set('coupons_enable', $c); 
        
        
        if ($test != 10)
         {
           $isadmin =false; 
         }
         else $isadmin = true; 
         
         if ((method_exists('VmConfig', 'isAtLeastVersion')) || (!$isadmin))
         {
           $msg .= 'Notice: You are running an old version of Virtuemart or you are not logged in as shop Administrator. Some Virtuemart settings cannot be updated with OPC. Please update TOS, registration type, SSL in your virtuemart configuration. (oncheckout_show_register, oncheckout_only_registered, agree_to_tos_onorder, automatic_shipment, oncheckout_show_legal_info, useSSL)  '; 
           
           $isadmin = false; 
         }
        if ($isadmin)
        if (!$configm->store($set))
        {
        	//$msg .= 'Error saving virtuemart configuration'; 
        }
        
        VmConfig::loadConfig(true); 
        */
        if (empty($_SESSION['onepage_err'])) {
            $_SESSION['onepage_err'] = serialize($msg);
        } else {
            $_SESSION['onepage_err'] = serialize($msg . unserialize($_SESSION['onepage_err']));
        }
        return $ret;
    }
コード例 #4
0
ファイル: opc.php プロジェクト: aldegtyarev/stelsvelo
 function opc()
 {
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     require_once JPATH_OPC . DS . 'helpers' . DS . 'loader.php';
     OPCloader::$debugMsg = '';
     //mobile handling:
     if (!defined('OPC_DETECTED_DEVICE')) {
         if (class_exists('OPCplugin')) {
             OPCplugin::detectMobile();
         }
     }
     if (!class_exists('OPCLang')) {
         require JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php';
     }
     OPCLang::loadLang();
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'shoppergroups.php';
     //$this->setShopperGroups();
     $userModel = OPCmini::getModel('user');
     $cmd = JRequest::getVar('cmd', '');
     if ($cmd === 'checkbitvat') {
         $checkvat = $this->checkBitVat();
     }
     if ($cmd === 'checkvatopc') {
         $checkvat = $this->checkOPCVat();
     }
     OPCShopperGroups::setShopperGroupsController();
     if (method_exists($userModel, 'getCurrentUser')) {
         $user = $userModel->getCurrentUser();
         self::$shopper_groups = $user->shopper_groups;
         if (!empty($user->virtuemart_shipmentmethod_id)) {
             $user->virtuemart_shipmentmethod_id = 0;
             $user->virtuemart_paymentmethod_id = 0;
         }
     }
     $session = JFactory::getSession();
     $b = $session->set('eurobnk', null, 'vm');
     if (empty($euvat_shopper_group)) {
         jimport('joomla.html.parameter');
         if (class_exists('plgSystemBit_vm_change_shoppergroup')) {
             $session = JFactory::getSession();
             $sg = $session->get('vm_shoppergroups_add', array(), 'vm');
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('system', 'plgSystemBit_vm_change_shoppergroup', true, $dispatcher);
             // very important
             $document = JFactory::getDocument();
             JRequest::setVar('format_override', 'html');
             $_REQUEST['view'] = 'cart';
             $_REQUEST['option'] = 'com_virtuemart';
             $doctype = $document->getType();
             $dispatcher->trigger('onAfterRender');
             JRequest::setVar('format_override', 'raw');
             $sg = $session->get('vm_shoppergroups_add', array(), 'vm');
         }
     }
     JResponse::setBody('');
     // security:
     JRequest::setVar('virtuemart_shoppergroup_id', null, 'post');
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig(true);
     // since vm2.0.21a we need to load the language files here
     if (method_exists('VmConfig', 'loadJLang')) {
         $lang = JFactory::getLanguage();
         $extension = 'com_virtuemart';
         $lang->load($extension);
         //  when AJAX it needs to be loaded manually here >> in case you are outside virtuemart !!!
         VmConfig::loadJLang('com_virtuemart_orders', true);
         VmConfig::loadJLang('com_virtuemart_shoppers', true);
     }
     /// load shipping here
     $vars = JRequest::get('post');
     // custom tag test
     $cmd = JRequest::getVar('cmd', 'get_shipping');
     $doc = JFactory::getDocument();
     $type = get_class($doc);
     if ($type == 'JDocumentRAW') {
         //C:\Documents and Settings\Rupos\Local Settings\Temp\scp02371\srv\www\clients\client1\web90\web\vm2\components\com_onepage\overrides\
         //require_once(JPATH_SITE.DS.'components'.DS.'com_onepage'.DS.'overrides'.DS.'opchtml.php');
         //JFactory::$instance = new JDocumentOpchtml();
         //JFactory::$document = new JDocumentOpchtml();
     }
     /*
     	$doc->addCustomTag = create_function('$string', 'return;');  
     	$doc->addCustomTag( '<!-- This is a comment. -->' );
     */
     $c = JRequest::getVar('virtuemart_currency_id', 0);
     JRequest::setVar('virtuemart_currency_id', (int) JRequest::getVar('virtuemart_currency_id'));
     /* to test the currency: */
     $mainframe = Jfactory::getApplication();
     $virtuemart_currency_id = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id'));
     // end custom tag test
     $view = $this->getView('cart', 'html');
     $cmd = JRequest::getCmd('cmd', 'get_shipping');
     $return = array();
     $return['cmd'] = $cmd;
     if (!empty($checkvat)) {
         $return['checkvat'] = $checkvat;
     }
     $db = JFactory::getDBO();
     $username = JRequest::getVar('username', '');
     $user = JFactory::getUser();
     $un = $user->get('username');
     if ($un == $username) {
         // do not complain if entering the same username of already registered
         $return['username_exists'] = false;
     } else {
         if (!empty($username)) {
             $q = "select username from #__users where username = '******' limit 0,1";
             $db->setQuery($q);
             $r = $db->loadResult();
             if (!empty($r)) {
                 $return['username_exists'] = true;
             } else {
                 $return['username_exists'] = false;
             }
         }
     }
     if ($cmd === 'checkemail') {
         $email = JRequest::getVar('email', '');
         $return['email'] = $email;
         $user = JFactory::getUser();
         $ue = $user->get('email');
         if ($email == $ue) {
             // do not complain if user is logged in and enters the same email address
             $return['email_exists'] = false;
         } else {
             if (!empty($email)) {
                 $q = "select email from #__users where username = '******' or email = '" . $db->getEscaped($email) . "' limit 0,1";
                 $db->setQuery($q);
                 $r = $db->loadResult();
                 if (!empty($r)) {
                     $return['email_exists'] = true;
                 } else {
                     $return['email_exists'] = false;
                 }
             }
         }
     }
     if ($cmd === 'get_klarna_address') {
         if (file_exists(JPATH_SITE . DS . 'plugins' . DS . 'vmpayment' . DS . 'klarna' . DS . 'klarna' . DS . 'api' . DS . 'klarna.php')) {
             $klarnaaddress = $this->getKlarnaAddress();
             if (!empty($klarnaaddress)) {
                 echo json_encode(array('cmd' => 'getKlarna', 'shipping' => 'opc_do_not_update', 'klarna' => $klarnaaddress, 'totals_html' => '', 'payment' => ''));
                 $mainframe = JFactory::getApplication();
                 // do not allow further processing
                 $mainframe->close();
             }
         }
     }
     if (!defined('JPATH_OPC')) {
         define('JPATH_OPC', JPATH_SITE . DS . 'components' . DS . 'com_onepage');
     }
     require_once JPATH_OPC . DS . 'helpers' . DS . 'loader.php';
     require_once JPATH_OPC . DS . 'helpers' . DS . 'ajaxhelper.php';
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $OPCloader = new OPCloader();
     $cart = VirtueMartCart::getCart(false);
     $opcsavedST = $cart->ST;
     $opcsavedBT = $cart->BT;
     $stopen = JRequest::getVar('shiptoopen', 0);
     if ($stopen === 'false') {
         $stopen = 0;
     }
     if (empty($stopen)) {
         $sa = JRequest::getVar('sa', '');
         if ($sa == 'adresaina') {
             $stopen = 1;
         }
     }
     if ($stopen) {
         $restoreST = false;
         $restoreBT = true;
     } else {
         $cart->ST = 0;
         $restoreST = true;
         $restoreBT = false;
     }
     //$virtuemart_currency_id;  = $mainframe->getUserStateFromRequest( "virtuemart_currency_id", 'virtuemart_currency_id',JRequest::getInt('virtuemart_currency_id') );
     $cart->paymentCurrency = $virtuemart_currency_id;
     if (defined('VM_VERSION') && VM_VERSION >= 3) {
         if (method_exists($cart, 'prepareCartProducts')) {
             $cart->prepareCartProducts();
         }
     }
     if ($cmd === 'getST') {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loggedshopper.php';
         $return['sthtml'] = OPCLoggedShopper::getSTHtml($cart);
     }
     if (!isset($cart->vendorId)) {
         $cart->vendorId = 1;
     }
     if ($cmd == 'updateattributes') {
         $arr = $this->updateattributes($cart);
         if (!empty($arr)) {
             foreach ($arr as $key => $val) {
                 $return[$key] = $val;
             }
         }
     }
     if ($cmd == 'update_product') {
         if (defined('VM_VERSION') && VM_VERSION >= 3) {
             $quantity = JRequest::getVar('quantity');
             if (!is_array($quantity)) {
                 $cart_virtuemart_product_id = JRequest::getVar('cart_virtuemart_product_id');
                 $arr = array($cart_virtuemart_product_id => (int) $quantity);
                 JRequest::setVar('quantity', $arr);
                 $x = JRequest::getVar('quantity');
             }
         }
         $cart->updateProductCart();
     }
     if ($cmd == 'delete_product') {
         $cart->updateProductCart();
     }
     if ($cmd == 'removecoupon') {
         JRequest::setVar('coupon_code', '');
         $_REQUEST['coupon_code'] = $_POST['coupon_code'] = $_GET['coupon_code'] = '';
         $cart->couponCode = '';
         //$this->setCoupon($cart);
         $deletecouponmsg = true;
     }
     $cp = 0;
     if (method_exists($cart, 'prepareCartProducts')) {
         $cart->prepareCartProducts();
     }
     $cart->setCartIntoSession();
     $stopen = JRequest::getVar('shiptoopen', false);
     //if (!empty($stopen))
     if ($stopen === 'true' || $stopen === '1') {
         $stopen = true;
         $sa = JRequest::setVar('sa', 'adresaina');
     } else {
         $stopen = false;
     }
     //$this->setAddress($cart, true, $stopen);
     $this->setAddress($cart);
     $BT = $cart->BT;
     if ($stopen) {
         $this->setAddress($cart, true, $stopen);
         $cart->BT = $BT;
     } else {
         $cart->ST = 0;
     }
     //die('h');
     $this->setExtAddress($cart, false, $stopen);
     $zip = JRequest::getVar('shipto_zip');
     // IMPORTANT: this function calls shipping if Vm's automatic enabled
     if (method_exists($cart, 'prepareCartData')) {
         $cart->prepareCartData(false);
     }
     // US and Canada fix, show no tax for no state selected
     if (!isset($cart->BT['virtuemart_state_id'])) {
         $cart->BT['virtuemart_state_id'] = '';
     }
     if (!empty($cart->ST)) {
         // if the VM uses BT address instead of ST address in calculation, uncomment the following line:
         // $cart->BT = $cart->ST;   // this only applies to the display of the checkout, not actual saving of the data
         if (!isset($cart->ST['virtuemart_state_id'])) {
             $cart->ST['virtuemart_state_id'] = '';
         }
     }
     @header('Content-Type: text/html; charset=utf-8');
     @header("Cache-Control: no-cache, must-revalidate");
     // HTTP/1.1
     @header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     // Date in the past
     // run vm main controlle due to compatibilty
     JPluginHelper::importPlugin('vmextended');
     JPluginHelper::importPlugin('vmuserfield');
     $dispatcher = JDispatcher::getInstance();
     $_controller = 'cart';
     $trigger = 'onVmSiteController';
     $trigger = 'plgVmOnMainController';
     $dispatcher->trigger($trigger, array($_controller));
     // this function will reload the taxes on products per country
     // this calls api methods as well, let's disable it for now:
     $cart->virtuemart_shipmentmethod_id = 0;
     if (method_exists($cart, 'prepareCartViewData')) {
         $cart->prepareCartViewData();
     }
     if (!empty($virtuemart_currency_id)) {
         $cart->paymentCurrency = $virtuemart_currency_id;
     }
     if ($cmd == 'process_coupon') {
         $cart->couponCode = JRequest::getVar('coupon_code', '');
         $this->setCoupon($cart);
         // set coupon
     }
     $view->cart = $cart;
     $view->assignRef('cart', $cart);
     //if (($cmd != 'runpay') && ($cmd != 'refreshPayment'))
     // this influences the recalculation of the basket:
     $cmds = array('process_coupon', 'refresh-totals', 'refresh_totals', 'removecoupon', 'delete_product', 'update_product', 'checkvatopc', 'delete_product', 'update_product', 'updateattributes', 'get_shipping');
     if (empty($cmd) || in_array($cmd, $cmds) || stripos($cmd, 'shipping') !== false) {
         $shipping = $OPCloader->getShipping($view, $cart, true);
         $saved_totals = OPCloader::$totals_html;
     } else {
         $shipping = 'opc_do_not_update';
         OPCloader::$totals_html = '';
     }
     $return['shipping'] = $shipping;
     if (empty(OPCloader::$inform_html)) {
         OPCloader::$inform_html = array();
     }
     $return['inform_html'] = implode('', OPCloader::$inform_html);
     if (!empty($cart->couponCode)) {
         $db = JFactory::getDBO();
         $q = "select * from #__virtuemart_coupons where coupon_code = '" . $db->getEscaped($cart->couponCode) . "' limit 0,1";
         $db->setQuery($q);
         $res = $db->loadAssoc();
         if (!empty($res)) {
             if ($res['percent_or_total'] == 'percent') {
                 $cp = $res['coupon_value'];
             }
         }
         if (empty($cp)) {
             if (OPCloader::tableExists('awocoupon')) {
                 $db = JFactory::getDBO();
                 $q = "select * from #__awocoupon where coupon_code = '" . $db->getEscaped($cart->couponCode) . "' and coupon_value_type = 'percent' limit 0,1";
                 $db->setQuery($q);
                 $res = $db->loadAssoc();
                 if (!empty($res)) {
                     $cp = $res['coupon_value'];
                 }
             }
         }
     }
     if (!empty($cp)) {
         $cp = (double) $cp;
         if (round($cp) == $cp) {
             $cp = (int) $cp . ' %';
         } else {
             $cp = number_format($cp, 2, '.', ' ') . ' %';
         }
     }
     $return['couponpercent'] = $cp;
     // get payment html
     $num = 0;
     if ($cmd == 'runpay') {
         $view->cart->virtuemart_shipmentmethod_id = JRequest::getVar('shipping_rate_id', '');
     }
     $isexpress = OPCloader::isExpress($cart);
     $ph2_a = $OPCloader->getPayment($view, $num, false, $isexpress);
     $ph2 = $ph2_a['html'];
     $return['payment_extra'] = $ph2_a['extra'];
     /*
     if (!empty($ph_a['extra']))
     {
       foreach ($ph_a['extra'] as $key=>$val)
     		  {
     		    $return['payment_extra'].$val; 
     		  }
     }
     */
     if ($cmd == 'runpay') {
         $cart->virtuemart_shipmentmethod_id = null;
     }
     if (!empty(OPCloader::$totalIsZero)) {
         $hide_payment_if_one = true;
         $num = 1;
         $ph2 = '<input type="hidden" value="0" name="virtuemart_paymentmethod_id" id="virtuemart_paymentmethod_id_0" />';
     }
     if (!empty($hide_payment_if_one) && $num === 1 || $isexpress) {
         $ph = '<div class="payment_inner_html" rel="force_hide_payments">' . $ph2;
     } else {
         $ph = '<div class="payment_inner_html" rel="force_show_payments">' . $ph2;
     }
     $ph .= '</div>';
     $return['payment'] = $ph;
     if (isset($saved_totals)) {
         $return['totals_html'] = $saved_totals;
     } else {
         $return['totals_html'] = OPCloader::$totals_html;
     }
     $return['min_pov'] = OPCloader::checkPurchaseValue($cart);
     if (!empty($return['totals_html'])) {
         $session = JFactory::getSession();
         /*
         $r = $session->get('opcuniq'); 
         if (empty($r))
         {
         $rand = uniqid('', true); 
                $session->set('opcuniq', $rand);
                $session->set($rand, '0');
         }
         */
         $rand = uniqid('', true);
         $return['totals_html'] .= '<input type="hidden" name="opcuniq" value="' . $rand . '" />';
     }
     $t = $return['shipping'] . ' ' . $return['payment'];
     $t = str_replace('//<![CDATA[', '', $t);
     $t = str_replace('//]]> ', '', $t);
     $t = str_replace('<![CDATA[', '', $t);
     $t = str_replace(']]> ', '', $t);
     $t = str_replace('#paymentForm', '#adminForm', $t);
     //$t = str_replace('jQuery(document).ready(', ' jQuery( ', $t);
     $js = array();
     if (strpos($t, '<script') !== false) {
         $xa = basketHelper::strposall($t, '<script');
         foreach ($xa as $st) {
             // end of <script tag
             $x1 = strpos($t, '>', $st + 1);
             // end of </scrip tag
             $x2 = strpos($t, '</scrip', $st + 1);
             $js1 = substr($t, $x1 + 1, $x2 - $x1 - 1);
             $js[] = $js1;
         }
     }
     $return['shipping'] .= JHtml::_('form.token');
     $return['payment'] .= JHtml::_('form.token');
     if (isset(VmPlugin::$ccount)) {
         if (!empty($opc_debug)) {
             $js[] = "\n" . 'op_log("Positive cache match: ' . VmPlugin::$ccount . '");';
         }
     }
     if (!empty($opc_debug)) {
         if (defined('OPCMEMSTART')) {
             $mem = memory_get_usage(true);
             $memd = $mem - OPCMEMSTART;
             $memd = (double) ($memd / 1024);
             $memd = number_format($memd, 0, '.', ' ');
             if (!defined('debugmem')) {
                 $debugmem = $mem - OPCMEMSTART;
                 $debugmem = (double) ($debugmem / 1024);
             } else {
                 $debugmem = (double) (debugmem / 1024);
             }
             $debugmem = number_format($debugmem, 0, '.', ' ');
             $mem = (double) ($mem / 1024);
             $mem = number_format($mem, 0, '.', ' ');
             $js[] = "\n" . 'op_log("Memory usage: ' . $memd . 'kb of ' . $mem . 'kb, debug mem: ' . $debugmem . 'kb ");';
         }
     }
     $return['javascript'] = $js;
     $return['opcplugins'] = OPCloader::getPluginData($cart);
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'removemsgs.php';
     OPCremoveMsgs::removeMsgs($cart);
     $x = JFactory::getApplication()->getMessageQueue();
     $arr = array();
     $disablarray = array('Unrecognised mathop', JText::_('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS'));
     include JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'third_party' . DS . 'third_party_disable_msgs.php';
     $euvat_text = array('VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_VALID', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_COUNTRYCODE', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_FORMAT_REASON', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_FORMAT', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_SERVICE_UNAVAILABLE', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_COMPANYNAME_REQUIRED');
     foreach ($euvat_text as $k => $t) {
         $tt = JText::_($t);
         $euvat_text[$k] = substr($tt, 0, 20);
     }
     $euvatinfo = '';
     $remove = array();
     foreach ($x as $key => $val) {
         foreach ($euvat_text as $kx => $eutext) {
             // echo 'comparing '.$eutext.' with '.$val['message']."<br />\n";
             if (stripos($val['message'], $eutext) !== false) {
                 $euvatinfo .= $val['message'];
                 $remove[] = $key;
                 break;
             }
         }
         foreach ($disablarray as $msg) {
             if (stripos($val['message'], $msg) !== false) {
                 $remove[] = $key;
             }
             if (stripos($val['message'], JText::_('COM_VIRTUEMART_COUPON_CODE_INVALID')) !== false) {
                 $cart->couponCode = '';
                 $cart->setCartIntoSession();
             }
         }
     }
     if (!empty($euvatinfo)) {
         $return['checkvat'] = $euvatinfo;
     }
     foreach ($x as $key => $val) {
         if (!in_array($key, $remove)) {
             $arr[] = $val['message'];
         }
     }
     $return['msgs'] = $arr;
     if (!empty($opc_debug)) {
         if (!empty(OPCloader::$debugMsg)) {
             $return['debug_msgs'] = OPCloader::$debugMsg;
         }
     }
     if (!empty($cart->couponCode)) {
         $return['couponcode'] = $cart->couponCode;
     } else {
         $return['couponcode'] = '';
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'shoppergroups.php';
     OPCShopperGroups::setShopperGroupsController($cart);
     $upd = array('update_product', 'delete_product', 'process_coupon', 'removecoupon', 'updateattribute', 'refreshall', 'updateattributes', 'checkvatopc', 'checkvat', 'vat_info');
     if (in_array($cmd, $upd) || stripos($cmd, 'shipping') !== false || !empty($ajaxify_cart)) {
         if ($shipping == 'opc_do_not_update') {
             $shipping = '';
         }
         if (!empty($ph2_a['html'])) {
             $payment_html = $op_payment = '<div id="payment_html">' . $ph2_a['html'] . '</div>';
         } else {
             $payment_html = $op_payment = '<div id="payment_html">&nbsp;</div>';
         }
         $html = $this->getCartHtml($cart, $OPCloader, $shipping, $payment_html);
         $return['basket'] = $html;
     }
     $cart->virtuemart_shipmentmethod_id = 0;
     $cart->virtuemart_paymentmethod_id = 0;
     $cart->setCartIntoSession();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     //echo json_encode('');
     echo json_encode($return);
     //echo $shipping;
     $dispatcher = JDispatcher::getInstance();
     $returnValues = $dispatcher->trigger('updateAbaData', array());
     if ($restoreBT) {
         $cart->BT = $opcsavedBT;
     }
     if ($restoreST) {
         $cart->ST = $opcsavedST;
     }
     $cart->setCartIntoSession();
     $mainframe = JFactory::getApplication();
     // do not allow further processing
     $mainframe->close();
     die;
 }
コード例 #5
0
 /**
  * Displays the view, collects needed data for the different layouts
  *
  * Okey I try now a completly new idea.
  * We make a function for every tab and the display is getting the right tabs by an own function
  * putting that in an array and after that we call the preparedataforlayoutBlub
  *
  * @author Oscar van Eijk
  * @author Max Milbers
  *
  *  Original code from: \components\com_virtuemart\views\user\view.html.php
  *
  */
 function display($tpl = null)
 {
     $useSSL = VmConfig::get('useSSL', 0);
     $useXHTML = true;
     $this->assignRef('useSSL', $useSSL);
     $this->assignRef('useXHTML', $useXHTML);
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $layoutName = $this->getLayout();
     if (!defined('OPC_IN_REGISTRATION_MODE')) {
         define('OPC_IN_REGISTRATION_MODE', 1);
     }
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php';
     OPCLang::loadLang();
     $this->loadOPC();
     // 	vmdebug('layout by view '.$layoutName);
     if (empty($layoutName) or $layoutName == 'default') {
         $layoutName = JRequest::getWord('layout', 'edit');
         if ($layoutName == 'default') {
             $layoutName = 'edit';
         }
         $this->setLayout($layoutName);
     }
     if (empty($this->fTask)) {
         $ftask = 'saveUser';
         $this->assignRef('fTask', $ftask);
     }
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     // 	vmdebug('my layoutname',$layoutName);
     if ($layoutName == 'login') {
         parent::display($tpl);
         return;
     }
     if (!class_exists('VirtuemartModelUser')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'user.php';
     }
     $this->_model = new VirtuemartModelUser();
     //		$this->_model->setCurrent(); //without this, the administrator can edit users in the FE, permission is handled in the usermodel, but maybe unsecure?
     $editor = JFactory::getEditor();
     //the cuid is the id of the current user
     $this->_currentUser = JFactory::getUser();
     $this->_cuid = $this->_lists['current_id'] = $this->_currentUser->get('id');
     $this->assignRef('userId', $this->_cuid);
     $this->_userDetails = $this->_model->getUser();
     $this->assignRef('userDetails', $this->_userDetails);
     $address_type = JRequest::getWord('addrtype', 'BT');
     $this->assignRef('address_type', $address_type);
     //New Address is filled here with the data of the cart (we are in the cart)
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $new = false;
     if (JRequest::getInt('new', '0') == 1) {
         $new = true;
     }
     if ($new) {
         $virtuemart_userinfo_id = 0;
     } else {
         $virtuemart_userinfo_id = JRequest::getString('virtuemart_userinfo_id', '0', '');
         if (empty($virtuemart_userinfo_id)) {
             require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'mini.php';
             $umodel = OPCmini::getModel('user');
             //new VirtuemartModelUser();
             $uid = JFactory::getUser()->id;
             $userDetails = $umodel->getUser();
             $virtuemart_userinfo_id = $umodel->getBTuserinfo_id();
         }
     }
     $this->assignRef('virtuemart_userinfo_id', $virtuemart_userinfo_id);
     $userFields = null;
     if ((strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) && empty($virtuemart_userinfo_id)) {
         $fieldtype = $address_type . 'address';
         if (method_exists($cart, 'prepareAddressDataInCart')) {
             $cart->prepareAddressDataInCart($address_type, $new);
         }
         if (method_exists($cart, 'prepareAddressFieldsInCart')) {
             $cart->prepareAddressFieldsInCart();
         }
         $userFields = $cart->{$fieldtype};
         $task = JRequest::getWord('task', '');
     } else {
         $userFields = $this->_model->getUserInfoInUserFields($layoutName, $address_type, $virtuemart_userinfo_id);
         if (!$new && empty($userFields[$virtuemart_userinfo_id])) {
             $virtuemart_userinfo_id = $this->_model->getBTuserinfo_id();
             // 			vmdebug('Try to get $virtuemart_userinfo_id by type BT', $virtuemart_userinfo_id);
         }
         $userFields = $userFields[$virtuemart_userinfo_id];
         $task = 'editaddressST';
     }
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'loader.php';
     /*
     if (!class_exists('VirtueMartCart'))
     	require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
     $this->cart = VirtueMartCart::getCart(); 
     */
     $OPCloader = new OPCloader();
     OPCloader::setRegType();
     $action_url = JURI::root(true) . '/index.php?option=com_onepage&amp;view=opc&amp;controller=opc&amp;task=opcregister&amp;nosef=1';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'javascript.php';
     OPCJavascript::getJavascript($this, $OPCloader, false, $action_url, 'com_onepage', 'opcregister');
     $OPCloader->customizeFieldsPerOPCConfig($userFields);
     OPCloader::loadJavascriptFiles($this);
     $op_formvars = OPCloader::getFormVars($this);
     /*
     	foreach ($userFields['fields'] as $key=>$val)
     {
        if (isset($val['formcode']))
     		{
     		
     		  $val['formcode'] .= $html; 
     		  break; 
     		  
     		}
     }
     */
     $this->assignRef('userFields', $userFields);
     if ($layoutName == 'edit') {
         if ($this->_model->getId() == 0 && $this->_cuid == 0) {
             $button_lbl = JText::_('COM_VIRTUEMART_REGISTER');
         } else {
             $button_lbl = JText::_('COM_VIRTUEMART_SAVE');
         }
         $this->assignRef('button_lbl', $button_lbl);
         $this->lUser();
         if (JVM_VERSION <= 2) {
             $this->shopper($userFields);
         } else {
             $this->shopper3($userFields);
         }
         $this->payment();
         $this->lOrderlist();
         $this->lVendor();
     }
     $this->_lists['shipTo'] = $this->generateStAddressList($this, $this->_model, $task, $cart);
     if ($this->_openTab < 0) {
         $_paneOffset = array();
     } else {
         if (defined('__VM_USER_USE_SLIDERS')) {
             $_paneOffset = array('startOffset' => $this->_openTab, 'startTransition' => 1, 'allowAllClose' => true);
         } else {
             $_paneOffset = array('startOffset' => $this->_openTab);
         }
     }
     // Implement the Joomla panels. If we need a ShipTo tab, make it the active one.
     // In tmpl/edit.php, this is the 4th tab (0-based, so set to 3 above)
     jimport('joomla.html.pane');
     $pane = OPCPane::getInstance(defined('__VM_USER_USE_SLIDERS') ? 'Sliders' : 'Tabs', $_paneOffset);
     $this->assignRef('lists', $this->_lists);
     $this->assignRef('editor', $editor);
     $this->assignRef('pane', $pane);
     if ($layoutName == 'mailregisteruser') {
         $vendorModel = VmModel::getModel('vendor');
         //			$vendorModel->setId($this->_userDetails->virtuemart_vendor_id);
         $vendor = $vendorModel->getVendor();
         $this->assignRef('vendor', $vendor);
     }
     if ($layoutName == 'editaddress') {
         $layoutName = 'edit_address';
         $this->setLayout($layoutName);
     }
     if (!$this->userDetails->JUser->get('id')) {
         $corefield_title = JText::_('COM_VIRTUEMART_USER_CART_INFO_CREATE_ACCOUNT');
     } else {
         $corefield_title = JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     }
     if (strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) {
         $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
     } else {
         //$pathway->addItem(JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS'), JRoute::_('index.php?option=com_virtuemart&view=user&&layout=edit'));
     }
     $pathway_text = JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     if (!$this->userDetails->JUser->get('id')) {
         if (strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) {
             if ($address_type == 'BT') {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
             } else {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         } else {
             if ($address_type == 'BT') {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
                 $title = JText::_('COM_VIRTUEMART_REGISTER');
             } else {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         }
     } else {
         if ($address_type == 'BT') {
             $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_BILLTO_LBL');
         } else {
             $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
         }
     }
     $add_product_link = "";
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'mini.php';
     if (OPCmini::isSuperVendor()) {
         $add_product_link = JRoute::_('/index.php?option=com_virtuemart&tmpl=component&view=product&view=product&task=edit&virtuemart_product_id=0');
         $add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_ADD_PRODUCT', 'new', false, false, true, true);
     }
     $this->assignRef('add_product_link', $add_product_link);
     $document = JFactory::getDocument();
     $document->setTitle($pathway_text);
     $pathway->additem($pathway_text);
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     $this->assignRef('page_title', $pathway_text);
     $this->assignRef('corefield_title', $corefield_title);
     $this->assignRef('vmfield_title', $vmfield_title);
     //   if ($onlyindex) return JURI::root(true).'/index.php';
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     require_once JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'removemsgs.php';
     OPCremoveMsgs::removeMsgs($cart);
     $jsvalidator = $OPCloader->getJSValidatorScript($this);
     $op_userfields = $OPCloader->getBTfields($this);
     $registration_html = $OPCloader->getRegistrationHhtml($this);
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'commonhtml.php';
     $reg_html = OPCCommonHtml::getFormVarsRegistration($OPCloader);
     $op_formvars = $reg_html . $jsvalidator;
     $op_userfields .= $op_formvars;
     $onsubmit = $op_onclick = $OPCloader->getJSValidator($this);
     $op_onclick = ' onclick="' . $op_onclick . '" ';
     ob_start();
     //parent::display($tpl);
     include_once JPATH_OPC . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'registration_templates.php';
     $html = ob_get_clean();
     //$html = str_replace('"com_virtuemart"', '"com_onepage"', $html);
     //$html = str_replace('=com_virtuemart', '=com_onepage', $html);
     $this->getActions($html);
     $html = $OPCloader->addListeners($html);
     echo $html;
     $extras = $OPCloader->getExtras($this);
     echo $extras;
 }