Ejemplo n.º 1
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $this->t['dw'] = PhocaDownloadRenderFront::renderPhocaDownload();
     $this->t['p'] = $app->getParams();
     $this->t['user'] = JFactory::getUser();
     $this->t['categories'] = $model->getCategoriesList();
     $this->t['mostvieweddocs'] = $model->getMostViewedDocsList($this->t['p']);
     $this->t['displaynew'] = $this->t['p']->get('display_new', 0);
     $this->t['displayhot'] = $this->t['p']->get('display_hot', 0);
     $this->t['displaymostdownload'] = $this->t['p']->get('display_most_download', 1);
     $this->t['displaynumdocsecs'] = $this->t['p']->get('display_num_doc_secs', 0);
     $this->t['displaynumdocsecsheader'] = $this->t['p']->get('display_num_doc_secs_header', 1);
     $this->t['file_icon_size_md'] = $this->t['p']->get('file_icon_size_md', 16);
     $this->t['download_metakey'] = $this->t['p']->get('download_metakey', '');
     $this->t['download_metadesc'] = $this->t['p']->get('download_metadesc', '');
     $this->t['description'] = $this->t['p']->get('description', '');
     $this->t['displaymaincatdesc'] = $this->t['p']->get('display_main_cat_desc', 0);
     $this->t['display_specific_layout'] = $this->t['p']->get('display_specific_layout', 0);
     PhocaDownloadRenderFront::renderAllCSS();
     $imagePath = PhocaDownloadPath::getPathSet('icon');
     $this->t['cssimgpath'] = str_replace('../', JURI::base(true) . '/', $imagePath['orig_rel_ds']);
     $filePath = PhocaDownloadPath::getPathSet('file');
     $this->t['absfilepath'] = $filePath['orig_abs_ds'];
     $this->_prepareDocument();
     parent::display($tpl);
 }
Ejemplo n.º 2
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $this->t = array();
     $this->t['user'] = JFactory::getUser();
     $uri = JFactory::getURI();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $fileId = $app->input->get('id', 0, 'int');
     $file = $model->getFile($fileId);
     $fileExt = '';
     $filePath = PhocaDownloadPath::getPathSet('fileplay');
     $filePath = str_replace('../', JURI::base(false) . '', $filePath['orig_rel_ds']);
     if (isset($file[0]->filename_play) && $file[0]->filename_play != '') {
         $fileExt = PhocaDownloadFile::getExtension($file[0]->filename_play);
         $canPlay = PhocaDownloadFile::canPlay($file[0]->filename_play);
         if ($canPlay) {
             $this->t['playfilewithpath'] = $filePath . $file[0]->filename_play;
             //$this->t['playerpath']		= JURI::base().'components/com_phocadownload/assets/jwplayer/';
             $this->t['playerpath'] = JURI::base() . 'components/com_phocadownload/assets/flowplayer/';
             $this->t['playerwidth'] = $params->get('player_width', 328);
             $this->t['playerheight'] = $params->get('player_height', 200);
             $this->t['html5_play'] = $params->get('html5_play', 0);
         } else {
             echo JText::_('COM_PHOCADOWNLOAD_ERROR_NO_CORRECT_FILE_TO_PLAY_FOUND');
             exit;
         }
     } else {
         echo JText::_('COM_PHOCADOWNLOAD_ERROR_NO_FILE_TO_PLAY_FOUND');
         exit;
     }
     $this->t['filetype'] = $fileExt;
     if ($fileExt == 'mp3') {
         $this->t['filetype'] = 'mp3';
         $this->t['playerheight'] = $params->get('player_mp3_height', 30);
     } else {
         if ($fileExt == 'ogg') {
             $this->t['filetype'] = 'ogg';
             $this->t['playerheight'] = $params->get('player_mp3_height', 30);
         }
     }
     $this->assignRef('file', $file);
     $this->assignRef('tmpl', $this->t);
     $this->assignRef('params', $params);
     $uriT = $uri->toString();
     $this->assignRef('request_url', $uriT);
     parent::display($tpl);
 }
Ejemplo n.º 3
0
 public function __construct()
 {
     if (empty($params)) {
         $this->params = JComponentHelper::getParams('com_phocadownload');
     }
     if ($this->filePath == '') {
         $this->filePath = PhocaDownloadPath::getPathSet('file');
     }
     if ($this->iconPath == '') {
         $this->iconPath = PhocaDownloadPath::getPathSet('icon');
     }
     if ($this->cssImagePath == '') {
         $this->cssImagePath = str_replace('../', JURI::base(true) . '/', $this->iconPath['orig_rel_ds']);
     }
     if ($this->fileAbsPath == '') {
         $this->fileAbsPath = $this->filePath['orig_abs_ds'];
     }
 }
Ejemplo n.º 4
0
	public static function realSingleUpload( $frontEnd = 0 ) {
		
		$paramsC 		= JComponentHelper::getParams('com_phocadownload');
	//	$chunkMethod 	= $paramsC->get( 'multiple_upload_chunk', 0 );
	//	$uploadMethod 	= $paramsC->get( 'multiple_upload_method', 4 );
	
		$overwriteExistingFiles 	= $paramsC->get( 'overwrite_existing_files', 0 );
		
		$app			= JFactory::getApplication();
		JRequest::checkToken( 'request' ) or jexit( 'ERROR: '. JTEXT::_('COM_PHOCADOWNLOAD_INVALID_TOKEN'));
		JResponse::allowCache(false);
		
		
		$file 			= JRequest::getVar( 'Filedata', '', 'files', 'array' );
		$folder			= JRequest::getVar( 'folder', '', '', 'path' );
		$format			= JRequest::getVar( 'format', 'html', '', 'cmd');
		$return			= JRequest::getVar( 'return-url', null, 'post', 'base64' );//includes field
		$viewBack		= JRequest::getVar( 'viewback', '', '', '' );
		$manager		= JRequest::getVar( 'manager', 'file', '', 'string' );
		$tab			= JRequest::getVar( 'tab', '', '', 'string' );
		$field			= JRequest::getVar( 'field' );
		$errUploadMsg	= '';
		$folderUrl 		= $folder;
		$tabUrl			= '';
		$component		= JRequest::getVar( 'option', '', '', 'string' );
		
		$path	= PhocaDownloadPath::getPathSet($manager);// we use viewback to get right path
	
		
		// In case no return value will be sent (should not happen)
		if ($component != '' && $frontEnd == 0) {
			$componentUrl 	= 'index.php?option='.$component;
		} else {
			$componentUrl	= 'index.php';
		}
		if ($tab != '') {
			$tabUrl = '&tab='.(string)$tab;
		}
		
		$ftp = JClientHelper::setCredentialsFromRequest('ftp');
		
		// Make the filename safe
		if (isset($file['name'])) {
			$file['name']	= JFile::makeSafe($file['name']);
		}
		
		
		if (isset($folder) && $folder != '') {
			$folder	= $folder . DS;
		}
		
		
		// All HTTP header will be overwritten with js message
		if (isset($file['name'])) {
			$filepath = JPath::clean($path['orig_abs_ds'].$folder.strtolower($file['name']));
			$filepath = JPath::clean($path['orig_abs_ds'].$folder.$file['name']);

			if (!PhocaDownloadFileUpload::canUpload( $file, $errUploadMsg, $manager, $frontEnd )) {
				
				if ($errUploadMsg == 'COM_PHOCADOWNLOAD_WARNING_FILE_TOOLARGE') {
					$errUploadMsg 	= JText::_($errUploadMsg) . ' ('.PhocaDownloadFileUpload::getFileSizeReadable($file['size']).')';
				} /* else if ($errUploadMsg == 'COM_PHOCADOWNLOAD_WARNING_FILE_TOOLARGE_RESOLUTION') {
					$imgSize		= phocadownloadImage::getImageSize($file['tmp_name']);
					$errUploadMsg 	= JText::_($errUploadMsg) . ' ('.(int)$imgSize[0].' x '.(int)$imgSize[1].' px)';
				} */ else {
					$errUploadMsg 	= JText::_($errUploadMsg);
				}
			
			
				if ($return) {
					$app->enqueueMessage( $errUploadMsg, 'error');
					$app->redirect(base64_decode($return).'&manager='.(string)$manager.'&folder='.$folderUrl);
					exit;
				} else {
					$app->enqueueMessage( $errUploadMsg, 'error');
					$app->redirect($componentUrl, $errUploadMsg);
					exit;
				}
			}

			if (JFile::exists($filepath) && $overwriteExistingFiles == 0) {
				if ($return) {
					$app->redirect(base64_decode($return).'&manager='.(string)$manager.'&folder='.$folderUrl, JText::_('COM_PHOCADOWNLOAD_FILE_ALREADY_EXISTS'), 'error');
					exit;
				} else {
					$app->enqueueMessage( JText::_('COM_PHOCADOWNLOAD_FILE_ALREADY_EXISTS'), 'error');
					$app->redirect($componentUrl);
					exit;
				}
			}

			if (!JFile::upload($file['tmp_name'], $filepath, false, true)) {
				if ($return) {
					$app->enqueueMessage( JText::_('COM_PHOCADOWNLOAD_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error');
					$app->redirect(base64_decode($return).'&manager='.(string)$manager.'&folder='.$folderUrl);
					exit;
				} else {
					$app->enqueueMessage( JText::_('COM_PHOCADOWNLOAD_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error');
					$app->redirect($componentUrl);
					exit;
				}
			} else {
			
				if ((int)$frontEnd > 0) {
					return $file['name'];
				}
			
				if ($return) {
					$app->enqueueMessage( JText::_('COM_PHOCADOWNLOAD_SUCCESS_FILE_UPLOAD'));
					$app->redirect(base64_decode($return).'&manager='.(string)$manager.'&folder='.$folderUrl);
					exit;
				} else {
					$app->enqueueMessage( JText::_('COM_PHOCADOWNLOAD_SUCCESS_FILE_UPLOAD'));
					$app->redirect($componentUrl);
					exit;
				}
			}
		} else {
			$msg = JText::_('COM_PHOCADOWNLOAD_ERROR_UNABLE_TO_UPLOAD_FILE');
			if ($return) {
				$app->enqueueMessage( $msg, 'error');
				$app->redirect(base64_decode($return).'&manager='.(string)$manager.'&folder='.$folderUrl);
				exit;
			} else {
				if($viewBack != '') {
					$group 	= PhocaDownloadSettings::getManagerGroup($manager);
					$link	= 'index.php?option=com_phocadownload&view=phocadownloadmanager&manager='.(string)$manager
							.str_replace('&', '&', $group['c']).'&'.$tabUrl.'&folder='.$folder.'&field='.$field;
					$app->enqueueMessage( $msg, 'error');
					$app->redirect($link);
				} else {
					$app->enqueueMessage( $msg, 'error');
					$app->redirect('index.php?option=com_phocadownload');
				}
					
			}
		}
		
	}
Ejemplo n.º 5
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $this->t['p'] = $app->getParams();
     $this->t['user'] = JFactory::getUser();
     $uri = JFactory::getURI();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $downloadToken = $app->input->get('id', '', 'string');
     // Token string
     $this->t['limitstart'] = $app->input->get('start', 0, 'int');
     // we need it for category back link
     $this->t['tmpl'] = $app->input->get('tmpl', '', 'string');
     $this->t['mediapath'] = PhocaDownloadPath::getPathMedia();
     $this->t['tmplr'] = 0;
     if ($this->t['tmpl'] == 'component') {
         $this->t['tmplr'] = 1;
     }
     if ($this->t['limitstart'] > 0) {
         $this->t['limitstarturl'] = '&start=' . $this->t['limitstart'];
     } else {
         $this->t['limitstarturl'] = '';
     }
     //$this->category			= $model->getCategory($fileId);
     //$this->file				= $model->getFile($fileId, $this->t['limitstarturl']);
     // Params
     $this->t['licenseboxheight'] = $this->t['p']->get('license_box_height', 300);
     $this->t['filename_or_name'] = $this->t['p']->get('filename_or_name', 'filename');
     $this->t['allowed_file_types'] = $this->t['p']->get('allowed_file_types', '');
     $this->t['disallowed_file_types'] = $this->t['p']->get('disallowed_file_types', '');
     $this->t['enable_user_statistics'] = $this->t['p']->get('enable_user_statistics', 1);
     $this->t['file_icon_size'] = $this->t['p']->get('file_icon_size', 16);
     $this->t['pw'] = PhocaDownloadRenderFront::renderPhocaDownload();
     $this->t['download_external_link'] = $this->t['p']->get('download_external_link', '_self');
     $this->t['display_report_link'] = $this->t['p']->get('display_report_link', 0);
     $this->t['send_mail_download'] = $this->t['p']->get('send_mail_download', 0);
     // not boolean but id of user
     $this->t['display_specific_layout'] = $this->t['p']->get('display_specific_layout', 0);
     $this->t['displaynew'] = $this->t['p']->get('display_new', 0);
     $this->t['displayhot'] = $this->t['p']->get('display_hot', 0);
     $this->t['enable_token_download'] = $this->t['p']->get('enable_token_download', 0);
     PhocaDownloadRenderFront::renderAllCSS();
     $this->t['found'] = 0;
     if ($this->t['enable_token_download'] == 0) {
         $this->t['found'] = 0;
     } else {
         if ($downloadToken == '') {
             $this->t['found'] = 0;
         } else {
             $this->file = $model->getFile($downloadToken);
             if (isset($this->file[0]->id) && (int) $this->file[0]->id > 0 && isset($this->file[0]->token) & $this->file[0]->token != '') {
                 $this->t['found'] = 1;
             }
             /*$document->addCustomTag('<script type="text/javascript" src="'.JURI::root().'components/com_phocadownload/assets/overlib/overlib_mini.js"></script>');
             		$js	= 'var enableDownloadButtonPD = 0;'
             			 .'function enableDownloadPD() {'
             			 .' if (enableDownloadButtonPD == 0) {'
             			 .'   document.forms[\'phocadownloadform\'].elements[\'pdlicensesubmit\'].disabled=false;'
             			 .'   enableDownloadButtonPD = 1;'
             			 .' } else {'
             			 .'   document.forms[\'phocadownloadform\'].elements[\'pdlicensesubmit\'].disabled=true;'
             			 .'   enableDownloadButtonPD = 0;'
             			 .' }'
             			 .'}';
             		$document->addScriptDeclaration($js);*/
             // DOWNLOAD
             // - - - - - - - - - - - - - - -
             $download = $app->input->get('download', 0, 'int');
             //$licenseAgree			= $app->input->get( 'license_agree', '', 'string' );
             $downloadId = (int) $this->file[0]->id;
             if ($download == 1) {
                 if (isset($this->file[0]->id)) {
                     $currentLink = 'index.php?option=com_phocadownload&view=download&id=' . htmlspecialchars($downloadToken) . $this->t['limitstarturl'] . '&Itemid=' . $app->input->get('Itemid', 0, 'int');
                 } else {
                     $currentLink = 'index.php?option=com_phocadownload&view=categories&Itemid=' . $app->input->get('Itemid', 0, 'int');
                 }
                 // Check Token
                 $token = JSession::getFormToken();
                 if (!JRequest::getInt($token, 0, 'get')) {
                     //JError::raiseError(403, 'Request Forbidden');
                     $app->redirect(JRoute::_('index.php', false), JText::_('COM_PHOCADOWNLOAD_INVALID_TOKEN'));
                     exit;
                 }
                 // Check License Agreement
                 /*if (empty($licenseAgree)) {
                 			$app->redirect(JRoute::_($currentLink, false), JText::_('COM_PHOCADOWNLOAD_WARNING_AGREE_LICENSE_TERMS'));
                 			exit;
                 		}*/
                 $fileData = PhocaDownloadDownload::getDownloadData($downloadId, $currentLink, 1);
                 PhocaDownloadDownload::download($fileData, $downloadId, $currentLink, 1);
             }
             // - - - - - - - - - - - - - - -
             /*$imagePath				= PhocaDownloadPath::getPathSet('icon');
             		$this->t['cssimgpath']	= str_replace ( '../', JURI::base(true).'/', $imagePath['orig_rel_ds']);
             		$filePath				= PhocaDownloadPath::getPathSet('file');
             		$this->t['absfilepath']	= $filePath['orig_abs_ds'];
             		$this->t['action']		= $uri->toString();	
             		
             		if (isset($this->category[0]) && is_object($this->category[0]) && isset($this->file[0]) && is_object($this->file[0])){
             			$this->_prepareDocument($this->category[0], $this->file[0]);
             		}*/
         }
     }
     parent::display($tpl);
 }
Ejemplo n.º 6
0
         $playLink = JRoute::_(PhocaDownloadRoute::getFileRoute($v->id, $v->catid, $v->alias, $v->categoryalias, 0, 'play') . $this->t['limitstarturl']);
         $pdButtonPlay .= '<div class="pd-button-play">';
         if ($this->t['play_popup_window'] == 1) {
             $pdButtonPlay .= '<a class="btn btn-danger"  href="' . $playLink . '" onclick="' . $buttonPlOptions . '" >' . JText::_('COM_PHOCADOWNLOAD_PLAY') . '</a>';
         } else {
             $pdButtonPlay .= '<a class="btn btn-danger pd-modal-button" href="' . $playLink . '" rel="' . $buttonPlOptions . '" >' . JText::_('COM_PHOCADOWNLOAD_PLAY') . '</a>';
         }
         $pdButtonPlay .= '</div>';
     }
 }
 // pdbuttonpreview
 $pdButtonPreview = '';
 if (isset($v->filename_preview) && $v->filename_preview != '') {
     $fileExt = PhocaDownloadFile::getExtension($v->filename_preview);
     if ($fileExt == 'pdf' || $fileExt == 'jpeg' || $fileExt == 'jpg' || $fileExt == 'png' || $fileExt == 'gif') {
         $filePath = PhocaDownloadPath::getPathSet('filepreview');
         $filePath = str_replace('../', JURI::base(true) . '/', $filePath['orig_rel_ds']);
         $previewLink = $filePath . $v->filename_preview;
         $pdButtonPreview .= '<div class="pd-button-preview">';
         if ($this->t['preview_popup_window'] == 1) {
             $pdButtonPreview .= '<a  class="btn btn-warning" href="' . $previewLink . '" onclick="' . $this->t['buttonpr']->options . '" >' . JText::_('COM_PHOCADOWNLOAD_PREVIEW') . '</a>';
         } else {
             if ($fileExt == 'pdf') {
                 // Iframe - modal
                 $pdButtonPreview .= '<a class="btn btn-warning pd-modal-button" href="' . $previewLink . '" rel="' . $this->t['buttonpr']->options . '" >' . JText::_('COM_PHOCADOWNLOAD_PREVIEW') . '</a>';
             } else {
                 // Image - modal
                 $pdButtonPreview .= '<a class="btn btn-warning pd-modal-button" href="' . $previewLink . '" rel="' . $this->t['buttonpr']->optionsimg . '" >' . JText::_('COM_PHOCADOWNLOAD_PREVIEW') . '</a>';
             }
         }
         $pdButtonPreview .= '</div>';
Ejemplo n.º 7
0
 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);
     $ordering = $paramsC->get('file_ordering', 1);
     // Start Plugin
     $regex_one = '/({phocadownload\\s*)(.*?)(})/si';
     $regex_all = '/{phocadownload\\s*.*?}/si';
     $matches = array();
     $count_matches = preg_match_all($regex_all, $article->text, $matches, PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER);
     JHTML::stylesheet('media/com_phocadownload/css/main/phocadownload.css');
     JHTML::stylesheet('media/plg_content_phocadownload/css/phocadownload.css');
     // Start if count_matches
     if ($count_matches != 0) {
         $l = new PhocaDownloadLayout();
         // Start CSS
         for ($i = 0; $i < $count_matches; $i++) {
             $view = '';
             $id = '';
             $text = '';
             $target = '';
             $playerwidth = $paramsC->get('player_width', 328);
             $playerheight = $paramsC->get('player_height', 200);
             $previewwidth = $paramsC->get('preview_width', 640);
             $previewheight = $paramsC->get('preview_height', 480);
             $playerheightmp3 = $paramsC->get('player_mp3_height', 30);
             $url = '';
             $youtubewidth = 448;
             $youtubeheight = 336;
             $fileView = $paramsC->get('display_file_view', 0);
             $previewWindow = $paramsC->get('preview_popup_window', 0);
             $playWindow = $paramsC->get('play_popup_window', 0);
             $limit = 5;
             // Get plugin parameters
             $phocadownload = $matches[0][$i][0];
             preg_match($regex_one, $phocadownload, $phocadownload_parts);
             $parts = explode("|", $phocadownload_parts[2]);
             $values_replace = array("/^'/", "/'\$/", "/^&#39;/", "/&#39;\$/", "/<br \\/>/");
             foreach ($parts as $key => $value) {
                 $values = explode("=", $value, 2);
                 foreach ($values_replace as $key2 => $values2) {
                     $values = preg_replace($values2, '', $values);
                 }
                 // Get plugin parameters from article
                 if ($values[0] == 'view') {
                     $view = $values[1];
                 } else {
                     if ($values[0] == 'id') {
                         $id = $values[1];
                     } else {
                         if ($values[0] == 'text') {
                             $text = $values[1];
                         } else {
                             if ($values[0] == 'target') {
                                 $target = $values[1];
                             } else {
                                 if ($values[0] == 'playerwidth') {
                                     $playerwidth = (int) $values[1];
                                 } else {
                                     if ($values[0] == 'playerheight') {
                                         $playerheight = (int) $values[1];
                                     } else {
                                         if ($values[0] == 'playerheightmp3') {
                                             $playerheightmp3 = (int) $values[1];
                                         } else {
                                             if ($values[0] == 'previewwidth') {
                                                 $previewwidth = (int) $values[1];
                                             } else {
                                                 if ($values[0] == 'previewheight') {
                                                     $previewheight = (int) $values[1];
                                                 } else {
                                                     if ($values[0] == 'youtubewidth') {
                                                         $youtubewidth = (int) $values[1];
                                                     } else {
                                                         if ($values[0] == 'youtubeheight') {
                                                             $youtubeheight = (int) $values[1];
                                                         } else {
                                                             if ($values[0] == 'previewwindow') {
                                                                 $previewWindow = (int) $values[1];
                                                             } else {
                                                                 if ($values[0] == 'playwindow') {
                                                                     $playWindow = (int) $values[1];
                                                                 } else {
                                                                     if ($values[0] == 'limit') {
                                                                         $limit = (int) $values[1];
                                                                     } else {
                                                                         if ($values[0] == 'url') {
                                                                             $url = $values[1];
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             switch ($target) {
                 case 'b':
                     $targetOutput = 'target="_blank" ';
                     break;
                 case 't':
                     $targetOutput = 'target="_top" ';
                     break;
                 case 'p':
                     $targetOutput = 'target="_parent" ';
                     break;
                 case 's':
                     $targetOutput = 'target="_self" ';
                     break;
                 default:
                     $targetOutput = '';
                     break;
             }
             $output = '';
             /*
             //Itemid
             $menu 		=& JSite::getMenu();
             $itemSection= $menu->getItems('link', 'index.php?option=com_phocadownload&view=sections');
             if(isset($itemSection[0])) {
             	$itemId = $itemSection[0]->id;
             } else {
             	$itemId = JRequest::getVar('Itemid', 1, 'get', 'int');
             }
             */
             switch ($view) {
                 /*
                 // - - - - - - - - - - - - - - - -
                 // SECTIONS
                 // - - - - - - - - - - - - - - - -
                 case 'sections':						
                 	if ($text !='') {
                 		$textOutput = $text;
                 	} else {
                 		$textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_SECTIONS');
                 	}
                 	
                 	$link = PhocaDownloadRoute::getSectionsRoute();
                 	
                 	$output .= '<div class="phocadownloadsections'.(int)$iSize.'"><a href="'. JRoute::_($link).'" '.$targetOutput.'>'. $textOutput.'</a></div>';
                 break;
                 
                 // - - - - - - - - - - - - - - - -
                 // SECTION
                 // - - - - - - - - - - - - - - - -
                 case 'section':
                 	if ((int)$id > 0) {
                 		$query = 'SELECT a.id, a.title, a.alias,'
                 		. ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug'
                 		. ' FROM #__phocadownload_sections AS a'
                 		. ' WHERE a.id = '.(int)$id;
                 		
                 		$db->setQuery($query);
                 		$item = $db->loadObject();
                 		
                 		if (isset($item->id) && isset($item->slug)) {
                 			
                 			if ($text !='') {
                 				$textOutput = $text;
                 			} else if (isset($item->title) && $item->title != '') {
                 				$textOutput = $item->title;
                 			} else {
                 				$textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_SECTION');
                 			}
                 			$link = PhocaDownloadRoute::getSectionRoute($item->id, $item->alias);
                 			// 'index.php?option=com_phocadownload&view=section&id='.$item->slug.'&Itemid='. $itemId
                 			
                 			$output .= '<div class="phocadownloadsection'.(int)$iSize.'"><a href="'. JRoute::_($link).'" '.$targetOutput.'>'. $textOutput.'</a></div>';
                 		}
                 	}
                 break;
                 */
                 // - - - - - - - - - - - - - - - -
                 // CATEGORIES
                 // - - - - - - - - - - - - - - - -
                 case 'categories':
                     if ($text != '') {
                         $textOutput = $text;
                     } else {
                         $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_CATEGORIES');
                     }
                     $link = PhocaDownloadRoute::getCategoriesRoute();
                     $output .= '<div class="phocadownloadcategories' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>';
                     break;
                     // - - - - - - - - - - - - - - - -
                     // CATEGORY
                     // - - - - - - - - - - - - - - - -
                 // - - - - - - - - - - - - - - - -
                 // CATEGORY
                 // - - - - - - - - - - - - - - - -
                 case 'category':
                     if ((int) $id > 0) {
                         $query = 'SELECT a.id, a.title, a.alias,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug' . ' FROM #__phocadownload_categories AS a' . ' WHERE a.id = ' . (int) $id;
                         $db->setQuery($query);
                         $item = $db->loadObject();
                         if (isset($item->id) && isset($item->slug)) {
                             if ($text != '') {
                                 $textOutput = $text;
                             } else {
                                 if (isset($item->title) && $item->title != '') {
                                     $textOutput = $item->title;
                                 } else {
                                     $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_CATEGORY');
                                 }
                             }
                             $link = PhocaDownloadRoute::getCategoryRoute($item->id, $item->alias);
                             //'index.php?option=com_phocadownload&view=category&id='.$item->slug.'&Itemid='. $itemId
                             $output .= '<div class="phocadownloadcategory' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>';
                         }
                     }
                     break;
                     // - - - - - - - - - - - - - - - -
                     // FILELIST
                     // - - - - - - - - - - - - - - - -
                 // - - - - - - - - - - - - - - - -
                 // FILELIST
                 // - - - - - - - - - - - - - - - -
                 case 'filelist':
                     $fileOrdering = PhocaDownloadOrdering::getOrderingText($ordering);
                     $query = 'SELECT a.id, a.title, a.alias, a.filename_play, a.filename_preview, a.link_external, a.image_filename, a.filename, c.id as catid, a.confirm_license, c.title as cattitle, c.alias as catalias,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug' . ' FROM #__phocadownload AS a' . ' LEFT JOIN #__phocadownload_categories AS c ON a.catid = c.id';
                     if ((int) $id > 0) {
                         $query .= ' WHERE c.id = ' . (int) $id;
                         //$query .= ' WHERE c.id = '.(int)$id . ' AND a.published = 1 AND a.approved = 1';
                     } else {
                         //$query .= ' WHERE a.published = 1 AND a.approved = 1';
                     }
                     $query .= ' ORDER BY a.' . $fileOrdering;
                     $query .= ' LIMIT 0, ' . (int) $limit;
                     $db->setQuery($query);
                     $items = $db->loadObjectList();
                     if (!empty($items)) {
                         $output .= '<div class="phocadownloadfilelist">';
                         foreach ($items as $item) {
                             $imageFileName = $l->getImageFileName($item->image_filename, $item->filename, 3, (int) $iSize);
                             if (isset($item->id) && isset($item->slug) && isset($item->catid) && isset($item->catslug)) {
                                 if ($text != '') {
                                     $textOutput = $text;
                                 } else {
                                     if (isset($item->title) && $item->title != '') {
                                         $textOutput = $item->title;
                                     } else {
                                         $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_FILE');
                                     }
                                 }
                                 if (isset($item->confirm_license) && $item->confirm_license > 0 || $fileView == 1) {
                                     $link = PhocaDownloadRoute::getFileRoute($item->id, $item->catid, $item->alias, $item->catalias, 0, 'file');
                                     if ($iMime == 1) {
                                         $output .= '<div class="pd-filename phocadownloadfilelistitem phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div></div>';
                                     } else {
                                         $output .= '<div class="phocadownloadfilelist' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>';
                                     }
                                 } else {
                                     if ($item->link_external != '') {
                                         $link = $item->link_external;
                                     } else {
                                         $link = PhocaDownloadRoute::getFileRoute($item->id, $item->catid, $item->alias, $item->catalias, 0, 'download');
                                     }
                                     if ($iMime == 1) {
                                         $output .= '<div class="pd-filename phocadownloadfilelistitem phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div></div>';
                                     } else {
                                         $output .= '<div class="phocadownloadfilelist' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>';
                                     }
                                 }
                             }
                         }
                         $output .= '</div>';
                     }
                     break;
                     // - - - - - - - - - - - - - - - -
                     // FILE
                     // - - - - - - - - - - - - - - - -
                 // - - - - - - - - - - - - - - - -
                 // FILE
                 // - - - - - - - - - - - - - - - -
                 case 'file':
                 case 'fileplay':
                 case 'fileplaylink':
                 case 'filepreviewlink':
                     if ((int) $id > 0) {
                         $query = 'SELECT a.id, a.title, a.alias, a.filename_play, a.filename_preview, a.link_external, a.image_filename, a.filename, c.id as catid, a.confirm_license, c.title as cattitle, c.alias as catalias,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug' . ' FROM #__phocadownload AS a' . ' LEFT JOIN #__phocadownload_categories AS c ON a.catid = c.id' . ' WHERE a.id = ' . (int) $id;
                         $db->setQuery($query);
                         $item = $db->loadObject();
                         if (isset($item->id) && isset($item->slug) && isset($item->catid) && isset($item->catslug)) {
                             if ($text != '') {
                                 $textOutput = $text;
                             } else {
                                 if (isset($item->title) && $item->title != '') {
                                     $textOutput = $item->title;
                                 } else {
                                     if ($view == 'fileplay') {
                                         $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_PLAY_FILE');
                                     } else {
                                         $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_DOWNLOAD_FILE');
                                     }
                                 }
                             }
                             $imageFileName = $l->getImageFileName($item->image_filename, $item->filename, 3, (int) $iSize);
                             // - - - - -
                             // PLAY
                             // - - - - -
                             if ($view == 'fileplay') {
                                 $play = 1;
                                 $fileExt = '';
                                 $filePath = PhocaDownloadPath::getPathSet('fileplay');
                                 $filePath = str_replace('../', JURI::base(true) . '/', $filePath['orig_rel_ds']);
                                 if (isset($item->filename_play) && $item->filename_play != '') {
                                     $fileExt = PhocaDownloadFile::getExtension($item->filename_play);
                                     $canPlay = PhocaDownloadFile::canPlay($item->filename_play);
                                     if ($canPlay) {
                                         $tmpl['playfilewithpath'] = $filePath . $item->filename_play;
                                         $tmpl['playerpath'] = JURI::base() . 'components/com_phocadownload/assets/flowplayer/';
                                     } else {
                                         $output .= JText::_('PLG_CONTENT_PHOCADOWNLOAD_NO_CORRECT_FILE_FOR_PLAYING_FOUND');
                                         $play = 0;
                                     }
                                 } else {
                                     $output .= JText::_('PLG_CONTENT_PHOCADOWNLOAD_NO_FILE_FOR_PLAYING_FOUND');
                                     $play = 0;
                                 }
                                 if ($play == 1) {
                                     //Correct MP3
                                     $tmpl['filetype'] = '';
                                     if ($fileExt == 'mp3') {
                                         $tmpl['filetype'] = 'mp3';
                                         $playerheight = $playerheightmp3;
                                     }
                                     $versionFLP = '3.2.2';
                                     $versionFLPJS = '3.2.2';
                                     //Flow Player
                                     $document->addScript($tmpl['playerpath'] . 'flowplayer-' . $versionFLPJS . '.min.js');
                                     $output .= '<div style="text-align:center;margin: 10px auto">' . "\n" . '<div style="margin: 0 auto;text-align:center; width:' . $playerwidth . 'px"><a href="' . $tmpl['playfilewithpath'] . '"  style="display:block;width:' . $playerwidth . 'px;height:' . $playerheight . 'px" id="pdplayer' . $i . '"></a>' . "\n";
                                     if ($tmpl['filetype'] == 'mp3') {
                                         $output .= '<script type="text/javascript">' . "\n" . 'window.addEvent("domready", function() {' . "\n" . 'flowplayer("pdplayer' . $i . '", "' . $tmpl['playerpath'] . 'flowplayer-' . $versionFLP . '.swf",' . '{ ' . "\n" . ' clip: { ' . "\n" . '		url: \'' . $tmpl['playfilewithpath'] . '\',' . "\n" . '		autoPlay: false' . "\n" . '	}, ' . "\n" . '	plugins: { ' . "\n" . '		controls: { ' . "\n" . '			fullscreen: false, ' . "\n" . '			height: ' . $playerheight . "\n" . '		} ' . "\n" . '	} ' . "\n" . '} ' . "\n" . ');' . "\n" . '});' . '</script>' . "\n";
                                     } else {
                                         $output .= '<script type="text/javascript">' . "\n" . 'window.addEvent("domready", function() {' . "\n" . 'flowplayer("pdplayer' . $i . '", "' . $tmpl['playerpath'] . 'flowplayer-' . $versionFLP . '.swf",' . "\n" . '{ ' . "\n" . ' clip: { ' . "\n" . '		url: \'' . $tmpl['playfilewithpath'] . '\',' . "\n" . '		autoPlay: false,' . "\n" . '		autoBuffering: true' . "\n" . '	}, ' . "\n" . '} ' . "\n" . ');' . "\n" . '});' . '</script>' . "\n";
                                     }
                                     $output .= '</div></div>' . "\n";
                                 }
                             } else {
                                 if ($view == 'fileplaylink') {
                                     // PLAY - - - - - - - - - - - -
                                     $windowWidthPl = (int) $playerwidth + 30;
                                     $windowHeightPl = (int) $playerheight + 30;
                                     $windowHeightPlMP3 = (int) $playerheightmp3 + 30;
                                     //$playWindow 	= $paramsC->get( 'play_popup_window', 0 );
                                     if ($playWindow == 1) {
                                         $buttonPl = new JObject();
                                         $buttonPl->set('methodname', 'js-button');
                                         $buttonPl->set('options', "window.open(this.href,'win2','width=" . $windowWidthPl . ",height=" . $windowHeightPl . ",scrollbars=yes,menubar=no,resizable=yes'); return false;");
                                         $buttonPl->set('optionsmp3', "window.open(this.href,'win2','width=" . $windowWidthPl . ",height=" . $windowHeightPlMP3 . ",scrollbars=yes,menubar=no,resizable=yes'); return false;");
                                     } else {
                                         JHTML::_('behavior.modal', 'a.modal-button');
                                         $document->addCustomTag("<style type=\"text/css\"> \n" . " #sbox-window.phocadownloadplaywindow   {background-color:#fff;padding:2px} \n" . " #sbox-overlay.phocadownloadplayoverlay  {background-color:#000;} \n" . " </style> \n");
                                         $buttonPl = new JObject();
                                         $buttonPl->set('name', 'image');
                                         $buttonPl->set('modal', true);
                                         $buttonPl->set('methodname', 'modal-button');
                                         $buttonPl->set('options', "{handler: 'iframe', size: {x: " . $windowWidthPl . ", y: " . $windowHeightPl . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadplaywindow', classOverlay: 'phocadownloadplayoverlay'}");
                                         $buttonPl->set('optionsmp3', "{handler: 'iframe', size: {x: " . $windowWidthPl . ", y: " . $windowHeightPlMP3 . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadplaywindow', classOverlay: 'phocadownloadplayoverlay'}");
                                     }
                                     // - - - - - - - - - - - - - - -
                                     $fileExt = '';
                                     $filePath = PhocaDownloadPath::getPathSet('fileplay');
                                     $filePath = str_replace('../', JURI::base(true) . '/', $filePath['orig_rel_ds']);
                                     if (isset($item->filename_play) && $item->filename_play != '') {
                                         $fileExt = PhocaDownloadFile::getExtension($item->filename_play);
                                         $canPlay = PhocaDownloadFile::canPlay($item->filename_play);
                                         if ($canPlay) {
                                             // Special height for music only
                                             $buttonPlOptions = $buttonPl->options;
                                             if ($fileExt == 'mp3') {
                                                 $buttonPlOptions = $buttonPl->optionsmp3;
                                             }
                                             /*if ($text == '') {
                                             			$text = JText::_('PLG_CONTENT_PHOCADOWNLOAD_PLAY');
                                             		}*/
                                             if ($text != '') {
                                                 $textOutput = $text;
                                                 //} else if (isset($item->title) && $item->title != '') {
                                                 //	$textOutput = $item->title;
                                             } else {
                                                 $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_PLAY');
                                             }
                                             $playLink = JRoute::_(PhocaDownloadRoute::getFileRoute($item->id, $item->catid, $item->alias, $item->catalias, 0, 'play'));
                                             if ($iMime == 1) {
                                                 $output .= '<div class="pd-filename phocadownloadfile phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '>';
                                             } else {
                                                 $output .= '<div><div class="phocadownloadplay' . (int) $iSize . '">';
                                             }
                                             if ($playWindow == 1) {
                                                 $output .= '<a  href="' . $playLink . '" onclick="' . $buttonPlOptions . '" >' . $textOutput . '</a>';
                                             } else {
                                                 $output .= '<a class="modal-button" href="' . $playLink . '" rel="' . $buttonPlOptions . '" >' . $textOutput . '</a>';
                                             }
                                             $output .= '</div></div>';
                                         }
                                     } else {
                                         $output .= JText::_('PLG_CONTENT_PHOCADOWNLOAD_NO_FILE_FOR_PLAYING_FOUND');
                                     }
                                 } else {
                                     if ($view == 'filepreviewlink') {
                                         if (isset($item->filename_preview) && $item->filename_preview != '') {
                                             $fileExt = PhocaDownloadFile::getExtension($item->filename_preview);
                                             if ($fileExt == 'pdf' || $fileExt == 'jpeg' || $fileExt == 'jpg' || $fileExt == 'png' || $fileExt == 'gif') {
                                                 $filePath = PhocaDownloadPath::getPathSet('filepreview');
                                                 $filePath = str_replace('../', JURI::base(true) . '/', $filePath['orig_rel_ds']);
                                                 $previewLink = $filePath . $item->filename_preview;
                                                 //$previewWindow 	= $paramsC->get( 'preview_popup_window', 0 );
                                                 // PREVIEW - - - - - - - - - - - -
                                                 $windowWidthPr = (int) $previewwidth + 20;
                                                 $windowHeightPr = (int) $previewheight + 20;
                                                 if ($previewWindow == 1) {
                                                     $buttonPr = new JObject();
                                                     $buttonPr->set('methodname', 'js-button');
                                                     $buttonPr->set('options', "window.open(this.href,'win2','width=" . $windowWidthPr . ",height=" . $windowHeightPr . ",scrollbars=yes,menubar=no,resizable=yes'); return false;");
                                                 } else {
                                                     JHTML::_('behavior.modal', 'a.modal-button');
                                                     $document->addCustomTag("<style type=\"text/css\"> \n" . " #sbox-window.phocadownloadpreviewwindow   {background-color:#fff;padding:2px} \n" . " #sbox-overlay.phocadownloadpreviewoverlay  {background-color:#000;} \n" . " </style> \n");
                                                     $buttonPr = new JObject();
                                                     $buttonPr->set('name', 'image');
                                                     $buttonPr->set('modal', true);
                                                     $buttonPr->set('methodname', 'modal-button');
                                                     $buttonPr->set('options', "{handler: 'iframe', size: {x: " . $windowWidthPr . ", y: " . $windowHeightPr . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadpreviewwindow', classOverlay: 'phocadownloadpreviewoverlay'}");
                                                     $buttonPr->set('optionsimg', "{handler: 'image', size: {x: 200, y: 150}, overlayOpacity: 0.7, classWindow: 'phocadownloadpreviewwindow', classOverlay: 'phocadownloadpreviewoverlay'}");
                                                 }
                                                 // - - - - - - - - - - - - - - -
                                                 /*if ($text == '') {
                                                 			$text = JText::_('PLG_CONTENT_PHOCADOWNLOAD_PREVIEW');
                                                 		}*/
                                                 if ($text != '') {
                                                     $textOutput = $text;
                                                     //} else if (isset($item->title) && $item->title != '') {
                                                     //	$textOutput = $item->title;
                                                 } else {
                                                     $textOutput = JText::_('PLG_CONTENT_PHOCADOWNLOAD_PREVIEW');
                                                 }
                                                 if ($iMime == 1) {
                                                     $output .= '<div class="pd-filename phocadownloadfile phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '>';
                                                 } else {
                                                     $output .= '<div><div class="phocadownloadpreview' . (int) $iSize . '">';
                                                 }
                                                 if ($previewWindow == 1) {
                                                     $output .= '<a  href="' . $previewLink . '" onclick="' . $buttonPr->options . '" >' . $text . '</a>';
                                                 } else {
                                                     if ($fileExt == 'pdf') {
                                                         // Iframe - modal
                                                         $output .= '<a class="modal-button" href="' . $previewLink . '" rel="' . $buttonPr->options . '" >' . $textOutput . '</a>';
                                                     } else {
                                                         // Image - modal
                                                         $output .= '<a class="modal-button" href="' . $previewLink . '" rel="' . $buttonPr->optionsimg . '" >' . $textOutput . '</a>';
                                                     }
                                                 }
                                                 $output .= '</div></div>';
                                             }
                                         } else {
                                             $output .= JText::_('PLG_CONTENT_PHOCADOWNLOAD_NO_FILE_FOR_PREVIEWING_FOUND');
                                         }
                                     } else {
                                         if (isset($item->confirm_license) && $item->confirm_license > 0 || $fileView == 1) {
                                             $link = PhocaDownloadRoute::getFileRoute($item->id, $item->catid, $item->alias, $item->catalias, 0, 'file');
                                             //'index.php?option=com_phocadownload&view=file&id='.$item->slug.'&Itemid='.$itemId
                                             if ($iMime == 1) {
                                                 $output .= '<div class="pd-filename phocadownloadfile phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div></div>';
                                             } else {
                                                 $output .= '<div class="phocadownloadfile' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>';
                                             }
                                         } else {
                                             if ($item->link_external != '') {
                                                 $link = $item->link_external;
                                             } else {
                                                 $link = PhocaDownloadRoute::getFileRoute($item->id, $item->catid, $item->alias, $item->catalias, 0, 'download');
                                             }
                                             //$link = PhocaDownloadRoute::getCategoryRoute($item->catid,$item->catalias,$item->sectionid);
                                             //'index.php?option=com_phocadownload&view=category&id='. $item->catslug. '&download='. $item->slug. '&Itemid=' . $itemId
                                             if ($iMime == 1) {
                                                 $output .= '<div class="pd-filename phocadownloadfile phoca-dl-file-box-mod">' . $imageFileName['filenamethumb'] . '<div class="pd-document' . (int) $iSize . '" ' . $imageFileName['filenamestyle'] . '><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div></div>';
                                             } else {
                                                 $output .= '<div class="phocadownloadfile' . (int) $iSize . '"><a href="' . JRoute::_($link) . '" ' . $targetOutput . '>' . $textOutput . '</a></div>';
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     break;
                     // - - - - - - - - - - - - - - - -
                     // YOUTUBE
                     // - - - - - - - - - - - - - - - -
                 // - - - - - - - - - - - - - - - -
                 // YOUTUBE
                 // - - - - - - - - - - - - - - - -
                 case 'youtube':
                     if ($url != '' && PhocaDownloadUtils::isURLAddress($url)) {
                         $l = new PhocaDownloadLayout();
                         $pdVideo = $l->displayVideo($url, 0, $youtubewidth, $youtubeheight);
                         $output .= $pdVideo;
                     } else {
                         $output .= JText::_('PLG_CONTENT_PHOCADOWNLOAD_WRONG_YOUTUBE_URL');
                     }
                     break;
             }
             $article->text = preg_replace($regex_all, $output, $article->text, 1);
         }
     }
     // end if count_matches
     return true;
 }
Ejemplo n.º 8
0
	public static function getFileTime($filename, $function, $format = "d. M Y") {
		
		$path			= PhocaDownloadPath::getPathSet();
		$fileNameAbs	= JPath::clean($path['orig_abs'] . DS . $filename);
		if (JFile::exists($fileNameAbs)) {
			switch($function) {
				case 2:
					$fileTime = filectime($fileNameAbs);
				break;
				case 3:
					$fileTime = fileatime($fileNameAbs);
				break;
				case 1:
				default:
					$fileTime = filemtime($fileNameAbs);
				break;
			}
			
			$fileTime = JHTML::Date($fileTime, $format);
		} else {
			$fileTime = '';
		}
		return $fileTime;
	}
Ejemplo n.º 9
0
 public function display($tpl = null)
 {
     $this->t = PhocaDownloadUtils::setVars('manager');
     $this->field = JRequest::getVar('field');
     $this->fce = 'phocaSelectFileName_' . $this->field;
     JHTML::stylesheet($this->t['s']);
     $this->folderstate = $this->get('FolderState');
     $this->files = $this->get('Files');
     $this->folders = $this->get('Folders');
     $this->session = JFactory::getSession();
     $this->manager = JRequest::getVar('manager', '', '', 'file');
     if ($this->manager == 'filemultiple') {
         $this->form = $this->get('Form');
     }
     $params = JComponentHelper::getParams($this->t['o']);
     $this->t['multipleuploadchunk'] = $params->get('multiple_upload_chunk', 0);
     $this->t['uploadmaxsize'] = $params->get('upload_maxsize', 3145728);
     $this->t['uploadmaxsizeread'] = PhocaDownloadFile::getFileSizeReadable($this->t['uploadmaxsize']);
     $this->t['enablemultiple'] = $params->get('enable_multiple_upload_admin', 0);
     $this->t['multipleuploadmethod'] = $params->get('multiple_upload_method', 1);
     $this->currentFolder = '';
     if (isset($this->folderstate->folder) && $this->folderstate->folder != '') {
         $this->currentFolder = $this->folderstate->folder;
     }
     // - - - - - - - - - -
     //TABS
     // - - - - - - - - - -
     $this->t['tab'] = JRequest::getVar('tab', '', '', 'string');
     $this->t['displaytabs'] = 0;
     // UPLOAD
     $this->t['currenttab']['upload'] = $this->t['displaytabs'];
     $this->t['displaytabs']++;
     // MULTIPLE UPLOAD
     if ((int) $this->t['enablemultiple'] >= 0) {
         $this->t['currenttab']['multipleupload'] = $this->t['displaytabs'];
         $this->t['displaytabs']++;
     }
     $group = PhocaDownloadSettings::getManagerGroup($this->manager);
     // - - - - - - - - - - -
     // Upload
     // - - - - - - - - - - -
     $sU = new PhocaDownloadFileUploadSingle();
     $sU->returnUrl = 'index.php?option=com_phocadownload&view=phocadownloadmanager&tab=upload' . str_replace('&amp;', '&', $group['c']) . '&manager=' . $this->manager . '&field=' . $this->field . '&folder=' . $this->currentFolder;
     $sU->tab = 'upload';
     $this->t['su_output'] = $sU->getSingleUploadHTML();
     $this->t['su_url'] = JURI::base() . 'index.php?option=com_phocadownload&task=phocadownloadupload.upload&amp;' . $this->session->getName() . '=' . $this->session->getId() . '&amp;' . JSession::getFormToken() . '=1&amp;viewback=phocadownloadmanager&amp;manager=' . $this->manager . '&amp;field=' . $this->field . '&amp;' . 'folder=' . $this->currentFolder . '&amp;tab=upload';
     // - - - - - - - - - - -
     // Multiple Upload
     // - - - - - - - - - - -
     // Get infos from multiple upload
     $muFailed = JRequest::getVar('mufailed', '0', '', 'int');
     $muUploaded = JRequest::getVar('muuploaded', '0', '', 'int');
     $this->t['mu_response_msg'] = $muUploadedMsg = '';
     if ($muUploaded > 0) {
         $muUploadedMsg = JText::_('COM_PHOCADOWNLOAD_COUNT_UPLOADED_FILE') . ': ' . $muUploaded;
     }
     if ($muFailed > 0) {
         $muFailedMsg = JText::_('COM_PHOCADOWNLOAD_COUNT_NOT_UPLOADED_FILE') . ': ' . $muFailed;
     }
     if ($muFailed > 0 && $muUploaded > 0) {
         $this->t['mu_response_msg'] = '<div class="alert alert-info">' . '<button type="button" class="close" data-dismiss="alert">&times;</button>' . JText::_('COM_PHOCADOWNLOAD_COUNT_UPLOADED_FILE') . ': ' . $muUploaded . '<br />' . JText::_('COM_PHOCADOWNLOAD_COUNT_NOT_UPLOADED_FILE') . ': ' . $muFailed . '</div>';
     } else {
         if ($muFailed > 0 && $muUploaded == 0) {
             $this->t['mu_response_msg'] = '<div class="alert alert-error">' . '<button type="button" class="close" data-dismiss="alert">&times;</button>' . JText::_('COM_PHOCADOWNLOAD_COUNT_NOT_UPLOADED_FILE') . ': ' . $muFailed . '</div>';
         } else {
             if ($muFailed == 0 && $muUploaded > 0) {
                 $this->t['mu_response_msg'] = '<div class="alert alert-success">' . '<button type="button" class="close" data-dismiss="alert">&times;</button>' . JText::_('COM_PHOCADOWNLOAD_COUNT_UPLOADED_FILE') . ': ' . $muUploaded . '</div>';
             } else {
                 $this->t['mu_response_msg'] = '';
             }
         }
     }
     if ((int) $this->t['enablemultiple'] >= 0) {
         PhocadownloadFileUploadMultiple::renderMultipleUploadLibraries();
         $mU = new PhocaDownloadFileUploadMultiple();
         $mU->frontEnd = 0;
         $mU->method = $this->t['multipleuploadmethod'];
         $mU->url = JURI::base() . 'index.php?option=com_phocadownload&task=phocadownloadupload.multipleupload&amp;' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=multipleupload&manager=' . $this->manager . '&field=' . $this->field . '&folder=' . $this->currentFolder;
         $mU->reload = JURI::base() . 'index.php?option=com_phocadownload&view=phocadownloadmanager' . str_replace('&amp;', '&', $group['c']) . '&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=multipleupload&' . 'manager=' . $this->manager . '&field=' . $this->field . '&folder=' . $this->currentFolder;
         $mU->maxFileSize = PhocadownloadFileUploadMultiple::getMultipleUploadSizeFormat($this->t['uploadmaxsize']);
         $mU->chunkSize = '1mb';
         $mU->renderMultipleUploadJS(0, $this->t['multipleuploadchunk']);
         $this->t['mu_output'] = $mU->getMultipleUploadHTML();
     }
     $this->t['ftp'] = !JClientHelper::hasCredentials('ftp');
     $this->t['path'] = PhocaDownloadPath::getPathSet($this->manager);
     $this->addToolbar();
     parent::display($tpl);
     echo JHTML::_('behavior.keepalive');
 }
Ejemplo n.º 10
0
 function getList()
 {
     static $list;
     //Params
     $params = JComponentHelper::getParams('com_phocadownload');
     // Only process the list once per request
     if (is_array($list)) {
         return $list;
     }
     // Get current path from request
     $current = $this->getState('folder');
     // If undefined, set to empty
     if ($current == 'undefined') {
         $current = '';
     }
     // File Manager, Icon Manager
     $manager = $this->getState('manager');
     if ($manager == 'undefined') {
         $manager = '';
     }
     $path = PhocaDownloadPath::getPathSet($manager);
     $group = PhocaDownloadSettings::getManagerGroup($manager);
     //$path = PhocaDownloadPath::getPathSet();
     // Initialize variables
     if (strlen($current) > 0) {
         $orig_path = $path['orig_abs_ds'] . $current;
     } else {
         $orig_path = $path['orig_abs_ds'];
     }
     $orig_path_server = str_replace(DS, '/', $path['orig_abs'] . '/');
     // Absolute Path defined by user
     $absolutePath = $params->get('absolute_path', '');
     $absolutePath = str_replace(DS, '/', $absolutePath);
     // Be aware - absolute path is not set for images folder and for preview and play folder - see documentation
     if ($absolutePath != '' && $group['f'] == 1) {
         $orig_path_server = str_replace(DS, '/', JPath::clean($absolutePath . '/'));
         //$absolutePath ;
     }
     $files = array();
     $folders = array();
     // Get the list of files and folders from the given folder
     $file_list = JFolder::files($orig_path);
     $folder_list = JFolder::folders($orig_path, '', false, false, array());
     // Iterate over the files if they exist
     //file - abc.img, file_no - folder/abc.img
     if ($file_list !== false) {
         foreach ($file_list as $file) {
             if (is_file($orig_path . DS . $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
                 $tmp = new JObject();
                 $tmp->name = basename($file);
                 $tmp->path_with_name = str_replace(DS, '/', JPath::clean($orig_path . DS . $file));
                 $tmp->path_without_name_relative = $path['orig_rel_ds'] . str_replace($orig_path_server, '', $tmp->path_with_name);
                 $tmp->path_with_name = str_replace(DS, '/', JPath::clean($orig_path . DS . $file));
                 $tmp->path_with_name_relative_no = str_replace($orig_path_server, '', $tmp->path_with_name);
                 $files[] = $tmp;
             }
         }
     }
     // Iterate over the folders if they exist
     if ($folder_list !== false) {
         foreach ($folder_list as $folder) {
             $tmp = new JObject();
             $tmp->name = basename($folder);
             $tmp->path_with_name = str_replace(DS, '/', JPath::clean($orig_path . DS . $folder));
             $tmp->path_without_name_relative = $path['orig_rel_ds'] . str_replace($orig_path_server, '', $tmp->path_with_name);
             $tmp->path_with_name_relative_no = str_replace($orig_path_server, '', $tmp->path_with_name);
             $folders[] = $tmp;
         }
     }
     $list = array('folders' => $folders, 'files' => $files);
     return $list;
 }
Ejemplo n.º 11
0
	function display($tpl = null){		
		
		$app					= JFactory::getApplication();
		$this->t['p'] 				= $app->getParams();
		$this->t['user'] 		= JFactory::getUser();
		$uri 					= JFactory::getURI();
		$model					= $this->getModel();
		$document				= JFactory::getDocument();
		$fileId					= $app->input->get('id', 0, 'int');
		$this->t['limitstart']	= $app->input->get( 'start', 0, 'int');// we need it for category back link
		$this->t['tmpl']		= $app->input->get( 'tmpl', '', 'string' );
		$this->t['mediapath']	= PhocaDownloadPath::getPathMedia();

		$this->t['tmplr'] = 0;
		if ($this->t['tmpl'] == 'component') {
			$this->t['tmplr'] = 1;
		}

		if ($this->t['limitstart'] > 0 ) {
			$this->t['limitstarturl'] = '&start='.$this->t['limitstart'];
		} else {
			$this->t['limitstarturl'] = '';
		}
		
		$this->category			= $model->getCategory($fileId);
		$this->file				= $model->getFile($fileId, $this->t['limitstarturl']);
		
		PhocaDownloadRenderFront::renderAllCSS();
		
		$document->addCustomTag('<script type="text/javascript" src="'.JURI::root().'components/com_phocadownload/assets/overlib/overlib_mini.js"></script>');
		$js	= 'var enableDownloadButtonPD = 0;'
			 .'function enableDownloadPD() {'
			 .' if (enableDownloadButtonPD == 0) {'
			 .'   document.forms[\'phocadownloadform\'].elements[\'pdlicensesubmit\'].disabled=false;'
			 .'   enableDownloadButtonPD = 1;'
			 .' } else {'
			 .'   document.forms[\'phocadownloadform\'].elements[\'pdlicensesubmit\'].disabled=true;'
			 .'   enableDownloadButtonPD = 0;'
			 .' }'
			 .'}';
		$document->addScriptDeclaration($js);

		
		// Params
		$this->t['licenseboxheight']		= $this->t['p']->get( 'license_box_height', 300 );
		$this->t['filename_or_name'] 		= $this->t['p']->get( 'filename_or_name', 'filename' );
		$this->t['display_up_icon'] 		= $this->t['p']->get( 'display_up_icon', 1 );
		$this->t['allowed_file_types']		= $this->t['p']->get( 'allowed_file_types', '' );
		$this->t['disallowed_file_types']	= $this->t['p']->get( 'disallowed_file_types', '' );
		$this->t['enable_user_statistics']	= $this->t['p']->get( 'enable_user_statistics', 1 );
		$this->t['display_file_comments'] 	= $this->t['p']->get( 'display_file_comments', 0 );
		$this->t['file_icon_size'] 			= $this->t['p']->get( 'file_icon_size', 16 );
		$this->t['display_file_view']		= $this->t['p']->get('display_file_view', 0);
		$this->t['download_metakey'] 		= $this->t['p']->get( 'download_metakey', '' );
		$this->t['download_metadesc'] 		= $this->t['p']->get( 'download_metadesc', '' );
		$this->t['display_downloads'] 		= $this->t['p']->get( 'display_downloads', 0 );
		$this->t['display_date_type'] 		= $this->t['p']->get( 'display_date_type', 0 );
		$this->t['displaynew']				= $this->t['p']->get( 'display_new', 0 );
		$this->t['displayhot']				= $this->t['p']->get( 'display_hot', 0 );
		$this->t['pw']						= PhocaDownloadRenderFront::renderPhocaDownload();
		$this->t['download_external_link'] 	= $this->t['p']->get( 'download_external_link', '_self' );
		$this->t['display_report_link'] 	= $this->t['p']->get( 'display_report_link', 0 );
		$this->t['send_mail_download'] 		= $this->t['p']->get( 'send_mail_download', 0 );// not boolean but id of user
		//$this->t['send_mail_upload'] 		= $this->t['p']->get( 'send_mail_upload', 0 );
		$this->t['display_rating_file'] 	= $this->t['p']->get( 'display_rating_file', 0 );
		$this->t['display_tags_links'] 		= $this->t['p']->get( 'display_tags_links', 0 );
		$this->t['display_mirror_links'] 	= $this->t['p']->get( 'display_mirror_links', 0 );
		$this->t['display_specific_layout']	= $this->t['p']->get( 'display_specific_layout', 0 );
		$this->t['display_detail']			= $this->t['p']->get( 'display_detail', 1);
		$this->t['fb_comment_app_id']		= $this->t['p']->get( 'fb_comment_app_id', '' );
		$this->t['fb_comment_width']		= $this->t['p']->get( 'fb_comment_width', '550' );
		$this->t['fb_comment_lang'] 		= $this->t['p']->get( 'fb_comment_lang', 'en_US' );
		$this->t['fb_comment_count'] 		= $this->t['p']->get( 'fb_comment_count', '' );
		
		// Rating
		if ($this->t['display_rating_file'] == 2 || $this->t['display_rating_file'] == 3 ) {
			JHTML::_('jquery.framework', true);
			PhocaDownloadRate::renderRateFileJS(1);
			$this->t['display_rating_file'] = 1;
		} else {
			$this->t['display_rating_file'] = 0;
		}

		// DOWNLOAD
		// - - - - - - - - - - - - - - - 
		$download				= $app->input->get( 'download', array(0), 'array' );
		$licenseAgree			= $app->input->get( 'license_agree', '', 'string' );
		$downloadId		 		= (int) $download[0];
		if ($downloadId > 0) {
			if (isset($this->file[0]->id)) {
				$currentLink	= 'index.php?option=com_phocadownload&view=file&id='.$this->file[0]->id.':'.$this->file[0]->alias. $this->t['limitstarturl'] . '&Itemid='. $app->input->get('Itemid', 0, 'int');
			} else {
				$currentLink	= 'index.php?option=com_phocadownload&view=categories&Itemid='. $app->input->get('Itemid', 0, 'int');
			}
		
			// Check Token
			$token	= JSession::getFormToken();
			if (!JRequest::getInt( $token, 0, 'post' )) {
				//JError::raiseError(403, 'Request Forbidden');
				$app->redirect(JRoute::_('index.php', false), JText::_('COM_PHOCADOWNLOAD_INVALID_TOKEN'));
				exit;
			}
			
			// Check License Agreement
			if (empty($licenseAgree)) {
				$app->redirect(JRoute::_($currentLink, false), JText::_('COM_PHOCADOWNLOAD_WARNING_AGREE_LICENSE_TERMS'));
				exit;
			}
			
			$fileData		= PhocaDownloadDownload::getDownloadData($downloadId, $currentLink);
			PhocaDownloadDownload::download($fileData, $downloadId, $currentLink);
		}
		// - - - - - - - - - - - - - - - 
		
		$imagePath				= PhocaDownloadPath::getPathSet('icon');
		$this->t['cssimgpath']	= str_replace ( '../', JURI::base(true).'/', $imagePath['orig_rel_ds']);
		$filePath				= PhocaDownloadPath::getPathSet('file');
		$this->t['absfilepath']	= $filePath['orig_abs_ds'];
		$this->t['action']		= $uri->toString();	
		
		if (isset($this->category[0]) && is_object($this->category[0]) && isset($this->file[0]) && is_object($this->file[0])){
			$this->_prepareDocument($this->category[0], $this->file[0]);
		}

		
		// Bootstrap 3 Layout
		$this->tmpl['display_bootstrap3_layout']	= $this->t['p']->get( 'display_bootstrap3_layout', 0 );
		
		if ($this->tmpl['display_bootstrap3_layout'] == 1) {
			
			JHtml::_('jquery.framework', false);
			JHTML::stylesheet('media/com_phocadownload/bootstrap/css/bootstrap.min.css' );
			JHTML::stylesheet('media/com_phocadownload/bootstrap/css/bootstrap.extended.css' );
			// Loaded by jquery.framework;
			//$document->addScript(JURI::root(true).'/media/com_phocadownload/bootstrap/js/bootstrap.min.js');
			/*$document->addScript(JURI::root(true).'/media/com_phocadownload/js/jquery.equalheights.min.js');
			$document->addScriptDeclaration(
			'jQuery(window).load(function(){
				jQuery(\'.ph-thumbnail\').equalHeights();
			});');*/
		}
		
		if ($this->tmpl['display_bootstrap3_layout'] == 1) {
			parent::display('bootstrap');	
		} else {
			parent::display($tpl);	
		}
		
	}
Ejemplo n.º 12
0
 protected function _addAllFilesFromFolder(&$existingImages, $category_id, $fullPath, $rel_path, $data = array())
 {
     $count = 0;
     $fileList = JFolder::files($fullPath);
     natcasesort($fileList);
     // Iterate over the files if they exist
     //file - abc.img, file_no - folder/abc.img
     // Make a copy for play and preview (1) --------
     if (isset($data['pap_copy_m']) && $data['pap_copy_m'] == 1) {
         $path = PhocaDownloadPath::getPathSet();
         $storedfoldername = ltrim(str_replace(DS, '/', JPath::clean($rel_path)), '/');
         $paramsC = JComponentHelper::getParams('com_phocadownload');
         $overwriteExistingFiles = $paramsC->get('overwrite_existing_files', 0);
     }
     // ------------------------------------------------
     if ($fileList !== false) {
         foreach ($fileList as $filename) {
             $storedfilename = ltrim(str_replace(DS, '/', JPath::clean($rel_path . DS . $filename)), '/');
             //$ext = strtolower(JFile::getExt($filename));
             if (JFile::exists($fullPath . DS . $filename) && substr($filename, 0, 1) != '.' && strtolower($filename) !== 'index.html' && !$this->_FileExist($existingImages, $storedfilename, $category_id)) {
                 $row =& $this->getTable('phocadownload');
                 $datam = array();
                 $datam['published'] = $data['published'];
                 $datam['catid'] = $category_id;
                 $datam['filename'] = $storedfilename;
                 $datam['approved'] = $data['approved'];
                 $datam['language'] = $data['language'];
                 if ($data['title'] != '') {
                     $datam['title'] = $data['title'];
                 } else {
                     $datam['title'] = PhocaDownloadFile::getTitleFromFilenameWithoutExt($filename);
                 }
                 if ($data['alias'] != '') {
                     $datam['alias'] = $data['alias'];
                 } else {
                     $datam['alias'] = $data['alias'];
                     //PhocaDownloadFile::get AliasName($datam['title']);
                 }
                 $datam['token'] = PhocaDownloadUtils::getToken($datam['title'] . $datam['filename']);
                 $image = new JObject();
                 // Make a copy for play and preview (2)
                 if (isset($data['pap_copy_m']) && $data['pap_copy_m'] == 1) {
                     $o = $this->_copyPreviewAndPlay($filename, $storedfilename, $storedfoldername, $path, $overwriteExistingFiles);
                     $datam['filename_play'] = $o['filename_play'];
                     $datam['filename_preview'] = $o['filename_preview'];
                 }
                 // Save
                 // Bind the form fields to the Phoca download table
                 if (!$row->bind($datam)) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 // Create the timestamp for the date
                 $row->date = gmdate('Y-m-d H:i:s');
                 // if new item, order last in appropriate group
                 if (!$row->id) {
                     $where = 'catid = ' . (int) $row->catid;
                     $row->ordering = $row->getNextOrder($where);
                 }
                 // Make sure the Phoca download table is valid
                 if (!$row->check()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 // Store the Phoca download table to the database
                 if (!$row->store()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 // --------------------------------------------
                 /*if ($this->firstImageFolder == '') {
                 			$this->setFirstImageFolder($row->filename);
                 		}*/
                 $image->filename = $storedfilename;
                 $image->catid = $category_id;
                 $existingImages[] =& $image;
                 $count++;
             }
         }
     }
     //	$this->setfileCount($count);
     return $count;
 }
Ejemplo n.º 13
0
	public function getFiles()
	{
		$result	= array();
		jimport('joomla.filesystem.folder');

		$paths		= PhocaDownloadPath::getPathMedia();
		$path		= JPath::clean($paths->media_css_abs . '/main/');
		
		if (is_dir($path)) {
			$files = JFolder::files($path, '\.css$', false, false);
		
			foreach ($files as $file) {
				$fileO 	= new stdClass;
				$fileO->filename 	= $file;
				$fileO->exists 		= file_exists($path.$file);
				$fileO->type 		= 1;
				$result[] 			= $fileO;
			}
		} else {
			$this->setError(JText::_('COM_PHOCADOWNLOAD_ERROR_CSS_FOLDER_NOT_FOUND') . ' (1)');
			return false;
		}
		
		$path	= JPath::clean($paths->media_css_abs . '/custom/');
		if (is_dir($path)) {
			$files = JFolder::files($path, '\.css$', false, false);
		
			foreach ($files as $file) {
				$fileO 	= new stdClass;
				$fileO->filename 	= $file;
				$fileO->exists 		= file_exists($path.$file);
				$fileO->type 		= 2;
				$result[] 			= $fileO;
			}
		} else {
			$this->setError(JText::_('COM_PHOCADOWNLOAD_ERROR_CSS_FOLDER_NOT_FOUND') . ' (2)');
			return false;
		}
		return $result;
	}
Ejemplo n.º 14
0
	function display($tpl = null)
	{		
		$app								= JFactory::getApplication();
		$model								= $this->getModel();
		$document							= JFactory::getDocument();
		$this->t['p'] 						= $app->getParams();
		$this->t['user'] 					= JFactory::getUser();	
		$this->t['categories']				= $model->getCategoriesList();
		$this->t['mostvieweddocs']			= $model->getMostViewedDocsList($this->t['p']);
		$this->t['dev']						= PhocaDownloadRenderFront::renderPhocaDownload();
		$this->t['displaynew']				= $this->t['p']->get( 'display_new', 0 );
		$this->t['displayhot']				= $this->t['p']->get( 'display_hot', 0 );
		$this->t['displaymostdownload']		= $this->t['p']->get( 'display_most_download', 1 );
		$this->t['displaynumdocsecs']		= $this->t['p']->get( 'display_num_doc_secs', 0 );
		$this->t['displaynumdocsecsheader']	= $this->t['p']->get( 'display_num_doc_secs_header', 1 );
		$this->t['file_icon_size_md'] 		= $this->t['p']->get( 'file_icon_size_md', 16 );
		$this->t['download_metakey'] 		= $this->t['p']->get( 'download_metakey', '' );
		$this->t['download_metadesc'] 		= $this->t['p']->get( 'download_metadesc', '' );
		$this->t['description']				= $this->t['p']->get( 'description', '' );
		$this->t['displaymaincatdesc']		= $this->t['p']->get( 'display_main_cat_desc', 0 );
		$this->t['display_specific_layout']	= $this->t['p']->get( 'display_specific_layout', 0 );
		
		

		
		// Bootstrap 3 Layout
		$this->tmpl['display_bootstrap3_layout']	= $this->t['p']->get( 'display_bootstrap3_layout', 0 );
		if ($this->tmpl['display_bootstrap3_layout'] == 1) {
			
			JHtml::_('jquery.framework', false);
			JHTML::stylesheet('media/com_phocadownload/bootstrap/css/bootstrap.min.css' );
			JHTML::stylesheet('media/com_phocadownload/bootstrap/css/bootstrap.extended.css' );
			// Loaded by jquery.framework;
			$document->addScript(JURI::root(true).'/media/com_phocadownload/bootstrap/js/bootstrap.min.js');
			
			
			$document->addScript(JURI::root(true).'/media/com_phocadownload/js/jquery.matchHeight.js');
			$document->addScriptDeclaration(
			'jQuery(window).load(function(){
				jQuery(\'.ph-thumbnail\').matchHeight();
			});');
			
			/*$document->addScript(JURI::root(true).'/media/com_phocadownload/js/jquery.equalheights.min.js');
			$document->addScriptDeclaration(
			'jQuery(window).load(function(){
				jQuery(\'.ph-thumbnail\').equalHeights();
			});');*/

		}
		
		PhocaDownloadRenderFront::renderAllCSS();
		
		$imagePath				= PhocaDownloadPath::getPathSet('icon');
		$this->t['cssimgpath']	= str_replace ( '../', JURI::base(true).'/', $imagePath['orig_rel_ds']);
		$filePath				= PhocaDownloadPath::getPathSet('file');
		$this->t['absfilepath']	= $filePath['orig_abs_ds'];

		$this->_prepareDocument();
		if ($this->tmpl['display_bootstrap3_layout'] == 1) {
			parent::display('bootstrap');	
		} else {
			parent::display($tpl);	
		}
		
	}
Ejemplo n.º 15
0
 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;
     }
 }
Ejemplo n.º 16
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $this->t['p'] = $app->getParams();
     $this->t['user'] = JFactory::getUser();
     $uri = JFactory::getURI();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $this->t['categoryid'] = $app->input->get('id', 0, 'int');
     $this->t['tagid'] = $app->input->get('tagid', 0, 'int');
     $limitStart = $app->input->get('limitstart', 0, 'int');
     $this->t['mediapath'] = PhocaDownloadPath::getPathMedia();
     $this->category = $model->getCategory($this->t['categoryid']);
     $this->subcategories = $model->getSubcategories($this->t['categoryid']);
     $this->files = $model->getFileList($this->t['categoryid'], $this->t['tagid']);
     $this->t['pagination'] = $model->getPagination($this->t['categoryid'], $this->t['tagid']);
     PhocaDownloadRenderFront::renderAllCSS();
     $document->addCustomTag('<script type="text/javascript" src="' . JURI::root() . 'components/com_phocadownload/assets/overlib/overlib_mini.js"></script>');
     if ($limitStart > 0) {
         $this->t['limitstarturl'] = '&start=' . $limitStart;
     } else {
         $this->t['limitstarturl'] = '';
     }
     $this->t['download_external_link'] = $this->t['p']->get('download_external_link', '_self');
     $this->t['filename_or_name'] = $this->t['p']->get('filename_or_name', 'filenametitle');
     $this->t['display_downloads'] = $this->t['p']->get('display_downloads', 0);
     $this->t['display_description'] = $this->t['p']->get('display_description', 3);
     $this->t['display_detail'] = $this->t['p']->get('display_detail', 1);
     $this->t['display_play'] = $this->t['p']->get('display_play', 0);
     $this->t['playerwidth'] = $this->t['p']->get('player_width', 328);
     $this->t['playerheight'] = $this->t['p']->get('player_height', 200);
     $this->t['playermp3height'] = $this->t['p']->get('player_mp3_height', 30);
     $this->t['previewwidth'] = $this->t['p']->get('preview_width', 640);
     $this->t['previewheight'] = $this->t['p']->get('preview_height', 480);
     $this->t['display_preview'] = $this->t['p']->get('display_preview', 0);
     $this->t['play_popup_window'] = $this->t['p']->get('play_popup_window', 0);
     $this->t['preview_popup_window'] = $this->t['p']->get('preview_popup_window', 0);
     $this->t['file_icon_size'] = $this->t['p']->get('file_icon_size', 16);
     $this->t['displaynew'] = $this->t['p']->get('display_new', 0);
     $this->t['displayhot'] = $this->t['p']->get('display_hot', 0);
     $this->t['display_up_icon'] = $this->t['p']->get('display_up_icon', 1);
     $this->t['allowed_file_types'] = $this->t['p']->get('allowed_file_types', '');
     $this->t['disallowed_file_types'] = $this->t['p']->get('disallowed_file_types', '');
     $this->t['enable_user_statistics'] = $this->t['p']->get('enable_user_statistics', 1);
     $this->t['display_category_comments'] = $this->t['p']->get('display_category_comments', 0);
     $this->t['display_date_type'] = $this->t['p']->get('display_date_type', 0);
     $this->t['display_file_view'] = $this->t['p']->get('display_file_view', 0);
     $this->t['download_metakey'] = $this->t['p']->get('download_metakey', '');
     $this->t['download_metadesc'] = $this->t['p']->get('download_metadesc', '');
     $this->t['display_rating_file'] = $this->t['p']->get('display_rating_file', 0);
     $this->t['display_mirror_links'] = $this->t['p']->get('display_mirror_links', 0);
     $this->t['display_report_link'] = $this->t['p']->get('display_report_link', 0);
     $this->t['send_mail_download'] = $this->t['p']->get('send_mail_download', 0);
     // not boolean but id of user
     //$this->t['send_mail_upload'] 		= $this->t['p']->get( 'send_mail_upload', 0 );
     $this->t['display_tags_links'] = $this->t['p']->get('display_tags_links', 0);
     $this->t['display_specific_layout'] = $this->t['p']->get('display_specific_layout', 0);
     $this->t['fb_comment_app_id'] = $this->t['p']->get('fb_comment_app_id', '');
     $this->t['fb_comment_width'] = $this->t['p']->get('fb_comment_width', '550');
     $this->t['fb_comment_lang'] = $this->t['p']->get('fb_comment_lang', 'en_US');
     $this->t['fb_comment_count'] = $this->t['p']->get('fb_comment_count', '');
     $this->t['html5_play'] = $this->t['p']->get('html5_play', 0);
     // Rating
     if ($this->t['display_rating_file'] == 1 || $this->t['display_rating_file'] == 3) {
         JHTML::_('behavior.framework', true);
         PhocaDownloadRate::renderRateFileJS(1);
         $this->t['display_rating_file'] = 1;
     } else {
         $this->t['display_rating_file'] = 0;
     }
     $this->t['dg'] = PhocaDownloadRenderFront::renderPhocaDownload();
     // DOWNLOAD
     // - - - - - - - - - - - - - - -
     $download = $app->input->get('download', array(0), 'array');
     $downloadId = (int) $download[0];
     if ($downloadId > 0) {
         if (isset($this->category[0]->id) && (int) $this->category[0]->id > 0) {
             $currentLink = 'index.php?option=com_phocadownload&view=category&id=' . $this->category[0]->id . ':' . $this->category[0]->alias . $this->t['limitstarturl'] . '&Itemid=' . $app->input->get('Itemid', 0, 'int');
         } else {
             $currentLink = $uri;
         }
         $fileData = PhocaDownloadDownload::getDownloadData($downloadId, $currentLink);
         PhocaDownloadDownload::download($fileData, $downloadId, $currentLink);
     }
     // - - - - - - - - - - - - - - -
     // DETAIL
     // - - - - - - - - - - - - - - -
     if ($this->t['display_detail'] == 2) {
         $this->t['buttond'] = new JObject();
         $this->t['buttond']->set('methodname', 'modal-button');
         $this->t['buttond']->set('name', 'detail');
         $this->t['buttond']->set('modal', true);
         $this->t['buttond']->set('options', "{handler: 'iframe', size: {x: 600, y: 500}, overlayOpacity: 0.7, classWindow: 'phocadownloaddetailwindow', classOverlay: 'phocadownloaddetailoverlay'}");
     }
     JHTML::_('behavior.modal', 'a.pd-modal-button');
     // PLAY - - - - - - - - - - - -
     $windowWidthPl = (int) $this->t['playerwidth'] + 20;
     $windowHeightPl = (int) $this->t['playerheight'] + 20;
     if ($this->t['html5_play'] == 1) {
         $windowWidthPl = (int) $this->t['playerwidth'] + 40;
     } else {
         $windowWidthPl = (int) $this->t['playerwidth'] + 50;
     }
     $windowHeightPlMP3 = (int) $this->t['playermp3height'] + 20;
     if ($this->t['play_popup_window'] == 1) {
         $this->t['buttonpl'] = new JObject();
         $this->t['buttonpl']->set('methodname', 'js-button');
         $this->t['buttonpl']->set('options', "window.open(this.href,'win2','width=" . $windowWidthPl . ",height=" . $windowHeightPl . ",scrollbars=yes,menubar=no,resizable=yes'); return false;");
         $this->t['buttonpl']->set('optionsmp3', "window.open(this.href,'win2','width=" . $windowWidthPl . ",height=" . $windowHeightPlMP3 . ",scrollbars=yes,menubar=no,resizable=yes'); return false;");
     } else {
         $document->addCustomTag("<style type=\"text/css\"> \n" . " #sbox-window.phocadownloadplaywindow   {background-color:#fff;padding:2px} \n" . " #sbox-overlay.phocadownloadplayoverlay  {background-color:#000;} \n" . " </style> \n");
         $this->t['buttonpl'] = new JObject();
         $this->t['buttonpl']->set('name', 'image');
         $this->t['buttonpl']->set('modal', true);
         $this->t['buttonpl']->set('methodname', 'modal-button');
         $this->t['buttonpl']->set('options', "{handler: 'iframe', size: {x: " . $windowWidthPl . ", y: " . $windowHeightPl . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadplaywindow', classOverlay: 'phocadownloadplayoverlay'}");
         $this->t['buttonpl']->set('optionsmp3', "{handler: 'iframe', size: {x: " . $windowWidthPl . ", y: " . $windowHeightPlMP3 . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadplaywindow', classOverlay: 'phocadownloadplayoverlay'}");
     }
     // - - - - - - - - - - - - - - -
     // PREVIEW - - - - - - - - - - - -
     $windowWidthPr = (int) $this->t['previewwidth'] + 20;
     $windowHeightPr = (int) $this->t['previewheight'] + 20;
     if ($this->t['preview_popup_window'] == 1) {
         $this->t['buttonpr'] = new JObject();
         $this->t['buttonpr']->set('methodname', 'js-button');
         $this->t['buttonpr']->set('options', "window.open(this.href,'win2','width=" . $windowWidthPr . ",height=" . $windowHeightPr . ",scrollbars=yes,menubar=no,resizable=yes'); return false;");
     } else {
         $document->addCustomTag("<style type=\"text/css\"> \n" . " #sbox-window.phocadownloadpreviewwindow   {background-color:#fff;padding:2px} \n" . " #sbox-overlay.phocadownloadpreviewoverlay  {background-color:#000;} \n" . " </style> \n");
         $this->t['buttonpr'] = new JObject();
         $this->t['buttonpr']->set('name', 'image');
         $this->t['buttonpr']->set('modal', true);
         $this->t['buttonpr']->set('methodname', 'modal-button');
         $this->t['buttonpr']->set('options', "{handler: 'iframe', size: {x: " . $windowWidthPr . ", y: " . $windowHeightPr . "}, overlayOpacity: 0.7, classWindow: 'phocadownloadpreviewwindow', classOverlay: 'phocadownloadpreviewoverlay'}");
         $this->t['buttonpr']->set('optionsimg', "{handler: 'image', size: {x: 200, y: 150}, overlayOpacity: 0.7, classWindow: 'phocadownloadpreviewwindow', classOverlay: 'phocadownloadpreviewoverlay'}");
     }
     // - - - - - - - - - - - - - - -
     $imagePath = PhocaDownloadPath::getPathSet('icon');
     $this->t['cssimgpath'] = str_replace('../', JURI::base(true) . '/', $imagePath['orig_rel_ds']);
     $filePath = PhocaDownloadPath::getPathSet('file');
     $this->t['absfilepath'] = $filePath['orig_abs_ds'];
     $this->t['action'] = $uri->toString();
     if (isset($this->category[0]) && is_object($this->category[0])) {
         $this->_prepareDocument($this->category[0]);
     }
     parent::display($tpl);
 }
Ejemplo n.º 17
0
	function delete(&$cid = array()) {
		
		$result 			= false;

		$paramsC 		= JComponentHelper::getParams('com_phocadownload');
		$deleteExistingFiles 	= $paramsC->get( 'delete_existing_files', 0 );
		
		if (count( $cid )) {
			JArrayHelper::toInteger($cid);
			$cids = implode( ',', $cid );
			
			// - - - - - - - - - - - - - 
			// Get all filenames we want to delete from database, we delete all thumbnails from server of this file
			$queryd = 'SELECT filename as filename FROM #__phocadownload WHERE id IN ( '.$cids.' )';
			$this->_db->setQuery($queryd);
			$fileObject = $this->_db->loadObjectList();
			// - - - - - - - - - - - - - 

		
			//Delete it from DB
			$query = 'DELETE FROM #__phocadownload'
				. ' WHERE id IN ( '.$cids.' )';
			$this->_db->setQuery( $query );
			if(!$this->_db->query()) {
				$this->setError($this->_db->getErrorMsg);
				return false;
			}
			
			//Delete tags from DB
			$query = 'DELETE FROM #__phocadownload_tags_ref'
				. ' WHERE fileid IN ( '.$cids.' )';
			$this->_db->setQuery( $query );
			if(!$this->_db->query()) {
				$this->setError($this->_db->getErrorMsg());
				return false;
			}

			// - - - - - - - - - - - - - - 
			// DELETE FILES ON SERVER
			if ($deleteExistingFiles == 1) {
				$path	= PhocaDownloadPath::getPathSet();
				foreach ($fileObject as $key => $value) {
					//The file can be stored in other category - don't delete it from server because other category use it
					$querys = "SELECT id as id FROM #__phocadownload WHERE filename='".$value->filename."' ";
					$this->_db->setQuery($querys);
					$sameFileObject = $this->_db->loadObject();
					// same file in other category doesn't exist - we can delete it
					if (!$sameFileObject) {
						JFile::delete(JPath::clean($path['orig_abs_ds'].$value->filename));
					}
				}
			}
			
		}
		return true;
	}
Ejemplo n.º 18
0
 function createfolder()
 {
     $app = JFactory::getApplication();
     // Check for request forgeries
     JRequest::checkToken() or jexit('COM_PHOCADOWNLOAD_INVALID_TOKEN');
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $paramsC = JComponentHelper::getParams('com_phocadownload');
     $folder_permissions = $paramsC->get('folder_permissions', 0755);
     //$folder_permissions = octdec((int)$folder_permissions);
     $folderNew = JRequest::getCmd('foldername', '');
     $folderCheck = JRequest::getVar('foldername', null, '', 'string', JREQUEST_ALLOWRAW);
     $parent = JRequest::getVar('folderbase', '', '', 'path');
     $tab = JRequest::getVar('tab', 0, '', 'string');
     $field = JRequest::getVar('field');
     $viewBack = JRequest::getVar('viewback', '', '', 'phocadownloadmanager');
     $manager = JRequest::getVar('manager', 'file', '', 'string');
     $link = '';
     if ($manager != '') {
         $group = PhocaDownloadSettings::getManagerGroup($manager);
         $link = 'index.php?option=com_phocadownload&view=' . (string) $viewBack . '&manager=' . (string) $manager . str_replace('&amp;', '&', $group['c']) . '&folder=' . $parent . '&tab=' . (string) $tab . '&field=' . $field;
         $path = PhocaDownloadPath::getPathSet($manager);
         // we use viewback to get right path
     } else {
         $app->enqueueMessage(JText::_('COM_PHOCADOWNLOAD_ERROR_CONTROLLER_MANAGER_NOT_SET'));
         $app->redirect('index.php?option=com_phocadownload');
         exit;
     }
     JRequest::setVar('folder', $parent);
     if ($folderCheck !== null && $folderNew !== $folderCheck) {
         $app->enqueueMessage(JText::_('COM_PHOCADOWNLOAD_WARNING_DIRNAME'));
         $app->redirect($link);
     }
     if (strlen($folderNew) > 0) {
         $folder = JPath::clean($path['orig_abs_ds'] . $parent . DS . $folderNew);
         if (!JFolder::exists($folder) && !JFile::exists($folder)) {
             //JFolder::create($path, $folder_permissions );
             switch ((int) $folder_permissions) {
                 case 777:
                     JFolder::create($folder, 0777);
                     break;
                 case 705:
                     JFolder::create($folder, 0705);
                     break;
                 case 666:
                     JFolder::create($folder, 0666);
                     break;
                 case 644:
                     JFolder::create($folder, 0644);
                     break;
                 case 755:
                 default:
                     JFolder::create($folder, 0755);
                     break;
             }
             if (isset($folder)) {
                 $data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
                 JFile::write($folder . DS . "index.html", $data);
             } else {
                 $app->redirect($link, JText::_('COM_PHOCADOWNLOAD_ERROR_FOLDER_CREATING'));
             }
             $app->redirect($link, JText::_('COM_PHOCADOWNLOAD_SUCCESS_FOLDER_CREATING'));
         } else {
             $app->redirect($link, JText::_('COM_PHOCADOWNLOAD_ERROR_FOLDER_CREATING_EXISTS'));
         }
         //JRequest::setVar('folder', ($parent) ? $parent.'/'.$folder : $folder);
     }
     $app->redirect($link);
 }