File manager - Edit - /home/jardides/www/Jardi-design/old/administrator/components/com_templateck/helpers/ckinstaller.php
Back
<?php /** * @name Template Creator CK 3 * @package com_templateck * @copyright Copyright (C) 2013. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - http://www.template-creator.com - http://www.joomlack.fr */ defined('_JEXEC') or die; jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); class CKInstaller { /* * Download the package from the url and extract it */ public static function install($url, $name, $type = 'widget') { require_once JPATH_COMPONENT . '/helpers/zip.php'; $config = JFactory::getConfig(); // set_time_limit(0); $target = $config->get('tmp_path'); $targetZip = $target . '/templatecreatorck_widget_' . $name . '.zip'; // check if the package can be downloaded if (! self::downloadPackage($url, $targetZip)) { echo JText::_('CK_ERROR_DOWNLOAD_PACKAGE_FROM_URL'); return false; } // instanciate ZIP archiver $archiver = new CKArchiveZip(); if ($type == 'widget') { return self::extractWidgetPackage($targetZip, $name); } else { // extract archive $extractdir = $target . '/' . $name; $isSuccess = $archiver->extract($targetZip, $extractdir); $dirList = array_merge(JFolder::files($extractdir, ''), JFolder::folders($extractdir, '')); if (count($dirList) == 1) { if (JFolder::exists($extractdir . '/' . $dirList[0])) { $extractdir = JPath::clean($extractdir . '/' . $dirList[0]); } } // $retval['dir'] = $extractdir; // Get an installer instance. $installer = JInstaller::getInstance(); // Install the package. if (!$installer->install($extractdir)) { // There was an error installing the package. echo JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($type))); return false; } if ($type == 'plugin') { // auto enable the plugin $db = JFactory::getDbo(); $db->setQuery("UPDATE #__extensions SET enabled = '1' WHERE `element` = '" . $name . "' AND `type` = 'plugin'"); $db->query(); } self::cleanDownload($targetZip, $extractdir); } return true; } /* * Download the package from the url */ public static function extractWidgetPackage($targetZip, $name) { require_once JPATH_COMPONENT . '/helpers/zip.php'; // instanciate ZIP archiver $archiver = new CKArchiveZip(); if (! JFolder::exists(JPATH_SITE . '/administrator/components/com_templateck/widgets/')) { JFolder::create(JPATH_SITE . '/administrator/components/com_templateck/widgets/'); } // extract archive $extractdir = JPATH_SITE . '/administrator/components/com_templateck/widgets/'; $isSuccess = $archiver->extract($targetZip, $extractdir); if ($isSuccess === false) { echo JText::_('CK_ERROR_EXTRACT_PACKAGE'); self::cleanDownload($targetZip); return false; } if (! file_exists($extractdir . $name)) { echo JText::_('CK_ERROR_WIDGET_NOT_FOUND'); self::cleanDownload($targetZip); return false; } require_once(JPATH_SITE . '/administrator/components/com_templateck/helpers/ckwidgets.php'); CKWidgets::triggerOnAfterInstall($name); self::cleanDownload($targetZip); return true; } /* * Download the package from the url */ public static function downloadPackage($url, $dest) { set_time_limit(0); try { $file = file_get_contents(urldecode($url)); } catch (Exception $e) { echo 'Exception : ', $e->getMessage(), "\n"; exit; } return file_put_contents($dest, $file); } /* * Download the package from the url */ public static function cleanDownload($file, $folder = '') { return JFile::delete($file) && ($folder ? JFolder::delete($folder) : 1); } public static function loadEdition($name) { include_once(JPATH_SITE . '/administrator/components/com_templateck/widgets/' . $name . '/' . $name . '.php'); $widgetClassName = 'TCK_Widget' . ucfirst($name); $widgetClass = new $widgetClassName(); $widgetClass->loadEdition(); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings