You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: protected/commands/FailtwobanipCommand.php
+51-18Lines changed: 51 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -53,13 +53,19 @@ public function run($args)
53
53
add the ~/.ssh/id_rsa.pub on /root/.ssh/authorized_keys of the proxy and slaves.
54
54
*/
55
55
56
+
$action = [
57
+
['0', 'Temp ban'],
58
+
['1', 'Permanent ban'],
59
+
['3', 'Unban'],
60
+
['5', 'Add to IgnoreIP']
61
+
];
56
62
57
63
58
64
if (isset($args[0])) {
59
65
$this->ssh_port = $args[0];
60
66
}
61
67
62
-
68
+
//only execute this script if the admin is logged on magnusbilling
63
69
$sql = "SELECT count(id) as logged FROM pkg_log where id_log_actions = 1 AND date >= NOW() - INTERVAL (SELECT config_value FROM pkg_configuration WHERE config_key = 'session_timeout') SECOND AND id_user IN (SELECT id FROM pkg_user WHERE id_group IN (SELECT id FROM pkg_group_user WHERE id_user_type = 1))";
64
70
$command = Yii::app()->db->createCommand($sql);
65
71
$resultAdmins = $command->queryAll();
@@ -68,21 +74,24 @@ public function run($args)
68
74
return;
69
75
}
70
76
71
-
77
+
//get all ips that action is 3 (to unban)
72
78
$sql = 'SELECT ip FROM pkg_firewall WHERE action = 3';
73
79
$command = Yii::app()->db->createCommand($sql);
74
80
$this->resultUnBanIps = $command->queryAll();
75
81
82
+
83
+
//delete all that already added on $this->resultUnBanIps
76
84
foreach ($this->resultUnBanIpsas$unbanIP) {
77
85
$sql = 'DELETE FROM pkg_firewall WHERE ip = "' . $unbanIP['ip'] . '"';
78
86
Yii::app()->db->createCommand($sql)->execute();
79
87
}
80
88
89
+
//get all ips that action is 1 (Permanent ban)
81
90
$sql = 'SELECT ip FROM pkg_firewall WHERE action = 1';
82
91
$command = Yii::app()->db->createCommand($sql);
83
92
$this->resultBanIps = $command->queryAll();
84
93
85
-
94
+
//get all ips that action is 5 (Add to IgnoreIP) and add it to $this->ignogeips
86
95
$sql = 'SELECT ip FROM pkg_firewall WHERE action = 5';
87
96
$command = Yii::app()->db->createCommand($sql);
88
97
$modelServersIgnoreIPs = $command->queryAll();
@@ -91,18 +100,19 @@ public function run($args)
91
100
$this->ignogeips .= $server['ip'] . "";
92
101
}
93
102
94
-
103
+
//get all ips of the clients and add it to $this->ignogeips
95
104
$sql = 'SELECT host FROM pkg_sip JOIN pkg_user ON pkg_sip.id_user = pkg_user.id WHERE pkg_user.active = 1 AND host != "dynamic"';
0 commit comments