|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class CpanelChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin |
|
|
|
|
|
|
4
|
|
|
{ |
|
5
|
|
|
public function Init() |
|
6
|
|
|
{ |
|
7
|
|
|
$this->addHook('main.fabrica', 'MainFabrica'); |
|
8
|
|
|
} |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @param string $sName |
|
12
|
|
|
* @param mixed $oProvider |
|
13
|
|
|
*/ |
|
14
|
|
|
public function MainFabrica($sName, &$oProvider) |
|
15
|
|
|
{ |
|
16
|
|
|
switch ($sName) |
|
17
|
|
|
{ |
|
18
|
|
|
case 'change-password': |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
$sHost = \trim($this->Config()->Get('plugin', 'host', '')); |
|
21
|
|
|
$iPost = (int) $this->Config()->Get('plugin', 'port', 2087); |
|
22
|
|
|
$sUser = (string) $this->Config()->Get('plugin', 'user', ''); |
|
23
|
|
|
$sPassword = (string) $this->Config()->Get('plugin', 'password', ''); |
|
24
|
|
|
$bSsl = (bool) $this->Config()->Get('plugin', 'ssl', false); |
|
25
|
|
|
|
|
26
|
|
|
if (!empty($sHost) && 0 < $iPost && 0 < \strlen($sUser) && 0 < \strlen($sPassword)) |
|
27
|
|
|
{ |
|
28
|
|
|
include_once __DIR__.'/CpanelChangePasswordDriver.php'; |
|
29
|
|
|
|
|
30
|
|
|
$oProvider = new CpanelChangePasswordDriver(); |
|
31
|
|
|
$oProvider->SetLogger($this->Manager()->Actions()->Logger()); |
|
32
|
|
|
$oProvider->SetConfig($sHost, $iPost, $bSsl, $sUser, $sPassword); |
|
33
|
|
|
$oProvider->SetAllowedEmails(\strtolower(\trim($this->Config()->Get('plugin', 'allowed_emails', '')))); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
break; |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @return array |
|
42
|
|
|
*/ |
|
43
|
|
|
public function configMapping() |
|
44
|
|
|
{ |
|
45
|
|
|
return array( |
|
46
|
|
|
\RainLoop\Plugins\Property::NewInstance('host')->SetLabel('cPanel Host') |
|
47
|
|
|
->SetDefaultValue(''), |
|
48
|
|
|
\RainLoop\Plugins\Property::NewInstance('port')->SetLabel('cPanel Port') |
|
49
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::INT) |
|
50
|
|
|
->SetDefaultValue(2087), |
|
51
|
|
|
\RainLoop\Plugins\Property::NewInstance('ssl')->SetLabel('Use SSL') |
|
52
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL) |
|
53
|
|
|
->SetDefaultValue(false), |
|
54
|
|
|
\RainLoop\Plugins\Property::NewInstance('user')->SetLabel('cPanel User') |
|
55
|
|
|
->SetDefaultValue(''), |
|
56
|
|
|
\RainLoop\Plugins\Property::NewInstance('password')->SetLabel('cPanel Password') |
|
57
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::PASSWORD) |
|
58
|
|
|
->SetDefaultValue(''), |
|
59
|
|
|
\RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails') |
|
60
|
|
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT) |
|
61
|
|
|
->SetDescription('Allowed emails, space as delimiter, wildcard supported. Example: [email protected] [email protected] *@domain2.net') |
|
62
|
|
|
->SetDefaultValue('*') |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
} |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.