/** * Sets the request paths for this request. */ public function setRequestPaths() { $requestPaths = XenForo_Application::getRequestPaths($this->_request); XenForo_Application::set('requestPaths', $requestPaths); }
/** * Sets the request paths for this request. */ public function setRequestPaths() { if (!XenForo_Application::isRegistered('requestPaths')) { $requestPaths = XenForo_Application::getRequestPaths($this->_request); XenForo_Application::set('requestPaths', $requestPaths); } }
public function actionPurchase() { $visitor = XenForo_Visitor::getInstance(); $xenOptions = XenForo_Application::get('options'); $paidContentId = $this->_input->filterSingle('paid_content_id', XenForo_Input::UINT); $paidContentModel = $this->_getPaidContentModel(); $paidContentItem = $paidContentModel->preparePaidContent($this->_getPaidContentItemOrError($paidContentId)); $paidContentHandler = $paidContentModel->getPaidContentHandler($paidContentItem['content_type']); if (!$paidContentHandler) { return $this->responseNoPermission(); } $content = $paidContentHandler->getContentById($paidContentItem['content_id']); if (!$content) { return $this->responseNoPermission(); } if (!$visitor['user_id'] && ($paidContentItem['user_group_ids'] == -1 || in_array(XenForo_Model_User::$defaultRegisteredGroupId, explode(',', $paidContentItem['user_group_ids'])))) { return $this->responseReroute('XenForo_ControllerPublic_Register', 'index'); } if (!$paidContentModel->canPurchasePaidContentItem($paidContentItem)) { return $this->responseNoPermission(); } if ($this->_checkCsrfFromToken(null, false)) { $paths = XenForo_Application::getRequestPaths(new Zend_Controller_Request_Http()); $baseUrl = $paths['fullBasePath']; $params = array('cmd' => '_xclick', 'amount' => $paidContentItem['cost_amount'], 'business' => $paidContentItem['paypal_email'] ? $paidContentItem['paypal_email'] : $xenOptions->payPalPrimaryAccount, 'currency_code' => $paidContentItem['currency'], 'item_name' => $paidContentHandler->getTitleForContent($content), 'quantity' => 1, 'no_note' => 1, 'custom' => implode(',', array($visitor->user_id, $paidContentItem['paid_content_id'], 'token', $visitor->csrf_token_page)), 'charset' => 'utf-8', 'email' => $visitor->email, 'return' => XenForo_Link::buildPublicLink('full:paid-content/purchase-success'), 'cancel_return' => XenForo_Link::buildPublicLink('full:index'), 'notify_url' => $baseUrl . 'paid_content_callback.php'); $payPalUrl = $this->_input->filterSingle('payPalUrl', XenForo_Input::STRING); if (!$payPalUrl) { $payPalUrl = 'https://www.paypal.com/cgi-bin/websrc'; } // Redirect to paypal $url = $payPalUrl . '?' . XenForo_Link::buildQueryString($params); header('Location: ' . $url); exit; } $viewParams = array('title' => $paidContentHandler->getTitleForContent($content), 'breadCrumbs' => $paidContentHandler->getBreadcrumbsForContent($content), 'paidContentItem' => $paidContentItem); return $this->responseView('ThemeHouse_PayForContent_ViewPublic_PaidContent_PurchaseConfirm', 'th_purchase_confirm_payforcontent', $viewParams); }