Skip to content

Commit b9d9dae

Browse files
fix fail2ban magnusbilling login
1 parent d0f4db8 commit b9d9dae

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

build/MagnusBilling-current.tar.gz

109 Bytes
Binary file not shown.

protected/commands/update.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,15 @@ chmod -R 700 /var/www/html/mbilling/resources/images
8888
chmod +x /var/www/html/mbilling/resources/asterisk/mbilling.php
8989
chmod -R 555 /var/www/html/mbilling/resources/asterisk/
9090
rm -rf /var/lib/asterisk/sbin/*
91+
pkill -f mbillingd
9192
if [ ${DIST} = "DEBIAN" ]; then
92-
CRONPATH='/var/spool/cron/crontabs/asterisk'
93+
rm -rf /var/spool/cron/crontabs/asterisk
9394
elif [ ${DIST} = "CENTOS" ]; then
94-
CRONPATH='/var/spool/cron/asterisk'
95+
rm -rf /var/spool/cron/asterisk
9596
fi
9697

98+
99+
97100
if [[ -e /var/www/html/mbilling/resources/images/lock-screen-background.jpg ]]; then
98101
for color in black blue gray orange purple red yellow green
99102
do

resources/asterisk/MassiveCall.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,21 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
4747
$now = time();
4848
}
4949

50-
if ($MAGNUS->dnid == 'failed' || !is_numeric($MAGNUS->dnid)) {
50+
if ($MAGNUS->dnid == 'failed' || ! is_numeric($MAGNUS->dnid)) {
5151
$agi->verbose("Hangup becouse dnid is OutgoingSpoolFailed", 25);
5252
$MAGNUS->hangup($agi);
5353
}
5454

5555
$sql = "SELECT *, pkg_campaign.id AS id, pkg_campaign.id_user AS id_user, pkg_campaign.description AS description, pkg_campaign.record_call AS record_call FROM pkg_campaign LEFT JOIN pkg_user ON pkg_campaign.id_user = pkg_user.id WHERE pkg_campaign.id = $idCampaign LIMIT 1";
5656
$modelCampaign = $agi->query($sql)->fetch(PDO::FETCH_OBJ);
5757

58-
if (!isset($modelCampaign->id)) {
58+
if ( ! isset($modelCampaign->id)) {
5959
$agi->verbose($idCampaign . ' campaing not exist');
6060
return;
6161
}
6262
$sql = "SELECT * FROM pkg_phonenumber WHERE id = $idPhonenumber LIMIT 1";
6363
$modelPhoneNumber = $agi->query($sql)->fetch(PDO::FETCH_OBJ);
64-
if (!isset($modelPhoneNumber->id)) {
64+
if ( ! isset($modelPhoneNumber->id)) {
6565
$agi->verbose($idPhonenumber . ' number not exist');
6666
exit;
6767
}
@@ -379,7 +379,7 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
379379

380380
$agi->verbose($url);
381381

382-
if (!$res = @file_get_contents($url, false)) {
382+
if ( ! $res = @file_get_contents($url, false)) {
383383
$agi->verbose("ERRO SMS -> " . $url);
384384
}
385385

@@ -451,7 +451,7 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
451451
$agi->verbose("Cliente votou na opcao: $dtmf_result", 5);
452452

453453
//Hungaup call if the fisrt poll dtmf is not numeric
454-
if ($i == 0 && !is_numeric($dtmf_result)) {
454+
if ($i == 0 && ! is_numeric($dtmf_result)) {
455455
$agi->verbose('nao votou nada na 1º enquete', 5);
456456
break;
457457
}
@@ -510,8 +510,13 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
510510

511511
$url = preg_replace("/\%number\%/", $destination, $poll->{'option' . $dtmf_result});
512512
$url = preg_replace("/\%name\%/", $modelPhoneNumber->name, $url);
513-
514-
if (preg_match('/POST/', $url)) {
513+
if (preg_match('/JSON/', $url)) {
514+
$url2 = explode('?', $url);
515+
$parts = parse_url($url);
516+
parse_str($parts['query'], $query);
517+
$data = json_encode($query);
518+
exec(" curl -k -X POST -d '" . $data . "' " . $url2[0] . "");
519+
} else if (preg_match('/POST/', $url)) {
515520
$url = explode('?', $url);
516521
exec(" curl -k -X POST -d '" . $url[1] . "' " . $url[0] . "");
517522
} else {
@@ -617,7 +622,7 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
617622
$sql = "SELECT * FROM pkg_rate WHERE id = $idRate LIMIT 1";
618623
$modelRate = $agi->query($sql)->fetch(PDO::FETCH_OBJ);
619624

620-
if (!isset($modelRate->id)) {
625+
if ( ! isset($modelRate->id)) {
621626
return;
622627
}
623628

@@ -702,7 +707,7 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
702707

703708
}
704709

705-
if (!is_null($MAGNUS->id_agent) && $MAGNUS->id_agent > 1) {
710+
if ( ! is_null($MAGNUS->id_agent) && $MAGNUS->id_agent > 1) {
706711
$CalcAgi->agent_bill = $CalcAgi->updateSystemAgent($agi, $MAGNUS, $destination, $sellratecost, $duration);
707712
}
708713

script/install.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,10 @@ ignoreregex =
948948
echo '
949949
[INCLUDES]
950950
[Definition]
951-
failregex = .* Username or password is wrong - User .* from IP - <HOST>
951+
failregex = .*Username and password combination is invalid - User.*IP: <HOST>
952952
ignoreregex =
953+
954+
datepattern = ^%%Y/%%m/%%d:%%H:%%M:%%S
953955
' > /etc/fail2ban/filter.d/mbilling_login.conf
954956

955957

@@ -1001,7 +1003,7 @@ filter = mbilling_login
10011003
action = iptables-allports[name=mbilling_login, port=all, protocol=all]
10021004
logpath = /var/www/html/mbilling/protected/runtime/application.log
10031005
maxretry = 3
1004-
bantime = 600
1006+
bantime = 300
10051007
10061008
[ip-blacklist]
10071009
enabled = true

0 commit comments

Comments
 (0)