Advertisement
Guest User

Untitled

a guest
Sep 24th, 2024
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.25 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP8 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 8.2.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 27.10.2023
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class i_action_install extends i_action
  15. {
  16. protected $_source = null;
  17. protected $_didCreateDb = false;
  18.  
  19. private static function _getInstanceError($errstr)
  20. {
  21. $api = new i_action_install();
  22. $api->addError($errstr);
  23. return $api;
  24. }
  25.  
  26. public static function getInstance($id = NULL, $type = NULL, $class = NULL, $preload = NULL)
  27. {
  28. if (itron::$isTaskqueue && itron::$input['cmd'] !== 'importbackup') {
  29. $t = i_action::getInstance(itron::$input['id'], itron::$input['type'], __CLASS__);
  30.  
  31. if ($t->input['cmd'] === 'install') {
  32. $t->isInstall = true;
  33. }
  34. else if (($t->input['cmd'] === 'migrate') || ($t->input['cmd'] === 'import') && isset($t->input['source_path']) || isset($t->input['source_ftu'])) {
  35. $t->isMigrate = true;
  36. }
  37. else if ($t->input['cmd'] === 'import') {
  38. $t->isImport = true;
  39. }
  40. else if ($t->input['cmd'] === 'importbackup') {
  41. $t->isImportBackup = true;
  42. }
  43. else if ($t->input['cmd'] === 'sync') {
  44. $t->isSync = true;
  45. }
  46. else if ($t->input['cmd'] === 'clone') {
  47. $t->isClone = true;
  48. }
  49. else if (($t->input['cmd'] === 'restoreto') || ($t->input['cmd'] === 'restore') && isset($t->input['url'])) {
  50. $t->isRestoreTo = true;
  51. }
  52. else if ($t->input['cmd'] === 'restore') {
  53. $t->isRestore = true;
  54. }
  55.  
  56. return $t;
  57. }
  58.  
  59. $forui = (is_null($id) ? true : $id);
  60. $noFtpConn = (is_null($type) ? false : $type);
  61.  
  62. if (!isset(itron::$input['mode'])) {
  63. itron::$input['mode'] = 'submit';
  64. }
  65.  
  66. if (!isset(itron::$input['cmd'])) {
  67. itron::$input['cmd'] = 'install';
  68. }
  69. if ((itron::$input['cmd'] === 'clone') || itron::$input['cmd'] === 'restore' || itron::$input['cmd'] === 'restoreto') {
  70. if (!isset(itron::$input['id'])) {
  71. return self::_getInstanceError('empty_argument_id|Missing argument: id');
  72. }
  73.  
  74. $source = i_action::getInstance(itron::$input['id'], (itron::$input['cmd'] === 'clone' ? 'current' : 'backups'));
  75.  
  76. if (isset($source->isBroken)) {
  77. $source->addError($source->isBroken, 1);
  78. }
  79.  
  80. if ($source->hasErrors()) {
  81. return $source;
  82. }
  83.  
  84. itron::$input['application'] = $source->install->ini['installer'];
  85. itron::$input['version'] = $source->install->ini['version'];
  86. itron::$input['source_cache_files'] = (isset($source->install->ini['cache-files']) ? $source->install->ini['cache-files'] : NULL);
  87. itron::$input['source_cache_tables'] = (isset($source->install->ini['cache-tables']) ? $source->install->ini['cache-tables'] : NULL);
  88. if ((itron::$input['mode'] === 'submit') && itron::$input['cmd'] === 'restore' && !isset(itron::$input['url'])) {
  89. if (!isset($source->vhost)) {
  90. $source->addError('invalid_website_vhost|Original location is not available: `' . $source->install->ini['url'] . '\'');
  91. return $source;
  92. }
  93.  
  94. itron::$input['field_url'] = $source->install->ini['url'];
  95. $source_owner = $source->install->ini['owner'];
  96. $pathCmp = $source->owner['vhosts'][$source->vhost] . substr($source->install->ini['url'], strlen($source->vhost));
  97. itron::$input['destin_id'] = itron::$input['destin_cache_files'] = itron::$input['destin_cache_tables'] = NULL;
  98. $preQuery = [$source->install->ini['owner'], $source->install->ini['url']];
  99.  
  100. foreach ($source->owner['vhosts'] as $vhost => $vhost_path) {
  101. if (($vhost_path === $pathCmp) || strpos($pathCmp, $vhost_path . '/') === 0) {
  102. $preQuery[] = $vhost . substr($pathCmp, strlen($vhost_path));
  103. }
  104. }
  105.  
  106. itron::initDb();
  107. $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);
  108. if ($searchDestinId !== false && isset($searchDestinId[0])) {
  109. itron::debug('restore: destId = ' . var_export($searchDestinId[0]['id'], true));
  110.  
  111. if ($searchDestinId[0]['installer'] !== $source->install->ini['installer']) {
  112. $source->addError('invalid_backup_app|App mismatch; trying to restore `' . $source->install->ini['installer'] . '\' but current is `' . $searchDestinId[0]['installer'] . '\'.');
  113. return $source;
  114. }
  115.  
  116. itron::$input['destin_id'] = $searchDestinId[0]['id'];
  117. itron::$input['destin_cache_files'] = (int) $searchDestinId[0]['cache_files'];
  118. itron::$input['destin_cache_tables'] = (int) $searchDestinId[0]['cache_tables'];
  119.  
  120. if (!isset(itron::$input['source_cache_files'])) {
  121. itron::$input['source_cache_files'] = itron::$input['destin_cache_files'];
  122. itron::$input['source_cache_tables'] = itron::$input['destin_cache_tables'];
  123. }
  124. if ((isset($source->installer['requirement']['mysql']) || isset($source->installer['requirement']['pgsql']) || isset($source->installer['requirement']['mssql'])) && !isset(itron::$input['db'])) {
  125. $dest = i_action::getInstance($searchDestinId[0]['id'], 'current', __CLASS__, $searchDestinId[0]);
  126. if (!isset($dest->isBroken) && !$dest->hasErrors() && $dest->db_init(false)) {
  127. itron::debug('restore: dest db initialized: ' . $dest->install->ini['db-name']);
  128. 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']) {
  129. itron::$input['field_db'] = itron::$input['db'] = 'manual';
  130. itron::$input['field_db_user'] = $dest->install->ini['db-user'];
  131. itron::$input['field_db_pass'] = $dest->install->ini['db-pass'];
  132. itron::$input['field_db_host'] = $dest->install->ini['db-host'];
  133. itron::$input['field_db_name'] = $dest->install->ini['db-name'];
  134. itron::$input['field_db_prefix'] = (isset($dest->install->ini['db-prefix']) ? $dest->install->ini['db-prefix'] : NULL);
  135. itron::debug('restore: dest db matched: ' . $dest->install->ini['db-name']);
  136. }
  137. else {
  138. itron::debug('restore: dest db match failure: ' . $dest->install->ini['db-name']);
  139. }
  140. }
  141. else {
  142. itron::debug('restore: dest db initialization failure: ' . $dest->install->ini['db-name']);
  143. }
  144. }
  145. }
  146. else {
  147. itron::debug('restore: destId not found - matching install might not exist');
  148. }
  149. if ((isset($source->installer['requirement']['mysql']) || isset($source->installer['requirement']['pgsql']) || isset($source->installer['requirement']['mssql'])) && !isset(itron::$input['db'])) {
  150. if (isset($source->install->ini['db-pass']) && 0 < strlen($source->install->ini['db-pass']) && $source->db_init(false, false, false)) {
  151. itron::$input['field_db'] = itron::$input['db'] = 'manual';
  152. itron::$input['field_db_user'] = $source->install->ini['db-user'];
  153. itron::$input['field_db_pass'] = $source->install->ini['db-pass'];
  154. itron::$input['field_db_host'] = $source->install->ini['db-host'];
  155. itron::$input['field_db_name'] = $source->install->ini['db-name'];
  156. itron::$input['field_db_prefix'] = (isset($source->install->ini['db-prefix']) ? $source->install->ini['db-prefix'] : NULL);
  157. itron::debug('restore: (fallback 1) dest db defined in backup file: ' . $source->install->ini['db-name']);
  158. }
  159. else {
  160. itron::debug('restore: (fallback 1) dest db NOT defined in backup file: ' . var_export($source->install->ini, true));
  161. }
  162. }
  163. if ((isset($source->installer['requirement']['mysql']) || isset($source->installer['requirement']['pgsql']) || isset($source->installer['requirement']['mssql'])) && !isset(itron::$input['db'])) {
  164. $isIR = false;
  165. $hasManualDBsOnly = isset($source->owner['db_mode']) && $source->owner['db_mode'] === 'manual';
  166. if ($hasManualDBsOnly || $isIR) {
  167. $dest->addError('An installation at the original location no longer exists. Use the option to \'Restore to a new location\' instead.');
  168. itron::debug('restore: (fallback 2) manual db only prevents creation of new db');
  169. }
  170. else {
  171. itron::$input['field_db'] = itron::$input['db'] = 'auto';
  172. itron::debug('restore: (fallback 2) new db to be created');
  173. }
  174. }
  175. }
  176.  
  177. if (isset($GLOBALS['it_debug'])) {
  178. itron::debug('getInstance().input = ' . var_export(itron::$input, true));
  179. }
  180. }
  181.  
  182. if (itron::$input['cmd'] === 'sync') {
  183. if (!isset(itron::$input['id'])) {
  184. return self::_getInstanceError('empty_argument_id|Missing argument: id');
  185. }
  186.  
  187. $dest = i_action::getInstance(itron::$input['id'], 'current', __CLASS__);
  188.  
  189. if (isset($dest->isBroken)) {
  190. $dest->addError($dest->isBroken, 1);
  191. }
  192.  
  193. if ($dest->hasErrors()) {
  194. return $dest;
  195. }
  196.  
  197. itron::$input['application'] = $dest->install->ini['installer'];
  198. itron::$input['version'] = $dest->install->ini['version'];
  199. itron::$input['destin_cache_files'] = $dest->install->ini['cache-files'];
  200. ..........................................................................
  201. ............................................
  202. .....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement