public static function checkOSE($fileName) { if (file_exists(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php') && file_exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_ose_cpu'.DS.'define.php')) { require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); oseRegistry :: call('content')->checkAccess('phoca', 'category', $fileName->catid); } else if (file_exists(JPATH_ADMINISTRATOR . DS . "components" . DS . "com_osemsc" . DS . "warehouse" . DS . "api.php")) { require_once (JPATH_ADMINISTRATOR . DS . "components" . DS . "com_osemsc" . DS . "warehouse" . DS . "api.php"); $checkmsc = new OSEMSCAPI(); $checkmsc->ACLCheck("phoca", "cat", $fileName->catid, true); } }
function getDownload($id, $return) { global $mainframe; $user =& JFactory::getUser(); $aid = $user->get('aid', 0); $returnUrl = 'index.php?option=com_user&view=login&return='.base64_encode($return); $outcome = array(); $wheres[] = " c.id= ".(int)$id; // Get the file information and then check if it is possible for user download (so we can leave a message) //if ($aid !== null) { // $wheres[] = "c.access <= " . (int) $aid; //} $wheres[] = " c.published = 1"; $wheres[] = " c.approved = 1"; $wheres[] = " c.catid = cc.id"; // Active $jnow =& JFactory::getDate(); $now = $jnow->toMySQL(); $nullDate = $this->_db->getNullDate(); $wheres[] = ' ( c.publish_up = '.$this->_db->Quote($nullDate).' OR c.publish_up <= '.$this->_db->Quote($now).' )'; $wheres[] = ' ( c.publish_down = '.$this->_db->Quote($nullDate).' OR c.publish_down >= '.$this->_db->Quote($now).' )'; $paramsC = JComponentHelper::getParams('com_phocadownload') ; $pQ = $paramsC->get( 'enable_plugin_query', 0 ); 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.access, c.confirm_license, c.metakey, c.metadesc, cc.access as cataccess, cc.accessuserid as cataccessuserid ' .' FROM #__phocadownload AS c, #__phocadownload_categories AS cc ' . ($pQ == 1 ? ((count($joins)>0?( ' LEFT JOIN ' .implode( ' LEFT JOIN ', $joins )):'')):'') // GWE MOD . ' WHERE ' . implode( ' AND ', $wheres ) . ' ORDER BY c.ordering'; $filename = $this->_getList($query, 0, 1); //OSE Modified Start; if (!empty($filename)) { if (file_exists(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php') && file_exists(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_ose_cpu'.DS.'define.php')) { require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); oseRegistry :: call('content')->checkAccess('phoca', 'category', $filename[0]->catid); } elseif (file_exists(JPATH_ADMINISTRATOR . DS . "components" . DS . "com_osemsc" . DS . "warehouse" . DS . "api.php")) { require_once (JPATH_ADMINISTRATOR . DS . "components" . DS . "com_osemsc" . DS . "warehouse" . DS . "api.php"); $checkmsc = new OSEMSCAPI(); $checkmsc->ACLCheck("phoca", "cat", $filename[0]->catid, true); } } //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 (!empty($filename[0])) { $rightDisplay = PhocaDownloadHelper::getUserRight('accessuserid', $filename[0]->cataccessuserid, $filename[0]->cataccess, $user->get('aid', 0), $user->get('id', 0), 0); } // - - - - - - - - - - - - - - - - - - - - - - if ($rightDisplay == 0) { $mainframe->redirect(JRoute::_($returnUrl), JText::_("PHOCADOWNLOAD_NO_RIGHTS_ACCESS_CATEGORY_FILE")); exit; } if (empty($filename)) { $outcome['file'] = "PhocaErrorNoDBResult"; $outcome['directlink'] = 0; return $outcome; } if (isset($filename[0]->access)) { if ($aid !== null) { if ($filename[0]->access > (int) $aid) { //$mainframe->redirect(JRoute::_('index.php?option=com_user&view=login', false), JText::_("Please login to download the file")); $mainframe->redirect(JRoute::_($returnUrl), JText::_("Please login to download the file")); exit; } } else { $outcome['file'] = "PhocaErrorAidProblem"; $outcome['directlink'] = 0; return $outcome; } } else { $outcome['file'] = "PhocaErrorNoDBResult"; $outcome['directlink'] = 0; return $outcome; } // - - - - - - - - - - - - - - - - $this->_filename = $filename[0]->filename; $this->_directlink = $filename[0]->directlink; $filePath = PhocaDownloadHelper::getPathSet('file'); if ($this->_filename !='') { // Important - you cannot use direct link if you have selected absolute path // Absolute Path defined by user $absolutePath = PhocaDownloadHelper::getSettings('absolute_path', ''); if ($absolutePath != '') { $this->_directlink = 0; } if ($this->_directlink == 1 ) { $relFile = JURI::base(true).'/'.PhocaDownloadHelper::getSettings('download_folder', 'phocadownload' ).'/'.$this->_filename; $outcome['file'] = $relFile; $outcome['directlink'] = $this->_directlink; return $outcome; } else { $absFile = str_replace('/', DS, JPath::clean($filePath['orig_abs_ds'] . $this->_filename)); } if (JFile::exists($absFile)) { $outcome['file'] = $absFile; $outcome['directlink'] = $this->_directlink; return $outcome; } else { $outcome['file'] = "PhocaErrorNoAbsFile"; $outcome['directlink'] = 0; return $outcome; } } else { $outcome['file'] = "PhocaErrorNoDBFile"; $outcome['directlink'] = 0; return $outcome; } }