diff --git a/scripts/OpenSIPS/notifyLastSessions.php b/scripts/OpenSIPS/notifyLastSessions.php index 377e1cc..373c7b7 100644 --- a/scripts/OpenSIPS/notifyLastSessions.php +++ b/scripts/OpenSIPS/notifyLastSessions.php @@ -1,21 +1,21 @@ #!/usr/bin/php -notifyLastSessions(200); } } - -?> diff --git a/scripts/OpenSIPS/purgeSIPTrace.php b/scripts/OpenSIPS/purgeSIPTrace.php index c46e3b8..a63192f 100644 --- a/scripts/OpenSIPS/purgeSIPTrace.php +++ b/scripts/OpenSIPS/purgeSIPTrace.php @@ -1,11 +1,8 @@ #!/usr/bin/php -purgeRecords(); - -?> diff --git a/scripts/OpenSIPS/purgeStalePrepaidSessions.php b/scripts/OpenSIPS/purgeStalePrepaidSessions.php index 8d8c66d..56ba8ee 100644 --- a/scripts/OpenSIPS/purgeStalePrepaidSessions.php +++ b/scripts/OpenSIPS/purgeStalePrepaidSessions.php @@ -1,75 +1,88 @@ #!/usr/bin/php -db = new DB_cdrtool; $this->db1 = new DB_cdrtool; } - function removeStaleSessions() { - $query=sprintf("select * from prepaid where active_sessions <> ''"); - + public function removeStaleSessions() + { + $query = sprintf("select * from prepaid where active_sessions <> ''"); + if (!$this->db->query($query)) { - $log=sprintf ("Database error for query '%s': %s (%s), link_id =%s, query_id =%s",$query,$this->db->Error,$this->db->Errno,$this->db->Link_ID,$this->db->Query_ID); - syslog(LOG_NOTICE,$log); + $log = sprintf( + "Database error for query '%s': %s (%s), link_id =%s, query_id =%s", + $query, + $this->db->Error, + $this->db->Errno, + $this->db->Link_ID, + $this->db->Query_ID + ); + syslog(LOG_NOTICE, $log); return 0; } $j=0; $expired=0; $removed=0; while ($this->db->next_record()) { $account_expired=0; - $active_sessions = json_decode($this->db->f('active_sessions'),true); - + $active_sessions = json_decode($this->db->f('active_sessions'), true); + if (count($active_sessions)) { $active_sessions_new=array(); - + foreach (array_keys($active_sessions) as $_session) { $expired_since=time() - $active_sessions[$_session]['timestamp'] - $active_sessions[$_session]['MaxSessionTime']; if ($expired_since > 120) { $account_expired++; - $log = sprintf ("Session %s for %s has expired since %d seconds\n", - $_session, - $active_sessions[$_session]['BillingPartyId'], - $expired_since + $log = sprintf( + "Session %s for %s has expired since %d seconds\n", + $_session, + $active_sessions[$_session]['BillingPartyId'], + $expired_since ); print $log; $expired++; } else { $active_sessions_new[$_session]=$active_sessions[$_session]; } } - + if ($account_expired) { - $query=sprintf("update prepaid set active_sessions = '%s', session_counter = '%s' where account = '%s'", - addslashes(json_encode($active_sessions_new)), - count($active_sessions_new), - addslashes($this->db->f('account')) + $query = sprintf( + "update prepaid set active_sessions = '%s', session_counter = '%s' where account = '%s'", + addslashes(json_encode($active_sessions_new)), + count($active_sessions_new), + addslashes($this->db->f('account')) ); if (!$this->db1->query($query)) { - $log=sprintf ("Database error for %s: %s (%s)",$query,$this->db1->Error,$this->db1->Errno); + $log = sprintf("Database error for %s: %s (%s)", $query, $this->db1->Error, $this->db1->Errno); print $log; } else { $removed++; } } - } $j++; } - printf ("%d prepaid accounts parsed, %d sessions were stale and %d account were updated\n", $j, $expired, $removed); + printf( + "%d prepaid accounts parsed, %d sessions were stale and %d account were updated\n", + $j, + $expired, + $removed + ); } } $PrepaidSessions = new PrepaidSessions(); $PrepaidSessions->removeStaleSessions(); - -?> diff --git a/scripts/OpenSIPS/quotaCheck.php b/scripts/OpenSIPS/quotaCheck.php index 6ecffbe..1eb5bbd 100644 --- a/scripts/OpenSIPS/quotaCheck.php +++ b/scripts/OpenSIPS/quotaCheck.php @@ -1,68 +1,70 @@ #!/usr/bin/php -checkQuota($v['UserQuotaNotify']); - $d=time()-$b; + $d = time() - $b; if ($d > 5) { - $log=sprintf("Runtime: %d s",$d); - syslog(LOG_NOTICE,$log); + $log = sprintf("Runtime: %d s", $d); + syslog(LOG_NOTICE, $log); } - } + } } -function deleteQuotaCheckLockfile($lockFile) { - if (!unlink($lockFile)) { - print "Error: cannot delete lock file $lockFile. Aborting.\n"; - syslog(LOG_NOTICE,"Error: cannot delete lock file $lockFile"); - } +function deleteQuotaCheckLockfile($lockFile) +{ + if (!unlink($lockFile)) { + print "Error: cannot delete lock file $lockFile. Aborting.\n"; + syslog(LOG_NOTICE, "Error: cannot delete lock file $lockFile"); + } } - diff --git a/scripts/OpenSIPS/quotaDailyReset.php b/scripts/OpenSIPS/quotaDailyReset.php index ab727f3..f18bed7 100644 --- a/scripts/OpenSIPS/quotaDailyReset.php +++ b/scripts/OpenSIPS/quotaDailyReset.php @@ -1,26 +1,26 @@ #!/usr/bin/php -resetDailyQuota(); - } + $Quota->resetDailyQuota(); + } } -?> diff --git a/scripts/OpenSIPS/quotaDeblock.php b/scripts/OpenSIPS/quotaDeblock.php index bbfcda7..8b3674e 100644 --- a/scripts/OpenSIPS/quotaDeblock.php +++ b/scripts/OpenSIPS/quotaDeblock.php @@ -1,66 +1,68 @@ #!/usr/bin/php -deblockAccounts(); - $d=time()-$b; - $log=sprintf("Runtime: %d s",$d); - syslog(LOG_NOTICE,$log); - } + $d = time()-$b; + $log = sprintf("Runtime: %d s", $d); + syslog(LOG_NOTICE, $log); + } } -function deleteQuotaDeblock($lockFile) { - if (!unlink($lockFile)) { - print "Error: cannot delete lock file $lockFile. Aborting.\n"; - syslog(LOG_NOTICE,"Error: cannot delete lock file $lockFile"); - } +function deleteQuotaDeblock($lockFile) +{ + if (!unlink($lockFile)) { + print "Error: cannot delete lock file $lockFile. Aborting.\n"; + syslog(LOG_NOTICE, "Error: cannot delete lock file $lockFile"); + } } - diff --git a/scripts/OpenSIPS/quotaReset.php b/scripts/OpenSIPS/quotaReset.php index 222fdb9..d2164c8 100644 --- a/scripts/OpenSIPS/quotaReset.php +++ b/scripts/OpenSIPS/quotaReset.php @@ -1,27 +1,27 @@ #!/usr/bin/php -deleteQuotaInitFlag(); - } + $Quota->deleteQuotaInitFlag(); + } } -?> diff --git a/scripts/OpenSIPS/quotaShowAccounts.php b/scripts/OpenSIPS/quotaShowAccounts.php index fa13c2b..82eea13 100644 --- a/scripts/OpenSIPS/quotaShowAccounts.php +++ b/scripts/OpenSIPS/quotaShowAccounts.php @@ -1,36 +1,33 @@ #!/usr/bin/php -showAccountsWithQuota($argv[1]); - } + $Quota->showAccountsWithQuota($argv[1]); + } } - -?> diff --git a/scripts/OpenSIPS/rotateTables.php b/scripts/OpenSIPS/rotateTables.php index 58197a4..45e0e55 100644 --- a/scripts/OpenSIPS/rotateTables.php +++ b/scripts/OpenSIPS/rotateTables.php @@ -1,24 +1,23 @@ #!/usr/bin/php -rotateTable($argv[1],$argv[2],$argv[3]); - -?> +$CDRS->rotateTable($argv[1], $argv[2], $argv[3]);