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/nice/administrator/components/com_djcatalog2/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/nice/administrator/components/com_djcatalog2/djcatalog2.script.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('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Component\ComponentHelper;
class com_djcatalog2InstallerScript {
	function update($parent) {
		$config = Factory::getConfig();
		$db = Factory::getDbo();
		$db->setQuery('show tables');
		$tables = $db->loadColumn();
		$db_prefix = $config->get('dbprefix');
		
		/* In v.2.3.rc.3 we added category params feature,
		 * but forgot to add 'params' column declaration to the SQL installation script.
		 * Since there were few schema updates since that modification
		 * and Joomla is not able to 'go back', we need to make sure that 'params' column exists
		 */
		
		if (count($tables) && in_array($db_prefix.'djc2_categories', $tables)) {
			$db->setQuery('SHOW COLUMNS FROM #__djc2_categories');
			$category_columns = $db->loadColumn(0);
			if (!in_array('params', $category_columns)) {
				$db->setQuery('ALTER TABLE #__djc2_categories ADD `params` TEXT');
				$db->execute();
			}
		}
		
		/*
		 * since v.3.2.beta.1
		 * splitting field values from old single table into separate tables
		 */
		$old_table 	= $db_prefix.'djc2_items_extra_fields_values';
		$text_table = $db_prefix.'djc2_items_extra_fields_values_text';
		$int_table 	= $db_prefix.'djc2_items_extra_fields_values_int';
		
		
		// if all three table exist then we should perform the upgrade
		if (in_array($old_table, $tables) && in_array($text_table, $tables) && in_array($int_table, $tables)) {
			$db->setQuery('select count(*) from #__djc2_items_extra_fields_values');
			$old_count = $db->loadResult();
			
			$db->setQuery('select count(*) from #__djc2_items_extra_fields_values_text');
			$text_count = $db->loadResult();
			
			$db->setQuery('select count(*) from #__djc2_items_extra_fields_values_int');
			$int_count = $db->loadResult();
			
			$errors = array();
			
			// is there anything to migrate?
			if ($old_count > 0) {
				/*
				 * if the new _text table isn't empty then probably something went wrong before
				 * so we don't migrate any data
				 */
				if ($text_count == 0) {
					try
					{
						$db->setQuery('insert ignore into #__djc2_items_extra_fields_values_text '
							.' (`id`, `item_id`, `field_id`, `value`)'
							.' select v.id, v.item_id, v.field_id, v.value'
							.' from #__djc2_items_extra_fields_values as v '
							.' inner join #__djc2_items_extra_fields as f on f.id=v.field_id '
							.' where (type=\'html\' or type=\'text\' or type=\'textarea\')');
						$success = $db->execute();
					}
					catch (\RuntimeException $e)
					{
						$errors[] = ($e->getMessage());
					}
				}
				
				/*
				 * if the new _int table isn't empty then probably something went wrong before
				 * so we don't migrate any data
				 */
				if ($int_count == 0) {
					try
					{
						$db->setQuery('insert ignore into #__djc2_items_extra_fields_values_int '
							.' (`id`, `item_id`, `field_id`, `value`)'
							.' select v.id, v.item_id, v.field_id, v.value'
							.' from #__djc2_items_extra_fields_values as v '
							.' inner join #__djc2_items_extra_fields as f on f.id=v.field_id '
							.' where (type=\'select\' or type=\'radio\' or type=\'checkbox\')');
						$db->execute();
						$success = $db->execute();
					}
					catch (\RuntimeException $e)
					{
						$errors[] = ($e->getMessage());
					}
				}
			}
			
			// if during the migration there haven't occurred any errors, remove the old table.
			if (count($errors) == 0) {
				$db->setQuery('drop table #__djc2_items_extra_fields_values');
				$db->execute();
			}
		}
		
		
		// Schema 3.7-2019-01-28 partially missing in install.sql file
		$db->setQuery('SHOW COLUMNS FROM #__djc2_orders');
		$fix1Cols = $db->loadColumn(0);
		if (!in_array('delivery_shipping_days', $fix1Cols)) {
			$db->setQuery('ALTER TABLE `#__djc2_orders` ADD `delivery_shipping_days` INT NOT NULL DEFAULT \'1\' AFTER `delivery_method_id`');
			$db->execute();
		}
		
		$db->setQuery('SHOW COLUMNS FROM #__djc2_order_items');
		$fix2Cols = $db->loadColumn(0);
		if (!in_array('shipping_day', $fix2Cols)) {
			$db->setQuery('ALTER TABLE `#__djc2_order_items` ADD `shipping_day` INT NOT NULL DEFAULT \'1\' AFTER `item_name`');
			$db->execute();
		}
		
		$db->setQuery('SHOW COLUMNS FROM #__djc2_payment_methods');
		$fix3Cols = $db->loadColumn(0);
		if (!in_array('recurring', $fix3Cols)) {
			$db->setQuery('ALTER TABLE `#__djc2_payment_methods` ADD `recurring` TINYINT NOT NULL DEFAULT \'0\' AFTER `postcodes`; ');
			$db->execute();
		}
		
		$db->setQuery('SHOW COLUMNS FROM #__djc2_items');
		$fix4Cols = $db->loadColumn(0);
		if (in_array('granted_usergroups', $fix4Cols)) {
			$db->setQuery('ALTER TABLE `#__djc2_items` CHANGE `granted_usergroups` `grant_usergroups` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;');
			$db->execute();
		}

		$db->setQuery('SHOW COLUMNS FROM #__djc2_items');
		$fix5Cols = $db->loadColumn(0);
		if (!in_array('expiration_cycle_type', $fix5Cols)) {
			$db->setQuery('ALTER TABLE `#__djc2_items` ADD COLUMN `expiration_cycle_type` VARCHAR(3);');
			$db->execute();
		}

		$db->setQuery('SHOW COLUMNS FROM #__djc2_categories');
		$fix6Cols = $db->loadColumn(0);
		if (!in_array('level', $fix6Cols)) {
			$db->setQuery('ALTER TABLE `#__djc2_categories` ADD COLUMN `level` INT;');
			$db->execute();
		}


	}
	
	function preflight($type, $parent)
	{
		$db = Factory::getDbo();
		// Pobierz wersję Joomla
		$version = new \Joomla\CMS\Version;
		$jVersion = $version->getShortVersion(); // np. '3.10.12' albo '4.4.2'

		// Jeśli Joomla 3.x lub 4.x — przerwij instalację
		if (version_compare($jVersion, '3.0.0', '>=') && version_compare($jVersion, '5.0.0', '<')) {
			throw new \RuntimeException('Instalacja DJ-Catalog2 została zablokowana dla Joomla '.$jVersion);
		}

		$query = $db->getQuery(true);
		$query->select('s.extension_id, s.version_id');
		$query->from('#__schemas AS s');
		$query->join('INNER', '#__extensions AS e ON e.extension_id=s.extension_id');
		$query->where('e.element = '.$db->quote('com_djcatalog2'));
		$query->where('e.type = '.$db->quote('component'));
		$db->setQuery($query);
		
		$schema = $db->loadObject();
		
		if (!empty($schema)) {
			// Schema ver. "3.4" was renamed to "3.4.0-2014-05-21"
			// They are technically the same, so we need a workaround
			if ($schema->version_id == '3.4') {
				$uquery = $db->getQuery(true);
				$uquery->update('#__schemas')->set('version_id='.$db->quote('3.4.0-2014-05-21'))->where('extension_id='.$schema->extension_id);
				$db->setQuery($uquery);
				$db->execute();
				
				$schema->version_id = '3.4.0-2014-05-21';
			}
			
			if (version_compare($schema->version_id, '3.9-2021-06-29') == -1 && version_compare($schema->version_id, '3.9-2020-07-06') == 1) {
				$db->setQuery('SHOW COLUMNS FROM #__djc2_delivery_methods');
				$delivery_columns = $db->loadColumn(0);
				if (in_array('note', $delivery_columns)) {
					$aquery = 'ALTER TABLE #__djc2_delivery_methods DROP `note`';
					$db->setQuery($aquery);
					$db->execute();
				}
			}
			
			if (version_compare($schema->version_id, '3.9-2021-05-26') == 1) {
				$db->setQuery('SHOW COLUMNS FROM #__djc2_item_reviews');
				$rev_columns = $db->loadColumn(0);
				if (in_array('language', $rev_columns) == false) {
					$rquery = 'ALTER TABLE `#__djc2_item_reviews`  ADD `language` CHAR(7) NULL DEFAULT \'*\'  AFTER `created`';
					$db->setQuery($rquery);
					$db->execute();
				}
			}
		} else if ($type == 'update' || $type == 'discover_install') {
			if (Folder::exists(JPATH_ROOT.'/administrator/components/com_djcatalog2/install/sqlupdates')) {
				$files = Folder::files(JPATH_ROOT.'/administrator/components/com_djcatalog2/install/sqlupdates', '\.sql$');
				if (count($files)) {
					$files = str_replace('.sql', '', $files);
					usort($files, 'version_compare');
					$currentSchema = end($files);
					
					if (empty($schema)) {
						$query = $db->getQuery(true);
						$query->select('e.extension_id');
						$query->from('#__extensions AS e');
						$query->where('e.element = '.$db->quote('com_djcatalog2'));
						$query->where('e.type = '.$db->quote('component'));
						$db->setQuery($query);
						
						$extId = $db->loadResult();
						
						if ($extId) {
							$uquery = $db->getQuery(true);
							$uquery->insert('#__schemas')->columns(array('version_id', 'extension_id'))->values($db->quote($currentSchema).','.$extId);
							$db->setQuery($uquery);
							$db->execute();
						}
					} else if ($currentSchema != $schema->version_id) {
						$uquery = $db->getQuery(true);
						$uquery->update('#__schemas')->set('version_id='.$db->quote($currentSchema))->where('extension_id='.$schema->extension_id);
						$db->setQuery($uquery);
						$db->execute();
					}
				}
			}
		}
	}
	
	function postflight($type, $parent)
	{
		$extFolder = Path::clean(JPATH_ROOT.'/media/djextensions');
		if (!Folder::exists($extFolder)) {
			Folder::create($extFolder);
		}
		
		$folders = array();
		$folders[] = array(
			'src' => Path::clean(JPATH_ROOT.'/media/djcatalog2/magnific'),
			'dst' => Path::clean(JPATH_ROOT.'/media/djextensions/magnific')
		);
		$folders[] = array(
			'src' => Path::clean(JPATH_ROOT.'/media/djcatalog2/jquery.ui'),
			'dst' => Path::clean(JPATH_ROOT.'/media/djextensions/jquery.ui')
		);
		
		$folders[] = array(
			'src' => Path::clean(JPATH_ROOT.'/media/djcatalog2/jquery-ui-1.13.0'),
			'dst' => Path::clean(JPATH_ROOT.'/media/djextensions/jquery-ui-1.13.0')
		);
		$folders[] = array(
			'src' => Path::clean(JPATH_ROOT.'/media/djcatalog2/misc'),
			'dst' => Path::clean(JPATH_ROOT.'/media/djextensions/misc')
		);
		
		foreach ($folders as $folder) {
			if (Folder::exists($folder['src'])) {
				Folder::move($folder['src'], $folder['dst']);
			}
		}
		
		if ($type == 'update') {
			require_once(Path::clean(JPATH_ADMINISTRATOR.'/components/com_djcatalog2/lib/djlicense.php'));
			DJLicense::setUpdateServer('Catalog2');
		}
		
		$db = Factory::getDbo();
		$db->setQuery('select count(*) from #__djc2_currencies');
		$currencyCount = $db->loadResult();
		
		$db->setQuery('select count(*) from #__djc2_currencies where is_default=1');
		$hasDefaultCurrency = $db->loadResult();
		
		if (!$hasDefaultCurrency && !$currencyCount) {
			$currency = ComponentHelper::getParams('com_djcatalog2')->get('cart_currency', 'USD');
			$query = $db->getQuery(true);
			$query->insert('#__djc2_currencies')->columns(['name', 'currency', 'symbol', 'is_default', 'ordering'])->values($db->quote($currency) . ',' . $db->quote($currency) . ',' . $db->quote($currency) . ', 1, 1');
			$db->setQuery($query);
			$db->execute();
		}
		
	}
}

Anon7 - 2022
AnonSec Team