-
Notifications
You must be signed in to change notification settings - Fork 269
Expand file tree
/
Copy pathFileSystemHandler.php
More file actions
84 lines (67 loc) · 1.87 KB
/
Copy pathFileSystemHandler.php
File metadata and controls
84 lines (67 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines https://www.simplemachines.org
* @copyright 2024 Simple Machines and individual contributors
* @license https://www.simplemachines.org/about/smf/license.php BSD
*
* @version 3.0 Alpha 3
*/
declare(strict_types=1);
namespace SMF\Maintenance\Migration\v3_0;
use SMF\Config;
use SMF\Maintenance\Migration\MigrationBase;
class FileSystemHandler extends MigrationBase
{
/*******************
* Public properties
*******************/
/**
*
*/
public string $name = 'Updating settings for File System Handler';
/*********************
* Internal properties
*********************/
private array $renames = [
'package_server' => 'filesystem_server',
'package_port' => 'filesystem_port',
'package_username' => 'filesystem_username',
'package_path' => 'filesystem_path',
];
/****************
* Public methods
****************/
/**
*
*/
public function isCandidate(): bool
{
return !empty(Config::$modSettings['package_server']);
}
/**
*
*/
public function execute(): bool
{
$newSettings = [];
foreach ($this->renames as $oldKey => $newKey) {
if (!isset(Config::$modSettings[$oldKey])) {
continue;
}
$newSettings[$newKey] = Config::$modSettings[$oldKey];
$newSettings[$oldKey] = null;
}
// Hold on, do we have a 'ssl://' or 'ftps://' in the server name?
if (str_starts_with(Config::$modSettings['package_server'], 'ssl://') || str_starts_with(Config::$modSettings['package_server'], 'ftps://')) {
$server_addr = preg_replace('~^((ft|htt)ps?|ssl)?://~i', '', Config::$modSettings['package_server']);
$server_addr = strtr($server_addr, ['/' => '', ':' => '', '@' => '']);
$newSettings['filesystem_server'] = $server_addr;
$newSettings['filesystem_type'] = 'FtpSSL';
}
Config::updateModSettings($newSettings);
return true;
}
}