Ejemplo n.º 1
0
 function makeDownload()
 {
     global $Itemid;
     if ($this->_customer->_user->id < 1) {
         $this->setRedirect(JRoute::_($this->log_link, false));
         return;
     }
     $fileInfo = $this->_model->getfileinfo();
     DigiComSiteHelperDigiCom::checkUserAccessToFile($fileInfo, $this->_customer->_user->id);
     if (empty($fileInfo->url)) {
         $itemid = JFactory::getApplication()->input->get('itemid', 0);
         $msg = JText::sprintf('COM_DIGICOM_DOWNLOADS_FILE_DONT_EXIST_DETAILS', $fileInfo->name);
         JFactory::getApplication()->redirect('index.php?option=com_digicom&view=downloads&Itemid=' . $itemid, $msg);
     }
     $parsed = parse_url($fileInfo->url);
     if (empty($parsed['scheme'])) {
         $fileLink = JPATH_BASE . '/' . $fileInfo->url;
     } else {
         $fileLink = $fileInfo->url;
     }
     //update hits
     $files = JTable::getInstance('Files', 'Table');
     $files->load($fileInfo->id);
     $files->hits = $files->hits + 1;
     $files->store();
     $downloadfile = new DigiComSiteHelperDownloadFile($fileLink);
     if (!$downloadfile->df_download()) {
         $itemid = JFactory::getApplication()->input->get('itemid', 0);
         $msg = JText::sprintf("COM_DIGICOM_FILE_DOWNLOAD_FAILED", $fileInfo->name);
         JFactory::getApplication()->redirect('index.php?option=com_digicom&view=downloads&Itemid=' . $itemid, $msg);
     }
 }