Beispiel #1
0
 function javaupload()
 {
     JRequest::checkToken('request') or exit('ERROR: ' . JTEXT::_('COM_PHOCAGALLERY_INVALID_TOKEN'));
     jimport('joomla.client.helper');
     $app = JFactory::getApplication();
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $user = JFactory::getUser();
     $path = PhocaGalleryPath::getPath();
     $return = $this->input->get('return-url', null, 'base64');
     $format = $this->input->get('format', 'html', 'cmd');
     $viewBack = $this->input->get('viewback', '', 'string');
     $tab = $this->input->get('tab', 0, 'int');
     $catid = $this->input->get('id', '', 'string');
     $rating = $this->input->get('rating', '', 'string');
     $Itemid = $this->input->get('Itemid', 0, 'int');
     $limitStart = $this->input->get('limitstart', 0, 'int');
     $catid = (int) $catid;
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $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;
     $catAccess = PhocaGalleryAccess::getCategoryAccess((int) $catid);
     if (!empty($catAccess)) {
         $rightDisplayUpload = PhocaGalleryAccess::getUserRight('uploaduserid', $catAccess->uploaduserid, 2, $user->getAuthorisedViewLevels(), $user->get('id', 0), 0);
     }
     // - - - - - - - - - - - - - - - - - - - - - -
     // USER RIGHT - FOLDER - - - - - - - - - - - -
     $rightFolder = '';
     if (isset($catAccess->userfolder)) {
         $rightFolder = $catAccess->userfolder;
     }
     // - - - - - - - - - - - - - - - - - - - - - -
     if ($rightDisplayUpload == 1) {
         if ($rightFolder == '') {
             exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_USER_FOLDER_NOT_DEFINED'));
             return false;
         }
         if (!JFolder::exists($path->image_abs . $rightFolder . DS)) {
             exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_USER_FOLDER_NOT_EXISTS'));
             return false;
         }
         // Check the size of all images by users
         /*	$maxUserImageSize 	= (int)$paramsC->get( 'user_images_max_size', 20971520 );
         			$allFileSize		= PhocaGalleryFileUploadFront::getSizeAllOriginalImages($file, $this->_user->id);
         
         			if ($maxUserImageSize > 0 && (int) $allFileSize > $maxUserImageSize) {
         				$errUploadMsg = JText::_('COM_PHOCAGALLERY_WARNING_USERIMAGES_TOOLARGE');	
         				$app->redirect($redirectUrl, $errUploadMsg);
         				return false;
         			}*/
         // Sending and setting data for common realsingleupload function
         $this->input->set('folder', $rightFolder);
         //Set the right path for uploaded image (category folder included)
         $this->input->set('return-url', base64_encode($return));
         // set return url
         $fileName = PhocaGalleryFileUpload::realJavaUpload(1);
         if ($fileName != '') {
             // Saving file name into database with relative path
             $fileName = $rightFolder . '/' . strtolower($fileName);
             if (PhocaGalleryControllerCategory::save((int) $catid, $fileName, false, $succeeded, $errUploadMsg, false)) {
                 //$app->enqueueMessage(JText::_('COM_PHOCAGALLERY_SUCCESS_FILE_UPLOAD'));
                 exit('SUCCESS');
                 return true;
             } else {
                 exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'));
                 return false;
             }
         }
     } else {
         exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
         return false;
     }
 }
 function javaupload()
 {
     $result = PhocaGalleryFileUpload::realJavaUpload();
     return true;
 }
Beispiel #3
0
 function javaupload()
 {
     JRequest::checkToken('request') or exit('ERROR: ' . JTEXT::_('COM_PHOCAGALLERY_INVALID_TOKEN'));
     jimport('joomla.client.helper');
     $app = JFactory::getApplication();
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $user = JFactory::getUser();
     $path = PhocaGalleryPath::getPath();
     //$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', '', '', '');
     $catid = JRequest::getVar('catid', '', '', 'int');
     $Itemid = JRequest::getVar('Itemid', 0, '', 'int');
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $limitStartUrl = $this->getLimitStartUrl(0, 'subcat');
     $return = JRoute::_($this->_url . $limitStartUrl->subcat . $limitStartUrl->image, false);
     $redirectUrl = $return;
     if ((int) $catid < 1) {
         exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_PLEASE_SELECT_CATEGORY'));
     }
     // Get user catid, we are not in the category, so we must find the catid
     $model = $this->getModel('user');
     $isOwnerCategory = $model->isOwnerCategory($this->_user->id, $catid);
     if (!$isOwnerCategory) {
         exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
     }
     // USER RIGHT - UPLOAD - - - - - - - - - - -
     // 2, 2 means that user access will be ignored in function getUserRight for display Delete button
     $rightDisplayUpload = 0;
     $catAccess = PhocaGalleryAccess::getCategoryAccess((int) $catid);
     if (!empty($catAccess)) {
         $rightDisplayUpload = PhocaGalleryAccess::getUserRight('uploaduserid', $catAccess->uploaduserid, 2, $user->authorisedLevels(), $user->get('id', 0), 0);
     }
     // - - - - - - - - - - - - - - - - - - - - - -
     // USER RIGHT - FOLDER - - - - - - - - - - - -
     $rightFolder = '';
     if (isset($catAccess->userfolder)) {
         $rightFolder = $catAccess->userfolder;
     }
     // - - - - - - - - - - - - - - - - - - - - - -
     if ($rightDisplayUpload == 1) {
         if ($rightFolder == '') {
             exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_USER_FOLDER_NOT_DEFINED'));
             return false;
         }
         if (!JFolder::exists($path->image_abs . $rightFolder . DS)) {
             exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_USER_FOLDER_NOT_EXISTS'));
             return false;
         }
         // Sending and setting data for common realsingleupload function
         JRequest::setVar('folder', $rightFolder);
         //Set the right path for uploaded image (category folder included)
         JRequest::setVar('return-url', base64_encode($return));
         // set return url
         $fileName = PhocaGalleryFileUpload::realJavaUpload(2);
         if ($fileName != '') {
             // Saving file name into database with relative path
             $fileName = $rightFolder . '/' . strtolower($fileName);
             if (PhocaGalleryControllerUser::save((int) $catid, $fileName, false, $succeeded, $errUploadMsg, false)) {
                 //$app->enqueueMessage(JText::_('COM_PHOCAGALLERY_SUCCESS_FILE_UPLOAD'));
                 exit('SUCCESS');
                 return true;
             } else {
                 exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'));
                 return false;
             }
         }
     } else {
         exit('ERROR: ' . JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
         return false;
     }
 }