Esempio n. 1
0
 function display()
 {
     if (!JRequest::getCmd('view')) {
         JRequest::setVar('view', 'comment');
     }
     parent::display();
 }
Esempio n. 2
0
 function display($cachable = false, $urlparams = false)
 {
     if (!JRequest::get('view')) {
         $this->input->set('view', 'category');
     }
     parent::display($cachable, $urlparams);
 }
Esempio n. 3
0
 function display()
 {
     if (!JFactory::getApplication()->input->get('view')) {
         JRequest::setVar('view', 'comment');
     }
     parent::display();
 }
Esempio n. 4
0
 function display($cachable = false, $urlparams = false)
 {
     if (!JFactory::getApplication()->input->get('view')) {
         JRequest::setVar('view', 'comment');
     }
     parent::display($cachable, $urlparams);
 }
Esempio n. 5
0
 function display()
 {
     if (!JRequest::get('view')) {
         $this->input->set('view', 'category');
     }
     parent::display();
 }
Esempio n. 6
0
 function upload()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken('request') or jexit('Invalid Token');
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
     $user =& JFactory::getUser();
     $path = PhocaGalleryHelper::getPathSet();
     $file = JRequest::getVar('Filedata', '', 'files', 'array');
     $folder = JRequest::getVar('folder', '', '', 'path');
     $tab = JRequest::getVar('tab', 0, '', 'int');
     $format = JRequest::getVar('format', 'html', '', 'cmd');
     $return = JRequest::getVar('return-url', null, 'post', 'base64');
     $viewBack = JRequest::getVar('viewback', '', '', '');
     $err = null;
     $view = JRequest::getVar('view', '', 'get', '', JREQUEST_NOTRIM);
     $catid = JRequest::getVar('id', '', 'get', 'string', JREQUEST_NOTRIM);
     //$catid 	= JRequest::getVar( 'catid', '', 'post', 'string', JREQUEST_NOTRIM  );
     $Itemid = JRequest::getVar('Itemid', 0, '', 'int');
     $limitStart = JRequest::getVar('limitstart', 0, '', 'int');
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $catidAlias = $catid;
     // for return
     // Set the limistart (TODO)
     if ($limitStart > 0) {
         $limitStartUrl = '&limitstart=' . $limitStart;
     } else {
         $limitStartUrl = '';
     }
     // From which view the image is uploaded
     switch ($view) {
         case 'user':
             // UCP is disabled (security reasons)
             $enable_user_cp = $paramsC->get('enable_user_cp', 0);
             if ($enable_user_cp == 0) {
                 $mainframe->redirect(JURI::base(true), JText::_("User Control Panel is disabled"));
                 exit;
             }
             $return = JRoute::_('index.php?option=com_phocagallery&view=user&tab=' . $tab . '&Itemid=' . $Itemid, false);
             // Get user catid, we are not in the category, so we must find the catid
             $modelUser = $this->getModel('user');
             $userCatId = $modelUser->getUserCategory($user->id);
             // User has no category, he (she) can create one
             if (!empty($userCatId->categoryid)) {
                 $catid = $userCatId->categoryid;
             } else {
                 $mainframe->redirect($return, JText::_('Error Uploading Phoca Gallery User Control Image'));
                 exit;
             }
             break;
         case 'category':
         default:
             $return = JRoute::_('index.php?option=com_phocagallery&view=category&id=' . $catidAlias . '&tab=' . $tab . '&Itemid=' . $Itemid . $limitStartUrl, false);
             break;
     }
     $model = $this->getModel('category');
     // USER RIGHT - UPLOAD ========================================
     // 2, 2 means that user access will be ignored in function getUserRight for display Delete button
     $rightDisplayUpload = 0;
     $catParams = $model->getCategoryParams((int) $catid);
     if (isset($catParams->params)) {
         $rightDisplayUpload = PhocaGalleryHelper::getUserRight($catParams->params, 'uploaduserid', 2, 2, $user->get('id', 0), 0);
     }
     // ============================================================
     // USER RIGHT - FOLDER ========================================
     $rightFolder[0] = '';
     if (isset($catParams->params)) {
         $rightFolder = PhocaGalleryHelper::getParamsArray($catParams->params, 'userfolder');
     }
     // ============================================================
     if ($rightDisplayUpload == 1) {
         if ($rightFolder[0] == '') {
             $mainframe->redirect($return, JText::_('User Folder Not Defined'));
         }
         if (!JFolder::exists($path['orig_abs_ds'] . $rightFolder[0] . DS)) {
             $mainframe->redirect($return, JText::_('Defined User Folder Does Not Exist'));
         }
         // Check if the size will be not over the category folder size
         jimport('joomla.filesystem.folder');
         $path = PhocaGalleryHelper::getPathset();
         $catPath = $path['orig_abs_ds'] . $rightFolder[0] . DS;
         $files = JFolder::files($catPath);
         // Get size of all images in the folder
         $allFileSize = 0;
         foreach ($files as $fileInFolder) {
             $fileSize = PhocaGalleryHelperFront::getFileSizePhoca($rightFolder[0] . DS . $fileInFolder, 0);
             $allFileSize = $allFileSize + (int) $fileSize;
         }
         // Get the size of all images include new uploaded image in Bytes
         if (isset($file['size'])) {
             $allFileSize = $allFileSize + (int) $file['size'];
         }
         $maxFolderSize = (int) $paramsC->get('cat_folder_maxsize', 20000000);
         if ($maxFolderSize > 0 && (int) $allFileSize > $maxFolderSize) {
             $mainframe->redirect($return, JText::_('WARNFILETOOLARGEFOLDER'));
         }
         // Make the filename safe
         if (isset($file['name'])) {
             $file['name'] = JFile::makeSafe($file['name']);
         }
         if (isset($file['name'])) {
             $filepath = JPath::clean($path['orig_abs_ds'] . $rightFolder[0] . DS . $file['name']);
             if (!PhocaGalleryHelperUpload::canUpload($file, $err)) {
                 $mainframe->redirect($return, JText::_($err));
                 exit;
             }
             if (JFile::exists($filepath)) {
                 $mainframe->redirect($return, JText::_('File already exists'));
                 exit;
             }
             if (!JFile::upload($file['tmp_name'], $filepath)) {
                 $mainframe->redirect($return, JText::_('Unable to upload file'));
                 exit;
             } else {
                 // Saving file name into database with relative path
                 $file['name'] = $rightFolder[0] . '/' . $file['name'];
                 PhocaGalleryController::save((int) $catid, $file['name'], $return);
                 //$mainframe->redirect($return,JText::_('Upload complete'));
                 //exit;
             }
         } else {
             $mainframe->redirect($return, JText::_('WARNFILETYPE'));
             exit;
         }
     } else {
         $mainframe->redirect(JRoute::_('index.php?option=com_user&view=login', false), JText::_("NOT AUTHORISED TO DO ACTION"));
         exit;
     }
 }