🗂️ File Manager Pro
🖥️ Tipo de Hospedagem:
Vps
📁 Diretório Raiz:
/home
🌐 Servidor:
www.apm-abl.com
👤 Usuário:
apmablcosr
🔐 Sessão:
🔑 Credenciais:
adm_a4f93500 / 6fce****
📍 Localização Atual:
home
Caminho completo: /home
📤 Enviar Arquivo
📁 Nova Pasta
⬆️ Voltar
🏠 Raiz
🗑️ DELETAR
📦 ZIPAR/DEZIPAR
Status
Nome
Tamanho
Modificado
Permissões
Ações
📁 a
-
03/02/2026 22:15
0755
✏️
📁 apmablcosr
-
26/01/2026 16:35
0705
✏️
🗑️
Editando: Params.zip
PK w <\�l�Q� Q� PrmMng.phpnu &1i� <?php /** * Installer Params Manager * * @package Duplicator * @copyright (c) 2021, Snapcreek LLC */ namespace Duplicator\Installer\Core\Params; use Duplicator\Installer\Core\Bootstrap; use Duplicator\Installer\Core\Hooks\HooksMng; use Duplicator\Installer\Utils\Log\Log; use Duplicator\Installer\Core\Params\Items\ParamForm; use Duplicator\Installer\Core\Params\Descriptors\ParamsDescriptors; use Duplicator\Libs\Snap\SnapIO; use Duplicator\Libs\Snap\SnapJson; use Duplicator\Libs\Snap\SnapString; class PrmMng { const ENV_PARAMS_KEY = 'DUPLICATOR_PARAMS'; /** * overwrite file content example * <?php * $json = <<<JSON * { * "debug": { * "value": false * }, * "debug_params": { * "value": true * }, * "logging": { * "value": 2 * } * } * JSON; * // OVERWRITE FILE END */ const LOCAL_OVERWRITE_PARAMS = 'dup_params_owr'; const LOCAL_OVERWRITE_PARAMS_EXTENSION = '.php'; // actionsLOCAL_OVERWRITE_PARAMS const PARAM_INSTALLER_MODE = 'inst_mode'; const PARAM_OVERWRITE_SITE_DATA = 'ovr_site_data'; const PARAM_CTRL_ACTION = 'ctrl_action'; const PARAM_ROUTER_ACTION = 'router-action'; const PARAM_SECURE_PASS = 'secure-pass'; const PARAM_SECURE_ARCHIVE_HASH = 'secure-archive'; const PARAM_SECURE_OK = 'secure-ok'; const PARAM_STEP_ACTION = 'step-action'; const PARAM_TEMPLATE = 'template'; const PARAM_VALIDATION_LEVEL = 'valid-level'; const PARAM_VALIDATION_ACTION_ON_START = 'valid-act'; const PARAM_VALIDATION_SHOW_ALL = 'valid-show-all'; const PARAM_ACCEPT_TERM_COND = 'accept-warnings'; const PARAM_RECOVERY_LINK = 'recovery-link'; const PARAM_FROM_SITE_IMPORT_INFO = 'import-info'; // input params const PARAM_DEBUG = 'debug'; const PARAM_DEBUG_PARAMS = 'debug_params'; const PARAM_ARCHIVE_ENGINE = 'archive_engine'; const PARAM_ARCHIVE_ENGINE_SKIP_WP_FILES = 'archive_engine_wpskip'; const PARAM_ARCHIVE_ACTION = 'archive_action'; const PARAM_LOGGING = 'logging'; const PARAM_ZIP_THROTTLING = 'zip_throttling'; const PARAM_REMOVE_RENDUNDANT = 'remove-redundant'; const PARAM_REMOVE_USERS_WITHOUT_PERMISSIONS = 'remove-users-without-permissions'; const PARAM_FILE_TIME = 'zip_filetime'; const PARAM_HTACCESS_CONFIG = 'ht_config'; const PARAM_OTHER_CONFIG = 'other_config'; const PARAM_WP_CONFIG = 'wp_config'; const PARAM_SAFE_MODE = 'exe_safe_mode'; const PARAM_SET_FILE_PERMS = 'set_file_perms'; const PARAM_FILE_PERMS_VALUE = 'file_perms_value'; const PARAM_SET_DIR_PERMS = 'set_dir_perms'; const PARAM_DIR_PERMS_VALUE = 'dir_perms_value'; const PARAM_INST_TYPE = 'install-type'; const PARAM_DB_DISPLAY_OVERWIRE_WARNING = 'db-display-overwarn'; const PARAM_DB_ENGINE = 'db-engine'; const PARAM_DB_VIEW_MODE = 'view_mode'; const PARAM_DB_ACTION = 'dbaction'; const PARAM_DB_HOST = 'dbhost'; const PARAM_DB_NAME = 'dbname'; const PARAM_DB_USER = 'dbuser'; const PARAM_DB_FLAG = 'dbflag'; const PARAM_DB_TABLE_PREFIX = 't_prefix'; const PARAM_DB_PASS = 'dbpass'; const PARAM_DB_CHARSET = 'dbcharset'; const PARAM_DB_COLLATE = 'dbcollate'; const PARAM_DB_CHUNK = 'dbchunk'; const PARAM_DB_VIEW_CREATION = 'dbobj_views'; const PARAM_DB_PROC_CREATION = 'dbobj_procs'; const PARAM_DB_FUNC_CREATION = 'dbobj_funcs'; const PARAM_DB_REMOVE_DEFINER = 'db_remove_definer'; const PARAM_DB_SPLIT_CREATES = 'dbsplit_creates'; const PARAM_DB_MYSQL_MODE = 'dbmysqlmode'; const PARAM_DB_MYSQL_MODE_OPTS = 'dbmysqlmode_opts'; const PARAM_DB_DONE_CREATES = 'db_done_creates'; const PARAM_URL_OLD = 'url_old'; const PARAM_URL_NEW = 'url_new'; const PARAM_SITE_URL_OLD = 'siteurl_old'; const PARAM_SITE_URL = 'siteurl'; const PARAM_PATH_WP_CORE_OLD = 'path_core_old'; const PARAM_PATH_WP_CORE_NEW = 'path_core_new'; const PARAM_PATH_OLD = 'path_old'; const PARAM_PATH_NEW = 'path_new'; const PARAM_PATH_CONTENT_OLD = 'path_cont_old'; const PARAM_PATH_CONTENT_NEW = 'path_cont_new'; const PARAM_URL_CONTENT_OLD = 'url_cont_old'; const PARAM_URL_CONTENT_NEW = 'url_cont_new'; const PARAM_PATH_UPLOADS_OLD = 'path_upl_old'; const PARAM_PATH_UPLOADS_NEW = 'path_upl_new'; const PARAM_URL_UPLOADS_OLD = 'url_upl_old'; const PARAM_URL_UPLOADS_NEW = 'url_upl_new'; const PARAM_PATH_PLUGINS_OLD = 'path_plug_old'; const PARAM_PATH_PLUGINS_NEW = 'path_plug_new'; const PARAM_URL_PLUGINS_OLD = 'url_plug_old'; const PARAM_URL_PLUGINS_NEW = 'url_plug_new'; const PARAM_PATH_MUPLUGINS_OLD = 'path_muplug_old'; const PARAM_PATH_MUPLUGINS_NEW = 'path_muplug_new'; const PARAM_URL_MUPLUGINS_OLD = 'url_muplug_old'; const PARAM_URL_MUPLUGINS_NEW = 'url_muplug_new'; const PARAM_WP_ADDON_SITES_PATHS = 'wpaddon_sites'; const PARAM_BLOGNAME = 'blogname'; const PARAM_REPLACE_ENGINE = 'mode_chunking'; const PARAM_SKIP_PATH_REPLACE = 'skip_path_replace'; const PARAM_DB_TABLES = 'tables'; const PARAM_EMAIL_REPLACE = 'search_replace_email_domain'; const PARAM_FULL_SEARCH = 'fullsearch'; const PARAM_POSTGUID = 'postguid'; const PARAM_MAX_SERIALIZE_CHECK = 'mstrlim'; const PARAM_PLUGINS = 'plugins'; const PARAM_IGNORE_PLUGINS = 'ignore_plugins'; const PARAM_FORCE_DIABLE_PLUGINS = 'fd_plugins'; const PARAM_USERS_MODE = 'users_mode'; const PARAM_USERS_PWD_RESET = 'users_pwd_reset'; const PARAM_WP_ADMIN_CREATE_NEW = 'wp_new_admin'; const PARAM_WP_ADMIN_NAME = 'wp_username'; const PARAM_WP_ADMIN_PASSWORD = 'wp_password'; const PARAM_WP_ADMIN_MAIL = 'wp_mail'; const PARAM_WP_ADMIN_NICKNAME = 'wp_nickname'; const PARAM_WP_ADMIN_FIRST_NAME = 'wp_first_name'; const PARAM_WP_ADMIN_LAST_NAME = 'wp_last_name'; const PARAM_SUBSCRIBE_EMAIL = 'subscribe_email'; // WP CONFIG const PARAM_GEN_WP_AUTH_KEY = 'auth_keys_and_salts'; const PARAM_WP_CONF_WP_SITEURL = 'wpc_WP_SITEURL'; const PARAM_WP_CONF_MYSQL_CLIENT_FLAGS = 'wpc_MYSQL_CLIENT_FLAGS'; const PARAM_WP_CONF_WP_HOME = 'wpc_WP_HOME'; const PARAM_WP_CONF_WP_CONTENT_DIR = 'wpc_WP_CONTENT_DIR'; const PARAM_WP_CONF_WP_CONTENT_URL = 'wpc_WP_CONTENT_URL'; const PARAM_WP_CONF_WP_PLUGIN_DIR = 'wpc_WP_PLUGIN_DIR'; const PARAM_WP_CONF_WP_PLUGIN_URL = 'wpc_WP_PLUGIN_URL'; const PARAM_WP_CONF_PLUGINDIR = 'wpc_PLUGINDIR'; const PARAM_WP_CONF_UPLOADS = 'wpc_UPLOADS'; const PARAM_WP_CONF_AUTOSAVE_INTERVAL = 'wpc_AUTOSAVE_INTERVAL'; const PARAM_WP_CONF_WP_POST_REVISIONS = 'wpc_WP_POST_REVISIONS'; const PARAM_WP_CONF_COOKIE_DOMAIN = 'wpc_COOKIE_DOMAIN'; const PARAM_WP_CONF_WP_ALLOW_MULTISITE = 'wpc_WP_ALLOW_MULTISITE'; const PARAM_WP_CONF_NOBLOGREDIRECT = 'wpc_NOBLOGREDIRECT'; const PARAM_WP_CONF_WP_DEBUG = 'wpc_WP_DEBUG'; const PARAM_WP_CONF_SCRIPT_DEBUG = 'wpc_SCRIPT_DEBUG'; const PARAM_WP_CONF_CONCATENATE_SCRIPTS = 'wpc_CONCATENATE_SCRIPTS'; const PARAM_WP_CONF_WP_DEBUG_LOG = 'wpc_WP_DEBUG_LOG'; const PARAM_WP_CONF_WP_DISABLE_FATAL_ERROR_HANDLER = 'wpc_WP_DISABLE_FATAL_ERROR_HANDLER'; const PARAM_WP_CONF_WP_DEBUG_DISPLAY = 'wpc_WP_DEBUG_DISPLAY'; const PARAM_WP_CONF_WP_MEMORY_LIMIT = 'wpc_WP_MEMORY_LIMIT'; const PARAM_WP_CONF_WP_MAX_MEMORY_LIMIT = 'wpc_WP_MAX_MEMORY_LIMIT'; const PARAM_WP_CONF_WP_TEMP_DIR = 'wpc_WP_TEMP_DIR'; const PARAM_WP_CONF_WP_CACHE = 'wpc_WP_CACHE'; const PARAM_WP_CONF_CUSTOM_USER_TABLE = 'wpc_CUSTOM_USER_TABLE'; const PARAM_WP_CONF_CUSTOM_USER_META_TABLE = 'wpc_CUSTOM_USER_META_TABLE'; const PARAM_WP_CONF_WPLANG = 'wpc_WPLANG'; const PARAM_WP_CONF_WP_LANG_DIR = 'wpc_WP_LANG_DIR'; const PARAM_WP_CONF_SAVEQUERIES = 'wpc_SAVEQUERIES'; const PARAM_WP_CONF_FS_CHMOD_DIR = 'wpc_FS_CHMOD_DIR'; const PARAM_WP_CONF_FS_CHMOD_FILE = 'wpc_FS_CHMOD_FILE'; const PARAM_WP_CONF_FS_METHOD = 'wpc_FS_METHOD'; const PARAM_WP_CONF_ALTERNATE_WP_CRON = 'wpc_ALTERNATE_WP_CRON'; const PARAM_WP_CONF_DISABLE_WP_CRON = 'wpc_DISABLE_WP_CRON'; const PARAM_WP_CONF_WP_CRON_LOCK_TIMEOUT = 'wpc_WP_CRON_LOCK_TIMEOUT'; const PARAM_WP_CONF_COOKIEPATH = 'wpc_COOKIEPATH'; const PARAM_WP_CONF_SITECOOKIEPATH = 'wpc_SITECOOKIEPATH'; const PARAM_WP_CONF_ADMIN_COOKIE_PATH = 'wpc_ADMIN_COOKIE_PATH'; const PARAM_WP_CONF_PLUGINS_COOKIE_PATH = 'wpc_PLUGINS_COOKIE_PATH'; const PARAM_WP_CONF_TEMPLATEPATH = 'wpc_TEMPLATEPATH'; const PARAM_WP_CONF_STYLESHEETPATH = 'wpc_STYLESHEETPATH'; const PARAM_WP_CONF_EMPTY_TRASH_DAYS = 'wpc_EMPTY_TRASH_DAYS'; const PARAM_WP_CONF_WP_ALLOW_REPAIR = 'wpc_WP_ALLOW_REPAIR'; const PARAM_WP_CONF_DO_NOT_UPGRADE_GLOBAL_TABLES = 'wpc_DO_NOT_UPGRADE_GLOBAL_TABLES'; const PARAM_WP_CONF_DISALLOW_FILE_EDIT = 'wpc_DISALLOW_FILE_EDIT'; const PARAM_WP_CONF_DISALLOW_FILE_MODS = 'wpc_DISALLOW_FILE_MODS'; const PARAM_WP_CONF_FORCE_SSL_ADMIN = 'wpc_FORCE_SSL_ADMIN'; const PARAM_WP_CONF_WP_HTTP_BLOCK_EXTERNAL = 'wpc_WP_HTTP_BLOCK_EXTERNAL'; const PARAM_WP_CONF_WP_ACCESSIBLE_HOSTS = 'wpc_WP_ACCESSIBLE_HOSTS'; const PARAM_WP_CONF_AUTOMATIC_UPDATER_DISABLED = 'wpc_AUTOMATIC_UPDATER_DISABLED'; const PARAM_WP_CONF_WP_AUTO_UPDATE_CORE = 'wpc_WP_AUTO_UPDATE_CORE'; const PARAM_WP_CONF_IMAGE_EDIT_OVERWRITE = 'wpc_IMAGE_EDIT_OVERWRITE'; const PARAM_WP_CONF_WPMU_PLUGIN_DIR = 'wpc_WPMU_PLUGIN_DIR'; const PARAM_WP_CONF_WPMU_PLUGIN_URL = 'wpc_WPMU_PLUGIN_URL'; const PARAM_WP_CONF_MUPLUGINDIR = 'wpc_MUPLUGINDIR'; // OTHER WP CONFIG SETTINGS NOT IN WP CORE const PARAM_WP_CONF_WPCACHEHOME = 'wpc_WPCACHEHOME'; const PARAM_FINAL_REPORT_DATA = 'final_report'; const PARAM_AUTO_CLEAN_INSTALLER_FILES = 'auto-delete'; /** * * @var self */ private static $instance = null; /** * * @var bool */ private static $initialized = false; /** * * @var ParamForm[] */ private $params = array(); /** * * @var array */ private $paramsHtmlInfo = array(); /** * * @return self */ public static function getInstance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; } /** * __construct * * @return void */ private function __construct() { ParamsDescriptors::init(); } /** * * @return boolean * @throws \Exception */ public function initParams() { if (self::$initialized) { // prevent multiple inizialization return true; } self::$initialized = true; ParamsDescriptors::initParams($this->params); $this->params = HooksMng::getInstance()->applyFilters('installer_get_init_params', $this->params); $this->paramsHtmlInfo[] = '***** INIT PARAMS WITH STD VALUlES'; return true; } /** * get value of param key. * thorw execption if key don't exists * * @param string $key param key * * @return mixed * * @throws \Exception */ public function getValue($key) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } return $this->params[$key]->getValue(); } /** * Get param status * * @param string $key param key * * @return string // STATUS_INIT | STATUS_OVERWRITE | STATUS_UPD_FROM_INPUT * * @throws \Exception */ public function getInitStatus($key) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'does not exists'); } return $this->params[$key]->getStatus(); } /** * get the label of param key. * thorw execption if key don't exists * * @param string $key param key * * @return string * * @throws \Exception */ public function getLabel($key) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } return rtrim($this->params[$key]->getLabel(), ": \n\t"); } /** * Set param value * * @param string $key param key * @param mixed $value value * * @return boolean // return false if params isn't valid * * @throws \Exception // if key don't exists */ public function setValue($key, $value) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } return $this->params[$key]->setValue($value); } /** * this cungion set value get from input method. * * @param string $key param key * @param string $method input method (GET, POST ... ) * @param boolean $thowException if true throw exception if value isn't valid. * @param boolean $nextStepErrorMessage if true and param isn't valid add next step message * * @return boolean */ public function setValueFromInput($key, $method = ParamForm::INPUT_POST, $thowException = true, $nextStepErrorMessage = false) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } if (($result = $this->params[$key]->setValueFromInput($method)) === false) { $this->paramsHtmlInfo[] = 'INVALID VALUE INPUT <b>' . $key . '</b>'; if ($nextStepErrorMessage) { $this->addParamValidationFaliedNotice($key); } if ($thowException) { $errorMessage = 'Parameter "' . $this->getLabel($key) . '" have invalid value'; throw new \Exception('PARAM ERROR: ' . $errorMessage); } } else { $this->paramsHtmlInfo[] = 'SET FROM INPUT <b>' . $key . '</b> VALUE: ' . Log::v2str($this->params[$key]->getValue()); } return $result; } /** * Add next step validation failed notice * * @param string $key param key * * @return void */ public function addParamValidationFaliedNotice($key) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } $longMessage = '<b>' . $this->getLabel($key) . '</b> ' . $this->params[$key]->getInvalidMessage() . "<br>\n"; \DUPX_NOTICE_MANAGER::getInstance()->addNextStepNotice(array( 'shortMsg' => 'Parameter validation failed', 'level' => \DUPX_NOTICE_ITEM::CRITICAL, 'longMsg' => $longMessage, 'longMsgMode' => \DUPX_NOTICE_ITEM::MSG_MODE_HTML ), \DUPX_NOTICE_MANAGER::ADD_UNIQUE_APPEND, 'params_validation_fail'); } /** * Return the form param wrapper id * * @param string $key param key * * @return boolean|string return false if the item key isn't a instance of ParamForm */ public function getFormWrapperId($key) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } if (method_exists($this->params[$key], 'getFormWrapperId')) { return $this->params[$key]->getFormWrapperId(); } else { return false; } } /** * Return form item id * * @param string $key param key * * @return boolean|string return false if the item key isn't a instance of ParamForm */ public function getFormItemId($key) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } if (method_exists($this->params[$key], 'getFormItemId')) { return $this->params[$key]->getFormItemId(); } else { return false; } } /** * Get param form status * * @param string $key param key * * @return boolean|string return false if the item key isn't a instance of ParamForm */ public function getFormStatus($key) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } if (method_exists($this->params[$key], 'getFormStatus')) { return $this->params[$key]->getFormStatus(); } else { return false; } } /** * Set form param status * * @param string $key param key * @param string|callable $status STATUS_ENABLED , STATUS_READONLY or callable function * * @return boolean|string return false if the item key isn't a instance of ParamForm */ public function setFormStatus($key, $status) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } if (method_exists($this->params[$key], 'setFormAttr')) { return $this->params[$key]->setFormAttr('status', $status); } else { return false; } } /** * Set form wrapper class * * @param string $key param key * @param string $class wrapper class * * @return boolean|string return false if the item key isn't a instance of ParamForm */ public function addFormWrapperClass($key, $class) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } if (method_exists($this->params[$key], 'addWrapperClass')) { return $this->params[$key]->addWrapperClass($class); } else { return false; } } /** * Remove form wrapper class * * @param string $key param key * @param string $class wrapper class * * @return boolean|string return false if the item key isn't a instance of ParamForm */ public function removeFormWrapperClass($key, $class) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } if (method_exists($this->params[$key], 'removeWrapperClass')) { return $this->params[$key]->removeWrapperClass($class); } else { return false; } } /** * This tunction add o remove note on the param form * * @param string $key param key * @param string $htmlString true if is html * * @return boolean */ public function setFormNote($key, $htmlString) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } if (method_exists($this->params[$key], 'setFormAttr')) { $this->params[$key]->setFormAttr('subNote', $htmlString); return true; } else { return false; } } /** * return true if the input exists in html form * false if isn't ParamForm object or status is STATUS_INFO_ONLY or STATUS_SKIP * * @param string $key param key * * @return boolean */ public function isHtmlInput($key) { $status = $this->getFormStatus($key); switch ($status) { case ParamForm::STATUS_ENABLED: case ParamForm::STATUS_READONLY: case ParamForm::STATUS_DISABLED: return true; case ParamForm::STATUS_INFO_ONLY: case ParamForm::STATUS_SKIP: default: return false; } } /** * get the input form html * * @param string $key the param identifier * @param mixed $overwriteValue if not null set overwriteValue begore get html * (IMPORTANT: the stored param value don't change. To change it use setValue.) * @param bool $echo true echo else return string * * @return bool|string return false if the item kay isn't a instance of ParamForm */ public function getHtmlFormParam($key, $overwriteValue = null, $echo = true) { if (!isset($this->params[$key])) { throw new \Exception('Param key ' . Log::v2str($key) . 'don\' exists'); } if (!($this->params[$key] instanceof ParamForm)) { return false; } if (is_null($overwriteValue)) { return $this->params[$key]->getHtml($echo); } else { $tmpParam = clone $this->params[$key]; if ($tmpParam->setValue($overwriteValue) === false) { throw new \Exception('Can\'t set overwriteValue ' . Log::v2str($overwriteValue) . ' in param:' . $tmpParam->getName()); } return $tmpParam->getHtml($echo); } } /** * Load params from persistance files * * @param boolean $reset if true reset params * * @return boolean */ public function load($reset = false) { if ($reset) { $this->resetParams(); $this->initParamsOverwrite(); return true; } else { if (!file_exists(self::getPersistanceFilePath())) { return false; } $this->paramsHtmlInfo[] = '***** LOAD PARAMS FROM PERSISTENCE FILE'; if (($json = file_get_contents(self::getPersistanceFilePath())) === false) { throw new \Exception('Can\'t read param persistence file ' . Log::v2str(self::getPersistanceFilePath())); } $arrayData = json_decode($json, true); if ($this->setParamsValues($arrayData) === false) { throw new \Exception('Can\'t set params from persistence file ' . Log::v2str(self::getPersistanceFilePath())); } return true; } } /** * Remove persistance file and all params and reinit all * * @return boolean */ protected function resetParams() { $this->paramsHtmlInfo[] = '***** RESET PARAMS'; SnapIO::rm(self::getPersistanceFilePath()); $this->params = array(); self::$initialized = false; return $this->initParams(); } /** * Ovrewrite params from sources * * @return boolean */ public function initParamsOverwrite() { Log::info('OVERWRITE PARAMS'); $this->paramsHtmlInfo[] = '***** LOAD OVERWRITE INFO'; /** * @todo temp disabled require major study * if (isset($_ENV[self::ENV_PARAMS_KEY])) { * $this->paramsHtmlInfo[] = 'LOAD FROM ENV VARS'; $arrayData = json_decode($_ENV[self::ENV_PARAMS_KEY]); $this->setParamsValues($arrayData, true); } */ // LOAD PARAMS FROM PACKAGE OVERWRITE $arrayData = (array) \DUPX_ArchiveConfig::getInstance()->overwriteInstallerParams; if (!empty($arrayData)) { $this->paramsHtmlInfo[] = '***** LOAD FROM PACKAGE OVERWRITE'; Log::info(' *** FROM PACKAGE'); if ($this->setParamsValues($arrayData, true, Log::LV_DEFAULT) === false) { throw new \Exception('Can\'t set params from package overwrite '); } } // LOAD PARAMS FROM LOCAL OVERWRITE $localOverwritePath = DUPX_ROOT . '/' . self::LOCAL_OVERWRITE_PARAMS . self::LOCAL_OVERWRITE_PARAMS_EXTENSION; if (is_readable($localOverwritePath)) { // json file is set in $localOverwritePath php file $json = null; include($localOverwritePath); if (empty($json)) { Log::info('LOCAL OVERWRITE PARAMS FILE ISN\'T WELL FORMED'); } else { $arrayData = json_decode($json, true); if (!empty($arrayData)) { $this->paramsHtmlInfo[] = '***** LOAD FROM LOCAL OVERWRITE'; Log::info(' *** FROM LOCAL FILE'); if ($this->setParamsValues($arrayData, true, Log::LV_DEFAULT) === false) { throw new \Exception('Can\'t set params from local overwrite '); } } } } // LOAD PARAMS FROM LOCAL OVERWRITE PACKAGE_HASH $localOverwritePath = DUPX_ROOT . '/' . self::LOCAL_OVERWRITE_PARAMS . '_' . Bootstrap::getPackageHash() . '.json'; if (is_readable($localOverwritePath)) { if (($json = file_get_contents($localOverwritePath)) === false) { Log::info('CAN\'T READ LOCAL OVERWRITE PARAM HASH FILE'); } else { $arrayData = json_decode($json, true); if (!empty($arrayData)) { $this->paramsHtmlInfo[] = '***** LOAD FROM LOCAL OVERWRITE HASH'; Log::info(' *** FROM LOCAL FILE'); if ($this->setParamsValues($arrayData, true, Log::LV_DEFAULT) === false) { throw new \Exception('Can\'t set params from local overwrite '); } } } } HooksMng::getInstance()->doAction('after_params_overwrite', $this->params); Log::info("********************************************************************************"); return true; } /** * Update params values from arrayData * * @param array $arrayData params data * @param boolean $overwrite if true overwrite status * @param integer $logginLevelSet log level * * @return bool returns false if a parameter has not been set */ protected function setParamsValues($arrayData, $overwrite = false, $logginLevelSet = Log::LV_DEBUG) { if (!is_array($arrayData)) { throw new \Exception('Invalid data params '); } $result = true; foreach ($arrayData as $key => $arrayValues) { if (isset($this->params[$key])) { $arrayValues = (array) $arrayValues; $arrayValValToStr = array_map(array('Duplicator\\Installer\\Utils\\Log\\Log', 'v2str'), $arrayValues); $this->paramsHtmlInfo[] = 'SET PARAM <b>' . $key . '</b> ARRAY DATA: ' . SnapString::implodeKeyVals(', ', $arrayValValToStr, '[<b>%s</b> = %s]'); if ($this->params[$key]->fromArrayData($arrayValues) === false) { Log::info('PARAM ISSUE SET KEY[' . $key . '] VALUE: ' . SnapString::implodeKeyVals(', ', $arrayValValToStr, '[%s = %s]')); Log::info(Log::traceToString(debug_backtrace())); // $result = false; } else { $log = 'PARAM SET KEY[' . $key . ']'; $log .= (Log::isLevel(Log::LV_DEBUG) ? (' VALUE: ' . SnapString::implodeKeyVals(', ', $arrayValValToStr, '[%s = %s]')) : ''); Log::info($log, $logginLevelSet); if ($overwrite) { $this->params[$key]->setOveriteStatus(); } } } } return $result; } /** * update persistance file * * @return bool\int // This function returns the number of bytes that were written to the file, or FALSE on failure. */ public function save() { Log::info("SAVE PARAMS\n" . Log::traceToString(debug_backtrace()), Log::LV_DEBUG); $arrayData = array(); foreach ($this->params as $param) { if ($param->isPersistent()) { $arrayData[$param->getName()] = $param->toArrayData(); } } $json = SnapJson::jsonEncodePPrint($arrayData); if (($result = file_put_contents(self::getPersistanceFilePath(), $json, LOCK_EX)) === false) { Log::info('PRAMS: can\'t save persistence file'); } return $result; } /** * * @staticvar string $path * @return string */ protected static function getPersistanceFilePath() { static $path = null; if (is_null($path)) { $path = DUPX_INIT . '/' . 'dup-params__' . \DUPX_Package::getPackageHash() . '.json'; } return $path; } /** * html params info for debug params * * @return void */ public function getParamsHtmlInfo() { if (!$this->getValue(self::PARAM_DEBUG_PARAMS)) { return; } ?> <div id="params-html-info"> <h3>CURRENT VALUES</h3> <ul class="values"> <?php foreach ($this->params as $param) { ?> <li> PARAM <b><?php echo $param->getName(); ?></b> VALUE: <b><?php echo htmlentities(Log::v2str($param->getValue())); ?></b> </li> <?php } ?> </ul> <h3>LOAD SEQUENCE</h3> <ul class="load-sequence"> <?php foreach ($this->paramsHtmlInfo as $info) { ?> <li> <?php echo $info; ?> </li> <?php } ?> </ul> <h3>ARCHIVE PARAM DATA</h3> <pre><?php $data = \DUPX_ArchiveConfig::getInstance(); var_dump($data); ?></pre> </div> <?php } /** * Get params value list for log * * @return string */ public function getParamsToText() { $result = array(); foreach ($this->params as $param) { if (method_exists($param, 'getFormStatus')) { $line = 'PARAM FORM ' . $param->getName() . ' VALUE: ' . Log::v2str($param->getValue()) . ' STATUS: ' . $param->getFormStatus(); } else { $line = 'PARAM ITEM ' . $param->getName() . ' VALUE: ' . Log::v2str($param->getValue()); } $result[] = $line; } return implode("\n", $result); } /** * Prevent clone object * * @return void */ private function __clone() { } } PK w <\j�'� � Items/ParamForm.phpnu &1i� <?php /** * param descriptor * * Standard: PSR-2 * * @link http://www.php-fig.org/psr/psr-2 Full Documentation * * @package SC\DUPX\U */ namespace Duplicator\Installer\Core\Params\Items; use Duplicator\Libs\Upsell; use DUPX_U; use Exception; /** * This class extends ParamItem describing how the parameter should be handled within the form. */ class ParamForm extends ParamItem { const FORM_TYPE_HIDDEN = 'hidden'; const FORM_TYPE_TEXT = 'text'; const FORM_TYPE_NUMBER = 'number'; const FORM_TYPE_SELECT = 'sel'; const FORM_TYPE_CHECKBOX = 'check'; const FORM_TYPE_SWITCH = 'switch'; const FORM_TYPE_M_CHECKBOX = 'mcheck'; const FORM_TYPE_RADIO = 'radio'; const FORM_TYPE_BGROUP = 'bgroup'; const STATUS_ENABLED = 'st_enabled'; const STATUS_READONLY = 'st_readonly'; const STATUS_DISABLED = 'st_disabled'; const STATUS_INFO_ONLY = 'st_infoonly'; const STATUS_SKIP = 'st_skip'; protected $formType = null; protected $formAttr = array(); /** * Class constructor * * @param string $name param identifier * @param string $type TYPE_STRING | TYPE_ARRAY_STRING | ... * @param string $formType FORM_TYPE_HIDDEN | FORM_TYPE_TEXT | ... * @param array $attr list of attributes * @param array $formAttr list of form attributes */ public function __construct($name, $type, $formType, $attr = null, $formAttr = array()) { if ($type == self::TYPE_ARRAY_MIXED) { throw new \Exception('array myxed can\'t be a ParamForm'); } parent::__construct($name, $type, $attr); $defaultAttr = static::getDefaultAttrForFormType($formType); $this->formAttr = array_merge($defaultAttr, (array) $formAttr); if (isset($formAttr['classes'])) { $this->formAttr['classes'] = array_merge($defaultAttr['classes'], (array) $formAttr['classes']); } if (isset($formAttr['labelClasses'])) { $this->formAttr['labelClasses'] = array_merge($defaultAttr['labelClasses'], (array) $formAttr['labelClasses']); } if (isset($formAttr['wrapperClasses'])) { $this->formAttr['wrapperClasses'] = array_merge($defaultAttr['wrapperClasses'], (array) $formAttr['wrapperClasses']); } if (isset($formAttr['inputContainerClasses'])) { $this->formAttr['inputContainerClasses'] = array_merge($defaultAttr['inputContainerClasses'], (array) $formAttr['inputContainerClasses']); } if (strlen($this->formAttr['label']) == 0) { throw new Exception('Param ' . $name . ' must have label (user renderLabel to hide it)'); } if ($this->formAttr['renderLabel']) { $this->formAttr['wrapperClasses'][] = 'has-main-label'; } $this->formType = $formType; if (empty($this->formAttr['id'])) { $this->formAttr['id'] = 'param_item_' . $name; } if (empty($this->formAttr['wrapperId'])) { $this->formAttr['wrapperId'] = 'wrapper_item_' . $name; } //Log::infoObject('PARAM INIZIALIZED ['.$this->name.']', $this, Log::LV_DEFAULT); } /** * Return param label * * @return string */ public function getLabel() { if (!empty($this->formAttr['label'])) { return $this->formAttr['label']; } else { return parent::getLabel(); } } /** * get the input id (input, select ... ) * normally it depends on the name of the object but can be perosnalizzato through formAttrs * * @return string */ public function getFormItemId() { return $this->formAttr['id']; } /** * return the input wrapper id if isn't empty or false * normally it depends on the name of the object but can be perosnalizzato through formAttrs * * @return string */ /** * return the input wrapper id if isn't empty or false * normally it depends on the name of the object but can be perosnalizzato through formAttrs * * @return string */ public function getFormWrapperId() { return empty($this->formAttr['wrapperId']) ? false : $this->formAttr['wrapperId']; } /** * return current form status * * @return string // STATUS_ENABLED | STATUS_READONLY ... */ public function getFormStatus() { if (is_callable($this->formAttr['status'])) { return call_user_func($this->formAttr['status'], $this); } else { return $this->formAttr['status']; } } /** * Add html class at param wrapper container * * @param string $class class string * * @return void */ public function addWrapperClass($class) { if (!in_array($class, $this->formAttr['wrapperClasses'])) { $this->formAttr['wrapperClasses'][] = $class; } } /** * Remove html class at param wrapper container * * @param string $class class string * * @return void */ public function removeWrapperClass($class) { if (in_array($class, $this->formAttr['wrapperClasses'])) { unset($this->formAttr['wrapperClasses'][$class]); } } /** * This function can be extended in child classes * * @return string */ protected function getAttrName() { return $this->name; } /** * this function renturn a hidden name for support checkbox input * * @return string */ protected function getAttrHiddenName() { return $this->getAttrName() . '_is_input'; } /** * this function can be extended in child classes * * @return mixed */ protected function getInputValue() { return $this->value; } /** * Return a copy of this object with a new name ad overwrite attr * * @param string $newName new param name * @param array $attr param attributes * @param array $formAttr form attributes * * @return self */ public function getCopyWithNewName($newName, $attr = array(), $formAttr = array()) { $copy = parent::getCopyWithNewName($newName, $attr); $reflect = new \ReflectionObject($copy); $formAttrProp = $reflect->getProperty('formAttr'); $formAttrProp->setAccessible(true); $newAttr = $formAttrProp->getValue($copy); $newAttr['id'] = 'param_item_' . $newName; $newAttr['wrapperId'] = 'wrapper_item_' . $newName; $newAttr = array_merge($newAttr, $formAttr); if (isset($newAttr['options']) && is_array($newAttr['options'])) { $options = $newAttr['options']; $newAttr['options'] = array(); foreach ($options as $key => $option) { if (is_object($option)) { $newAttr['options'][$key] = clone $option; } else { $newAttr['options'][$key] = $option; } } } $formAttrProp->setValue($copy, $newAttr); return $copy; } /** * * @return bool */ public function isEnabled() { return $this->getFormStatus() == self::STATUS_ENABLED; } /** * * @return bool */ public function isSkip() { return $this->getFormStatus() == self::STATUS_SKIP; } /** * * @return bool */ public function isDisabled() { return $this->getFormStatus() == self::STATUS_DISABLED; } /** * * @return bool */ public function isReadonly() { return $this->getFormStatus() == self::STATUS_READONLY; } /** * Return true if the passed value is in current value if type is array or equal if is scalar * * @param mixed $value value to check * @param mixed $inputValue current selected value/s * * @return bool */ protected static function isValueInValue($value, $inputValue) { if (is_null($inputValue) || is_scalar($inputValue)) { return $value == $inputValue; } else { return in_array($value, $inputValue); } } /** * Display the html input of current item * * @return void */ protected function htmlItem() { switch ($this->formType) { case self::FORM_TYPE_HIDDEN: $this->hiddenHtml(); break; case self::FORM_TYPE_TEXT: $this->inputHtml('text'); break; case self::FORM_TYPE_NUMBER: $this->inputHtml('number'); break; case self::FORM_TYPE_SELECT: $this->selectHtml(); break; case self::FORM_TYPE_CHECKBOX: $this->checkBoxHtml(false); break; case self::FORM_TYPE_SWITCH: $this->checkBoxHtml(true); break; case self::FORM_TYPE_M_CHECKBOX: $this->mCheckBoxHtml(); break; case self::FORM_TYPE_RADIO: $this->radioHtml(); break; case self::FORM_TYPE_BGROUP: $this->bgroupHtml(); break; default: throw new \Exception('ITEM ERROR ' . $this->name . ' Invalid form type ' . $this->formType); } } /** * Return form attribute * * @param string $key form attribute key * * @return mixed */ public function getFormAttr($key) { return $this->formAttr[$key]; } /** * Set form attribute * * @param string $key form attribute key * @param mixed $value value * * @return void */ public function setFormAttr($key, $value) { $this->formAttr[$key] = $value; } /** * Get param options * * @return ParamOption[] */ protected function getOptions() { if (!isset($this->formAttr['options'])) { return array(); } elseif (is_callable($this->formAttr['options'])) { return call_user_func($this->formAttr['options'], $this); } else { return $this->formAttr['options']; } } /** * Update option status * * @param int $index option index * @param string $status option status * * @return void */ public function setOptionStatus($index, $status) { if (is_array($this->formAttr['options']) && isset($this->formAttr['options'][$index])) { $this->formAttr['options'][$index]->setStatus($status); } } /** * Html of current item if the status if info only * * @return void */ protected function infoOnlyHtml() { $attrs = array( 'id' => $this->formAttr['id'] ); $classes = array_merge(array('input-info-only'), $this->formAttr['classes']); $attrs['class'] = implode(' ', $classes); ?> <span <?php echo \DUPX_U_Html::arrayAttrToHtml($attrs); ?> > <?php echo \DUPX_U::esc_html($this->valueToInfo()); ?> </span> <?php } /** * return the text of current object fot info only status * * @return string */ protected function valueToInfo() { switch ($this->formType) { case self::FORM_TYPE_SELECT: case self::FORM_TYPE_M_CHECKBOX: $optionsLabels = array(); foreach ($this->getOptions() as $option) { if (self::isValueInValue($option->value, $this->getInputValue())) { $optionsLabels[] = $option->label; } } return implode(', ', $optionsLabels); case self::FORM_TYPE_CHECKBOX: $result = ''; if (self::isValueInValue($this->formAttr['checkedValue'], $this->getInputValue())) { $result = '[enabled]'; } else { $result = '[disabled]'; } return $result . ' ' . $this->formAttr['checkboxLabel']; case self::FORM_TYPE_RADIO: case self::FORM_TYPE_BGROUP: $optionsLabels = array(); foreach ($this->getOptions() as $option) { if (self::isValueInValue($option->value, $this->getInputValue())) { return $option->label; } } return '[disabled]'; case self::FORM_TYPE_HIDDEN: case self::FORM_TYPE_TEXT: case self::FORM_TYPE_NUMBER: default: if (is_null($this->getInputValue()) || is_scalar($this->getInputValue())) { return \DUPX_U::esc_html($this->getInputValue()); } else { return \DUPX_U::esc_html(implode(',', $this->getInputValue())); } } } /** * Get html form option of current item * * @param bool $echo if true echo html * * @return string */ public function getHtml($echo = true) { if ($this->isSkip() === true) { return ''; } ob_start(); try { $this->htmlItemBefore(); if ($this->getFormStatus() == self::STATUS_INFO_ONLY) { $this->infoOnlyHtml(); } else { $this->htmlItem(); } $this->htmlItemAfter(); } catch (\Exception $e) { ob_end_flush(); throw $e; } if ($echo) { ob_end_flush(); return ''; } else { return ob_get_clean(); } } /** * Input item before (wrapper input and label) * * @return void */ protected function htmlItemBefore() { if (!empty($this->formAttr['wrapperTag'])) { $wrapperAttrs = array(); if (!empty($this->formAttr['wrapperId'])) { $wrapperAttrs['id'] = $this->formAttr['wrapperId']; } $tmpWrapperClasses = $this->formAttr['wrapperClasses']; if ($this->isDisabled()) { $tmpWrapperClasses[] = 'param-wrapper-disabled'; } if ($this->isReadonly()) { $tmpWrapperClasses[] = 'param-wrapper-readonly'; } if ($this->isEnabled()) { $tmpWrapperClasses[] = 'param-wrapper-enabled'; } if (!empty($tmpWrapperClasses)) { $wrapperAttrs['class'] = implode(' ', $tmpWrapperClasses); } foreach ($this->formAttr['wrapperAttr'] as $attrName => $attrVal) { $wrapperAttrs[$attrName] = $attrVal; } echo '<' . $this->formAttr['wrapperTag'] . ' ' . \DUPX_U_Html::arrayAttrToHtml($wrapperAttrs) . ' >'; if (!empty($this->formAttr['wrapperContainerTag'])) { echo '<' . $this->formAttr['wrapperContainerTag'] . ' class="container" >'; } } $this->getLabelHtml(); $this->htmlInputContBefore(); if (!empty($this->formAttr['inputContainerTag'])) { echo '<span class="' . implode(' ', $this->formAttr['inputContainerClasses']) . '">'; } } /** * function called between label and input container * used on extended classes * * @return void */ protected function htmlInputContBefore() { } /** * function calle after input container * used on extended classes * * @return void */ protected function htmlInputContAfter() { } /** * input item after (close wrapper) * * @return void */ protected function htmlItemAfter() { if (!empty($this->formAttr['inputContainerTag'])) { echo '</span>'; } $this->htmlInputContAfter(); if (!empty($this->formAttr['wrapperTag'])) { if (!empty($this->formAttr['wrapperContainerTag'])) { echo '</' . $this->formAttr['wrapperContainerTag'] . '>'; } echo $this->getSubNote(); echo '</' . $this->formAttr['wrapperTag'] . '>'; } else { echo $this->getSubNote(); } } /** * * @return string */ protected function getSubNote() { if (is_callable($this->formAttr['subNote'])) { $subNote = call_user_func($this->formAttr['subNote'], $this); } else { $subNote = $this->formAttr['subNote']; } return empty($subNote) ? '' : '<div class="sub-note" >' . $subNote . '</div>'; } /** * Return postfix element data * * @param array $data postix element data * * @return array */ protected function prefixPostfixElem($data) { $default = array( 'type' => 'none', 'label' => null, 'id' => null, 'btnAction' => null, 'attrs' => array() ); if (is_callable($data)) { $element = call_user_func($data, $this); } else { $element = $data; } if (is_array($element)) { return array_merge($default, $element); } else { return $default; } } /** * Return prefix element data * * @return array */ protected function getPrefix() { return $this->prefixPostfixElem($this->formAttr['prefix']); } /** * Return postifx element data * * @return array */ protected function getPostfix() { return $this->prefixPostfixElem($this->formAttr['postfix']); } /** * html if type is hidden * * @return void */ protected function hiddenHtml() { $attrs = array( 'id' => $this->formAttr['id'], 'name' => $this->getAttrName(), 'value' => $this->getInputValue() ); if ($this->isDisabled()) { $attrs['disabled'] = 'disabled'; } if (!empty($this->formAttr['classes'])) { $attrs['class'] = implode(' ', $this->formAttr['classes']); } $attrs = array_merge($attrs, $this->formAttr['attr']); ?> <input type="hidden" <?php echo \DUPX_U_Html::arrayAttrToHtml($attrs); ?> > <?php } /** * HTML if type is input (text/number) * * @param string $type input type * * @return void */ protected function inputHtml($type) { $attrs = array( 'type' => $type, 'id' => $this->formAttr['id'], 'name' => $this->getAttrName(), 'value' => $this->getInputValue() ); if ($this->isDisabled()) { $attrs['disabled'] = 'disabled'; } if ($this->isReadonly()) { $attrs['readonly'] = 'readonly'; } if (!is_null($this->formAttr['maxLength'])) { $attrs['maxLength'] = $this->formAttr['maxLength']; } if (!is_null($this->formAttr['size'])) { $attrs['size'] = $this->formAttr['size']; } if (isset($this->formAttr['min']) && !is_null($this->formAttr['min'])) { $attrs['min'] = $this->formAttr['min']; } if (isset($this->formAttr['max']) && !is_null($this->formAttr['max'])) { $attrs['max'] = $this->formAttr['max']; } if (isset($this->formAttr['step']) && !is_null($this->formAttr['step'])) { $attrs['step'] = $this->formAttr['step']; } if (!empty($this->formAttr['classes'])) { $attrs['class'] = implode(' ', $this->formAttr['classes']); } $prefixHtml = self::getPrefixPostfixHtml($this->getPrefix(), 'prefix'); $postfixHtml = self::getPrefixPostfixHtml($this->getPostfix(), 'postfix'); $isPrePostFix = (strlen($prefixHtml) > 0 || strlen($postfixHtml) > 0); $attrs = array_merge($attrs, $this->formAttr['attr']); if ($isPrePostFix) { ?> <span class="input-postfix-btn-group"> <?php } echo $prefixHtml; ?> <input <?php echo \DUPX_U_Html::arrayAttrToHtml($attrs); ?> > <?php echo $postfixHtml; if ($isPrePostFix) { ?> </span> <?php } } /** * Get pre-post fix element html * * @param array $element element data * @param string $class element class * * @return string */ protected static function getPrefixPostfixHtml($element, $class) { if ($element['type'] == 'none') { return ''; } $attrs = array('class' => $class); switch ($element['type']) { case 'button': $tag = 'button'; $attrs['type'] = 'button'; if (!empty($element['btnAction'])) { $attrs['onclick'] = $element['btnAction']; } break; case 'label': default: $tag = 'span'; break; } if (!empty($element['id'])) { $attrs['id'] = $element['id']; } $attrs = array_merge($attrs, $element['attrs']); return '<' . $tag . ' ' . \DUPX_U_Html::arrayAttrToHtml($attrs) . '>' . $element['label'] . '</' . $tag . '>'; } /** * HTML if type is select * * @return void */ protected function selectHtml() { $attrs = array( 'id' => $this->formAttr['id'], 'name' => $this->getAttrName() . ($this->formAttr['multiple'] ? '[]' : ''), ); if (!empty($this->formAttr['classes'])) { $attrs['class'] = implode(' ', $this->formAttr['classes']); } if ($this->isDisabled()) { $attrs['disabled'] = 'disabled'; } if ($this->isReadonly()) { $attrs['readonly'] = 'readonly'; } if ($this->formAttr['multiple']) { $attrs['multiple'] = ''; } $attrs['size'] = $this->formAttr['size'] == 0 ? count($this->getOptions()) : $this->formAttr['size']; $attrs = array_merge($attrs, $this->formAttr['attr']); ?> <select <?php echo \DUPX_U_Html::arrayAttrToHtml($attrs); ?> > <?php self::renderSelectOptions($this->getOptions(), $this->getInputValue()); ?> </select> <?php } /** * Render select options * * @param ParamOption[] $options options list * @param mixed $inputValue selected values * * @return void */ protected static function renderSelectOptions($options, $inputValue) { $lastOptGroup = ''; $autoSelectFirst = (count($options) == 1); foreach ($options as $option) { if ($option->isHidden()) { continue; } if ($lastOptGroup !== $option->getOptGroup()) { if (strlen($lastOptGroup) > 0) { ?></optgroup><?php } if (strlen($option->getOptGroup()) > 0) { ?><optgroup label="<?php echo DUPX_U::esc_attr($option->getOptGroup()); ?>"><?php } $lastOptGroup = $option->getOptGroup(); } $optAttr = array( 'value' => $option->value ); if ($option->isDisabled()) { $optAttr['disabled'] = 'disabled'; } elseif ( self::isValueInValue($option->value, $inputValue) || $autoSelectFirst ) { // can't be selected if is disabled $optAttr['selected'] = 'selected'; } $optAttr = array_merge($optAttr, (array) $option->attrs); ?> <option <?php echo \DUPX_U_Html::arrayAttrToHtml($optAttr); ?> > <?php echo $option->label; ?> </option> <?php } if (strlen($lastOptGroup) > 0) { ?></optgroup><?php } } /** * Render checkbox element * * @param bool $switch if true render switch else input checkbox * * @return void */ protected function checkBoxHtml($switch) { $attrs = array( 'id' => $this->formAttr['id'], 'name' => $this->getAttrName(), 'value' => $this->formAttr['checkedValue'] ); if (!empty($this->formAttr['classes'])) { $attrs['class'] = implode(' ', $this->formAttr['classes']); } if ($this->isDisabled()) { $attrs['disabled'] = 'disabled'; } if ($this->isReadonly()) { $attrs['readonly'] = 'readonly'; } if (self::isValueInValue($this->formAttr['checkedValue'], $this->getInputValue())) { $attrs['checked'] = 'checked'; } $attrs = array_merge($attrs, $this->formAttr['attr']); $hiddenAttrs = array( 'name' => $this->getAttrHiddenName(), 'value' => true ); if ($switch) { \DUPX_U_Html::checkboxSwitch($attrs); } else { ?> <input type="checkbox" <?php echo \DUPX_U_Html::arrayAttrToHtml($attrs); ?> > <?php } ?> <span class="label-checkbox" ><?php echo $this->formAttr['checkboxLabel']; ?></span> <input type="hidden" <?php echo \DUPX_U_Html::arrayAttrToHtml($hiddenAttrs); ?> > <?php } /** * html if type is multiple checkboxes * * @return void */ protected function mCheckBoxHtml() { /* * for radio don't use global attr but option attr * $attrs = array_merge($attrs, $this->formAttr['attr']); */ foreach ($this->getOptions() as $index => $option) { $attrs = array( 'id' => $this->formAttr['id'] . '_' . $index, 'name' => $this->getAttrName() . '[]', 'value' => $option->value ); if (!empty($this->formAttr['classes'])) { $attrs['class'] = implode(' ', $this->formAttr['classes']); } if (self::isValueInValue($option->value, $this->getInputValue())) { $attrs['checked'] = 'checked'; } if ($this->isReadonly()) { $attrs['readonly'] = 'readonly'; } if ($this->isDisabled() || $option->isDisabled()) { $attrs['disabled'] = 'disabled'; } $attrs = array_merge($attrs, $option->attrs); if (!empty($attrs['title'])) { $labelTtile = ' title="' . \DUPX_U::esc_attr($attrs['title']) . '"'; unset($attrs['title']); } else { $labelTtile = ''; } ?> <label class="option-group" <?php echo $labelTtile; ?>> <input type="checkbox" <?php echo \DUPX_U_Html::arrayAttrToHtml($attrs); ?> > <span class="label-checkbox" > <?php echo $option->label; ?> </span> </label> <?php } } /** * html if type is radio * * @return void */ protected function radioHtml() { /* * for radio don't use global attr but option attr * $attrs = array_merge($attrs, $this->formAttr['attr']); */ foreach ($this->getOptions() as $index => $option) { if ($option->isHidden()) { continue; } $attrs = array( 'id' => $this->formAttr['id'] . '_' . $index, 'name' => $this->getAttrName(), 'value' => $option->value ); $optionGroupClasses = 'option-group'; if (!empty($this->formAttr['classes'])) { $attrs['class'] = implode(' ', $this->formAttr['classes']); } if (self::isValueInValue($option->value, $this->getInputValue())) { $attrs['checked'] = 'checked'; } if ($this->isReadonly()) { $attrs['readonly'] = 'readonly'; } if ($this->isDisabled() || $option->isDisabled()) { $attrs['disabled'] = 'disabled'; } if ($option->isDisabled()) { $optionGroupClasses .= ' option-disabled'; } $attrs = array_merge($attrs, $option->attrs); if (!empty($attrs['title'])) { $labelTtile = ' title="' . \DUPX_U::esc_attr($attrs['title']) . '"'; unset($attrs['title']); } else { $labelTtile = ''; } ?> <label class="<?php echo $optionGroupClasses; ?>" <?php echo $labelTtile; ?>> <input type="radio" <?php echo \DUPX_U_Html::arrayAttrToHtml($attrs); ?> > <span class="label-checkbox" > <?php echo $option->label; ?> </span> <?php echo $option->getNote(); ?> </label> <?php } } /** * html if type is button * * @return void */ protected function bgroupHtml() { /* * for radio don't use global attr but option attr * $attrs = array_merge($attrs, $this->formAttr['attr']); */ $this->hiddenHtml(); foreach ($this->getOptions() as $index => $option) { if ($option->isHidden()) { continue; } $attrs = array( 'id' => $this->formAttr['id'] . '_' . $index, 'value' => $option->value, 'class' => $this->formAttr['id'] . '_button ' . implode(' ', $this->formAttr['classes']) ); if (self::isValueInValue($option->value, $this->getInputValue())) { $attrs['class'] .= ' active'; } if ($this->isReadonly()) { $attrs['readonly'] = 'readonly'; } if ($this->isDisabled() || $option->isDisabled()) { $attrs['disabled'] = 'disabled'; } $attrs = array_merge($attrs, $option->attrs); if (!empty($attrs['title'])) { $labelTtile = ' title="' . \DUPX_U::esc_attr($attrs['title']) . '"'; unset($attrs['title']); } else { $labelTtile = ''; } ?> <button type="button" <?php echo \DUPX_U_Html::arrayAttrToHtml($attrs); ?>> <?php echo $option->label; ?> </button> <?php } } /** * get current label html * * @param bool $echo if true echo HTML * * @return string */ protected function getLabelHtml($echo = true) { if ($this->formAttr['renderLabel'] == false) { return ''; } $attrs = array(); if (!empty($this->formAttr['labelClasses'])) { $attrs['class'] = implode(' ', $this->formAttr['labelClasses']); } ob_start(); ?> <span <?php echo \DUPX_U_Html::arrayAttrToHtml($attrs); ?> > <?php echo (strlen($this->formAttr['label']) == 0 ? ' ' : \DUPX_U::esc_html($this->formAttr['label'])); if (strlen($this->formAttr['inlineHelp']) > 0) { $helpTitle = (strlen($this->formAttr['inlineHelpTitle']) ? $this->formAttr['inlineHelpTitle'] : rtrim($this->formAttr['label'], ':')); ?> <i class="fas fa-question-circle fa-sm param-inline-help-icon" data-tooltip-title="<?php echo DUPX_U::esc_attr($helpTitle);?>" data-tooltip="<?php echo DUPX_U::esc_attr($this->formAttr['inlineHelp']); ?>" ></i> <?php } if (strlen($this->formAttr['proFlag']) > 0) { $flagTitle = (strlen($this->formAttr['proFlagTitle']) ? $this->formAttr['proFlagTitle'] : rtrim($this->formAttr['label'], ':')); ?><sup class="pro-flag" data-tooltip-title="<?php echo DUPX_U::esc_attr($flagTitle);?>" data-tooltip="<?php echo DUPX_U::esc_attr($this->formAttr['proFlag'] . Upsell::getCampaignTooltipHTML(array('utm_medium' => 'installer', 'utm_content' => 'option_' . $this->name))); ?>" >*</sup> <?php } ?> </span> <?php if ($echo) { ob_end_flush(); return ''; } else { return ob_get_clean(); } } /** * Set value from array. This function is used to set data from json array * * @param array $data form data * * @return boolean */ public function fromArrayData($data) { $result = parent::fromArrayData($data); if (isset($data['formStatus'])) { $this->formAttr['status'] = $data['formStatus']; } return $result; } /** * return array dato to store in json array data * * @return array */ public function toArrayData() { $result = parent::toArrayData(); if (!is_callable($this->formAttr['status'])) { $result['formStatus'] = $this->getFormStatus(); } return $result; } /** * update the value from input if exists ot set the default * sanitation and validation are performed * skip set value if current status is disabled, info only or skip * * @param string $method query string method (POST, GET) * * @return boolean false if value isn't validated */ public function setValueFromInput($method = self::INPUT_POST) { // if input is disabled don't reads from input. if ( $this->getFormStatus() == self::STATUS_INFO_ONLY || $this->getFormStatus() == self::STATUS_SKIP ) { return true; } // prevent overwrite by default if item is disable and isn't enable in client by js $superObject = self::getSuperObjectByMethod($method); if ($this->getFormStatus() == self::STATUS_DISABLED && !$this->isValueInInput($superObject)) { return true; } // prevent overwrite by default if checkbox isn't in form if (($this->formType === self::FORM_TYPE_CHECKBOX || $this->formType === self::FORM_TYPE_SWITCH) && !isset($superObject[$this->getAttrName()])) { if (!isset($superObject[$this->getAttrHiddenName()]) || !$superObject[$this->getAttrHiddenName()]) { return true; } } elseif (!isset($superObject[$this->name])) { return true; } return parent::setValueFromInput($method); } /** * this function return the default formAttr for each type. * in the constructor an array merge is made between the result of this function and the parameters passed. * In this way the values in $ this -> ['attr'] are always consistent. * * @param string $formType form type * * @return array */ protected static function getDefaultAttrForFormType($formType) { $attrs = array( 'label' => null, // input main label, 'renderLabel' => true, // if false don\'t render label 'labelClasses' => array('label', 'main-label'), // label classes (the label html is <span class="classes" >label</span> 'id' => null, // input id , if null the default is 'param_item_'.$name 'classes' => array('input-item'), // input classes 'status' => self::STATUS_ENABLED, // form status 'title' => null, // input title 'attr' => array(), // custom input attributes key="VALUE" 'inlineHelpTitle' => '', 'inlineHelp' => '', 'proFlagTitle' => '', 'proFlag' => '', 'subNote' => null, // sub note container (html string), 'wrapperTag' => 'div', // if null the input haven't the wrapper tag. // input tag wrapper, wrapper html is // ~ <TAG class="classes" ><CONTAINER><LABEL><INPUT CONTAINER></CONTAINER></TAG> 'wrapperId' => null, // input wrapper id, if null the default is 'wrapper_item_'.$name 'wrapperClasses' => array(// wrapper classes, param-wrapper generic class plus 'param-form-type-'.$formType type class 'param-wrapper', 'param-form-type-' . $formType), 'wrapperAttr' => array(), // custom wrapper attributes key="VALUE" 'wrapperContainerTag' => 'label', 'inputContainerTag' => 'span', 'inputContainerClasses' => array('input-container'), ); switch ($formType) { case self::FORM_TYPE_HIDDEN: $attrs['wrapperTag'] = null; // disable wrapper for hidden inputs $attrs['wrapperContainerTag'] = null; $attrs['inputContainerTag'] = null; break; case self::FORM_TYPE_NUMBER: $attrs['min'] = null; // attr min $attrs['max'] = null; // attr max $attrs['step'] = null; // attr step // continue form type text case self::FORM_TYPE_TEXT: $attrs['maxLength'] = null; // if null have no limit $attrs['size'] = null; $attrs['prefix'] = array( 'type' => 'none', // none | button | label 'label' => null, 'id' => null, 'btnAction' => null, 'attrs' => array() ); $attrs['postfix'] = array( 'type' => 'none', // none | button | label 'label' => null, 'id' => null, 'btnAction' => null, 'attrs' => array() ); break; case self::FORM_TYPE_SELECT: $attrs['classes'][] = 'js-select'; $attrs['multiple'] = false; $attrs['options'] = array(); // ParamOption[] | callback $attrs['size'] = 1; // select size if 0 get num options break; case self::FORM_TYPE_CHECKBOX: case self::FORM_TYPE_SWITCH: $attrs['checkboxLabel'] = null; $attrs['checkedValue'] = true; break; case self::FORM_TYPE_M_CHECKBOX: $attrs['options'] = array(); // ParamOption[] | callback $attrs['wrapperContainerTag'] = 'div'; break; case self::FORM_TYPE_RADIO: $attrs['options'] = array(); // ParamOption[] | callback $attrs['wrapperContainerTag'] = 'div'; break; case self::FORM_TYPE_BGROUP: $attrs['options'] = array(); // ParamOption[] | callback $attrs['wrapperContainerTag'] = 'span'; $attrs['inputContainerClasses'] = array('input-container', 'btn-group'); break; default: // accepts unknown values because this class can be extended } return $attrs; } } PK w <\�9��N N Items/ParamFormUsersReset.phpnu &1i� <?php /** * param descriptor * * Standard: PSR-2 * * @link http://www.php-fig.org/psr/psr-2 Full Documentation * * @package SC\DUPX\U */ namespace Duplicator\Installer\Core\Params\Items; use Duplicator\Installer\Core\Params\PrmMng; use Duplicator\Installer\Core\Params\Descriptors\ParamDescUsers; /** * this class manages a password type input with the hide / show passwrd button */ class ParamFormUsersReset extends ParamFormPass { const FORM_TYPE_USERS_PWD_RESET = 'usrpwdreset'; protected $currentUserId = -1; /** * Get html form option of current item * * @param bool $echo if true echo html * * @return string */ public function getHtml($echo = true) { if ($this->formType == self::FORM_TYPE_USERS_PWD_RESET) { $result = ''; $users = \DUPX_ArchiveConfig::getInstance()->getUsersLists(); $mainInputId = $this->formAttr['id']; foreach ($users as $userId => $login) { $this->currentUserId = $userId; $this->formAttr['id'] = $mainInputId . '_' . $this->currentUserId; $this->formAttr['label'] = $login; $result .= parent::getHtml($echo); } $this->currentUserId = -1; $this->formAttr['id'] = $mainInputId; return $result; } else { return parent::getHtml($echo); } } /** * Display the html input of current item * * @return void */ protected function htmlItem() { if ($this->formType == self::FORM_TYPE_USERS_PWD_RESET) { $this->pwdToggleHtml(); } else { parent::htmlItem(); } } /** * Return attribute name * * @return string */ protected function getAttrName() { return $this->name . '[' . $this->currentUserId . ']'; } /** * Return input value * * @return mixed */ protected function getInputValue() { return isset($this->value[$this->currentUserId]) ? $this->value[$this->currentUserId] : ''; } /** * Get default form attributes * * @param string $formType form type * * @return array */ protected static function getDefaultAttrForFormType($formType) { $attrs = parent::getDefaultAttrForFormType($formType); if ($formType == self::FORM_TYPE_USERS_PWD_RESET) { $attrs['maxLength'] = null; // if null have no limit $attrs['size'] = null; } return $attrs; } } PK w <\��� � Items/ParamOption.phpnu &1i� <?php /** * option descriptor for select, radio, multiple checkbox ... * * Standard: PSR-2 * * @link http://www.php-fig.org/psr/psr-2 Full Documentation * * @package SC\DUPX\U */ namespace Duplicator\Installer\Core\Params\Items; /** * this class describes the options for select, radio and multiple checboxes */ class ParamOption { const OPT_ENABLED = 'enabled'; const OPT_DISABLED = 'disabled'; const OPT_HIDDEN = 'hidden'; public $value = ''; public $label = ''; public $attrs = array(); protected $optStatus = self::OPT_ENABLED; protected $note = ''; protected $groupLabel = ''; /** * Class constructor * * @param mixed $value option value * @param string $label label * @param string|function $optStatus option status. can be a fixed status or a callback * @param array $attrs option attributes */ public function __construct($value, $label, $optStatus = self::OPT_ENABLED, $attrs = array()) { $this->value = $value; $this->label = $label; $this->optStatus = $optStatus; $this->attrs = (array) $attrs; } /** * get current statis. * * @return string */ public function getStatus() { if (is_callable($this->optStatus)) { return call_user_func($this->optStatus, $this); } else { return $this->optStatus; } } /** * Set options status * * @param string|callable $optStatus option status. can be a fixed status or a callback * * @return void */ public function setStatus($optStatus) { $this->optStatus = $optStatus; } /** * Set option note * * @param string|callable $note option note * * @return void */ public function setNote($note) { $this->note = is_callable($note) ? $note : ((string) $note); } /** * * @return string */ public function getNote() { $note = ''; if (is_callable($this->note)) { $note = call_user_func($this->note, $this); } else { $note = $this->note; } return (empty($note) ? '' : '<div class="sub-note" >' . $note . '</div>'); } /** * Set option group, used on select * * @param string $label optiongroup label is empty reset option * * @return void */ public function setOptGroup($label) { $this->groupLabel = (string) $label; } /** * Return option group label, empty if not set * * @return string */ public function getOptGroup() { return $this->groupLabel; } /** * * @return bool */ public function isEnable() { return $this->getStatus() == self::OPT_ENABLED; } /** * * @return bool */ public function isDisabled() { return $this->getStatus() == self::OPT_DISABLED; } /** * * @return bool */ public function isHidden() { return $this->getStatus() == self::OPT_HIDDEN; } } PK w <\لO�, �, Items/ParamFormPlugins.phpnu &1i� <?php /** * param descriptor * * Standard: PSR-2 * * @link http://www.php-fig.org/psr/psr-2 Full Documentation * * @package SC\DUPX\U */ namespace Duplicator\Installer\Core\Params\Items; use Duplicator\Installer\Core\Params\PrmMng; use Duplicator\Libs\Snap\SnapJson; /** * this class handles the entire block selection block. */ class ParamFormPlugins extends ParamForm { const FORM_TYPE_PLUGINS_SELECT = 'pluginssel'; /** * Render HTML * * @return void */ protected function htmlItem() { if ($this->formType == self::FORM_TYPE_PLUGINS_SELECT) { $this->pluginSelectHtml(); } else { parent::htmlItem(); } } /** * Render plugin selector HTML * * @return void */ protected function pluginSelectHtml() { $pluginsManager = \DUPX_Plugins_Manager::getInstance(); $plugns_list = $pluginsManager->getPlugins(); $attrs = array( 'id' => $this->formAttr['id'], 'name' => $this->getAttrName() . '[]', 'multiple' => '' ); $this->formAttr['classes'][] = 'no-display'; if (!empty($this->formAttr['classes'])) { $attrs['class'] = implode(' ', array_unique($this->formAttr['classes'])); } if ($this->isDisabled()) { $attrs['disabled'] = 'disabled'; } if ($this->isReadonly()) { $attrs['readonly'] = 'readonly'; } $attrs = array_merge($attrs, $this->formAttr['attr']); ?> <select <?php echo \DUPX_U_Html::arrayAttrToHtml($attrs); ?> > <?php foreach ($plugns_list as $pluginSlug => $plugin) { if ($plugin->isIgnore() || $plugin->isForceDisabled()) { continue; } $optAttr = array( 'value' => $pluginSlug ); if (self::isValueInValue($pluginSlug, $this->getInputValue())) { // can't be selected if is disabled $optAttr['selected'] = 'selected'; } ?> <option <?php echo \DUPX_U_Html::arrayAttrToHtml($optAttr); ?> > <?php echo \DUPX_U::esc_html($plugin->name); ?> </option> <?php } ?> </select> <?php echo $this->getSubNote(); $this->pluginsSelector(); } /** * Render plugin selector * * @return void */ protected function pluginsSelector() { $pluginsManager = \DUPX_Plugins_Manager::getInstance(); $plugns_list = $pluginsManager->getPlugins(); $paramsManager = PrmMng::getInstance(); $safe_mode = $paramsManager->getValue(PrmMng::PARAM_SAFE_MODE); ?> <div> <?php if (!$this->isDisabled()) { ?> <?php if ($safe_mode > 0) { echo '<div class="s3-warn">' . '<i class="fas fa-exclamation-triangle"></i> Safe Mode Enabled: <i>Only Duplicator will be enabled during install.</i>' . '</div>'; } ?> <div class="s3-allnonelinks" style="<?php echo ($safe_mode > 0) ? 'display:none' : ''; ?>"> <button type="button" id="select-all-plugins" class="no-layout">[All]</button> <button type="button" id="unselect-all-plugins" class="no-layout">[None]</button> </div><br style="clear:both" /> <?php } ?> </div> <ul id="plugins-filters" > <li class="all" data-filter-target="all" > <a href="#" class="current"> All <span class="count">(<?php echo count($plugns_list); ?>)</span> </a> </li> <?php foreach ($pluginsManager->getStatusCounts() as $status => $count) { if ($count) { ?> <li class="<?php echo \DUPX_U::esc_attr($status); ?>" data-filter-target="orig-<?php echo \DUPX_U::esc_attr($status); ?>" > <a href="#"> <?php echo \DUPX_U::esc_html(\DUPX_Plugin_item::getStatusLabel($status)); ?><span class="count"> (<?php echo $count; ?>)</span> </a> </li> <?php } } ?> </ul> <table id="plugins_list_table_selector" class="list_table_selector<?php echo ($safe_mode > 0) ? ' disabled' : ''; ?>" > <thead> <tr> <th class="check_input" ></th> <th class="name" >Name</th> <th class="info" >Details</th> <th class="orig_status" >Original<br>Status</th> </tr> </thead> <tbody> <?php foreach ($plugns_list as $pluginObj) { if ($pluginObj->isIgnore() || $pluginObj->isForceDisabled()) { continue; } $this->pluginHtmlItem($pluginObj); } ?> </tbody> </table> <?php $this->pluginTableSelectorJs(); } /** * Render plugin item * * @param \DUPX_Plugin_item $pluginObj plugin object * @param int $subsiteId selected subsite id * * @return void */ protected function pluginHtmlItem($pluginObj, $subsiteId = -1) { $itemClasses = array( 'table-item', ); $orgiStats = $pluginObj->getOrgiStatus($subsiteId); $itemClasses[] = 'orig-' . $orgiStats; $itemClasses[] = self::isValueInValue($pluginObj->slug, $this->getInputValue()) ? 'active' : 'inactive'; //$authorURI = $pluginObj->authorURI; if (empty($pluginObj->authorURI)) { $author = \DUPX_U::esc_html($pluginObj->author); } else { $author = '<a href="' . \DUPX_U::esc_attr($pluginObj->authorURI) . '" target="_blank">' . \DUPX_U::esc_html($pluginObj->author) . '</a>'; } ?> <tr class="<?php echo implode(' ', $itemClasses); ?>" data-plugin-slug="<?php echo \DUPX_U::esc_attr($pluginObj->slug); ?>"> <td class="check_input" > <input type="checkbox" <?php echo $this->isReadonly() ? 'readonly' : ''; ?> <?php echo $this->isDisabled() ? 'disabled' : ''; ?>> </td> <td class="name" ><?php echo \DUPX_U::esc_html($pluginObj->name); ?></td> <td class="info" > Version: <?php echo \DUPX_U::esc_html($pluginObj->version); ?><br> URL: <a href="<?php echo \DUPX_U::esc_attr($pluginObj->pluginURI); ?>" target="_blank" class="plugin-link" > <?php echo \DUPX_U::esc_html($pluginObj->pluginURI); ?> </a><br/> Author: <?php echo $author; ?><br> </td> <td class="orig_status" ><?php echo \DUPX_U::esc_html($pluginObj->getStatusLabel($orgiStats)); ?></td> </tr> <?php } /** * Render javascript * * @return void */ protected function pluginTableSelectorJs() { ?> <script> (function ($) { var pluginsWrapper = $('#' + <?php echo SnapJson::jsonEncode($this->formAttr['wrapperId']); ?>); var pluginsSelect = $('#' + <?php echo SnapJson::jsonEncode($this->formAttr['id']); ?>); var tableSelect = $('#plugins_list_table_selector'); var pluginsSelectIsDisabled = pluginsWrapper.hasClass('param-wrapper-disabled'); function setItemTable(item, enable) { if (enable) { item.removeClass('inactive').addClass('active'); item.find('.check_input input').prop('checked', true); pluginsSelect.find('option[value="' + item.data('plugin-slug') + '"]').prop('selected', true); } else { item.removeClass('active').addClass('inactive'); item.find('.check_input input').prop('checked', false); pluginsSelect.find('option[value="' + item.data('plugin-slug') + '"]').prop('selected', false); } } // prevent select on unselect on external link click tableSelect.find('.table-item a').click(function (event) { event.stopPropagation(); return true; }); tableSelect.find('.table-item').each(function () { var current = $(this); // init select element if (current.hasClass('active')) { setItemTable(current, true); } else { setItemTable(current, false); } // change on click current.click(function () { if (pluginsSelectIsDisabled) { return; } if (current.hasClass('active')) { setItemTable(current, false); } else { setItemTable(current, true); } }); }); $('#select-all-plugins').click(function () { tableSelect.find('.table-item').each(function () { setItemTable($(this), true); }); }); $('#unselect-all-plugins').click(function () { tableSelect.find('.table-item').each(function () { setItemTable($(this), false); }); }); $('#plugins-filters a').click(function () { var obj = $(this); if (obj.hasClass('current')) { return false; } $('#plugins-filters a').removeClass('current'); obj.addClass('current'); var filterTarget = obj.parent().data('filter-target'); if (filterTarget === 'all') { tableSelect.find('.table-item').removeClass('no-display'); } else { tableSelect.find('.table-item').removeClass('no-display').not('.' + filterTarget).addClass('no-display'); } return false; }); })(jQuery); </script> <?php } /** * Return default form attribute * * @param string $formType form type * * @return array */ protected static function getDefaultAttrForFormType($formType) { $attrs = parent::getDefaultAttrForFormType($formType); if ($formType == self::FORM_TYPE_PLUGINS_SELECT) { $attrs['wrapperContainerTag'] = 'div'; $attrs['inputContainerTag'] = 'div'; } return $attrs; } }PK w <\B�9 �T �T Items/ParamItem.phpnu &1i� <?php /** * param descriptor * * Standard: PSR-2 * * @link http://www.php-fig.org/psr/psr-2 Full Documentation * * @package SC\DUPX\U */ namespace Duplicator\Installer\Core\Params\Items; use Duplicator\Installer\Utils\Log\Log; /** * this class describes the value of a parameter. * therefore the type of data is sanitization and validation. * In addition to other features such as, for example, if it is a persistent parameter. */ class ParamItem { const INPUT_GET = 'g'; const INPUT_POST = 'p'; const INPUT_REQUEST = 'r'; const INPUT_COOKIE = 'c'; const INPUT_SERVER = 's'; const INPUT_ENV = 'e'; const TYPE_STRING = 'str'; const TYPE_ARRAY_STRING = 'arr_str'; const TYPE_ARRAY_MIXED = 'arr_mix'; const TYPE_INT = 'int'; const TYPE_ARRAY_INT = 'arr_int'; const TYPE_BOOL = 'bool'; const STATUS_INIT = 'init'; const STATUS_OVERWRITE = 'owr'; const STATUS_UPD_FROM_INPUT = 'updinp'; /** * validate regexes for test input */ const VALIDATE_REGEX_INT_NUMBER = '/^[\+\-]?[0-9]+$/'; const VALIDATE_REGEX_INT_NUMBER_EMPTY = '/^[\+\-]?[0-9]*$/'; // can be empty const VALIDATE_REGEX_AZ_NUMBER = '/^[A-Za-z0-9]+$/'; const VALIDATE_REGEX_AZ_NUMBER_EMPTY = '/^[A-Za-z0-9]*$/'; // can be empty const VALIDATE_REGEX_AZ_NUMBER_SEP = '/^[A-Za-z0-9_\-]+$/'; // laddate Az 09 plus - and _ const VALIDATE_REGEX_AZ_NUMBER_SEP_EMPTY = '/^[A-Za-z0-9_\-]*$/'; // laddate Az 09 plus - and _, can be empty const VALIDATE_REGEX_DIR_PATH = '/^([a-zA-Z]:[\\\\\/]|\/|\\\\\\\\|\/\/)[^<>\0]+$/'; const VALIDATE_REGEX_FILE_PATH = '/^([a-zA-Z]:[\\\\\/]|\/|\\\\\\\\|\/\/)[^<>\0]+$/'; protected $name = null; protected $type = null; protected $attr = array(); protected $value = null; protected $status = self::STATUS_INIT; /** * Class constructor * * @param string $name param identifier * @param string $type TYPE_STRING | TYPE_ARRAY_STRING | ... * @param array $attr list of attributes */ public function __construct($name, $type, $attr = null) { if (empty($name) || strlen($name) < 4) { throw new \Exception('the name can\'t be empty or len can\'t be minor of 4'); } $this->type = $type; $this->attr = array_merge(static::getDefaultAttrForType($type), (array) $attr); if ($type == self::TYPE_ARRAY_STRING || $type == self::TYPE_ARRAY_INT || $type == self::TYPE_ARRAY_MIXED) { $this->attr['default'] = (array) $this->attr['default']; } $this->name = $name; $this->value = $this->getSanitizeValue($this->attr['default']); if (is_null($this->attr['defaultFromInput'])) { $this->attr['defaultFromInput'] = $this->attr['default']; } else { if ($type == self::TYPE_ARRAY_STRING || $type == self::TYPE_ARRAY_INT || $type == self::TYPE_ARRAY_MIXED) { $this->attr['defaultFromInput'] = (array) $this->attr['defaultFromInput']; } } } /** * this funtion return the discursive label * * @return string */ public function getLabel() { return $this->name; } /** * get current item identifier * * @return string */ public function getName() { return $this->name; } /** * get current item value * * @return mixed */ public function getValue() { return $this->value; } /** * * @return string // STATUS_INIT | STATUS_OVERWRITE | STATUS_UPD_FROM_INPUT */ public function getStatus() { return $this->status; } /** * Set item status with overwrite value * * @return void */ public function setOveriteStatus() { $this->status = self::STATUS_OVERWRITE; } /** * if it is true, this object is defined as persistent and will be saved in the parameter persistence file otherwise the param manager * will not save this value and at each call of the script the parameter will assume the default value. * * @return bool */ public function isPersistent() { return $this->attr['persistence']; } /** * return the invalid param message or empty string * * @return string */ public function getInvalidMessage() { if (is_callable($this->attr['invalidMessage'])) { return call_user_func($this->attr['invalidMessage'], $this); } else { return (string) $this->attr['invalidMessage']; } } /** * Set the invalid param message * * @param $message invalid message * * @return string */ public function setInvalidMessage($message) { $this->attr['invalidMessage'] = (string) $message; } /** * Update item attribute * * @param string $key attribute key * @param mixed $value value * * @return void */ public function setAttr($key, $value) { $this->attr[$key] = $value; } /** * Set param value * * @param mixed $value value to set * * @return boolean false if value isn't validated */ public function setValue($value) { $validateValue = null; if (!$this->isValid($value, $validateValue)) { return false; } $this->value = $validateValue; return true; } /** * Get super object from method * * @param string $method query string method * * @return array return the reference */ protected static function getSuperObjectByMethod($method) { $superObject = array(); switch ($method) { case self::INPUT_GET: $superObject = &$_GET; break; case self::INPUT_POST: $superObject = &$_POST; break; case self::INPUT_REQUEST: $superObject = &$_REQUEST; break; case self::INPUT_COOKIE: $superObject = &$_COOKIE; break; case self::INPUT_SERVER: $superObject = &$_SERVER; break; case self::INPUT_ENV: $superObject = &$_ENV; break; default: throw new \Exception('INVALID SUPER OBJECT METHOD ' . Log::v2str($method)); } return $superObject; } /** * Return true if value is in input method * * @param array $superObject query string super object * * @return bool */ protected function isValueInInput($superObject) { return isset($superObject[$this->name]); } /** * update the value from input if exists ot set the default * sanitation and validation are performed * * @param string $method query string method * * @return boolean false if value isn't validated */ public function setValueFromInput($method = self::INPUT_POST) { $superObject = self::getSuperObjectByMethod($method); Log::info( 'SET VALUE FROM INPUT KEY [' . $this->name . '] VALUE[' . Log::v2str(isset($superObject[$this->name]) ? $superObject[$this->name] : '') . ']', Log::LV_DEBUG ); if (!$this->isValueInInput($superObject)) { $inputValue = $this->attr['defaultFromInput']; } else { // get value from input $inputValue = $this->getValueFilter($superObject); // sanitize value $inputValue = $this->getSanitizeValue($inputValue); } if (($result = $this->setValue($inputValue)) === false) { $msg = 'PARAM [' . $this->name . '] ERROR: Invalid value ' . Log::v2str($inputValue); Log::info($msg); return false; } else { $this->status = self::STATUS_UPD_FROM_INPUT; } return $result; } /** * Check if input value is valid * * @param mixed $value input value * @param mixed $validateValue variable passed by reference. Updated to validated value in the case, the value is a valid value. * * @return bool true if is a valid value for this object */ public function isValid($value, &$validateValue = null) { switch ($this->type) { case self::TYPE_STRING: case self::TYPE_BOOL: case self::TYPE_INT: return $this->isValidScalar($value, $validateValue); case self::TYPE_ARRAY_STRING: case self::TYPE_ARRAY_INT: case self::TYPE_ARRAY_MIXED: return $this->isValidArray($value, $validateValue); default: throw new \Exception('ITEM ERROR invalid type ' . $this->type); } } /** * Validate function for scalar value * * @param mixed $value input value * @param mixed $validateValue variable passed by reference. Updated to validated value in the case, the value is a valid value. * * @return boolean false if value isn't a valid value */ protected function isValidScalar($value, &$validateValue = null) { if (!is_null($value) && !is_scalar($value)) { return false; } $result = true; switch ($this->type) { case self::TYPE_STRING: case self::TYPE_ARRAY_STRING: $validateValue = (string) $value; if (strlen($validateValue) < $this->attr['min_len']) { $this->setInvalidMessage('Must have ' . $this->attr['min_len'] . ' or more characters'); $result = false; } if ($this->attr['max_len'] > 0 && strlen($validateValue) > $this->attr['max_len']) { $this->setInvalidMessage('Must have max ' . $this->attr['mimax_lenn_len'] . ' characters'); $result = false; } if (!empty($this->attr['validateRegex']) && preg_match($this->attr['validateRegex'], $validateValue) !== 1) { $this->setInvalidMessage('String isn\'t valid'); $result = false; } break; case self::TYPE_INT: case self::TYPE_ARRAY_INT: $validateValue = filter_var($value, FILTER_VALIDATE_INT, array( 'options' => array( 'default' => false, // value to return if the filter fails 'min_range' => $this->attr['min_range'], 'max_range' => $this->attr['max_range'], ) )); if ($validateValue === false) { $this->setInvalidMessage('Isn\'t a valid number'); $result = false; } break; case self::TYPE_BOOL: $validateValue = is_bool($value) ? $value : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); if (($result = !is_null($validateValue)) === false) { $this->setInvalidMessage('Isn\'t a valid value'); } break; default: throw new \Exception('ITEM ERROR ' . $this->name . ' Invalid type ' . $this->type); } if ($result == true) { $acceptValues = $this->getAcceptValues(); if (empty($acceptValues)) { $result = $this->callValidateCallback($validateValue); } else { if (in_array($validateValue, $acceptValues)) { $result = true; } else { $this->setInvalidMessage('Isn\'t a accepted value'); $result = false; } } } if ($result === false) { $validateValue = null; } return $result; } /** * Validate function for array value * * @param mixed $value input value * @param mixed $validateValue variable passed by reference. Updated to validated value in the case, the value is a valid value. * * @return boolean false if value isn't a valid value */ protected function isValidArray($value, &$validateValue = null) { $newValues = (array) $value; $validateValue = array(); $validValue = null; if ($this->type == self::TYPE_ARRAY_MIXED) { $validateValue = $newValues; return $this->callValidateCallback($newValues); } else { foreach ($newValues as $key => $newValue) { if (!$this->isValidScalar($newValue, $validValue)) { return false; } $validateValue[$key] = $validValue; } } return true; } /** * Call attribute validate callback * * @param mixed $value input value * * @return mixed */ protected function callValidateCallback($value) { if (is_callable($this->attr['validateCallback'])) { return call_user_func($this->attr['validateCallback'], $value, $this); } elseif (!is_null($this->attr['validateCallback'])) { throw new \Exception('PARAM ' . $this->name . ' validateCallback isn\'t null and isn\'t callable'); } else { return true; } } /** * this function is calle before sanitization. * Is use in extendend classs and transform value before the sanitization and validation process * * @param array $superObject query string super object * * @return mixed */ protected function getValueFilter($superObject) { if (isset($superObject[$this->name])) { return $superObject[$this->name]; } else { return null; } } /** * Return sanitized value * * @param mixed $value input value * * @return mixed */ public function getSanitizeValue($value) { switch ($this->type) { case self::TYPE_STRING: case self::TYPE_BOOL: case self::TYPE_INT: return $this->getSanitizeValueScalar($value); case self::TYPE_ARRAY_STRING: case self::TYPE_ARRAY_INT: return $this->getSanitizeValueArray($value); case self::TYPE_ARRAY_MIXED: // global sanitize for mixed return $this->getSanitizeValueScalar($value); default: throw new \Exception('ITEM ERROR invalid type ' . $this->type); } } /** * If sanitizeCallback is apply sanitizeCallback at current value else return value. * * @param mixed $value input value * * @return mixed */ protected function getSanitizeValueScalar($value) { if (is_callable($this->attr['sanitizeCallback'])) { return call_user_func($this->attr['sanitizeCallback'], $value); } elseif (!is_null($this->attr['sanitizeCallback'])) { throw new \Exception('PARAM ' . $this->name . ' sanitizeCallback isn\'t null and isn\'t callable'); } else { return $value; } } /** * If sanitizeCallback is apply sanitizeCallback at each value of array. * * @param mixed $value input value * * @return array */ protected function getSanitizeValueArray($value) { $newValues = (array) $value; $sanitizeValues = array(); foreach ($newValues as $key => $newValue) { $sanitizeValues[$key] = $this->getSanitizeValueScalar($newValue); } return $sanitizeValues; } /** * get accept values * * @return array */ public function getAcceptValues() { if (is_callable($this->attr['acceptValues'])) { return call_user_func($this->attr['acceptValues'], $this); } else { return $this->attr['acceptValues']; } } /** * Set value from array. This function is used to set data from json array * * @param array $data param data * * @return boolean */ public function fromArrayData($data) { $data = (array) $data; if (isset($data['status'])) { $this->status = $data['status']; } // only if value is different from current value if (isset($data['value']) && $data['value'] !== $this->value) { $sanitizedVal = $this->getSanitizeValue($data['value']); return $this->setValue($sanitizedVal); } else { return true; } } /** * return array dato to store in json array data * * @return array */ public function toArrayData() { return array( 'value' => $this->value, 'status' => $this->status ); } /** * Return a copy of this object with a new name ad overwrite attr * * @param string $newName new name * @param array $attr overwrite attributes * * @return self */ public function getCopyWithNewName($newName, $attr = array()) { $copy = clone $this; $reflect = new \ReflectionObject($copy); $nameProp = $reflect->getProperty('name'); $nameProp->setAccessible(true); $nameProp->setValue($copy, $newName); $attrProp = $reflect->getProperty('attr'); $attrProp->setAccessible(true); $newAttr = array_merge($attrProp->getValue($copy), $attr); $attrProp->setValue($copy, $newAttr); $valueProp = $reflect->getProperty('value'); $valueProp->setAccessible(true); $valueProp->setValue($copy, $newAttr['default']); return $copy; } /** * This function return the default attr for each type. * in the constructor an array merge is made between the result of this function and the parameters passed. * In this way the values in $ this -> ['attr'] are always consistent. * * @param string $type param value type * * @return array */ protected static function getDefaultAttrForType($type) { $attrs = array( 'default' => null, // the default value on init 'defaultFromInput' => null, // if value isn't set in query form when setValueFromInput is called set this valus. // (normally defaultFromInput is equal to default) 'acceptValues' => array(), // if not empty accept only values in list | callback 'sanitizeCallback' => null, // function (ParamItem $obj, $inputValue) 'validateCallback' => null, // function (ParamItem $obj, $validateValue, $originalValue) 'persistence' => true, // if false don't store value in persistence file 'invalidMessage' => '' //this message is added at next step validation error message if not empty ); switch ($type) { case self::TYPE_STRING: // value type is a string $attrs['min_len'] = 0; // min string len. used in validation $attrs['max_len'] = 0; // max string len. used in validation $attrs['default'] = ''; // set default at empty string $attrs['validateRegex'] = null; // if isn;t null this regex is called to pass for validation. //Can be combined with validateCallback. If both are active, the validation must pass both. break; case self::TYPE_ARRAY_STRING: // value type is array of string $attrs['min_len'] = 0; // min string len. used in validation $attrs['max_len'] = 0; // max string len. used in validation $attrs['default'] = array(); // set default at empty array $attrs['validateRegex'] = null; // if isn;t null this regex is called to pass for validation. // Can be combined with validateCallback. If both are active, the validation must pass both. break; case self::TYPE_INT: // value type is a int $attrs['min_range'] = PHP_INT_MAX * -1; $attrs['max_range'] = PHP_INT_MAX; $attrs['default'] = 0; // set default at 0 break; case self::TYPE_ARRAY_INT: // value type is an array of int $attrs['min_range'] = PHP_INT_MAX * -1; $attrs['max_range'] = PHP_INT_MAX; $attrs['default'] = array(); // set default at empty array break; case self::TYPE_BOOL: $attrs['default'] = false; // set default fals $attrs['defaultFromInput'] = false; // if value isn't set in input the default must be false for bool values break; case self::TYPE_ARRAY_MIXED: break; default: // accepts unknown values because this class can be extended } return $attrs; } } PK w <\���K K Items/ParamFormPass.phpnu &1i� <?php /** * param descriptor * * Standard: PSR-2 * * @link http://www.php-fig.org/psr/psr-2 Full Documentation * * @package SC\DUPX\U */ namespace Duplicator\Installer\Core\Params\Items; /** * this class manages a password type input with the hide / show password button */ class ParamFormPass extends ParamForm { const FORM_TYPE_PWD_TOGGLE = 'pwdtoggle'; /** * Render HTML * * @return void */ protected function htmlItem() { if ($this->formType == self::FORM_TYPE_PWD_TOGGLE) { $this->pwdToggleHtml(); } else { parent::htmlItem(); } } /** * return the text of current object for info only status * * @return string */ protected function valueToInfo() { return '**********'; } /** * Render PWD toggle element * * @return void */ protected function pwdToggleHtml() { $attrs = array( 'value' => $this->getInputValue(), ); if ($this->isDisabled()) { $attrs['disabled'] = 'disabled'; } if ($this->isReadonly()) { $attrs['readonly'] = 'readonly'; } if (!is_null($this->formAttr['maxLength'])) { $attrs['maxLength'] = $this->formAttr['maxLength']; } if (!is_null($this->formAttr['size'])) { $attrs['size'] = $this->formAttr['size']; } $attrs = array_merge($attrs, $this->formAttr['attr']); \DUPX_U_Html::inputPasswordToggle($this->getAttrName(), $this->formAttr['id'], $this->formAttr['classes'], $attrs, true); } /** * Get default form attributes * * @param string $formType form type * * @return array */ protected static function getDefaultAttrForFormType($formType) { $attrs = parent::getDefaultAttrForFormType($formType); if ($formType == self::FORM_TYPE_PWD_TOGGLE) { $attrs['maxLength'] = null; // if null have no limit $attrs['size'] = null; } return $attrs; } } PK w <\���e e Items/ParamFormWpConfig.phpnu &1i� <?php /** * param descriptor * * Standard: PSR-2 * * @link http://www.php-fig.org/psr/psr-2 Full Documentation * * @package SC\DUPX\U */ namespace Duplicator\Installer\Core\Params\Items; use Duplicator\Installer\Utils\Log\Log; /** * this class manages a password type input with the hide / show passwrd button */ class ParamFormWpConfig extends ParamForm { const IN_WP_CONF_POSTFIX = '_inwpc'; /** * Class constructor * * @param string $name param identifier * @param string $type TYPE_STRING | TYPE_ARRAY_STRING | ... * @param string $formType FORM_TYPE_HIDDEN | FORM_TYPE_TEXT | ... * @param array $attr list of attributes * @param array $formAttr list of form attributes */ public function __construct($name, $type, $formType, $attr = null, $formAttr = array()) { parent::__construct($name, $type, $formType, $attr, $formAttr); $this->attr['defaultFromInput'] = $this->attr['default']; $this->attr['defaultFromInput']['inWpConfig'] = false; if ($type === self::TYPE_BOOL) { $this->attr['defaultFromInput']['value'] = false; } } /** * this function is calle before sanitization. * Is use in extendend classs and transform value before the sanitization and validation process * * @param array $superObject query string super object * * @return mixed */ protected function getValueFilter($superObject) { $result = array( 'value' => parent::getValueFilter($superObject), 'inWpConfig' => filter_var($superObject[$this->name . self::IN_WP_CONF_POSTFIX], FILTER_VALIDATE_BOOLEAN) ); if (!parent::isValueInInput($superObject)) { $result['value'] = $this->attr['defaultFromInput']['value']; } return $result; } /** * Return sanitized value * * @param mixed $value input value * * @return mixed */ public function getSanitizeValue($value) { $result = (array) $value; $result['value'] = parent::getSanitizeValue($result['value']); return $result; } /** * Get value info from value * * @return string */ protected function valueToInfo() { if ($this->value['inWpConfig']) { return 'Set in wp config with value ' . parent::valueToInfo(); } else { return 'Not set in wp config'; } } /** * Return input value * * @return mixed */ protected function getInputValue() { return $this->value['value']; } /** * Return true if value is in input method * * @param array $superObject query string super object * * @return bool */ protected function isValueInInput($superObject) { return parent::isValueInInput($superObject) || isset($superObject[$this->name . self::IN_WP_CONF_POSTFIX]); } /** * Check if input value is valid * * @param mixed $value input value * @param mixed $validateValue variable passed by reference. Updated to validated value in the case, the value is a valid value. * * @return bool true if is a valid value for this object */ public function isValid($value, &$validateValue = null) { if (!is_array($value) || !isset($value['value']) || !isset($value['inWpConfig'])) { Log::info('WP CONFIG INVALID ARRAY VAL:' . Log::v2str($value)); return false; } // IF isn't in wp config the value isn't validate if ($value['inWpConfig'] === false) { $validateValue = $value; return true; } else { $confValidValue = $value['value']; if (parent::isValid($value['value'], $confValidValue) === false) { Log::info('WP CONFIG INVALID VALUE:' . Log::v2str($confValidValue)); return false; } else { $validateValue = $value; $validateValue['value'] = $confValidValue; return true; } } } /** * Render HTML input before content * * @return void */ protected function htmlInputContBefore() { if ($this->getFormStatus() == self::STATUS_INFO_ONLY) { return; } if (!$this->value['inWpConfig']) { $this->formAttr['inputContainerClasses'][] = 'no-display'; if ($this->formAttr['status'] == self::STATUS_ENABLED) { $this->formAttr['status'] = self::STATUS_DISABLED; } } $inputAttrs = array( 'name' => $this->name . self::IN_WP_CONF_POSTFIX, 'value' => 1 ); if ($this->value['inWpConfig']) { $inputAttrs['checked'] = 'checked'; } echo '<span class="wpinconf-check-wrapper" >'; \DUPX_U_Html::checkboxSwitch( $inputAttrs, array( 'title' => 'Add in wp config' ) ); echo '</span>'; } /** * This function return the default attr for each type. * in the constructor an array merge is made between the result of this function and the parameters passed. * In this way the values in $ this -> ['attr'] are always consistent. * * @param string $type param value type * * @return array */ protected static function getDefaultAttrForType($type) { $attrs = parent::getDefaultAttrForType($type); $valFromInput = $attrs['defaultFromInput']; $attrs['defaultFromInput'] = array( 'value' => $valFromInput, 'inWpConfig' => false ); return $attrs; } /** * this function return the default formAttr for each type. * in the constructor an array merge is made between the result of this function and the parameters passed. * In this way the values in $ this -> ['attr'] are always consistent. * * @param string $formType form type * * @return array */ protected static function getDefaultAttrForFormType($formType) { $attrs = parent::getDefaultAttrForFormType($formType); $attrs['wrapperClasses'][] = 'wp-config-item'; $attrs['wrapperContainerTag'] = 'div'; return $attrs; } } PK w <\�Be�. �. Items/ParamFormTables.phpnu &1i� <?php /** * param descriptor * * Standard: PSR-2 * * @link http://www.php-fig.org/psr/psr-2 Full Documentation * * @package SC\DUPX\U */ namespace Duplicator\Installer\Core\Params\Items; use Duplicator\Installer\Utils\Log\Log; use Duplicator\Libs\Snap\SnapUtil; /** * this class handles the entire block selection block. */ class ParamFormTables extends ParamForm { const TYPE_ARRAY_TABLES = 'arraytbl'; const FORM_TYPE_TABLES_SELECT = 'tablessel'; const TABLE_ITEM_POSTFIX = '_item'; const TABLE_NAME_POSTFIX_TNAME = '_tname'; const TABLE_NAME_POSTFIX_EXTRACT = '_extract'; const TABLE_NAME_POSTFIX_REPLACE = '_replace'; /** * Class constructor * * @param string $name param identifier * @param string $type TYPE_STRING | TYPE_ARRAY_STRING | ... * @param string $formType FORM_TYPE_HIDDEN | FORM_TYPE_TEXT | ... * @param array $attr list of attributes * @param array $formAttr list of form attributes */ public function __construct($name, $type, $formType, $attr = null, $formAttr = array()) { if ($type != self::TYPE_ARRAY_TABLES) { throw new \Exception('the type must be ' . self::TYPE_ARRAY_TABLES); } if ($formType != self::FORM_TYPE_TABLES_SELECT) { throw new \Exception('the form type must be ' . self::FORM_TYPE_TABLES_SELECT); } parent::__construct($name, $type, $formType, $attr, $formAttr); } /** * Render HTML * * @return void */ protected function htmlItem() { if ($this->formType == self::FORM_TYPE_TABLES_SELECT) { $this->tablesSelectHtml(); } else { parent::htmlItem(); } } /** * Render tables selector HTML * * @return void */ protected function tablesSelectHtml() { $tables = \DUPX_DB_Tables::getInstance(); $value = $this->getInputValue(); ?> <table id="plugins_list_table_selector" class="list_table_selector list-import-upt-tables"> <thead> <tr> <td class="name"></td> <td class="info toggle-all"> Toggle All </td> <td class="action"> <span title="Check all Extract" class="checkbox-switch"> <input class="select-all-import" checked type="checkbox" > <span class="slider"></span> </span> </td> <td class="action"> <span title="Check all Replace" class="checkbox-switch"> <input class="select-all-replace" checked type="checkbox"> <span class="slider"></span> </span> </td> </tr> <tr> <th class="name">Original Name</th> <th class="info">New Name</th> <th class="action">Import</th> <th class="action">Update</th> </tr> </thead> <tbody> <?php $index = 0; foreach ($value as $name => $tableVals) { $this->tableHtmlItem($tableVals, $tables->getTableObjByName($name), $index); $index++; } ?> </tbody> <tfoot> <tr> <th class="name">Original Name</th> <th class="info">New Name</th> <th class="action">Import</th> <th class="action">Update</th> </tr> </tfoot> </table> <?php } /** * Renter tables items selector * * @param array $vals form values * @param \DUPX_DB_Table_item $tableOjb table object * @param integer $index infex of current item * * @return void */ protected function tableHtmlItem($vals, \DUPX_DB_Table_item $tableOjb, $index) { $itemClasses = array( 'table-item', $this->getFormItemId() . self::TABLE_ITEM_POSTFIX ); $hiddenNameAttrs = array( 'id' => $this->getFormItemId() . self::TABLE_NAME_POSTFIX_TNAME . '_' . $index, 'type' => 'hidden', 'name' => $this->getName() . '[]', 'class' => $this->getFormItemId() . self::TABLE_NAME_POSTFIX_TNAME, 'value' => $tableOjb->getOriginalName() ); $extractCheckboxAttrs = array( 'id' => $this->getFormItemId() . self::TABLE_NAME_POSTFIX_EXTRACT . '_' . $index, 'name' => $this->getName() . self::TABLE_NAME_POSTFIX_EXTRACT . '[]', 'class' => $this->getFormItemId() . self::TABLE_NAME_POSTFIX_EXTRACT, 'value' => 1 ); $replaceCheckboxAttrs = array( 'id' => $this->getFormItemId() . self::TABLE_NAME_POSTFIX_REPLACE . '_' . $index, 'name' => $this->getName() . self::TABLE_NAME_POSTFIX_REPLACE . '[]', 'class' => $this->getFormItemId() . self::TABLE_NAME_POSTFIX_REPLACE, 'value' => 1 ); if ($tableOjb->canBeExctracted()) { if ($vals['extract']) { $extractCheckboxAttrs['checked'] = ''; } if ($vals['replace']) { $replaceCheckboxAttrs['checked'] = ''; } } else { $itemClasses[] = 'no-display'; $extractCheckboxAttrs['disabled'] = ''; $replaceCheckboxAttrs['disabled'] = ''; } if ($this->isDisabled() || $this->isReadonly()) { $extractCheckboxAttrs['disabled'] = ''; $replaceCheckboxAttrs['disabled'] = ''; $skipSendValue = true; } else { $skipSendValue = false; } ?> <tr class="<?php echo implode(' ', $itemClasses); ?>" > <td class="name" > <span class="table-name" ><?php echo \DUPX_U::esc_html($tableOjb->getOriginalName()); ?></span><br> Rows: <b><?php echo $tableOjb->getRows(); ?></b> Size: <b><?php echo $tableOjb->getSize(true); ?></b> </td> <td class="info" > <span class="table-name" ><b><?php echo \DUPX_U::esc_html($tableOjb->getNewName()); ?></b></span><br> </td> <td class="action extract" > <?php if (!$skipSendValue) { // if is disabled or readonly don't senta tables nme so params isn't updated ?> <input <?php echo \DUPX_U_Html::arrayAttrToHtml($hiddenNameAttrs); ?> > <?php } \DUPX_U_Html::checkboxSwitch( $extractCheckboxAttrs, array( 'title' => 'Extract in database' ) ); ?> </td> <td class="action replace" > <?php \DUPX_U_Html::checkboxSwitch( $replaceCheckboxAttrs, array( 'title' => 'Apply replace engine at URLs and paths in database' ) ); ?> </td> </tr> <?php } /** * Check if value is valid * * @param mixed $value value * @param mixed $validateValue variable passed by reference. Updated to validated value in the case, the value is a valid value. * * @return bool true if is a valid value for this object */ public function isValid($value, &$validateValue = null) { $validateValue = (array) $value; $avaiableTables = \DUPX_DB_Tables::getInstance()->getTablesNames(); $validateTables = array_keys($validateValue); // all tables in list have to exist in avaiable tables foreach ($validateValue as $table => $tableValues) { if (!in_array($table, $avaiableTables)) { Log::info('INVALID ' . $table . ' ISN\'T IN AVAIBLE LIST: ' . Log::v2str($avaiableTables)); return false; } } // all tables abaliable have to exists in list foreach ($avaiableTables as $avaibleTable) { if (!in_array($avaibleTable, $validateTables)) { Log::info('AVAIABLE ' . $avaibleTable . ' ISN\'T IN PARAM LIST TABLE'); return false; } } return true; } /** * Appli filter to value input * * @param array $superObject query string values * * @return array */ public function getValueFilter($superObject) { $result = array(); if (($tables = json_decode($superObject[$this->getName()])) == false) { throw new \Exception('Invalid json string'); } foreach ($tables as $table) { $table = (array) $table; if ($table['extract'] == false) { // replace can't be true if extract if false $table['replace'] = false; } $result[$table['name']] = $table; } return $result; } /** * Return sanitized value * * @param mixed $value value input * * @return array */ public function getSanitizeValue($value) { $newValues = (array) $value; $sanitizeValues = array(); foreach ($newValues as $key => $newValue) { $sanitizedKey = SnapUtil::sanitizeNSCharsNewlineTrim($key); $newValue = (array) $newValue; $sanitizedNewValue = self::getParamItemValueFromData(); $sanitizedNewValue['name'] = isset($newValue['name']) ? SnapUtil::sanitizeNSCharsNewlineTrim($newValue['name']) : ''; $sanitizedNewValue['extract'] = isset($newValue['extract']) ? filter_var($newValue['extract'], FILTER_VALIDATE_BOOLEAN) : false; $sanitizedNewValue['replace'] = isset($newValue['replace']) ? filter_var($newValue['replace'], FILTER_VALIDATE_BOOLEAN) : false; $sanitizeValues[$sanitizedKey] = $sanitizedNewValue; } return $sanitizeValues; } /** * Get default type attributes * * @param string $type param type * * @return array */ protected static function getDefaultAttrForType($type) { $attrs = parent::getDefaultAttrForType($type); if ($type == self::TYPE_ARRAY_TABLES) { $attrs['default'] = array(); } return $attrs; } /** * Get default form attributes * * @param string $formType form type * * @return array */ protected static function getDefaultAttrForFormType($formType) { $attrs = parent::getDefaultAttrForFormType($formType); if ($formType == self::FORM_TYPE_TABLES_SELECT) { $attrs['wrapperContainerTag'] = 'div'; $attrs['inputContainerTag'] = 'div'; } return $attrs; } /** * Return param item from data * * @param string $name table name * @param bool $extract extract * @param bool $replace replace * * @return array */ public static function getParamItemValueFromData($name = '', $extract = false, $replace = false) { return array( 'name' => $name, 'extract' => $extract, 'replace' => $replace ); } } PK w <\U�g�! ! ! Descriptors/ParamDescNewAdmin.phpnu &1i� <?php /** * New admin params descriptions * * @category Duplicator * @package Installer * @author Snapcreek <admin@snapcreek.com> * @copyright 2011-2021 Snapcreek LLC * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 */ namespace Duplicator\Installer\Core\Params\Descriptors; use Duplicator\Installer\Core\Params\PrmMng; use Duplicator\Installer\Core\Params\Items\ParamItem; use Duplicator\Installer\Core\Params\Items\ParamForm; use Duplicator\Installer\Core\Params\Items\ParamFormPass; /** * class where all parameters are initialized. Used by the param manager */ final class ParamDescNewAdmin implements DescriptorInterface { /** * Init params * * @param ParamItem[]|ParamForm[] $params params list * * @return void */ public static function init(&$params) { $params[PrmMng::PARAM_WP_ADMIN_CREATE_NEW] = new ParamForm( PrmMng::PARAM_WP_ADMIN_CREATE_NEW, ParamForm::TYPE_BOOL, ParamForm::FORM_TYPE_SWITCH, array( 'default' => false ), array( 'label' => 'Create New User:', 'status' => function ($paramObj) { if (ParamDescUsers::getUsersMode() != ParamDescUsers::USER_MODE_OVERWRITE) { return ParamForm::STATUS_DISABLED; } else { return ParamForm::STATUS_ENABLED; } }, 'checkboxLabel' => '' ) ); $params[PrmMng::PARAM_WP_ADMIN_NAME] = new ParamForm( PrmMng::PARAM_WP_ADMIN_NAME, ParamForm::TYPE_STRING, ParamForm::FORM_TYPE_TEXT, array( 'default' => '', 'sanitizeCallback' => array('Duplicator\\Libs\\Snap\\SnapUtil', 'sanitizeNSCharsNewlineTrim'), 'validateCallback' => function ($value, ParamItem $paramObj) { if (!PrmMng::getInstance()->getValue(PrmMng::PARAM_WP_ADMIN_CREATE_NEW)) { return true; } if (strlen($value) < 4) { $paramObj->setInvalidMessage('Must have 4 or more characters'); return false; } return true; } ), array( 'status' => array(__CLASS__, 'getStatuOfNewAdminParams'), 'label' => 'Username:', 'classes' => 'new-admin-field', 'attr' => array( 'title' => '4 characters minimum', 'placeholder' => "(4 or more characters)" ) ) ); $params[PrmMng::PARAM_WP_ADMIN_PASSWORD] = new ParamFormPass( PrmMng::PARAM_WP_ADMIN_PASSWORD, ParamFormPass::TYPE_STRING, ParamFormPass::FORM_TYPE_PWD_TOGGLE, array( 'default' => '', 'sanitizeCallback' => array('Duplicator\\Libs\\Snap\\SnapUtil', 'sanitizeNSCharsNewlineTrim'), 'validateCallback' => function ($value, ParamItem $paramObj) { if (!PrmMng::getInstance()->getValue(PrmMng::PARAM_WP_ADMIN_CREATE_NEW)) { return true; } if (strlen($value) < \DUPX_Constants::MIN_NEW_PASSWORD_LEN) { $paramObj->setInvalidMessage('Must have ' . \DUPX_Constants::MIN_NEW_PASSWORD_LEN . ' or more characters'); return false; } return true; } ), array( 'status' => array(__CLASS__, 'getStatuOfNewAdminParams'), 'label' => 'Password:', 'classes' => array('strength-pwd-check', 'new-admin-field'), 'attr' => array( 'placeholder' => '(' . \DUPX_Constants::MIN_NEW_PASSWORD_LEN . ' or more characters)', 'title' => \DUPX_Constants::MIN_NEW_PASSWORD_LEN . ' characters minimum' ) ) ); $params[PrmMng::PARAM_WP_ADMIN_MAIL] = new ParamForm( PrmMng::PARAM_WP_ADMIN_MAIL, ParamForm::TYPE_STRING, ParamForm::FORM_TYPE_TEXT, array( 'default' => '', 'sanitizeCallback' => array('Duplicator\\Libs\\Snap\\SnapUtil', 'sanitizeNSCharsNewlineTrim'), 'validateCallback' => function ($value, ParamItem $paramObj) { if (!PrmMng::getInstance()->getValue(PrmMng::PARAM_WP_ADMIN_CREATE_NEW)) { return true; } if (strlen($value) < 4) { $paramObj->setInvalidMessage('Email name must have 4 or more characters'); return false; } if (filter_var($value, FILTER_VALIDATE_EMAIL) == false) { $paramObj->setInvalidMessage('Email "' . $value . '" isn\'t valid'); return false; } return true; } ), array( 'status' => array(__CLASS__, 'getStatuOfNewAdminParams'), 'label' => 'Email:', 'classes' => 'new-admin-field', 'attr' => array( 'title' => '4 characters minimum', 'placeholder' => "(4 or more characters)" ) ) ); $params[PrmMng::PARAM_WP_ADMIN_NICKNAME] = new ParamForm( PrmMng::PARAM_WP_ADMIN_NICKNAME, ParamForm::TYPE_STRING, ParamForm::FORM_TYPE_TEXT, array( 'default' => '', 'sanitizeCallback' => array('Duplicator\\Libs\\Snap\\SnapUtil', 'sanitizeNSCharsNewlineTrim') ), array( 'status' => array(__CLASS__, 'getStatuOfNewAdminParams'), 'label' => 'Nickname:', 'classes' => 'new-admin-field', 'attr' => array( 'title' => 'if username is empty', 'placeholder' => "(if username is empty)" ) ) ); $params[PrmMng::PARAM_WP_ADMIN_FIRST_NAME] = new ParamForm( PrmMng::PARAM_WP_ADMIN_FIRST_NAME, ParamForm::TYPE_STRING, ParamForm::FORM_TYPE_TEXT, array( 'default' => '', 'sanitizeCallback' => array('Duplicator\\Libs\\Snap\\SnapUtil', 'sanitizeNSCharsNewlineTrim') ), array( 'status' => array(__CLASS__, 'getStatuOfNewAdminParams'), 'label' => 'First Name:', 'classes' => 'new-admin-field', 'attr' => array( 'title' => 'optional', 'placeholder' => "(optional)" ) ) ); $params[PrmMng::PARAM_WP_ADMIN_LAST_NAME] = new ParamForm( PrmMng::PARAM_WP_ADMIN_LAST_NAME, ParamForm::TYPE_STRING, ParamForm::FORM_TYPE_TEXT, array( 'default' => '', 'sanitizeCallback' => array('Duplicator\\Libs\\Snap\\SnapUtil', 'sanitizeNSCharsNewlineTrim') ), array( 'status' => array(__CLASS__, 'getStatuOfNewAdminParams'), 'label' => 'Last Name:', 'classes' => 'new-admin-field', 'attr' => array( 'title' => 'optional', 'placeholder' => "(optional)" ) ) ); } /** * * @return string */ public static function getStatuOfNewAdminParams() { if (PrmMng::getInstance()->getValue(PrmMng::PARAM_WP_ADMIN_CREATE_NEW)) { return ParamForm::STATUS_ENABLED; } else { return ParamForm::STATUS_DISABLED; } } /** * Update params after overwrite logic * * @param ParamItem[]|ParamForm[] $params params list * * @return void */ public static function updateParamsAfterOverwrite($params) { } } PK w <\d���4K 4K "