Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP8 Decoder for ionCube Encoder)
- *
- * @ Version : 8.2.0.1
- * @ Author : DeZender
- * @ Release on : 27.10.2023
- * @ Official site : http://DeZender.Net
- *
- */
- class i_action_install extends i_action
- {
- protected $_source = null;
- protected $_didCreateDb = false;
- private static function _getInstanceError($errstr)
- {
- $api = new i_action_install();
- $api->addError($errstr);
- return $api;
- }
- public static function getInstance($id = NULL, $type = NULL, $class = NULL, $preload = NULL)
- {
- if (itron::$isTaskqueue && itron::$input['cmd'] !== 'importbackup') {
- $t = i_action::getInstance(itron::$input['id'], itron::$input['type'], __CLASS__);
- if ($t->input['cmd'] === 'install') {
- $t->isInstall = true;
- }
- else if (($t->input['cmd'] === 'migrate') || ($t->input['cmd'] === 'import') && isset($t->input['source_path']) || isset($t->input['source_ftu'])) {
- $t->isMigrate = true;
- }
- else if ($t->input['cmd'] === 'import') {
- $t->isImport = true;
- }
- else if ($t->input['cmd'] === 'importbackup') {
- $t->isImportBackup = true;
- }
- else if ($t->input['cmd'] === 'sync') {
- $t->isSync = true;
- }
- else if ($t->input['cmd'] === 'clone') {
- $t->isClone = true;
- }
- else if (($t->input['cmd'] === 'restoreto') || ($t->input['cmd'] === 'restore') && isset($t->input['url'])) {
- $t->isRestoreTo = true;
- }
- else if ($t->input['cmd'] === 'restore') {
- $t->isRestore = true;
- }
- return $t;
- }
- $forui = (is_null($id) ? true : $id);
- $noFtpConn = (is_null($type) ? false : $type);
- if (!isset(itron::$input['mode'])) {
- itron::$input['mode'] = 'submit';
- }
- if (!isset(itron::$input['cmd'])) {
- itron::$input['cmd'] = 'install';
- }
- if ((itron::$input['cmd'] === 'clone') || itron::$input['cmd'] === 'restore' || itron::$input['cmd'] === 'restoreto') {
- if (!isset(itron::$input['id'])) {
- return self::_getInstanceError('empty_argument_id|Missing argument: id');
- }
- $source = i_action::getInstance(itron::$input['id'], (itron::$input['cmd'] === 'clone' ? 'current' : 'backups'));
- if (isset($source->isBroken)) {
- $source->addError($source->isBroken, 1);
- }
- if ($source->hasErrors()) {
- return $source;
- }
- itron::$input['application'] = $source->install->ini['installer'];
- itron::$input['version'] = $source->install->ini['version'];
- itron::$input['source_cache_files'] = (isset($source->install->ini['cache-files']) ? $source->install->ini['cache-files'] : NULL);
- itron::$input['source_cache_tables'] = (isset($source->install->ini['cache-tables']) ? $source->install->ini['cache-tables'] : NULL);
- if ((itron::$input['mode'] === 'submit') && itron::$input['cmd'] === 'restore' && !isset(itron::$input['url'])) {
- if (!isset($source->vhost)) {
- $source->addError('invalid_website_vhost|Original location is not available: `' . $source->install->ini['url'] . '\'');
- return $source;
- }
- itron::$input['field_url'] = $source->install->ini['url'];
- $source_owner = $source->install->ini['owner'];
- $pathCmp = $source->owner['vhosts'][$source->vhost] . substr($source->install->ini['url'], strlen($source->vhost));
- itron::$input['destin_id'] = itron::$input['destin_cache_files'] = itron::$input['destin_cache_tables'] = NULL;
- $preQuery = [$source->install->ini['owner'], $source->install->ini['url']];
- foreach ($source->owner['vhosts'] as $vhost => $vhost_path) {
- if (($vhost_path === $pathCmp) || strpos($pathCmp, $vhost_path . '/') === 0) {
- $preQuery[] = $vhost . substr($pathCmp, strlen($vhost_path));
- }
- }
- itron::initDb();
- $searchDestinId = itron::$db->query('SELECT * FROM `i_installs` WHERE `type`=\'current\' AND `owner`=? AND `url` IN (' . substr(str_repeat('?,', count($preQuery) - 1), 0, -1) . ') LIMIT 1', $preQuery, true);
- if ($searchDestinId !== false && isset($searchDestinId[0])) {
- itron::debug('restore: destId = ' . var_export($searchDestinId[0]['id'], true));
- if ($searchDestinId[0]['installer'] !== $source->install->ini['installer']) {
- $source->addError('invalid_backup_app|App mismatch; trying to restore `' . $source->install->ini['installer'] . '\' but current is `' . $searchDestinId[0]['installer'] . '\'.');
- return $source;
- }
- itron::$input['destin_id'] = $searchDestinId[0]['id'];
- itron::$input['destin_cache_files'] = (int) $searchDestinId[0]['cache_files'];
- itron::$input['destin_cache_tables'] = (int) $searchDestinId[0]['cache_tables'];
- if (!isset(itron::$input['source_cache_files'])) {
- itron::$input['source_cache_files'] = itron::$input['destin_cache_files'];
- itron::$input['source_cache_tables'] = itron::$input['destin_cache_tables'];
- }
- if ((isset($source->installer['requirement']['mysql']) || isset($source->installer['requirement']['pgsql']) || isset($source->installer['requirement']['mssql'])) && !isset(itron::$input['db'])) {
- $dest = i_action::getInstance($searchDestinId[0]['id'], 'current', __CLASS__, $searchDestinId[0]);
- if (!isset($dest->isBroken) && !$dest->hasErrors() && $dest->db_init(false)) {
- itron::debug('restore: dest db initialized: ' . $dest->install->ini['db-name']);
- if (($source->install->ini['db-user'] === $dest->install->ini['db-user']) && $source->install->ini['db-host'] === $dest->install->ini['db-host'] && $source->install->ini['db-name'] === $dest->install->ini['db-name'] && !isset($dest->install->ini['db-prefix']) || $source->install->ini['db-prefix'] === $dest->install->ini['db-prefix']) {
- itron::$input['field_db'] = itron::$input['db'] = 'manual';
- itron::$input['field_db_user'] = $dest->install->ini['db-user'];
- itron::$input['field_db_pass'] = $dest->install->ini['db-pass'];
- itron::$input['field_db_host'] = $dest->install->ini['db-host'];
- itron::$input['field_db_name'] = $dest->install->ini['db-name'];
- itron::$input['field_db_prefix'] = (isset($dest->install->ini['db-prefix']) ? $dest->install->ini['db-prefix'] : NULL);
- itron::debug('restore: dest db matched: ' . $dest->install->ini['db-name']);
- }
- else {
- itron::debug('restore: dest db match failure: ' . $dest->install->ini['db-name']);
- }
- }
- else {
- itron::debug('restore: dest db initialization failure: ' . $dest->install->ini['db-name']);
- }
- }
- }
- else {
- itron::debug('restore: destId not found - matching install might not exist');
- }
- if ((isset($source->installer['requirement']['mysql']) || isset($source->installer['requirement']['pgsql']) || isset($source->installer['requirement']['mssql'])) && !isset(itron::$input['db'])) {
- if (isset($source->install->ini['db-pass']) && 0 < strlen($source->install->ini['db-pass']) && $source->db_init(false, false, false)) {
- itron::$input['field_db'] = itron::$input['db'] = 'manual';
- itron::$input['field_db_user'] = $source->install->ini['db-user'];
- itron::$input['field_db_pass'] = $source->install->ini['db-pass'];
- itron::$input['field_db_host'] = $source->install->ini['db-host'];
- itron::$input['field_db_name'] = $source->install->ini['db-name'];
- itron::$input['field_db_prefix'] = (isset($source->install->ini['db-prefix']) ? $source->install->ini['db-prefix'] : NULL);
- itron::debug('restore: (fallback 1) dest db defined in backup file: ' . $source->install->ini['db-name']);
- }
- else {
- itron::debug('restore: (fallback 1) dest db NOT defined in backup file: ' . var_export($source->install->ini, true));
- }
- }
- if ((isset($source->installer['requirement']['mysql']) || isset($source->installer['requirement']['pgsql']) || isset($source->installer['requirement']['mssql'])) && !isset(itron::$input['db'])) {
- $isIR = false;
- $hasManualDBsOnly = isset($source->owner['db_mode']) && $source->owner['db_mode'] === 'manual';
- if ($hasManualDBsOnly || $isIR) {
- $dest->addError('An installation at the original location no longer exists. Use the option to \'Restore to a new location\' instead.');
- itron::debug('restore: (fallback 2) manual db only prevents creation of new db');
- }
- else {
- itron::$input['field_db'] = itron::$input['db'] = 'auto';
- itron::debug('restore: (fallback 2) new db to be created');
- }
- }
- }
- if (isset($GLOBALS['it_debug'])) {
- itron::debug('getInstance().input = ' . var_export(itron::$input, true));
- }
- }
- if (itron::$input['cmd'] === 'sync') {
- if (!isset(itron::$input['id'])) {
- return self::_getInstanceError('empty_argument_id|Missing argument: id');
- }
- $dest = i_action::getInstance(itron::$input['id'], 'current', __CLASS__);
- if (isset($dest->isBroken)) {
- $dest->addError($dest->isBroken, 1);
- }
- if ($dest->hasErrors()) {
- return $dest;
- }
- itron::$input['application'] = $dest->install->ini['installer'];
- itron::$input['version'] = $dest->install->ini['version'];
- itron::$input['destin_cache_files'] = $dest->install->ini['cache-files'];
- ..........................................................................
- ............................................
- .....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement