/** * Technic to inject params as table attributes * @author Max Milbers */ function store($updateNulls = false) { $this->setLoggableFieldsForStore(); if ($this->_cryptedFields) { if (!class_exists('vmCrypt')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmcrypt.php'; } vmdebug('my crytped fields in store ' . get_class($this), $this->_cryptedFields); foreach ($this->_cryptedFields as $field) { if (isset($this->{$field})) { $this->{$field} = vmCrypt::encrypt($this->{$field}); } else { vmdebug('Store vmtable empty property for ' . $field); } } } $this->storeParams(); return parent::store($updateNulls); }
/** * This function is called, when the order is confirmed by the shopper. * * Here are the last checks done by payment plugins. * The mails are created and send to vendor and shopper * will show the orderdone page (thank you page) * */ function confirmedOrder() { //Just to prevent direct call if ($this->_dataValidated && $this->_confirmDone and !$this->_inCheckOut) { if ($this->_inConfirm) { vmdebug('Already in CONFIRM,.. RETURN'); return false; } //We set this in the trigger of the plugin. so old plugins keep the old behaviour //$this->_inConfirm = true; //$this->setCartIntoSession(); //session_write_close(); //session_start(); $orderModel = VmModel::getModel('orders'); if (($this->virtuemart_order_id = $orderModel->createOrderFromCart($this)) === false) { $mainframe = JFactory::getApplication(); JError::raiseWarning(500, 'No order created ' . $orderModel->getError()); $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE)); } $orderDetails = $orderModel->getMyOrderDetails($this->virtuemart_order_id); if (!$orderDetails or empty($orderDetails['details'])) { echo JText::_('COM_VIRTUEMART_CART_ORDER_NOTFOUND'); return; } $orderModel->notifyCustomer($this->virtuemart_order_id, $orderDetails); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('vmcalculation'); JPluginHelper::importPlugin('vmcustom'); JPluginHelper::importPlugin('vmshipment'); JPluginHelper::importPlugin('vmpayment'); $returnValues = $dispatcher->trigger('plgVmConfirmedOrder', array($this, $orderDetails)); $lifetime = 24 * 60 * 60 * 180; //180 days if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } foreach ($orderDetails['items'] as $product) { //We set a cookie for guests to allow that they can rate/review a product without logging in. $app = JFactory::getApplication(); $key = 'productBought' . $product->virtuemart_product_id; $v = vmCrypt::encrypt($key); $app->input->cookie->set($key, $v, time() + $lifetime, '/'); } // may be redirect is done by the payment plugin (eg: paypal) // if payment plugin echos a form, false = nothing happen, true= echo form , // 1 = cart should be emptied, 0 cart should not be emptied $this->_inConfirm = false; $this->setCartIntoSession(); session_write_close(); session_start(); return $this->virtuemart_order_id; } return NULL; }
function _setAuthorizeNetIntoSession() { if (!class_exists('vmCrypt')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmcrypt.php'; } $session = JFactory::getSession(); $sessionAuthorizeNet = new stdClass(); // card information $sessionAuthorizeNet->cc_type = $this->_cc_type; $sessionAuthorizeNet->cc_number = vmCrypt::encrypt($this->_cc_number); $sessionAuthorizeNet->cc_cvv = vmCrypt::encrypt($this->_cc_cvv); $sessionAuthorizeNet->cc_expire_month = $this->_cc_expire_month; $sessionAuthorizeNet->cc_expire_year = $this->_cc_expire_year; $sessionAuthorizeNet->cc_valid = $this->_cc_valid; $session->set('authorizenet', json_encode($sessionAuthorizeNet), 'vm'); }
/** * Derived from JTable * Records in this table do not need to exist, so we might need to create a record even * if the primary key is set. Therefore we need to overload the store() function. * Technic to inject params as table attributes and to encrypt data * @author Max Milbers * @copyright for derived parts, (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @see libraries/joomla/database/JTable#store($updateNulls) */ function store($updateNulls = false) { $this->setLoggableFieldsForStore(); if ($this->_cryptedFields) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } foreach ($this->_cryptedFields as $field) { if (isset($this->{$field})) { $this->{$field} = vmCrypt::encrypt($this->{$field}); } } } $this->storeParams(); if (!empty($this->asset_id)) { $currentAssetId = $this->asset_id; } // The asset id field is managed privately by this class. if ($this->_trackAssets) { unset($this->asset_id); } $tblKey = $this->_tbl_key; if (!empty($this->{$tblKey})) { $_qry = 'SELECT `' . $tblKey . '` ' . 'FROM `' . $this->_tbl . '` ' . 'WHERE `' . $tblKey . '` = "' . $this->{$tblKey} . '" '; $this->_db->setQuery($_qry); $this->{$tblKey} = $this->_db->loadResult(); } if (!empty($this->{$tblKey})) { $ok = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls); } else { $ok = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key); } //reset Params if (isset($this->_tmpParams) and is_array($this->_tmpParams)) { foreach ($this->_tmpParams as $k => $v) { $this->{$k} = $v; } } $this->_tmpParams = false; // If the store failed return false. if (!$ok) { $e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', get_class($this), $this->_db->getErrorMsg())); vmError($e); return false; } // If the table is not set to track assets return true. if (!$this->_trackAssets) { return true; } if ($this->_locked) { $this->_unlock(); } $parentId = $this->_getAssetParentId(); $name = $this->_getAssetName(); $title = $this->_getAssetTitle(); $asset = JTable::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo())); $asset->loadByName($name); // Re-inject the asset id. $this->asset_id = $asset->id; // Check for an error. if ($error = $asset->getError()) { vmError($error); return false; } // Specify how a new or moved node asset is inserted into the tree. if (empty($this->asset_id) || $asset->parent_id != $parentId) { $asset->setLocation($parentId, 'last-child'); } // Prepare the asset to be stored. $asset->parent_id = $parentId; $asset->name = $name; $asset->title = $title; if ($this->_rules instanceof JAccessRules) { $asset->rules = (string) $this->_rules; } if (!$asset->check() || !$asset->store($updateNulls)) { vmError($asset->getError()); return false; } // Create an asset_id or heal one that is corrupted. if (empty($this->asset_id) || $currentAssetId != $this->asset_id && !empty($this->asset_id)) { // Update the asset_id field in this table. $this->asset_id = (int) $asset->id; $query = $this->_db->getQuery(true); $query->update($this->_db->quoteName($this->_tbl)); $query->set('asset_id = ' . (int) $this->asset_id); $query->where($this->_db->quoteName($tblKey) . ' = ' . (int) $this->{$tblKey}); $this->_db->setQuery($query); if (!$this->_db->execute()) { $e = new JException(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED_UPDATE_ASSET_ID', $this->_db->getErrorMsg())); vmError($e); return false; } } return $ok; }
private function setRetourParams($order, $context) { $params = $order['details']['BT']->virtuemart_paymentmethod_id . ':' . $order['details']['BT']->order_number . ':' . $context; if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $cryptedParams = vmCrypt::encrypt($params); $cryptedParams = base64_encode($cryptedParams); return $cryptedParams; }
/** * Decides if the rating/review should be shown on the FE * @author Max Milbers */ private function show($product_id, $show) { //dont show if ($show == 'none') { return false; } else { if ($show == 'all') { return true; } else { if ($show == 'registered') { $user = JFactory::getUser(); return !empty($user->id); } else { if ($show == 'bought') { if (empty($product_id)) { return false; } if (isset($this->_productBought[$product_id])) { return $this->_productBought[$product_id]; } if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $key = vmCrypt::encrypt('productBought' . $product_id); $count = JFactory::getApplication()->input->cookie->getString($key, false); if ($count) { //check, somehow broken, atm $v = vmCrypt::encrypt($key); if ($v != $count) { $count = false; } } if (!$count) { $user = JFactory::getUser(); $rr_os = VmConfig::get('rr_os', array('C')); if (!is_array($rr_os)) { $rr_os = array($rr_os); } $db = JFactory::getDBO(); $q = 'SELECT COUNT(*) as total FROM `#__virtuemart_orders` AS o LEFT JOIN `#__virtuemart_order_items` AS oi '; $q .= 'ON `o`.`virtuemart_order_id` = `oi`.`virtuemart_order_id` '; $q .= 'WHERE o.virtuemart_user_id > 0 AND o.virtuemart_user_id = "' . $user->id . '" AND oi.virtuemart_product_id = "' . $product_id . '" '; $q .= 'AND o.order_status IN (\'' . implode("','", $rr_os) . '\') '; $db->setQuery($q); $count = $db->loadResult(); } if ($count) { $this->_productBought[$product_id] = true; return true; } else { $this->_productBought[$product_id] = false; return false; } } } } } }
/** * Change the shopper * * @author Maik Künnemann */ public function changeShopper() { vRequest::vmCheckToken() or jexit('Invalid Token'); $app = JFactory::getApplication(); $redirect = vRequest::getString('redirect', false); if ($redirect) { $red = $redirect; } else { $red = JRoute::_('index.php?option=com_virtuemart&view=cart'); } $id = vmAccess::getBgManagerId(); $current = JFactory::getUser(); $manager = vmAccess::manager('user'); if (!$manager) { $app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_CART_CHANGE_SHOPPER_NO_PERMISSIONS', $current->name . ' (' . $current->username . ')'), 'error'); $app->redirect($red); return false; } $userID = vRequest::getCmd('userID'); if ($manager and !empty($userID) and $userID != $current->id) { if ($userID == $id) { } else { if (vmAccess::manager('user', $userID)) { //if($newUser->authorise('core.admin', 'com_virtuemart') or $newUser->authorise('vm.user', 'com_virtuemart')){ $app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_CART_CHANGE_SHOPPER_NO_PERMISSIONS', $current->name . ' (' . $current->username . ')'), 'error'); $app->redirect($red); } } } $searchShopper = vRequest::getString('searchShopper'); if (!empty($searchShopper)) { $this->display(); return false; } //update session $session = JFactory::getSession(); $adminID = $session->get('vmAdminID'); if (!isset($adminID)) { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $session->set('vmAdminID', vmCrypt::encrypt($current->id)); } $newUser = JFactory::getUser($userID); $session->set('user', $newUser); //update cart data $cart = VirtueMartCart::getCart(); $usermodel = VmModel::getModel('user'); $data = $usermodel->getUserAddressList(vRequest::getCmd('userID'), 'BT'); if (isset($data[0])) { foreach ($data[0] as $k => $v) { $data[$k] = $v; } } $cart->BT['email'] = $newUser->email; $cart->ST = 0; $cart->STsameAsBT = 1; $cart->selected_shipto = 0; $cart->virtuemart_shipmentmethod_id = 0; $cart->saveAddressInCart($data, 'BT'); $msg = vmText::sprintf('COM_VIRTUEMART_CART_CHANGED_SHOPPER_SUCCESSFULLY', $newUser->name . ' (' . $newUser->username . ')'); if (empty($userID)) { $red = JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT'); $msg = vmText::sprintf('COM_VIRTUEMART_CART_CHANGED_SHOPPER_SUCCESSFULLY', ''); } $app->enqueueMessage($msg, 'info'); $app->redirect($red); }
function setMd() { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $md = array('cc_type' => $this->customerData->getVar('cc_type'), 'cc_name' => $this->customerData->getVar('cc_name'), 'cc_number' => $this->customerData->getVar('cc_number'), 'cc_cvv' => $this->customerData->getVar('cc_cvv'), 'cc_expire_month' => $this->customerData->getVar('cc_expire_month'), 'cc_expire_year' => $this->customerData->getVar('cc_expire_year')); $jsonencodeMd = json_encode($md); $encryptMd = vmCrypt::encrypt($jsonencodeMd); return $encryptMd; }
public function save() { if (!class_exists('vmCrypt')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php'; } $session = JFactory::getSession(); $sessionData = new stdClass(); $sessionData->selected_method = $this->_selected_method; // card information $sessionData->cc_type = $this->_cc_type; $sessionData->cc_number = vmCrypt::encrypt($this->_cc_number); $sessionData->cc_cvv = vmCrypt::encrypt($this->_cc_cvv); $sessionData->cc_expire_month = $this->_cc_expire_month; $sessionData->cc_expire_year = $this->_cc_expire_year; $sessionData->cc_valid = $this->_cc_valid; //Customer settings $sessionData->autobilling_max_amount = $this->_autobilling_max_amount; //PayPal Express $sessionData->token = $this->_token; $sessionData->payer_id = $this->_payer_id; $sessionData->first_name = $this->_first_name; $sessionData->last_name = $this->_last_name; $sessionData->payer_email = $this->_payer_email; // $sessionData->txn_id = $this->_txn_id; // $sessionData->txn_type = $this->_txn_type; // $sessionData->payment_status = $this->_payment_status; // $sessionData->pending_reason = $this->_pending_reason; $session->set('paypal', json_encode($sessionData), 'vm'); }
function setMd() { if (!class_exists('vmCrypt')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmCrypt.php'; } $md = array('cc_type' => $this->customerData->getVar('cc_type'), 'cc_name' => $this->customerData->getVar('cc_name'), 'cc_number' => $this->customerData->getVar('cc_number'), 'cc_cvv' => $this->customerData->getVar('cc_cvv'), 'cc_expire_month' => $this->customerData->getVar('cc_expire_month'), 'cc_expire_year' => $this->customerData->getVar('cc_expire_year')); $serializedMd = serialize($md); $encryptMd = vmCrypt::encrypt($serializedMd); return $encryptMd; }