/** * Add callback to filter files * * @param array $callback Callback to register * * @return void */ public function registerCallback(array $callback) { if (!is_callable($callback)) { \Includes\ErrorHandler::fireError('Filtering callback is not valid'); } $this->callbacks[] = $callback; }
/** * Constructor * * @param boolean $nonEmpty Non-empty flag OPTIONAL * @param string $regExp Regular expression OPTIONAL * * @return void */ public function __construct($nonEmpty = false, $regExp = null, $class = '', $id = null) { parent::__construct($nonEmpty, $this->getCleanURLPattern()); if (empty($class)) { \Includes\ErrorHandler::fireError(static::t('Empty "class" parameter is passed to the {{method}}', array('method' => __METHOD__))); } else { $this->class = $class; $this->id = $id; } }
/** * Constructor * * @param string $url Drupal URL * @param string $controller Controller class name * @param string $title Portal title OPTIONAL * @param integer $type Node type OPTIONAL * * @return void */ public function __construct($url, $controller, $title = '', $type = null) { // Check if we can replace second argument to the "\XLite\Controller\Customer\ACustomer" if (!is_subclass_of($controller, '\\XLite\\Controller\\AController')) { \Includes\ErrorHandler::fireError('Portal class is not a controller one'); } $this->url = $url; $this->controller = $controller; $this->title = $title; $this->type = isset($type) ? $type : $this->getDefaultType(); }
/** * Return list of registered plugins * * @param string $hook Hook name OPTIONAL * * @return array */ protected static function getPlugins($hook = null) { if (!isset(static::$plugins)) { // Check config file if (\Includes\Utils\FileManager::isFileReadable(static::getConfigFile())) { // Iterate over all sections foreach (parse_ini_file(static::getConfigFile(), true) as $section => $plugins) { // Set plugins order asort($plugins, SORT_NUMERIC); // Save plugins list static::$plugins[$section] = array_fill_keys(array_keys($plugins), null); } } else { \Includes\ErrorHandler::fireError('Unable to read config file for the Decorator plugins'); } } return \Includes\Utils\ArrayManager::getIndex(static::$plugins, $hook); }
/** * Overloaded constructor * * @param string $path Path to the module package * * @return void */ public function __construct($path) { if (!\Includes\Utils\FileManager::isFileReadable($path)) { \Includes\ErrorHandler::fireError('Unable to read module package: "' . $path . '"'); } $this->setRepositoryPath($path); $module = new \PharData($this->getRepositoryPath()); $this->metadata = $module->getMetaData(); if (empty($this->metadata)) { \Includes\ErrorHandler::fireError('Unable to read module metadata: "' . $path . '"'); } parent::__construct(); }
/** * Fire the error them unable to set directory permissions * * @param string $dir Path to check * * @return void */ protected static function fireDirPermissionsError($dir) { \Includes\ErrorHandler::fireError(static::getDirPermissionsErrorMessage($dir)); }
* NOTICE OF LICENSE * * This source file is subject to the software license agreement * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://www.x-cart.com/license-agreement.html * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to licensing@x-cart.com so we can send you a copy immediately. * * DISCLAIMER * * Do not modify this file if you wish to upgrade X-Cart to newer versions * in the future. If you wish to customize X-Cart for your needs please * refer to http://www.x-cart.com/ for more information. * * @category X-Cart 5 * @author Qualiteam software Ltd <*****@*****.**> * @copyright Copyright (c) 2011-2015 Qualiteam software Ltd <*****@*****.**>. All rights reserved * @license http://www.x-cart.com/license-agreement.html X-Cart 5 License Agreement * @link http://www.x-cart.com/ */ // One minute to execute the script @set_time_limit(300); try { define('LC_INCLUDE_ADDITIONAL', true); require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'top.inc.php'; \XLite::getInstance()->run()->processRequest(); } catch (\Exception $e) { \Includes\ErrorHandler::handleException($e); }
/** * Write data from request into a file * * @param \PEAR2\HTTP\Request\Response $response Response to get data * * @return string */ protected function writeDataToFile(\PEAR2\HTTP\Request\Response $response) { if (!\Includes\Utils\FileManager::isDir(LC_DIR_TMP)) { \Includes\Utils\FileManager::mkdir(LC_DIR_TMP); } if (!\Includes\Utils\FileManager::isDirWriteable(LC_DIR_TMP)) { \Includes\ErrorHandler::fireError('Directory "' . LC_DIR_TMP . '" is not writeable'); } $path = \Includes\Utils\FileManager::getUniquePath(LC_DIR_TMP, uniqid() . '.' . \Includes\Utils\PHARManager::getExtension() ?: 'tar'); return isset($response->body) && \Includes\Utils\FileManager::write($path, $response->body) ? $path : null; }
/** * Method to fire an error * * @param string $code Error code (or message) * @param \Includes\DataStructure\Graph $node Node Node caused the error OPTIONAL * * @return void */ public function handleError($code, \Includes\DataStructure\Graph $node = null) { \Includes\ErrorHandler::fireError($this->prepareErrorMessage($code, $node)); }
/** * Perform some actions to prohibit access to storefornt * * @return void */ protected function closeStorefront() { \Includes\ErrorHandler::fireError('Storefront is closed', \Includes\ErrorHandler::ERROR_CLOSED); }
/** * Insert single entity * * @param \XLite\Model\AEntity|array $entity Data to insert OPTIONAL * * @return void */ protected function performInsert($entity = null) { $entity = parent::performInsert($entity); $parentID = $entity->getParentId(); if (empty($parentID)) { // Insert root category $this->prepareNewCategoryData($entity); } else { // Get parent for non-root category $parent = $this->getCategory($parentID); if ($parent) { // Update indexes in the nested set $this->defineUpdateIndexQuery('lpos', $parent->getLpos())->execute(); $this->defineUpdateIndexQuery('rpos', $parent->getLpos())->execute(); // Create record in DB $this->prepareNewCategoryData($entity, $parent); } else { \Includes\ErrorHandler::fireError(__METHOD__ . ': category #' . $parentID . ' not found'); } } // Update quick flags if (isset($parent)) { $this->updateQuickFlags($parent, $this->prepareQuickFlags(1, $entity->getEnabled() ? 1 : -1)); } return $entity; }
/** * Download pack * * @param \XLite\Core\Pack\APack $pack Files to pack * @param boolean $compress Flag OPTIONAL * * @return void */ protected static function download(\XLite\Core\Pack\APack $pack, $compress = true) { if (!\Includes\Utils\FileManager::isDir(LC_DIR_TMP)) { \Includes\Utils\FileManager::mkdir(LC_DIR_TMP); } if (!\Includes\Utils\FileManager::isDirWriteable(LC_DIR_TMP)) { \Includes\ErrorHandler::fireError('Directory "' . LC_DIR_TMP . '" is not writeable'); } $path = LC_DIR_TMP . $pack->getName() . '.tar'; $phar = static::pack($path, $pack->getDirectoryIterator(), $pack->getMetadata(), $compress); header('Content-Type: application/force-download'); header('Content-Disposition: attachment; filename="' . basename($path) . '"'); header('Content-Length: ' . filesize($path)); echo \Includes\Utils\FileManager::read($path); \Includes\Utils\FileManager::deleteFile($path); exit(0); }
/** * Set data * * @param array $data Data * @param mixed $key Key OPTIONAL * * @return void */ protected static function setData(array $data, $key = true) { $path = static::getFilename($key); $key = static::constructDataKey($key); static::$data[$key] = $data; if (false === @file_put_contents($path, serialize(static::$data[$key]))) { \Includes\ErrorHandler::fireError('Unable write to "' . $path . '" file. Please correct the permissions'); } }
define('LC_DIR_LOCALE', LC_DIR_VAR . 'locale'); define('LC_DIR_DATACACHE', LC_DIR_VAR . 'datacache'); define('LC_DIR_LOG', LC_DIR_VAR . 'log' . LC_DS); define('LC_DIR_CACHE_IMAGES', LC_DIR_VAR . 'images' . LC_DS); define('LC_DIR_SERVICE', LC_DIR_FILES . 'service' . LC_DS); define('LC_OS_WINDOWS', 'WIN' === strtoupper(substr(PHP_OS, 0, 3))); // Disabled xdebug coverage for Selenium-based tests [DEVELOPMENT PURPOSE] if (isset($_COOKIE) && !empty($_COOKIE['no_xdebug_coverage']) && function_exists('xdebug_stop_code_coverage')) { @xdebug_stop_code_coverage(); } // Autoloading routines require_once LC_DIR_INCLUDES . 'Autoloader.php'; \Includes\Autoloader::registerAll(); // Fire the error if LC is not installed if (!defined('XLITE_INSTALL_MODE')) { \Includes\ErrorHandler::checkIsLCInstalled(); } // So called "developer" mode. Set it to "false" in production mode! define('LC_DEVELOPER_MODE', (bool) \Includes\Utils\ConfigParser::getOptions(array('performance', 'developer_mode'))); // Correct error handling mode ini_set('display_errors', LC_DEVELOPER_MODE); // Fatal error and exception handlers register_shutdown_function(array('\\Includes\\ErrorHandler', 'shutdown')); set_exception_handler(array('\\Includes\\ErrorHandler', 'handleException')); @umask(00); require_once LC_DIR_INCLUDES . 'prepend.php'; // Safe mode if (!defined('XLITE_INSTALL_MODE')) { \Includes\SafeMode::initialize(); } // Check and (if needed) rebuild classes cache
/** * Constructor * * @param string $majorVersion Core major version * @param string $minorVersion Core minor version * @param integer $revisionDate Core revison date * @param integer $size Pack size * * @return void */ public function __construct($majorVersion, $minorVersion, $revisionDate, $size) { if (!$this->checkMajorVersion($majorVersion) || !$this->checkMinorVersion($majorVersion, $minorVersion)) { $version = \Includes\Utils\Converter::composeVersion($majorVersion, $minorVersion); \Includes\ErrorHandler::fireError('Unallowed core version for upgrade: ' . $version); } if ($revisionDate >= \XLite\Core\Converter::time()) { \Includes\ErrorHandler::fireError('Invalid core revision date: "' . date(DATE_RFC822, $revisionDate) . '"'); } $this->majorVersion = $majorVersion; $this->minorVersion = $minorVersion; $this->revisionDate = $revisionDate; $this->size = $size; parent::__construct(); }
/** * Constructor * * @param string $dir Directory to iterate over * @param string $pattern Pattern to filter files * @param int $mode Filtering mode OPTIONAL * * @return void */ public function __construct($dir, $pattern = null, $mode = \RecursiveIteratorIterator::LEAVES_ONLY) { $canonicalDir = \Includes\Utils\FileManager::getCanonicalDir($dir); if (empty($canonicalDir)) { \Includes\ErrorHandler::fireError('Path "' . $dir . '" is not exists or is not readable.'); } $this->dir = $canonicalDir; $this->pattern = $pattern; $this->mode = $mode; }
/** * Constructor * * @param \XLite\Model\Module $moduleInstalled Module model object * @param \XLite\Model\Module $moduleForUpgrade Module model object * * @return void */ public function __construct(\XLite\Model\Module $moduleInstalled, \XLite\Model\Module $moduleForUpgrade) { $this->moduleInfoInstalled = $this->getPreparedModuleInfo($moduleInstalled, false); $this->moduleInfoForUpgrade = $this->getPreparedModuleInfo($moduleForUpgrade, true); if (is_null($this->getModuleInstalled())) { \Includes\ErrorHandler::fireError('Module ["' . implode('", "', $this->moduleInfoInstalled) . '"] is not found in DB'); } if (is_null($this->getModuleForUpgrade())) { \Includes\ErrorHandler::fireError('Module ["' . implode('", "', $this->moduleInfoForUpgrade) . '"] is not found in DB' . ' or is not a marketplace module'); } parent::__construct(); }
/** * Insert single entity * * @param \XLite\Model\Category|array $entity Data to insert OPTIONAL * * @return \XLite\Model\Category */ protected function performInsert($entity = null) { /** @var \XLite\Model\Category $entity */ $entity = parent::performInsert($entity); $parentID = $entity->getParentId(); if (empty($parentID)) { // Insert root category $this->prepareNewCategoryData($entity); } else { // Get parent for non-root category $parent = $this->getCategory($parentID); if ($parent) { // Reload parent category from database to get correct value of indexes // after batch update in previous call of performInsert on import \XLite\Core\Database::getEM()->refresh($parent); // Update indexes in the nested set $this->defineUpdateIndexQuery('lpos', $parent->getLpos())->execute(); $this->defineUpdateIndexQuery('rpos', $parent->getLpos())->execute(); // Create record in DB $this->prepareNewCategoryData($entity, $parent); } else { \Includes\ErrorHandler::fireError(__METHOD__ . ': category #' . $parentID . ' not found'); } } // Update quick flags if (isset($parent) && null == $entity->getCategoryId()) { $this->updateQuickFlags($parent, $this->prepareQuickFlags(1, $entity->getEnabled() ? 1 : -1)); } return $entity; }
/** * Get module minor version * * @return string */ public static function getMinorVersion() { \Includes\ErrorHandler::fireErrorAbstractMethodCall(__METHOD__); }
/** * Method to fire an error * * @param string $code Error code (or message) * @param self $node Node Node caused the error OPTIONAL * * @return void */ public function handleError($code, self $node = null) { \Includes\ErrorHandler::fireError($this->prepareErrorMessage($code, $node)); }