Current Path :
/
home
/
develito
/
www
/
tmp
/
install_61117129093a9
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/www/tmp/install_61117129093a9/spinstall.php
<?php /** * @package: SobiPro Component for Joomla! * * @author * Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH * Email: sobi[at]sigsiu.net * Url: https://www.Sigsiu.NET * * @copyright Copyright (C) 2006 - 2020 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved. * @license GNU/GPL Version 3 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3. * See https://www.gnu.org/licenses/gpl.html and https://www.sigsiu.net/licenses. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * @modified 04 November 2020 by Sigrid Suski */ defined( '_JEXEC' ) || exit( 'Restricted access' ); use Joomla\CMS\Factory; use Joomla\CMS\Filesystem\File; use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Installer\Installer; use Joomla\CMS\Log\Log; /** * Class com_sobiproInstallerScript */ class com_sobiproInstallerScript { /** * The minimum PHP version required to install this SobiPro version * * @var string */ protected $minimumPHPVersion = '7.1.0'; /** * The minimum Joomla! version required to install this SobiPro version * * @var string */ protected $minimumJoomlaVersion = '3.7.0'; /** * The maximum Joomla! version this SobiPro version can be installed on * * @var string */ protected $maximumJoomlaVersion = '3.99.999'; /** * @return mixed|null */ protected function getInstalledSobiPro() { $db = Factory::getDbo(); $query = $db->getQuery( true ); $installed = null; $query->select( $db->quoteName( [ 'name', 'manifest_cache', 'type' ] ) ) ->from( $db->quoteName( '#__extensions' ) ) ->where( $db->quoteName( 'type' ) . ' = ' . $db->quote( 'component' ) ) ->where( $db->quoteName( 'element' ) . ' = ' . $db->quote( 'com_sobipro' ) ); $extension = $db->setQuery( $query )->loadObjectList(); if ( count( $extension ) ) { $installed = json_decode( $extension[ 0 ]->manifest_cache ); } return $installed; } /** * Called before any type of action. * Runs just before any installation action is performed on the component. * Verifications and pre-requisites should run in this function. * * @param $action -> Which action is happening (install|discover_install|update) * @param $adapter -> The object responsible for running this script * * @return bool -> True to let the installation proceed, false to halt the installation */ public function preflight( $action, $adapter ) { $return = true; /* Version from current installation manifest file version */ $manifest = $adapter->getManifest(); $this->release = $manifest->version; // Check the minimum PHP version if ( !version_compare( PHP_VERSION, $this->minimumPHPVersion, 'ge' ) ) { $msg = "<p><strong>You need PHP $this->minimumPHPVersion or later to install SobiPro $this->release!</strong></p>"; Log::add( $msg, Log::ERROR, 'jerror' ); $return = false; } // Check the minimum Joomla! version if ( !version_compare( JVERSION, $this->minimumJoomlaVersion, 'ge' ) ) { $msg = "<p><strong>You need Joomla! $this->minimumJoomlaVersion or later to install SobiPro $this->release!</strong></p>"; Log::add( $msg, Log::ERROR, 'jerror' ); $return = false; } // Check the maximum Joomla! version if ( !version_compare( JVERSION, $this->maximumJoomlaVersion, 'le' ) ) { $msg = "<p><strong>You need Joomla! $this->maximumJoomlaVersion or earlier to install SobiPro $this->release.</strong></p>"; Log::add( $msg, Log::ERROR, 'jerror' ); $return = false; } if ( $action == 'update' ) { /* Get the minimum SobiPro version this SobiPro version can be installed on */ $vString = 'version'; $minimumSobiProVersion = (string) $manifest->SobiPro->requirements->core->attributes()->$vString; $installedSobiPro = $this->getInstalledSobiPro(); if ( $installedSobiPro && $installedSobiPro->version < $minimumSobiProVersion ) { $msg = "<p><strong>You have installed SobiPro $installedSobiPro->version. Please install first SobiPro $minimumSobiProVersion and then SobiPro $this->release!</strong></p>"; Log::add( $msg, Log::ERROR, 'jerror' ); $return = false; } } if ( !$return ) { return false; } /* Always reset the OPcache if it's enabled. Otherwise there's a good chance the server will not know we are replacing .php scripts. This is a major concern since PHP 5.5 included and enabled OPcache by default. */ if ( function_exists( 'opcache_reset' ) ) { opcache_reset(); } clearstatcache(); // Show the essential information at the install/update back-end echo "<h2>Installing SobiPro version $this->release ...</h2>"; /* Installing the SobiPro header plugin */ $this->installPlugins( $adapter->getParent()->get( 'paths' ) ); return true; } /** * Called after any type of action. * Runs right after any installation action is performed on the component. * * @param $action -> Which action is happening (install|discover_install|update) * @param $adapter -> The object responsible for running this script */ public function postflight( $action, $adapter ) { } /** * Called on update. * * @return bool * @throws \SPException * @throws \Sobi\Error\Exception */ public function update() { $this->updateFilesandFolders(); $db = Factory::getDBO(); /* Table structure modifications */ /* ----------------------------- */ /* __sobipro_view_cache */ try { $db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_view_cache` (`cid` INT(11) NOT NULL AUTO_INCREMENT, `section` INT(11) NOT NULL, `sid` INT(11) NOT NULL, `fileName` VARCHAR(100) NOT NULL, `task` VARCHAR(100) NOT NULL, `site` INT(11) NOT NULL, `request` VARCHAR(190) NOT NULL, `language` VARCHAR(15) NOT NULL, `template` VARCHAR(150) NOT NULL, `configFile` TEXT NOT NULL, `userGroups` VARCHAR(190) NOT NULL, `created` DATETIME NOT NULL, PRIMARY KEY (`cid`), KEY `sid` (`sid`), KEY `section` (`section`), KEY `language` (`language`), KEY `task` (`task`), KEY `request` (`request`), KEY `site` (`site`), KEY `userGroups` (`userGroups`)) ENGINE = InnoDB DEFAULT CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`;' )->execute(); $db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_view_cache_relation` (`cid` INT(11) NOT NULL, `sid` INT(11) NOT NULL, PRIMARY KEY (`cid`, `sid`)) ENGINE = InnoDB DEFAULT CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`;' )->execute(); } catch ( Exception $x ) { } /* __sobipro_user_group */ try { $db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_user_group` (`description` TEXT, `gid` INT(11) NOT NULL AUTO_INCREMENT, `enabled` INT(11) NOT NULL, `pid` INT(11) NOT NULL, `groupName` VARCHAR(150) NOT NULL, PRIMARY KEY (`gid`)) ENGINE = InnoDB DEFAULT CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci` AUTO_INCREMENT = 5000;' )->execute(); } catch ( Exception $x ) { } /* __sobipro_counter */ try { $db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_counter` (`sid` INT(11) NOT NULL, `counter` INT(11) NOT NULL, `lastUpdate` DATETIME NOT NULL, PRIMARY KEY (`sid`)) ENGINE = InnoDB DEFAULT CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`;' )->execute(); } catch ( Exception $x ) { } /* __sobipro_history */ try { $db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_history` (`revision` VARCHAR(150) NOT NULL, `changedAt` DATETIME NOT NULL, `uid` INT(11) NOT NULL, `userName` VARCHAR(150) NOT NULL, `userEmail` VARCHAR(150) NOT NULL, `changeAction` VARCHAR(150) NOT NULL, `site` ENUM (\'site\', \'adm\') NOT NULL, `sid` INT(11) NOT NULL, `changes` TEXT NOT NULL, `params` TEXT NOT NULL, `reason` TEXT NOT NULL, `language` VARCHAR(50) NOT NULL, PRIMARY KEY (`revision`)) ENGINE = InnoDB DEFAULT CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`;' )->execute(); } catch ( Exception $x ) { } /* rename column `change` to `changeAction` */ $db->setQuery( 'SHOW INDEX FROM #__sobipro_history' ); $cols = $db->loadAssocList(); $skip = false; foreach ( $cols as $col ) { if ( $col[ 'Key_name' ] == 'changeAction' ) { $skip = true; continue; } } if ( !( $skip ) ) { try { $db->setQuery( 'ALTER TABLE `#__sobipro_history` CHANGE `change` `changeAction` VARCHAR(150) CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci` NOT NULL;' )->execute(); } catch ( Exception $x ) { } } /* __sobipro_field */ try { $db->setQuery( 'ALTER TABLE `#__sobipro_field` CHANGE `notice` `notice` TEXT CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci` NOT NULL;' )->execute(); } catch ( Exception $x ) { } /* __sobipro_field_data */ try { $db->setQuery( 'ALTER TABLE #__sobipro_field_data CONVERT TO CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`' )->execute(); $db->setQuery( 'ALTER TABLE #__sobipro_field_data CHANGE `baseData` `baseData` LONGTEXT CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`;' )->execute(); } catch ( Exception $x ) { } try { $db->setQuery( 'SHOW INDEX FROM #__sobipro_field_data' ); $cols = $db->loadAssocList(); $skip = false; foreach ( $cols as $col ) { if ( $col[ 'Key_name' ] == 'baseData' ) { $skip = true; continue; } } if ( !( $skip ) ) { $db->setQuery( 'ALTER TABLE #__sobipro_field_data ENGINE = MYISAM;' )->execute(); $db->setQuery( 'ALTER TABLE #__sobipro_field_data ADD FULLTEXT `baseData` (`baseData`);' )->execute(); } } catch ( Exception $x ) { } try { $db->setQuery( 'SHOW COLUMNS FROM #__sobipro_field_data' ); $cols = $db->loadAssocList( 'Field' ); if ( !( isset( $cols[ 'editLimit' ] ) ) ) { $db->setQuery( 'ALTER TABLE `#__sobipro_field_data` ADD `editLimit` INT( 11 );' )->execute(); } } catch ( Exception $x ) { } /* __sobipro_field_option (1.5.1) */ try { $db->setQuery( 'ALTER TABLE #__sobipro_field_option CONVERT TO CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`' )->execute(); $db->setQuery( 'ALTER TABLE #__sobipro_field_option_selected CONVERT TO CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`' )->execute(); $db->setQuery( 'ALTER TABLE #__sobipro_field_option_selected CHANGE `params` `params` MEDIUMTEXT CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci` NULL DEFAULT NULL;' )->execute(); } catch ( Exception $x ) { } /* __sobipro_field_url_clicks */ try { $db->setQuery( 'CREATE TABLE IF NOT EXISTS `#__sobipro_field_url_clicks` (`date` DATETIME NOT NULL, `uid` INT(11) NOT NULL, `sid` INT(11) NOT NULL, `fid` VARCHAR(50) NOT NULL, `ip` VARCHAR(15) NOT NULL, `section` INT(11) NOT NULL, `browserData` TEXT NOT NULL, `osData` TEXT NOT NULL, `humanity` INT(3) NOT NULL, PRIMARY KEY (`date`, `sid`, `fid`, `ip`, `section`)) ENGINE = InnoDB DEFAULT CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`;' )->execute(); } catch ( Exception $x ) { } /* __sobipro_object (1.6.1) */ try { $db->setQuery( 'ALTER TABLE #__sobipro_object CHANGE `validUntil` `validUntil` DATETIME NULL DEFAULT NULL' )->execute(); $db->setQuery( 'ALTER TABLE #__sobipro_object CHANGE `updatedTime` `updatedTime` DATETIME NULL DEFAULT NULL' )->execute(); } catch ( Exception $x ) { } /* __sobipro_language */ try { $db->setQuery( 'ALTER TABLE #__sobipro_language CONVERT TO CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`' )->execute(); } catch ( Exception $x ) { } try { $db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `section` `section` INT(11) NOT NULL DEFAULT 0' )->execute(); /*1.6.1*/ $db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `sKey` `sKey` VARCHAR(150) CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci` NULL DEFAULT NULL;' )->execute(); $db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `language` `language` VARCHAR(50) CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci` NULL DEFAULT NULL;' )->execute(); $db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `oType` `oType` VARCHAR(150) CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`;' )->execute(); $db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `params` `params` MEDIUMTEXT CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`;' )->execute(); $db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `options` `options` MEDIUMTEXT CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`;' )->execute(); $db->setQuery( 'ALTER TABLE #__sobipro_language CHANGE `explanation` `explanation` MEDIUMTEXT CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`;' )->execute(); } catch ( Exception $x ) { } $db->setQuery( 'SHOW INDEX FROM #__sobipro_language' ); $cols = $db->loadAssocList(); $skip = false; foreach ( $cols as $col ) { if ( $col[ 'Key_name' ] == 'sValue' ) { $skip = true; continue; } } if ( !( $skip ) ) { try { $db->setQuery( 'ALTER TABLE `#__sobipro_language` ENGINE = MYISAM;' )->execute(); } catch ( Exception $x ) { } try { $db->setQuery( 'ALTER TABLE `#__sobipro_language` ADD FULLTEXT `sValue` (`sValue`);' )->execute(); } catch ( Exception $x ) { } } /* __sobipro_relations */ try { $db->setQuery( 'ALTER TABLE #__sobipro_relations CHANGE `copy` `copy` TINYINT(1) NOT NULL DEFAULT 0' )->execute(); } catch ( Exception $x ) { } /* __sobipro_permissions */ try { $db->setQuery( 'SHOW INDEX FROM `#__sobipro_permissions` WHERE `Key_name` = "uniquePermission"' ); $cols = $db->loadAssocList(); $skip = is_array( $cols ) && count( $cols ); if ( !( $skip ) ) { $db->setQuery( 'ALTER TABLE `#__sobipro_permissions` ADD UNIQUE `uniquePermission` ( `subject` , `action` , `value` , `site` );' )->execute(); } } catch ( Exception $x ) { } /* __sobipro_category */ $col = $db->setQuery( "SHOW COLUMNS FROM `#__sobipro_category` LIKE 'allFields'" )->loadResult(); if ( $col != 'allFields' ) { try { $db->setQuery( 'ALTER TABLE `#__sobipro_category` ADD `allFields` TINYINT(2) NOT NULL AFTER `showIcon`, ADD `entryFields` TEXT NOT NULL AFTER `allFields`;' )->execute(); $db->setQuery( 'UPDATE `#__sobipro_category` SET `allFields` = 1' )->execute(); } catch ( Exception $x ) { } } $col = $db->setQuery( "SHOW COLUMNS FROM `#__sobipro_category` LIKE 'section'" )->loadResult(); if ( $col != 'section' ) { $categories = null; try { $db->setQuery( 'ALTER TABLE `#__sobipro_category` ADD `section` INT(11) AFTER `id`;' )->execute(); $categories = $db->setQuery( 'SELECT `id` FROM `#__sobipro_category` WHERE 1' )->loadColumn(); } catch ( Exception $x ) { } if ( is_array( $categories ) && count( $categories ) ) { require_once( JPATH_SITE . '/components/com_sobipro/lib/sobi.php' ); Sobi::Initialise(); foreach ( $categories as $i => $id ) { $parent = SPFactory::config()->getParentPath( $id ); $sid = ( is_array( $parent ) && count( $parent ) ) ? $parent[ 0 ] : 0; try { $db->setQuery( "UPDATE `#__sobipro_category` SET `section` = {$sid} WHERE `id` = {$id};" )->execute(); } catch ( Exception $x ) { } } } } /* __sobipro_crawler */ try { $db->setQuery( "CREATE TABLE IF NOT EXISTS `#__sobipro_crawler` ( `url` VARCHAR(190) NOT NULL,`crid` INT(11) NOT NULL AUTO_INCREMENT,`state` TINYINT(1) NOT NULL, PRIMARY KEY (`crid`), UNIQUE KEY `url` (`url`) ) ENGINE=InnoDB DEFAULT CHARSET=`utf8mb4` COLLATE = `utf8mb4_unicode_ci`;" )->execute(); } catch ( Exception $x ) { } /*1.6.4 */ /* __sobipro_language */ try { $db->setQuery( 'ALTER TABLE `#__sobipro_language` CHANGE `sValue` `sValue` MEDIUMTEXT CHARACTER SET `utf8mb4` COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;' )->execute(); } catch ( Exception $x ) { } /* __sobipro_config */ try { $db->setQuery( 'ALTER TABLE `#__sobipro_config` CHANGE `sValue` `sValue` TEXT CHARACTER SET `utf8mb4` COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;' )->execute(); } catch ( Exception $x ) { } /* __sobipro_search */ try { $db->setQuery( 'ALTER TABLE `#__sobipro_search` CHANGE `requestData` `requestData` TEXT CHARACTER SET `utf8mb4` COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;' )->execute(); $db->setQuery( 'ALTER TABLE `#__sobipro_search` CHANGE `ssid` `ssid` VARCHAR(50) NOT NULL;' )->execute(); $db->setQuery( 'ALTER TABLE `#__sobipro_search` CHANGE `entriesResults` `entriesResults` LONGTEXT CHARACTER SET `utf8mb4` COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;' )->execute(); $db->setQuery( 'ALTER TABLE `#__sobipro_search` CHANGE `catsResults` `catsResults` MEDIUMTEXT CHARACTER SET `utf8mb4` COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL;' )->execute(); } catch ( Exception $x ) { } /* Table content modifications */ /* --------------------------- */ /* __sobipro_language */ try { $db->setQuery( "INSERT IGNORE INTO `#__sobipro_language` (`sKey`, `sValue`, `section`, `language`, `oType`, `fid`, `id`, `params`, `options`, `explanation`) VALUES ('rejection-of-a-new-entry', 'Entry {entry.name} has been rejected as it does not comply with the rules.\n\n<br/>Rejected by {user.name}\n<br/>at {date%d F Y H:i:s}\n', 0, 'en-GB', 'rejections-templates', 0, 1, '', '', ''), ('rejection-of-changes', 'Changes in {entry.name} discarded as these changes violating rules.\n\n<br/>Rejected by {user.name}\n<br/>at {date%d F Y H:i:s}\n', 0, 'en-GB', 'rejections-templates', 0, 1, '', '', '');" )->execute(); $db->setQuery( "UPDATE #__sobipro_language SET `sKey` = REPLACE( `sKey` , '_', '-' ) WHERE `oType` = 'field_option'" )->execute(); /* 1.1 */ } catch ( Exception $x ) { } /* __sobipro_field_option */ try { $db->setQuery( "UPDATE #__sobipro_field_option_selected SET `optValue` = REPLACE (`optValue`, '_', '-')" )->execute(); /* 1.1 */ $db->setQuery( "UPDATE #__sobipro_field_option SET `optValue` = REPLACE (`optValue`, '_', '-')" )->execute(); /*1.1 */ } catch ( Exception $x ) { } /* __sobipro_permissions */ try { $db->setQuery( "INSERT IGNORE INTO `#__sobipro_permissions` (`pid`, `subject`, `action`, `value`, `site`, `published`) VALUES (86, 'entry', '*', '*', 'adm', 1), (87, 'category', '*', '*', 'adm', 1), (88, 'section', '*', '*', 'adm', 1), (89, 'section', 'access', '*', 'adm', 1), (90, 'section', 'configure', '*', 'adm', 1), (91, 'section', 'delete', '*', 'adm', 0), (92, 'category', 'edit', '*', 'adm', 1), (93, 'category', 'add', '*', 'adm', 1), (94, 'category', 'delete', '*', 'adm', 1), (95, 'entry', 'edit', '*', 'adm', 1), (96, 'entry', 'add', '*', 'adm', 1), (97, 'entry', 'delete', '*', 'adm', 1), (98, 'entry', 'approve', '*', 'adm', 1), (99, 'entry', 'publish', '*', 'adm', 1);" )->execute(); $db->setQuery( "INSERT IGNORE INTO `#__sobipro_permissions` (`pid`, `subject`, `action`, `value`, `site`, `published`) VALUES (NULL, 'section', 'search', '*', 'front', 1), (NULL, 'entry', 'delete', 'own', 'front', 1),(NULL, 'entry', 'delete', '*', 'front', 1), (NULL, 'entry', 'manage', 'own', 'front', 1), (NULL, 'entry', 'access', 'expired_own', 'front', 1), (NULL, 'entry', 'access', 'expired_any', 'front', 1);;;" )->execute(); $db->setQuery( "UPDATE `#__sobipro_permissions` SET `value` = '*' WHERE `pid` = 18;" )->execute(); $db->setQuery( 'DELETE FROM `#__sobipro_permissions` WHERE `pid` = 5;' )->execute(); } catch ( Exception $x ) { } /* __sobipro_registry */ try { $db->setQuery( "INSERT IGNORE INTO `#__sobipro_registry` (`section`, `key`, `value`, `params`, `description`, `options`) VALUES ('rejections-templates', 'rejection-of-a-new-entry', 'Rejection of a new entry', 'YTo0OntzOjE3OiJ0cmlnZ2VyLnVucHVibGlzaCI7YjoxO3M6MTc6InRyaWdnZXIudW5hcHByb3ZlIjtiOjA7czo5OiJ1bnB1Ymxpc2giO2I6MTtzOjc6ImRpc2NhcmQiO2I6MDt9', '', ''), ('rejections-templates', 'rejection-of-changes', 'Rejection of changes', 'YTo0OntzOjE3OiJ0cmlnZ2VyLnVucHVibGlzaCI7YjowO3M6MTc6InRyaWdnZXIudW5hcHByb3ZlIjtiOjE7czo5OiJ1bnB1Ymxpc2giO2I6MDtzOjc6ImRpc2NhcmQiO2I6MTt9', '', '');" )->execute(); $db->setQuery( "UPDATE `#__sobipro_registry` SET `params` = 'L15bXHdcLi1dK0BbXHdcLi1dK1wuW2EtekEtWl17MiwyNH0kLw==' WHERE `key` = 'email' " )->execute(); } catch ( Exception $x ) { } /* __sobipro_field_types */ try { $db->setQuery( "INSERT IGNORE INTO `#__sobipro_field_types` (`tid`, `fType`, `tGroup`, `fPos`) VALUES ('category', 'Category', 'special', 11);" )->execute(); $db->setQuery( "INSERT IGNORE INTO `#__sobipro_field_types` (`tid`, `fType`, `tGroup`, `fPos`) VALUES ('info', 'Information', 'free_single_simple_data', 6);" )->execute(); $db->setQuery( "INSERT IGNORE INTO `#__sobipro_field_types` (`tid`, `fType`, `tGroup`, `fPos`) VALUES ('button', 'Button', 'special', 5);" )->execute(); } catch ( Exception $x ) { } /* __sobipro_plugins */ try { $db->setQuery( "INSERT IGNORE INTO `#__sobipro_plugins` (`pid`, `name`, `version`, `description`, `author`, `authorURL`, `authorMail`, `enabled`, `type`, `depend`) VALUES ('category', 'Category', '2.0', NULL, 'Sigsiu.NET GmbH', 'https://www.sigsiu.net/', 'sobi@sigsiu.net', 1, 'field', '');" )->execute(); $db->setQuery( "INSERT IGNORE INTO `#__sobipro_plugins` (`pid`, `name`, `version`, `description`, `author`, `authorURL`, `authorMail`, `enabled`, `type`, `depend`) VALUES ('info', 'Information', '2.0', NULL, 'Sigsiu.NET GmbH', 'https://www.sigsiu.net/', 'sobi@sigsiu.net', 1, 'field', '');" )->execute(); $db->setQuery( "INSERT IGNORE INTO `#__sobipro_plugins` (`pid`, `name`, `version`, `description`, `author`, `authorURL`, `authorMail`, `enabled`, `type`, `depend`) VALUES ('button', 'Button', '2.0', NULL, 'Sigsiu.NET GmbH', 'https://www.sigsiu.net/', 'sobi@sigsiu.net', 1, 'field', '');" )->execute(); } catch ( Exception $x ) { } /* __sobipro_config */ try { $db->setQuery( "INSERT IGNORE INTO `#__sobipro_config` ( `sKey` , `sValue` , `section` , `critical` , `cSection` ) VALUES ( 'icon_fonts_load', '1', 1 , NULL , 'template' )" )->execute(); /* 1.4.6 (set it for section 1 if it does not exist) */ $db->setQuery( 'DELETE FROM `#__sobipro_config` WHERE `sKey` = "xml_raw" AND `section` = 0;' )->execute(); $db->setQuery( 'DELETE FROM `#__sobipro_config` WHERE `sKey` = "field_types_for_ordering"' )->execute(); } catch ( Exception $x ) { } if ( $this->installFramework() ) { echo '<div class="alert alert-info" style="margin-top: 20px;"><h3>Thank you for updating SobiPro!</h3><p>SobiPro is checking your system now, please see if there are errors or warnings. If the system check reports errors, your SobiPro installation will probably not work. If you see warnings, some functionality of SobiPro can be disturbed or malfunction. In these cases you should take a look to the <a href="https://www.sigsiu.net/sobipro/requirements"><strong>Requirements for SobiPro</strong></a> page on our website.</p> <p>You can install languages directly from our <a href="index.php?option=com_sobipro&task=extensions.browse"><strong>Repository</strong></a> or download them from our <a href="https://www.sigsiu.net/center/languages"><strong>website</strong></a> and install it in the <a href="index.php?option=com_sobipro&task=extensions.installed"><strong>SobiPro Application Manager</strong></a>.</p></div>'; echo '<iframe src="index.php?option=com_sobipro&task=requirements&init=1&tmpl=component" style="border: 1px solid #e0e0e0; border-radius: 5px; height: 900px; min-width: 1000px; width: 99%; margin-bottom: 50px; padding-left: 10px; padding-top: 10px;"></iframe>'; return true; } else { return false; } } /** * Called on installation. * * @return bool */ public function install() { $this->updateFilesandFolders(); /* allow public search for new installations */ $db = Factory::getDBO(); $db->setQuery( 'SELECT `pid` FROM `#__sobipro_permissions` WHERE `subject` = "section" AND `action` = "search"' ); $pid = $db->loadResult(); $db->setQuery( "INSERT IGNORE INTO `#__sobipro_permissions_map` (`rid`, `sid`, `pid`) VALUES (1, 1, {$pid})" )->execute(); if ( $this->installFramework() ) { echo '<div class="alert alert-info" style="margin-top: 20px;"><h3>Welcome to SobiPro!</h3><p>SobiPro is checking your system now, please see if there are errors or warnings. If the system check reports errors, your SobiPro installation will probably not work. If you see warnings, some functionality of SobiPro can be disturbed or malfunction. In these cases you should take a look to the <a href="https://www.sigsiu.net/sobipro/requirements"><strong>Requirements for SobiPro</strong></a> page on our website.</p> <p>You can install languages directly from our <a href="index.php?option=com_sobipro&task=extensions.browse"><strong>Repository</strong></a> or download them from our <a href="https://www.sigsiu.net/center/languages"><strong>website</strong></a> and install it in the <a href="index.php?option=com_sobipro&task=extensions.installed"><strong>SobiPro Application Manager</strong></a>.</p></div>'; echo '<iframe src="index.php?option=com_sobipro&task=requirements&init=1&tmpl=component" style="border: 1px solid #e0e0e0; border-radius: 5px; height: 900px; min-width: 1000px; width: 99%; margin-bottom: 50px; padding-left: 10px; padding-top: 10px;"></iframe>'; return true; } else { return false; } } /** * @param $source */ protected function installPlugins( $source ) { $source = $source[ 'source' ]; $plugins = [ 'Header' ]; $path = $source . '/Plugins'; $installer = new Installer; $db = Factory::getDBO(); foreach ( $plugins as $plugin ) { $dir = $path . '/' . $plugin; $installer->install( $dir ); $db->setQuery( "UPDATE #__extensions SET enabled = '1' WHERE element = 'sp{$plugin}';" )->execute(); } } /** * Called on uninstallation. */ public function uninstall( $id ) { $db = Factory::getDBO(); $error = false; $installedSobiPro = $this->getInstalledSobiPro(); if ( $installedSobiPro ) { $msg = "<p>Uninstalling SobiPro version $installedSobiPro->version ...</p>"; } else { $msg = "<p>Uninstalling SobiPro ...</p>"; } Log::add( $msg, Log::INFO, 'jerror' ); /* remove the header plugin */ $query = $db->getQuery( true ) ->select( 'extension_id' ) ->from( '#__extensions' ) ->where( 'type = ' . $db->quote( 'plugin' ) ) ->where( 'element = ' . $db->quote( 'spHeader' ) ); $id = $db->setQuery( $query )->loadResult(); if ( $id ) { $installer = new Installer; $installer->uninstall( 'plugin', $id, 0 ); $msg = "<span>...SobiPro Header plugin removed</span>"; Log::add( $msg, Log::INFO, 'jerror' ); } /* remove the framework */ if ( Folder::delete( implode( '/', [ JPATH_ROOT, 'libraries', 'sobi' ] ) ) ) { $msg = "<span>...SobiPro Framework removed</span>"; Log::add( $msg, Log::INFO, 'jerror' ); } else { $msg = "<span>Error removing SobiPro Framework. Please remove it manually from '/libraries/sobi'.</span>"; Log::add( $msg, Log::WARNING, 'jerror' ); $error = true; } /* remove all tables starting with SobiPro prefix */ try { $prefix = $db->getPrefix(); $db->setQuery( "show tables like '" . $prefix . "sobipro_%'" ); $tables = $db->loadColumn(); foreach ( $tables as $table ) { $db->setQuery( "DROP TABLE {$table};" )->execute(); } $msg = "<span>...all SobiPro '$prefix" . "sobipro_' tables removed from database</span>"; Log::add( $msg, Log::INFO, 'jerror' ); } catch ( Exception $x ) { $msg = "<span>Error removing SobiPro tables from database. Please remove all tables starting with '$prefix" . "sobipro_' manually.</span>"; Log::add( $msg, Log::WARNING, 'jerror' ); $error = true; } /* delete the SobiPro folder from the images folder */ if ( Folder::delete( implode( '/', [ JPATH_ROOT, 'images', 'sobipro' ] ) ) ) { $msg = "<span>...all SobiPro files removed from images folder</span>"; Log::add( $msg, Log::INFO, 'jerror' ); } else { $msg = "<span>Error removing files from images folder. Please remove them manually.</span>"; Log::add( $msg, Log::WARNING, 'jerror' ); $error = true; } /* Finish message */ if ( $error ) { $msg = '<p><br/><strong>Done! Please check the occurred problems and fix them manually to remove SobiPro completely from your system.</strong></p>'; } else { $msg = '<p><br/><strong>Done! All SobiPro files and database tables have been removed from your system.</strong></p>'; } Log::add( $msg, Log::INFO, 'jerror' ); $msg = "<p><strong>Thank you for using SobiPro!</strong></p>"; Log::add( $msg, Log::INFO, 'jerror' ); } /** * */ protected function updateFilesandFolders() { /* Images folder (category images) */ if ( !( file_exists( implode( '/', [ JPATH_ROOT, 'images', 'sobipro' ] ) ) ) ) { Folder::create( implode( '/', [ JPATH_ROOT, 'images', 'sobipro' ] ) ); } if ( !( file_exists( implode( '/', [ JPATH_ROOT, 'images', 'sobipro', 'categories' ] ) ) ) ) { Folder::create( implode( '/', [ JPATH_ROOT, 'images', 'sobipro', 'categories' ] ) ); if ( file_exists( JPATH_ROOT . '/components/com_sobipro/tmp/install/image.png' ) ) { File::move( JPATH_ROOT . '/components/com_sobipro/tmp/install/image.png', JPATH_ROOT . '/images/sobipro/categories/image.png' ); } } /* Handling sample data */ if ( file_exists( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'tmp', 'SampleData', 'entries' ] ) ) ) { Folder::move( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'tmp', 'SampleData', 'entries' ] ), implode( '/', [ JPATH_ROOT, 'images', 'sobipro', 'entries' ] ) ); } /* Delete temporary installation folders and unnecessary files */ if ( file_exists( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'usr', 'locale' ] ) ) ) { Folder::delete( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'usr', 'locale' ] ) ); } if ( file_exists( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'services', 'installers', 'schemas', 'application.xsd' ] ) ) ) { Folder::delete( implode( '/', [ JPATH_ROOT, 'components', 'com_sobipro', 'services', 'installers', 'schemas', 'application.xsd' ] ) ); } /* Update repository */ try { define( 'SOBIPRO', true ); require_once( JPATH_SITE . '/components/com_sobipro/lib/sobi.php' ); Sobi::Initialise(); require_once( JPATH_ROOT . '/components/com_sobipro/lib/ctrl/adm/extensions.php' ); $ctrl = new SPExtensionsCtrl(); $ctrl->updateRepository( 'repository.1.6.xml' ); } catch ( Exception $x ) { } } /** * Sobi Framework installation. * * @return bool */ protected function installFramework() { $libpathShort = '/libraries/sobi'; $libpath = JPATH_ROOT . $libpathShort; $fwPackage = JPATH_ROOT . '/components/com_sobipro/Sobi-Framework.zip'; $fwPackageShort = 'Site/Sobi-Framework.zip'; if ( !( file_exists( $libpath ) ) ) { Folder::create( $libpath ); } else { $files = scandir( $libpath ); if ( count( $files ) ) { foreach ( $files as $file ) { if ( strstr( $file, '.tar.gz' ) || strstr( $file, '.php' ) ) { File::delete( $libpath . '/' . $file ); } } } } if ( file_exists( $fwPackage ) ) { try { $arch = new Joomla\Archive\Zip(); $arch->extract( $fwPackage, $libpath ); File::delete( $fwPackage ); return true; } catch ( Exception $x ) { $msg = "<p>Failed to unpack the Sobi Framework '$fwPackageShort' to '$libpathShort'.</p>"; Log::add( $msg, Log::ERROR, 'jerror' ); } } else { $msg = "<p>Sobi Framework file '$fwPackageShort' not copied to components folder on installation.</p>"; Log::add( $msg, Log::ERROR, 'jerror' ); } return false; } }