| Current Path : /home/megadansyp/www/e392e/ |
| Current File : /home/megadansyp/www/e392e/cli.tar |
deletefiles.php 0000644 00000004043 15217301655 0007550 0 ustar 00 <?php
/**
* @package Joomla.Cli
*
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* A command line cron job to attempt to remove files that should have been deleted at update.
*/
// We are a valid entry point.
const _JEXEC = 1;
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
// Configure error reporting to maximum for CLI output.
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Load Library language
$lang = JFactory::getLanguage();
// Try the files_joomla file in the current language (without allowing the loading of the file in the default language)
$lang->load('files_joomla.sys', JPATH_SITE, null, false, false)
// Fallback to the files_joomla file in the default language
|| $lang->load('files_joomla.sys', JPATH_SITE, null, true);
/**
* A command line cron job to attempt to remove files that should have been deleted at update.
*
* @since 3.0
*/
class DeletefilesCli extends JApplicationCli
{
/**
* Entry point for CLI script
*
* @return void
*
* @since 3.0
*/
public function doExecute()
{
// Import the dependencies
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
// We need the update script
JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php');
// Instantiate the class
$class = new JoomlaInstallerScript;
// Run the delete method
$class->deleteUnexistingFiles();
}
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('DeletefilesCli')->execute();
update_cron.php 0000644 00000003276 15217301655 0007575 0 ustar 00 <?php
/**
* @package Joomla.Cli
*
* @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* This is a CRON script which should be called from the command-line, not the
* web. For example something like:
* /usr/bin/php /path/to/site/cli/update_cron.php
*/
// Set flag that this is a parent file.
const _JEXEC = 1;
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';
// Load the configuration
require_once JPATH_CONFIGURATION . '/configuration.php';
/**
* This script will fetch the update information for all extensions and store
* them in the database, speeding up your administrator.
*
* @since 2.5
*/
class Updatecron extends JApplicationCli
{
/**
* Entry point for the script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
// Get the update cache time
$component = JComponentHelper::getComponent('com_installer');
$params = $component->params;
$cache_timeout = $params->get('cachetimeout', 6, 'int');
$cache_timeout = 3600 * $cache_timeout;
// Find all updates
$this->out('Fetching updates...');
$updater = JUpdater::getInstance();
$updater->findUpdates(0, $cache_timeout);
$this->out('Finished fetching updates');
}
}
JApplicationCli::getInstance('Updatecron')->execute();
sessionMetadataGc.php 0000644 00000002612 15217301655 0010661 0 ustar 00 <?php
/**
* @package Joomla.Cli
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* This is a CRON script to delete expired optional session metadata which should be called from the command-line, not the
* web. For example something like:
* /usr/bin/php /path/to/site/cli/sessionMetadataGc.php
*/
// Initialize Joomla framework
const _JEXEC = 1;
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
/**
* Cron job to trash expired session metadata.
*
* @since 3.8.6
*/
class SessionMetadataGc extends JApplicationCli
{
/**
* Entry point for the script
*
* @return void
*
* @since 3.8.6
*/
public function doExecute()
{
$metadataManager = new \Joomla\CMS\Session\MetadataManager($this, \Joomla\CMS\Factory::getDbo());
$sessionExpire = \Joomla\CMS\Factory::getSession()->getExpire();
$metadataManager->deletePriorTo(time() - $sessionExpire);
}
}
JApplicationCli::getInstance('SessionMetadataGc')->execute();
index.html 0000644 00000000037 15217301655 0006546 0 ustar 00 <!DOCTYPE html><title></title>
eventgallery-local-thumbnails.php 0000644 00000007374 15217301655 0013232 0 ustar 00 <?php
/**
* @package Sven.Bluege
* @subpackage com_eventgallery
*
* @copyright Copyright (C) 2005 - 2019 Sven Bluege All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Set flag that this is a parent file.
const _JEXEC = 1;
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';
// Load the configuration
require_once JPATH_CONFIGURATION . '/configuration.php';
require_once JPATH_ROOT . '/components/com_eventgallery/vendor/autoload.php';
/**
* Job to sync the file system with the database
*
* @package Joomla.Cli
* @since 2.5
*/
class EventgalleryLocalThumbnails extends JApplicationCli
{
/** @noinspection PhpMissingParentConstructorInspection */
public function __construct(JInputCli $input = null, JRegistry $config = null, JEventDispatcher $dispatcher = null)
{
if (array_key_exists('REQUEST_METHOD', $_SERVER))
{
die('CLI only. Do not call this from the browser.');
}
}
/**
* Entry point for the script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
echo " ================================================="."\n";
echo " Local Thumbnail Creator\n\n";
echo " This script calculates the thumbnails for your local images"."\n";
echo " "."\n\n";
echo " Command line options\n\n";
echo " calcthumbnails=[true|false]\n";
echo " use this to perform the thumbnail calculation. Default: false";
echo " "."\n";
echo " ================================================="."\n\n\n";
$doCalculateMissingThumbnails = false;
foreach ($_SERVER['argv'] as $arg) {
$e=explode("=",$arg);
if (count($e)==2) {
if (strcasecmp('calcthumbnails',$e[0]) == 0 && boolval($e[1])) {
$doCalculateMissingThumbnails = true;
}
}
}
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_eventgallery');
define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/com_eventgallery');
$language = JFactory::getLanguage();
$language->load('com_eventgallery' , JPATH_COMPONENT_ADMINISTRATOR, $language->getTag(), true);
JLoader::registerPrefix('Eventgallery', JPATH_COMPONENT_SITE);
require_once(JPATH_COMPONENT_ADMINISTRATOR.'/models/thumbnailgenerator.php');
$localModel = JModelLegacy::getInstance('EventgalleryModelThumbnailgenerator', '', array('ignore_request' => true));
/**
* @var EventgalleryLibraryFactoryFile $fileFactory
* @var EventgalleryLibraryFileLocal $fileObject
* @var EventgalleryModelThumbnailcreator $localModel
*/
$fileFactory = EventgalleryLibraryFactoryFile::getInstance();
$folders = $localModel->getFolders([EventgalleryLibraryFolderLocal::ID]);
echo "\n\n=== Doing thumbnail creation for " . count($folders) . " folders ===\n\n";
foreach($folders as $folder) {
$files = $localModel->getFilesToSync($folder->getFolderName());
echo "Folder \"$folder\" needs thumbnails for " . count($files) . " files\n\n";
if ($doCalculateMissingThumbnails) {
foreach ($files as $file) {
echo " (Memory usage: " . memory_get_usage() . ") $folder - $file \n";
$file->createThumbnails();
}
}
echo "\n";
}
echo "Thumbnail creation finished.\n\n\n";
}
}
JApplicationCli::getInstance('EventgalleryLocalThumbnails')->execute();
eventgallery-s3-thumbnails.php 0000644 00000010433 15217301655 0012453 0 ustar 00 <?php
/**
* @package Sven.Bluege
* @subpackage com_eventgallery
*
* @copyright Copyright (C) 2005 - 2019 Sven Bluege All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Set flag that this is a parent file.
const _JEXEC = 1;
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';
// Load the configuration
require_once JPATH_CONFIGURATION . '/configuration.php';
require_once JPATH_ROOT . '/components/com_eventgallery/vendor/autoload.php';
/**
* Job to sync the file system with the database
*
* @package Joomla.Cli
* @since 2.5
*/
class EventgalleryS3Thumbnails extends JApplicationCli
{
/** @noinspection PhpMissingParentConstructorInspection */
public function __construct(JInputCli $input = null, JRegistry $config = null, JEventDispatcher $dispatcher = null)
{
if (array_key_exists('REQUEST_METHOD', $_SERVER))
{
die('CLI only. Do not call this from the browser.');
}
}
/**
* Entry point for the script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
echo " ================================================="."\n";
echo " S3 Thumbnail Creator\n\n";
echo " This script calculates the thumbnails for your S3 images if the"."\n";
echo " ETag values do not match the current thumbnail or if the thumbnail"."\n";
echo " is missing at all. "."\n";
echo " "."\n\n";
echo " Command line options\n\n";
echo " refreshetags=[true|false]\n";
echo " You can get the ETag data from S3 and write them to the database by"."\n";
echo " adding -refreshetags=true to the command line to avoid calculating them"."\n";
echo " twice. Default is true.\n\n";
echo " calcthumbnails=[true|false]\n";
echo " use this to perform the thumbnail calculation. Default: false";
echo " "."\n";
echo " ================================================="."\n\n\n";
$saveETagOfThumbnailsToDatabase = true;
$calculateMissingThumbnails = false;
foreach ($_SERVER['argv'] as $arg) {
$e=explode("=",$arg);
if (count($e)==2) {
if (strcasecmp('refreshetags',$e[0]) == 0 && !boolval($e[1])) {
$saveETagOfThumbnailsToDatabase = false;
}
if (strcasecmp('calcthumbnails',$e[0]) == 0 && boolval($e[1])) {
$calculateMissingThumbnails = true;
}
}
}
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_eventgallery');
define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/com_eventgallery');
$language = JFactory::getLanguage();
$language->load('com_eventgallery' , JPATH_COMPONENT_ADMINISTRATOR, $language->getTag(), true);
JLoader::registerPrefix('Eventgallery', JPATH_COMPONENT_SITE);
require_once(JPATH_COMPONENT_ADMINISTRATOR.'/models/thumbnailgenerator.php');
$s3Model = JModelLegacy::getInstance('EventgalleryModelThumbnailgenerator', '', array('ignore_request' => true));
/**
* @var EventgalleryLibraryFactoryFile $fileFactory
* @var EventgalleryLibraryFileS3 $fileObject
* @var EventgalleryModelS3 $s3Model
*/
$fileFactory = EventgalleryLibraryFactoryFile::getInstance();
$folders = $s3Model->getFolders([EventgalleryLibraryFolderS3::ID]);
echo "\n\n=== Doing thumbnail creation for " . count($folders) . " folders ===\n\n";
foreach($folders as $folder) {
$files = $s3Model->getFilesToSync($folder->getFolderName(), $saveETagOfThumbnailsToDatabase);
echo "Folder \"$folder\" needs thumbnails for " . count($files) . " files\n\n";
if ($calculateMissingThumbnails) {
foreach ($files as $file) {
echo " (Memory usage: " . memory_get_usage() . ") $folder - $file \n";
$file->createThumbnails();
}
}
echo "\n";
}
echo "Thumbnail creation finished.";
}
}
JApplicationCli::getInstance('EventgalleryS3Thumbnails')->execute();
sessionGc.php 0000644 00000002233 15217301655 0007217 0 ustar 00 <?php
/**
* @package Joomla.Cli
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* This is a CRON script to delete expired session data which should be called from the command-line, not the
* web. For example something like:
* /usr/bin/php /path/to/site/cli/sessionGc.php
*/
// Initialize Joomla framework
const _JEXEC = 1;
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
/**
* Cron job to trash expired session data.
*
* @since 3.8.6
*/
class SessionGc extends JApplicationCli
{
/**
* Entry point for the script
*
* @return void
*
* @since 3.8.6
*/
public function doExecute()
{
JFactory::getSession()->gc();
}
}
JApplicationCli::getInstance('SessionGc')->execute();
finder_indexer.php 0000644 00000031515 15217301655 0010254 0 ustar 00 <?php
/**
* @package Joomla.Cli
*
* @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* Smart Search CLI.
*
* This is a command-line script to help with management of Smart Search.
*
* Called with no arguments: php finder_indexer.php
* Performs an incremental update of the index using dynamic pausing.
*
* IMPORTANT NOTE: since Joomla version 3.9.12 the default behavior of this script has changed.
* If called with no arguments, the `--pause` argument is silently applied, in order to avoid the possibility of
* stressing the server too much and making a site (or multiple sites, if on a shared environment) unresponsive.
* If a pause is unwanted, just apply `--pause=0` to the command
*
* Called with --purge php finder_indexer.php --purge
* Purges and rebuilds the index (search filters are preserved).
*
* Called with --pause `php finder_indexer.php --pause`
* or --pause=x or `php finder_indexer.php --pause=x` where x = seconds.
* or --pause=division or `php finder_indexer.php --pause=division` The default divisor is 5.
* If another divisor is required, it can be set with --divisor=y, where
* y is the integer divisor
*
* This will pause for x seconds between batches,
* in order to give the server some time to catch up
* if --pause is called without an assignment, it defaults to dynamic pausing
* using the division method with a divisor of 5
* (eg. 1 second pause for every 5 seconds of batch processing time)
*
* Called with --minproctime=x Will set the minimum processing time of batches for a pause to occur. Defaults to 1
*
*/
// We are a valid entry point.
const _JEXEC = 1;
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_finder');
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
// Import the configuration.
require_once JPATH_CONFIGURATION . '/configuration.php';
// System configuration.
$config = new JConfig;
define('JDEBUG', $config->debug);
// Configure error reporting to maximum for CLI output.
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Load Library language
$lang = JFactory::getLanguage();
// Try the finder_cli file in the current language (without allowing the loading of the file in the default language)
$lang->load('finder_cli', JPATH_SITE, null, false, false)
// Fallback to the finder_cli file in the default language
|| $lang->load('finder_cli', JPATH_SITE, null, true);
/**
* A command line cron job to run the Smart Search indexer.
*
* @since 2.5
*/
class FinderCli extends JApplicationCli
{
/**
* Start time for the index process
*
* @var string
* @since 2.5
*/
private $time;
/**
* Start time for each batch
*
* @var string
* @since 2.5
*/
private $qtime;
/**
* Static filters information.
*
* @var array
* @since 3.3
*/
private $filters = array();
/**
* Pausing type or defined pause time in seconds.
* One pausing type is implemented: 'division' for dynamic calculation of pauses
*
* Defaults to 'division'
*
* @var string|integer
* @since 3.9.12
*/
private $pause = 'division';
/**
* The divisor of the division: batch-processing time / divisor.
* This is used together with --pause=division in order to pause dynamically
* in relation to the processing time
* Defaults to 5
*
* @var integer
* @since 3.9.12
*/
private $divisor = 5;
/**
* Minimum processing time in seconds, in order to apply a pause
* Defaults to 1
*
* @var integer
* @since 3.9.12
*/
private $minimumBatchProcessingTime = 1;
/**
* Entry point for Smart Search CLI script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
// Print a blank line.
$this->out(JText::_('FINDER_CLI'));
$this->out('============================');
// Initialize the time value.
$this->time = microtime(true);
// Remove the script time limit.
@set_time_limit(0);
// Fool the system into thinking we are running as JSite with Smart Search as the active component.
$_SERVER['HTTP_HOST'] = 'domain.com';
JFactory::getApplication('site');
$this->minimumBatchProcessingTime = $this->input->getInt('minproctime', 1);
// Pause between batches to let the server catch a breath. The default, if not set by the user, is set in the class property `pause`
$pauseArg = $this->input->get('pause', $this->pause, 'raw');
if ($pauseArg === 'division')
{
$this->divisor = $this->input->getInt('divisor', $this->divisor);
}
else
{
$this->pause = (int) $pauseArg;
}
// Purge before indexing if --purge on the command line.
if ($this->input->getString('purge', false))
{
// Taxonomy ids will change following a purge/index, so save filter information first.
$this->getFilters();
// Purge the index.
$this->purge();
// Run the indexer.
$this->index();
// Restore the filters again.
$this->putFilters();
}
else
{
// Run the indexer.
$this->index();
}
// Total reporting.
$this->out(JText::sprintf('FINDER_CLI_PROCESS_COMPLETE', round(microtime(true) - $this->time, 3)), true);
$this->out(JText::sprintf('FINDER_CLI_PEAK_MEMORY_USAGE', number_format(memory_get_peak_usage(true))));
// Print a blank line at the end.
$this->out();
}
/**
* Run the indexer.
*
* @return void
*
* @since 2.5
*/
private function index()
{
JLoader::register('FinderIndexer', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/indexer.php');
// Disable caching.
$config = JFactory::getConfig();
$config->set('caching', 0);
$config->set('cache_handler', 'file');
// Reset the indexer state.
FinderIndexer::resetState();
// Import the plugins.
JPluginHelper::importPlugin('system');
JPluginHelper::importPlugin('finder');
// Starting Indexer.
$this->out(JText::_('FINDER_CLI_STARTING_INDEXER'), true);
// Trigger the onStartIndex event.
JEventDispatcher::getInstance()->trigger('onStartIndex');
// Remove the script time limit.
@set_time_limit(0);
// Get the indexer state.
$state = FinderIndexer::getState();
// Setting up plugins.
$this->out(JText::_('FINDER_CLI_SETTING_UP_PLUGINS'), true);
// Trigger the onBeforeIndex event.
JEventDispatcher::getInstance()->trigger('onBeforeIndex');
// Startup reporting.
$this->out(JText::sprintf('FINDER_CLI_SETUP_ITEMS', $state->totalItems, round(microtime(true) - $this->time, 3)), true);
// Get the number of batches.
$t = (int) $state->totalItems;
$c = (int) ceil($t / $state->batchSize);
$c = $c === 0 ? 1 : $c;
try
{
// Process the batches.
for ($i = 0; $i < $c; $i++)
{
// Set the batch start time.
$this->qtime = microtime(true);
// Reset the batch offset.
$state->batchOffset = 0;
// Trigger the onBuildIndex event.
JEventDispatcher::getInstance()->trigger('onBuildIndex');
// Batch reporting.
$this->out(JText::sprintf('FINDER_CLI_BATCH_COMPLETE', $i + 1, $processingTime = round(microtime(true) - $this->qtime, 3)), true);
if ($this->pause !== 0)
{
// Pausing Section
$skip = !($processingTime >= $this->minimumBatchProcessingTime);
$pause = 0;
if ($this->pause === 'division' && $this->divisor > 0)
{
if (!$skip)
{
$pause = round($processingTime / $this->divisor);
}
else
{
$pause = 1;
}
}
elseif ($this->pause > 0)
{
$pause = $this->pause;
}
if ($pause > 0 && !$skip)
{
$this->out(JText::sprintf('FINDER_CLI_BATCH_PAUSING', $pause), true);
sleep($pause);
$this->out(JText::_('FINDER_CLI_BATCH_CONTINUING'));
}
if ($skip)
{
$this->out(JText::sprintf('FINDER_CLI_SKIPPING_PAUSE_LOW_BATCH_PROCESSING_TIME', $processingTime, $this->minimumBatchProcessingTime), true);
}
// End of Pausing Section
}
}
}
catch (Exception $e)
{
// Display the error
$this->out($e->getMessage(), true);
// Reset the indexer state.
FinderIndexer::resetState();
// Close the app
$this->close($e->getCode());
}
// Reset the indexer state.
FinderIndexer::resetState();
}
/**
* Purge the index.
*
* @return void
*
* @since 3.3
*/
private function purge()
{
$this->out(JText::_('FINDER_CLI_INDEX_PURGE'));
// Load the model.
JModelLegacy::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/models', 'FinderModel');
$model = JModelLegacy::getInstance('Index', 'FinderModel');
// Attempt to purge the index.
$return = $model->purge();
// If unsuccessful then abort.
if (!$return)
{
$message = JText::_('FINDER_CLI_INDEX_PURGE_FAILED', $model->getError());
$this->out($message);
exit();
}
$this->out(JText::_('FINDER_CLI_INDEX_PURGE_SUCCESS'));
}
/**
* Restore static filters.
*
* Using the saved filter information, update the filter records
* with the new taxonomy ids.
*
* @return void
*
* @since 3.3
*/
private function putFilters()
{
$this->out(JText::_('FINDER_CLI_RESTORE_FILTERS'));
$db = JFactory::getDbo();
// Use the temporary filter information to update the filter taxonomy ids.
foreach ($this->filters as $filter_id => $filter)
{
$tids = array();
foreach ($filter as $element)
{
// Look for the old taxonomy in the new taxonomy table.
$query = $db->getQuery(true);
$query
->select('t.id')
->from($db->qn('#__finder_taxonomy') . ' AS t')
->leftJoin($db->qn('#__finder_taxonomy') . ' AS p ON p.id = t.parent_id')
->where($db->qn('t.title') . ' = ' . $db->q($element['title']))
->where($db->qn('p.title') . ' = ' . $db->q($element['parent']));
$taxonomy = $db->setQuery($query)->loadResult();
// If we found it then add it to the list.
if ($taxonomy)
{
$tids[] = $taxonomy;
}
else
{
$this->out(JText::sprintf('FINDER_CLI_FILTER_RESTORE_WARNING', $element['parent'], $element['title'], $element['filter']));
}
}
// Construct a comma-separated string from the taxonomy ids.
$taxonomyIds = empty($tids) ? '' : implode(',', $tids);
// Update the filter with the new taxonomy ids.
$query = $db->getQuery(true);
$query
->update($db->qn('#__finder_filters'))
->set($db->qn('data') . ' = ' . $db->q($taxonomyIds))
->where($db->qn('filter_id') . ' = ' . (int) $filter_id);
$db->setQuery($query)->execute();
}
$this->out(JText::sprintf('FINDER_CLI_RESTORE_FILTER_COMPLETED', count($this->filters)));
}
/**
* Save static filters.
*
* Since a purge/index cycle will cause all the taxonomy ids to change,
* the static filters need to be updated with the new taxonomy ids.
* The static filter information is saved prior to the purge/index
* so that it can later be used to update the filters with new ids.
*
* @return void
*
* @since 3.3
*/
private function getFilters()
{
$this->out(JText::_('FINDER_CLI_SAVE_FILTERS'));
// Get the taxonomy ids used by the filters.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select('filter_id, title, data')
->from($db->qn('#__finder_filters'));
$filters = $db->setQuery($query)->loadObjectList();
// Get the name of each taxonomy and the name of its parent.
foreach ($filters as $filter)
{
// Skip empty filters.
if ($filter->data === '')
{
continue;
}
// Get taxonomy records.
$query = $db->getQuery(true);
$query
->select('t.title, p.title AS parent')
->from($db->qn('#__finder_taxonomy') . ' AS t')
->leftJoin($db->qn('#__finder_taxonomy') . ' AS p ON p.id = t.parent_id')
->where($db->qn('t.id') . ' IN (' . $filter->data . ')');
$taxonomies = $db->setQuery($query)->loadObjectList();
// Construct a temporary data structure to hold the filter information.
foreach ($taxonomies as $taxonomy)
{
$this->filters[$filter->filter_id][] = array(
'filter' => $filter->title,
'title' => $taxonomy->title,
'parent' => $taxonomy->parent,
);
}
}
$this->out(JText::sprintf('FINDER_CLI_SAVE_FILTER_COMPLETED', count($filters)));
}
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('FinderCli')->execute();
eventgallery-sync.php 0000644 00000007564 15217301655 0010751 0 ustar 00 <?php
/**
* @package Sven.Bluege
* @subpackage com_eventgallery
*
* @copyright Copyright (C) 2005 - 2019 Sven Bluege All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Set flag that this is a parent file.
const _JEXEC = 1;
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';
// Load the configuration
require_once JPATH_CONFIGURATION . '/configuration.php';
require_once JPATH_ROOT . '/components/com_eventgallery/vendor/autoload.php';
/**
* Job to sync the file system with the database
*
* @package Joomla.Cli
* @since 2.5
*/
class EventgallerySync extends JApplicationCli
{
/** @noinspection PhpMissingParentConstructorInspection */
public function __construct(JInputCli $input = null, JRegistry $config = null, JEventDispatcher $dispatcher = null)
{
if (array_key_exists('REQUEST_METHOD', $_SERVER))
{
die('CLI only. Do not call this from the browser.');
}
}
/**
* Entry point for the script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_eventgallery');
define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/com_eventgallery');
$language = JFactory::getLanguage();
$language->load('com_eventgallery' , JPATH_COMPONENT_ADMINISTRATOR, $language->getTag(), true);
//JLoader::registerPrefix('Eventgallery', JPATH_COMPONENT_ADMINISTRATOR);
JLoader::registerPrefix('Eventgallery', JPATH_COMPONENT_SITE);
$config = \Joomla\Component\Eventgallery\Site\Library\Configuration\Main::getInstance();
$use_htacces_to_protect_original_files = $config->getImage()->doUseHtaccessToProtectOriginalFiles();
require_once(JPATH_COMPONENT_ADMINISTRATOR.'/models/sync.php');
$syncModel = JModelLegacy::getInstance('EventgalleryModelSync', '', array('ignore_request' => true));
echo "\n\n=== Adding new Folders === \n\n";
/**
* @var EventgalleryLibraryManagerFolder $folderMgr
* @var EventgalleryLibraryFactoryFile $fileFactory
*/
$folderMgr = EventgalleryLibraryManagerFolder::getInstance();
$fileFactory = EventgalleryLibraryFactoryFile::getInstance();
$addResults = $folderMgr->addNewFolders();
foreach($addResults as $addResult) {
/**
* @var EventgalleryLibraryFolderAddresult $addResult
*/
if ($addResult->getError() != null) {
echo "ERROR: " . $addResult->getError() . "\n";
} else {
echo "Added: " . $addResult->getFolderName() . "\n";
}
}
$folders = $syncModel->getFolders();
echo "\n\n=== Synchronizing " . count($folders) . " folders ===\n\n";
foreach($folders as $folder) {
$result = $syncModel->syncFolder($folder->getFolderName(), null, $use_htacces_to_protect_original_files);
if (isset($result['files'])) {
$files = $result['files'];
echo "Sync $folder with " . count($files) . " files\n\n";
/**
* @var EventgalleryLibraryFile $file
*/
foreach ($files as $filename) {
echo " (Memory usage: ".memory_get_usage().") $folder - $filename \n";
$file = $fileFactory->getFile($folder->getFolderName(), $filename);
$file->syncFile();
}
}
echo "\n\n";
}
echo "Sync finished.";
}
}
JApplicationCli::getInstance('EventgallerySync')->execute();
garbagecron.php 0000644 00000002040 15217301655 0007530 0 ustar 00 <?php
/**
* @package Joomla.Cli
*
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* A command line cron job to trash expired cache data.
*/
// Initialize Joomla framework
const _JEXEC = 1;
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
/**
* Cron job to trash expired cache data.
*
* @since 2.5
*/
class GarbageCron extends JApplicationCli
{
/**
* Entry point for the script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
$cache = JFactory::getCache();
$cache->gc();
}
}
JApplicationCli::getInstance('GarbageCron')->execute();