Beispiel #1
0
 function download()
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $authorised = $user->authorise('djcatalog2.filedownload', 'com_djcatalog2');
     if ($authorised !== true) {
         JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
         return false;
     }
     if ($out = DJCatalog2FileHelper::getFile($app->input->get('fid', '', 'int'))) {
         $app->input->set('format', 'raw');
         echo $out;
     } else {
         JError::raiseError(404);
         return false;
     }
 }
Beispiel #2
0
 public function download_file()
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     if (!$user->authorise('core.manage', 'com_djcatalog2') && !$user->authorise('core.admin', 'com_djcatalog2')) {
         return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     $path = $app->input->get('path', null, 'base64');
     $file_path = JPATH_ROOT . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, base64_decode($path));
     if (empty($path) || !JFile::exists($file_path)) {
         $this->setRedirect('index.php?option=com_djcatalog2', JText::sprintf('COM_DJCATALOG2_ERROR_FILE_MISSING', base64_decode($path)), 'error');
         return false;
     }
     if (!DJCatalog2FileHelper::getFileByPath($file_path)) {
         //JError::raiseError(404);
         throw new Exception('', 404);
         return false;
     }
     return true;
 }
Beispiel #3
0
 public function moveToFolders()
 {
     die('NO NO NO!');
     $db = JFactory::getDbo();
     $errors = array();
     $db->setQuery('select * from #__djc2_images');
     $images = $db->loadObjectList();
     foreach ($images as $image) {
         if (!empty($image->path)) {
             continue;
         }
         $dest = DJCatalog2ImageHelper::getDestinationFolder(DJCATIMGFOLDER, $image->item_id, $image->type);
         if (!JFolder::exists($dest)) {
             JFolder::create($dest);
         }
         if (JFile::copy(DJCATIMGFOLDER . DS . $image->fullname, $dest . DS . $image->fullname)) {
             $path = DJCatalog2ImageHelper::getDestinationPath($image->item_id, $image->type);
             $fullpath = $path . '/' . $image->fullname;
             $db->setQuery('update #__djc2_images set fullpath=' . $db->quote($fullpath) . ', path=' . $db->quote($path) . ' where id=' . $image->id);
             if (!$db->query()) {
                 $errors[] = array('DB', $image->fullname);
                 continue;
             }
             JFile::delete(DJCATIMGFOLDER . DS . $image->fullname);
         } else {
             $errors['images'] = array('COPY', $image->fullname);
         }
     }
     $db->setQuery('select * from #__djc2_files');
     $files = $db->loadObjectList();
     foreach ($files as $file) {
         if (!empty($file->path)) {
             continue;
         }
         $dest = DJCatalog2FileHelper::getDestinationFolder(DJCATATTFOLDER, $file->item_id, $file->type);
         if (!JFolder::exists($dest)) {
             JFolder::create($dest);
         }
         if (JFile::copy(DJCATATTFOLDER . DS . $file->fullname, $dest . DS . $file->fullname)) {
             $path = DJCatalog2ImageHelper::getDestinationPath($file->item_id, $file->type);
             $fullpath = $path . '/' . $file->fullname;
             $db->setQuery('update #__djc2_files set fullpath=' . $db->quote($fullpath) . ', path=' . $db->quote($path) . ' where id=' . $file->id);
             if (!$db->query()) {
                 $errors[] = array('DB', $file->fullname);
                 continue;
             }
             JFile::delete(DJCATATTFOLDER . DS . $file->fullname);
         } else {
             $errors['files'] = array('COPY', $file->fullname);
         }
     }
     echo '<pre>';
     print_r($errors);
     echo '</pre>';
     die;
 }
Beispiel #4
0
 public static function storeMedias($item_id, $type, $files, $source_path, $target_path, $table_name)
 {
     $db = JFactory::getDbo();
     $destination = DJCatalog2FileHelper::getDestinationFolder($target_path, $item_id, $type);
     $sub_path = DJCatalog2FileHelper::getDestinationPath($item_id, $type);
     if (!JFolder::exists($destination)) {
         $destExist = JFolder::create($destination, 0755);
     } else {
         $destExist = true;
     }
     if ($destExist && !empty($files)) {
         $ordering = 1;
         foreach ($files as $file) {
             $file = trim($file);
             if ($file && JFile::exists($source_path . DS . $file)) {
                 $obj = new stdClass();
                 $obj->id = null;
                 $obj->fullname = DJCatalog2FileHelper::createFileName($file, $destination);
                 $obj->name = JFile::stripExt($obj->fullname);
                 $obj->ext = JFile::getExt($obj->fullname);
                 $obj->item_id = $item_id;
                 $obj->path = $sub_path;
                 $obj->fullpath = $sub_path . '/' . $obj->fullname;
                 $obj->type = $type;
                 $obj->caption = JFile::stripExt($file);
                 $obj->ordering = $ordering++;
                 if (JFile::copy($source_path . DS . $file, $destination . DS . $obj->fullname)) {
                     $db->insertObject($table_name, $obj, 'id');
                 }
             }
         }
     }
 }
Beispiel #5
0
?>
            
            <?php 
if (isset($this->item->tabs)) {
    ?>
            	<div class="djc_clear"></div>
            	<div class="djc_tabs">
            		<?php 
    echo JHTML::_('content.prepare', $this->item->tabs);
    ?>
            	</div>
            <?php 
}
?>
            <?php 
if ($this->item->files = DJCatalog2FileHelper::getFiles('item', $this->item->id)) {
    echo $this->loadTemplate('files');
}
?>
			<?php 
if ($this->params->get('show_contact_form', '1')) {
    ?>
			<div class="djc_clear"></div>
			<div class="djc_contact_form_wrapper" id="contactform">
				<?php 
    echo $this->loadTemplate('contact');
    ?>
			</div>
			<?php 
}
?>
Beispiel #6
0
							<div class="controls">
							<?php 
echo $this->form->getInput('id');
?>
							</div>
						</div>
					</div>

					<div class="tab-pane" id="images">
					<?php 
echo DJCatalog2ImageHelper::renderInput('item', JFactory::getApplication()->input->getInt('id', null), (bool) JComponentHelper::getParams('com_djcatalog2')->get('multiple_image_upload', true));
?>
					</div>
					<div class="tab-pane" id="files">
					<?php 
echo DJCatalog2FileHelper::renderInput('item', JFactory::getApplication()->input->getInt('id', null), (bool) JComponentHelper::getParams('com_djcatalog2')->get('multiple_file_upload', true));
?>
					</div>
					
					<div class="tab-pane" id="location">
					<?php 
foreach ($this->form->getGroup('location') as $field) {
    ?>
						<div class="control-group">
							<div class="control-label"><?php 
    echo $field->label;
    ?>
</div>
							<div class="controls"><?php 
    echo $field->input;
    ?>
Beispiel #7
0
    echo JHtml::_('tabs.panel', JText::_('COM_DJCATALOG2_FORM_FILES'), 'product-files');
    ?>
			<p class="djc_fileupload_tip">
				<?php 
    $file_count_limit = (int) $this->params->get('fed_max_files', 6);
    $file_size_limit = (int) $this->params->get('fed_max_file_size', 2048);
    ?>
				<?php 
    echo JText::sprintf('COM_DJCATALOG2_FILE_MAX_COUNT', $file_count_limit);
    if ($img_size_limit > 0) {
        echo ' | ' . JText::sprintf('COM_DJCATALOG2_FILE_MAX_SIZE', DJCatalog2FileHelper::formatBytes($file_size_limit * 1024));
    }
    ?>
			</p>
			<?php 
    echo DJCatalog2FileHelper::renderInput('item', JFactory::getApplication()->input->getInt('id', null), (bool) $this->params->get('fed_multiple_file_upload', true));
    ?>
			<?php 
}
?>
			
			<?php 
if ((int) $this->params->get('fed_meta', '0') > 0) {
    ?>
			<?php 
    echo JHtml::_('tabs.panel', JText::_('COM_DJCATALOG2_META_DETAILS'), 'product-meta');
    ?>
			<div class="control-group formelm">
				<div class="control-label">
					<?php 
    echo $this->form->getLabel('metatitle');
Beispiel #8
0
 public static function getUploader($uploader_type, $record_type, $item_id, $limit, $size_limit, $whitelist, $files = array(), $multiple_upload)
 {
     $prefix = $suffix = $uploader_type;
     //.'_'.$record_type;
     $uploader_id = 'multiuploader_' . $suffix;
     $wrapper_id = 'djc_uploader_' . $suffix;
     $wrapper_class = 'djc_uploader_' . $uploader_type;
     $document = JFactory::getDocument();
     if (self::$plUpload_scripts_included == false) {
         $document->addScript(JURI::root(false) . 'components/com_djcatalog2/assets/upload/upload.js');
         $script_vars = array();
         $script_vars['url'] = JUri::root(false);
         $script_vars['client'] = JFactory::getApplication()->isAdmin() ? 1 : 0;
         $script_vars['lang'] = array();
         $script_vars['lang']['remove'] = JText::_('COM_DJCATALOG2_DELETE_BTN');
         $script_vars['lang']['limitreached'] = JText::_('COM_DJCATALOG2_UPLOADER_LIMIT_REACHED');
         $document->addScriptDeclaration('var DJCatalog2UploaderVars = ' . json_encode($script_vars));
         self::$plUpload_scripts_included = true;
     }
     $app = JFactory::getApplication();
     $settings = array();
     $settings['max_file_size'] = $size_limit > 0 ? $size_limit . 'kb' : '102400kb';
     $settings['chunk_size'] = '1024kb';
     $settings['resize'] = true;
     $settings['width'] = '2880';
     $settings['height'] = '2880';
     $settings['quality'] = '90';
     $settings['filter'] = implode(',', $whitelist);
     $settings['onUploadedEvent'] = 'DJC2PlUploadInjectUploaded' . ucfirst($uploader_type);
     //.ucfirst($record_type);
     $settings['onAddedEvent'] = 'DJC2PlUploadStartUpload' . ucfirst($uploader_type);
     //.ucfirst($record_type);
     $settings['debug'] = false;
     $layoutFile = dirname(__FILE__) . DS . 'layouts' . DS . $uploader_type . '.php';
     if (JFile::exists($layoutFile) == false) {
         $layoutFile = dirname(__FILE__) . DS . 'layouts' . DS . 'file.php';
     }
     ob_start();
     include $layoutFile;
     $layoutOutput = ob_get_contents();
     ob_end_clean();
     return $layoutOutput;
 }
Beispiel #9
0
 public function onItemAfterDelete($context, $table)
 {
     $params = JComponentHelper::getParams('com_djcatalog2');
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $db->setQuery('DELETE FROM #__djc2_items_categories WHERE item_id=\'' . $table->id . '\'');
     $db->query();
     $db->setQuery('DELETE FROM #__djc2_items_related WHERE item_id=\'' . $table->id . '\' OR related_item=\'' . $table->id . '\'');
     $db->query();
     $db->setQuery('DELETE FROM #__djc2_items_extra_fields_values_text WHERE item_id=\'' . $table->id . '\'');
     $db->query();
     $db->setQuery('DELETE FROM #__djc2_items_extra_fields_values_int WHERE item_id=\'' . $table->id . '\'');
     $db->query();
     if (!DJCatalog2ImageHelper::deleteImages('item', $table->id)) {
         $app->enqueueMessage(JText::_('COM_DJCATALOG2_ERROR_DELETING_IMAGES'), 'error');
     }
     if (!DJCatalog2FileHelper::deleteFiles('item', $table->id)) {
         $app->enqueueMessage(JText::_('COM_DJCATALOG2_ERROR_DELETING_FILE'), 'error');
     }
 }
Beispiel #10
0
 function download()
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $db = JFactory::getDbo();
     $file_id = $app->input->getInt('fid', 0);
     $query = 'select i.created_by ' . 'from #__djc2_items as i, ' . '#__djc2_files as f where f.item_id = i.id and f.id=' . (int) $file_id;
     $db->setQuery($query);
     $owner = $db->loadResult();
     $authorised = $user->authorise('djcatalog2.filedownload', 'com_djcatalog2') || $owner == $user->id ? true : false;
     if ($authorised !== true) {
         if ($user->guest) {
             $return = base64_encode(JRoute::_('index.php?option=com_djcatalog2&format=raw&task=download&fid=' . $file_id, false));
             $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $return, false), JText::_('COM_DJCATALOG2_LOGIN_FIRST'));
             return true;
         } else {
             throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
             return false;
         }
     }
     if (!DJCatalog2FileHelper::getFile($file_id)) {
         throw new Exception('', 404);
         return false;
     }
     // Close the application instead of returning from it.
     $app->close();
     //return true;
 }
Beispiel #11
0
            	<?php 
    echo $this->loadTemplate('children');
    ?>
            </div>
            <?php 
}
?>
            
            <?php 
if (((int) $this->params->get('show_location_map_item', 1) > 0 || (int) $this->params->get('show_location_details_item', 1) > 0) && ($this->item->latitude != 0.0 && $this->item->longitude != 0.0 || (!empty($this->item->address) || !empty($this->item->city)))) {
    echo $this->loadTemplate('map');
}
?>
            
            <?php 
if ($this->params->get('show_files_item', 1) > 0 && ($this->item->files = DJCatalog2FileHelper::getFiles('item', $this->item->id))) {
    echo $this->loadTemplate('files');
}
?>
			<?php 
if ($this->params->get('show_contact_form', '1')) {
    ?>
			<div class="djc_clear"></div>
			<div class="djc_contact_form_wrapper" id="contactform">
				<?php 
    echo $this->loadTemplate('contact');
    ?>
			</div>
			<?php 
}
?>
Beispiel #12
0
 public static function getDestinationPath($itemid, $itemtype)
 {
     return parent::getDestinationPath($itemid, $itemtype);
 }
Beispiel #13
0
 public static function getUploader($uploader_type, $record_type, $item_id, $limit, $size_limit, $whitelist, $files = array(), $multiple_upload)
 {
     $prefix = $suffix = $uploader_type;
     //.'_'.$record_type;
     $uploader_id = 'multiuploader_' . $suffix;
     $wrapper_id = 'djc_uploader_' . $suffix;
     $wrapper_class = 'djc_uploader_' . $uploader_type;
     $params = JComponentHelper::getParams('com_djcatalog2');
     $valid_captions = trim($params->get('allowed_attachment_captions', ''));
     $captions = explode(PHP_EOL, $valid_captions);
     foreach ($captions as $k => $v) {
         if (trim($v) == '') {
             unset($captions[$k]);
             continue;
         }
         $captions[$k] = trim($v);
     }
     $document = JFactory::getDocument();
     if (self::$plUpload_scripts_included == false) {
         $document->addScript(JURI::root(false) . 'components/com_djcatalog2/assets/upload/upload.js');
         $script_vars = array();
         $script_vars['url'] = JUri::root(false);
         $script_vars['client'] = JFactory::getApplication()->isAdmin() ? 1 : 0;
         $script_vars['lang'] = array();
         $script_vars['lang']['remove'] = JText::_('COM_DJCATALOG2_DELETE_BTN');
         $script_vars['lang']['limitreached'] = JText::_('COM_DJCATALOG2_UPLOADER_LIMIT_REACHED');
         if (count($captions) > 0) {
             $script_vars['valid_captions'] = array();
             foreach ($captions as $caption) {
                 $script_vars['valid_captions'][] = '<option value="' . htmlspecialchars($caption) . '">' . htmlspecialchars($caption) . '</option>';
             }
         } else {
             $script_vars['valid_captions'] = false;
         }
         $document->addScriptDeclaration('var DJCatalog2UploaderVars = ' . json_encode($script_vars));
         self::$plUpload_scripts_included = true;
     }
     $app = JFactory::getApplication();
     $settings = array();
     $settings['max_file_size'] = $size_limit > 0 ? $size_limit . 'kb' : '102400kb';
     $settings['chunk_size'] = '1024kb';
     $settings['resize'] = true;
     $settings['width'] = '2880';
     $settings['height'] = '2880';
     $settings['quality'] = '90';
     $settings['filter'] = implode(',', $whitelist);
     $settings['onUploadedEvent'] = 'DJC2PlUploadInjectUploaded' . ucfirst($uploader_type);
     //.ucfirst($record_type);
     $settings['onAddedEvent'] = 'DJC2PlUploadStartUpload' . ucfirst($uploader_type);
     //.ucfirst($record_type);
     $settings['debug'] = false;
     $layoutFile = dirname(__FILE__) . DS . 'layouts' . DS . $uploader_type . '.php';
     if (JFile::exists($layoutFile) == false) {
         $layoutFile = dirname(__FILE__) . DS . 'layouts' . DS . 'file.php';
     }
     ob_start();
     include $layoutFile;
     $layoutOutput = ob_get_contents();
     ob_end_clean();
     return $layoutOutput;
 }