diff --git a/scripts/Cisco/importRadius.php b/scripts/Cisco/importRadius.php old mode 100644 new mode 100755 index 0ed66e6..190ffa4 --- a/scripts/Cisco/importRadius.php +++ b/scripts/Cisco/importRadius.php @@ -1,51 +1,50 @@ -#!/usr/bin/php +#!/usr/bin/env php import($argv[1], $argv[2]); print "Normalizing cdrs: "; $results = $CDRS->NormalizeCDRS(); print "$results[total] not yet normalized calls,$results[success] normalized,$results[failure] skipped\n"; } function checkArguments($argv) { $PHP_SELF = $_SERVER['PHP_SELF']; $c = count($argv); if (!count($argv) || count($argv) < 2 || count($argv) > 3) { print "Syntax: $PHP_SELF radacctFile [timezone]\n"; print "Example: $PHP_SELF /tmp/detail-20040221 Europe/Amsterdam\n"; return 0; } if (!is_readable($argv[1])) { print "Error: cannot open file $argv[1]\n"; return 0; } if ($argv[2]) { $TZfile = $path."../../timezones"; $tzones = explode("\n", file_get_contents($TZfile)); if (!in_array($argv[2], $tzones)) { print "Error: unexisting timezone $argv[2]. See timezones file for available timezones.\n"; return 0; } } return 1; } -?> diff --git a/scripts/OpenSIPS/notifyLastSessions.php b/scripts/OpenSIPS/notifyLastSessions.php old mode 100644 new mode 100755 index 373c7b7..a9e74fd --- a/scripts/OpenSIPS/notifyLastSessions.php +++ b/scripts/OpenSIPS/notifyLastSessions.php @@ -1,21 +1,21 @@ -#!/usr/bin/php +#!/usr/bin/env php notifyLastSessions(200); } } diff --git a/scripts/OpenSIPS/purgeSIPTrace.php b/scripts/OpenSIPS/purgeSIPTrace.php old mode 100644 new mode 100755 index a63192f..941ab61 --- a/scripts/OpenSIPS/purgeSIPTrace.php +++ b/scripts/OpenSIPS/purgeSIPTrace.php @@ -1,8 +1,8 @@ -#!/usr/bin/php +#!/usr/bin/env php purgeRecords(); diff --git a/scripts/OpenSIPS/purgeStalePrepaidSessions.php b/scripts/OpenSIPS/purgeStalePrepaidSessions.php old mode 100644 new mode 100755 index 56ba8ee..e7a02d8 --- a/scripts/OpenSIPS/purgeStalePrepaidSessions.php +++ b/scripts/OpenSIPS/purgeStalePrepaidSessions.php @@ -1,88 +1,88 @@ -#!/usr/bin/php +#!/usr/bin/env php db = new DB_cdrtool; $this->db1 = new DB_cdrtool; } 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); 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); 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 ); 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')) ); if (!$this->db1->query($query)) { $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 ); } } $PrepaidSessions = new PrepaidSessions(); $PrepaidSessions->removeStaleSessions(); diff --git a/scripts/OpenSIPS/quotaCheck.php b/scripts/OpenSIPS/quotaCheck.php old mode 100644 new mode 100755 index 1eb5bbd..2861eb8 --- a/scripts/OpenSIPS/quotaCheck.php +++ b/scripts/OpenSIPS/quotaCheck.php @@ -1,70 +1,70 @@ -#!/usr/bin/php +#!/usr/bin/env php checkQuota($v['UserQuotaNotify']); $d = time() - $b; if ($d > 5) { $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"); } } diff --git a/scripts/OpenSIPS/quotaDailyReset.php b/scripts/OpenSIPS/quotaDailyReset.php old mode 100644 new mode 100755 index f18bed7..1872a02 --- a/scripts/OpenSIPS/quotaDailyReset.php +++ b/scripts/OpenSIPS/quotaDailyReset.php @@ -1,26 +1,26 @@ -#!/usr/bin/php +#!/usr/bin/env php resetDailyQuota(); } } diff --git a/scripts/OpenSIPS/quotaDeblock.php b/scripts/OpenSIPS/quotaDeblock.php old mode 100644 new mode 100755 index 8b3674e..5d67712 --- a/scripts/OpenSIPS/quotaDeblock.php +++ b/scripts/OpenSIPS/quotaDeblock.php @@ -1,68 +1,68 @@ -#!/usr/bin/php +#!/usr/bin/env php deblockAccounts(); $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"); } } diff --git a/scripts/OpenSIPS/quotaReset.php b/scripts/OpenSIPS/quotaReset.php old mode 100644 new mode 100755 index d2164c8..731fae8 --- a/scripts/OpenSIPS/quotaReset.php +++ b/scripts/OpenSIPS/quotaReset.php @@ -1,27 +1,27 @@ -#!/usr/bin/php +#!/usr/bin/env php deleteQuotaInitFlag(); } } diff --git a/scripts/OpenSIPS/quotaShowAccounts.php b/scripts/OpenSIPS/quotaShowAccounts.php old mode 100644 new mode 100755 index 82eea13..3d3d1ff --- a/scripts/OpenSIPS/quotaShowAccounts.php +++ b/scripts/OpenSIPS/quotaShowAccounts.php @@ -1,33 +1,33 @@ -#!/usr/bin/php +#!/usr/bin/env php showAccountsWithQuota($argv[1]); } } diff --git a/scripts/OpenSIPS/rotateTables.php b/scripts/OpenSIPS/rotateTables.php old mode 100644 new mode 100755 index 45e0e55..23b1027 --- a/scripts/OpenSIPS/rotateTables.php +++ b/scripts/OpenSIPS/rotateTables.php @@ -1,23 +1,23 @@ -#!/usr/bin/php +#!/usr/bin/env php rotateTable($argv[1], $argv[2], $argv[3]); diff --git a/scripts/buildStatistics.php b/scripts/buildStatistics.php old mode 100644 new mode 100755 index a3a7431..2cd9195 --- a/scripts/buildStatistics.php +++ b/scripts/buildStatistics.php @@ -1,9 +1,7 @@ -#!/usr/bin/php +#!/usr/bin/env php buildStatistics(); - -?> diff --git a/scripts/generateMrtgConfig.php b/scripts/generateMrtgConfig.php old mode 100644 new mode 100755 index dec5fb6..a000ab4 --- a/scripts/generateMrtgConfig.php +++ b/scripts/generateMrtgConfig.php @@ -1,9 +1,7 @@ -#!/usr/bin/php +#!/usr/bin/env php generateMrtgConfigFile(); - -?> diff --git a/scripts/generateMrtgData.php b/scripts/generateMrtgData.php old mode 100644 new mode 100755 index 5eb8621..e8439b7 --- a/scripts/generateMrtgData.php +++ b/scripts/generateMrtgData.php @@ -1,14 +1,12 @@ -#!/usr/bin/php +#!/usr/bin/env php generateMrtgData($argv[1], $argv[2]); - -?> diff --git a/scripts/harvestStatistics.php b/scripts/harvestStatistics.php old mode 100644 new mode 100755 index 7c9b1f1..440e29b --- a/scripts/harvestStatistics.php +++ b/scripts/harvestStatistics.php @@ -1,9 +1,7 @@ -#!/usr/bin/php +#!/usr/bin/env php harvestStatistics(); - -?> diff --git a/scripts/importRatingTables.php b/scripts/importRatingTables.php old mode 100644 new mode 100755 index 55f0c27..2527ee1 --- a/scripts/importRatingTables.php +++ b/scripts/importRatingTables.php @@ -1,34 +1,32 @@ -#!/usr/bin/php +#!/usr/bin/env php ImportCSVFiles(); if ($RatingTables->mustReload) { if (!reloadRatingEngineTables()) { print "Error: cannot connect to network rating engine\n"; } } - -?> diff --git a/scripts/keepaliveRatingEngine.php b/scripts/keepaliveRatingEngine.php old mode 100644 new mode 100755 index b4ff3fd..36cec80 --- a/scripts/keepaliveRatingEngine.php +++ b/scripts/keepaliveRatingEngine.php @@ -1,7 +1,6 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/normalize.php b/scripts/normalize.php old mode 100644 new mode 100755 index 86d6e5a..957c31b --- a/scripts/normalize.php +++ b/scripts/normalize.php @@ -1,112 +1,110 @@ -#!/usr/bin/php +#!/usr/bin/env php db_class)) { $db_class = $CDRS->db_class[0]; } else { $db_class = $CDRS->db_class; } if ($table) $CDRS->table=$table; $log = sprintf("Normalize datasource %s, database %s, table %s\n", $k, $db_class, $CDRS->table); print $log; syslog(LOG_NOTICE, $log); $CDRS->NormalizeCDRS(); $e=time(); $d=$e-$b; if ($CDRS->status['cdr_to_normalize']) { $speed=0; if ($d) $speed = number_format($CDRS->status['cdr_to_normalize']/$d, 0, "", ""); $log = sprintf( " %d CDRs, %d normalized in %s s @ %s cps\n", $CDRS->status['cdr_to_normalize'], $CDRS->status['normalized'], $d, $speed ); print $log; syslog(LOG_NOTICE, $log); } if (!$table && preg_match("/^(\w+)\d{6}$/", $CDRS->table, $m)) { $lastMonthTable=$m[1].date('Ym', mktime(0, 0, 0, date("m")-1, "01", date("Y"))); $log = sprintf("Normalize datasource %s, database %s, table %s\n", $k, $db_class, $lastMonthTable); print $log; syslog(LOG_NOTICE, $log); $b=time(); $CDRS->table = $lastMonthTable; $CDRS->NormalizeCDRS(); if ($CDRS->status['cdr_to_normalize']) { $e=time(); $d=$e-$b; $speed=0; if ($d) $speed = number_format($CDRS->status['cdr_to_normalize']/$d, 0, "", ""); $log = sprintf( " %d CDRs, %d normalized in %s s @ %s cps\n", $CDRS->status['cdr_to_normalize'], $CDRS->status['normalized'], $d, $speed ); print $log; syslog(LOG_NOTICE, $log); } } } } keepAliveRatingEngine(); - -?> diff --git a/scripts/purgeTables.php b/scripts/purgeTables.php old mode 100644 new mode 100755 index 927ca5e..9fb22d6 --- a/scripts/purgeTables.php +++ b/scripts/purgeTables.php @@ -1,40 +1,38 @@ -#!/usr/bin/php +#!/usr/bin/env php purge(); print "\n"; // purge old CDRs when using a central radius table while (list($k,$v) = each($DATASOURCES)) { if (strlen($v['purgeCDRsAfter'])) { $class_name = $v["class"]; $log = sprintf("Datasource: %s\n", $v['name']); print $log; syslog(LOG_NOTICE, $log); unset($CDRS); $CDRS = new $class_name($k); if ($argv[1] && !preg_match("/^(\d{4})(\d{2})$/", $argv[1], $m)) { print "Error: Month must be in YYYYMM format\n"; continue; } else { $endDate = date('Y-m-d', time() - 3600 * 24 * $v['purgeCDRsAfter']); $log = sprintf("Purge CDRs before %s\n", $endDate); print $log; syslog(LOG_NOTICE, $log); } $CDRS->purgeTable($argv[1]); print "\n"; } } - -?> diff --git a/scripts/ratingEngine.php b/scripts/ratingEngine.php old mode 100644 new mode 100755 index 0453b22..468ea43 --- a/scripts/ratingEngine.php +++ b/scripts/ratingEngine.php @@ -1,41 +1,39 @@ -#!/usr/bin/php +#!/usr/bin/env php init_ok) { syslog(LOG_NOTICE, 'Error: Cannot start Rating Engine, fix the errors and try again'); exit; } syslog(LOG_NOTICE, "Rating Engine started sucesfully, going to background..."); // Go to the background $d = new Daemon('/var/run/ratingEngine.pid'); $d->start(); $daemon = new socketDaemon(); $server = $daemon->create_server( 'ratingEngineServer', 'ratingEngineClient', $RatingEngine['socketIP'], $RatingEngine['socketPort'] ); syslog(LOG_NOTICE, "Rating Engine is now ready to serve network requests"); $daemon->process(); - -?> diff --git a/scripts/reloadRatingTables.php b/scripts/reloadRatingTables.php old mode 100644 new mode 100755 index 2d22f9d..2dafe51 --- a/scripts/reloadRatingTables.php +++ b/scripts/reloadRatingTables.php @@ -1,16 +1,15 @@ -#!/usr/bin/php +#!/usr/bin/env php diff --git a/scripts/splitRatingTables.php b/scripts/splitRatingTables.php old mode 100644 new mode 100755 index 7af984e..3acd077 --- a/scripts/splitRatingTables.php +++ b/scripts/splitRatingTables.php @@ -1,9 +1,7 @@ -#!/usr/bin/php +#!/usr/bin/env php splitRatingTable(); - -?> diff --git a/scripts/testRatingTables.php b/scripts/testRatingTables.php old mode 100644 new mode 100755 index 3336992..ff2f59c --- a/scripts/testRatingTables.php +++ b/scripts/testRatingTables.php @@ -1,7 +1,6 @@ -#!/usr/bin/php +#!/usr/bin/env php