@@ -46,6 +46,10 @@ public function run($args)
4646 # ONLINE CALLS ON THE SAME NUMBER
4747 $ this ->onlineCallsSameNumber ($ alarm );
4848 break ;
49+ case 6 :
50+ # ONLINE CALLS ON THE SAME NUMBER
51+ $ this ->numberEqualCaller ($ alarm );
52+ break ;
4953 }
5054 }
5155 }
@@ -71,12 +75,12 @@ public function asr($alarm)
7175 echo 'ASR ' . $ asr . "\n" ;
7276 if ($ alarm ->condition == 1 ) {
7377 if ($ asr > $ alarm ->amount ) {
74- $ message = "MagnusBilling ALERT . The ASR is bigger than your alarm configuration " ;
78+ $ message = "MagnusBilling ALARM . The ASR is bigger than your alarm configuration " ;
7579 $ this ->notification ($ message , $ alarm );
7680 }
7781 } else if ($ alarm ->condition == 2 ) {
7882 if ($ asr < $ alarm ->amount ) {
79- $ message = "MagnusBilling ALERT . The ASR is less than your alarm configuration " ;
83+ $ message = "MagnusBilling ALARM . The ASR is less than your alarm configuration " ;
8084 $ this ->notification ($ message , $ alarm );
8185 }
8286 }
@@ -98,12 +102,12 @@ public function aloc($alarm)
98102 echo 'ALOC ' . $ aloc . "\n" ;
99103 if ($ alarm ->condition == 1 ) {
100104 if ($ aloc > $ alarm ->amount ) {
101- $ message = "MagnusBilling ALERT . The ALOC is bigger than your alarm configuration " ;
105+ $ message = "MagnusBilling ALARM . The ALOC is bigger than your alarm configuration " ;
102106 $ this ->notification ($ message , $ alarm );
103107 }
104108 } else if ($ alarm ->condition == 2 ) {
105109 if ($ aloc < $ alarm ->amount ) {
106- $ message = "MagnusBilling ALERT . The ALOC is less than your alarm configuration " ;
110+ $ message = "MagnusBilling ALARM . The ALOC is less than your alarm configuration " ;
107111 $ this ->notification ($ message , $ alarm );
108112 }
109113 }
@@ -128,12 +132,12 @@ public function callPerMin($alarm)
128132 echo 'CALLS PER MINUTE ' . $ callPerMin . "\n" ;
129133 if ($ alarm ->condition == 1 ) {
130134 if ($ callPerMin > $ alarm ->amount ) {
131- $ message = "MagnusBilling ALERT . You had more calls per minute than your alarm configuration " ;
135+ $ message = "MagnusBilling ALARM . You had more calls per minute than your alarm configuration " ;
132136 $ this ->notification ($ message , $ alarm );
133137 }
134138 } else if ($ alarm ->condition == 2 ) {
135139 if ($ callPerMin < $ alarm ->amount ) {
136- $ message = "MagnusBilling ALERT . You had less calls per minute than your alarm configuration " ;
140+ $ message = "MagnusBilling ALARM . You had less calls per minute than your alarm configuration " ;
137141 $ this ->notification ($ message , $ alarm );
138142 }
139143 }
@@ -156,12 +160,12 @@ public function consecutiveCalls($alarm)
156160
157161 if ($ alarm ->condition == 1 ) {
158162 if ($ totalConsecutiveCalls > $ alarm ->amount ) {
159- $ message = "MagnusBilling ALERT . User " . $ cdr ->idUser ->username . " dial more than $ totalConsecutiveCalls to numeber $ cdr ->calledstation " ;
163+ $ message = "MagnusBilling ALARM . User " . $ cdr ->idUser ->username . " dial more than $ totalConsecutiveCalls to numeber $ cdr ->calledstation " ;
160164 $ this ->notification ($ message , $ alarm );
161165 }
162166 } else if ($ alarm ->condition == 2 ) {
163167 if ($ totalConsecutiveCalls < $ alarm ->amount ) {
164- $ message = "MagnusBilling ALERT . User $ cdr ->id_user dial less than $ totalConsecutiveCalls to numeber $ cdr ->calledstation " ;
168+ $ message = "MagnusBilling ALARM . User $ cdr ->id_user dial less than $ totalConsecutiveCalls to numeber $ cdr ->calledstation " ;
165169 $ this ->notification ($ message , $ alarm );
166170
167171 }
@@ -182,11 +186,28 @@ public function onlineCallsSameNumber($alarm)
182186 foreach ($ modelCallOnLine as $ key => $ call ) {
183187
184188 if (($ call ->canal ) >= ($ alarm ->amount )) {
185- $ message = "MagnusBilling ALERT . Multiple online calls to the same number( " . $ call ->ndiscado . ") detected! " ;
189+ $ message = "MagnusBilling ALARM . Multiple online calls to the same number( " . $ call ->ndiscado . ") detected! " ;
186190 $ this ->notification ($ message , $ alarm );
187191 }
188192 }
189193
194+ }
195+ public function numberEqualCaller ($ alarm )
196+ {
197+ $ period = time () - $ alarm ->period ;
198+
199+ $ period = date ("Y-m-d H:i:s " , $ period );
200+
201+ $ filter = "starttime > ' $ period' " ;
202+
203+ $ sql = "SELECT COUNT(*) id, calledstation FROM pkg_cdr WHERE " . $ filter . " AND (calledstation = callerid OR SUBSTRING(calledstation,2) = callerid) " ;
204+ $ modeCdr = Call::model ()->findBySql ($ sql );
205+
206+ if (($ modeCdr ->id ) >= ($ alarm ->amount )) {
207+ $ message = "MagnusBilling ALARM. Multiple calls to the Dialled Number ( " . $ modeCdr ->calledstation . ") with the salve CallerID detected! " ;
208+ $ this ->notification ($ message , $ alarm );
209+ }
210+
190211 }
191212
192213 public function notification ($ message , $ alarm )
@@ -222,10 +243,10 @@ public function notification($message, $alarm)
222243 $ mail ->Username = $ smtp_username ;
223244 $ mail ->Password = $ smtp_password ;
224245 $ mail ->Port = $ smtp_port ;
225- $ mail ->SetFrom ($ alarm -> email , $ alarm -> email );
246+ $ mail ->SetFrom ($ modelSmtps -> username , " MagnusBilling ALARM " );
226247 $ mail ->SetLanguage ($ this ->config ['global ' ]['base_language ' ] == 'pt_BR ' ? 'br ' : $ this ->config ['global ' ]['base_language ' ]);
227248
228- $ mail ->Subject = mb_encode_mimeheader ('MagnusBilling ALERT ' );
249+ $ mail ->Subject = mb_encode_mimeheader ('MagnusBilling ALARM ' );
229250 $ mail ->AltBody = 'To view the message, please use an HTML compatible email viewer! ' ;
230251 $ mail ->MsgHTML ($ message );
231252 $ mail ->AddAddress ($ alarm ->email );
0 commit comments