public static function getDownloadData($id, $return, $type = 0) { $outcome = array(); $wheres = array(); $db = JFactory::getDBO(); $app = JFactory::getApplication(); $params = $app->getParams(); $user = JFactory::getUser(); $redirectUrl = urlencode(base64_encode($return)); $returnUrl = 'index.php?option=com_users&view=login&return=' . $redirectUrl; $userLevels = implode(',', $user->getAuthorisedViewLevels()); $limitEnabled = $params->get('user_files_max_count_download', 0); if ((int) $limitEnabled > 0) { if ((int) $user->id < 1) { $app->redirect(JRoute::_($returnUrl, false), JText::_("COM_PHOCADOWNLOAD_NOT_LOGGED_IN_USERS_NOT_ALLOWED_DOWNLOAD")); exit; } $userFileCount = PhocaDownloadStat::getCountFilePerUser($id); (int) $userFileCount++; // Because we need to count this attempt too. if ((int) $userFileCount > (int) $limitEnabled) { $app->redirect(JRoute::_($returnUrl, false), JText::_("COM_PHOCADOWNLOAD_MAX_LIMIT_DOWNLOAD_PER_FILE_REACHED")); exit; } } $pQ = $params->get('enable_plugin_query', 0); $wheres[] = " c.id = " . (int) $id; $wheres[] = " c.published = 1"; $wheres[] = " c.approved \t= 1"; $wheres[] = " c.catid = cc.id"; if ($type == 1) { // Unique download link does not have any access $rightDisplay = 1; } else { $wheres[] = " cc.access IN (" . $userLevels . ")"; } // Active $jnow = JFactory::getDate(); $now = $jnow->toSql(); $nullDate = $db->getNullDate(); $wheres[] = ' ( c.publish_up = ' . $db->Quote($nullDate) . ' OR c.publish_up <= ' . $db->Quote($now) . ' )'; $wheres[] = ' ( c.publish_down = ' . $db->Quote($nullDate) . ' OR c.publish_down >= ' . $db->Quote($now) . ' )'; if ($pQ == 1) { // GWE MOD - to allow for access restrictions JPluginHelper::importPlugin("phoca"); $dispatcher =& JDispatcher::getInstance(); $joins = array(); $results = $dispatcher->trigger('onGetDownload', array(&$wheres, &$joins, $id, $paramsC)); // END GWE MOD } /*$query = " SELECT c.filename, c.directlink, c.access" ." FROM #__phocadownload AS c" . ($pQ == 1 ? ((count($joins)>0?( " LEFT JOIN " .implode( " LEFT JOIN ", $joins )):"")):"") // GWE MOD . " WHERE " . implode( " AND ", $wheres ) . " ORDER BY c.ordering";*/ $query = ' SELECT c.catid, c.filename, c.directlink, c.link_external, c.access, c.confirm_license, c.metakey, c.metadesc, cc.access as cataccess, cc.accessuserid as cataccessuserid, c.tokenhits ' . ' FROM #__phocadownload AS c, #__phocadownload_categories AS cc ' . ($pQ == 1 ? count($joins) > 0 ? ' LEFT JOIN ' . implode(' LEFT JOIN ', $joins) : '' : '') . ' WHERE ' . implode(' AND ', $wheres) . ' ORDER BY c.ordering'; $db->setQuery($query, 0, 1); $filename = $db->loadObjectList(); $limitTokenEnabled = $params->get('token_files_max_count_download', 0); if ((int) $limitTokenEnabled > 0) { if (isset($filename[0]->tokenhits)) { $tokenFileCount = $filename[0]->tokenhits; (int) $tokenFileCount++; // Because we need to count this attempt too. if ((int) $tokenFileCount > (int) $limitTokenEnabled) { $app->redirect(JRoute::_(htmlspecialchars($return)), JText::_("COM_PHOCADOWNLOAD_MAX_LIMIT_DOWNLOAD_TOKEN_REACHED")); exit; } } } //OSE Modified Start; if (!empty($filename[0])) { phocadownloadimport('phocadownload.utils.external'); PhocaDownloadExternal::checkOSE($filename[0]); } //OSE Modified End; // - - - - - - - - - - - - - - - // USER RIGHT - Access of categories (if file is included in some not accessed category) - - - - - // ACCESS is handled in SQL query, ACCESS USER ID is handled here (specific users) $rightDisplay = 0; if ($type == 1) { // Unique download link does not have any access $rightDisplay = 1; } else { if (!empty($filename[0])) { $rightDisplay = PhocaDownloadAccess::getUserRight('accessuserid', $filename[0]->cataccessuserid, $filename[0]->cataccess, $user->getAuthorisedViewLevels(), $user->get('id', 0), 0); } // - - - - - - - - - - - - - - - - - - - - - - if ($rightDisplay == 0) { $app->redirect(JRoute::_($returnUrl, false), JText::_("COM_PHOCADOWNLOAD_NO_RIGHTS_ACCESS_CATEGORY_FILE")); exit; } } if (empty($filename)) { $outcome['file'] = "COM_PHOCADOWNLOAD_ERROR_NO_DB_RESULT"; $outcome['directlink'] = 0; $outcome['externallink'] = 0; return $outcome; } if ($type == 1) { // Unique download link } else { if (isset($filename[0]->access)) { if (!in_array($filename[0]->access, $user->getAuthorisedViewLevels())) { $app->redirect(JRoute::_($returnUrl, false), JText::_('COM_PHOCADOWNLOAD_PLEASE_LOGIN_DOWNLOAD_FILE')); exit; } } else { $outcome['file'] = "COM_PHOCADOWNLOAD_ERROR_NO_DB_RESULT"; $outcome['directlink'] = 0; $outcome['externallink'] = 0; return $outcome; } } // - - - - - - - - - - - - - - - - $filenameT = $filename[0]->filename; $directlinkT = $filename[0]->directlink; $linkExternalT = $filename[0]->link_external; // Unique Download Link if ($type == 1) { $directlinkT = 0; // Unique Download Link cannot work with direct link } $filePath = PhocaDownloadPath::getPathSet('file'); if ($filenameT != '') { // Important - you cannot use direct link if you have selected absolute path // Absolute Path defined by user $absolutePath = $params->get('absolute_path', ''); if ($absolutePath != '') { $directlinkT = 0; } if ($directlinkT == 1) { $relFile = JURI::base(true) . '/' . $params->get('download_folder', 'phocadownload') . '/' . $filenameT; $outcome['file'] = $relFile; $outcome['directlink'] = $directlinkT; $outcome['externallink'] = $linkExternalT; return $outcome; } else { if ($directlinkT == 0 && $linkExternalT != '') { $relFile = JURI::base(true) . '/' . $params->get('download_folder', 'phocadownload') . '/' . $filenameT; $outcome['file'] = $relFile; $outcome['directlink'] = $directlinkT; $outcome['externallink'] = $linkExternalT; return $outcome; } else { $absFile = str_replace('/', DS, JPath::clean($filePath['orig_abs_ds'] . $filenameT)); } } if (JFile::exists($absFile)) { $outcome['file'] = $absFile; $outcome['directlink'] = $directlinkT; $outcome['externallink'] = $linkExternalT; return $outcome; } else { $outcome['file'] = "COM_PHOCADOWNLOAD_ERROR_NO_ABS_FILE"; $outcome['directlink'] = 0; $outcome['externallink'] = $linkExternalT; return $outcome; } } else { $outcome['file'] = "COM_PHOCADOWNLOAD_ERROR_NO_DB_FILE"; $outcome['directlink'] = 0; $outcome['externallink'] = $linkExternalT; return $outcome; } }
define('DS', DIRECTORY_SEPARATOR); } if (!JFactory::getUser()->authorise('core.manage', 'com_phocadownload')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } if (!class_exists('PhocaDownloadLoader')) { require_once JPATH_ADMINISTRATOR . DS . 'components/com_phocadownload/libraries/loader.php'; } require_once JPATH_COMPONENT . DS . 'controller.php'; jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); phocadownloadimport('phocadownload.path.path'); phocadownloadimport('phocadownload.utils.utils'); phocadownloadimport('phocadownload.utils.settings'); phocadownloadimport('phocadownload.utils.exception'); phocadownloadimport('phocadownload.render.renderadmin'); phocadownloadimport('phocadownload.render.renderadminview'); phocadownloadimport('phocadownload.render.renderadminviews'); phocadownloadimport('phocadownload.html.category'); phocadownloadimport('phocadownload.html.jgrid'); phocadownloadimport('phocadownload.html.batch'); phocadownloadimport('phocadownload.file.file'); phocadownloadimport('phocadownload.file.fileupload'); phocadownloadimport('phocadownload.file.fileuploadmultiple'); phocadownloadimport('phocadownload.file.fileuploadsingle'); phocadownloadimport('phocadownload.category.category'); phocadownloadimport('phocadownload.tag.tag'); jimport('joomla.application.component.controller'); $controller = JControllerLegacy::getInstance('PhocaDownloadCp'); $controller->execute(JFactory::getApplication()->input->get('task')); $controller->redirect();
echo '<div class="tab-pane" id="mirror">' . "\n"; $formArray = array('mirror1link', 'mirror1title', 'mirror1target', 'mirror2link', 'mirror2title', 'mirror2target'); echo $r->group($this->form, $formArray); echo '</div>' . "\n"; echo '<div class="tab-pane" id="video">' . "\n"; $formArray = array('video_filename'); echo $r->group($this->form, $formArray); echo '</div>' . "\n"; echo '</div>'; //end tab content echo '</div>'; //end span10 // Second Column echo '<div class="span2">'; if (isset($this->item->id) && isset($this->item->catid) && isset($this->item->token) && (int) $this->item->id > 0 && (int) $this->item->catid > 0 && $this->item->token != '') { phocadownloadimport('phocadownload.path.route'); $downloadLink = PhocaDownloadRoute::getDownloadRoute((int) $this->item->id, (int) $this->item->catid, $this->item->token, 0); $app = JApplication::getInstance('site'); $router = $app->getRouter(); $uri = $router->build($downloadLink); $frontendUrl = JURI::root(false) . str_replace(JURI::root(true) . '/administrator/', '', $uri->toString()); echo '<div>' . JText::_('COM_PHOCADOWNLOAD_UNIQUE_DOWNLOAD_URL') . '</div>'; echo '<textarea rows="7">' . $frontendUrl . '</textarea>'; echo '<div><small>(' . JText::_('COM_PHOCADOWNLOAD_URL_FORMAT_DEPENDS_ON_SEF') . ')</small></div>'; } echo '</div>'; //end span2 echo $r->formInputs(); echo $r->endForm(); /* ?>
phocadownloadimport('phocadownload.path.path'); phocadownloadimport('phocadownload.path.route'); phocadownloadimport('phocadownload.render.layout'); phocadownloadimport('phocadownload.file.file'); phocadownloadimport('phocadownload.file.fileupload'); phocadownloadimport('phocadownload.file.fileuploadmultiple'); phocadownloadimport('phocadownload.file.fileuploadsingle'); phocadownloadimport('phocadownload.download.download'); phocadownloadimport('phocadownload.render.renderfront'); phocadownloadimport('phocadownload.rate.rate'); phocadownloadimport('phocadownload.stat.stat'); phocadownloadimport('phocadownload.mail.mail'); phocadownloadimport('phocadownload.pagination.pagination'); phocadownloadimport('phocadownload.ordering.ordering'); phocadownloadimport('phocadownload.access.access'); phocadownloadimport('phocadownload.category.category'); phocadownloadimport('phocadownload.user.user'); phocadownloadimport('phocadownload.log.log'); // Require specific controller if requested if ($controller = JRequest::getWord('controller')) { $path = JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php'; if (file_exists($path)) { require_once $path; } else { $controller = ''; } } $classname = 'PhocaDownloadController' . ucfirst($controller); $controller = new $classname(); $controller->execute(JFactory::getApplication()->input->get('task')); $controller->redirect();
define('DS', DIRECTORY_SEPARATOR); } jimport('joomla.plugin.plugin'); if (!JComponentHelper::isEnabled('com_phocadownload', true)) { return JError::raiseError(JText::_('PLG_CONTENT_PHOCADOWNLOAD_PHOCA_DOWNLOAD_ERROR'), JText::_('PLG_CONTENT_PHOCADOWNLOAD_PHOCA_DOWNLOAD_NOT_INSTALLED_ON_YOUR_SYSTEM')); } if (!class_exists('PhocaDownloadLoader')) { require_once JPATH_ADMINISTRATOR . '/components/com_phocadownload/libraries/loader.php'; } phocadownloadimport('phocadownload.utils.settings'); phocadownloadimport('phocadownload.path.path'); phocadownloadimport('phocadownload.path.route'); phocadownloadimport('phocadownload.file.file'); phocadownloadimport('phocadownload.utils.utils'); phocadownloadimport('phocadownload.render.layout'); phocadownloadimport('phocadownload.ordering.ordering'); class plgContentPhocaDownload extends JPlugin { public function __construct(&$subject, $config) { parent::__construct($subject, $config); $this->loadLanguage(); } public function onContentPrepare($context, &$article, &$params, $page = 0) { $document = JFactory::getDocument(); $db = JFactory::getDBO(); $iSize = $this->params->get('icon_size', 32); $iMime = $this->params->get('file_icon_mime', 0); $component = 'com_phocadownload'; $paramsC = JComponentHelper::getParams($component);
<?php /* * @package Joomla.Framework * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * * @component Phoca Component * @copyright Copyright (C) Jan Pavelka www.phoca.cz * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later; */ defined('_JEXEC') or die; phocadownloadimport('phocadownload.user.user'); class JFormFieldPhocaUsers extends JFormField { protected $type = 'PhocaUsers'; protected function getInput() { $userId = (string) $this->form->getValue($this->element['name']); return PhocaDownloadUser::usersList($this->name, $this->id, $userId, 1, NULL, 'name', 0); } }
phocadownloadimport('phocadownload.file.file'); phocadownloadimport('phocadownload.file.fileupload'); phocadownloadimport('phocadownload.file.fileuploadmultiple'); phocadownloadimport('phocadownload.file.fileuploadsingle'); phocadownloadimport('phocadownload.download.download'); phocadownloadimport('phocadownload.render.renderfront'); phocadownloadimport('phocadownload.rate.rate'); phocadownloadimport('phocadownload.stat.stat'); phocadownloadimport('phocadownload.mail.mail'); phocadownloadimport('phocadownload.pagination.pagination'); phocadownloadimport('phocadownload.ordering.ordering'); phocadownloadimport('phocadownload.access.access'); phocadownloadimport('phocadownload.category.category'); phocadownloadimport('phocadownload.user.user'); phocadownloadimport('phocadownload.log.log'); phocadownloadimport('phocadownload.utils.utils'); // Require specific controller if requested if($controller = JRequest::getWord('controller')) { $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php'; if (file_exists($path)) { require_once $path; } else { $controller = ''; } } $classname = 'PhocaDownloadController'.ucfirst($controller); $controller = new $classname( ); $controller->execute( JFactory::getApplication()->input->get('task') );