[Astpp-commit] SF.net SVN: astpp:[2204] trunk
Brought to you by:
darrenkw
|
From: <dar...@us...> - 2008-11-11 19:05:47
|
Revision: 2204
http://astpp.svn.sourceforge.net/astpp/?rev=2204&view=rev
Author: darrenkw
Date: 2008-11-11 19:05:42 +0000 (Tue, 11 Nov 2008)
Log Message:
-----------
Added support to view and delete Freeswitch SIP users from within the interface.
Modified Paths:
--------------
trunk/astpp-admin.cgi
trunk/astpp-common.pl
trunk/astpp-users.cgi
trunk/modules/ASTPP/lib/ASTPP.pm
Added Paths:
-----------
trunk/sql/astpp-2008-10-31.sql
Modified: trunk/astpp-admin.cgi
===================================================================
--- trunk/astpp-admin.cgi 2008-11-08 04:36:02 UTC (rev 2203)
+++ trunk/astpp-admin.cgi 2008-11-11 19:05:42 UTC (rev 2204)
@@ -99,8 +99,7 @@
gettext("View Card"), gettext("Update Card(s) Status"),
gettext("Reset InUse"), gettext("CC Brands")
);
-my @SwitchConfig =
- ( gettext("IAX Devices"), gettext("SIP Devices"), gettext("Dialplan") );
+my @SwitchConfig = ();
my @CallShops = ( gettext("Create CallShop"), gettext("Remove CallShop") );
my @Booths = (
gettext("Create Booth"), gettext("Remove Booth"),
@@ -398,11 +397,13 @@
return &build_refill_card()
if $params->{mode} eq gettext("Refill Card");
return &build_sip_devices()
- if $params->{mode} eq gettext("SIP Devices");
+ if $params->{mode} eq gettext("Asterisk(TM) SIP Devices");
return &build_iax_devices()
- if $params->{mode} eq gettext("IAX Devices");
+ if $params->{mode} eq gettext("Asterisk(TM) IAX Devices");
return &build_dialplan()
- if $params->{mode} eq gettext("Dialplan");
+ if $params->{mode} eq gettext("Asterisk(TM) Dialplan");
+ return &build_freeswitch_sip_devices()
+ if $params->{mode} eq gettext("Freeswitch(TM) SIP Devices");
return &build_stats_acd()
if $params->{mode} eq gettext("Trunk stats");
return &build_stats_acd()
@@ -462,9 +463,9 @@
return &build_dids()
if $params->{mode} eq gettext("DIDs");
return &build_sip_devices()
- if $params->{mode} eq gettext("SIP Devices");
+ if $params->{mode} eq gettext("Asterisk(TM) SIP Devices");
return &build_iax_devices()
- if $params->{mode} eq gettext("IAX Devices");
+ if $params->{mode} eq gettext("Asterisk(TM) IAX Devices");
return &build_packages() if $params->{mode} eq gettext("Packages");
return &build_counters() if $params->{mode} eq gettext("Counters");
return &build_statistics()
@@ -1942,6 +1943,21 @@
push(@account_device_list, \%row);
}
}
+ if ($fs_db) {
+ my (@sip_devices);
+ @sip_devices = $ASTPP->fs_list_sip_usernames( cc => $accountinfo->{cc}, accountcode => $accountinfo->{number});
+ foreach my $record (@sip_devices) {
+ print STDERR $record->{username};
+ my $deviceinfo = &get_sip_account_freeswitch($fs_db,$config,$record->{id});
+ my %row;
+ $row{tech} = "SIP";
+ $row{type} = "user@" . $record->{domain};
+ $row{username} = $record->{username};
+ $row{secret} = $deviceinfo->{password};
+ $row{context} = $deviceinfo->{context};
+ push(@account_device_list, \%row);
+ }
+ }
if ($freepbx_db) {
my @sip_names = &list_sip_account_freepbx($freepbx_db,$config,$accountinfo->{number}, $accountinfo->{cc});
my @iax_names = &list_iax_account_freepbx($freepbx_db,$config,$accountinfo->{number}, $accountinfo->{cc});
@@ -2267,6 +2283,18 @@
);
$status .= "<br>";
}
+ if ( $config->{users_dids_freeswitch} == 1 ) {
+ my $name =
+ &finduniquesip_freeswitch( $fs_db, $config,
+ $params->{number} );
+ $status .= &add_sip_user_freeswitch(
+ $fs_db, $config, $name,
+ $params->{accountpassword},
+ $params->{number}, $params,
+ $accountinfo->{cc}
+ );
+ $status .= "<br>";
+ }
}
if ( $params->{IAX2} ) {
$config->{rt_iax_type} = $params->{devicetype};
@@ -8389,7 +8417,7 @@
{
$body .=
"</td><td><a href=\"astpp-admin.cgi?mode="
- . gettext("SIP Devices")
+ . gettext("Asterisk(TM) SIP Devices")
. "&action="
. gettext("Edit...")
. "&devicenumber="
@@ -9291,11 +9319,15 @@
}
if ( $config->{users_dids_rt} == 1 ) {
$rt_db = &rt_connect_db( $config, @output );
- push @modes, gettext("Switch Config");
}
if ( $config->{users_dids_amp} == 1 ) {
$freepbx_db = &freepbx_connect_db( $config, @output );
}
+ if ( $config->{users_dids_freeswitch} == 1 ) {
+ $fs_db = &connect_freeswitch_db( $config, @output );
+ $ASTPP->set_freeswitch_db($fs_db);
+ }
+
if ( $config->{callingcards} == 1 ) {
push @modes, gettext("Calling Cards");
}
@@ -9305,6 +9337,38 @@
$ASTPP->set_cdr_db($cdr_db);
}
+
+############### Freeswitch SIP Device handling ##############################
+sub build_freeswitch_sip_devices(){
+ return gettext("Database is NOT configured!") . "\n" unless $astpp_db;
+ my (@device_list,@sip_devices);
+ my $template = HTML::Template->new(
+ filename => '/var/lib/astpp/templates/freeswitch-sip-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
+ if ($params->{action} eq "Delete...") {
+ $ASTPP->fs_delete_sip_user(id => $params->{directory_id} );
+ $status = gettext("SIP Device:") . " " . $params->{directory_id} . " " . gettext("Removed Successfully!");
+ }
+
+ @sip_devices = $ASTPP->fs_list_sip_usernames();
+ foreach my $record (@sip_devices) {
+ my $deviceinfo = &get_sip_account_freeswitch($fs_db,$config,$record->{id});
+ my %row;
+ $row{directory_id} = $record->{id};
+ $row{tech} = "SIP";
+ $row{type} = "user@" . $record->{domain};
+ $row{username} = $record->{username};
+ $row{password} = $deviceinfo->{password};
+ $row{vmpassword} = $deviceinfo->{vmpassword};
+ $row{context} = $deviceinfo->{context};
+ $row{accountcode} = $deviceinfo->{accountcode};
+ push(@device_list, \%row);
+ }
+ $template->param( device_list => \@device_list );
+ $template->param( status => $status );
+ return $template->output;
+}
+
+
############### Integration with Realtime starts here #######################
sub build_sip_devices() {
my (
@@ -9425,7 +9489,7 @@
. "</td><td>"
. gettext("IP Address")
. "</td><td>"
- . hidden( -name => "mode", -value => gettext("SIP Devices") )
+ . hidden( -name => "mode", -value => gettext("Asterisk(TM) SIP Devices") )
. "</td></tr>
<tr class=\"rowone\"><td>"
. popup_menu(
@@ -9498,7 +9562,7 @@
. "</td><td>"
. gettext("Host")
. "</td><td>"
- . hidden( -name => "mode", -value => gettext("SIP Devices") )
+ . hidden( -name => "mode", -value => gettext("Asterisk(TM) SIP Devices") )
. hidden(
-name => "devicenumber",
-value => $deviceinfo->{id}
@@ -9638,7 +9702,7 @@
$body = start_form
. "<table class=\"default\">"
. "<tr class=\"header\"><td>"
- . hidden( -name => "mode", -value => gettext("SIP Devices") )
+ . hidden( -name => "mode", -value => gettext("Asterisk(TM) SIP Devices") )
. submit( -name => "action", -value => gettext("Add...") )
. "</td></tr>
"
@@ -9702,14 +9766,14 @@
. "</td><td>$deviceinfo->{type}"
. "</td><td>$deviceinfo->{secret}"
. "</td><td><a href=\"astpp-admin.cgi?mode="
- . gettext("SIP Devices")
+ . gettext("Asterisk(TM) SIP Devices")
. "&action="
. gettext("Edit...")
. "&devicename="
. $deviceinfo->{name} . "\">"
. gettext("Edit...") . "</a>"
. " <a href=\"astpp-admin.cgi?mode="
- . gettext("SIP Devices")
+ . gettext("Asterisk(TM) SIP Devices")
. "&action="
. gettext("Delete...")
. "&devicename="
@@ -9725,7 +9789,7 @@
if ( $params->{limit} != 0 ) {
$body .=
"<a href=\"astpp-admin.cgi?mode="
- . gettext("SIP Devices")
+ . gettext("Asterisk(TM) SIP Devices")
. "&limit=0\">";
$body .= $i + 1;
$body .= "</a>";
@@ -9738,7 +9802,7 @@
if ( $params->{limit} != ( $i * $results_per_page ) ) {
$body .=
"<a href=\"astpp-admin.cgi?mode="
- . gettext("SIP Devices")
+ . gettext("Asterisk(TM) SIP Devices")
. "&limit=";
$body .= ( $i * $results_per_page );
$body .= "\">\n";
@@ -9889,7 +9953,7 @@
. "</td><td>"
. gettext("IP Address")
. "</td><td>"
- . hidden( -name => "mode", -value => gettext("IAX Devices") )
+ . hidden( -name => "mode", -value => gettext("Asterisk(TM) IAX Devices") )
. "</td></tr>
<tr class=\"rowone\"><td>"
. popup_menu(
@@ -9962,7 +10026,7 @@
. "</td><td>"
. gettext("Host")
. "</td><td>"
- . hidden( -name => "mode", -value => gettext("IAX Devices") )
+ . hidden( -name => "mode", -value => gettext("Asterisk(TM) IAX Devices") )
. hidden(
-name => "devicenumber",
-value => $deviceinfo->{name}
@@ -10070,7 +10134,7 @@
$body = start_form
. "<table class=\"default\">"
. "<tr class=\"header\"><td>"
- . hidden( -name => "mode", -value => gettext("IAX Devices") )
+ . hidden( -name => "mode", -value => gettext("Asterisk(TM) IAX Devices") )
. submit( -name => "action", -value => gettext("Add...") )
. "</td></tr>
"
@@ -10131,14 +10195,14 @@
. "</td><td>$deviceinfo->{type}"
. "</td><td>$deviceinfo->{secret}"
. "</td><td><a href=\"astpp-admin.cgi?mode="
- . gettext("IAX Devices")
+ . gettext("Asterisk(TM) IAX Devices")
. "&action="
. gettext("Edit...")
. "&devicename="
. $deviceinfo->{name} . "\">"
. gettext("Edit...") . "</a>"
. " <a href=\"astpp-admin.cgi?mode="
- . gettext("IAX Devices")
+ . gettext("Asterisk(TM) IAX Devices")
. "&action="
. gettext("Delete...")
. "&devicename="
@@ -10154,7 +10218,7 @@
if ( $params->{limit} != 0 ) {
$body .=
"<a href=\"astpp-admin.cgi?mode="
- . gettext("IAX Devices")
+ . gettext("Asterisk(TM) IAX Devices")
. "&limit=0\">";
$body .= $i + 1;
$body .= "</a>";
@@ -10167,7 +10231,7 @@
if ( $params->{limit} != ( $i * $results_per_page ) ) {
$body .=
"<a href=\"astpp-admin.cgi?mode="
- . gettext("IAX Devices")
+ . gettext("Asterisk(TM) IAX Devices")
. "&limit=";
$body .= ( $i * $results_per_page );
$body .= "\">\n";
@@ -10300,7 +10364,7 @@
. "</td><td>"
. gettext("App Data")
. "</td><td>"
- . hidden( -name => "mode", -value => gettext("Dialplan") )
+ . hidden( -name => "mode", -value => gettext("Asterisk(TM) Dialplan") )
. "<td></tr>
<tr class=\"rowone\"><td>"
. textfield(
@@ -10360,7 +10424,7 @@
. "</td><td>"
. gettext("App Data")
. "</td><td>"
- . hidden( -name => "mode", -value => gettext("Dialplan") )
+ . hidden( -name => "mode", -value => gettext("Asterisk(TM) Dialplan") )
. hidden(
-name => "id",
-value => $params->{id}
@@ -10409,7 +10473,7 @@
$body = start_form
. "<table class=\"default\">"
. "<tr class=\"header\"><td>"
- . hidden( -name => "mode", -value => gettext("Dialplan") )
+ . hidden( -name => "mode", -value => gettext("Asterisk(TM) Dialplan") )
. submit( -name => "action", -value => gettext("Add...") )
. "</td></tr>
"
@@ -10464,13 +10528,13 @@
. "</td><td>$exteninfo->{app}"
. "</td><td>$exteninfo->{appdata}"
. "</td><td><a href=\"astpp-admin.cgi?mode="
- . gettext("Dialplan")
+ . gettext("Asterisk(TM) Dialplan")
. "&action="
. gettext("Edit...") . "&id="
. $exteninfo->{id} . "\">"
. gettext("Edit...") . "</a>"
. " <a href=\"astpp-admin.cgi?mode="
- . gettext("Dialplan")
+ . gettext("Asterisk(TM) Dialplan")
. "&action="
. gettext("Delete...") . "&id="
. $exteninfo->{id} . "\">"
@@ -10485,7 +10549,7 @@
if ( $params->{limit} != 0 ) {
$body .=
"<a href=\"astpp-admin.cgi?mode="
- . gettext("Dialplan")
+ . gettext("Asterisk(TM) Dialplan")
. "&limit=0\">";
$body .= $i + 1;
$body .= "</a>";
@@ -10498,7 +10562,7 @@
if ( $params->{limit} != ( $i * $results_per_page ) ) {
$body .=
"<a href=\"astpp-admin.cgi?mode="
- . gettext("Dialplan")
+ . gettext("Asterisk(TM) Dialplan")
. "&limit=";
$body .= ( $i * $results_per_page );
$body .= "\">\n";
@@ -11305,8 +11369,14 @@
if ( $config->{enablelcr} == 1 ) {
push @modes, gettext("LCR");
}
- if ( $config->{users_dids_rt} == 1 ) {
+ if ( $config->{users_dids_rt} == 1 || $config->{users_dids_freeswitch} == 1 ) {
push @modes, gettext("Switch Config");
+ if ( $config->{users_dids_rt} == 1 ) {
+ push @SwitchConfig, ( gettext("Asterisk(TM) IAX Devices"), gettext("Asterisk(TM) SIP Devices"), gettext("Asterisk(TM) Dialplan") );
+ }
+ if ( $config->{users_dids_freeswitch} == 1 ) {
+ push @SwitchConfig, ( gettext("Freeswitch(TM) SIP Devices") );
+ }
}
if ( $config->{callingcards} == 1 ) {
push @modes, gettext("Calling Cards");
Modified: trunk/astpp-common.pl
===================================================================
--- trunk/astpp-common.pl 2008-11-08 04:36:02 UTC (rev 2203)
+++ trunk/astpp-common.pl 2008-11-11 19:05:42 UTC (rev 2204)
@@ -2656,6 +2656,162 @@
}
####### OpenSER Integration Ends ###############
+####### Freeswitch Integration Starts ###############
+
+sub get_sip_account_freeswitch(){
+ my ($fs_db,$config,$directory_id) = @_;
+ my ($tmp,$record,$sql,$deviceinfo);
+ $tmp = "SELECT var_value FROM directory_vars WHERE directory_id = "
+ . $fs_db->quote($directory_id)
+ . " AND var_name = 'user_context'";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $fs_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{context} = $record->{var_value};
+
+ $tmp = "SELECT param_value FROM directory_params WHERE directory_id = "
+ . $fs_db->quote($directory_id)
+ . " AND param_name = 'password' LIMIT 1";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $fs_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{password} = $record->{param_value};
+
+ $tmp = "SELECT param_value FROM directory_params WHERE directory_id = "
+ . $fs_db->quote($directory_id)
+ . " AND param_name = 'vm-password' LIMIT 1";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $fs_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{vmpassword} = $record->{param_value};
+
+ $tmp = "SELECT var_value FROM directory_vars WHERE directory_id = "
+ . $fs_db->quote($directory_id)
+ . " AND var_name = 'accountcode' LIMIT 1";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $fs_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{accountcode} = $record->{var_value};
+
+
+ return $deviceinfo;
+}
+
+
+# Return a list of sip devices belong to a specific account
+sub list_sip_account_freeswitch() {
+ my ( $fs_db, $config, $name, $cc) = @_;
+ my ($tmp, $row, $sql, @devicelist);
+ if ($config->{debug} == 1) {
+ print STDERR "NAME: $name";
+ print STDERR "CC: $cc";
+ }
+ $tmp = "select directory_id from directory_vars where var_name = 'accountcode' and var_value IN ("
+ . $fs_db->quote($name) . ","
+ . $fs_db->quote($cc) . ")";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $fs_db->prepare($tmp);
+ $sql->execute;
+ while ( $row = $sql->fetchrow_hashref ) {
+ push @devicelist, $row->{directory_id};
+ }
+ $sql->finish;
+ return @devicelist;
+}
+
+# Check to see if a SIP account already exists in ATSPP. The first 5 digits of the device ID are random followed by a dash
+# and then the accountcode.
+sub finduniquesip_freeswitch() {
+ my ($fs_db, $config, $name) = @_;
+ my ( $cc, $sql, $count, $sipid, $record );
+ for ( ; ; ) {
+ $count = 1;
+ $sipid =
+ int( rand() * 9000 + 1000 )
+ . int( rand() * 9000 + 1000 )
+ . int( rand() * 9000 + 1000 )
+ . int( rand() * 9000 + 1000 )
+ . int( rand() * 9000 + 1000 )
+ . int( rand() * 9000 + 1000 )
+ . int( rand() * 9000 + 1000 )
+ . int( rand() * 9000 + 1000 );
+ $sipid = $config->{sip_ext_prepend} . $sipid;
+ $sipid = substr( $sipid, 0, 5 );
+ $sipid = $name . $sipid;
+ print STDERR "SIPID: $sipid\n" if $config->{debug} == 1;
+ $sql =
+ $fs_db->prepare(
+ "SELECT COUNT(*) FROM directory WHERE username = "
+ . $fs_db->quote($sipid) );
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $count = $record->{"COUNT(*)"};
+ $sql->finish;
+ return $sipid if ( $count == 0 );
+ }
+}
+
+
+# Add a SIP user to the FreeSwitch DB.
+sub add_sip_user_freeswitch() {
+ my ( $fs_db, $config, $name, $secret, $username,
+ $params,$cc )
+ = @_;
+ my ( $md5secret, $tmp, $id, $appdata );
+ $name =~ s/\W//mg;
+ $username =~ s/\W//mg;
+ if ( $config->{debug} == 1 ) {
+ print STDERR "NAME: $name\n";
+ print STDERR "USERNAME: $username\n";
+ print STDERR "SECRET: $secret\n";
+ }
+ $tmp =
+ "INSERT INTO directory (username,domain) VALUES ("
+ . $fs_db->quote($name) . ", "
+ . $fs_db->quote($config->{freeswitch_domain}). ")";
+ if ( $config->{debug} == 1 ) {
+ print STDERR " $tmp \n";
+ }
+ my $sql = $fs_db->prepare($tmp);
+ if ( !$sql->execute ) {
+ print "$tmp failed";
+ return gettext("SIP Device Creation Failed!");
+ }
+ else {
+ my $directory_id = $sql->{'mysql_insertid'};
+ $fs_db->do("INSERT INTO directory_vars (directory_id,var_name,var_value) VALUES ("
+ . $fs_db->quote($directory_id) . ","
+ . "'accountcode',"
+ . $fs_db->quote($username) . ")");
+
+ $fs_db->do("INSERT INTO directory_vars (directory_id,var_name,var_value) VALUES ("
+ . $fs_db->quote($directory_id) . ","
+ . "'user_context',"
+ . $fs_db->quote($config->{freeswitch_context}) . ")");
+
+ $fs_db->do("INSERT INTO directory_params (directory_id,param_name,param_value) VALUES ("
+ . $fs_db->quote($directory_id) . ","
+ . "'vm-password',"
+ . $fs_db->quote($secret) . ")");
+
+ $fs_db->do("INSERT INTO directory_params (directory_id,param_name,param_value) VALUES ("
+ . $fs_db->quote($directory_id) . ","
+ . "'password',"
+ . $fs_db->quote($secret) . ")");
+
+ return gettext("SIP Device Added!") . gettext("Username:") . " " . $name . " " . gettext("Password:") . " " . $secret;
+ }
+}
+
+####### Freeswitch Integration ends ###############
####### FreePBX subroutines start here ###########
sub get_iax_account_freepbx(){
Modified: trunk/astpp-users.cgi
===================================================================
--- trunk/astpp-users.cgi 2008-11-08 04:36:02 UTC (rev 2203)
+++ trunk/astpp-users.cgi 2008-11-11 19:05:42 UTC (rev 2204)
@@ -175,17 +175,15 @@
sub build_callback() {
my ( $body, $pstn, $voip );
if ( $params->{action} eq gettext("Place Call") ) {
-
- # my $out = new Asterisk::Outgoing;
- # $out->setvariable( "Channel", "$channel" );
- # $out->setvariable( "MaxRetries", "0" );
- # $out->setvariable( "context", "$context" );
- # $out->setvariable( "extension", "$extension" );
- # $out->setvariable( "CallerID", "$outgoingclid $clidnumber" );
- # $out->setvariable( "Account", "$params->{username}" );
- # $out->outtime( time() + 15 );
- # $out->create_outgoing;
- # $AGI->stream_file("callback-confirmed");
+ my $out = new Asterisk::Outgoing;
+ $out->setvariable( "Channel", "$channel" );
+ $out->setvariable( "MaxRetries", "0" );
+ $out->setvariable( "context", "$context" );
+ $out->setvariable( "extension", "$extension" );
+ $out->setvariable( "CallerID", "$outgoingclid $clidnumber" );
+ $out->setvariable( "Account", "$params->{username}" );
+ $out->outtime( time() + 15 );
+ $out->create_outgoing;
}
$voip = gettext("VOIP Route");
$pstn = gettext("PSTN Route");
Modified: trunk/modules/ASTPP/lib/ASTPP.pm
===================================================================
--- trunk/modules/ASTPP/lib/ASTPP.pm 2008-11-08 04:36:02 UTC (rev 2203)
+++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-11-11 19:05:42 UTC (rev 2204)
@@ -193,6 +193,97 @@
return $arg{xml};
}
+sub fs_delete_sip_user
+#Delete the SIP user
+#id = directory.id to delete
+{
+ my ($self, %arg) = @_;
+ my ($tmp,$sql,@results);
+ $tmp = "DELETE FROM directory WHERE id = " . $self->{_freeswitch_db}->quote($arg{id});
+ $self->{_freeswitch_db}->do($tmp);
+ $tmp = "DELETE FROM directory_vars WHERE directory_id = " . $self->{_freeswitch_db}->quote($arg{id});
+ $self->{_freeswitch_db}->do($tmp);
+ $tmp = "DELETE FROM directory_params WHERE directory_id = " . $self->{_freeswitch_db}->quote($arg{id});
+ $self->{_freeswitch_db}->do($tmp);
+ return 0;
+}
+
+sub fs_list_sip_usernames
+#Return an array with a list of appropriate sip devices.
+#accountcode = accountcode
+#domain = SIP Domain
+#ip = IP address that user is connecting from
+#user = SIP Username
+#cc = Callingcard number tagged to each account
+#accountcode = accountcode
+{
+ my ($self, %arg) = @_;
+ my ($tmp,$sql,@results);
+ if ($arg{accountcode} || $arg{cc}) {
+ $tmp = "SELECT directory.id AS id, directory.username AS username, directory.domain AS domain FROM "
+ . "directory,directory_vars WHERE directory.id = directory_vars.directory_id "
+ . "AND directory_vars.var_name = 'accountcode' "
+ . "AND directory_vars.var_value IN ("
+ . $self->{_freeswitch_db}->quote($arg{accountcode})
+ . "," . $self->{_freeswitch_db}->quote($arg{cc}) . ")";
+ } else {
+ $tmp = "SELECT id,username,domain FROM directory ";
+ if ($arg{user}) {
+ $tmp .= " WHERE username = " . $self->{_freeswitch_db}->quote($arg{user});
+ if ($arg{domain}) {
+ $tmp .= " AND domain = "
+ . $self->{_freeswitch_db}->quote($arg{domain});
+ }
+ } else {
+ if ($arg{domain}) {
+ $tmp .= " WHERE domain = "
+ . $self->{_freeswitch_db}->quote($arg{domain});
+ }
+ }
+ }
+ print STDERR $tmp;
+ $sql = $self->{_freeswitch_db}->prepare($tmp);
+ $sql->execute;
+ while (my $record = $sql->fetchrow_hashref) {
+ print STDERR $record->{username};
+ push @results, $record;
+ }
+ $sql->finish;
+ return @results;
+}
+
+sub fs_list_sip_params
+#Return the list of parameters set on a freeswitch sip account
+{
+ my ($self, $id) = @_;
+ my ($tmp,$sql,@results);
+ $tmp = "SELECT * FROM directory_params WHERE directory_id = "
+ . $self->{_freeswitch_db}->quote($id);
+ $sql = $self->{_freeswitch_db}->prepare($tmp);
+ $sql->execute;
+ while (my $record = $sql->fetchrow_hashref) {
+ push @results, $record;
+ }
+ $sql->finish;
+ return @results;
+}
+
+sub fs_list_sip_vars
+#Return the list of variables set on a freeswitch sip account
+{
+ my ($self, $id) = @_;
+ my ($tmp,$sql,@results);
+ $tmp = "SELECT * FROM directory_vars WHERE directory_id = "
+ . $self->{_freeswitch_db}->quote($id);
+ $sql = $self->{_freeswitch_db}->prepare($tmp);
+ $sql->execute;
+ while (my $record = $sql->fetchrow_hashref) {
+ push @results, $record;
+ }
+ $sql->finish;
+ return @results;
+}
+
sub fs_directory_xml
#Return the user detail lines for Freeswitch(TM) sip athentication.
#xml = Current XML code
@@ -203,37 +294,20 @@
my ($self, %arg) = @_;
my ($sql,$sql1,$tmp,$tmp1);
$arg{xml} .= "<domain name=\"" . $arg{domain} . "\">";
- $tmp = "SELECT * FROM directory WHERE username = "
- . $self->{_freeswitch_db}->quote($arg{user});
-# . " AND domain = "
-# . $self->{_freeswitch_db}->quote($arg{domain});
- print STDERR $tmp . "\n";
- $sql = $self->{_freeswitch_db}->prepare($tmp);
- $sql->execute;
- while (my $record = $sql->fetchrow_hashref) {
+ my @sip_users = &fs_list_sip_usernames($self,%arg);
+ foreach my $record (@sip_users) {
$arg{xml} .= "<user id=\"" . $record->{username} . "\" mailbox=\"" . $record->{mailbox} . "\">\n";
$arg{xml} .= "<params>\n";
- my $tmp1 = "SELECT * FROM directory_params WHERE directory_id = "
- . $self->{_freeswitch_db}->quote($record->{id});
- print STDERR $tmp1 . "\n";
- $sql1 = $self->{_freeswitch_db}->prepare($tmp1);
- $sql1->execute;
- while (my $record = $sql1->fetchrow_hashref) {
+ my @params = &fs_list_sip_params($self,$record->{id});
+ foreach my $record (@params) {
$arg{xml} .= "<param name=\"" . $record->{param_name} . "\" value=\"" . $record->{param_value} . "\"/>\n";
}
- $sql1->finish;
$arg{xml} .= "</params>\n";
$arg{xml} .= "<variables>\n";
-
- print STDERR $tmp1 . "\n";
- $tmp1 = "SELECT * FROM directory_vars WHERE directory_id = "
- . $self->{_freeswitch_db}->quote($record->{id});
- $sql1 = $self->{_freeswitch_db}->prepare($tmp1);
- $sql1->execute;
- while (my $record = $sql1->fetchrow_hashref) {
- $arg{xml} .= "<variable name=\"" .$record->{var_name} . "\" value=\"" . $record->{var_value} . "\"/>\n";
+ my @vars = &fs_list_sip_vars($self,$record->{id});
+ foreach my $record (@vars) {
+ $arg{xml} .= "<variable name=\"" . $record->{varm_name} . "\" value=\"" . $record->{var_value} . "\"/>\n";
}
- $sql1->finish;
$arg{xml} .= "</variables>\n";
$arg{xml} .= "</user>\n";
};
Added: trunk/sql/astpp-2008-10-31.sql
===================================================================
--- trunk/sql/astpp-2008-10-31.sql (rev 0)
+++ trunk/sql/astpp-2008-10-31.sql 2008-11-11 19:05:42 UTC (rev 2204)
@@ -0,0 +1,1298 @@
+DROP TABLE IF EXISTS `routes`;
+CREATE TABLE routes (
+id INTEGER NOT NULL AUTO_INCREMENT,
+pattern CHAR(40),
+comment CHAR(80),
+connectcost INTEGER NOT NULL,
+includedseconds INTEGER NOT NULL,
+cost INTEGER NOT NULL,
+pricelist CHAR(80),
+inc INTEGER,
+reseller CHAR(50) default NULL,
+precedence INT(4) NOT NULL DEFAULT 0,
+status INTEGER NOT NULL DEFAULT 1,
+PRIMARY KEY (`id`),
+KEY `pattern` (`pattern`),
+KEY `pricelist` (`pricelist`),
+KEY `reseller` (`reseller`),
+KEY `status` (`status`)
+);
+
+DROP TABLE IF EXISTS `pricelists`;
+CREATE TABLE pricelists (
+name CHAR(40) NOT NULL,
+markup INTEGER NOT NULL DEFAULT 0,
+inc INTEGER NOT NULL DEFAULT 0,
+status INTEGER DEFAULT 1 NOT NULL,
+reseller CHAR(50) default NULL,
+PRIMARY KEY (`name`)
+);
+
+DROP TABLE IF EXISTS `callingcardbrands`;
+CREATE TABLE callingcardbrands (
+name CHAR(40) NOT NULL,
+reseller CHAR(40) NOT NULL DEFAULT '',
+language CHAR(10) NOT NULL DEFAULT '',
+pricelist CHAR(40) NOT NULL DEFAULT '',
+status INTEGER DEFAULT 1 NOT NULL,
+validfordays CHAR(4) NOT NULL DEFAULT '',
+pin INTEGER NOT NULL DEFAULT 0,
+maint_fee_pennies INTEGER NOT NULL DEFAULT 0,
+maint_fee_days INTEGER NOT NULL DEFAULT 0,
+disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0,
+minute_fee_minutes INTEGER NOT NULL DEFAULT 0,
+minute_fee_pennies INTEGER NOT NULL DEFAULT 0,
+min_length_minutes INTEGER NOT NULL DEFAULT 0,
+min_length_pennies INTEGER NOT NULL DEFAULT 0,
+PRIMARY KEY (`name`),
+ KEY `reseller` (`reseller`),
+ KEY `pricelist` (`pricelist`)
+);
+
+DROP TABLE IF EXISTS `callingcardcdrs`;
+CREATE TABLE callingcardcdrs (
+id INTEGER NOT NULL AUTO_INCREMENT,
+cardnumber CHAR(50) NOT NULL DEFAULT '',
+clid CHAR(80) NOT NULL DEFAULT '',
+destination CHAR(40) NOT NULL DEFAULT '',
+disposition CHAR(20)NOT NULL DEFAULT '',
+callstart CHAR(40) NOT NULL DEFAULT '',
+seconds INTEGER NOT NULL DEFAULT 0,
+debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000,
+credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000,
+status INTEGER DEFAULT 0 NOT NULL,
+uniqueid VARCHAR(32) NOT NULL DEFAULT '',
+notes CHAR(80) NOT NULL DEFAULT '',
+pricelist CHAR(80) NOT NULL DEFAULT '',
+pattern CHAR(80) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`),
+ KEY `cardnumber` (`cardnumber`)
+);
+
+DROP TABLE IF EXISTS `trunks`;
+CREATE TABLE trunks (
+name VARCHAR(30) NOT NULL,
+tech CHAR(10) NOT NULL DEFAULT '',
+path CHAR(40) NOT NULL DEFAULT '',
+provider CHAR(100) NOT NULL DEFAULT '',
+status INTEGER DEFAULT 1 NOT NULL,
+dialed_modify TEXT NOT NULL DEFAULT '',
+resellers TEXT NOT NULL DEFAULT '',
+precedence INT(4) NOT NULL DEFAULT 0,
+maxchannels INTEGER DEFAULT 0 NOT NULL,
+ PRIMARY KEY (`name`),
+ KEY `provider` (`provider`),
+ KEY `provider_2` (`provider`)
+);
+
+DROP TABLE IF EXISTS `outbound_routes`;
+CREATE TABLE outbound_routes (
+pattern CHAR(40),
+id INTEGER NOT NULL AUTO_INCREMENT,
+comment CHAR(80) NOT NULL DEFAULT '',
+connectcost INTEGER NOT NULL DEFAULT 0,
+includedseconds INTEGER NOT NULL DEFAULT 0,
+cost INTEGER NOT NULL DEFAULT 0,
+trunk CHAR(80) NOT NULL DEFAULT '',
+inc CHAR(10) NOT NULL DEFAULT '',
+strip CHAR(40) NOT NULL DEFAULT '',
+prepend CHAR(40) NOT NULL DEFAULT '',
+precedence INT(4) NOT NULL DEFAULT 0,
+resellers TEXT NOT NULL DEFAULT '',
+status INTEGER DEFAULT 1 NOT NULL,
+PRIMARY KEY (`id`),
+ KEY `trunk` (`trunk`),
+ KEY `pattern` (`pattern`)
+);
+
+DROP TABLE IF EXISTS `dids`;
+CREATE TABLE dids (
+number CHAR(40) NOT NULL,
+account CHAR(50) NOT NULL DEFAULT '',
+connectcost INTEGER NOT NULL DEFAULT 0,
+includedseconds INTEGER NOT NULL DEFAULT 0,
+monthlycost INTEGER NOT NULL DEFAULT 0,
+cost INTEGER NOT NULL DEFAULT 0,
+inc CHAR(10) NOT NULL DEFAULT '',
+extensions CHAR(180) NOT NULL DEFAULT '',
+status INTEGER DEFAULT 1 NOT NULL,
+provider CHAR(40) NOT NULL DEFAULT '',
+country CHAR (80)NOT NULL DEFAULT '',
+province CHAR (80) NOT NULL DEFAULT '',
+city CHAR (80) NOT NULL DEFAULT '',
+prorate int(1) NOT NULL default 0,
+setup int(11) NOT NULL default 0,
+limittime int(1) NOT NULL default 1,
+disconnectionfee INT(11) NOT NULL default 0,
+variables TEXT NOT NULL DEFAULT '',
+options varchar(40) default NULL,
+maxchannels int(4) NOT NULL default 0,
+chargeonallocation int(1) NOT NULL default 1,
+allocation_bill_status int(1) NOT NULL default 0,
+dial_as CHAR(40) NOT NULL DEFAULT '',
+PRIMARY KEY (`number`),
+ KEY `account` (`account`)
+);
+
+DROP TABLE IF EXISTS `accounts`;
+CREATE TABLE accounts (
+cc CHAR(20) NOT NULL DEFAULT '',
+number CHAR(50) NOT NULL,
+reseller CHAR(40) NOT NULL DEFAULT '',
+pricelist CHAR(24) NOT NULL DEFAULT '',
+status INTEGER DEFAULT 1 NOT NULL,
+credit INTEGER NOT NULL DEFAULT 0,
+sweep INTEGER NOT NULL DEFAULT 0,
+creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+pin INTEGER NOT NULL DEFAULT 0,
+credit_limit INTEGER NOT NULL DEFAULT 0,
+posttoexternal INTEGER NOT NULL DEFAULT 0,
+balance DECIMAL(20,6) NOT NULL DEFAULT 0,
+password CHAR(80) NOT NULL DEFAULT '',
+first_name CHAR(40) NOT NULL DEFAULT '',
+middle_name CHAR(40) NOT NULL DEFAULT '',
+last_name CHAR(40) NOT NULL DEFAULT '',
+company_name CHAR(40) NOT NULL DEFAULT '',
+address_1 CHAR(80) NOT NULL DEFAULT '',
+address_2 CHAR(80) NOT NULL DEFAULT '',
+address_3 CHAR(80) NOT NULL DEFAULT '',
+postal_code CHAR(12) NOT NULL DEFAULT '',
+province CHAR(40) NOT NULL DEFAULT '',
+city CHAR(80) NOT NULL DEFAULT '',
+country CHAR(40) NOT NULL DEFAULT '',
+telephone_1 CHAR(40) NOT NULL DEFAULT '',
+telephone_2 CHAR(40) NOT NULL DEFAULT '',
+fascimile CHAR(40) NOT NULL DEFAULT '',
+email CHAR(80) NOT NULL DEFAULT '',
+language CHAR(2) NOT NULL DEFAULT '',
+currency CHAR(3) NOT NULL DEFAULT '',
+maxchannels INTEGER DEFAULT 1 NOT NULL,
+routing_technique INT(4) NOT NULL DEFAULT 0,
+dialed_modify TEXT NOT NULL DEFAULT '',
+type INTEGER DEFAULT 0,
+tz CHAR(40) NOT NULL DEFAULT '',
+PRIMARY KEY (`number`),
+ KEY `pricelist` (`pricelist`),
+ KEY `reseller` (`reseller`)
+);
+
+DROP TABLE IF EXISTS `counters`;
+CREATE TABLE counters (
+id INTEGER NOT NULL AUTO_INCREMENT,
+package CHAR(40) NOT NULL DEFAULT '',
+account VARCHAR(50) NOT NULL,
+seconds INTEGER NOT NULL DEFAULT 0,
+status INTEGER NOT NULL DEFAULT 1,
+PRIMARY KEY (`id`)
+);
+
+DROP TABLE IF EXISTS `callingcards`;
+CREATE TABLE callingcards (
+id INTEGER NOT NULL AUTO_INCREMENT,
+cardnumber CHAR(20) NOT NULL DEFAULT '',
+language CHAR(10) NOT NULL DEFAULT '',
+value INTEGER NOT NULL DEFAULT 0,
+used INTEGER NOT NULL DEFAULT 0,
+brand VARCHAR(20) NOT NULL DEFAULT '',
+created DATETIME,
+firstused DATETIME,
+expiry DATETIME,
+validfordays CHAR(4) NOT NULL DEFAULT '',
+inuse INTEGER NOT NULL DEFAULT 0,
+pin CHAR(20),
+account VARCHAR(50) NOT NULL DEFAULT '',
+maint_fee_pennies INTEGER NOT NULL DEFAULT 0,
+maint_fee_days INTEGER NOT NULL DEFAULT 0,
+maint_day INTEGER NOT NULL DEFAULT 0,
+disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0,
+minute_fee_minutes INTEGER NOT NULL DEFAULT 0,
+minute_fee_pennies INTEGER NOT NULL DEFAULT 0,
+min_length_minutes INTEGER NOT NULL DEFAULT 0,
+min_length_pennies INTEGER NOT NULL DEFAULT 0,
+timeused INTEGER NOT NULL DEFAULT 0,
+invoice CHAR(20) NOT NULL DEFAULT 0,
+status INTEGER DEFAULT 1 NOT NULL,
+PRIMARY KEY (`id`),
+ KEY `brand` (`brand`)
+);
+
+CREATE TABLE charge_to_account (
+id INTEGER NOT NULL AUTO_INCREMENT,
+charge_id INTEGER NOT NULL DEFAULT 0,
+cardnum CHAR(50) NOT NULL DEFAULT '',
+status INTEGER NOT NULL DEFAULT 1,
+PRIMARY KEY (`id`)
+);
+
+CREATE TABLE queue_list (
+id INTEGER NOT NULL AUTO_INCREMENT,
+queue_id INTEGER NOT NULL DEFAULT 0,
+cardnum CHAR(20) NOT NULL DEFAULT '',
+PRIMARY KEY (`id`)
+);
+
+CREATE TABLE pbx_list (
+id INTEGER NOT NULL AUTO_INCREMENT,
+pbx_id INTEGER NOT NULL DEFAULT 0,
+cardnum CHAR(20) NOT NULL DEFAULT '',
+PRIMARY KEY (`id`)
+);
+
+CREATE TABLE extension_list (
+id INTEGER NOT NULL AUTO_INCREMENT,
+extension_id INTEGER NOT NULL DEFAULT 0,
+cardnum CHAR(20) NOT NULL DEFAULT '',
+PRIMARY KEY (`id`)
+);
+
+CREATE TABLE cdrs (
+id INTEGER NOT NULL AUTO_INCREMENT,
+uniqueid varchar(32) NOT NULL DEFAULT '',
+cardnum CHAR(50),
+callerid CHAR(80),
+callednum varchar(80) NOT NULL DEFAULT '',
+billseconds INT DEFAULT 0 NOT NULL,
+trunk VARCHAR(30),
+disposition varchar(45) NOT NULL DEFAULT '',
+callstart varchar(80) NOT NULL DEFAULT '',
+debit DECIMAL (20,6) NOT NULL DEFAULT 0,
+credit DECIMAL (20,6) NOT NULL DEFAULT 0,
+status INTEGER DEFAULT 0 NOT NULL,
+notes CHAR(80),
+provider CHAR(50),
+cost DECIMAL(20,6) NOT NULL DEFAULT 0,
+pricelist CHAR(80) NOT NULL DEFAULT '',
+pattern CHAR(80) NOT NULL DEFAULT '',
+PRIMARY KEY (`id`),
+ KEY `cardnum` (`cardnum`),
+ KEY `provider` (`provider`),
+ KEY `trunk` (`trunk`),
+ KEY `uniqueid` (`uniqueid`),
+ KEY `status` (`status`)
+);
+
+CREATE TABLE packages (
+id INTEGER NOT NULL AUTO_INCREMENT,
+name CHAR(40) NOT NULL DEFAULT '',
+pricelist CHAR(40) NOT NULL DEFAULT '',
+pattern CHAR(40) NOT NULL DEFAULT '',
+includedseconds INTEGER NOT NULL DEFAULT 0,
+reseller VARCHAR(50) NOT NULL DEFAULT '',
+status INTEGER DEFAULT 1 NOT NULL,
+PRIMARY KEY (`id`),
+ KEY `pricelist` (`pricelist`),
+ KEY `reseller` (`reseller`)
+);
+
+CREATE TABLE ani_map (
+number char(20) NOT NULL,
+account char(50) NOT NULL default '',
+status int(11) NOT NULL default '0',
+context varchar(20) NOT NULL,
+ PRIMARY KEY (`number`),
+KEY `account` (`account`)
+);
+
+CREATE TABLE `ip_map` (
+ip char(15) NOT NULL default '',
+account char(20) NOT NULL default '',
+prefix varchar(20) NULL,
+context varchar(20) NOT NULL,
+PRIMARY KEY (`ip`,`prefix`),
+KEY `account` (`account`)
+);
+
+CREATE TABLE charges (
+id INTEGER NOT NULL AUTO_INCREMENT,
+pricelist CHAR(40) NOT NULL DEFAULT '',
+description VARCHAR(80) NOT NULL DEFAULT '',
+charge INTEGER NOT NULL DEFAULT 0,
+sweep INTEGER NOT NULL DEFAULT 0,
+reseller CHAR(40) NOT NULL DEFAULT '',
+status INTEGER NOT NULL DEFAULT 1,
+PRIMARY KEY (`id`),
+ KEY `pricelist` (`pricelist`)
+);
+
+CREATE TABLE manager_action_variables (
+id INTEGER NOT NULL AUTO_INCREMENT,
+name CHAR(60) NOT NULL DEFAULT '',
+value CHAR(60) NOT NULL DEFAULT '',
+PRIMARY KEY (`id`)
+);
+
+CREATE TABLE callingcard_stats (
+uniqueid VARCHAR(48) NOT NULL,
+total_time VARCHAR(48) NOT NULL,
+billable_time VARCHAR(48) NOT NULL,
+timestamp DATETIME NULL,
+PRIMARY KEY (`uniqueid`)
+);
+
+CREATE TABLE system (
+name VARCHAR(48) NULL,
+value VARCHAR(255) NULL,
+comment VARCHAR(255) NULL,
+timestamp DATETIME NULL,
+reseller VARCHAR(48) NULL,
+brand VARCHAR(48) NULL,
+PRIMARY KEY (`name`),
+ KEY `reseller` (`reseller`),
+ KEY `brand` (`brand`)
+);
+
+
+INSERT INTO system (name, value, comment) VALUES (
+'callout_accountcode','admin','Call Files: What accountcode should we use?');
+
+INSERT INTO system (name, value, comment) VALUES (
+'lcrcontext','astpp-outgoing','This is the Local context we use to route our outgoing calls through esp for callbacks');
+
+INSERT INTO system (name, value, comment) VALUES (
+'maxretries','3','Call Files: How many times do we retry?');
+
+INSERT INTO system (name, value, comment) VALUES (
+'retrytime','30','Call Files: How long do we wait between retries?');
+
+INSERT INTO system (name, value, comment) VALUES (
+'waittime','15','Call Files: How long do we wait before the initial call?');
+
+INSERT INTO system (name, value, comment) VALUES (
+'clidname','Private','Call Files: Outgoing CallerID Name');
+
+INSERT INTO system (name, value, comment) VALUES (
+'clidnumber','0000000000','Call Files: Outgoing CallerID Number');
+
+INSERT INTO system (name, value, comment) VALUES (
+'callingcards_callback_context','astpp-callingcards','Call Files: For callingcards what context do we end up in?');
+
+INSERT INTO system (name, value, comment) VALUES (
+'callingcards_callback_extension', 's','Call Files: For callingcards what extension do we use?');
+
+INSERT INTO system (name, value, comment) VALUES (
+'openser_dbengine', 'MySQL','For now this must be MySQL');
+
+INSERT INTO system (name, value, comment) VALUES (
+'openser', '0','Use OPENSER? 1 for yes or 0 for no');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'openser_dbname', 'openser','OPENSER Database Name', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'openser_dbuser', 'root','OPENSER Database User', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'openser_dbhost', 'localhost','OPENSER Database Host', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'openser_dbpass', 'Passw0rd','OPENSER Database Password', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'openser_domain', NULL,'OPENSER Domain', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'company_email', 'em...@as...','Email address that email should appear to be from', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'asterisk_dir', '/etc/asterisk','Which directory are asterisk configuration files stored in?', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'company_website', 'http://www.astpp.org','Link to your company website', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'company_name', 'ASTPP.ORG','The name of your company. Used in emails.', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'email', '1','Send out email? 0=no 1=yes', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'user_email', '1','Email user on account changes? 0=no 1=yes', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'debug', '0','Enable debugging output? 0=no 1=yes', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'emailadd', 'em...@as...','Administrator email address', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'startingdigit', '0','The digit that all calling cards must start with. 0=disabled', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'enablelcr', '1','Use least cost routing 0=no 1=yes', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'log_file', '/var/log/astpp/astpp.log','ASTPP Log file', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'key_home', 'http://www.astpp.org/astpp.pub','Asterisk RSA Key location (optional)', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rate_engine_csv_file', '/var/log/astpp/astpp.csv','CSV File for call rating data', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'csv_dir', '/var/log/astpp/','CSV File Directory', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'default_brand', 'default','Default pricelist. If a price is not found in the customers pricelist we check this one.', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'new_user_brand', 'default','What is the default pricelist for new customers?', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'default_context', 'custom-astpp','What is the default context for new devices?', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'cardlength', '10','Number of digits in calling cards and cc codes.', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'asterisk_server', 'voip.astpp.org','Your default voip server. Used in outgoing email.', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'currency', 'CAD','Name of the currency you use', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'iax_port', '4569','Default IAX2 Port', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'sip_port', '5060','Default SIP Port', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'ipaddr', 'dynamic','Default IP Address for new devices', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'key', 'astpp.pub','Asterisk RSA Key Name (Optional)', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'pinlength', '6','For those calling cards that are using pins this is the number of digits it will have.', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'credit_limit', '0','Default credit limit in dollars.', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'decimalpoints', '4','How many decimal points do we bill to?', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'max_free_length', '100','What is the maximum length (in minutes) of calls that are at no charge?', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'trackvendorcharges', '1','Do we track the amount of money we spend with specific providers? 0=no 1=yes', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'company_logo', 'http://www.astpp.org/logo.png','The location of our company logo.', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'company_slogan', 'Welcome to ASTPP','Company slogan', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'version', '1.5Beta', 'ASTPP Version', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'default_language', 'en', 'Default ASTPP Language','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'card_retries','3', 'How many retries do we allow for calling card numbers?','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'pin_retries','3', 'How many retries do we allow for pins?','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'number_retries','3','How many retries do we allow calling card users when dialing a number?','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'booth_context','callshop_booth','Please enter the default context for a callshop booth.','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?','');
+
+INSERT INTO system (name,value,comment,timestamp) VALUES (
+'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'results_per_page','30','How many results per page do we should in the web interface?','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'astpp_dir','/var/lib/astpp','Where do the astpp configs live?','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'auth','Passw0rd!','This is the override authorization code and will allow access to the system.','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'cdr_dbengine','MySQL','Database type for the cdr database','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'osc_dbengine','MySQL','Database type for OSCommerce','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'agile_dbengine','MySQL','Database type for AgileBill(tm)','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_dbengine','MySQL','Database type for FreePBX','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.','');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'users_dids_freeswitch','0','If this is enabled, ASTPP will create SIP users in the freeswitch database.','');
+
+
+INSERT INTO system (name, value, comment) VALUES (
+'service_prepend','778','');
+INSERT INTO system (name, value, comment) VALUES (
+'service_length,','7','');
+INSERT INTO system (name, value, comment) VALUES (
+'service_filler','4110000','');
+
+INSERT INTO system (name, value, comment) VALUES (
+'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?');
+
+-- AgileBill(Trademark of AgileCo) Settings:
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'agile_host','127.0.0.1','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'agile_db','agile','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'agile_user','root','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'agile_pass','','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'agile_site_id','1','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'agile_charge_status','0','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'agile_taxable','1','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'agile_dbprefix','_','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'agile_service_prepend','778','','');
+
+-- OSCommerce Settings (www.oscommerce.org)
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'osc_host','127.0.0.1','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'osc_db','oscommerce','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'osc_user','root','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'osc_pass','password','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'osc_product_id','99999999','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'osc_payment_method','"Charge"','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'osc_order_status','1','','');
+
+-- FreePBX Settings (www.freepbx.org)
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_host','127.0.0.1','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_db','asterisk','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_user','root','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_pass','passw0rd','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_iax_table','iax','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_table','sip','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_extensions_table','extensions','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_codec_allow','g729,ulaw,alaw','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_codec_disallow','all','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_mailbox_group','default','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_sip_nat','yes','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_sip_canreinvite','no','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_sip_dtmfmode','rfc2833','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_sip_qualify','yes','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_sip_type','friend','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_sip_callgroup','','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_sip_pickupgroup','','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_iax_notransfer','yes','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_iax_type','friend','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freepbx_iax_qualify','yes','','');
+
+-- Asterisk -realtime Settings
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_host','127.0.0.1','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_db','realtime','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_user','root','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_pass','','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_iax_table','iax','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_sip_table','sip','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_extensions_table','extensions','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_sip_insecure','very','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_sip_nat','yes','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_sip_canreinvite','no','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_codec_allow','g729,ulaw,alaw','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_codec_disallow','all','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_mailbox_group','default','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_sip_qualify','yes','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_sip_type','friend','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_iax_qualify','yes','','');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'rt_iax_type','friend','','');
+INSERT INTO system (name, value, comment) VALUES (
+'rt_voicemail_table','voicemail_users','');
+
+
+INSERT INTO system (name, value, comment) VALUES (
+'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?');
+INSERT INTO system (name, value, comment) VALUES (
+'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?');
+INSERT INTO system (name, value, comment) VALUES (
+'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?');
+INSERT INTO system (name, value, comment) VALUES (
+'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?');
+INSERT INTO system (name, value, comment) VALUES (
+'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?');
+INSERT INTO system (name, value, comment) VALUES (
+'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS');
+INSERT INTO system (name, value, comment) VALUES (
+'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS');
+INSERT INTO system (name, value, comment) VALUES (
+'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS');
+INSERT INTO system (name, value, comment) VALUES (
+'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS');
+INSERT INTO system (name, value, comment) VALUES (
+'calling_cards_welcome_file','silence/1','What do we play for a welcome file?');
+
+INSERT INTO system (name, value, comment) VALUES (
+'sip_ext_prepend','10','What should every autoadded SIP extension begin with?');
+INSERT INTO system (name, value, comment) VALUES (
+'iax2_ext_prepend','10','What should every autoadded IAX2 extension begin with?');
+INSERT INTO system (name, value, comment) VALUES (
+'cc_prepend','','What should every autoadded callingcard begin with?');
+INSERT INTO system (name, value, comment) VALUES (
+'pin_cc_prepend','','What should every autoadded callingcard pin begin with?');
+INSERT INTO system (name, value, comment) VALUES (
+'pin_act_prepend','','What should every autoadded account pin begin with?');
+
+INSERT INTO system (name, value, comment) VALUES (
+'freeswitch_directory','/usr/local/freeswitch','What is the Freeswitch root directory?');
+
+INSERT INTO system (name, value, comment) VALUES (
+'freeswitch_password','ClueCon','Freeswitch event socket password');
+INSERT INTO system (name, value, comment) VALUES (
+'freeswitch_host','localhost','Freeswitch event socket host');
+INSERT INTO system (name, value, comment) VALUES (
+'freeswitch_port','8021','Freeswitch event socket port');
+INSERT INTO system (name, value, comment) VALUES (
+'freeswitch_timeout','30','Freeswitch seconds to expect a heartbeat event or reconnect');
+
+INSERT INTO system (name, value, comment) VALUES (
+'freeswitch_dbengine', 'MySQL','For now this must be MySQL');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freeswitch_dbname', 'freeswitch','Freeswitch Database Name', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freeswitch_dbuser', 'root','Freeswitch Database User', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freeswitch_dbhost', 'localhost','Freeswitch Database Host', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'freeswitch_dbpass', 'Passw0rd','Freeswitch Database Password', '');
+
+INSERT INTO system (name, value, comment) VALUES (
+'freeswitch_cdr_table','fscdr','Which table of the cdr database are the Freeswitch cdrs in?');
+
+INSERT INTO system (name, value, comment) VALUES (
+'freeswitch_domain','$${local_ip_v4}','This is entered as the Freeswitch domain.');
+
+INSERT INTO system (name, value, comment) VALUES (
+'freeswitch_context','default','This is entered as the Freeswitch user context.');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'cdr_dbname', 'asteriskcdrdb',
+'CDR Database Name', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'cdr_dbuser', 'root',
+'CDR Database User', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'cdr_dbhost', 'localhost',
+'CDR Database Host', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'cdr_dbpass', 'Passw0rd',
+'CDR Database Password', '');
+
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'astman_user', 'admin','Asterisk(tm) Manager Interface User', '');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'astman_host', 'localhost','Asterisk(tm) Manager Interface Host', '');
+INSERT INTO system (name, value, comment, timestamp) VALUES (
+'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', '');
+
+
+--
+-- Enough Configuration settings
+--
+
+DROP TABLE IF EXISTS `countrycode`;
+CREATE TABLE `countrycode` (
+ `country` varchar(255) NOT NULL,
+ PRIMARY KEY (`country`),
+ KEY `country` (`country`)
+);
+
+INSERT INTO `countrycode` (`country`) VALUES
+ ('Afghanistan'),
+ ('Alaska'),
+ ('Albania'),
+ ('Algeria'),
+ ('AmericanSamoa'),
+ ('Andorra'),
+ ('Angola'),
+ ('Antarctica'),
+ ('Argentina'),
+ ('Armenia'),
+ ('Aruba'),
+ ('Ascension'),
+ ('Australia'),
+ ('Austria'),
+ ('Azerbaijan'),
+ ('Bahrain'),
+ ('Bangladesh'),
+ ('Belarus'),
+ ('Belgium'),
+ ('Belize'),
+ ('Benin'),
+ ('Bhutan'),
+ ('Bolivia'),
+ ('Bosnia & Herzegovina'),
+ ('Botswana'),
+ ('Brazil'),
+ ('Brunei Darussalam'),
+ ('Bulgaria'),
+ ('Burkina Faso'),
+ ('Burundi'),
+ ('Cambodia'),
+ ('Cameroon'),
+ ('Canadda'),
+ ('Cape Verde Islands'),
+ ('Central African Republic'),
+ ('Chad'),
+ ('Chile'),
+ ('China'),
+ ('Colombia'),
+ ('Comoros'),
+ ('Congo'),
+ ('Cook Islands'),
+ ('Costa Rica'),
+ ('Croatia'),
+ ('Cuba'),
+ ('Cuba Guantanamo Bay'),
+ ('Cyprus'),
+ ('Czech Republic'),
+ ('De...
[truncated message content] |