diff --git a/build/MagnusBilling-current.tar.gz b/build/MagnusBilling-current.tar.gz index 5e94c3967..e0e410b8e 100644 Binary files a/build/MagnusBilling-current.tar.gz and b/build/MagnusBilling-current.tar.gz differ diff --git a/protected/components/BaseController.php b/protected/components/BaseController.php index dad2c5538..f36fb23e5 100755 --- a/protected/components/BaseController.php +++ b/protected/components/BaseController.php @@ -824,6 +824,9 @@ public function actionReport() $sort = $sort ? $firstSort . implode(',', $sort) : null; $this->sort = $this->replaceOrder(); + if ( ! strlen($this->sort)) { + $this->order = $this->attributeOrder; + } $this->select = $this->getColumnsFromReport($columns, $fieldGroup, 'pdf'); diff --git a/protected/controllers/RateProviderController.php b/protected/controllers/RateProviderController.php index b86935683..1729b0cde 100755 --- a/protected/controllers/RateProviderController.php +++ b/protected/controllers/RateProviderController.php @@ -191,7 +191,7 @@ public function importRates($values) } - $sql = "UPDATE pkg_rate_provider t JOIN pkg_prefix p ON t.dialprefix = p.prefix SET t.id_prefix = p.id, t.dialprefix = NULL, t.destination = NULL WHERE dialprefix > 0 AND p.prefix > 0"; + $sql = "UPDATE pkg_rate_provider t JOIN pkg_prefix p ON t.dialprefix = p.prefix SET t.id_prefix = p.id, t.dialprefix = NULL, t.destination = NULL WHERE dialprefix IS NOT NULL AND p.prefix > 0"; try { Yii::app()->db->createCommand($sql)->execute(); } catch (Exception $e) { @@ -203,7 +203,7 @@ public function importRates($values) } - $modelRate = RateProvider::model()->findAll('dialprefix > 0'); + $modelRate = RateProvider::model()->findAll('dialprefix IS NOT NULL'); if (isset($modelRate[0]->id)) { //check if there are more than 2000 new prefix, if yes, import using LOAD DATA. if (count($modelRate) > 2000) { @@ -226,7 +226,7 @@ public function importRates($values) } } - $sql = "UPDATE pkg_rate_provider t JOIN pkg_prefix p ON t.dialprefix = p.prefix SET t.id_prefix = p.id, t.dialprefix = NULL, t.destination = NULL WHERE dialprefix > 0"; + $sql = "UPDATE pkg_rate_provider t JOIN pkg_prefix p ON t.dialprefix = p.prefix SET t.id_prefix = p.id, t.dialprefix = NULL, t.destination = NULL WHERE dialprefix IS NOT NULL"; try { Yii::app()->db->createCommand($sql)->execute(); } catch (Exception $e) { @@ -238,7 +238,7 @@ public function importRates($values) } - RateProvider::model()->updateAll(['dialprefix' => null, 'destination' => null], 'dialprefix > 0'); + RateProvider::model()->updateAll(['dialprefix' => null, 'destination' => null], 'dialprefix IS NOT NULL'); } diff --git a/resources/asterisk/CallbackAgi.php b/resources/asterisk/CallbackAgi.php index ceed8edd6..219fa30c5 100755 --- a/resources/asterisk/CallbackAgi.php +++ b/resources/asterisk/CallbackAgi.php @@ -20,12 +20,12 @@ class CallbackAgi { - public function callbackCID($agi, $MAGNUS, $CalcAgi, $DidAgi) + public static function callbackCID($agi, $MAGNUS, $CalcAgi, $DidAgi) { $agi->verbose("MAGNUS CID CALLBACK"); $MAGNUS->agiconfig['cid_enable'] = 1; - if ($MAGNUS->dnid == 'failed' || !is_numeric($MAGNUS->dnid)) { + if ($MAGNUS->dnid == 'failed' || ! is_numeric($MAGNUS->dnid)) { $agi->verbose("Hangup becouse dnid is OutgoingSpoolFailed", 25); $MAGNUS->hangup($agi); exit; @@ -119,7 +119,7 @@ public function callback0800($agi, $MAGNUS, $CalcAgi, $DidAgi) $agi->verbose("MAGNUS 0800 CALLBACK"); - if ($MAGNUS->dnid == 'failed' || !is_numeric($MAGNUS->dnid)) { + if ($MAGNUS->dnid == 'failed' || ! is_numeric($MAGNUS->dnid)) { $agi->verbose("Hangup becouse dnid is OutgoingSpoolFailed"); $MAGNUS->hangup($agi); exit; @@ -140,7 +140,7 @@ public function callback0800($agi, $MAGNUS, $CalcAgi, $DidAgi) $sql = "SELECT * FROM pkg_sip WHERE id_user = " . $DidAgi->modelDestination[0]['id_user'] . " LIMIT 1"; $MAGNUS->modelSip = $agi->query($sql)->fetch(PDO::FETCH_OBJ); - if (!isset($MAGNUS->modelSip->id)) { + if ( ! isset($MAGNUS->modelSip->id)) { $agi->verbose("Username not have SIP ACCOUNT"); $MAGNUS->hangup($agi); return; @@ -188,7 +188,7 @@ public function callback0800($agi, $MAGNUS, $CalcAgi, $DidAgi) public static function chargeFistCall($agi, $MAGNUS, $CalcAgi, $sessiontime = 0) { - if ($MAGNUS->dnid == 'failed' || !is_numeric($MAGNUS->dnid)) { + if ($MAGNUS->dnid == 'failed' || ! is_numeric($MAGNUS->dnid)) { $agi->verbose("Hangup becouse dnid is OutgoingSpoolFailed", 25); $MAGNUS->hangup($agi); exit; diff --git a/resources/asterisk/DidAgi.php b/resources/asterisk/DidAgi.php index ccd0d2158..c6fcc1fcf 100755 --- a/resources/asterisk/DidAgi.php +++ b/resources/asterisk/DidAgi.php @@ -394,7 +394,8 @@ public function call_did(&$agi, &$MAGNUS, &$CalcAgi, $destinationIvr = false) $MAGNUS->extension = $MAGNUS->destination = $MAGNUS->dnid = $modelSip->name; - $dialResult = SipCallAgi::processCall($MAGNUS, $agi, $CalcAgi, $this->did); + $SipCallAgi = new SipCallAgi(); + $dialResult = $SipCallAgi->processCall($MAGNUS, $agi, $CalcAgi, $this->did); $dialstatus = $dialResult['dialstatus']; $answeredtime = $dialResult['answeredtime']; diff --git a/resources/asterisk/IvrAgi.php b/resources/asterisk/IvrAgi.php index 5f295a43d..6035cd1da 100755 --- a/resources/asterisk/IvrAgi.php +++ b/resources/asterisk/IvrAgi.php @@ -20,7 +20,7 @@ class IvrAgi { - public function callIvr(&$agi, &$MAGNUS, &$CalcAgi, &$DidAgi = null, $type = 'ivr') + public static function callIvr(&$agi, &$MAGNUS, &$CalcAgi, &$DidAgi = null, $type = 'ivr') { $agi->verbose("Ivr module", 5); diff --git a/resources/asterisk/MassiveCall.php b/resources/asterisk/MassiveCall.php index 330e872c7..9894715c5 100755 --- a/resources/asterisk/MassiveCall.php +++ b/resources/asterisk/MassiveCall.php @@ -20,7 +20,7 @@ class MassiveCall { - public function send($agi, &$MAGNUS, &$CalcAgi) + public static function send($agi, &$MAGNUS, &$CalcAgi) { require_once 'Tts.php'; diff --git a/resources/asterisk/PickupAgi.php b/resources/asterisk/PickupAgi.php index c8935a203..3a6d301fb 100755 --- a/resources/asterisk/PickupAgi.php +++ b/resources/asterisk/PickupAgi.php @@ -20,7 +20,7 @@ class PickupAgi { - public function execute(&$agi, &$MAGNUS) + public static function execute(&$agi, &$MAGNUS) { $sql = "SELECT * FROM pkg_sip WHERE ( name = '" . substr($MAGNUS->dnid, 2) . "' OR alias = '" . substr($MAGNUS->dnid, 2) . "' ) AND accountcode = '$MAGNUS->accountcode' LIMIT 1"; diff --git a/resources/asterisk/PortalDeVozAgi.php b/resources/asterisk/PortalDeVozAgi.php index cd88d60a6..71a9ea7de 100755 --- a/resources/asterisk/PortalDeVozAgi.php +++ b/resources/asterisk/PortalDeVozAgi.php @@ -20,7 +20,7 @@ class PortalDeVozAgi { - public function send(&$agi, &$MAGNUS, &$CalcAgi, &$DidAgi) + public static function send(&$agi, &$MAGNUS, &$CalcAgi, &$DidAgi) { $agi->answer(); $agi->verbose('PortalDeVozAgi'); @@ -31,7 +31,7 @@ public function send(&$agi, &$MAGNUS, &$CalcAgi, &$DidAgi) $sql = "SELECT * FROM pkg_sip WHERE name = '$MAGNUS->dnid' OR alias = '$MAGNUS->dnid' LIMIT 1 "; $MAGNUS->modelSip = $agi->query($sql)->fetch(PDO::FETCH_OBJ); - if (!isset($MAGNUS->modelSip->id)) { + if ( ! isset($MAGNUS->modelSip->id)) { $agi->verbose('User no found', 15); $agi->stream_file('prepaid-invalid-digits', '#'); continue; diff --git a/resources/asterisk/QueueAgi.php b/resources/asterisk/QueueAgi.php index 540b8773b..2dffd536c 100755 --- a/resources/asterisk/QueueAgi.php +++ b/resources/asterisk/QueueAgi.php @@ -20,7 +20,7 @@ class QueueAgi { - public function callQueue(&$agi, &$MAGNUS, &$CalcAgi, $DidAgi = null, $type = 'queue', $startTime = 0) + public static function callQueue(&$agi, &$MAGNUS, &$CalcAgi, $DidAgi = null, $type = 'queue', $startTime = 0) { $agi->verbose("Queue module", 5); $MAGNUS->sip_account = ''; @@ -125,7 +125,7 @@ public function callQueue(&$agi, &$MAGNUS, &$CalcAgi, $DidAgi = null, $type = 'q if ($siptransfer['data'] != 'yes' && $type == 'queue') { $CalcAgi->real_sessiontime = intval($CalcAgi->sessiontime); - if (!is_null($DidAgi)) { + if ( ! is_null($DidAgi)) { $DidAgi->billDidCall($agi, $MAGNUS, $CalcAgi->sessiontime, $CalcAgi); } diff --git a/resources/asterisk/SearchTariff.php b/resources/asterisk/SearchTariff.php index 90b8121b3..21469f27e 100755 --- a/resources/asterisk/SearchTariff.php +++ b/resources/asterisk/SearchTariff.php @@ -48,7 +48,7 @@ public function find(&$MAGNUS, &$agi) "ORDER BY LENGTH( prefix ) DESC LIMIT 1"; $result = $agi->query($sql)->fetchAll(PDO::FETCH_ASSOC); - if (!is_array($result) || count($result) == 0) { + if ( ! is_array($result) || count($result) == 0) { return 0; } diff --git a/resources/asterisk/SipCallAgi.php b/resources/asterisk/SipCallAgi.php index 37d9265e5..9489ee2b9 100755 --- a/resources/asterisk/SipCallAgi.php +++ b/resources/asterisk/SipCallAgi.php @@ -5,7 +5,7 @@ class SipCallAgi { - public function processCall(&$MAGNUS, &$agi, &$CalcAgi, $type = 'normal') + public static function processCall(&$MAGNUS, &$agi, &$CalcAgi, $type = 'normal') { if (($MAGNUS->agiconfig['use_dnid'] == 1) && (strlen($MAGNUS->dnid) > 2)) { $MAGNUS->destination = $MAGNUS->dnid; @@ -59,7 +59,7 @@ public function processCall(&$MAGNUS, &$agi, &$CalcAgi, $type = 'normal') $agi->verbose("[" . $MAGNUS->username . " Friend]:[ANSWEREDTIME=" . $answeredtime . "-DIALSTATUS=" . $dialstatus . "]", 6); - if (!preg_match('/^CANCEL|^ANSWER/', strtoupper($dialstatus))) { + if ( ! preg_match('/^CANCEL|^ANSWER/', strtoupper($dialstatus))) { $sql = "SELECT * FROM pkg_sip WHERE name = '$MAGNUS->destination' LIMIT 1 "; $modelSipForward = $agi->query($sql)->fetch(PDO::FETCH_OBJ); @@ -107,14 +107,14 @@ public function processCall(&$MAGNUS, &$agi, &$CalcAgi, $type = 'normal') $MAGNUS->hangup($agi); } else { - return array( + return [ 'dialstatus' => $dialstatus, 'answeredtime' => $answeredtime, - ); + ]; } } - public function callForward($MAGNUS, $agi, $CalcAgi, $modelSipForward) + public static function callForward($MAGNUS, $agi, $CalcAgi, $modelSipForward) { $forward = explode(("|"), $modelSipForward->forward); @@ -137,7 +137,7 @@ public function callForward($MAGNUS, $agi, $CalcAgi, $modelSipForward) $sql = "SELECT * FROM pkg_sip WHERE sip_group = '$optionValue'"; $modelSip = $agi->query($sql)->fetchAll(PDO::FETCH_OBJ); - if (!isset($modelSip[0]->id)) { + if ( ! isset($modelSip[0]->id)) { $agi->verbose('GROUP NOT FOUND'); $agi->stream_file('prepaid-invalid-digits', '#'); } @@ -195,7 +195,7 @@ public function callForward($MAGNUS, $agi, $CalcAgi, $modelSipForward) } - public function smsForward($MAGNUS, $agi, $CalcAgi, $optionValue) + public static function smsForward($MAGNUS, $agi, $CalcAgi, $optionValue) { $agi->verbose("try send SMS", 5); @@ -263,7 +263,7 @@ public function smsForward($MAGNUS, $agi, $CalcAgi, $optionValue) $agi->verbose($url); - if (!$res = @file_get_contents($url, false)) { + if ( ! $res = @file_get_contents($url, false)) { $agi->verbose("ERRO SMS -> " . $url); } diff --git a/resources/asterisk/SipTransferAgi.php b/resources/asterisk/SipTransferAgi.php index 9ebc34f03..8030a1e1d 100755 --- a/resources/asterisk/SipTransferAgi.php +++ b/resources/asterisk/SipTransferAgi.php @@ -20,7 +20,7 @@ class SipTransferAgi { - public function billing(&$MAGNUS, $agi, &$CalcAgi) + public static function billing(&$MAGNUS, $agi, &$CalcAgi) { $siptransfer = $agi->get_variable("SIPTRANSFER"); if ($siptransfer['data'] == 'yes') { diff --git a/script/installOpenSips.sh b/script/installOpenSips.sh index 3e11a9574..5673bf8df 100755 --- a/script/installOpenSips.sh +++ b/script/installOpenSips.sh @@ -206,7 +206,40 @@ set cl.column6 warning set cl.column6.width 0' > /usr/local/etc/sngreprc -echo "local0.* /var/log/opensips.log" >> /etc/rsyslog.conf +echo ' +module(load="imuxsock") # provides support for local system logging +module(load="imklog") # provides kernel logging support +$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat +$FileOwner root +$FileGroup adm +$FileCreateMode 0640 +$DirCreateMode 0755 +$Umask 0022 +$WorkDirectory /var/spool/rsyslog +$IncludeConfig /etc/rsyslog.d/*.conf +auth,authpriv.* /var/log/auth.log +*.*;auth,authpriv.none -/var/log/syslog +#cron.* /var/log/cron.log +daemon.* -/var/log/daemon.log +kern.* -/var/log/kern.log +lpr.* -/var/log/lpr.log +mail.* -/var/log/mail.log +user.* -/var/log/user.log +mail.info -/var/log/mail.info +mail.warn -/var/log/mail.warn +mail.err /var/log/mail.err +*.=debug;\ + auth,authpriv.none;\ + mail.none -/var/log/debug +*.=info;*.=notice;*.=warn;\ + auth,authpriv.none;\ + cron,daemon.none;\ + mail.none -/var/log/messages +*.emerg :omusrmsg:* +local0.* /var/log/opensips.log +' > /etc/rsyslog.conf + + systemctl restart rsyslog systemctl restart opensips diff --git a/script/opensips-3.1.cfg b/script/opensips-3.1.cfg index 43100fc60..d5cf8df29 100755 --- a/script/opensips-3.1.cfg +++ b/script/opensips-3.1.cfg @@ -12,6 +12,7 @@ server_signature=no server_header="Server: MagnusSipProxy" user_agent_header="User-Agent: Magnus SipProxy" +#/sbin/opensips -C /etc/opensips/opensips.cfg ###################################################################### ## Core Logging Parameters