public function onAfterRoute() { $user = JFactory::getUser(); if (!empty($user->id)) { return; } if (empty($user->guest)) { return; } if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } if (!file_exists(JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'plugin.php')) { return; } require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'pluginregistration.php'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'plugin.php'; if (!OPCplugin::checkLoad()) { return; } $option = JRequest::getVar('option', ''); if ($option != 'com_virtuemart') { return; } $view = JRequest::getVar('view', ''); if ($view != 'user' && $view != 'opcuser') { return; } $task = JRequest::getVar('task', ''); $controller = JRequest::getVar('controller', ''); if ($controller == 'opc' && $view == 'opcuser') { JRequest::setVar('view', 'opc'); if (strpos($controller, '..') !== false) { die('?'); } require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'controllers' . DS . 'opc.php'; //OPC checkout loads the user page for editaddresscheckout, registerCheckoutUser, saveCheckoutUser $allowed = array('saveUser', 'display', 'editAddressST', 'editAddressCart', 'saveCartUser', 'registerCartuser', 'saveUser', 'saveAddressST', 'cancelCartUser', 'cancelCheckoutUser', 'cancel', 'removeAddressST'); if (in_array($task, $allowed)) { JRequest::setVar('task_original', $task); JRequest::setVar('task', 'opcregister'); } } // check OPC loaded //if (!defined('JPATH_OPC')) return; // check OPC cart includes $ign = array('editaddresscheckout', 'pluginUserPaymentCancel', 'opc', 'cart'); if (in_array($task, $ign)) { return; } // check includes that we do not need: $ign_layout = array('login', 'mailregisteruser', 'mail_html_reguser', 'mail_html_regvendor', 'mail_raw_reguser', 'mail_raw_regvendor', 'edit_vendor', 'edit_orderlist'); $layout = JRequest::getVar('layout', 'default'); if (in_array($layout, $ign_layout)) { return; } if (!class_exists('VirtueMartViewUser')) { require JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'overrides' . DS . 'virtuemart.user.registration.view.html.php'; } }
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"> </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; }