AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.112
Web Server : Apache
System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : coopiak ( 151928)
PHP Version : 8.3.23
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/coopiak/amisdesseniors-fr/brest/administrator/components/com_djcatalog2/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/brest/administrator/components/com_djcatalog2/controller.php
<?php
/**
 * @package DJ-Catalog2
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */

defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Router\Route;
class Djcatalog2Controller extends BaseController
{
	protected $default_view = 'cpanel';
	public function updategroupsprices()
	{
		$app = Factory::getApplication();
		$jinput = $app->input;
		$db = Factory::getDbo();



		$start = $jinput->get('start', 0);
		$group_id = $jinput->get('group_id', 0);
		$total = $jinput->get('total');
		$lastId = $start;

		$query = $db->getQuery(true);
		$query
			->select('i.id')
			->from($db->quoteName('#__djc2_items', 'i'))
			->join('INNER', $db->quoteName('#__djc2_items_customisations', 'ic') . ' ON ic.item_id = i.id AND ic.group_id = ' . (int)$group_id)
			->join('INNER', $db->quoteName('#__djc2_customisations', 'c') . ' ON c.id = ic.customisation_id')
			->join('INNER', $db->quoteName('#__djc2_customisations_groups_fields', 'cg') . ' ON cg.field_id = ic.customisation_id')
			->where('i.id > ' . (int )$start)
			->group('i.id')
			->limit(5);
		$db->setQuery($query);
		$items = $db->loadObjectList();
		if (count($items)) {

			$query = $db->getQuery(true);
			$query
				->select(array(
					'c.id AS customisation_id',
					'c.price AS price',
					'c.required AS required',
					'c.min_quantity AS min_quantity',
					'c.max_quantity AS max_quantity',
				))
				->from($db->quoteName('#__djc2_customisations', 'c'))
				->join('INNER', $db->quoteName('#__djc2_customisations_groups_fields', 'cg') . ' ON cg.field_id = c.id AND cg.group_id = ' . (int)$group_id);

			$db->setQuery($query);
			$customs = $db->loadObjectList();

			if ($db->execute()) {
				if(count($customs)) {
					foreach ($items as $item) {

						$db->setQuery('DELETE FROM #__djc2_items_customisations WHERE group_id = ' . (int)$group_id . ' AND item_id = ' . (int) $item->id);
						if ($db->execute()) {


							foreach ($customs as $custom) {
								$customObj = new stdClass();
								$customObj->item_id = $item->id;
								$customObj->customisation_id = $custom->customisation_id;
								$customObj->price = $custom->price;
								$customObj->required = $custom->required;
								$customObj->min_quantity = $custom->min_quantity;
								$customObj->max_quantity = $custom->max_quantity;
								$customObj->group_id = $group_id;
								Factory::getDbo()->insertObject('#__djc2_items_customisations', $customObj);
							}
						}

						$lastId = $item->id;

					}
				}
			}


		}

		if($lastId != $start) {
			echo 'Trwa aktualizacja cen';
			header("refresh:1;url=" . 'index.php?option=com_djcatalog2&task=updategroupsprices&start=' . $lastId . '&group_id=' . (int)$group_id);
		}else {
			$app->enqueueMessage('Wszystkie dostosowania zostaƂy zaktualizowane', 'success');
			$app->redirect('index.php?option=com_djcatalog2&view=customisationsgroups');
		}
	}
	function testmsg() {
		$msg = new DJCatalog2HelperMessenger();
		$msg->notify('test@example.com', ['type'=>'order' ,'skip_db' => true], [], ['order_number' => 'x']);
		echo '<pre>' . print_r($msg, true) . '</pre>';
		die();
	}

	public function display($cachable = false, $urlparams = false)
	{
		require_once JPATH_ROOT.'/components/com_djcatalog2/helpers/djcatalog2.php';
		Djcatalog2AdminHelper::addSubmenu(Factory::getApplication()->input->getCmd('view', 'cpanel'));
		parent::display($cachable, $urlparams);
	}
	public function download_file() {
		$app = Factory::getApplication();
		$user = Factory::getUser();
		if (!$user->authorise('core.manage', 'com_djcatalog2') && !$user->authorise('core.admin', 'com_djcatalog2')){
			$app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error');
			$app->setHeader('status', 403, true);
			return;
		}
		$path = $app->input->get('path', null, 'base64');
		$file_path = JPATH_ROOT.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, base64_decode($path));

		if (empty($path) || !File::exists($file_path) || strpos($file_path, 'media') === false || strpos($file_path, 'djcatalog2') === false) {
			$this->setRedirect( 'index.php?option=com_djcatalog2', Text::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;
		}
		$app->close();
		return true;
	}

	public function multiupload() {

		// todo: secure upload from injections
		$user = Factory::getUser();
		if (!$user->authorise('core.manage', 'com_djcatalog2')){
			echo Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN');
			exit(0);
		}

		DJCatalog2UploadHelper::upload();

		return true;
	}

	public function getStatesByCountry() {
		$app = Factory::getApplication();
		$country = $app->input->getInt('country');

		$results = array();

		$db = Factory::getDbo();
		$query = $db->getQuery(true);
		$query->select('cs.*')->from('#__djc2_countries_states AS cs')->order('cs.name asc');

		if ($country > 0) {
			$query->where('cs.country_id='.(int)$country);
		} else {
			$query->join('inner', '#__djc2_countries AS c ON c.id=cs.country_id AND c.is_default=1');
		}

		$db->setQuery($query);
		$results = $db->loadObjectList();

		echo json_encode($results);
		$app->close();
	}

	public function findItemByName()
	{
		// Required objects
		$app = Factory::getApplication();

		$like = $app->input->getString('like', '');

		$db = Factory::getDbo();
		$query = $db->getQuery(true);
		$query->select('id as value, concat(name, " [", id, "]") as text')
			->from('#__djc2_items')
			->where('name like '.$db->quote('%'.$db->escape($like).'%'))
			->order('name asc');

		$db->setQuery($query);

		if ($results = $db->loadObjectList())
		{
			// Output a JSON object
			echo json_encode($results);
		}

		$app->close();
	}

	public function toggleMode() {
		if (!Factory::getUser()->authorise('core.admin', 'com_djcatalog2')){
			throw new Exception(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
		}
		$app = Factory::getApplication();
		$mode = $app->input->getCmd('mode');
		$validModes = array('default', 'catalog');
		if (!in_array($mode, $validModes)) {
			$this->setRedirect(Route::_('index.php?option=com_djcatalog2'), 'Mode "'.$mode.'" is invalid', 'error');
			return false;
		}

		$presetsPath = JPath::clean(JPATH_ROOT.'/administrator/components/com_djcatalog2/assets/presets');

		if (!Folder::exists($presetsPath) || !Folder::exists($presetsPath.'/'.$mode)) {
			$this->setRedirect(Route::_('index.php?option=com_djcatalog2'), 'Mode "'.$mode.'" doesn\'t exist', 'error');
			return false;
		}

		$log = array();

		$adminFiles = Folder::files($presetsPath.'/'.$mode.'/admin');
		$adminFolders = Folder::folders($presetsPath.'/'.$mode.'/admin');

		if (is_array($adminFolders) && count($adminFolders)) {
			foreach($adminFolders as $folder) {
				$target =  JPATH_ROOT.'/administrator/components/com_djcatalog2/'.$folder;
				if (Folder::copy($presetsPath.'/'.$mode.'/admin/'.$folder, $target, '', true)) {
					$log[] = $target.' installed successfully';
				} else {
					$log[] = $target.' copy failed';
				}
			}
		}
		if (is_array($adminFiles) && count($adminFiles)) {
			foreach($adminFiles as $file) {
				$target =  JPATH_ROOT.'/administrator/components/com_djcatalog2/'.$file;
				if (File::copy($presetsPath.'/'.$mode.'/admin/'.$file, $target, '', true)) {
					$log[] = $target.' installed successfully';
				} else {
					$log[] = $target.' copy failed';
				}
			}
		}

		$siteFiles = Folder::files($presetsPath.'/'.$mode.'/site');
		$siteFolders = Folder::folders($presetsPath.'/'.$mode.'/site');

		if (is_array($siteFolders) && count($siteFolders)) {
			foreach($siteFolders as $folder) {
				$target =  JPATH_ROOT.'/components/com_djcatalog2/'.$folder;
				if (Folder::copy($presetsPath.'/'.$mode.'/site/'.$folder, $target, '', true)) {
					$log[] = $target.' installed successfully';
				} else {
					$log[] = $target.' copy failed';
				}
			}
		}
		if (is_array($siteFiles) && count($siteFiles)) {
			foreach($siteFiles as $file) {
				$target =  JPATH_ROOT.'/components/com_djcatalog2/'.$file;
				if (File::copy($presetsPath.'/'.$mode.'/site/'.$file, $target, '', true)) {
					$log[] = $target.' installed successfully';
				} else {
					$log[] = $target.' copy failed';
				}
			}
		}

		$app->enqueueMessage(implode('<br />', $log).'<br /><br />', 'notice');

		$this->setRedirect(Route::_('index.php?option=com_djcatalog2'), 'DJ-Catalog2 switched to "'.$mode.'" mode<br />PLEASE REMEMBER TO CHECK CONFIGURATION', 'notice');
		return true;
	}

	public function fileBrowser(){

		$app = Factory::getApplication();
		$cParams = ComponentHelper::getParams('com_djcatalog2');
		$source = $app->input->getCmd('source', 'image');

		// todo: secure upload from injections
		$user = Factory::getUser();
		if (!$user->authorise('core.create', 'com_djcatalog2')){
			echo Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN');
			exit(0);
		}

		$folder = urldecode($app->input->get('folder','','string'));
		$roots = array_map('trim', explode("\n",$cParams->get('fb_paths','images')));

		$allow = false;
		foreach($roots as $root) {
			if(strpos($folder, $root) === 0) $allow = true;
		}
		if(!$allow) $folder = $roots[0];

		// Set folder path
		$path = Path::clean(JPATH_ROOT . '/' . $folder);

		// Get a list of folders in the search path with the given filter.
		$folders = Folder::folders($path);
		$files = Folder::files($path);

		$html = array();

		$html[] = '<p>';
		if(count($roots) > 1) foreach($roots as $root) {
			$html[] = '<a href="#" class="btn btn-primary btn-small btn-info" data-folder="'.$root.'">'.$root.'</a>';
		}
		$html[] = '</p>';

		$html[] = '<p class="muted">'.$folder.'</p>';

		// Build the options list from the list of folders.
		$html[] = '<ul class="inline folders">';
		if(!in_array($folder, $roots)) {
			$html[] = '<li><a href="#" data-folder="'.dirname($folder).'"><i class="icon-undo"></i> [ .. ]</a></li>';
		}
		if (is_array($folders))
		{
			foreach ($folders as $fldr)
			{
				$html[] = '<li><a href="#" data-folder="'.$folder.'/'.$fldr.'"><i class="icon-folder"></i> '.$fldr.'</a></li>';
			}
		}
		$html[] = '</ul>';

		$html[] = '<ul class="items">';
		if (is_array($files))
		{
			foreach ($files as $file)
			{
				$path = $folder.'/'.$file;

				if ($source == 'image') {
					if(!preg_match('/.+\.(jpg|jpeg|gif|png)$/i', $file) || preg_match('/(_f|_l|_m|_s|_t)\.jpg$/', $file)) continue;

					$size = @getimagesize(JPath::clean(JPATH_ROOT.'/'.$path));
					//$thumb = DJCatalog2ImageHelper::getProcessedImage($path, 200, 150, true); // ta funkcja nie zwraca miniatury - do sprawdzenia dlaczego
					//if($size[0] < 200 || $size[1] < 150 || !$thumb) {
					$thumb = $path;
					//}

					$html[] = '<li><a class="additem" href="#" data-path="'.$path.'"><span class="valignhelper"></span><img src="'.JURI::root(true).'/'.$thumb.'" /><span class="icon-plus"></span><span class="icon-minus"></span></a><span class="name">'.$file.'</span></li>';

				} else if ($source == 'video') {
					if(!preg_match('/.+\.(avi|mp4|mpeg)$/i', $file)) continue;
					$html[] = '<li><a class="additem" href="#" data-path="'.$path.'"><span class="valignhelper"></span><code>'.$file.'</code><span class="icon-plus"></span><span class="icon-minus"></span></a><span class="name">'.$file.'</span></li>';
				}
			}
		}

		$html[] = '</ul><div style="clear:both"></div>';

		echo implode("\n", $html);

		$app->close();
	}


	/**
	 * Method to search Joomla content articles
	 *
	 * @return  void
	 */
	public function searchArticleAjax()
	{
		// Required objects
		$app = Factory::getApplication();

		$like = trim((string)$app->input->get('like', null, 'string'));

		$db = Factory::getDbo();
		$query = $db->getQuery(true);

		$query->select(array($db->quoteName('a.id', 'value'), $db->quoteName('a.title', 'text')))
			->from($db->quoteName('#__content', 'a'))
			->where($db->quoteName('a.title') . ' LIKE ' . $db->quote('%' . $db->escape($like) . '%'));

		$db->setQuery($query);
		$results = $db->loadObjectList();

		echo json_encode($results);

		$app->close();
	}
}

?>

Anon7 - 2022
AnonSec Team