<?php
/*
 * Copyright (c) 2014-2015 Aimy Extensions, Lingua-Systems Software GmbH
 *
 * http://www.aimy-extensions.com/
 *
 * License: GNU GPLv2, see LICENSE.txt within distribution and/or
 *          http://www.aimy-extensions.com/software-license.html
 */
 defined( '_JEXEC' ) or die(); class com_aimysitemapInstallerScript { const V_JOOMLA_MIN = '3.0'; const V_PHP_MIN = '5.3.10'; static private $db_support = array( 'mysql', 'mysqli' ); public function preflight( $type, $parent ) { $app = JFactory::getApplication(); $db = $app->getCfg( 'dbtype', '' ); if ( ! in_array( $db, self::$db_support ) ) { $app->enqueueMessage( 'You are currently using <strong>' . $db . '</strong> ' . 'as a database backend for your Joomla! installation. ' . 'Aimy Sitemap at the moment only supports the following ' . 'database backends: ' . '<b>' . implode( ', ', self::$db_support ) . '</b>.', 'error' ); if ( $db == 'postgresql' ) { $app->enqueueMessage( '<strong>PostgreSQL</strong> support is available in ' . '<a href="http://www.aimy-extensions.com/joomla/sitemap.html" target="_blank">Aimy Sitemap ' . 'PRO</a>!' ); } else { $app->enqueueMessage( 'Please use the ' . '<a href="http://www.aimy-extensions.com//contact.html">contact ' . 'form on our website</a> to get in touch with us ' . 'if you would like us to implement support for ' . 'your database system as well.' ); } return false; } $dis_ini = str_replace( ' ', '', ini_get( 'disable_functions' ) . ',' . ini_get( 'suhosin.executor.func.blacklist' ) ); if ( $dis_ini !== ',' ) { $dis_fns = explode( ',', $dis_ini ); if ( in_array( 'stream_socket_client', $dis_fns ) ) { $app->enqueueMessage( 'The <code>stream_socket_client</code> PHP function is ' . 'currently disabled in your setup - Aimy Sitemap ' . 'requires this function to be ' . '<strong>enabled</strong> in order to crawl your ' . 'website. ' . 'Please fix your setup and install again.', 'error' ); return false; } } return ( self::check_php_version( self::V_PHP_MIN ) && self::check_joomla_version( self::V_JOOMLA_MIN ) ); } public function uninstall( $parent ) { require_once( JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_aimysitemap' . DIRECTORY_SEPARATOR . 'Sitemap.php' ); JFactory::getLanguage()->load( 'com_aimysitemap', JPATH_ADMINISTRATOR ); $sm = new AimySitemapSitemap(); $sm->unlink_file_if_exists(); } public function postflight( $route, $adapter ) { $task = strtolower( $route ); if ( $task != 'install' && $task != 'update' ) { return; } JFactory::getLanguage()->load( 'com_aimysitemap', JPATH_ADMINISTRATOR ); if ( $task == 'update' ) { require( __DIR__ . DIRECTORY_SEPARATOR . 'UpdateServer.php' ); AimySitemapUpdateServer::cleanup_server_list( $adapter ); } echo '<div style="padding:32px;text-align:center;">', '<h1>', '<img src="', JURI::base(), '../media/com_aimysitemap/aimy-logo_340x327.png" ', 'width="340" height="327" alt="Aimy" />', '<br/>', 'Aimy Sitemap  v3.15.1 ', '</h1>', '<p class="lead">', JText::_( $task == 'update' ? 'AIMY_SM_HINT_UPDATED' : 'AIMY_SM_HINT_INSTALLED' ), '!', '</p>'; echo '<p>', self::_btn( JRoute::_( 'index.php?option=com_aimysitemap' ), JText::_( 'AIMY_SM_HINT_EDIT' ) ), ' &nbsp; ', self::_btn( 'http://www.aimy-extensions.com/joomla/sitemap.html#user-manual', JText::_( 'AIMY_SM_HINT_READ_MANUAL' ), true ), ' &nbsp; ', self::_btn( 'http://static.aimy-extensions.com/images/products/sitemap/com-aimy-sitemap.pdf?v=3.15.1', JText::_( 'AIMY_SM_HINT_DL_MANUAL' ), false ), '</p>', '<p style="padding:12px 0;" />', '<a href="http://www.aimy-extensions.com/joomla/sitemap.html" target="_blank">http://www.aimy-extensions.com/joomla/sitemap.html</a>', '</p>', '</div>', "\n"; } static private function _btn( $url, $text, $new_tab = false ) { return '<a class="btn btn-lg btn-success" href="' . $url . '" ' . ( $new_tab ? 'target="_blank" ' : '' ) . 'role="button">' . $text . '!' . '</a>'; } static private function check_php_version( $min ) { if ( version_compare( PHP_VERSION, $min, '<' ) ) { JFactory::getApplication()->enqueueMessage( 'You are currently using PHP ' . PHP_VERSION . '. ' . 'Aimy Sitemap requires at least PHP ' . $min . '. ' . '<strong>Please update your PHP version</strong>.', 'error' ); return false; } return true; } static private function check_joomla_version( $min ) { $jv = defined( 'JVERSION' ) ? JVERSION : 0; if ( version_compare( $jv, $min, '<' ) ) { JFactory::getApplication()->enqueueMessage( 'You are currently using Joomla! ' . $jv . '. ' . 'Aimy Sitemap requires at least Joomla! ' . $min . '. ' . '<strong>Please update your Joomla! version</strong>.', 'error' ); return false; } return true; } } 
