Файловый менеджер - Редактировать - /home/wuectly/www/03cbe/profiles.php.tar
Назад
home/wuectly/www/administrator/components/com_jce/tables/profiles.php 0000604 00000003713 15245655652 0022305 0 ustar 00 <?php /** * @package JCE * @subpackage Admin * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @copyright Copyright (c) 2009-2024 Ryan Demmer. All rights reserved * @license GNU General Public License version 2 or later; see LICENSE.txt */ \defined('_JEXEC') or die; use Joomla\CMS\Table\Table; require_once JPATH_ADMINISTRATOR . '/components/com_jce/helpers/encrypt.php'; class JceTableProfiles extends Table { /** * Indicates that columns fully support the NULL value in the database * * @var boolean * @since 4.0.0 */ protected $_supportNullValue = true; public function __construct(&$db) { parent::__construct('#__wf_profiles', 'id', $db); } public function load($id = null, $reset = true) { $return = parent::load($id, $reset); if ($return !== false) { // decrypt params if (!empty($this->params)) { $this->params = JceEncryptHelper::decrypt($this->params); } } return $return; } /** * Overloaded check function * * @return boolean True on success, false on failure * * @see Table::check() * @since 2.9.18 */ public function check() { try { parent::check(); } catch (Exception $e) { $this->setError($e->getMessage()); return false; } /** * Ensure any new items have compulsory fields set */ if (!$this->id) { if (!isset($this->device)) { $this->device = 'desktop,tablet,phone'; } if (!isset($this->area)) { $this->area = '0'; } // Params can be an empty json string for new tables if (empty($this->params)) { $this->params = '{}'; } } return true; } } home/wuectly/www/administrator/components/com_jce/models/profiles.php 0000604 00000017723 15245663746 0022327 0 ustar 00 <?php /** * @package JCE * @subpackage Admin * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @copyright Copyright (c) 2009-2024 Ryan Demmer. All rights reserved * @license GNU General Public License version 2 or later; see LICENSE.txt */ \defined('_JEXEC') or die; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Table\Table; use Joomla\Event\DispatcherAwareInterface; require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/profiles.php'; class JceModelProfiles extends ListModel { /** * Constructor. * * @param array $config An optional associative array of configuration settings. * * @see JControllerLegacy * @since 1.6 */ public function __construct($config = array()) { if ($this instanceof DispatcherAwareInterface) { $this->setDispatcher(Factory::getApplication()->getDispatcher()); } if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'id', 'name', 'name', 'checked_out', 'checked_out', 'checked_out_time', 'checked_out_time', 'published', 'published', 'ordering', 'ordering', ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @note Calling getState in this method will result in recursion. * @since 1.6 */ protected function populateState($ordering = 'id', $direction = 'asc') { // Load the filter state. $this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string')); // Load the parameters. $params = ComponentHelper::getParams('com_jce'); $this->setState('params', $params); // List state information. parent::populateState($ordering, $direction); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. * * @since 1.6 */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('filter.search'); $id .= ':' . $this->getState('filter.published'); $id .= ':' . $this->getState('filter.components'); return parent::getStoreId($id); } /** * Method to get an array of data items. * * @return mixed An array of data items on success, false on failure. * * @since 1.6 */ public function getItems() { $items = parent::getItems(); // Filter by device $device = $this->getState('filter.device'); // Filter by component $components = $this->getState('filter.components'); // Filter by user groups $usergroups = $this->getState('filter.usergroups'); $items = array_filter($items, function ($item) use ($device, $components, $usergroups) { $state = true; if ($device) { $state = in_array($device, explode(',', $item->device)); } if ($components) { $state = in_array($components, explode(',', $item->components)); } if ($usergroups) { $state = in_array($usergroups, explode(',', $item->types)); } return $state; }); // Get a storage key. $store = $this->getStoreId(); // update cache store $this->cache[$store] = $items; return $items; } /** * Build an SQL query to load the list data. * * @return JDatabaseQuery * * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $user = Factory::getUser(); // Select the required fields from the table. $query->select( $this->getState( 'list.select', '*' ) ); $query->from($db->quoteName('#__wf_profiles')); // Filter by published state $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where($db->quoteName('published') . ' = ' . (int) $published); } elseif ($published === '') { $query->where('(' . $db->quoteName('published') . ' = 0 OR ' . $db->quoteName('published') . ' = 1)'); } // Filter by area $area = (int) $this->getState('filter.area'); if ($area) { $query->where($db->quoteName('area') . ' = ' . (int) $area); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where($db->quoteName('id') . ' = ' . (int) substr($search, 3)); } else { $search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%')); $query->where('(' . $db->quoteName('name') . ' LIKE ' . $search . ' OR ' . $db->quoteName('description') . ' LIKE ' . $search . ')'); } } // Add the list ordering clause. $listOrder = $this->getState('list.ordering', 'ordering'); $listDirn = $this->getState('list.direction', 'ASC'); $query->order($db->escape($listOrder . ' ' . $listDirn)); return $query; } public function repair() { $file = __DIR__ . '/profiles.xml'; if (!is_file($file)) { $this->setError(Text::_('WF_PROFILES_REPAIR_ERROR')); return false; } $xml = simplexml_load_file($file); if (!$xml) { $this->setError(Text::_('WF_PROFILES_REPAIR_ERROR')); return false; } foreach ($xml->profiles->children() as $profile) { $groups = JceProfilesHelper::getUserGroups((int) $profile->children('area')); $table = Table::getInstance('Profiles', 'JceTable'); foreach ($profile->children() as $item) { switch ((string) $item->getName()) { case 'description': $table->description = Text::_((string) $item); case 'types': $table->types = implode(',', $groups); break; case 'area': $table->area = (int) $item; break; case 'rows': $table->rows = (string) $item; break; case 'plugins': $table->plugins = (string) $item; break; default: $key = $item->getName(); $table->$key = (string) $item; break; } } // default $table->checked_out = 0; $table->checked_out_time = '0000-00-00 00:00:00'; // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } } return true; } } home/wuectly/www/administrator/components/com_jce/helpers/profiles.php 0000604 00000027666 15245700667 0022507 0 ustar 00 <?php /** * @package JCE * @subpackage Admin * * @copyright Copyright (C) 2005 - 2023 Open Source Matters, Inc. All rights reserved. * @copyright Copyright (c) 2009-2024 Ryan Demmer. All rights reserved * @license GNU General Public License version 2 or later; see LICENSE.txt */ \defined('_JEXEC') or die; use Joomla\CMS\Access\Access; use Joomla\CMS\Factory; use Joomla\Filesystem\File; use Joomla\CMS\Language\Text; use Joomla\CMS\Table\Table; use Joomla\String\StringHelper; abstract class JceProfilesHelper { /** * Create the Profiles table. * * @return bool */ public static function createProfilesTable() { $app = Factory::getApplication(); $db = Factory::getDBO(); $driver = strtolower($db->name); switch ($driver) { default: case 'mysql': case 'mysqli': $driver = 'mysql'; break; case 'sqlsrv': case 'sqlazure': case 'sqlzure': $driver = 'sqlsrv'; break; case 'postgresql': case 'pgsql': $driver = 'postgresql'; break; } $file = JPATH_ADMINISTRATOR . '/components/com_jce/sql/' . $driver . '.sql'; $error = null; if (is_file($file)) { $query = file_get_contents($file); if ($query) { // replace prefix $query = $db->replacePrefix((string) $query); // set query $db->setQuery(trim($query)); if (!$db->execute()) { $app->enqueueMessage(Text::_('WF_INSTALL_TABLE_PROFILES_ERROR') . $db->stdErr(), 'error'); return false; } else { return true; } } else { $error = 'NO SQL QUERY'; } } else { $error = 'SQL FILE MISSING'; } $app->enqueueMessage(Text::_('WF_INSTALL_TABLE_PROFILES_ERROR') . !is_null($error) ? ' - ' . $error : '', 'error'); return false; } /** * Install Profiles. * * @return bool * * @param object $install[optional] */ public static function installProfiles() { $app = Factory::getApplication(); $db = Factory::getDBO(); if (self::createProfilesTable()) { self::buildCountQuery(); $profiles = array('Default' => false, 'Front End' => false); // No Profiles table data if (!$db->loadResult()) { $xml = JPATH_ADMINISTRATOR . '/components/com_jce/models/profiles.xml'; if (is_file($xml)) { if (!self::processImport($xml)) { $app->enqueueMessage(Text::_('WF_INSTALL_PROFILES_ERROR'), 'error'); return false; } } else { $app->enqueueMessage(Text::_('WF_INSTALL_PROFILES_NOFILE_ERROR'), 'error'); return false; } } return true; } return false; } private static function buildCountQuery($name = '') { $db = Factory::getDBO(); $query = $db->getQuery(true); // check for name $query->select('COUNT(id)')->from('#__wf_profiles'); if ($name) { $query->where('name = ' . $db->Quote($name)); } $db->setQuery($query); } public static function getDefaultProfile() { $mainframe = Factory::getApplication(); $file = JPATH_ADMINISTRATOR . '/components/com_jce/models/profiles.xml'; $xml = simplexml_load_file($file); Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jce/tables'); if ($xml) { foreach ($xml->profiles->children() as $profile) { if ($profile->attributes()->default) { $table = Table::getInstance('Profiles', 'JceTable'); foreach ($profile->children() as $item) { switch ($item->getName()) { case 'rows': $table->rows = (string) $item; break; case 'plugins': $table->plugins = (string) $item; break; default: $key = $item->getName(); $table->$key = (string) $item; break; } } // reset name and description $table->name = ''; $table->description = ''; return $table; } } } return null; } /** * Check whether a table exists. * * @return bool * * @param string $table Table name */ public static function checkTable() { $db = Factory::getDBO(); $tables = $db->getTableList(); if (!empty($tables)) { // swap array values with keys, convert to lowercase and return array keys as values $tables = array_keys(array_change_key_case(array_flip($tables))); $app = Factory::getApplication(); $match = str_replace('#__', strtolower($app->getCfg('dbprefix', '')), '#__wf_profiles'); return in_array($match, $tables); } // try with query self::buildCountQuery(); return $db->execute(); } /** * Check table contents. * * @return int * * @param string $table Table name */ public static function checkTableContents() { $db = Factory::getDBO(); self::buildCountQuery(); return $db->loadResult(); } public static function getUserGroups($area) { $db = Factory::getDBO(); $query = $db->getQuery(true); $query->select('id')->from('#__usergroups'); $db->setQuery($query); $groups = $db->loadColumn(); $front = array(); $back = array(); foreach ($groups as $group) { $create = Access::checkGroup($group, 'core.create'); $admin = Access::checkGroup($group, 'core.login.admin'); $super = Access::checkGroup($group, 'core.admin'); if ($super) { $back[] = $group; } else { // group can create if ($create) { // group has admin access if ($admin) { $back[] = $group; } else { $front[] = $group; } } } } switch ($area) { case 0: return array_merge($front, $back); break; case 1: return $front; break; case 2: return $back; break; } return array(); } /** * Process import data from XML file. * * @param object $file XML file * @param bool $install Can be used by the package installer */ public static function processImport($file) { $n = 0; $app = Factory::getApplication(); // load data from file $data = file_get_contents($file); // format params data as CDATA $data = preg_replace('#<params>{(.+?)}<\/params>#', '<params><![CDATA[{$1}]]></params>', $data); // load processed string $xml = simplexml_load_string($data); $user = Factory::getUser(); $date = Factory::getDate(); Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jce/tables'); $language = Factory::getLanguage(); $language->load('com_jce', JPATH_ADMINISTRATOR, null, true); if ($xml) { foreach ($xml->profiles->children() as $profile) { $table = Table::getInstance('Profiles', 'JceTable'); foreach ($profile->children() as $item) { $key = $item->getName(); $value = (string) $item; switch ($key) { case 'name': // only if name set and table name not set if ($value) { // create name copy if exists while ($table->load(array('name' => $value))) { if ($value === $table->name) { $value = StringHelper::increment($value); } } } break; case 'description': $value = Text::_($value); break; case 'types': if ($value === "") { $area = (string) $profile->area[0] || 0; $groups = self::getUserGroups($area); $value = implode(',', array_unique($groups)); } break; case 'users': break; case 'area': if ($value === "") { $value = '0'; } break; case 'components': break; case 'params': if (!empty($value)) { $data = json_decode($value, true); if (is_array($data)) { array_walk($data, function (&$param, $key) { if (is_string($param) && WFUtility::isJson($param)) { $param = json_decode($param, true); } }); } $value = json_encode($data); } if (empty($value)) { $value = "{}"; } break; case 'rows': break; case 'plugins': break; case 'area': case 'published': case 'ordering': $value = (int) $value; break; } $table->$key = $value; } // set new id $table->id = 0; // set checked_out $table->checked_out = $user->get('id'); // set checked_out_time $table->checked_out_time = $date->toSQL(); if (!$table->store()) { $app->enqueueMessage($table->getError(), 'error'); return false; } // check-in $table->checkin(); ++$n; } } return $n; } /** * CDATA encode a parameter if it contains & < > characters, eg: <![CDATA[index.php?option=com_content&view=article&id=1]]>. * * @param object $param * * @return CDATA encoded parameter or parameter */ public static function encodeData($data) { if (preg_match('/[<>&]/', $data)) { $data = '<![CDATA[' . $data . ']]>'; } $data = preg_replace('/"/', '\"', $data); return $data; } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка