$web = str_replace('%%downloadlink%%',$downloadLink,$dmpcfg['thankyoupagecode']); $web = str_replace('%%downloadname%%',$dmname,$web); echo $web; } else if ($mode == 'cart') { $order_id = JRequest::getInt('order_id',null,null,'int'); $key = JRequest::getVar('key'); $out = ''; $document->addStylesheet(JURI::base() . 'components/com_docman/themes/default/css/theme.css'); $dm->cartEmpty(); $web = $dm->cfg['thankyoupagecodeCart']; $order = $dm->getOrder(JRequest::getInt('order_id')); if ($order) { $ids = explode(",",$order->file_id); $out .= ''; foreach ($ids as $id) { $item = $dm->getItem($id); if ($item->offlineGood == 0) { $out .= '<div class="dm_taskbar" style="float:none; padding-top:20px;"><ul><li style="float:none;"><a href="' . JRoute::_("index.php?option=com_docman&view=download&Itemid=" . (int)JRequest::getVar('Itemid') . "&order_id=$order_id&id=$id&key=$key") . '" style="display:inline;">' . _DMP_DOWNLOAD . ' <b>' . $item->dmname . '</b></a></li></ul></div>'; } else { $out .= '<div class="dm_taskbar" style="float:none; padding-top:20px;"><ul><li style="float:none;"><b>' . $item->dmname . '</b></li></ul></div>'; } } $out .= ''; } $web = str_replace('%%cartDownloadList%%', $out, $web); echo $web; } break; case "downloadslimit": /* $order_id = (int)$_GET['order_id'];
function bot_docmanpaypalprices2($params) { global $mainframe, $_DOCMAN, $_DMUSER, $currency_symbols; $database =& JFactory::getDBO(); $my = JFactory::getUser(); require_once $_DOCMAN->getPath('classes', 'button'); require_once $_DOCMAN->getPath('classes', 'token'); $_DOCMAN->loadLanguage('frontend'); $doc =& $params['doc']; $file =& $params['file']; $objDBDoc = $doc->objDBTable; $buttonStaysBuyNow = false; $objFormatData = $doc->objFormatData; if ($objFormatData->id > 0) { $currency = docmanpaypal::cfg('currency'); $gid = $objFormatData->id; $item = docmanpaypal::getItem($gid); $database->setQuery("select price from #__docmanpaypal where id = '{$gid}' limit 1;"); $price = $database->loadResult(); $database->setQuery("select dmdescription from #__docman where id = {$gid} limit 1"); $dmdescription = $database->loadResult(); $document_price = number_format($price, 2); //free fownloads for user in specific groups if ($my->id > 0) { $tmp = docmanpaypal::cfg('free_for_usertypes'); $tmp = explode(',', $tmp); if (in_array($my->usertype, $tmp)) { $price = 0; } if (docmanpaypal::isInDOCmanFreeDownloadGroup()) { $price = 0; } //die($price); } //free fownloads for user in specific groups END if ($price > 0) { $document_price = number_format($price, 2); $priceFormat = docmanpaypal::cfg('priceFormat'); $priceFormatted = str_replace(array('%priceText%', '%price%', '%currency%'), array(_DMP_PRICE, $document_price, $currency), $priceFormat); $objFormatData->dmdescription = $priceFormatted . $dmdescription; $objFormatData->dmdescription = str_replace('%price%', $currency_symbols[$currency] . number_format($price, 2), $objFormatData->dmdescription); //$objFormatData->dmdescription = '<div id="DMP_PRICE_DIV"><span class="DMP_PRICE">' . _DMP_PRICE . '</span> <span class="DMP_PRICE_VALUE">' . $document_price . '</span> <span class="DMP_PRICE_CURRENCY">' . $currency . '</span></div>' . $dmdescription; } } $botParams = bot_docmanpaypalpricesParams2(); //print_r($botParams); $js = "javascript:if(confirm('" . _DML_ARE_YOU_SURE . "')) {window.location='%s'}"; $buttons = array(); $tmp = docmanpaypal::cfg('moreThanOnce'); if ($tmp > 0 && $my->id > 0) { unset($tmp); $database->setQuery("select order_id from #__docmanpaypalorders where buyer_id = " . $my->id . " and file_id = {$gid} OR file_id like '{$gid},%' or file_id like '%,{$gid},%' or file_id like '%,{$gid}' and completed = 1 order by order_id desc limit 1"); //die($database->getQuery()); $tmp = $database->loadResult(); if ($tmp > 0) { $database->setQuery("select downloads from #__docmanpaypaldownloads where order_id = {$tmp} and id = {$gid} order by order_id desc limit 1"); //die($database->getQuery()); $downloads = $database->loadResult(); if ($downloads < $item->downloadslimit && is_null($downloads) == false) { $price = 0; } $buttonStaysBuyNow = docmanpaypal::cfg('buttonStaysBuyNow'); } } //offline good update if ($item->offlineGood > 0) { $price = $item->price; } // if ($botParams->get('priceInBuyNow', 1)) { $priceInBuyNow = ' (' . $currency_symbols[$currency] . number_format($price, 2) . ')'; } if ($botParams->get('priceInTitle', 1) && $price > 0) { $objFormatData->dmname .= ' - ' . $currency_symbols[$currency] . number_format($price, 2); } if ($price > 0) { if ($_DMUSER->canDownload($objDBDoc) and $botParams->get('download', 1)) { if (docmanpaypal::cfg('useCart') > 0) { $buttons['addToCart'] = new DOCMAN_Button('addToCart', _DMP_ADD_TO_CART, 'javascript:addToCart(' . $gid . ');'); } if ($botParams->get('buynow', 1)) { $buttons['download'] = new DOCMAN_Button('download', _DMP_BUY_NOW . $priceInBuyNow, $doc->_formatLink('doc_download')); } } } else { //die('shit'); if ($_DMUSER->canDownload($objDBDoc) and $botParams->get('download', 1) and $buttonStaysBuyNow == 0) { $buttons['download'] = new DOCMAN_Button('download', _DML_BUTTON_DOWNLOAD, $doc->_formatLink('doc_download')); } if ($_DMUSER->canDownload($objDBDoc) and $botParams->get('download', 1) and $buttonStaysBuyNow == 1) { $buttons['download'] = new DOCMAN_Button('download', _DMP_BUY_NOW . $priceInBuyNow, $doc->_formatLink('doc_download')); } } //pdfPreview option if (pathinfo($objFormatData->dmfilename, PATHINFO_EXTENSION) == 'pdf' && docmanpaypal::cfg('pdfPreviewPages') > 0 && $price > 0) { $buttons['pdfPreview'] = new DOCMAN_Button('pdfPreview', _DMP_PDFPREVIEWBUTTON, JRoute::_('index.php?&option=com_docmanpaypal&task=pdfPreview&id=' . $gid)); } // //custom buttons if ($item->buttons != '' && strpos($item->buttons, '|')) { $tmp = str_replace("\r", "", $item->buttons); $tmp = explode("\n", $tmp); foreach ($tmp as $tmp) { if (strpos($tmp, "|")) { $t = explode("|", $tmp); $btn++; if (count($t) > 1) { $buttons['btn' . $btn] = new DOCMAN_Button('btn' . $btn, $t[0], JRoute::_($t[1])); } } } } // if ($_DMUSER->canDownload($objDBDoc) and $botParams->get('view', 1) && $price == 0) { $viewtypes = trim($_DOCMAN->getCfg('viewtypes')); if ($viewtypes != '' && ($viewtypes == '*' || stristr($viewtypes, $file->ext))) { $link = $doc->_formatLink('doc_view', null, true, 'index2.php'); $params = new DMmosParameters('popup=1'); $buttons['view'] = new DOCMAN_Button('view', _DML_BUTTON_VIEW, $link, $params); } } if ($botParams->get('details', 1)) { $buttons['details'] = new DOCMAN_Button('details', _DML_BUTTON_DETAILS, $doc->_formatLink('doc_details')); } if ($_DMUSER->canEdit($objDBDoc) and $botParams->get('edit', 1)) { $buttons['edit'] = new DOCMAN_Button('edit', _DML_BUTTON_EDIT, $doc->_formatLink('doc_edit')); } if ($_DMUSER->canMove($objDBDoc) and $botParams->get('move', 1)) { $buttons['move'] = new DOCMAN_Button('move', _DML_BUTTON_MOVE, $doc->_formatLink('doc_move')); } if ($_DMUSER->canDelete($objDBDoc) and $botParams->get('delete', 1)) { $link = $doc->_formatLink('doc_delete', null, null, null, true); $buttons['delete'] = new DOCMAN_Button('delete', _DML_BUTTON_DELETE, sprintf($js, $link)); } if ($_DMUSER->canUpdate($objDBDoc) and $botParams->get('update', 1)) { $buttons['update'] = new DOCMAN_Button('update', _DML_BUTTON_UPDATE, $doc->_formatLink('doc_update')); } if ($_DMUSER->canReset($objDBDoc) and $botParams->get('reset', 1)) { $buttons['reset'] = new DOCMAN_Button('reset', _DML_BUTTON_RESET, sprintf($js, $doc->_formatLink('doc_reset'))); } if ($_DMUSER->canCheckin($objDBDoc) and $objDBDoc->checked_out and $botParams->get('checkout', 1)) { $params = new DMmosParameters('class=checkin'); $buttons['checkin'] = new DOCMAN_Button('checkin', _DML_BUTTON_CHECKIN, $doc->_formatLink('doc_checkin'), $params); } if ($_DMUSER->canCheckout($objDBDoc) and !$objDBDoc->checked_out and $botParams->get('checkout', 1)) { $buttons['checkout'] = new DOCMAN_Button('checkout', _DML_BUTTON_CHECKOUT, $doc->_formatLink('doc_checkout')); } if ($_DMUSER->canApprove($objDBDoc) and !$objDBDoc->approved and $botParams->get('approve', 1)) { $params = new DMmosParameters('class=approve'); $link = $doc->_formatLink('doc_approve', null, null, null, true); $buttons['approve'] = new DOCMAN_Button('approve', _DML_BUTTON_APPROVE, $link, $params); } if ($_DMUSER->canPublish($objDBDoc) and $botParams->get('publish', 1)) { $params = new DMmosParameters('class=publish'); $link = $doc->_formatLink('doc_publish', null, null, null, true); $buttons['publish'] = new DOCMAN_Button('publish', _DML_BUTTON_PUBLISH, $link, $params); } if ($_DMUSER->canUnPublish($objDBDoc) and $botParams->get('publish', 1)) { $link = $doc->_formatLink('doc_unpublish', null, null, null, true); $buttons['unpublish'] = new DOCMAN_Button('unpublish', _DML_BUTTON_UNPUBLISH, $link); } //print_r($buttons); return $buttons; }
//$sandbox = mysql_result(mysql_query("select value from $mosConfig_dbprefix" . "docmanpaypalconfig where name = 'sandbox'"),0); if ($sandbox == 'No') { $p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; } else { $p->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } $componentdir = 'components/com_docmanpaypal'; // if there is not action variable, set the default action of 'process' $request_action = JRequest::getVar('action'); if (empty($request_action)) $request_action = 'process'; switch ($request_action) { case 'process': // Process and order... if (is_numeric(JRequest::getVar('id')) and JRequest::getVar('id') > 0) { //SINGLE $item = $dm->getItem(JRequest::getVar('id')); $price = $item->price; $name = $item->dmname; $p->add_field('return', JURI::base() . "index.php?option=com_docmanpaypal&task=doc_download&mode=" . JRequest::getVar('mode') . "&gid=" . (int)JRequest::getVar('id') . "&order_id=$order_id&key=$key&Itemid=" . (int)JRequest::getVar('Itemid')); $p->add_field('cancel_return', JURI::base() . "index.php?option=com_docmanpaypal&task=order_canceled"); //$p->add_field('notify_url', JURI::base() ."index.php?option=com_docmanpaypal&task=ipn&mode=single&action=ipn&merchant=PayPal"); $p->add_field('notify_url', JURI::base() ."index.php?option=com_docmanpaypal&task=ipn&mode=single&action=ipn&Itemid=" . (int)JRequest::getVar('Itemid')); $p->add_field('item_name', $name); $p->add_field('item_number', $order_id); $p->add_field('amount', $price); //$p->add_field('upload',1);//fix when added cart $p->add_field('custom', base64_encode(serialize(array('my_id' => $my->id,'doc_id' => (int)JRequest::getVar('id'), 'order_id' => $order_id, 'key' => $key)))); if ($cfg['useVat'] > 0) { $p->add_field('tax', $dm->vatCalc($price)); } if ($item->vendor_id == 0) {
<?php $doc = JFactory::getDocument(); JHtml::_('jquery.framework'); $doc->addStylesheet(JURI::base() . 'components/com_docmanpaypal/css/style.css'); $doc->addScript(JURI::base() . 'components/com_docmanpaypal/js/script.js'); $lang = JFactory::getLanguage(); $extension = 'com_docmanpaypal'; $lang->load($extension, JPATH_SITE . '/components/com_docmanpaypal'); include_once(JPATH_SITE . '/administrator/components/com_docmanpaypal/docmanpaypal.class.php'); $dm = new docmanpaypal(); $item = $dm->getItem($document->id); $price = $item->price; if ($price > 0 && $dm->canDownload($document->id,'',false) == false) { //$showAddToCart = true; $showBuyNow = true; $currencySymbol = $dm->currencies[$dm->cfg['currency']]['ASCII']; if ($dm->cfg['pdfPreviewPages'] > 0 && pathinfo($item->storage_path, PATHINFO_EXTENSION) == 'pdf') { $showPreviewButton = true; } } $show_download = true; $priceFormat = money_format($price, 2); if ($showBuyNow) { $show_download = false;
$classPath = JPATH_SITE . "/administrator/components/com_docmanpaypal/docmanpaypal.class.php"; //echo $classPath; require_once($classPath); $dm = new docmanpaypal(); if (!$dm->constructRun) { $dm->__construct(); } $doc_id = JRequest::getVar('id',null,null,'int'); $key = JRequest::getVar('key'); $order_id = JRequest::getVar('order_id',null,null,'int'); if (!$doc_id) { $doc_id = (int)JRequest::getVar('alias'); } $item = $dm->getItem($doc_id); $my = JFactory::getUser(); $dm->cfg = $dm->getConfig(); $price = $dm->getPrice($doc_id); /** * free for user /** * @author Deian * * free for user type */