astpp-commit Mailing List for ASTPP - Open Source Voip Billing (Page 5)
Brought to you by:
darrenkw
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(8) |
Oct
(1) |
Nov
(34) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
(3) |
Jul
(1) |
Aug
(3) |
Sep
(8) |
Oct
(3) |
Nov
(11) |
Dec
(6) |
2009 |
Jan
(9) |
Feb
(11) |
Mar
(6) |
Apr
(3) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(14) |
Oct
(32) |
Nov
(2) |
Dec
|
2010 |
Jan
(1) |
Feb
(11) |
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
|
Dec
(5) |
2011 |
Jan
(7) |
Feb
|
Mar
(1) |
Apr
(3) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dar...@us...> - 2009-02-22 03:10:00
|
Revision: 2238 http://astpp.svn.sourceforge.net/astpp/?rev=2238&view=rev Author: darrenkw Date: 2009-02-22 03:09:51 +0000 (Sun, 22 Feb 2009) Log Message: ----------- Modify the sql tables to support taxes, payments, and invoice presentation. Added Paths: ----------- add-invoicing/sql/astpp-2009-02-21.sql Added: add-invoicing/sql/astpp-2009-02-21.sql =================================================================== --- add-invoicing/sql/astpp-2009-02-21.sql (rev 0) +++ add-invoicing/sql/astpp-2009-02-21.sql 2009-02-22 03:09:51 UTC (rev 2238) @@ -0,0 +1,1368 @@ +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 '', +invoiceid INT(11) NOT NULL DEFAULT '0' +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 ( +'decimalpoints_tax', '2','How many decimal points do we calculate taxes to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints_total', '2','How many decimal points do we calculate totals 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','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_post_nc','0','Do we post "free" items to the oscommerce invoice? 0=No 1=Yes',''); + +-- 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', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'call_max_length','1440000','What is the maximum length (in ms) of a LCR call?',''); + +------ 3rd Party PBX Mods +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); + +-- +-- 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'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +Privilege VARCHAR(255) NULL, +Channel VARCHAR(255) NULL, +Cause VARCHAR(255) NULL, +Causetxt VARCHAR(255) NULL, +PeerStatus VARCHAR(255) NULL, +Peer VARCHAR(255) NULL, +Context VARCHAR(255) NULL, +Application VARCHAR(255) NULL, +AppData VARCHAR(255) NULL, +Priority VARCHAR(255) NULL, +Uniqueid VARCHAR(255) NULL, +Event VARCHAR(255) NULL, +State VARCHAR(255) NULL, +CallerIDName VARCHAR(255) NULL, +CallerID VARCHAR(255) NULL, +AstExtension VARCHAR(255) NULL, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + +CREATE TABLE sql_commands ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +sql TEXT NOT NULL default '', +comment TEXT NOT NULL default '', +timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`id`)); + + +CREATE TABLE `invoices` ( +`invoiceid` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , +`customerid` INT( 11 ) NOT NULL , +`date` DATE NOT NULL , +`status` TINYINT NOT NULL DEFAULT '0' +) ENGINE = MYISAM; + +CREATE TABLE `invoices_total` ( +`invoices_total_id` int(10) unsigned NOT NULL auto_increment, +`invoices_id` int(11) NOT NULL, +`title` varchar(255) NOT NULL, +`text` varchar(255) NOT NULL, +`value` decimal(15,4) NOT NULL, +`class` varchar(32) NOT NULL, +`sort_order` int(11) NOT NULL, +PRIMARY KEY (`invoices_total_id`) +); + + + CREATE TABLE `payments` ( +`id` INT( 11 ) NOT NULL , +`customerid` INT( 11 ) NOT NULL , +`credit` DECIMAL NOT NULL DEFAULT '0', +`status` TINYINT NOT NULL DEFAULT '0', +`type` INT NOT NULL , +`notes` TEXT NOT NULL , +PRIMARY KEY ( `id` ) +) ENGINE = MYISAM; + + CREATE TABLE `taxes` ( +`taxes_id` int(11) NOT NULL auto_increment, +`taxes_priority` int(5) default '1', +`taxes_amount` decimal(7,4) NOT NULL, +`taxes_rate` decimal(7,4) NOT NULL, +`taxes_description` varchar(255) NOT NULL, +`last_modified` datetime default NULL, +`date_added` datetime NOT NULL, +PRIMARY KEY (`taxes_id`) +); + + CREATE TABLE `taxes_to_accounts` ( +`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , +`customerid` VARCHAR( 11 ) NOT NULL , +`taxes_id` VARCHAR( 11 ) NOT NULL +) ENGINE = MYISAM ; + \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-21 19:43:14
|
Revision: 2237 http://astpp.svn.sourceforge.net/astpp/?rev=2237&view=rev Author: darrenkw Date: 2009-02-21 19:43:05 +0000 (Sat, 21 Feb 2009) Log Message: ----------- More work on getting callingcards working. Modified Paths: -------------- trunk/freeswitch/astpp-callingcards.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/freeswitch/astpp-callingcards.pl =================================================================== --- trunk/freeswitch/astpp-callingcards.pl 2009-02-21 18:36:58 UTC (rev 2236) +++ trunk/freeswitch/astpp-callingcards.pl 2009-02-21 19:43:05 UTC (rev 2237) @@ -149,13 +149,13 @@ if ($config->{calling_cards_rate_announce} == 1) { if ( $numberinfo->{cost} > 0 ) { $session->streamFile($sound->{call_will_cost}); -# $AGI->say_number(ceil($numberinfo->{cost} / 100)); + $session->execute("phrase","pronounce," . ceil($numberinfo->{cost}/100)); $session->streamFile($sound->{currency}); my @call_cost = split(/\./, ($numberinfo->{cost} / 100)); -# $AGI->say_number(@call_cost[0]); + $session->execute("phrase","pronounce," . @call_cost[0]); if (@call_cost[1]) { $session->streamFile($sound->{point}); -# $AGI->say_number(@call_cost[1]); + $session->execute("phrase","pronounce," . @call_cost[1]); $session->streamFile($sound->{sub_currency}); } $session->streamFile($sound->{per}); @@ -163,7 +163,7 @@ } if ( $numberinfo->{connectcost} > 0 ) { $session->streamFile($sound->{a_connect_charge}); -# $AGI->say_number(ceil($numberinfo->{connectcost} / 100)); + $session->execute("phrase","pronounce," . ceil($numberinfo->{connectcost}/100)); $session->streamFile($sound->{sub_currency}); $session->streamFile($sound->{will_apply}); } @@ -243,11 +243,11 @@ $minutes = sprintf( "%.0f", $minutes ); $session->streamFile($sound->{call_will_last}); if ( $minutes == 1 ) { -# $AGI->say_number($minutes); + $session->execute("phrase","pronounce," . $minutes); $session->streamFile($sound->{minute}); } elsif ( $minutes > 1 ) { -# $AGI->say_number($minutes); + $session->execute("phrase","pronounce," . $minutes); $session->streamFile($sound->{minutes}); } } @@ -284,19 +284,19 @@ my $interrupt = $session->playAndGetDigits(1,1,1,0,"#*","$sound->{card_has_balance_of}","$sound->{card_has_balance_of}",'^[0-9]+$'); if (!$interrupt || $interrupt eq "" || $interrupt == 0) { if ( $main_balance == 1 ) { -# $AGI->say_number($main_balance); +$session->execute("phrase","pronounce," . $main_balance); $session->streamFile($sound->{main_currency}); } elsif ( $main_balance > 1 ) { -# $AGI->say_number($main_balance); +$session->execute("phrase","pronounce," . $main_balance); $session->streamFile($sound->{main_currency_plural}); } if ( $sub_balance == 1 ) { -# $AGI->say_number($sub_balance); +$session->execute("phrase","pronounce," . $sub_balance); $session->streamFile($sound->{sub_currency}); } elsif ( $sub_balance > 1 ) { -# $AGI->say_number($sub_balance); +$session->execute("phrase","pronounce," . $sub_balance); $session->streamFile($sound->{sub_currency_plural}); } } @@ -370,8 +370,160 @@ $session->execute("set", "DIALSTATUS=NO ANSWER" ); } +sub dialout() { # Rig up the LCR stuff and do the outbound dialing. + # If a call does not go through we give the user the option + # of trying again. + my ( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ) = + @_; + my ( $status, $count, $increment ); + $ASTPP->debug( debug => "Looking for outbound Route", verbosity => $verbosity ); + my @outboundroutes = &get_outbound_routes( $astpp_db, $destination,$cardinfo,$numberinfo, @resellerlist ); + $count = @outboundroutes; + if ( $count == 0 ) { + $ASTPP->debug(debug => "NO OUTBOUND ROUTES FOUND!", verbosity => $verbosity ); + my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{noanswer}","$sound->{noanswer}",'^[0-9]+$'); + if ( $order != 1 ) { + &write_cdr( $cardinfo, "", $destination, gettext("NO Route Found"), "", 0, 0 ); + &leave($cardinfo); + } + } + $count = 0; + foreach my $route (@outboundroutes) { + my $dialstring = $ASTPP->fs_dialplan_xml_bridge(); + my $callstart = localtime(); + my ($accountcode); + $callstart = &prettytimestamp if $cc == 1; + $session->execute->("sched_hangup","+" . $timelimit * 60); + my ($xml_string,$data_string) = $ASTPP->fs_dialplan_xml_bridge( + destination_number => $destination, + route_prepend => $route->{prepend}, + trunk_name => $route->{trunk} + ); + my $vars = $session->execute->("bridge",$data_string); +# return 1 if (! $session->ready()); +# $VARS{destination_number} = $num_dial; +# UPDATEV(); +# return 1; + my $asterisk_time = &prettytimestamp; + $ASTPP->debug( debug => "CALL STATUS $status", verbosity => 1); + $ASTPP->debug( debug => "ANSWERED TIME $answeredtime", verbosity => $verbosity); + $ASTPP->debug( debug => "Account CC?: $cc", verbosity => $verbosity); + if ( ( $status != ~/CHANUNAVAIL/ ) && ( $status != ~/CONGESTION/ ) ) { + if ( $status =~ /BUSY/ ) { + $ASTPP->debug( debug => "CALL BUSY", verbosity => $verbosity ); + my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{busy}","$sound->{busy}",'^[0-9]+$'); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } else { + push @outboundroutes, $route; + } + } + elsif ( $status =~ /NOANSWER/ ) { + $ASTPP->debug(debug=> "NO ANSWER", verbosity => $verbosity ); + my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{noanswer}","$sound->{noanswer}",'^[0-9]+$'); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } else { + push @outboundroutes, $route; + } + } + elsif ( $status =~ /ANSWER/ || $answeredtime > 0) { + $ASTPP->debug( debug => "CALL ANSWERED", verbosity => $verbosity ); + my $increment; + if ( $numberinfo->{inc} > 0 ) { + $increment = $numberinfo->{inc}; + } + else { + $increment = $pricelistinfo->{inc}; + } + $ASTPP->debug( debug => "$numberinfo->{connectcost}, $numberinfo->{cost}, $answeredtime, $increment, $numberinfo->{includedseconds}", + verbosity => $verbosity); + my $charge = &calc_call_cost( + $numberinfo->{connectcost}, $numberinfo->{cost}, + $answeredtime, $increment, + $numberinfo->{includedseconds} + ); + $ASTPP->debug( debug => "Cost $charge ", verbosity => $verbosity ); + if ($cardinfo->{minute_fee_pennies} > 0) { + $charge = (($cardinfo->{minute_fee_pennies} * 100) + $charge) if $cardinfo->{timeused} + $answeredtime => $cardinfo->{minute_fee_minutes}; + } + if ($cardinfo->{min_length_pennies} > 0 && ($cardinfo->{min_length_minutes}*60) > $answeredtime) { + $charge = (($cardinfo->{min_length_pennies} * 100) + $charge); + } + if ( $cc == 0 ) { + &write_cdr( + $cardinfo, $clid, $destination, $status, + $callstart, $charge, $answeredtime, $uniqueid + ); + &write_asterisk_cdr( $accountcode, $clid, $destination, "ANSWERED", + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &update_balance( $cardinfo, $charge ); + $astpp_db->do("UPDATE callingcards SET timeused = " + . $astpp_db->quote($cardinfo->{timeused} + $answeredtime) + . " WHERE cardnumber = " + . $astpp_db->quote($cardinfo->{cardnumber})); + } + elsif ( $cc == 1 ) { + my $status = + &write_account_cdr( $astpp_db, $cardinfo->{number}, + $charge, $destination, $callstart, $answeredtime, $uniqueid, $clid ); + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $ASTPP->debug( debug => $status, verbosity => $verbosity ); + } + $session->streamFile($sound->{call_completed}); + &leave($cardinfo); + } + elsif ( $status =~ /CANCEL/ ) { + $ASTPP->debug( debug => "CALL CANCELLED", verbosity => $verbosity ); + $session->streamFile($sound->{cancelled}) if $config->{calling_cards_cancelled_prompt} == 1; + &write_cdr( $cardinfo, $clid, $destination, $status, $callstart, 0, + 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } + else { + $ASTPP->debug( debug => "ERROR - ERROR - ERROR", verbosity => $verbosity ); + my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{noanswer}","$sound->{noanswer}",'^[0-9]+$'); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } + } + } + } +} + sub leave() { # Prepare everything and then leave the calling card app. my ($cardinfo) = @_; my ($whatnow); @@ -539,18 +691,10 @@ # Congratulations, we now have a working card,pin, and phone number. $stats{destination} = $destination; -#&tell_cost( $numberinfo, $pricelistinfo, $cardinfo ); +&tell_cost( $numberinfo, $pricelistinfo, $cardinfo ); my $timelimit = &timelimit( $numberinfo, $pricelistinfo, $cardinfo, $destination ); $session->streamFile($sound->{please_wait_will_connect}) if $config->{calling_cards_connection_prompt} == 1; -#&dialout( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ); +&dialout( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ); - - - - - - - - 1; Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-02-21 18:36:58 UTC (rev 2236) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-02-21 19:43:05 UTC (rev 2237) @@ -131,7 +131,7 @@ # route_prepend = What do we tag on for numbers on this route? { my ($self, %arg) = @_; - my ( $sql, $trunkdata, $dialstring ); + my ( $sql, $trunkdata, $dialstring,$data ); $sql = $self->{_astpp_db}->prepare( "SELECT * FROM trunks WHERE name = " . $self->{_astpp_db}->quote( $arg{trunk_name} ) ); $sql->execute; @@ -151,19 +151,21 @@ } } if ( $trunkdata->{tech} eq "Zap" ) { - $dialstring = "<action application=\"bridge\" data=\"openzap/" . $trunkdata->{path} . "/1/" . $arg{route_prepend} . $arg{destination_number}. "\"/>\n"; - return $dialstring; + $dialstring = "<action application=\"bridge\" data=\"openzap/" . $trunkdata->{path} . "/1/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; + return $dialstring,$data; } elsif ( $trunkdata->{tech} eq "SIP" ) { my ($profile,$dest) = split(m/","/m, $trunkdata->{path}); $profile =~ s/"//g; #Strip off quotation marks $dest =~ s/"//g; #Strip off quotation marks if ($profile eq "gateway") { - $dialstring = "<action application=\"bridge\" data=\"sofia/gateway/" . $dest . "/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; + $data = "sofia/gateway/" . $dest . "/" . $arg{route_prepend} . $arg{destination_number}; + $dialstring = "<action application=\"bridge\" data=\"" . $data . "\"/>\n"; } else { - $dialstring = "<action application=\"bridge\" data=\"sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest . "\"/>\n"; + $data = "sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest; + $dialstring = "<action application=\"bridge\" data=\"" . $data . "\"/>\n"; } - return $dialstring; + return $dialstring,$data; } else { print STDERR "CANNOT ROUTE THIS CALL!!!!!\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-21 18:37:08
|
Revision: 2236 http://astpp.svn.sourceforge.net/astpp/?rev=2236&view=rev Author: darrenkw Date: 2009-02-21 18:36:58 +0000 (Sat, 21 Feb 2009) Log Message: ----------- Added the beginning of callingcard support for Freeswitch. A few fixes to the xml generator. Modified Paths: -------------- trunk/freeswitch/astpp-fs-xml.pl Added Paths: ----------- trunk/freeswitch/astpp-callingcards.pl Added: trunk/freeswitch/astpp-callingcards.pl =================================================================== --- trunk/freeswitch/astpp-callingcards.pl (rev 0) +++ trunk/freeswitch/astpp-callingcards.pl 2009-02-21 18:36:58 UTC (rev 2236) @@ -0,0 +1,556 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2004, Aleph Communications +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +############################################################################# +use DBI; +use POSIX qw(ceil floor); +use POSIX qw(strftime); +use Time::HiRes qw( gettimeofday tv_interval ); +use ASTPP; +use strict; +our $session; + +use vars qw(@output $verbosity $config $astpp_db $cdr_db + $ASTPP %stats %input $cc $pricelistinfo $brandinfo $sound @resellerlist $brand); +$stats{start_time} = [gettimeofday]; +$cc = 0; +$verbosity = 1; +require "/usr/local/astpp/astpp-common.pl"; + +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to be. + +sub initialize() { + $SIG{HUP} = 'ignore_hup'; # We ignore the HUP command that Asterisk sends on a call hangup. + $config = &load_config(); # Load /var/lib/astpp/astpp-config.conf + $astpp_db = &connect_db( $config, @output ); + $ASTPP->set_astpp_db($astpp_db); + $config = &load_config_db($astpp_db,$config); + $brand = "brand"; #$AGI->get_variable("BRAND"); + if ($brand && $brand ne "") { + my $brandinfo = &get_cc_brand($astpp_db, $brand); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$brand); + } + $cdr_db = &cdr_connect_db( $config, @output ); + $ASTPP->set_cdr_db($cdr_db); + $sound = &define_sounds($astpp_db); +} + +sub set_in_use() { # Set the "inuse" flag on the calling cards. This prevents multiple people from +# using the same card. + my ( $cardinfo, $status ) = @_; + my $sql; + $sql = + "UPDATE callingcards SET inuse = " + . $astpp_db->quote($status) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); +} + +sub check_card() { # Check a few things before saying the card is ok. + my ($cardinfo) = @_; + my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; + $ASTPP->debug( debug => "Present Time: $now", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Expiration Date: $cardinfo->{expiry}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Valid for Days: $cardinfo->{validfordays}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "First Use: $cardinfo->{firstused}", + verbosity => $verbosity ); + if ( $cardinfo->{inuse} != 0 ) { # If the card is in use then say so and leave. + $session->streamFile($sound->{card_inuse}); + $session->streamFile($sound->{goodbye}); + &leave($cardinfo); + } + &set_in_use( $cardinfo, 1 ); # Now the card is in use and nobody else can use it. + if ( $cardinfo->{firstused} eq "00000000000000" || $cardinfo->{firstused} eq "0000-00-00 00:00:00" ) { # If "firstused" has not been set, we will set it now. + # At the same time we will update the "maint_day" field. + my $sql = + "UPDATE callingcards SET firstused = NOW() WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $sql = + "UPDATE callingcards SET maint_day = DATE_ADD(NOW(), INTERVAL " + . "$cardinfo->{maint_fee_days} day) WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + if ( $cardinfo->{maint_fee_days} > 0 ) { + $astpp_db->do($sql); + } +# $cardinfo = &get_callingcard( $astpp_db, $cardinfo->{cardnumber} ); + if ( $cardinfo->{validfordays} > 0 ) { #Check if the card is set to expire and deal with that as appropriate. + my $sql = +"UPDATE callingcards SET expiry = DATE_ADD(NOW(), INTERVAL " + . " $cardinfo->{validfordays} day) WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $cardinfo = &get_callingcard( $astpp_db, $cardinfo->{cardnumber}, $config ); + } + } + elsif ( $cardinfo->{validfordays} > 0 ) { + my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; + $cardinfo->{expiry} = $astpp_db->selectall_arrayref("SELECT DATE_FORMAT('$cardinfo->{expiry}' , '\%Y\%m\%d\%H\%i\%s')")->[0][0]; + if ( $now >= $cardinfo->{expiry} ) { + my $sql = + "UPDATE callingcards SET status = 2 WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $sql = + "DELETE FROM ani_map WHERE account = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $session->streamFile($sound->{card_has_expired}); + $session->streamFile($sound->{goodbye}); + &leave($cardinfo); + } + } + $ASTPP->debug( debug => "Present Time: $now", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Expiration Date: $cardinfo->{expiry}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Valid for Days: $cardinfo->{validfordays}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "First Use: $cardinfo->{firstused}", + verbosity => $verbosity ); +} + +sub tell_cost() { #Say how much the call will cost. + my ( $numberinfo, $pricelistinfo, $cardinfo ) = @_; + if ( $pricelistinfo->{markup} ne "" && $pricelistinfo->{markup} != 0 ) { + $ASTPP->debug( debug => "Adding Markup of $pricelistinfo->{markup}", + verbosity => $verbosity); + $numberinfo->{connectcost} = + $numberinfo->{connectcost} * + ( ( $pricelistinfo->{markup} / 10000 ) + 1 ); + $numberinfo->{cost} = + $numberinfo->{cost} * ( ( $pricelistinfo->{markup} / 10000 ) + 1 ); + } + if ($config->{calling_cards_rate_announce} == 1) { + if ( $numberinfo->{cost} > 0 ) { + $session->streamFile($sound->{call_will_cost}); +# $AGI->say_number(ceil($numberinfo->{cost} / 100)); + $session->streamFile($sound->{currency}); + my @call_cost = split(/\./, ($numberinfo->{cost} / 100)); +# $AGI->say_number(@call_cost[0]); + if (@call_cost[1]) { + $session->streamFile($sound->{point}); +# $AGI->say_number(@call_cost[1]); + $session->streamFile($sound->{sub_currency}); + } + $session->streamFile($sound->{per}); + $session->streamFile($sound->{minute}); + } + if ( $numberinfo->{connectcost} > 0 ) { + $session->streamFile($sound->{a_connect_charge}); +# $AGI->say_number(ceil($numberinfo->{connectcost} / 100)); + $session->streamFile($sound->{sub_currency}); + $session->streamFile($sound->{will_apply}); + } + } +} + +sub timelimit() { #Calculate and say the time limit. + my ( $numberinfo, $pricelistinfo, $cardinfo, $phoneno ) = @_; + my ( $connectfee, $cost, $timelimit, $available, $maxtime, $balance ); + # Timelimit is in seconds + if ($cc == 0) { + $available = + ( $cardinfo->{value} - $cardinfo->{used} ) - $numberinfo->{connectfee}; + $ASTPP->debug( debug => "FUNDS AVAILABLE: $available", + verbosity => $verbosity); + } elsif ( $cc == 1 ) { + $balance = &accountbalance( $astpp_db, $cardinfo->{number} ); + $balance = ($balance * -1) + ( $cardinfo->{credit_limit}); + $available = ($balance - $numberinfo->{connectfee}) / 100; + } + if ( $available > 0 && $numberinfo->{cost} > 0 ) { + $timelimit = ( ( $available / $numberinfo->{cost} ) * 60 ); + } + elsif ( $available >= 0 && $numberinfo->{cost} <= 0 ) { + $timelimit = $config->{callingcards_max_length}; + } + if ( $timelimit > $config->{callingcards_max_length} ) { + $timelimit = $config->{callingcards_max_length}; + } + $ASTPP->debug( debug => "TIMELIMIT: $timelimit", + verbosity => $verbosity); + if ($brandinfo->{reseller} ne "") { + ASTPP->debug( debug => "THIS BRAND BELONGS TO $brandinfo->{reseller}!", + verbosity => $verbosity); + my $carddata = &get_account( $astpp_db, $brandinfo->{reseller} ); +# ($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); +# my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); + my $minimumcharge = $numberinfo->{cost}; + my $belongs_to_reseller = 1; + while ( $belongs_to_reseller == 1 ) { + $ASTPP->debug( debug => "FINDING LIMIT FOR: $carddata->{reseller}", + verbosity => $verbosity); + push @resellerlist, $carddata->{number}; + $ASTPP->debug( debug => "PUSHING $carddata->{number} ONTO THE LIST OF RESELLERS", + verbosity => $verbosity); + my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); + my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist}, $carddata, "CC" ); + if ($resellercallstatus != 1) { + $carddata->{reseller} = ""; + $timelimit = 0; + } elsif ($resellermaxlength < $timelimit / 60) { + $timelimit = $resellermaxlength * 60; + } + if ($resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) { + $carddata->{reseller} = ""; + $timelimit = 0; + } + $ASTPP->debug( debug => "RESELLER Max Length: $resellermaxlength", + verbosity => $verbosity); + $ASTPP->debug( debug => "RESELLER Call Status: $resellercallstatus", + verbosity => $verbosity); + if ($carddata->{reseller} && $carddata->{reseller} ne "") { + $carddata = &get_account( $astpp_db, $carddata->{reseller} ); + } else { + $belongs_to_reseller = 0; + } + } + } else { + $ASTPP->debug( debug => "THIS BRAND DOES NOT BELONG TO A RESELLER!", + verbosity => $verbosity); + } + $ASTPP->debug( debug =>"TIMELIMIT: $timelimit", verbosity => $verbosity); + my $minutes = $timelimit / 60; + $ASTPP->debug( debug => "MINUTES: $minutes", verbosity => $verbosity); + if ($minutes > 0 && $config->{calling_cards_timelimit_announce} == 1) { + my $minutes = $timelimit / 60; + $minutes = sprintf( "%.0f", $minutes ); + $session->streamFile($sound->{call_will_last}); + if ( $minutes == 1 ) { +# $AGI->say_number($minutes); + $session->streamFile($sound->{minute}); + } + elsif ( $minutes > 1 ) { +# $AGI->say_number($minutes); + $session->streamFile($sound->{minutes}); + } + } + elsif ($minutes < 1) { + $session->streamFile($sound->{not_enough_credit}); + $session->streamFile($sound->{goodbye}); + &leave($cardinfo); + } + $maxtime = $timelimit * 1000; + + + $timelimit = "\|30\|HL($maxtime:60000:30000)\|Hgj"; + $ASTPP->debug( debug => "Available: $available", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Balance: $balance", verbosity => $verbosity ); + $ASTPP->debug( debug => "Max Time: $maxtime", verbosity => $verbosity ); + return $timelimit; +} + +sub say_balance() { #Calculate and say the card balance. + my ($cardinfo) = @_; + my ( $connectfee, $cost, $included, $sub_balance, $balance, $main_balance ); + if ($cc == 0 ) { + $balance = $cardinfo->{value} - $cardinfo->{used}; + } elsif ($cc ==1) { + $balance = &accountbalance( $astpp_db, $cardinfo->{number} ); + $balance = ($balance * -1) + ( $cardinfo->{credit_limit} ); + } + if ( $balance > 0 ) { + $balance = $balance / 10000; + $balance = sprintf( "%.2f", $balance ); + $sub_balance = substr( $balance, -2, 2 ); + $main_balance = substr( $balance, 0, -2 ); + my $interrupt = $session->playAndGetDigits(1,1,1,0,"#*","$sound->{card_has_balance_of}","$sound->{card_has_balance_of}",'^[0-9]+$'); + if (!$interrupt || $interrupt eq "" || $interrupt == 0) { + if ( $main_balance == 1 ) { +# $AGI->say_number($main_balance); + $session->streamFile($sound->{main_currency}); + } + elsif ( $main_balance > 1 ) { +# $AGI->say_number($main_balance); + $session->streamFile($sound->{main_currency_plural}); + } + if ( $sub_balance == 1 ) { +# $AGI->say_number($sub_balance); + $session->streamFile($sound->{sub_currency}); + } + elsif ( $sub_balance > 1 ) { +# $AGI->say_number($sub_balance); + $session->streamFile($sound->{sub_currency_plural}); + } + } + } + else { + $session->streamFile($sound->{card_is_empty}); + $session->streamFile($sound->{goodbye}); + &leave($cardinfo); + } + return $balance; +} + +sub update_balance() { #Update the available credit on the calling card. + my ( $cardinfo, $charge ) = @_; + my $sql = + "UPDATE callingcards SET used = " + . $astpp_db->quote( ($charge) + $cardinfo->{used} ) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); +} +sub write_asterisk_cdr() { #Write the cdr record to the asterisk cdr db. This is done so we get a record of the call the callingcard user placed. + # This is especially important for resellers and calling cards. + my ( + $reseller, $clid, $destination, $status, + $callstart, $answeredtime, $dstchannel, $lastapp, $dialedtime, $uniqueid, $asterisk_time, $cdr_db + ) + = @_; + my ($sql); + if (!$status) {$status = gettext("N/A"); } + $sql = "INSERT INTO cdr (calldate,dst,clid,dstchannel,lastapp,duration,billsec,disposition,accountcode,uniqueid) VALUES(" + . $astpp_db->quote($asterisk_time) . ", " + . $astpp_db->quote($destination) . ", " + . $astpp_db->quote($clid) . ", " + . $astpp_db->quote($dstchannel) . ", " + . $astpp_db->quote($lastapp) . ", " + . $astpp_db->quote($dialedtime) . ", " + . $astpp_db->quote($answeredtime) . ", " + . $astpp_db->quote($status) . ", " + . $astpp_db->quote( $reseller ) . ", " + . $astpp_db->quote( $uniqueid ) . ")"; + $cdr_db->do($sql); + $session->execute("set", "ANSWEREDTIME=0" ); + $session->execute("set", "DIALEDTIME=0" ); + $session->execute("set", "DIALSTATUS=NO ANSWER" ); +} + +sub write_cdr() { # Write the callingcardcdr record if this is a calling card. + my ( + $cardinfo, $clid, $destination, $status, + $callstart, $charge, $answeredtime + ) + = @_; + my ($sql); + if (!$status) {$status = gettext("N/A"); } + $sql = +"INSERT INTO callingcardcdrs (cardnumber,clid,destination,disposition,callstart,seconds," + . "debit) VALUES (" + . $astpp_db->quote( $cardinfo->{cardnumber} ) . ", " + . $astpp_db->quote($clid) . ", " + . $astpp_db->quote($destination) . ", " + . $astpp_db->quote($status) . ", " + . $astpp_db->quote($callstart) . ", " + . $astpp_db->quote($answeredtime) . ", " + . $astpp_db->quote($charge) . ")"; + $astpp_db->do($sql); + $ASTPP->debug( debug => "$sql", verbosity => $verbosity ); + $ASTPP->debug( debug => "Resetting CDR Variables", verbosity => $verbosity ); + $session->execute("set", "ANSWEREDTIME=0" ); + $session->execute("set", "DIALEDTIME=0" ); + $session->execute("set", "DIALSTATUS=NO ANSWER" ); +} + + + +sub leave() { # Prepare everything and then leave the calling card app. + my ($cardinfo) = @_; + my ($whatnow); + my $retries = 0; + &set_in_use( $cardinfo, 0 ) if $cc == 0; + while ($retries < 3) { + $whatnow = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{astpp_callingcard_menu}","$sound->{astpp_callingcard_menu}",'^[0-9]+$'); + $ASTPP->debug( debug => "WHAT NEXT = $whatnow ", verbosity => $verbosity ); + if ($cc == 1) { + $session->execute("set", "CARDNUMBER=$cardinfo->{number}" ); + } else { + $session->execute("set", "CARDNUMBER=$cardinfo->{cardnumber}" ); + } + $session->execute("set", "PIN=$cardinfo->{pin}" ); + if ( $whatnow == 1 ) { + $session->execute("set", "NEWCALL=1" ); + $session->execute("set", "DESTINATION=$stats{destination}" ); + &exit_program(); + } + elsif ( $whatnow == 2 ) { + $session->execute("set", "NEWCALL=1" ); + $session->execute("set", "DESTINATION=" ); + &exit_program(); + } + elsif ( $whatnow == 3 ) { + $session->streamFile($sound->{goodbye}); + $session->hangup; + } else { + $retries++; + } + } + if ($retries == 3) { + $session->streamFile($sound->{goodbye}); + $session->hangup; + } + +} + +sub exit_program() { + $stats{total_time} = tv_interval ($stats{start_time}); + $astpp_db->do("INSERT INTO callingcard_stats(uniqueid,total_time,billable_time) VALUES (" + . $astpp_db->quote($stats{uniqueid}) . "," + . $astpp_db->quote($stats{total_time}) . "," + . $astpp_db->quote($stats{answered_time}) . ")"); + $stats{total_time} = tv_interval ($stats{start_time}); + exit(0); +} + +sub print_console() #Dump string to the console +{ + my ($output) = @_; + freeswitch::consoleLog("ASTPP",$output . "\n"); +} + +sub say() +{ + my($phrase,$say) = @_; + $session->execute("phrase", $phrase ."," . $say ); +} + + + +################# Program Starts Here ################################# +my ( $cardnum, $pin, $destination, $connectsurcharge, $perminsurcharge, $brand ) = + @ARGV; +my ( $retries, $cardinfo, $numberinfo, $pricelistinfo, @outboundroutes, + $callstart ); +$session->answer(); +&initialize; +return 1 if (! $session->ready()); + +if ($cardnum && $cardnum ne "") { + $ASTPP->debug( debug => "We recieved a cardnumber from the dialplan",verbosity => $verbosity); + $cardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); + if ( !$cardinfo ) { + $cardinfo = &get_account_cc( $astpp_db, $cardnum ); + $cc = 1 if $cardinfo; + } +} else { #We won't play the welcome file when we already have card numbers. + $session->streamFile($config->{calling_cards_welcome_file}); +} +# If $cc == 1 means that we are using an ASTPP account instead of an actual +# calling card. +if ( $cardinfo->{status} != 1 || !$cardinfo->{status}) { + $retries = 0; + while ( $cardinfo->{status} != 1 && $retries < $config->{card_retries} ) { + $cardnum = $session->playAndGetDigits($config->{cardlength},$config->{cardlength},1,$config->{calling_cards_number_input_timeout},"#","$sound->{cardnumber}","$sound->{cardnumber}",'^[0-9]+$'); + $cardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); + if ( !$cardinfo ) { + $cardinfo = &get_account_cc( $astpp_db, $cardnum ); + $cc = 1 if $cardinfo; + } + $ASTPP->debug(debug => "CARD BRAND: $cardinfo->{brand} SPECIFIED BRAND: $brand", verbosity => $verbosity); + if ($brand && $brand ne "") { + $cardinfo = "" if $cardinfo->{brand} ne $brand; + } + $ASTPP->debug( debug => "ASTPP Number: $cardnum ", verbosity => $verbosity ); + $ASTPP->debug( debug => "ASTPP Number Status: $cardinfo->{status}", verbosity => $verbosity ); + if ( $cardinfo->{status} != 1 ) { + $session->streamFile($sound->{cardnumber_incorrect}); + } + $retries++; + } + if ( $cardinfo->{status} != 1 ) { + $session->streamFile($sound->{goodbye}); + exit(1); + } +} + +if ( $pin != $cardinfo->{pin} ) { + $retries = 0; + while ( $cardinfo->{pin} != $pin && $retries < $config->{pin_retries} ) { + $pin = $session->playAndGetDigits($config->{pinlength},$config->{pinlength},1,$config->{calling_cards_pin_input_timeout},"#","$sound->{pin}","$sound->{pin}",'^[0-9]+$'); + if ( $cardinfo->{pin} != $pin ) { + $session->streamFile($sound->{pin_incorrect}); + } + $retries++; + } + if ( $pin != $cardinfo->{pin} ) { + $session->streamFile($sound->{pin_incorrect}); + $session->streamFile($sound->{goodbye}); + exit(0); + } +} +&check_card($cardinfo) if $cc == 0; +my $balance = &say_balance($cardinfo); + +# Getting this far means we have a valid card and pin. +$brandinfo = &get_cc_brand( $astpp_db, $cardinfo->{brand} ) if $cc == 0; +if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); +} +$config = &load_config_db_brand($astpp_db,$config,$cardinfo->{brand}); +$pricelistinfo = &get_pricelist( $astpp_db, $brandinfo->{pricelist} ) + if $cc == 0; +$pricelistinfo = &get_pricelist( $astpp_db, $cardinfo->{pricelist} ) + if $cc == 1; +if ($destination && $destination ne "" ) { + $numberinfo = + &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, $cardinfo ) + if $cc == 0; + $numberinfo = + &get_route( $astpp_db, $config, $destination, $cardinfo->{pricelist}, $cardinfo ) + if $cc == 1; +} +$retries = 0; +while ( !$numberinfo->{pattern} && $retries < $config->{number_retries} ) { + $destination = $session->playAndGetDigits(4,999,1,$config->{calling_cards_dial_input_timeout},"#","$sound->{destination}","$sound->{destination}",'^[0-9]+$'); + $numberinfo = + &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, $cardinfo ); + if ( !$numberinfo->{pattern} ) { + $session->streamFile($sound->{destination_incorrect}); + } else { + $numberinfo->{cost} = $numberinfo->{cost} + $perminsurcharge if $perminsurcharge ne ""; + $numberinfo->{connectcost} = $numberinfo->{connectcost} + $connectsurcharge if $connectsurcharge ne ""; + } + $retries++; +} +if ( !$numberinfo->{pattern} ) { + $session->streamFile($sound->{destination_incorrect}); + $session->streamFile($sound->{goodbye}); + $session->hangup(); + &leave($cardinfo); +} + +# Congratulations, we now have a working card,pin, and phone number. +$stats{destination} = $destination; +#&tell_cost( $numberinfo, $pricelistinfo, $cardinfo ); +my $timelimit = &timelimit( $numberinfo, $pricelistinfo, $cardinfo, $destination ); +$session->streamFile($sound->{please_wait_will_connect}) if $config->{calling_cards_connection_prompt} == 1; +#&dialout( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ); + + + + + + + + + +1; + Property changes on: trunk/freeswitch/astpp-callingcards.pl ___________________________________________________________________ Added: svn:executable + * Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-02-21 18:19:44 UTC (rev 2235) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-02-21 18:36:58 UTC (rev 2236) @@ -42,7 +42,7 @@ ################# Programs start here ####################################### &initialize; -my ( $xml, $maxlength, $maxmins, $callstatus ); +my ( $xml, $maxlength, $maxmins, $callstatus,$astppdid,$didinfo ); foreach my $param ( param() ) { $params->{$param} = param($param); $ASTPP->debug( debug => "$param $params->{$param}" ); @@ -58,6 +58,17 @@ destination_number => $params->{'Caller-Destination-Number'} ); +# Check to see if this is a DID. If it is we handle it differently. +# + $didinfo = &get_did($astpp_db, $params->{'Caller-Destination-Number'}); + if ($didinfo->{number}) { + $astppdid = "ASTPP-DID"; + $ASTPP->debug( debug => "This is a call for a DID: "); + $params->{variable_accountcode} = $didinfo->{account}; + } + + + if ( !$params->{variable_accountcode} ) { # First we strip off X digits to see if this account is prepending numbers @@ -130,10 +141,11 @@ my $routeinfo = &get_route( $astpp_db, $config, $params->{'Caller-Destination-Number'}, - $carddata->{pricelist}, $carddata + $carddata->{pricelist}, $carddata,$astppdid ); - $ASTPP->debug( debug => "Minimum Charge on call = " . $routeinfo->{cost} ); + $ASTPP->debug( debug => "Cost: " . $routeinfo->{cost} ); + $ASTPP->debug( debug => "Pricelist: " . $routeinfo->{pricelist} ); my $minimumcharge = $routeinfo->{cost}; my @reseller_list; $ASTPP->debug( debug => "CALLSTATUS: $callstatus MAX_LENGTH: $maxlength" ); @@ -213,9 +225,12 @@ my $routeinfo = &get_route( $astpp_db, $config, $params->{'Caller-Destination-Number'}, - $carddata->{pricelist}, $carddata + $carddata->{pricelist}, $carddata, $astppdid ); + if ($astppdid > 0 ) { + $ASTPP->debug( debug => "THIS IS A DID CALL: $xml"); + } else { # Get the list of routes for the phone number. my @outboundroutes = &get_outbound_routes( $astpp_db, $params->{'Caller-Destination-Number'}, @@ -236,6 +251,7 @@ ); } } + } $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); $ASTPP->debug( debug => $xml ); print $xml; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-21 18:19:49
|
Revision: 2235 http://astpp.svn.sourceforge.net/astpp/?rev=2235&view=rev Author: darrenkw Date: 2009-02-21 18:19:44 +0000 (Sat, 21 Feb 2009) Log Message: ----------- Create a branch for me to work on adding invoicing support Added Paths: ----------- add-invoicing/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-21 18:17:54
|
Revision: 2234 http://astpp.svn.sourceforge.net/astpp/?rev=2234&view=rev Author: darrenkw Date: 2009-02-21 18:17:40 +0000 (Sat, 21 Feb 2009) Log Message: ----------- Update code to more record more information in astpp-device-monitor.pl Modified Paths: -------------- trunk/scripts/astpp-device-monitor.pl Modified: trunk/scripts/astpp-device-monitor.pl =================================================================== --- trunk/scripts/astpp-device-monitor.pl 2009-02-21 18:12:03 UTC (rev 2233) +++ trunk/scripts/astpp-device-monitor.pl 2009-02-21 18:17:40 UTC (rev 2234) @@ -127,9 +127,10 @@ $astpp_db = &connect_db( $config, @output ); } $ASTPP->debug( debug=> "Peer: @extension1[0] Answer"); - my $tmp = "INSERT INTO extensions_status (tech,extension,status,number) VALUES (" + my $tmp = "INSERT INTO extensions_status (tech,extension,status,UniqueID,number) VALUES (" . $astpp_db->quote(@extension[0]) . "," . $astpp_db->quote(@extension1[0]) . ",'Answer'," + . $astpp_db->quote($_[ARG0]->{Uniqueid}) . "," . $astpp_db->quote($_[ARG0]->{Extension}) . ")"; $ASTPP->debug( debug=> "SQL: $tmp"); $astpp_db->do($tmp); @@ -168,8 +169,9 @@ $astpp_db = &connect_db( $config, @output ); } $ASTPP->debug( debug=> "Peer: @extension2[0] HUNGUP"); - my $tmp = "INSERT INTO extensions_status (tech,extension,status) VALUES (" + my $tmp = "INSERT INTO extensions_status (tech,extension,UniqueID,status) VALUES (" . $astpp_db->quote(@extension[0]) . "," + . $astpp_db->quote($_[ARG0]->{Uniqueid}) . "," . $astpp_db->quote(@extension2[0]) . ",'Hungup')"; $ASTPP->debug( debug=> "SQL: $tmp"); $astpp_db->do($tmp); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-21 18:12:16
|
Revision: 2233 http://astpp.svn.sourceforge.net/astpp/?rev=2233&view=rev Author: darrenkw Date: 2009-02-21 18:12:03 +0000 (Sat, 21 Feb 2009) Log Message: ----------- cleaned up a few minor coding problems. Modified Paths: -------------- trunk/freeswitch/test-fs-xml.pl Modified: trunk/freeswitch/test-fs-xml.pl =================================================================== --- trunk/freeswitch/test-fs-xml.pl 2009-02-03 17:15:20 UTC (rev 2232) +++ trunk/freeswitch/test-fs-xml.pl 2009-02-21 18:12:03 UTC (rev 2233) @@ -20,7 +20,7 @@ my $starttime = [gettimeofday]; -my $url = 'http://localhost/cgi-bin/astpp-fs-xml.pl?section=dialplan&Caller-Destination-Number=123456789&variable_accountcode=1000'; +#my $url = 'http://localhost/cgi-bin/astpp-fs-xml.pl?section=dialplan&Caller-Destination-Number=123456789&variable_accountcode=1000'; my $url = 'http://localhost/perl/astpp-fs-xml.pl?section=dialplan&Caller-Destination-Number=123456789&variable_accountcode=1000'; #my $req = HTTP::Request->new(POST, $url, $headers); @@ -38,8 +38,8 @@ print $count; $count++; my $content = get $url; +print $content; } -print $content; my $generation_time = tv_interval($starttime); print "\n\n" . $generation_time . "\n\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-03 17:15:26
|
Revision: 2232 http://astpp.svn.sourceforge.net/astpp/?rev=2232&view=rev Author: darrenkw Date: 2009-02-03 17:15:20 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Corrected code so that calls where an accountcode does not exist in ASTPP will be marked as being in error. Modified Paths: -------------- trunk/scripts/astpp-common.pl Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-02-02 19:43:38 UTC (rev 2231) +++ trunk/scripts/astpp-common.pl 2009-02-03 17:15:20 UTC (rev 2232) @@ -1727,6 +1727,7 @@ $record = &get_did($astpp_db,$destination) if $carddata->{reseller} eq ""; $record->{comment} = $record->{city} . "," . $record->{province} . "," . $record->{country}; $record->{pattern} = "DID:" . $destination; + $record->{pricelist} = $pricelist; my $branddata = &get_pricelist( $astpp_db, $pricelist); print STDERR "pattern: $record->{pattern}\n" if $record->{pattern}; } @@ -3519,7 +3520,7 @@ my ($astpp_db) = @_; my ( $sql, @brandlist, $result ); $sql = - $astpp_db->prepare("SELECT name FROM callingcardbrands WHERE status = 1 AND reseller IN (NULL,'')"); + $astpp_db->prepare("SELECT name FROM callingcardbrands WHERE status = 1 AND (reseller IS NULL OR reseller = '')"); $sql->execute; while ( $result = $sql->fetchrow_hashref ) { push @brandlist, $result->{name}; @@ -3936,7 +3937,7 @@ $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'CANCEL'"); } if ($config->{thirdlane_mods} == 1) { - $cdr_db->do("UPDATE cdr SET accountcode = userfield WHERE accountcode IN ('',NULL)"); + $cdr_db->do("UPDATE cdr SET accountcode = userfield WHERE (accountcode IS NULL or accountcode = '')"); } } } @@ -4206,11 +4207,11 @@ print STDERR "disposition: $cdrinfo->{disposition}\n"; print STDERR "----------------------\n"; if(!$vars) { - my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " + my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'error' WHERE uniqueid = " . $uniqueid . " AND cost = 'rating' LIMIT 1"; $cdr_db->do($tmp); } else { - $cdrinfo->{cost} = 'none'; + $cdrinfo->{cost} = 'error'; } } } @@ -4356,13 +4357,13 @@ if (!$sweep || $sweep eq "" ) { $sql = $astpp_db->prepare( -"SELECT number FROM accounts WHERE status < 2 AND reseller IN (NULL,'') AND posttoexternal = 0 " +"SELECT number FROM accounts WHERE status < 2 AND (reseller IS NULL OR reseller = '') AND posttoexternal = 0 " ); } else { $sql = $astpp_db->prepare( -"SELECT number FROM accounts WHERE status < 2 AND reseller IN (NULL,'') AND sweep = " +"SELECT number FROM accounts WHERE status < 2 AND ( reseller IS NULL OR reseller = '') AND sweep = " . $astpp_db->quote($sweep) ); } $sql->execute; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-02 19:43:43
|
Revision: 2231 http://astpp.svn.sourceforge.net/astpp/?rev=2231&view=rev Author: darrenkw Date: 2009-02-02 19:43:38 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Corrected code that checks to make sure an account number is entered. Modified Paths: -------------- trunk/web_interface/astpp-admin.cgi Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-02-01 01:41:41 UTC (rev 2230) +++ trunk/web_interface/astpp-admin.cgi 2009-02-02 19:43:38 UTC (rev 2231) @@ -2392,7 +2392,7 @@ $params->{count} = 1; $params->{pennies} = 0; $params->{number} = $params->{customnum}; - if ($params->{number} > 0) { + if ($params->{number} ne "") { $status .= &generate_accounts( $params, $config ); my $accountinfo = &get_account( $astpp_db, $params->{number} ); ## Here we add support to add IAX and SIP devices at account creation. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-01 02:22:11
|
Revision: 2230 http://astpp.svn.sourceforge.net/astpp/?rev=2230&view=rev Author: darrenkw Date: 2009-02-01 01:41:41 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Corrected the code for viewing booths. Modified Paths: -------------- trunk/scripts/astpp-common.pl trunk/web_interface/astpp-admin.cgi Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-02-01 00:59:00 UTC (rev 2229) +++ trunk/scripts/astpp-common.pl 2009-02-01 01:41:41 UTC (rev 2230) @@ -1502,11 +1502,11 @@ # Select all the unbilled CDRS belonging to a specific account. This is mostly used by booths. sub list_cdrs_account() { - my ( $config, $cdr_db, $account, $cc ) = @_; + my ( $cdr_db,$config, $account, $cc ) = @_; my ( $sql, @cdrlist, $row ); - $sql = - $cdr_db->prepare( - "SELECT * FROM $config->{asterisk_cdr_table} WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ") AND disposition REGEXP 'ANSWE.*'"); + my $tmp = "SELECT * FROM $config->{asterisk_cdr_table} WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ") AND disposition REGEXP 'ANSWE.*'"; + print STDERR $tmp ."\n" if $config->{debug} == 1; + $sql = $cdr_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-02-01 00:59:00 UTC (rev 2229) +++ trunk/web_interface/astpp-admin.cgi 2009-02-01 01:41:41 UTC (rev 2230) @@ -9638,6 +9638,16 @@ $params->{secret}, $params->{context}, $number, $params ); $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>"; + } $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Delete...") ) { @@ -11006,6 +11016,16 @@ $params->{context}, $params->{number}, $params ); $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} ) { $ASTPP->debug( @@ -11373,7 +11393,7 @@ } sub build_view_booth() { - my ( $config, $sql, @cdrs, $sip_login, $iax2_login ); + my ( $sql, @cdrs, $sip_login, $iax2_login ); # Prepare the booth list for the menu. @booth_list = @@ -11473,7 +11493,7 @@ $sql->finish; } my @chargelist = - &list_cdrs_account( $config, $cdr_db, $accountinfo->{number}, + &list_cdrs_account( $cdr_db,$config, $accountinfo->{number}, $accountinfo->{cc} ); &processlist( $astpp_db, $cdr_db, $config, $config->{asterisk_cdr_table}, @@ -11523,10 +11543,12 @@ push( @cdrs, $record ); } } + my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); + $template->param( booth_name => $params->{booth_name} ); my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; my $unrated = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-01 00:59:04
|
Revision: 2229 http://astpp.svn.sourceforge.net/astpp/?rev=2229&view=rev Author: darrenkw Date: 2009-02-01 00:59:00 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Have interface return all accounts in the list field if the type is not specified. Modified Paths: -------------- trunk/web_interface/astpp-admin.cgi Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-02-01 00:34:10 UTC (rev 2228) +++ trunk/web_interface/astpp-admin.cgi 2009-02-01 00:59:00 UTC (rev 2229) @@ -2192,6 +2192,7 @@ filename => '/var/lib/astpp/templates/account-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); + $params->{type} = -1 if !$params->{type}; # Default to listing all accounts; my $yes = gettext("YES"); my $no = gettext("NO"); return gettext("Cannot view account until database is configured") @@ -2380,6 +2381,7 @@ return gettext("Please configure 'Pricelists'") . "\n" unless @pricelists; if ( $params->{action} eq gettext("Generate Account") ) { + if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { my $pricelistinfo = &get_pricelist( $astpp_db, $params->{pricelist} ); @@ -2390,9 +2392,10 @@ $params->{count} = 1; $params->{pennies} = 0; $params->{number} = $params->{customnum}; + if ($params->{number} > 0) { $status .= &generate_accounts( $params, $config ); my $accountinfo = &get_account( $astpp_db, $params->{number} ); - ### Here we add support to add IAX and SIP devices at account creation. + ## Here we add support to add IAX and SIP devices at account creation. if ( $params->{SIP} ) { $config->{rt_sip_type} = $params->{devicetype}; $config->{ipaddr} = $params->{ipaddr}; @@ -2463,6 +2466,9 @@ } } ### End of Device creation support + } else { + $status = "No account number entered!"; + } } $template->param( pricelist_menu => popup_menu( @@ -2496,6 +2502,7 @@ accounttype_menu => popup_menu( -name => "accounttype", -values => \%types, + -labels => $types, -default => 0 ) ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-01 00:34:16
|
Revision: 2228 http://astpp.svn.sourceforge.net/astpp/?rev=2228&view=rev Author: darrenkw Date: 2009-02-01 00:34:10 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Fixed a small typo. Modified Paths: -------------- trunk/web_interface/astpp-admin.cgi Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-01-31 23:20:21 UTC (rev 2227) +++ trunk/web_interface/astpp-admin.cgi 2009-02-01 00:34:10 UTC (rev 2228) @@ -8192,7 +8192,7 @@ while ( my $packageinfo = $results->fetchrow_hashref ) { $ASTPP->debug( user => $param->{username}, - debug => "PACKAGE: " . $packgeinfo->{id} + debug => "PACKAGE: " . $packageinfo->{id} ); my (%row); $row{id} = $packageinfo->{id}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-01-31 23:22:10
|
Revision: 2226 http://astpp.svn.sourceforge.net/astpp/?rev=2226&view=rev Author: darrenkw Date: 2009-01-31 22:07:39 +0000 (Sat, 31 Jan 2009) Log Message: ----------- Added support for Freeswitch clients to authenticate by ip address as stored in ASTPP. Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-01-31 19:57:58 UTC (rev 2225) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-01-31 22:07:39 UTC (rev 2226) @@ -90,9 +90,11 @@ { my ($self, %arg) = @_; my ($sql,$tmp); + $arg{ip_address} = $arg{ip} if $arg{ip}; #Freeswitch passes the ip in a different format. $tmp = "SELECT * FROM ip_map WHERE ip = " . $self->{_astpp_db}->quote($arg{ip_address}) - . " AND prefix IN (NULL,'') OR ip = " . $self->{_astpp_db}->quote($arg{ip_address}) - . " AND " . $self->{_astpp_db}->quote($arg{destination}) . " RLIKE prefix ORDER BY LENGTH(prefix) DESC LIMIT 1"; + . " AND prefix IN (NULL,'') OR ip = " . $self->{_astpp_db}->quote($arg{ip_address}); + $tmp .= " AND " . $self->{_astpp_db}->quote($arg{destination}) . " RLIKE prefix" if $arg{destination}; + $tmp .= " ORDER BY LENGTH(prefix) DESC LIMIT 1"; $sql = $self->{_astpp_db}->prepare($tmp); $sql->execute; my $anidata = $sql->fetchrow_hashref; @@ -251,7 +253,7 @@ $sql->finish; return @results; } - + sub fs_list_sip_params #Return the list of parameters set on a freeswitch sip account { @@ -311,6 +313,28 @@ $arg{xml} .= "</variables>\n"; $arg{xml} .= "</user>\n"; }; + my @ip_users = &ip_address_authenticate($self,%arg); + foreach my $record (@ip_users) { +# This is only temporary and should be removed +# +$record->{id} = 0; +# + $arg{xml} .= "<user id=\"" . $record->{account} . $record->{ip} . "\" ip=\"" . $record->{ip} . "\">\n"; + $arg{xml} .= "<params>\n"; + 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"; + } + $arg{xml} .= "</params>\n"; + $arg{xml} .= "<variables>\n"; + my @vars = &fs_list_sip_vars($self,$record->{id}); + foreach my $record (@vars) { + $arg{xml} .= "<variable name=\"" . $record->{var_name} . "\" value=\"" . $record->{var_value} . "\"/>\n"; + } + $arg{xml} .= "<variable name=\"accountcode\" value=\"" . $record->{account} . "\"/>\n"; + $arg{xml} .= "</variables>\n"; + $arg{xml} .= "</user>\n"; + } $arg{xml} .= "</domain>\n"; return $arg{xml}; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-01-31 23:20:27
|
Revision: 2227 http://astpp.svn.sourceforge.net/astpp/?rev=2227&view=rev Author: darrenkw Date: 2009-01-31 23:20:21 +0000 (Sat, 31 Jan 2009) Log Message: ----------- Correct the code to handle users authenticating by ip address. Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-01-31 22:07:39 UTC (rev 2226) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-01-31 23:20:21 UTC (rev 2227) @@ -332,6 +332,7 @@ $arg{xml} .= "<variable name=\"" . $record->{var_name} . "\" value=\"" . $record->{var_value} . "\"/>\n"; } $arg{xml} .= "<variable name=\"accountcode\" value=\"" . $record->{account} . "\"/>\n"; + $arg{xml} .= "<variable name=\"user_context\" value=\"" . $record->{context} . "\"/>\n"; $arg{xml} .= "</variables>\n"; $arg{xml} .= "</user>\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-01-31 19:58:09
|
Revision: 2225 http://astpp.svn.sourceforge.net/astpp/?rev=2225&view=rev Author: darrenkw Date: 2009-01-31 19:57:58 +0000 (Sat, 31 Jan 2009) Log Message: ----------- Corrected which table the data is getting placed into. Modified Paths: -------------- trunk/freeswitch/contrib/wasim/cdrload.pl Modified: trunk/freeswitch/contrib/wasim/cdrload.pl =================================================================== --- trunk/freeswitch/contrib/wasim/cdrload.pl 2009-01-31 18:53:47 UTC (rev 2224) +++ trunk/freeswitch/contrib/wasim/cdrload.pl 2009-01-31 19:57:58 UTC (rev 2225) @@ -36,7 +36,8 @@ foreach my $line (@LS) { chop($line); $ASTPP->debug($line); - my $stm = "load data local infile '$line' into table TABLE fields enclosed by '\"' terminated by ','"; + my $stm = "load data local infile '$line' into table $config->{freeswitch_cdr_table} fields enclosed by '\"' terminated by ','"; + print STDERR $stm if $config->{debug} == 1; my $ul = $cdr_db->prepare($stm) or die "$0: Couldn't prepare statement $stm: " . $cdr_db->errstr;; $ul->execute(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-01-31 18:53:54
|
Revision: 2224 http://astpp.svn.sourceforge.net/astpp/?rev=2224&view=rev Author: darrenkw Date: 2009-01-31 18:53:47 +0000 (Sat, 31 Jan 2009) Log Message: ----------- Add sample configuration from my testing machine. Added Paths: ----------- trunk/freeswitch/contrib/darren/ trunk/freeswitch/contrib/darren/conf/ trunk/freeswitch/contrib/darren/conf/autoload_configs/ trunk/freeswitch/contrib/darren/conf/autoload_configs/acl.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/alsa.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/cdr_csv.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/cdr_csv.conf.xml.backup trunk/freeswitch/contrib/darren/conf/autoload_configs/conference.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/console.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/dialplan_directory.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/dingaling.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/enum.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/event_multicast.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/event_socket.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/fax.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/iax.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/ivr.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/java.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/limit.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/local_stream.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/logfile.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/lua.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/modules.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/openmrcp.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/perl.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/pocketsphinx.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/portaudio.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/post_load_modules.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/python.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/rss.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/sofia.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/spidermonkey.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/switch.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/syslog.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/timezones.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/voicemail.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/wanpipe.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/woomera.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/xml_cdr.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/xml_curl.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/xml_rpc.conf.xml trunk/freeswitch/contrib/darren/conf/autoload_configs/zeroconf.conf.xml trunk/freeswitch/contrib/darren/conf/dialplan/ trunk/freeswitch/contrib/darren/conf/dialplan/default.xml trunk/freeswitch/contrib/darren/conf/dialplan/extensions/ trunk/freeswitch/contrib/darren/conf/dialplan/extensions/00_pizza_demo.xml trunk/freeswitch/contrib/darren/conf/dialplan/extensions/99999_enum.xml trunk/freeswitch/contrib/darren/conf/dialplan/features.xml trunk/freeswitch/contrib/darren/conf/dialplan/public.xml trunk/freeswitch/contrib/darren/conf/directory/ trunk/freeswitch/contrib/darren/conf/directory/default/ trunk/freeswitch/contrib/darren/conf/directory/default/1001.xml trunk/freeswitch/contrib/darren/conf/directory/default/1002.xml trunk/freeswitch/contrib/darren/conf/directory/default/1003.xml trunk/freeswitch/contrib/darren/conf/directory/default/1004.xml trunk/freeswitch/contrib/darren/conf/directory/default/1005.xml trunk/freeswitch/contrib/darren/conf/directory/default/1006.xml trunk/freeswitch/contrib/darren/conf/directory/default/1007.xml trunk/freeswitch/contrib/darren/conf/directory/default/1008.xml trunk/freeswitch/contrib/darren/conf/directory/default/1009.xml trunk/freeswitch/contrib/darren/conf/directory/default/1010.xml trunk/freeswitch/contrib/darren/conf/directory/default/1011.xml trunk/freeswitch/contrib/darren/conf/directory/default/1012.xml trunk/freeswitch/contrib/darren/conf/directory/default/1013.xml trunk/freeswitch/contrib/darren/conf/directory/default/1014.xml trunk/freeswitch/contrib/darren/conf/directory/default/1015.xml trunk/freeswitch/contrib/darren/conf/directory/default/1016.xml trunk/freeswitch/contrib/darren/conf/directory/default/1017.xml trunk/freeswitch/contrib/darren/conf/directory/default/1018.xml trunk/freeswitch/contrib/darren/conf/directory/default/1019.xml trunk/freeswitch/contrib/darren/conf/directory/default/brian.xml trunk/freeswitch/contrib/darren/conf/directory/default/default.xml trunk/freeswitch/contrib/darren/conf/directory/default.xml trunk/freeswitch/contrib/darren/conf/extensions.conf trunk/freeswitch/contrib/darren/conf/freeswitch.xml trunk/freeswitch/contrib/darren/conf/fur_elise.ttml trunk/freeswitch/contrib/darren/conf/jingle_profiles/ trunk/freeswitch/contrib/darren/conf/jingle_profiles/client.xml trunk/freeswitch/contrib/darren/conf/jingle_profiles/server.xml trunk/freeswitch/contrib/darren/conf/lang/ trunk/freeswitch/contrib/darren/conf/lang/de/ trunk/freeswitch/contrib/darren/conf/lang/de/de.xml trunk/freeswitch/contrib/darren/conf/lang/de/demo/ trunk/freeswitch/contrib/darren/conf/lang/de/demo/demo.xml trunk/freeswitch/contrib/darren/conf/lang/de/vm/ trunk/freeswitch/contrib/darren/conf/lang/de/vm/tts.xml trunk/freeswitch/contrib/darren/conf/lang/en/ trunk/freeswitch/contrib/darren/conf/lang/en/demo/ trunk/freeswitch/contrib/darren/conf/lang/en/demo/demo-ivr.xml trunk/freeswitch/contrib/darren/conf/lang/en/demo/demo.xml trunk/freeswitch/contrib/darren/conf/lang/en/en.xml trunk/freeswitch/contrib/darren/conf/lang/en/vm/ trunk/freeswitch/contrib/darren/conf/lang/en/vm/sounds.xml trunk/freeswitch/contrib/darren/conf/lang/en/vm/tts.xml trunk/freeswitch/contrib/darren/conf/lang/fr/ trunk/freeswitch/contrib/darren/conf/lang/fr/demo/ trunk/freeswitch/contrib/darren/conf/lang/fr/demo/demo.xml trunk/freeswitch/contrib/darren/conf/lang/fr/fr.xml trunk/freeswitch/contrib/darren/conf/lang/fr/vm/ trunk/freeswitch/contrib/darren/conf/lang/fr/vm/sounds.xml trunk/freeswitch/contrib/darren/conf/mime.types trunk/freeswitch/contrib/darren/conf/mrcp_profiles/ trunk/freeswitch/contrib/darren/conf/mrcp_profiles/openmrcp-v1.xml trunk/freeswitch/contrib/darren/conf/mrcp_profiles/openmrcp-v2.xml trunk/freeswitch/contrib/darren/conf/notify-voicemail.tpl trunk/freeswitch/contrib/darren/conf/sip_profiles/ trunk/freeswitch/contrib/darren/conf/sip_profiles/external/ trunk/freeswitch/contrib/darren/conf/sip_profiles/external/example.xml trunk/freeswitch/contrib/darren/conf/sip_profiles/external.xml trunk/freeswitch/contrib/darren/conf/sip_profiles/internal/ trunk/freeswitch/contrib/darren/conf/sip_profiles/internal/example.xml trunk/freeswitch/contrib/darren/conf/sip_profiles/internal-ipv6.xml trunk/freeswitch/contrib/darren/conf/sip_profiles/internal.xml trunk/freeswitch/contrib/darren/conf/tetris.ttml trunk/freeswitch/contrib/darren/conf/vars.xml trunk/freeswitch/contrib/darren/conf/voicemail.tpl trunk/freeswitch/contrib/darren/conf/web-vm.tpl Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/acl.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/acl.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/acl.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,29 @@ +<configuration name="acl.conf" description="Network Lists"> + <network-lists> + <list name="dl-candidates" default="allow"> + <node type="deny" cidr="10.0.0.0/8"/> + <node type="deny" cidr="172.16.0.0/12"/> + <node type="deny" cidr="192.168.0.0/16"/> + </list> + <list name="rfc1918" default="deny"> + <node type="allow" cidr="10.0.0.0/8"/> + <node type="allow" cidr="172.16.0.0/12"/> + <node type="allow" cidr="192.168.0.0/16"/> + </list> + + <list name="lan" default="allow"> + <node type="deny" cidr="192.168.42.0/24"/> + <node type="allow" cidr="192.168.42.42/32"/> + </list> + + <list name="strict" default="deny"> + <node type="allow" cidr="208.102.123.124/32"/> + </list> + + <list name="domains" default="deny"> + <node type="allow" domain="$${domain}"/> + </list> + + </network-lists> +</configuration> + Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/alsa.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/alsa.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/alsa.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,12 @@ +<configuration name="alsa.conf" description="Soundcard Endpoint"> + <settings> + <!--Default dialplan and caller-id info --> + <param name="dialplan" value="XML"/> + <param name="cid-name" value="N800 Alsa"/> + <param name="cid-num" value="5555551212"/> + + <!--audio sample rate and interval --> + <param name="sample-rate" value="8000"/> + <param name="codec-ms" value="20"/> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/cdr_csv.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/cdr_csv.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/cdr_csv.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,17 @@ +<configuration name="cdr_csv.conf" description="CDR CSV Format"> + <settings> + <!-- 'cdr-csv' will always be appended to log-base --> + <!--<param name="log-base" value="/var/log"/>--> + <param name="default-template" value="astpp"/> + <!-- This is like the info app but after the call is hung up --> + <!--<param name="debug" value="true"/>--> + <param name="rotate-on-hup" value="true"/> + <!-- may be a b or ab --> + <param name="legs" value="a"/> + </settings> + <templates> + <template name="example">"${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}", "${accountcode}","${read_codec}","${write_codec}"</template> + <template name="astpp">"${accountcode}","${caller_id_number}","${destination_number}","${context}","${caller_id}","${channel_name}","${bridge_channel}","${last_app}","${last_arg}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${amaflags}","${uuid}","${userfield}","${read_codec}","${write_codec}","none","none"</template> + </templates> +</configuration> + Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/cdr_csv.conf.xml.backup =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/cdr_csv.conf.xml.backup (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/cdr_csv.conf.xml.backup 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,20 @@ +<configuration name="cdr_csv.conf" description="CDR CSV Format"> + <settings> + <!-- 'cdr-csv' will always be appended to log-base --> + <!--<param name="log-base" value="/var/log"/>--> + <param name="default-template" value="example"/> + <!-- This is like the info app but after the call is hung up --> + <!--<param name="debug" value="true"/>--> + <param name="rotate-on-hup" value="true"/> + <!-- may be a b or ab --> + <param name="legs" value="a"/> + </settings> + <templates> + <template name="sql">INSERT INTO cdr VALUES ("${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}", "${accountcode}");</template> + <template name="example">"${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}", "${accountcode}","${read_codec}","${write_codec}"</template> + <template name="snom">"${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}", "${accountcode}","${read_codec}","${write_codec}","${sip_user_agent}","${call_clientcode}","${sip_rtp_rxstat}","${sip_rtp_txstat}","${sofia_record_file}"</template> + <template name="linksys">"${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}","${accountcode}","${read_codec}","${write_codec}","${sip_user_agent}","${sip_p_rtp_stat}"</template> + <template name="asterisk">"${accountcode}","${caller_id_number}","${destination_number}","${context}","${caller_id}","${channel_name}","${bridge_channel}","${last_app}","${last_arg}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${amaflags}","${uuid}","${userfield}"</template> + </templates> +</configuration> + Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/conference.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/conference.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/conference.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,150 @@ +<!-- http://wiki.freeswitch.org/wiki/Mod_conference --> +<!-- None of these paths are real if you want any of these options you need to really set them up --> +<configuration name="conference.conf" description="Audio Conference"> + <!-- Advertise certain presence on startup . --> + <advertise> + <room name="3001@$${domain}" status="FreeSWITCH"/> + </advertise> + + <!-- These are the default keys that map when you do not specify a caller control group --> + <!-- Note: none and default are reserved names for group names --> + <caller-controls> + <group name="default"> + <control action="mute" digits="0"/> + <control action="deaf mute" digits="*"/> + <control action="energy up" digits="9"/> + <control action="energy equ" digits="8"/> + <control action="energy dn" digits="7"/> + <control action="vol talk up" digits="3"/> + <control action="vol talk zero" digits="2"/> + <control action="vol talk dn" digits="1"/> + <control action="vol listen up" digits="6"/> + <control action="vol listen zero" digits="5"/> + <control action="vol listen dn" digits="4"/> + <control action="hangup" digits="#"/> + </group> + </caller-controls> + + <!-- Profiles are collections of settings you can reference by name. --> + <profiles> + <!--If no profile is specified it will default to "default"--> + <profile name="default"> + <!-- Domain (for presence) --> + <param name="domain" value="$${domain}"/> + <!-- Sample Rate--> + <param name="rate" value="8000"/> + <!-- Number of milliseconds per frame --> + <param name="interval" value="20"/> + <!-- Energy level required for audio to be sent to the other users --> + <param name="energy-level" value="300"/> + + <!--Can be | delim of waste|mute|deaf waste will always transmit data to each channel + even during silence --> + <!--<param name="member-flags" value="waste"/>--> + + <!-- Name of the caller control group to use for this profile --> + <!-- <param name="caller-controls" value="some name"/> --> + <!-- TTS Engine to use --> + <!--<param name="tts-engine" value="cepstral"/>--> + <!-- TTS Voice to use --> + <!--<param name="tts-voice" value="david"/>--> + + <!-- If TTS is enabled all audio-file params beginning with --> + <!-- 'say:' will be considered text to say with TTS --> + <!-- Set a default path here so you can use relative paths in the other sound params--> + <param name="sound-prefix" value="$${base_dir}/sounds/en/us/callie"/> + <!-- File to play to acknowledge succees --> + <!--<param name="ack-sound" value="beep.wav"/>--> + <!-- File to play to acknowledge failure --> + <!--<param name="nack-sound" value="beeperr.wav"/>--> + <!-- File to play to acknowledge muted --> + <param name="muted-sound" value="conference/conf-muted.wav"/> + <!-- File to play to acknowledge unmuted --> + <param name="unmuted-sound" value="conference/conf-unmuted.wav"/> + <!-- File to play if you are alone in the conference --> + <param name="alone-sound" value="conference/conf-alone.wav"/> + <!-- File to play endlessly (nobody will ever be able to talk) --> + <!--<param name="perpetual-sound" value="perpetual.wav"/>--> + <!-- File to play when you're alone (music on hold)--> + <param name="moh-sound" value="$${hold_music}"/> + <!-- File to play when you join the conference --> + <param name="enter-sound" value="tone_stream://%(200,0,500,600,700)"/> + <!-- File to play when you leave the conference --> + <param name="exit-sound" value="tone_stream://%(500,0,300,200,100,50,25)"/> + <!-- File to play when you ae ejected from the conference --> + <param name="kicked-sound" value="conference/conf-kicked.wav"/> + <!-- File to play when the conference is locked --> + <param name="locked-sound" value="conference/conf-locked.wav"/> + <!-- File to play when the conference is locked during the call--> + <param name="is-locked-sound" value="conference/conf-is-locked.wav"/> + <!-- File to play when the conference is unlocked during the call--> + <param name="is-unlocked-sound" value="conference/conf-is-unlocked.wav"/> + <!-- File to play to prompt for a pin --> + <param name="pin-sound" value="conference/conf-pin.wav"/> + <!-- File to play to when the pin is invalid --> + <param name="bad-pin-sound" value="conference/conf-bad-pin.wav"/> + <param name="comfort-noise-level" value="1400"/> + <!-- Conference pin --> + <!--<param name="pin" value="12345"/>--> + <!-- Default Caller ID Name for outbound calls --> + <param name="caller-id-name" value="$${outbound_caller_name}"/> + <!-- Default Caller ID Number for outbound calls --> + <param name="caller-id-number" value="$${outbound_caller_id}"/> + <!-- Suppress start and stop talking events --> + <!-- <param name="suppress-events" value="start-talking,stop-talking"/> --> + <!-- enable comfort noise generation --> + <param name="comfort-noise" value="true"/> + <!-- Uncomment auto-record to toggle recording every conference call. --> + <!-- Another valid value is shout://user:pa...@se.../live.mp3 --> + <!-- + <param name="auto-record" value="/usr/local/freeswitch/sounds/conference/${conference_name}_${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/> + --> + </profile> + + <profile name="wideband"> + <param name="domain" value="$${domain}"/> + <param name="rate" value="16000"/> + <param name="interval" value="20"/> + <param name="energy-level" value="300"/> + <param name="sound-prefix" value="$${base_dir}/sounds/en/us/callie"/> + <param name="muted-sound" value="conference/conf-muted.wav"/> + <param name="unmuted-sound" value="conference/conf-unmuted.wav"/> + <param name="alone-sound" value="conference/conf-alone.wav"/> + <param name="moh-sound" value="$${hold_music}"/> + <param name="enter-sound" value="tone_stream://%(200,0,500,600,700)"/> + <param name="exit-sound" value="tone_stream://%(500,0,300,200,100,50,25)"/> + <param name="kicked-sound" value="conference/conf-kicked.wav"/> + <param name="locked-sound" value="conference/conf-locked.wav"/> + <param name="is-locked-sound" value="conference/conf-is-locked.wav"/> + <param name="is-unlocked-sound" value="conference/conf-is-unlocked.wav"/> + <param name="pin-sound" value="conference/conf-pin.wav"/> + <param name="bad-pin-sound" value="conference/conf-bad-pin.wav"/> + <param name="caller-id-name" value="$${outbound_caller_name}"/> + <param name="caller-id-number" value="$${outbound_caller_id}"/> + <param name="comfort-noise" value="true"/> + </profile> + + <profile name="ultrawideband"> + <param name="domain" value="$${domain}"/> + <param name="rate" value="32000"/> + <param name="interval" value="20"/> + <param name="energy-level" value="300"/> + <param name="sound-prefix" value="$${base_dir}/sounds/en/us/callie"/> + <param name="muted-sound" value="conference/conf-muted.wav"/> + <param name="unmuted-sound" value="conference/conf-unmuted.wav"/> + <param name="alone-sound" value="conference/conf-alone.wav"/> + <param name="moh-sound" value="$${hold_music}"/> + <param name="enter-sound" value="tone_stream://%(200,0,500,600,700)"/> + <param name="exit-sound" value="tone_stream://%(500,0,300,200,100,50,25)"/> + <param name="kicked-sound" value="conference/conf-kicked.wav"/> + <param name="locked-sound" value="conference/conf-locked.wav"/> + <param name="is-locked-sound" value="conference/conf-is-locked.wav"/> + <param name="is-unlocked-sound" value="conference/conf-is-unlocked.wav"/> + <param name="pin-sound" value="conference/conf-pin.wav"/> + <param name="bad-pin-sound" value="conference/conf-bad-pin.wav"/> + <param name="caller-id-name" value="$${outbound_caller_name}"/> + <param name="caller-id-number" value="$${outbound_caller_id}"/> + <param name="comfort-noise" value="true"/> + </profile> + </profiles> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/console.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/console.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/console.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,56 @@ +<configuration name="console.conf" description="Console Logger"> + <!-- pick a file name, a function name or 'all' --> + <!-- map as many as you need for specific debugging --> + <mappings> + <!-- + name can be a file name, function name or 'all' + value is one or more of debug,info,notice,warning,err,crit,alert,all + See examples below + + + The following map is the default, which is all debug levels enabled: + <map name="all" value="debug,info,notice,warning,err,crit,alert"/> + + + Example: the following turns on debugging for error and critical levels only + <map name="all" value="err,crit"/> + + NOTE: using map name="all" will override any other settings! If you + want a more specific set of console messages then you will need + to specify which files and/or functions you want to have debug + messages. One option is to turn on just the more critical + messages with map name="all", then specify the other types of + console messages you want to see for various files and functions. + + Example: turn on ERROR, CRIT, ALERT for all modules, then specify other + levels for various modules and functions + + <map name="all" value="err,crit,alert"/> + <map name="switch_loadable_module_process" value="all"/> + <map name="mod_local_stream.c" value="warning,debug"/> + <map name="mod_sndfile.c" value="warning,info,debug"/> + --> + <map name="all" value="console,debug,info,notice,warning,err,crit,alert"/> + + <!-- + You can use or modify this sample set of mappings. It turns on higher + level messages for all modules and then specifies extra lower level + messages for OpenZAP, Sofia, and switch core messages. + + <map name="all" value="warning,err,crit,alert"/> + <map name="zap_analog.c" value="all"/> + <map name="zap_io.c" value="all"/> + <map name="zap_isdn.c" value="all"/> + <map name="zap_zt.c" value="all"/> + <map name="mod_openzap" value="all"/> + <map name="sofia.c" value="notice"/> + <map name="switch_core_state_machine.c" value="all"/> + + --> + </mappings> + <settings> + <!-- comment or set to false for no color logging --> + <param name="colorize" value="true"/> + <param name="loglevel" value="info"/> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/dialplan_directory.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/dialplan_directory.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/dialplan_directory.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,9 @@ +<configuration name="dialplan_directory.conf" description="Dialplan Directory"> + <settings> + <param name="directory-name" value="ldap"/> + <param name="host" value="ldap.freeswitch.org"/> + <param name="dn" value="cn=Manager,dc=freeswitch,dc=org"/> + <param name="pass" value="test"/> + <param name="base" value="dc=freeswitch,dc=org"/> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/dingaling.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/dingaling.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/dingaling.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,9 @@ +<configuration name="dingaling.conf" description="XMPP Jingle Endpoint"> + <settings> + <param name="debug" value="0"/> + <param name="codec-prefs" value="PCMU"/> + </settings> + + <X-PRE-PROCESS cmd="include" data="../jingle_profiles/*.xml"/> + +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/enum.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/enum.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/enum.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,14 @@ +<configuration name="enum.conf" description="ENUM Module"> + <settings> + <param name="default-root" value="e164.org"/> + <param name="default-isn-root" value="freenum.org"/> + <param name="query-timeout" value="10"/> + <param name="auto-reload" value="true"/> + </settings> + + <routes> + <route service="E2U+SIP" regex="sip:(.*)" replace="sofia/${use_profile}/$1"/> + <!--<route service="E2U+IAX2" regex="iax2:(.*)" replace="iax/$1"/>--> + <!--<route service="E2U+XMPP" regex="XMPP:(.*)" replace="dingaling/$${xmpp_server_profile}/$1"/>--> + </routes> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/event_multicast.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/event_multicast.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/event_multicast.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,8 @@ +<configuration name="event_multicast.conf" description="Multicast Event"> + <settings> + <param name="address" value="225.1.1.1"/> + <param name="port" value="4242"/> + <param name="bindings" value="all"/> + </settings> +</configuration> + Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/event_socket.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/event_socket.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/event_socket.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,8 @@ +<configuration name="event_socket.conf" description="Socket Client"> + <settings> + <param name="listen-ip" value="127.0.0.1"/> + <param name="listen-port" value="8021"/> + <param name="password" value="ClueCon"/> + <!--<param name="apply-inbound-acl" value="lan"/>--> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/fax.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/fax.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/fax.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,12 @@ +<configuration name="fax.conf" description="FAX application configuration"> + <settings> + <param name="use-ecm" value="true"/> + <param name="verbose" value="false"/> + <param name="disable-v17" value="false"/> + <param name="ident" value="SpanDSP Fax Ident"/> + <param name="header" value="SpanDSP Fax Header"/> + + <param name="spool-dir" value="/tmp"/> + <param name="file-prefix" value="faxrx"/> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/iax.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/iax.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/iax.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,12 @@ +<configuration name="iax.conf" description="IAX Configuration"> + <settings> + <param name="debug" value="0"/> + <param name="ip" value="$${local_ip_v4}"/> + <param name="port" value="4569"/> + <param name="context" value="public"/> + <param name="dialplan" value="XML"/> + <param name="codec-prefs" value="PCMU@20i,PCMA,speex,L16"/> + <param name="codec-master" value="us"/> + <param name="codec-rates" value="8"/> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/ivr.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/ivr.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/ivr.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,58 @@ +<configuration name="ivr.conf" description="IVR menus"> + <menus> + <!-- demo IVR setup --> + <!-- demo IVR, Main Menu --> + <menu name="demo_ivr" + greet-long="phrase:demo_ivr_main_menu" + greet-short="phrase:demo_ivr_main_menu_short" + invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav" + exit-sound="voicemail/vm-goodbye.wav" + timeout ="10000" + inter-digit-timeout="2000" + max-failures="3" + max-timeouts="3" + digit-len="4"> + <entry action="menu-exec-app" digits="1" param="bridge sofia/$${domain}/88...@co..."/> + <entry action="menu-exec-app" digits="2" param="transfer 9996 XML default"/> <!-- FS echo --> + <entry action="menu-exec-app" digits="3" param="transfer 9999 XML default"/> <!-- MOH --> + <entry action="menu-sub" digits="4" param="demo_ivr_submenu"/> <!-- demo sub menu --> + <entry action="menu-exec-app" digits="5" param="transfer 1234*256 enum"/> <!-- Screaming monkeys --> + <entry action="menu-exec-app" digits="/^(10[01][0-9])$/" param="transfer $1 XML default"/> + <entry action="menu-top" digits="9"/> <!-- Repeat this menu --> + </menu> + <!-- Demo IVR, Sub Menu --> + <menu name="demo_ivr_submenu" + greet-long="phrase:demo_ivr_sub_menu" + greet-short="phrase:demo_ivr_sub_menu_short" + invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav" + exit-sound="voicemail/vm-goodbye.wav" + timeout="15000" + max-failures="3" + max-timeouts="3"> + <entry action="menu-top" digits="*"/> + </menu> + + </menus> + + +</configuration> + + +<!-- TTS sample; non-functional but it demonstrates say: and TTS --> +<!-- + <menu name="demo3" + greet-long="say:Press 1 to join the conference, Press 2 to join the other conference" + greet-short="say:Press 1 to join the conference, Press 2 to join the other conference" + invalid-sound="say:invalid extension" + exit-sound="say:exit sound" + timeout ="15000" + max-failures="3"> + <entry action="menu-exit" digits="*"/> + <entry action="menu-playback" digits="1" param="say:You pressed 1"/> + <entry action="menu-call-transfer" digits="2" param= + + +"1000"/> + <entry action="menu-call-transfer" digits="3" param="1001"/> + </menu> +--> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/java.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/java.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/java.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,11 @@ +<configuration name="java.conf" description="Java Plug-Ins"> + <!-- Path to the Java 1.6 virtual machine to use --> + <javavm path="/usr/java/jdk1.6.0/jre/lib/i386/client/libjvm.so"/> + <!-- Options to pass to Java --> + <options> + <!-- Your class path (make sure freeswitch.jar is on it) --> + <option value="-Djava.class.path=/usr/local/freeswitch/scripts/freeswitch.jar"/> + <!-- Enable remote debugging --> + <option value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:8000"/> + </options> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/limit.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/limit.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/limit.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,5 @@ +<configuration name="limit.conf" description="LIMIT Configuration"> + <settings> + <!--<param name="odbc-dsn" value="dsn:user:pass"/>--> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/local_stream.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/local_stream.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/local_stream.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,26 @@ +<configuration name="local_stream.conf" description="stream files from local dir"> + <directory name="moh/8000" path="$${base_dir}/sounds/music/8000"> + <param name="rate" value="8000"/> + <param name="shuffle" value="true"/> + <param name="channels" value="1"/> + <param name="interval" value="20"/> + <param name="timer_name" value="soft"/> + </directory> + + <directory name="moh/16000" path="$${base_dir}/sounds/music/16000"> + <param name="rate" value="16000"/> + <param name="shuffle" value="true"/> + <param name="channels" value="1"/> + <param name="interval" value="20"/> + <param name="timer_name" value="soft"/> + </directory> + <!-- + <directory name="moh/32000" path="$${base_dir}/sounds/music/32000"> + <param name="rate" value="32000"/> + <param name="shuffle" value="true"/> + <param name="channels" value="1"/> + <param name="interval" value="20"/> + <param name="timer_name" value="soft"/> + </directory> + --> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/logfile.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/logfile.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/logfile.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,24 @@ +<configuration name="logfile.conf" description="File Logging"> + <settings> + <!-- true to auto rotate on HUP, false to open/close --> + <param name="rotate-on-hup" value="true"/> + </settings> + <profiles> + <profile name="default"> + <settings> + <!-- File to log to --> + <!--<param name="logfile" value="/var/log/freeswitch.log"/>--> + <!-- At this length in bytes rotate the log file (0 for never) --> + <!--<param name="rollover" value="10485760"/>--> + </settings> + <mappings> + <!-- + name can be a file name, function name or 'all' + value is one or more of debug,info,notice,warning,err,crit,alert,all + Please see comments in console.conf.xml for more information + --> + <map name="all" value="debug,info,notice,warning,err,crit,alert"/> + </mappings> + </profile> + </profiles> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/lua.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/lua.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/lua.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,15 @@ +<configuration name="lua.conf" description="LUA Configuration"> + <settings> + <!--<param name="xml-handler-script" value="/dp.lua"/>--> + <!--<param name="xml-handler-bindings" value="dialplan"/>--> + + <!-- + The following options identifies a lua script that is launched + at startup and may live forever in the background. + You can define multiple lines, one for each script you + need to run. + --> + <!--<param name="startup-script" value="startup_script_1.lua"/>--> + <!--<param name="startup-script" value="startup_script_2.lua"/>--> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/modules.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/modules.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/modules.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,90 @@ +<configuration name="modules.conf" description="Modules"> + <modules> + + <!-- Loggers (I'd load these first) --> + <load module="mod_console"/> + <load module="mod_logfile"/> + <!-- <load module="mod_syslog"/> --> + + <!-- Multi-Faceted --> + <!-- mod_enum is a dialplan interface, an application interface and an api command interface --> + <load module="mod_enum"/> + + <!-- XML Interfaces --> + <!-- <load module="mod_xml_rpc"/> --> + <load module="mod_xml_curl"/> + <load module="mod_xml_cdr"/> + + <!-- Event Handlers --> + <load module="mod_cdr_csv"/> + <!-- <load module="mod_event_multicast"/> --> + <load module="mod_event_socket"/> + <!-- <load module="mod_xmpp_event"/> --> + <!-- <load module="mod_zeroconf"/> --> + + <!-- Directory Interfaces --> + <!-- <load module="mod_ldap"/> --> + + <!-- Endpoints --> + <!-- <load module="mod_dingaling"/> --> + <!-- <load module="mod_iax"/> --> + <!-- <load module="mod_portaudio"/> --> + <!-- <load module="mod_alsa"/> --> + <load module="mod_sofia"/> + <!-- <load module="mod_wanpipe"/> --> + <!-- <load module="mod_woomera"/> --> + <!-- <load module="mod_openzap"/> --> + + <!-- Applications --> + <load module="mod_commands"/> + <load module="mod_conference"/> + <load module="mod_dptools"/> + <load module="mod_expr"/> + <load module="mod_fifo"/> + <load module="mod_voicemail"/> + <load module="mod_limit"/> + <load module="mod_esf"/> + <load module="mod_fsv"/> + + <!-- Dialplan Interfaces --> + <!-- <load module="mod_dialplan_directory"/> --> + <load module="mod_dialplan_xml"/> + <load module="mod_dialplan_asterisk"/> + + <!-- Codec Interfaces --> + <load module="mod_voipcodecs"/> + <load module="mod_g723_1"/> + <load module="mod_g729"/> + <load module="mod_amr"/> + <load module="mod_ilbc"/> + <load module="mod_speex"/> + <load module="mod_h26x"/> + + <!-- File Format Interfaces --> + <load module="mod_sndfile"/> + <load module="mod_native_file"/> + <!--For icecast/mp3 streams/files--> + <!--<load module="mod_shout"/>--> + <!--For local streams (play all the files in a directory)--> + <load module="mod_local_stream"/> + <load module="mod_tone_stream"/> + + <!-- Timers --> + + <!-- Languages --> + <load module="mod_spidermonkey"/> + <load module="mod_perl"/> + <!-- <load module="mod_python"/> --> + <!-- <load module="mod_java"/> --> + <load module="mod_lua"/> + + <!-- ASR /TTS --> + <!-- <load module="mod_cepstral"/> --> + <!-- <load module="mod_openmrcp"/> --> + <!-- <load module="mod_rss"/> --> + <load module="mod_pocketsphinx"/> + + <!-- Say --> + <load module="mod_say_en"/> + </modules> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/openmrcp.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/openmrcp.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/openmrcp.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,10 @@ +<!-- http://wiki.freeswitch.org/wiki/Mod_openmrcp#Configuration --> +<configuration name="openmrcp.conf" description="mod_openmrcp configuration"> + <settings> + <param name="asr_default_profile" value="openmrcp-v2"/> + <param name="tts_default_profile" value="openmrcp-v2"/> + </settings> + <profiles> + <X-PRE-PROCESS cmd="include" data="../mrcp_profiles/*.xml"/> + </profiles> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/perl.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/perl.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/perl.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,16 @@ +<configuration name="perl.conf" description="PERL Configuration"> + <settings> + <!--<param name="xml-handler-script" value="/tmp/xml.pl"/>--> + <!--<param name="xml-handler-bindings" value="dialplan"/>--> + + <!-- + The following options identifies a perl script that is launched + at startup and may live forever in the background. + You can define multiple lines, one for each script you + need to run. + --> +<!-- <param name="startup-script" value="/root/test_perl.pl"/> --> + <!--param name="startup-script" value="startup_script_2.pl"/--> + + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/pocketsphinx.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/pocketsphinx.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/pocketsphinx.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,10 @@ +<configuration name="pocketsphinx.conf" description="PocketSphinx ASR Configuration"> + <settings> + <param name="threshold" value="400"/> + <param name="silence-hits" value="25"/> + <param name="listen-hits" value="1"/> + <param name="auto-reload" value="true"/> + <!--<param name="narrowband-model" value="communicator"/>--> + <!--<param name="wideband-model" value="wsj1"/>--> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/portaudio.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/portaudio.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/portaudio.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,33 @@ +<configuration name="portaudio.conf" description="Soundcard Endpoint"> + <settings> + <!-- indev, outdev, ringdev: + partial case sensitive string match on something in the name + or the device number prefixed with # eg "#1" (or blank for default) --> + + <!-- device to use for input --> + <param name="indev" value=""/> + <!-- device to use for output --> + <param name="outdev" value=""/> + + <!--device to use for inbound ring --> + <!--<param name="ringdev" value=""/>--> + <!--File to play as the ring sound --> + <!--<param name="ring-file" value="/sounds/ring.wav"/>--> + <!--Number of seconds to pause between rings --> + <!--<param name="ring-interval" value="5"/>--> + + <!--file to play when calls are on hold--> + <!--<param name="hold-file" value="/sounds/holdmusic.wav"/>--> + <!--Timer to use for hold music (i'd leave this one commented)--> + <!--<param name="timer-name" value="soft"/>--> + + <!--Default dialplan and caller-id info --> + <param name="dialplan" value="XML"/> + <param name="cid-name" value="FreeSwitch"/> + <param name="cid-num" value="5555551212"/> + + <!--audio sample rate and interval --> + <param name="sample-rate" value="8000"/> + <param name="codec-ms" value="20"/> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/post_load_modules.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/post_load_modules.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/post_load_modules.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,4 @@ +<configuration name="post_load_modules.conf" description="Modules"> + <modules> + </modules> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/python.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/python.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/python.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,16 @@ +<configuration name="python.conf" description="PYTHON Configuration"> + <settings> + <!--<param name="xml-handler-script" value="dp"/>--> + <!--<param name="xml-handler-bindings" value="dialplan"/>--> + + <!-- + The following options identifies a py script that is launched + at startup and may live forever in the background. + You can define multiple lines, one for each script you + need to run. + --> + <!--<param name="startup-script" value="startup_script_1.py"/>--> + <!--<param name="startup-script" value="startup_script_2.py"/>--> + + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/rss.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/rss.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/rss.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,7 @@ +<configuration name="rss.conf" description="RSS Parser"> + <feeds> + <!-- Just download the files to wherever and refer to them here --> + <!-- <feed name="Slash Dot">/home/rss/rss.rss</feed> --> + <!-- <feed name="News Forge">/home/rss/newsforge.rss</feed> --> + </feeds> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/sofia.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/sofia.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/sofia.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,9 @@ +<configuration name="sofia.conf" description="sofia Endpoint"> + <global_settings> + <param name="log-level" value="0"/> + </global_settings> + + <profiles> + <X-PRE-PROCESS cmd="include" data="../sip_profiles/*.xml"/> + </profiles> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/spidermonkey.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/spidermonkey.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/spidermonkey.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,8 @@ +<configuration name="spidermonkey.conf" description="Spider Monkey JavaScript Plug-Ins"> + <modules> + <load module="mod_spidermonkey_teletone"/> + <load module="mod_spidermonkey_core_db"/> + <load module="mod_spidermonkey_socket"/> + <!--<load module="mod_spidermonkey_odbc"/>--> + </modules> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/switch.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/switch.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/switch.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,66 @@ +<configuration name="switch.conf" description="Core Configuration"> + + <cli-keybindings> + <key name="1" value="help"/> + <key name="2" value="status"/> + <key name="3" value="show channels"/> + <key name="4" value="show calls"/> + <key name="5" value="sofia status"/> + <key name="6" value="reloadxml"/> + <key name="7" value="console loglevel 0"/> + <key name="8" value="console loglevel 7"/> + <key name="9" value="sofia status profile internal"/> + <key name="10" value="fsctl pause"/> + <key name="11" value="fsctl resume"/> + <key name="12" value="version"/> + </cli-keybindings> + + <settings> + <!--Colorize the Console --> + <param name="colorize-console" value="true"/> + <!--Most channels to allow at once --> + <param name="max-sessions" value="1000"/> + <!--Most channels to create per second --> + <param name="sessions-per-second" value="30"/> + <!-- Default Global Log Level - value is one of debug,info,notice,warning,err,crit,alert --> + <param name="loglevel" value="debug"/> + <!--Try to catch any crashes that can be recoverable (in the context of a call)--> + <param name="crash-protection" value="false"/> + <!--<param name="max_dtmf_duration" value="192000"/>--> + <!--<param name="default_dtmf_duration" value="8000"/>--> + <!-- + If you want to send out voicemail notifications via Windows you'll need to change the mailer-app + variable to the setting below: + + <param name="mailer-app" value="msmtp"/> + + Donot change mailer-app-args. + You will also need to download a sendmail clone for Windows (msmtp). This version works without issue: + http://msmtp.sourceforge.net/index.html. Download and copy the .exe to %winddir%\system32. + You'll need to create a small config file for smtp credentials (host name, authentication, tls, etc.) in + %USERPROFILE%\Application Data\ called "msmtprc.txt". Below is a sample copy of this file: + + ################################### + # The SMTP server of the provider. + account provider + host smtp.myisp.com + from jo...@my... + auth login + user johndoe + password mypassword + + # Set a default account + account default : provider + ################################### + + --> + <param name="mailer-app" value="sendmail"/> + <param name="mailer-app-args" value="-t"/> + <param name="dump-cores" value="yes"/> + <!--RTP port range --> + <!--<param name="rtp-start-port" value="16384"/>--> + <!--<param name="rtp-end-port" value="32768"/>--> + </settings> + +</configuration> + Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/syslog.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/syslog.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/syslog.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,15 @@ +<configuration name="syslog.conf" description="Syslog Logger"> + <!-- SYSLOG --> + <!-- emerg - system is unusable --> + <!-- alert - action must be taken immediately --> + <!-- crit - critical conditions --> + <!-- err - error conditions --> + <!-- warning - warning conditions --> + <!-- notice - normal, but significant, condition --> + <!-- info - informational message --> + <!-- debug - debug-level message --> + <settings> + <param name="ident" value="freeswitch"/> + <param name="loglevel" value="warning"/> + </settings> +</configuration> Added: trunk/freeswitch/contrib/darren/conf/autoload_configs/timezones.conf.xml =================================================================== --- trunk/freeswitch/contrib/darren/conf/autoload_configs/timezones.conf.xml (rev 0) +++ trunk/freeswitch/contrib/darren/conf/autoload_configs/timezones.conf.xml 2009-01-31 18:53:47 UTC (rev 2224) @@ -0,0 +1,551 @@ +<configuration name="timezones.conf" description="Timezones"> + <timezones> + <zone name="Africa/Abidjan" value="GMT0" /> + <zone name="Africa/Accra" value="GMT0" /> + <zone name="Africa/Addis_Ababa" value="EAT-3" /> + <zone name="Africa/Algiers" value="CET-1" /> + <zone name="Africa/Asmara" value="EAT-3" /> + <zone name="Africa/Asmera" value="EAT-3" /> + <zone name="Africa/Bamako" value="GMT0" /> + <zone name="Africa/Bangui" value="WAT-1" /> + <zone name="Africa/Banjul" value="GMT0" /> + <zone name="Africa/Bissau" value="GMT0" /> + <zone name="Africa/Blantyre" value="CAT-2" /> + <zone name="Africa/Brazzaville" value="WAT-1" /> + <zone name="Africa/Bujumbura" value="CAT-2" /> + <zone name="Africa/Cairo" value="EEST" /> + <zone name="Africa/Casablanca" value="WET0" /> + <zone name="Africa/Ceuta" value="CET-1CEST,M3.5.0,M10.5.0/3" /> + <zone name="Africa/Conakry" value="GMT0" /> + <zone name="Africa/Dakar" value="GMT0" /> + <zone name="Africa/Dar_es_Salaam" value="EAT-3" /> + <zone name="Africa/Djibouti" value="EAT-3" /> + <zone name="Africa/Douala" value="WAT-1" /> + <zone name="Africa/El_Aaiun" value="WET0" /> + <zone name="Africa/Freetown" value="GMT0" /> + <zone name="Africa/Gaborone" value="CAT-2" /> + <zone name="Africa/Harare" value="CAT-2" /> + <zone name="Africa/Johannesburg" value="SAST-2" /> + <zone name="Africa/Kampala" value="EAT-3" /> + <zone name="Africa/Khartoum" value="EAT-3" /> + <zone name="Africa/Kigali" value="CAT-2" /> + <zone name="Africa/Kinshasa" value="WAT-1" /> + <zone name="Africa/Lagos" value="WAT-1" /> + <zone name="Africa/Libreville" value="WAT-1" /> + <zone name="Africa/Lome" value="GMT0" /> + <zone name="Africa/Luanda" value="WAT-1" /> + <zone name="Africa/Lubumbashi" value="CAT-2" /> + <zone name="Africa/Lusaka" value="CAT-2" /> + <zone name="Africa/Malabo" value="WAT-1" /> + <zone name="Africa/Maputo" value="CAT-2" /> + <zone name="Africa/Maseru" value="SAST-2" /> + <zone name="Africa/Mbabane" value="SAST-2" /> + <zone name="Africa/Mogadishu" value="EAT-3" /> + <zone name="Africa/Monrovia" value="GMT0" /> + <zone name="Africa/Nairobi" value="EAT-3" /> + <zone name="Africa/Ndjamena" value="WAT-1" /> + <zone name="Africa/Niamey" value="WAT-1" /> + <zone name="Africa/Nouakchott" value="GMT0" /> + <zone name="Africa/Ouagadougou" value="GMT0" /> + <zone name="Africa/Porto-Novo" value="WAT-1" /> + <zone name="Africa/Sao_Tome" value="GMT0" /> + <zone name="Africa/Timbuktu" value="GMT0" /> + <zone name="Africa/Tripoli" value="EET-2" /> + <zone name="Africa/Tunis" value="CET-1CEST,M3.5.0,M10.5.0/3" /> + <zone name="Africa/Windhoek" value="WAT-1WAST,M9.1.0,M4.1.0" /> + + <zone name="America/Adak" value="HAST10HADT,M3.2.0,M11.1.0" /> + <zone name="America/Anchorage" value="AKST9AKDT,M3.2.0,M11.1.0" /> + <zone name="America/Anguilla" value="AST4" /> + <zone name="America/Antigua" value="AST4" /> + <zone name="America/Araguaina" value="BRT3" /> + <zone name="America/Argentina/Buenos_Aires" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Argentina/Catamarca" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Argentina/ComodRivadavia" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Argentina/Cordoba" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Argentina/Jujuy" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Argentina/La_Rioja" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Argentina/Mendoza" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Argentina/Rio_Gallegos" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Argentina/San_Juan" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Argentina/San_Luis" value="ART3" /> + <zone name="America/Argentina/Tucuman" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Argentina/Ushuaia" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Aruba" value="AST4" /> + <zone name="America/Asuncion" value="PYT4PYST,M10.3.0/0,M3.2.0/0" /> + <zone name="America/Atikokan" value="EST5" /> + <zone name="America/Atka" value="HAST10HADT,M3.2.0,M11.1.0" /> + <zone name="America/Bahia" value="BRT3" /> + <zone name="America/Barbados" value="AST4" /> + <zone name="America/Belem" value="BRT3" /> + <zone name="America/Belize" value="CST6" /> + <zone name="America/Blanc-Sablon" value="AST4" /> + <zone name="America/Boa_Vista" value="AMT4" /> + <zone name="America/Bogota" value="COT5" /> + <zone name="America/Boise" value="MST7MDT,M3.2.0,M11.1.0" /> + <zone name="America/Buenos_Aires" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Cambridge_Bay" value="MST7MDT,M3.2.0,M11.1.0" /> + <zone name="America/Campo_Grande" value="AMT4AMST,M10.2.0/0,M2.3.0/0" /> + <zone name="America/Cancun" value="CST6CDT,M4.1.0,M10.5.0" /> + <zone name="America/Caracas" value="VET4:30" /> + <zone name="America/Catamarca" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Cayenne" value="GFT3" /> + <zone name="America/Cayman" value="EST5" /> + <zone name="America/Chicago" value="CST6CDT,M3.2.0,M11.1.0" /> + <zone name="America/Chihuahua" value="MST7MDT,M4.1.0,M10.5.0" /> + <zone name="America/Coral_Harbour" value="EST5" /> + <zone name="America/Cordoba" value="ART3ARST,M10.1.0/0,M3.3.0/0" /> + <zone name="America/Costa_Rica" value="CST6" /> + <zone name="America/Cuiaba" value="AMT4AMST,M10.2.0/0,M2.3.0/0" /> + <zone name="America/Curacao" value="AST4" /> + <zone name="America/Danmarkshavn" value="GMT0" /> + <zone name="America/Dawson" value="PST8PDT,M3.2.0,M11.1.0" /> + <zone name="America/Dawson_Creek" value="MST7" /> + <zone name="America/Denver" value="MST7MDT,M3.2.0,M11.1.0" /> + <zone name="America/Detroit" value="EST5EDT,M3.2.0,M11.1.0" /> + <zone name="America/Dominica" value="AST4" /> + <zone name="America/Edmonton" value="MST7MDT,M3.2.0,M11.1.0" /> + <zone name="America/Eirunepe" value="ACT5" /> + <zone name="America/El_Salvador" value="CST6" /> + <zone name="America/Ensenada" value="PST8PDT,M4.1.0,M10.5.0" /> + <zone name="America/Fortaleza" value="B... [truncated message content] |
From: <dar...@us...> - 2009-01-24 20:56:11
|
Revision: 2223 http://astpp.svn.sourceforge.net/astpp/?rev=2223&view=rev Author: darrenkw Date: 2009-01-24 20:56:05 +0000 (Sat, 24 Jan 2009) Log Message: ----------- Corrected code so that if ASTPP can't find a route it will fail back to the freeswitch dialplan. Modified Paths: -------------- trunk/freeswitch/astpp-fs-xml.pl Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-01-17 17:42:06 UTC (rev 2222) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-01-24 20:56:05 UTC (rev 2223) @@ -126,6 +126,7 @@ ( $callstatus, $maxlength ) = &max_length( $astpp_db, $config, $carddata, $params->{'Caller-Destination-Number'} ); + my $routeinfo = &get_route( $astpp_db, $config, $params->{'Caller-Destination-Number'}, @@ -136,6 +137,11 @@ my $minimumcharge = $routeinfo->{cost}; my @reseller_list; $ASTPP->debug( debug => "CALLSTATUS: $callstatus MAX_LENGTH: $maxlength" ); + + if (!$routeinfo->{cost} && !$routeinfo->{pricelist}) { + $ASTPP->debug( debug => "COULD NOT FIND ROUTE. EXITING SO DIALPLAN CAN TAKE OVER" ); + exit(0); + } while ( $carddata->{reseller} && $maxlength > 1 && $callstatus == 1 ) { $ASTPP->debug( debug => "FINDING LIMIT FOR: $carddata->{reseller}" ); $carddata = &get_account( $astpp_db, $carddata->{reseller} ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-01-17 17:42:09
|
Revision: 2222 http://astpp.svn.sourceforge.net/astpp/?rev=2222&view=rev Author: darrenkw Date: 2009-01-17 17:42:06 +0000 (Sat, 17 Jan 2009) Log Message: ----------- Updated the changelog Modified Paths: -------------- trunk/ChangeLog Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-01-17 17:21:21 UTC (rev 2221) +++ trunk/ChangeLog 2009-01-17 17:42:06 UTC (rev 2222) @@ -1,3 +1,246 @@ +2009-01-17 17:21 darrenkw + + * Makefile, astpp-admin.cgi, astpp-auto-admin.cgi, + astpp-callback.cgi, astpp-callingcards-daily.pl, astpp-common.pl, + astpp-device-monitor.pl, astpp-email-incoming.pl, + astpp-generate-invoices.pl, astpp-low-balance.pl, + astpp-pricelist.cgi, astpp-rate-engine.pl, astpp-refill.cgi, + astpp-update-balance.pl, astpp-users.cgi, astpp.jpg, astpp.png, + images/astpp.png, menu.js, scripts, + scripts/astpp-callingcards-daily.pl, scripts/astpp-common.pl, + scripts/astpp-device-monitor.pl, scripts/astpp-email-incoming.pl, + scripts/astpp-generate-invoices.pl, scripts/astpp-low-balance.pl, + scripts/astpp-rate-engine.pl, scripts/astpp-update-balance.pl, + style.css, web_interface, web_interface/astpp-admin.cgi, + web_interface/astpp-auto-admin.cgi, + web_interface/astpp-callback.cgi, + web_interface/astpp-pricelist.cgi, + web_interface/astpp-refill.cgi, web_interface/astpp-users.cgi, + web_interface/menu.js, web_interface/style.css: A whole bunch + more cleanup of the svn tree. Try to put everything in a logical + location. + +2009-01-17 17:13 darrenkw + + * Makefile, asterisk_apps/astpp-ani-map.agi, + asterisk_apps/astpp-authorize.agi, + asterisk_apps/astpp-callback-register.agi, + asterisk_apps/astpp-callback.agi, + asterisk_apps/astpp-callingcards.agi, + asterisk_apps/astpp-did-map.agi, asterisk_apps/astpp-ip-map.agi, + asterisk_apps/astpp-lcr.agi, + asterisk_apps/astpp-manager-variables.agi, + asterisk_apps/astpp-refill.agi, astpp-ani-map.agi, + astpp-authorize.agi, astpp-callback-register.agi, + astpp-callback.agi, astpp-callingcards.agi, astpp-did-map.agi, + astpp-ip-map.agi, astpp-lcr.agi, astpp-manager-variables.agi, + astpp-refill.agi: Moved the agi files into the asterisk_apps + directory. + +2009-01-17 02:19 darrenkw + + * astpp-common.pl, contrib/auto_dialer/LICENSE: Change auto_dialer + license to BSD. + Fix code that was causing invoices to be totaled incorrectly in + oscommerce. + +2008-12-07 01:06 darrenkw + + * astpp-common.pl, freeswitch/astpp-fs-xml.pl, + sql/astpp-2008-12-06.sql: Corrected Freeswitch max call length + support. + +2008-12-06 22:37 darrenkw + + * astpp-common.pl, freeswitch/astpp-fs-xml.pl, + sql/astpp-2008-12-06.sql: Fix the code that causes astpp to + return results for freeswitch directory even when no result is + found. Also add code to round totals and taxes to a different + number of decimal points than we bill to. This is useful to be + able to bill calls accurately up to X decimal points but still + present the customer with a bill where the totals are just + rounded to 2 decimal points. + +2008-12-06 18:35 darrenkw + + * freeswitch/astpp-fs-xml.pl: Tidied the source code. + +2008-12-03 06:14 darrenkw + + * astpp-common.pl: Fixed Thirdlane DID billing code. + +2008-12-02 03:35 darrenkw + + * astpp-common.pl, contrib/auto_dialer/aleph-autocall.pl: Repair + the thirdlane DID billing handling. + +2008-12-02 02:39 darrenkw + + * contrib/auto_dialer/aac.conf: Changed the default CLID number + +2008-11-25 06:22 darrenkw + + * astpp-common.pl, sql/astpp-2008-11-24.sql: Add Thirdlane(tm) + specific code. + +2008-11-25 05:24 darrenkw + + * astpp-common.pl: The "decimalpoints" variable is not being + respected when posting to oscommerce. Fixed this. + +2008-11-25 05:12 darrenkw + + * astpp-common.pl, sql/astpp-2008-11-24.sql: Added support to only + post charges greater or less than 0 to oscommerce. + +2008-11-16 01:59 darrenkw + + * modules/ASTPP/lib/ASTPP.pm: Correct the code that returns + freeswitch user vars. + +2008-11-16 01:42 darrenkw + + * modules/ASTPP/lib/ASTPP.pm: Removed an old line of code that's + not needed any more and was causing it to not run. + +2008-11-11 23:09 darrenkw + + * astpp-admin.cgi, templates/freeswitch-sip-list.tpl, + templates/list-errors.tpl: Correct the code to show freeswitch + voicemail passwords. Moved the list_errors template to + list-errors to match the rest. + +2008-11-11 23:06 darrenkw + + * astpp-admin.cgi: Performed a "perl-tidy" and cleaned up all the + code formatting. + +2008-11-11 22:57 darrenkw + + * astpp-admin.cgi, modules/ASTPP/lib/ASTPP.pm: Added support to + "deactivate" cdrs from the list_errors section. + +2008-11-11 19:05 darrenkw + + * astpp-admin.cgi, astpp-common.pl, astpp-users.cgi, + modules/ASTPP/lib/ASTPP.pm, sql/astpp-2008-10-31.sql: Added + support to view and delete Freeswitch SIP users from within the + interface. + +2008-11-08 04:36 darrenkw + + * contrib/auto_dialer/Makefile, contrib/auto_dialer/aac.conf, + contrib/auto_dialer/aleph-aac.agi, + contrib/auto_dialer/aleph-aac.sql, + contrib/auto_dialer/aleph-autocall.pl: Make a whole bunch of + improvements to the autodialer. + + M auto_dialer/aleph-autocall.pl + M auto_dialer/aac.conf + M auto_dialer/aleph-aac.sql + M auto_dialer/aleph-aac.agi + M auto_dialer/Makefile + +2008-11-01 22:01 darrenkw + + * templates/account-info.tpl: Fix a minor template bug. + +2008-10-28 04:19 darrenkw + + * astpp-admin.cgi, astpp-common.pl, astpp-rate-engine.pl, + sql/astpp-2008-10-14.sql, sql/cdrdb-2008-10-28.sql: Added more + freeswitch support. + +2008-10-10 04:25 darrenkw + + * astpp-common.pl: We now use the accountname instead of the CC + code on asterisk-realtime users accountcodes. + +2008-10-02 03:59 darrenkw + + * modules/ASTPP/lib/ASTPP.pm: Add support to properly return the + freeswitch sip profiles. + +2008-09-11 05:14 darrenkw + + * astpp-common.pl, freeswitch/astpp-fs-xml.pl, + modules/ASTPP/lib/ASTPP.pm, sql/astpp-2008-09-04.sql: Add support + for ASTPP to authenticate Freeswitch users. Also fixed the + freeswitch call length limiting code. + +2008-09-06 16:55 darrenkw + + * astpp-common.pl, astpp-generate-invoices.pl: Fix a bug in the "by + cdr date" invoice generation code. + +2008-09-04 00:06 darrenkw + + * Makefile: Added support to install the freeswich cgi files. + +2008-09-02 05:17 darrenkw + + * astpp-admin.cgi, templates/configuration-list.tpl: Added support + to add and delete configuration items. Somebody still needs to + add edit support. + +2008-09-02 05:15 darrenkw + + * astpp-update-balance.pl: Split the invoice generation code off of + astpp-update-balance.pl. + +2008-09-02 05:09 darrenkw + + * modules/ASTPP/lib/ASTPP.pm: Added Freeswitch LCR call time + limiting based on available credit. + +2008-09-02 05:04 darrenkw + + * freeswitch/astpp-fs-xml.pl, freeswitch/contrib, + freeswitch/contrib/wasim, freeswitch/contrib/wasim/README, + freeswitch/contrib/wasim/cdrload.pl: Add a contributed script and + modify it to use mostly ASTPP configuration rather than inline + configuration. Add partial support for time limiting FreeSwitch + LCR calls. + +2008-09-02 05:02 darrenkw + + * samples/sample.astpp-config.conf, + samples/sample.astpp-enh-config.conf, sql/astpp-2008-09-01.sql: + Added Freeswitch configuration and moved the remaining optional + configuration to the database. + +2008-08-28 17:15 darrenkw + + * astpp-admin.cgi: Fixed a problem caused by a missing + configuration line. + +2008-08-23 19:11 darrenkw + + * contrib/auto_dialer, contrib/auto_dialer/LICENSE, + contrib/auto_dialer/Makefile, contrib/auto_dialer/aac.conf, + contrib/auto_dialer/aleph-aac.agi, + contrib/auto_dialer/aleph-aac.sql, + contrib/auto_dialer/aleph-autocall.pl, contrib/surveys, + contrib/surveys/LICENCE, contrib/surveys/README, + contrib/surveys/survey.agi, contrib/surveys/survey.sql: Add a few + other scripts I've written. Both scripts are standalone but were + in danger of getting lost. + +2008-08-23 16:02 darrenkw + + * astpp-common.pl, astpp-generate-invoices.pl: Commit patch for the + following feature request. Will require more testing. + [ 2033328 ] Generate invoices on selected time period + +2008-07-03 00:06 darrenkw + + * modules/ASTPP/lib/ASTPP.pm: Fixed a pagination error. + +2008-06-07 15:00 darrenkw + + * ChangeLog: Commit inital version of the changelog. Thanks to + svn2cl! + 2008-06-07 14:41 darrenkw * freeswitch/README, freeswitch/conf, freeswitch/conf/README, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-01-17 17:21:26
|
Revision: 2221 http://astpp.svn.sourceforge.net/astpp/?rev=2221&view=rev Author: darrenkw Date: 2009-01-17 17:21:21 +0000 (Sat, 17 Jan 2009) Log Message: ----------- A whole bunch more cleanup of the svn tree. Try to put everything in a logical location. Modified Paths: -------------- trunk/Makefile Added Paths: ----------- trunk/images/astpp.png trunk/scripts/ trunk/scripts/astpp-callingcards-daily.pl trunk/scripts/astpp-common.pl trunk/scripts/astpp-device-monitor.pl trunk/scripts/astpp-email-incoming.pl trunk/scripts/astpp-generate-invoices.pl trunk/scripts/astpp-low-balance.pl trunk/scripts/astpp-rate-engine.pl trunk/scripts/astpp-update-balance.pl trunk/web_interface/ trunk/web_interface/astpp-admin.cgi trunk/web_interface/astpp-auto-admin.cgi trunk/web_interface/astpp-callback.cgi trunk/web_interface/astpp-pricelist.cgi trunk/web_interface/astpp-refill.cgi trunk/web_interface/astpp-users.cgi trunk/web_interface/menu.js trunk/web_interface/style.css Removed Paths: ------------- trunk/astpp-admin.cgi trunk/astpp-auto-admin.cgi trunk/astpp-callback.cgi trunk/astpp-callingcards-daily.pl trunk/astpp-common.pl trunk/astpp-device-monitor.pl trunk/astpp-email-incoming.pl trunk/astpp-generate-invoices.pl trunk/astpp-low-balance.pl trunk/astpp-pricelist.cgi trunk/astpp-rate-engine.pl trunk/astpp-refill.cgi trunk/astpp-update-balance.pl trunk/astpp-users.cgi trunk/astpp.jpg trunk/astpp.png trunk/menu.js trunk/style.css Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-01-17 17:13:20 UTC (rev 2220) +++ trunk/Makefile 2009-01-17 17:21:21 UTC (rev 2221) @@ -36,14 +36,14 @@ # Install Freeswitch .pl files as .cgi files install -m 755 -o $(OWNER) -g $(GROUP) freeswitch/astpp-fs-xml.pl $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-fs-xml.cgi # - install -m 755 -o $(OWNER) -g $(GROUP) astpp-callback.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-callback.cgi - install -m 755 -o $(OWNER) -g $(GROUP) astpp-pricelist.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-pricelist.cgi - install -m 755 -o $(OWNER) -g $(GROUP) astpp-refill.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-refill.cgi - install -m 755 -o $(OWNER) -g $(GROUP) astpp-admin.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-admin/astpp-admin.cgi - install -m 755 -o $(OWNER) -g $(GROUP) astpp-auto-admin.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-admin/astpp-auto-admin.cgi - install -m 755 -o $(OWNER) -g $(GROUP) astpp-users.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp/astpp-users.cgi - install -m 644 -o $(OWNER) -g $(GROUP) style.css $(DESTDIR)$(WWWDIR)/html/_astpp/ - install -m 644 -o $(OWNER) -g $(GROUP) menu.js $(DESTDIR)$(WWWDIR)/html/_astpp/ + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-callback.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-callback.cgi + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-pricelist.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-pricelist.cgi + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-refill.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-refill.cgi + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-admin.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-admin/astpp-admin.cgi + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-auto-admin.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-admin/astpp-auto-admin.cgi + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-users.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp/astpp-users.cgi + install -m 644 -o $(OWNER) -g $(GROUP) web_interface/style.css $(DESTDIR)$(WWWDIR)/html/_astpp/ + install -m 644 -o $(OWNER) -g $(GROUP) web_interface/menu.js $(DESTDIR)$(WWWDIR)/html/_astpp/ # Install Sample Configuration Files # install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.reseller-config.conf $(DESTDIR)$(ASTPPDIR)/sample.reseller-config.conf install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-config.conf @@ -69,7 +69,7 @@ done install_astpp_exec: - for x in ./*.pl; do \ + for x in scripts/*.pl; do \ echo $$x; \ install -m 755 -o $(OWNER) -g $(GROUP) $$x $(PREFIX)$(ASTPPEXECDIR); \ done @@ -92,6 +92,10 @@ install -m 644 $$x $(DESTDIR)$(WWWDIR)/html/_astpp/; \ done install -m 644 images/favicon.ico $(DESTDIR)$(WWWDIR)/html/_astpp/; + for x in images/*.png; do \ + echo $$x;\ + install -m 644 $$x $(DESTDIR)$(WWWDIR)/html/_astpp/; \ + done resolve_perl_dep: perl -MCPAN -e "install Text::Template"; Deleted: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2009-01-17 17:13:20 UTC (rev 2220) +++ trunk/astpp-admin.cgi 2009-01-17 17:21:21 UTC (rev 2221) @@ -1,11806 +0,0 @@ -#!/usr/bin/perl -# -# ASTPP - Open Source Voip Billing -# -# Copyright (C) 2006, Aleph Communications -# -# Darren Wiebe (da...@al...) -# Sergey Tamkovich was hired by Aleph Communications to add -# the import ability and some of the "statistics" features. -# -# This program is Free Software and is distributed under the -# terms of the GNU General Public License version 2. -############################################################ -# Account Status Info -# 0 = Account InActive -# 1 = Account Active -# 2 = Account Deactivated -# -# CDR Status Info -# 0 - New line -# 1 - Billed Line -# 2 - Deactivated Line -# -# -# Account Type -# 0 - Regular User (Has login permissions for astpp-users.cgi) -# 1 - Reseller (Has login permissions for astpp-users.cgi and has reduced permissions for astpp-admin.cgi) -# 2 - Admin (Has login permissions everywhere) -# 3 - Vendor (Has reduced login permissions in astpp-admin.cgi) -# 4 - Customer Service (Has reduced login permissions in astpp-admin.cgi) -# 5 - Call shop (Has reduced login permissions in astpp-admin.cgi) -# 6 - Booth (No login permissions) -############################################################################### -use POSIX; -use POSIX qw(strftime); -use DBI; -use CGI; -use CGI qw/:standard Vars/; -use Getopt::Long; -use Locale::Country; -use Locale::Language; -use Locale::gettext_pp qw(:locale_h); -use Data::Dumper; -use lib './lib', '../lib'; -use warnings; -use Asterisk::Manager; -use Text::CSV; -use HTML::Template; -use HTML::Template::Expr; -use Time::HiRes qw( gettimeofday tv_interval ); -use Data::Paginate; -use DateTime; -use DateTime::TimeZone; -use ASTPP; - -; # We use DateTime::TimeZone to show users cdrs in their own timezones. - -require "/usr/local/astpp/astpp-common.pl"; -$ENV{LANGUAGE} = "en"; # de, es, br - whatever -print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; -bindtextdomain( "astpp", "/usr/local/share/locale" ); -textdomain("astpp"); -use vars qw(@output $astpp_db $params $config - $status $config $limit $accountinfo - $freepbx_db $rt_db $openser_db $ASTPP); -my $starttime = [gettimeofday]; -$ASTPP = ASTPP->new; -$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. -$ASTPP->set_asterisk_agi($AGI); -$ASTPP->set_pagination_script("astpp-admin.cgi"); -my @Home = ( gettext("Home Page") ); -my @Accounts = ( - gettext("Create Account"), gettext("Process Payment"), - gettext("Remove Account"), gettext("Edit Account"), - gettext("List Accounts"), gettext("View Details") -); -my @Rates = ( - gettext("Pricelists"), gettext("Calc Charge"), - gettext("Routes"), gettext("Import Routes"), - gettext("Periodic Charges"), gettext("Packages"), - gettext("Counters") -); -my @DIDs = ( gettext("Manage DIDs"), gettext("Import DIDs") ); -my @LCR = ( - gettext("Providers"), gettext("Trunks"), - gettext("Outbound Routes"), - gettext("Import Outbound Routes") -); -my @System = ( gettext("Purge Deactivated"), gettext("Configuration") ); -my @Statistics = ( - gettext("Asterisk Stats"), gettext("List Errors"), - gettext("Trunk stats"), gettext("View CDRs"), - gettext("LCR Tables") -); - -my @Callingcards = ( - gettext("List Cards"), gettext("Add Cards"), - gettext("Delete Card"), gettext("Refill Card"), - gettext("View Card"), gettext("Update Card(s) Status"), - gettext("Reset InUse"), gettext("CC Brands") -); -my @SwitchConfig = (); -my @CallShops = ( gettext("Create CallShop"), gettext("Remove CallShop") ); -my @Booths = ( - gettext("Create Booth"), gettext("Remove Booth"), - gettext("List Booths"), gettext("View Booth") -); - -# Report added by Sonia Ali Khan <son...@gm...> -my @AdminReports = ( gettext("Reseller Report"), gettext("Vendor Report") ); - -my @CallShopReports = ( gettext("Booth Report") ); - -my @ResellerReports = ( - - # gettext("Brand Report"), - gettext("CallShop Report"), - gettext("Reseller Report"), - gettext("User Report") -); - -my %menumap = ( - gettext('Accounts') => \@Accounts, - gettext('Rates') => \@Rates, - gettext('DIDs') => \@DIDs, - gettext('Statistics') => \@Statistics, - gettext('System') => \@System, - gettext('LCR') => \@LCR, - gettext('Calling Cards') => \@Callingcards, - gettext('Switch Config') => \@SwitchConfig, - gettext('Booths') => \@Booths, - gettext('Call Shops') => \@CallShops, - gettext('Admin Reports') => \@AdminReports, - gettext('CallShop Reports') => \@CallShopReports, - gettext('Reseller Reports') => \@ResellerReports -); -my @months = ( - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' -); -my @techs = ( "SIP", "IAX2", "Zap", "Local", "OH323", "OOH323C" ); -my @incs = ( "1", "6", "30", "60" ); -my @devicetypes = ( gettext("friend"), gettext("user"), gettext("peer") ); -my %yesno = ( - '0' => gettext("NO"), - '1' => gettext("YES") -); -my @cardstatus = ( gettext("ACTIVE"), gettext("INACTIVE"), gettext("DELETED") ); -my %sweeplist = ( - '0' => gettext("daily"), - '1' => gettext("weekly"), - '2' => gettext("monthly"), - '3' => gettext("quarterly"), - '4' => gettext("semi-annually"), - '5' => gettext("annually") -); -my @output = ("STDERR"); # "LOGFILE" ); -my @language = all_language_codes; -@language = sort @language; -my @currency; -my @deviceprotocol = ("SIP"); -my @countries = all_country_names(); -@countries = sort @countries; -my @timezones = DateTime::TimeZone->all_names; -@timezones = sort(@timezones); -my ( - $rt_db, $astpp_db, $config, $params, $param, - $cdr_db, $agile_db, $body, $menu, $status, - $msg, $loginstat, @modes, $openser_db -); - -$params->{mode} = ""; -$params->{username} = ""; -$params->{password} = ""; -$loginstat = 0; - -sub login() { - my ( $sql, $count, $record, $cookie, $cookie1, $accountinfo ); - $sql = - $astpp_db->prepare( "SELECT COUNT(*) FROM accounts WHERE number = " - . $astpp_db->quote( $params->{username} ) - . " AND password = " - . $astpp_db->quote( $params->{password} ) - . " AND status = 1 AND type IN (1,2,3,4,5)" ); - $sql->execute; - $record = $sql->fetchrow_hashref; - $count = $record->{"COUNT(*)"}; - $sql->finish; - $cookie = cookie( - -name => 'ASTPP_User', - -value => $params->{username}, - -expires => '+8h', - -domain => $ENV->{SERVER_NAME}, - -path => $ENV->{SCRIPT_NAME} - ); - $cookie1 = cookie( - -name => 'ASTPP_Password', - -value => $params->{password}, - -expires => '+8h', - -domain => $ENV->{SERVER_NAME}, - -path => $ENV->{SCRIPT_NAME} - ); - - if ( $count == 1 ) { - $status .= gettext("Successful Login!") . "<br>"; - print header( -cookie => [ $cookie, $cookie1, ] ); - $accountinfo = &get_account( $astpp_db, $params->{username} ); - $params->{logintype} = $accountinfo->{type}; - } - if ( !$params->{username} && $config->{auth} eq $params->{password} ) { - $status .= gettext("Successful Login!") . "<br>"; - $count = 1; - print header( -cookie => [ $cookie, $cookie1 ] ); - $params->{logintype} = 2; - } - if ( $count == 0 && $params->{password} eq "" ) { - $params->{mode} = ""; - $status .= gettext("Please Login") . "<br>"; - print header(); - } - elsif ( $count == 0 ) { - $params->{mode} = ""; - $status .= gettext("Login Failed") . "<br>"; - print header(); - } - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-USER:") . " $params->{username}" - ); - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-PASS:") . " $params->{password}" - ); - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-AUTHCODE:") . " $config->{auth}" - ); - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-USER-COUNT:") . " $count" - ); - return ( $params->{mode}, $count ); -} - -sub verify_login() { - my ( $sql, $count, $record, $username, $password ); - $params->{username} = cookie('ASTPP_User'); - $params->{password} = cookie('ASTPP_Password'); - if ( !$params->{username} ) { - $params->{username} = ""; - } - if ( !$params->{password} ) { - $params->{password} = ""; - } - if ( $params->{username} && $params->{password} ) { - $sql = - $astpp_db->prepare( "SELECT COUNT(*) FROM accounts WHERE number = " - . $astpp_db->quote( $params->{username} ) - . " AND password = " - . $astpp_db->quote( $params->{password} ) - . " AND status = 1 AND type IN (1,2,3,4,5)" ); - $sql->execute; - $record = $sql->fetchrow_hashref; - $count = $record->{"COUNT(*)"}; - $sql->finish; - $count = 0 if !$count; - if ( $count == 1 ) { - $accountinfo = &get_account( $astpp_db, $params->{username} ); - $params->{logintype} = $accountinfo->{type}; - } - } - if ( !$params->{username} && $config->{auth} eq $params->{password} ) { - $count = 1; - $params->{logintype} = 2; - } - if ( $count != 1 && !$params->{password} ) { - $params->{mode} = ""; - $status .= "" . "<br>"; - $count = 0; - } - elsif ( $count != 1 ) { - $params->{mode} = ""; - $status .= gettext("Login Failed") . "<br>"; - $count = 0; - } - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-USER:") . " $params->{username}" - ) if $config->{debug} == 1 && $params->{username}; - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-PASS:") . " $params->{password}" - ) if $config->{debug} == 1 && $params->{password}; - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-AUTHCODE:") . " $config->{auth}" - ) if $config->{debug} == 1; - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-USER-COUNT:") . " $count" - ) if $config->{debug} == 1; - print header(); - return $count; -} - -sub logout() { - my ( $cookie, $cookie1 ); - $cookie = cookie( - -name => 'ASTPP_User', - -value => 'loggedout', - -expires => 'now' - ); - $cookie1 = cookie( - -name => 'ASTPP_Password', - -value => 'loggedout', - -expires => 'now' - ); - print header( -cookie => [ $cookie, $cookie1 ] ); - $status .= "Successfully Logged User Out" . "<br>"; - return ""; -} - -sub build_menu_ts() { - my ($selected) = @_; - my ( $tmp, $body, $x ); - my $i = 0; - foreach $tmp (@modes) { - $body .= -"<div class=\"ts_ddm\" name=tt$i id=tt$i style=\"visibility:hidden;width:200;background-color:#CCCCFF;\"onMouseover=\"clearhidemenu()\" onMouseout=\"dynamichide(event)\"><table width=100\% border=0 cellspacing=0 cellpadding=0>"; - my $j = 0; - foreach $x ( @{ $menumap{$tmp} } ) { - $body .= -"<tr><td name=t$i\_$j id=t$i\_$j><a href=\"?mode=$x\" onmouseover='light_on(t$i\_$j);' onmouseout='light_off(t$i\_$j);'> $x </a></td></tr> -\n"; - $j++; - } - $body .= "</table> -</div>"; - $i++; - } - $body .= "<table width=900 cellpadding=0 class=ts_menu><tr>\n"; - $i = 0; - foreach $tmp (@modes) { - $body .= -"<td name=t$i id=t$i><a href=\"?mode=$tmp\" onmouseover='light_on(t$i);dropdownmenu(this, event,\"tt$i\");' onmouseout='light_off(t$i);delayhidemenu();'> $tmp </a></td>\n"; - $i++; - } - $body .= "</tr></table>"; - return $body; -} - -sub build_body() { - if ( $params->{logintype} == 2 ) { #Admin Login - return &build_providers() if $params->{mode} eq gettext("Providers"); - return &build_trunks() if $params->{mode} eq gettext("Trunks"); - return &build_outbound_routes() - if $params->{mode} eq gettext("Outbound Routes"); - return &build_pricelists() if $params->{mode} eq gettext("Pricelists"); - return &build_routes() if $params->{mode} eq gettext("Routes"); - return &build_calc_charge() - if $params->{mode} eq gettext("Calc Charge"); - return &build_list_errors() - if $params->{mode} eq gettext("List Errors"); - return &build_lcr_tables() - if $params->{mode} eq gettext("LCR Tables"); - return &build_dids() if $params->{mode} eq gettext("Manage DIDs"); - return &build_import_dids() - if $params->{mode} eq gettext("Import DIDs"); - return &build_purge_deactivated() - if $params->{mode} eq gettext("Purge Deactivated"); - return &build_create_account() - if $params->{mode} eq gettext("Create Account"); - return &build_remove_account() - if $params->{mode} eq gettext("Remove Account"); - return &build_process_payment() - if $params->{mode} eq gettext("Process Payment"); - return &build_account_info() - if $params->{mode} eq gettext("View Details"); - return &build_list_accounts() - if $params->{mode} eq gettext("Accounts"); - return &build_list_accounts() - if $params->{mode} eq gettext("List Accounts"); - return &build_edit_account() - if $params->{mode} eq gettext("Edit Account"); - return &build_import_routes() - if $params->{mode} eq gettext("Import Routes"); - return &build_import_outbound_routes() - if $params->{mode} eq gettext("Import Outbound Routes"); - return &logout() - if $params->{mode} eq gettext("Logout"); - return &build_packages() - if $params->{mode} eq gettext("Packages"); - return &build_counters() - if $params->{mode} eq gettext("Counters"); - return &build_statistics() - if $params->{mode} eq gettext("Asterisk Stats"); - return &build_create_card() - if $params->{mode} eq gettext("Add Cards"); - return &build_list_cards() - if $params->{mode} eq gettext("List Cards"); - return &build_list_cards() - if $params->{mode} eq gettext("Calling Cards"); - return &build_update_card_status() - if $params->{mode} eq gettext("Update Card(s) Status"); - return &build_reset_card_inuse() - if $params->{mode} eq gettext("Reset InUse"); - return &build_view_card() if $params->{mode} eq gettext("View Card"); - return &build_cc_brands() - if $params->{mode} eq gettext("CC Brands"); - return &build_delete_cards() - if $params->{mode} eq gettext("Delete Card"); - return &build_refill_card() - if $params->{mode} eq gettext("Refill Card"); - return &build_sip_devices() - if $params->{mode} eq gettext("Asterisk(TM) SIP Devices"); - return &build_iax_devices() - if $params->{mode} eq gettext("Asterisk(TM) IAX Devices"); - return &build_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() - if $params->{mode} eq gettext("Statistics"); - return &build_periodic_charges() - if $params->{mode} eq gettext("Periodic Charges"); - return &build_view_cdrs() if $params->{mode} eq gettext("View CDRs"); - return &build_configuration() - if $params->{mode} eq gettext("Configuration"); - - return &build_add_callshop() - if $params->{mode} eq gettext("Create CallShop"); - return &build_remove_callshop() - if $params->{mode} eq gettext("Remove CallShop"); - - return &build_admin_reseller_report() - if $params->{mode} eq gettext("Reseller Report"); - return &build_admin_vendor_report() - if $params->{mode} eq gettext("Vendor Report"); - - return &build_homepage() - if $params->{mode} eq gettext("Home Page") - || $params->{mode} eq gettext("Home") - || $params->{mode} eq "" - || $params->{mode} eq gettext("Login") - || $params->{mode} eq gettext("Logout"); - return gettext("Not Available!") . "\n"; - } - elsif ( $params->{logintype} == 3 ) { #Vendor Login - return &build_stats_acd() - if $params->{mode} eq gettext("Trunk Statistics"); - return &logout() if $params->{mode} eq gettext("Logout"); - return &build_view_cdrs() if $params->{mode} eq gettext("View CDRs"); - return &build_outbound_routes() - if $params->{mode} eq gettext("Outbound Routes"); - $params->{mode} = gettext("Home"); - return gettext("Welcome to ASTPP!") . "\n" - if $params->{mode} eq gettext("Home"); - } - elsif ( $params->{logintype} == 4 ) { #Customer Service Login - return &build_create_account() - if $params->{mode} eq gettext("Create Account"); - return &build_remove_account() - if $params->{mode} eq gettext("Remove Account"); - return &build_process_payment() - if $params->{mode} eq gettext("Process Payment"); - return &build_account_info() - if $params->{mode} eq gettext("View Details"); - return &build_list_accounts() - if $params->{mode} eq gettext("List Accounts"); - return &build_edit_account() - if $params->{mode} eq gettext("Edit Account"); - return &build_calc_charge() - if $params->{mode} eq gettext("Calc Charge"); - return &build_dids() - if $params->{mode} eq gettext("Manage DIDs"); - return &build_dids() - if $params->{mode} eq gettext("DIDs"); - return &build_sip_devices() - if $params->{mode} eq gettext("Asterisk(TM) SIP Devices"); - return &build_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() - if $params->{mode} eq gettext("Asterisk Stats"); - return &build_create_card() if $params->{mode} eq gettext("Add Cards"); - return &build_list_cards() if $params->{mode} eq gettext("List Cards"); - return &build_update_card_status() - if $params->{mode} eq gettext("Update Card(s) Status"); - return &build_reset_card_inuse() - if $params->{mode} eq gettext("Reset InUse"); - return &build_view_card() if $params->{mode} eq gettext("View Card"); - return &build_cc_brands() - if $params->{mode} eq gettext("CC Brands"); - return &build_delete_cards() - if $params->{mode} eq gettext("Delete Card"); - return &build_refill_card() - if $params->{mode} eq gettext("Refill Card"); - - } - elsif ( $params->{logintype} == 1 ) { #Reseller Login - return &build_create_card() if $params->{mode} eq gettext("Add Cards"); - return &build_list_cards() if $params->{mode} eq gettext("List Cards"); - return &build_update_card_status() - if $params->{mode} eq gettext("Update Card(s) Status"); - return &build_reset_card_inuse() - if $params->{mode} eq gettext("Reset InUse"); - return &build_view_card() if $params->{mode} eq gettext("View Card"); - return &build_cc_brands() - if $params->{mode} eq gettext("CC Brands"); - return &build_delete_cards() - if $params->{mode} eq gettext("Delete Card"); - return &build_refill_card() - if $params->{mode} eq gettext("Refill Card"); - return &build_pricelists() if $params->{mode} eq gettext("Pricelists"); - return &build_routes() if $params->{mode} eq gettext("Routes"); - return &build_create_account() - if $params->{mode} eq gettext("Create Account"); - return &build_remove_account() - if $params->{mode} eq gettext("Remove Account"); - return &build_process_payment() - if $params->{mode} eq gettext("Process Payment"); - return &build_account_info() - if $params->{mode} eq gettext("View Details"); - return &build_list_accounts() - if $params->{mode} eq gettext("List Accounts"); - return &build_edit_account() - if $params->{mode} eq gettext("Edit Account"); - return &build_calc_charge() - if $params->{mode} eq gettext("Calc Charge"); - return &build_import_routes() - if $params->{mode} eq gettext("Import Routes"); - return &build_dids_reseller() - if $params->{mode} eq gettext("Manage DIDs"); - return &build_add_callshop() - if $params->{mode} eq gettext("Create CallShop"); - return &build_remove_callshop() - if $params->{mode} eq gettext("Remove CallShop"); - - # return &build_reseller_brand_report() - # if $params->{mode} eq gettext("Brand Report"); - return &build_reseller_callshop_report() - if $params->{mode} eq gettext("CallShop Report"); - return &build_reseller_reseller_report() - if $params->{mode} eq gettext("Reseller Report"); - return &build_reseller_user_report() - if $params->{mode} eq gettext("User Report"); - return &build_packages() - if $params->{mode} eq gettext("Packages"); - return &build_counters() - if $params->{mode} eq gettext("Counters"); - - return &build_homepage() - if $params->{mode} eq gettext("Home Page") - || $params->{mode} eq gettext("Home") - || $params->{mode} eq "" - || $params->{mode} eq gettext("Login") - || $params->{mode} eq gettext("Logout"); - return gettext("Not Available!") . "\n"; - return gettext("Not Available!") . "\n"; - } - elsif ( $params->{logintype} == 5 ) { #Call Shop Login - return &build_pricelists() if $params->{mode} eq gettext("Pricelists"); - return &build_routes() if $params->{mode} eq gettext("Routes"); - return &build_add_booth() if $params->{mode} eq gettext("Create Booth"); - return &build_remove_booth() - if $params->{mode} eq gettext("Remove Booth"); - return &build_list_booths() - if $params->{mode} eq gettext("List Booths"); - return &build_view_booth() if $params->{mode} eq gettext("View Booth"); - - return &build_create_card() if $params->{mode} eq gettext("Add Cards"); - return &build_list_cards() if $params->{mode} eq gettext("List Cards"); - return &build_list_cards() - if $params->{mode} eq gettext("Calling Cards"); - return &build_update_card_status() - if $params->{mode} eq gettext("Update Card(s) Status"); - return &build_reset_card_inuse() - if $params->{mode} eq gettext("Reset InUse"); - return &build_view_card() if $params->{mode} eq gettext("View Card"); - return &build_cc_brands() if $params->{mode} eq gettext("CC Brands"); - return &build_delete_cards() - if $params->{mode} eq gettext("Delete Card"); - return &build_refill_card() - if $params->{mode} eq gettext("Refill Card"); - return &build_callshop_callshop_report() - if $params->{mode} eq gettext("Booth Report"); - - return &build_list_booths() - if $params->{mode} eq gettext("Home Page") - || $params->{mode} eq gettext("Home") - || $params->{mode} eq "" - || $params->{mode} eq gettext("Login") - || $params->{mode} eq gettext("Logout"); - return gettext("Not Available!") . "\n"; - } - else { - $params->{mode} = gettext("Home"); - return gettext("Not Available!") . "\n"; - } -} - -sub build_purge_deactivated() { - my ( $status, $body ); - return gettext("Cannot drop items until database is configured") - unless $astpp_db; - if ( $params->{action} eq gettext("Yes, Drop Them") ) { - if ( $astpp_db->do("DELETE FROM outbound_routes WHERE status = 2") ) { - $status .= gettext("Dropped deactivated outbound routes.") . "<br>"; - } - else { - $status .= - gettext("Unable to drop deactivated outbound routes.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM routes WHERE status = 2") ) { - $status .= gettext("Dropped deactivated routes.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated routes.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM accounts WHERE status = 2") ) { - $status .= gettext("Dropped deactivated accounts.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated accounts.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM pricelists WHERE status = 2") ) { - $status .= gettext("Dropped deactivated pricelists.") . "<br>"; - } - else { - $status .= - gettext("Unable to drop deactivated pricelists.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM cdrs WHERE status = 2") ) { - $status .= gettext("Dropped deactivated cdrs.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated cdrs.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM trunks WHERE status = 2") ) { - $status .= gettext("Dropped deactivated trunks.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated trunks.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM dids WHERE status = 2") ) { - $status .= gettext("Dropped deactivated DIDs.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated DIDs.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM packages WHERE status = 2") ) { - $status .= gettext("Dropped deactivated packages.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated packages.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM callshops WHERE status = 2") ) { - $status .= gettext("Dropped deactivated callshops.") . "<br>"; - } - else { - $status .= - gettext("Unable to drop deactivated callshops.") . "<br>"; - } - } - $body = start_form(); - $body .= "<TABLE>"; - $body .= - "<tr><td>" - . gettext( - "Remove records in your system that have been marked as deactivated.") - . "</td></tr>\n"; - if ( $params->{action} eq gettext("Drop Deactivated Records") ) { - $body .= - "<tr><td>" - . hidden( -name => "mode", -value => gettext("Purge Deactivated") ) - . submit( -name => "action", -value => gettext("Yes, Drop Them") ) - . "</td><td>" - . submit( -name => "action", -value => gettext("Cancel") ) - . "</td></tr><tr><td>$status</td></tr></table>"; - } - else { - $body .= - "<tr><td>" - . hidden( -name => "mode", -value => gettext("Purge Deactivated") ) - . submit( - -name => "action", - -value => gettext("Drop Deactivated Records") - ) - . "</td><td>" - . submit( -name => "action", -value => gettext("Cancel") ) - . "</td></tr><tr><td>$status</td></tr></table>"; - } - return $body; -} - -######## Reporting Module ################ -# - -# Modified and Extended By Sonia Ali Khan <son...@gm...> -# Last updated: Sept. 11, 2007 at 1445hours GMT. - -sub build_filter($$) { - my ( $additional_fields, $submit_title ) = @_; - my ($body); - return gettext("ASTPP Database Not Available!") . "<br>" unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, @output ); - return gettext("Asterisk CDR Database Not Available!") . "<br>" - unless $cdr_db; - - # Set the defaults for the date options - my ( undef, undef, undef, $current_day, $current_month, $current_year ) = - localtime(); - my ( - $start_year, $start_month, $start_day, $start_hour, - $start_minute, $start_second, $end_year, $end_month, - $end_day, $end_hour, $end_minute, $end_second - ); - my $count = 0; - if ( !$params->{start_month} ) { - $start_year = $current_year + 1900; - $start_month = sprintf( "%02d", $current_month + 1 ); - $start_day = "01"; - $start_hour = "00"; - $start_minute = "00"; - $start_second = "00"; - $end_year = $current_year + 1900; - $end_month = sprintf( "%02d", $current_month + 1 ); - $end_day = $current_day; - $end_hour = "23"; - $end_minute = "59"; - $end_second = "59"; - } - else { - $start_year = $params->{start_year}; - $start_month = sprintf( "%02d", $params->{start_month} + 1 ); - $start_day = sprintf( "%02d", $params->{start_day} ); - $start_hour = sprintf( "%02d", $params->{start_hour} ); - $start_minute = sprintf( "%02d", $params->{start_minute} ); - $start_second = sprintf( "%02d", $params->{start_second} ); - $end_year = $params->{end_year}; - $end_month = sprintf( "%02d", $params->{end_month} + 1 ); - $end_day = sprintf( "%02d", $params->{end_day} ); - $end_hour = sprintf( "%02d", $params->{end_hour} ); - $end_minute = sprintf( "%02d", $params->{end_minute} ); - $end_second = sprintf( "%02d", $params->{end_second} ); - } - - $body .= - "<form method=get><input type=hidden name=mode value=\"" - . param('mode') - . "\"><table class=\"default\" width=100%>"; - $body .= - "<tr><td width=50%>" - . gettext("Start date:") - . "</td><td><input type=text name=start_year value=\"$start_year\" size=5><select name=start_month>"; - - for ( $id = 0 ; $id < 12 ; $id++ ) { - if ( $id == ( $start_month - 1 ) ) { - $body .= "<option value=$id selected>$months[$id]"; - } - else { - $body .= "<option value=$id>$months[$id]"; - } - } - $body .= -"</select><input type=text name=start_day value=\"$start_day\" size=3></td></tr>"; - $body .= - "<tr><td>" - . gettext("Start time:") - . "</td><td><input type=text name=start_hour value=\"$start_hour\" size=3>" - . "<input type=text name=start_minute value=\"$start_minute\" size=3>" - . "<input type=text name=start_second value=\"$start_second\" size=3></td></tr>"; - $body .= - "<tr><td>" - . gettext("End date:") - . "</td><td><input type=text name=end_year value=\"$end_year\" size=5><select name=end_month>"; - for ( $id = 0 ; $id < 12 ; $id++ ) { - if ( $id == ( $end_month - 1 ) ) { - $body .= "<option value=$id selected>$months[$id]"; - } - else { - $body .= "<option value=$id>$months[$id]"; - } - } - - $submit_title = "Filter!" if !$submit_title; - $body .= -"</select><input type=text name=end_day value=\"$end_day\" size=3></td></tr>"; - $body .= - "<tr><td>" - . gettext("End time:") - . "</td><td><input type=text name=end_hour value=\"$end_hour\" size=3>" - . "<input type=text name=end_minute value=\"$end_minute\" size=3>" - . "<input type=text name=end_second value=\"$end_second\" size=3></td></tr>\n"; - $body .= $additional_fields if $additional_fields; - $body .= -"<tr><td align=center colspan=2><input type=submit value=$submit_title></td></tr>"; - $body .= "</table>\n</form>"; - - my %report_filter = ( - 'start_year' => $start_year, - 'start_month' => $start_month, - 'start_day' => $start_day, - 'start_hour' => $start_hour, - 'start_minute' => $start_minute, - 'start_second' => $start_second, - 'end_year' => $end_year, - 'end_month' => $end_month, - 'end_day' => $end_day, - 'end_hour' => $end_hour, - 'end_minute' => $end_minute, - 'end_second' => $end_second, - 'start_date' => -"$start_year-$start_month-$start_day $start_hour:$start_minute:$start_second", - 'end_date' => - "$end_year-$end_month-$end_day $end_hour:$end_minute:$end_second", - 'form_body' => $body - ); - return \%report_filter; -} - -sub build_admin_reseller_report() { - return &build_report( "Reseller", "1" ); -} - -sub build_admin_vendor_report() { - return &build_report( "Vendor", "3" ); -} - -sub build_callshop_callshop_report() { - return &build_report( "Booth", "6" ); -} - -sub build_reseller_callshop_report() { - return &build_report( "Booth", "6" ); -} - -sub build_reseller_reseller_report() { - return &build_report( "Reseller", "1" ); -} - -sub build_reseller_user_report() { - return &build_report( "User", "0" ); -} - -sub build_list_box($$) { - my ( $in, $selected ) = @_; - my $body = ""; - undef %list; - @list{@$in} = (); - my @out = sort keys %list; # remove sort if undesired - for ( my $i = 0 ; $i < @out ; $i++ ) { - if ( $out[$i] eq $selected ) { - $body .= "<option value='$out[$i]' selected>$out[$i]</option>\n"; - } - else { - $body .= "<option value='$out[$i]'>$out[$i]</option>\n"; - } - } - return $body; -} - -sub build_report($$) { - - return gettext("Cannot display reports until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - return gettext("Cannot display reports until database is configured") - unless $cdr_db; - - my $name = shift; - my $type = shift; - my ( $sth, $body ); - - my $destination = $params->{destination}; - my $pattern = $params->{pattern}; - - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $sth = - $astpp_db->prepare( "SELECT * FROM accounts WHERE reseller = " - . $astpp_db->quote( $params->{username} ) - . " AND type IN ($type)" ); - } - else { - $sth = - $astpp_db->prepare("SELECT * FROM accounts WHERE type IN ($type)"); - } - - $sth->execute() - || return gettext("Something is wrong with astpp database") . "\n"; - - $body = "<tr><td align=right> $name:" - . "<select name=$name value='$params->{$name}'>\n<option value='ALL'>ALL</option>\n"; - - while ( my $row = $sth->fetchrow_hashref ) { - if ( $row->{'number'} eq $params->{$name} ) { - $body .= -"<option value='$row->{'number'}' selected>$row->{'number'}</option>\n"; - } - else { - $body .= - "<option value='$row->{'number'}'>$row->{'number'}</option>\n"; - } - } - - $sth->finish; - - $body .= "</select> <strong>AND</strong> "; - - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $sth = $astpp_db->prepare( - "SELECT DISTINCT notes FROM cdrs WHERE notes LIKE " - . $astpp_db->quote( $params->{username} . "|%" ) ); - } - else { - $sth = $astpp_db->prepare("SELECT DISTINCT notes FROM cdrs"); - } - - $sth->execute() - || return gettext("Something is wrong with astpp database") . "\n"; - - my ( $dest, $ptrn ); - my ( @dst, @ptn, $i ); - $dest = -"Destination: </td><td align=left><select name=destination value='Destination'>\n" - . "<option value='ALL'>ALL</option>\n"; - $ptrn = - " <strong>OR</strong> " - . "IDD Code: <select name=pattern value='IDD Code'>\n" - . "<option value='ALL'>ALL</option>\n"; - - while ( my $notes = $sth->fetchrow_hashref ) { - my @note = split( m/(\^|DID:)/, $notes->{'notes'}, 2 ); - $ptn[$i] = $note[1] . $note[2]; - @note = split( /\|/, $note[0] ); - $dst[$i] = ( @note == 1 ) ? $note[0] : $note[1] if $note[0] ne ""; - $i++; - } - $sth->finish; - - $dest .= build_list_box( \@dst, $destination ); - $dest .= "</select>\n"; - - $ptrn .= build_list_box( \@ptn, $pattern ); - $ptrn .= "</select>\n"; - - $body .= $dest . $ptrn . "</td></tr>"; - - my $filter = build_filter( $body, undef ); - my $sd = $filter->{'start_date'}; - my $ed = $filter->{'end_date'}; - $body = $filter->{'form_body'}; - - my $where = - "callstart BETWEEN " - . $astpp_db->quote($sd) . " AND " - . $astpp_db->quote($ed) . " "; - - if ( $params->{$name} eq 'ALL' ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $where .= - "AND cardnum IN (SELECT `number` FROM accounts WHERE reseller = " - . $astpp_db->quote( $params->{username} ) - . " AND type IN ($type)) "; - } - else { - if ( index( $type, "1" ) != -1 ) { - $where .= -"AND cardnum IN (SELECT `number` FROM accounts WHERE type IN ($type)) "; - } - elsif ( index( $type, "3" ) != -1 ) { - $where .= - "AND provider = " . $astpp_db->quote( $params->{$name} ); - } - } - } - else { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $where .= - "AND cardnum = " . $astpp_db->quote( $params->{$name} ) . " "; - } - else { - if ( index( $type, "1" ) != -1 ) { - $where .= -"AND cardnum IN (SELECT `number` FROM accounts WHERE `number` = " - . $astpp_db->quote( $params->{$name} ) - . " AND type IN ($type)) "; - } - elsif ( index( $type, "3" ) != -1 ) { - $where .= - "AND provider = " . $astpp_db->quote( $params->{$name} ); - } - } - } - - if ( $destination eq 'ALL' ) { - if ( $pattern eq 'ALL' ) { - $where .= ""; - } - else { - $where .= - "AND notes LIKE " . $astpp_db->quote( "%|" . $pattern ) . " "; - } - } - else { - if ( $pattern eq 'ALL' ) { - $where .= "AND notes LIKE " - . $astpp_db->quote( "%|" . $destination . "|%" ) . " "; - } - else { - $where .= "AND (notes LIKE " - . $astpp_db->quote( "%|" . $destination . "|%" ) . " "; - $where .= - "OR notes LIKE " . $astpp_db->quote( "%|" . $pattern ) . ") "; - } - } - - $where = 0 if $param->{$name} eq "" && $destination eq "" && $pattern eq ""; - - $body .= - start_form() - . "<table class=\"default\" width=100%><tr><td colspan=12 align=center><b>$sd - $ed</b></td></tr>" - . "<tr class=\"header\"><td>" - . gettext("$name") - . "</td><td>" - . gettext("Destination") - . "</td><td>" - . gettext("IDD Code") - . "</td><td>" - . gettext("Attempted Calls") - . "</td><td>" - . gettext("Completed Calls") - . "</td><td>" - . "<acronym title=\"" - . gettext("Answer Seizure Rate") . "\">" - . gettext("ASR") - . "</acronym>" - . "</td><td>" - . "<acronym title=\"" - . gettext("Average Call Duration") . "\">" - . gettext("ACD") - . "</acronym>" - . "</td><td>" - . "<acronym title=\"" - . gettext("Maximum Call Duration") . "\">" - . gettext("MCD") - . "</acronym>" - . "</td><td>" - . gettext("Actual") - . "</td><td>" - . gettext("Billable") - . "</td><td>" - . gettext("Price") - . "</td><td>" - . gettext("Cost") - . "</td></tr>\n"; - - my $table = "tmp_" . time(); - my ( - $bth, $dst, $idd, $atmpt, $cmplt, $asr, - $acd, $mcd, $act, $bill, $price, $cost - ); - my $query = -"CREATE TEMPORARY TABLE $table SELECT * FROM cdrs WHERE uniqueid != '' AND $where"; - $sth = $astpp_db->do($query) - || return gettext("Something is wrong with astpp database") . "\n"; - $ASTPP->debug( user => $param->{username}, debug => " SQL: $query " ); - - my $sql = - $astpp_db->prepare("SELECT DISTINCT cardnum AS $name FROM $table"); - $sql->execute() - || return gettext("Something is wrong with astpp database") . "\n"; - - while ( my $row = $sql->fetchrow_hashref ) { - $bth = $row->{$name}; - my $sql1 = $astpp_db->prepare( - "SELECT notes, COUNT(*) AS attempts, AVG(billseconds) AS acd, - MAX(billseconds) AS mcd, SUM(billseconds) AS billable, - SUM(debit) AS cost, SUM(cost) AS price FROM $table - WHERE (notes IS NOT NULL AND notes != '') AND cardnum = " - . $astpp_db->quote($bth) . " GROUP BY notes" - ); - $sql1->execute() - || return gettext("Something is wrong with astpp database") . "\n"; - - while ( my $row1 = $sql1->fetchrow_hashref() ) { - my @note1 = split( m/(\^|DID:)/, $row1->{notes}, 2 ); - $idd = $note1[1] . $note1[2]; - @note1 = split( /\|/, $note1[0] ); - $dst = ( @note1 == 1 ) ? $note1[0] : $note1[1]; - $dst = 'N/A' if $dst eq ""; - - $atmpt = $row1->{'attempts'}; - $acd = $row1->{'acd'}; - $mcd = $row1->{'mcd'}; - $bill = $row1->{'billable'}; - $price = $row1->{'price'}; - $cost = $row1->{'cost'}; - - $notes = "notes = " . $astpp_db->quote( $row1->{notes} ); - - my $sql2 = $astpp_db->prepare( - "SELECT COUNT(*) AS completed FROM $table - WHERE $notes AND disposition = 'ANSWERED'" - ); - $sql2->execute() - || return gettext("Something is wrong with astpp database") - . "\n"; - my $row2 = $sql2->fetchrow_hashref(); - $cmplt = $row2->{'completed'} || 0; - $sql2->finish; - - $asr = ( ( $atmpt - $cmplt ) / $atmpt ) * 100; - - my $in = ""; - my $sql3 = - $astpp_db->prepare("SELECT uniqueid FROM $table WHERE $notes "); - $sql3->execute() - || return gettext("Something is wrong with astpp database") - . "\n"; - - while ( my $row3 = $sql3->fetchrow_hashref ) { - $in .= "'" . $row3->{'uniqueid'} . "'," if $row3->{'uniqueid'}; - } - - $in = substr( $in, 0, -1 ) if length($in) > 0; - $sql3->finish; - - my $sql4 = $cdr_db->prepare( -"SELECT SUM(duration) AS actual FROM cdr WHERE uniqueid IN ($in)" - ); - $sql4->execute() - || return gettext("Something is wrong with cdr database") . "\n"; - my $row4 = $sql4->fetchrow_hashref(); - $act = $row4->{'actual'}; - $sql4->finish; - - $act = int( $act / 60 ) . ":" . ( $act % 60 ); - $acd = int( $acd / 60 ) . ":" . ( $acd % 60 ); - $mcd = int( $mcd / 60 ) . ":" . ( $mcd % 60 ); - $bill = int( $bill / 60 ) . ":" . ( $bill % 60 ); - $price = $price / 10000.0; - $cost = $cost / 10000.0; - - $body .= "<tr>" - . "<td>$bth</td><td>$dst</td><td>$idd</td><td>$atmpt</td><td>$cmplt</td><td>$asr</td>" - . "<td align=right>$acd</td><td align=right>$mcd</td><td align=right>$act</td>" - . "<td align=right>$bill</td><td>$price</td><td>$cost</td>" - . "</tr>"; - } - $sql1->finish; - } - $sql->finish; - - $sth = $astpp_db->do("DROP TEMPORARY TABLE $table") - || return gettext("Something is wrong with astpp database") . "\n"; - - $body .= "</table>"; - return $body; -} - -sub build_admin_report() { - my ($body); - return gettext("Cannot display reports until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - return gettext("Cannot display reports until database is configured") - unless $cdr_db; - - return gettext("Comming Soon!"); -} - -sub build_reseller_report() { - my ($body); - return gettext("Cannot display reports until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - return gettext("Cannot display reports until database is configured") - unless $cdr_db; - - return gettext("Coming Soon!"); -} - -# End of code changes by Sonia Ali Khan. - -#################### Stats stuff ########################### -sub build_stats_acd() { - my ( $body, $id ); - return gettext("Cannot display stats until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - return gettext("Cannot display stats until database is configured") - unless $cdr_db; - - my $filter = build_filter( undef, undef ); - my $sd = $filter->{'start_date'}; - my $ed = $filter->{'end_date'}; - $body = $filter->{'form_body'}; - - my $sth; - - if ( $params->{logintype} == 3 ) { - $sth = - $astpp_db->prepare( "SELECT * FROM trunks WHERE provider = " - . $astpp_db->quote( $params->{username} ) ); - } - else { - $sth = $astpp_db->prepare("SELECT * FROM trunks"); - } - $sth->execute - || return gettext("Something is wrong with the trunks database") . "\n"; - $body .= - start_form() - . "<table class=\"default\" width=100%><tr><td colspan=5 align=center><b>$sd - $ed</b></td></tr>" - . "<tr class=\"header\"><td>" - . gettext("Trunk Name") - . "</td><td>" - . gettext("Calls") - . "</td><td>" - . "<acronym title=\"" - . gettext("Average Call Duration") . "\">" - . gettext("ACD") - . "</acronym>" - . "</td><td>" - . "<acronym title=\"" - . gettext("Average Call Wait Time") . "\">" - . gettext("ACWT") - . "</acronym>" - . "</td><td>" - . gettext("Success") - . "</td><td>" - . gettext("Congestion") - . "</td></tr>\n"; - - while ( my $row = $sth->fetchrow_hashref ) { - $count++; - my $sql1 = " SELECT COUNT( - *) as calls, - AVG(billsec) as bs, - AVG( duration-billsec ) as acwt from cdr where lastapp = 'Dial' - and disposition REGEXP '^ANSWERED$' - and calldate >= " . $cdr_db->quote($sd) . " - and calldate <= " . $cdr_db->quote($ed) . " - and (dstchannel like '$row->{tech}/$row->{path}%' - or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; - $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql1 \n " ); - my $sth1 = $cdr_db->prepare($sql1); - $sth1->execute(); - my $ref1 = $sth1->fetchrow_hashref(); - $sth1->finish; - my $sql2 = " select count( - *) as ct from cdr where calldate >= - " . $cdr_db->quote($sd) . " - and calldate <= " . $cdr_db->quote($ed) . " - and disposition not in( - 'ANSWERED','16' - ) - and (dstchannel like '$row->{tech}/$row->{path}%' - or dstchannel like '$row->{tech}\[$row->{path}\]%' ) - "; - my $sth2 = $cdr_db->prepare($sql2); - $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql2" ); - $sth2->execute(); - my $ref2 = $sth2->fetchrow_hashref(); - $sth2->finish; - my $sql3 = " select count( - *) as ct from cdr where calldate >= - " . $cdr_db->quote($sd) . " - and calldate <= " . $cdr_db->quote($ed) . " - and disposition REGEXP '^CONGESTION$' - and (dstchannel like '$row->{tech}/$row->{path}%' - or dstchannel like '$row->{tech}\[$row->{path}\]%' ) - "; - my $sth3 = $cdr_db->prepare($sql3); - $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql3" ); - $sth3->execute(); - my $ref3 = $sth3->fetchrow_hashref(); - $sth3->finish; - my $sql4 = " select count( - *) as ct from cdr where calldate >= - " . $cdr_db->quote($sd) . " - and calldate <= " . $cdr_db->quote($ed) . " - and (dstchannel like '$row->{tech}/$row->{path}%' - or dstchannel like '$row->{tech}\[$row->{path}\]%' ) - "; - my $sth4 = $cdr_db->prepare($sql4); - $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql4" ); - $sth4->execute(); - my $ref4 = $sth4->fetchrow_hashref(); - $sth4->finish; - my $success_rate = 0; - my $congestion_rate = 0; - - if ( $ref4->{ct} > 0 && $ref1->{calls} > 0 ) { - $success_rate = ( $ref1->{calls} / $ref4->{ct} ) * 100; - } - if ( $ref4->{ct} > 0 && $ref3->{ct} > 0 ) { - $congestion_rate = ( $ref3->{ct} / $ref4->{ct} ) * 100; - } - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= -"<td>$row->{tech}/$row->{path}</td><td align=right>$ref4->{ct}</td><td align=right>" - . "$ref1->{bs}</td><td align=right>$ref1->{acwt}</td><td align=right>" - . "$ref1->{calls} " - . sprintf( "%.04f", $success_rate ) - . " %</td><td>" - . "$ref3->{ct} " - . sprintf( "%.04f", $congestion_rate ) - . "%</td></tr>\n"; - } - $sth->finish; - $body .= "</table>"; - return $body; -} - -#################### Stats stuff ########################### -sub build_view_cdrs() { - my ( - @trunklist, $body, $id, $tmp, - $row, $sql, $results, $pagesrequired, - $pageno, $string, $sd_month - ); - return gettext("Cannot display stats until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, @output ); - return gettext("Cannot display stats until database is configured") - unless $cdr_db; - if ( $params->{limit} < 1 || !$params->{limit} ) { $params->{limit} = 0 } - my $results_per_page = $config->{results_per_page}; - if ( $results_per_page eq "" ) { $results_per_page = 25; } - my ( undef, undef, undef, $day, $mnth, $yr ) = localtime(); - - if ( $params->{logintype} == 3 ) { - my $sql = - $astpp_db->prepare( "SELECT * FROM trunks WHERE provider = " - . $astpp_db->quote( $params->{username} ) ); - $sql->execute; - while ( my $record = $sql->fetchrow_hashref ) { - push @trunklist, $record->{name}; - } - $sql->finish; - } - else { - @trunklist = &list_trunks($astpp_db); - push( @trunklist, "" ); - } - @trunklist = sort @trunklist; - - $body = - "<tr><td>" - . gettext("Answered Calls Only?") - . popup_menu( - -name => "answered", - -values => \%yesno - ) . "</td><td>"; - if ( $params->{logintype} == 2 ) { - $body .= gettext("AccountCode:") - . textfield( - -name => "accountcode", - -width => 8 - ); - } - $body .= - "</td></tr>" - . "<tr><td>" - . gettext("Select Outbound Trunk?") - . popup_menu( - -name => "trunk", - -values => \@trunklist - ) . "</td></tr>"; - - my $filter = build_filter( $body, undef ); - my $sd = $filter->{'start_date'}; - my $ed = $filter->{'end_date'}; - $body = $filter->{'form_body'}; - - $body .= start_form() - . "<table class=\"viewcdrs\" width=100%><tr><td colspan=5 align=center><b>$sd - $ed</b></td></tr> -" - . "<tr class=\"header\"><td>" - . gettext("Date") - . "</td><td>" - . gettext("CallerID") . "</td>" . "<td>" - . gettext("Source") - . "</td><td>" - . gettext("Dest") . "</td>" . "<td>" - . gettext("D.Context") - . "</td><td>" - . gettext("Chan") . "</td>" . "<td>" - . gettext("D.Chan") - . "</td><td>" - . gettext("Last App") - . " </td>" . "<td>" - . gettext("Last Data") - . "</td><td>" - . gettext("Duration") . "</td>" . "<td>" - . gettext("BillSec") - . "</td><td>" - . gettext("Disposition") . "</td>" . "<td>" - . gettext("AMAFlags") - . "</td><td>"; - - if ( $params->{logintype} == 2 ) { - $body .= gettext("AccountCode"); - } - $body .= - "</td>" . "<td>" - . gettext("U-ID") - . "</td><td>" - . gettext("UserField") . "</td>" . "<td>" - . gettext("Cost") - . "</td></tr> -\n"; - if ( $params->{answered} == 1 ) { - $tmp = - " SELECT * from cdr where disposition = 'ANSWERED'" - . " and calldate >= " - . $cdr_db->quote($sd) - . " and calldate <= " - . $cdr_db->quote($ed); - $ASTPP->debug( user => $param->{username}, debug => " SQL: $tmp" ); - } - else { - $tmp = - " SELECT * from cdr where calldate >= " - . $cdr_db->quote($sd) - . " and calldate <= " - . $cdr_db->quote($ed); - $ASTPP->debug( user => $param->{username}, debug => " SQL: $tmp" ); - } - if ( $params->{accountcode} && $params->{logintype} == 2 ) { - $tmp .= - " and accountcode = " . $cdr_db->quote( $params->{accountcode} ); - } - if ( $params->{trunk} ) { - my $tmpsql = - "SELECT * FROM trunks WHERE name = " - . $astpp_db->quote( $params->{trunk} ) - . " LIMIT 1"; - $ASTPP->debug( user => $param->{username}, debug => $tmpsql ); - $sql = $astpp_db->prepare($tmpsql); - $sql->execute - || return gettext("Something is wrong with the trunks database") - . "\n"; - $row = $sql->fetchrow_hashref; - $sql->finish; - $tmp .= " and (dstchannel like '$row->{tech}/$row->{path}\%'" - . " or dstchannel like '$row->{tech}\[$row->{path}\]\%')"; - } - $ASTPP->debug( user => $param->{username}, debug => $tmp ); - $sql = $cdr_db->prepare($tmp); - $sql->execute; - $results = $sql->rows; - $pagesrequired = ceil( $results / $results_per_page ); - $sql->finish; - $tmp .= " limit $params->{limit} , $results_per_page"; - $sql = $cdr_db->prepare($tmp); - $sql->execute; - - while ( my $record = $sql->fetchrow_hashref ) { - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - my $dcontext = substr( $record->{dcontext}, 0, 4 ) . ".."; - my $channel = substr( $record->{channel}, 0, 9 ) . ".."; - my $dstchannel = substr( $record->{channel}, 0, 9 ) . ".."; - my $lastdata = substr( $record->{lastdata}, 0, 4 ) . ".."; - if ( $params->{logintype} != 2 ) { - ... [truncated message content] |
From: <dar...@us...> - 2009-01-17 17:13:27
|
Revision: 2220 http://astpp.svn.sourceforge.net/astpp/?rev=2220&view=rev Author: darrenkw Date: 2009-01-17 17:13:20 +0000 (Sat, 17 Jan 2009) Log Message: ----------- Moved the agi files into the asterisk_apps directory. Modified Paths: -------------- trunk/Makefile Added Paths: ----------- trunk/asterisk_apps/astpp-ani-map.agi trunk/asterisk_apps/astpp-authorize.agi trunk/asterisk_apps/astpp-callback-register.agi trunk/asterisk_apps/astpp-callback.agi trunk/asterisk_apps/astpp-callingcards.agi trunk/asterisk_apps/astpp-did-map.agi trunk/asterisk_apps/astpp-ip-map.agi trunk/asterisk_apps/astpp-lcr.agi trunk/asterisk_apps/astpp-manager-variables.agi trunk/asterisk_apps/astpp-refill.agi Removed Paths: ------------- trunk/astpp-ani-map.agi trunk/astpp-authorize.agi trunk/astpp-callback-register.agi trunk/astpp-callback.agi trunk/astpp-callingcards.agi trunk/astpp-did-map.agi trunk/astpp-ip-map.agi trunk/astpp-lcr.agi trunk/astpp-manager-variables.agi trunk/astpp-refill.agi Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-01-17 02:19:55 UTC (rev 2219) +++ trunk/Makefile 2009-01-17 17:13:20 UTC (rev 2220) @@ -63,7 +63,7 @@ install_agi: - for x in *.agi; do \ + for x in asterisk_apps/*.agi; do \ echo $$x; \ install -m 755 -o $(OWNER) -g $(GROUP) $$x $(PREFIX)$(AGIDIR); \ done Copied: trunk/asterisk_apps/astpp-ani-map.agi (from rev 2218, trunk/astpp-ani-map.agi) =================================================================== --- trunk/asterisk_apps/astpp-ani-map.agi (rev 0) +++ trunk/asterisk_apps/astpp-ani-map.agi 2009-01-17 17:13:20 UTC (rev 2220) @@ -0,0 +1,90 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2004, Aleph Communications +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +# +# This script is used to authenticate calls to ASTPP accounts based on pin codes in the Dialplan. +# It can be used to do wholesale SIP termination which is authenticated by a pin code that is dialed +# in front of the number to be called. +# + +use DBI; +use Asterisk::AGI; +use POSIX qw(ceil floor); +use POSIX qw(strftime); +use strict; +use vars qw(@output $verbose $SIG $astpp_db $config $AGI); +@output = ( "STDERR", "LOGFILE" ); +$verbose = 2; +require "/usr/local/astpp/astpp-common.pl"; +$AGI = new Asterisk::AGI; + +sub initialize() { + $SIG{HUP} = 'ignore_hup'; + $config = &load_config(); + $astpp_db = &connect_db( $config, @output ); + $config = &load_config_db($astpp_db,$config); +} + +sub ignore_hup { + foreach my $handle (@output) { + print $handle "HUP received\n"; + $AGI->verbose( "HUP received!\n", $verbose ); + } +} + +sub get_ani() { + my ($number) = @_; + my ($sql); + $sql = + $astpp_db->prepare( + "SELECT * FROM ani_map WHERE number = " . $astpp_db->quote($number) . " AND status IN (0,1)" ); + $sql->execute; + $AGI->verbose( "$sql\n", $verbose ); + my $anidata = $sql->fetchrow_hashref; + $sql->finish; + return $anidata; +} + +sub get_cc() { + my ($number) = @_; + my ($sql); + $sql = + $astpp_db->prepare( + "SELECT * FROM accounts WHERE cc = " . $astpp_db->quote($number) ); + $sql->execute; + $AGI->verbose( "$sql\n", $verbose ); + my $anidata = $sql->fetchrow_hashref; + $sql->finish; + return $anidata; +} +################# Program Starts Here ################################# +my ( $number, $type,$variablename ) = @ARGV; +my ( $sql, $anidata ); +&initialize; +if ( $type eq "ANI" || $type eq "PREFIX" ) { + $anidata = &get_ani($number); + $AGI->set_variable( "$variablename", "\"$anidata->{account}\"" ); + $AGI->exec( 'Set', "$variablename=$anidata->{account}" ); + if ($anidata->{context} ne "" ) { + $AGI->set_variable( 'DEST_CONTEXT', "\"$anidata->{context}\"" ); + $AGI->exec( 'Set', "DEST_CONTEXT=$anidata->{context}" ); + } else { + $AGI->set_variable( 'DEST_CONTEXT', "\"$config->{lcrcontext}\"" ); + $AGI->exec( 'Set', "DEST_CONTEXT=$config->{lcrcontext}" ); + } +} +elsif ($type eq "CC") { + $anidata = &get_cc($number); + $AGI->set_variable( "$variablename", "\"$anidata->{cc}\"" ); + $AGI->exec( 'Set', "$variablename=$anidata->{cc}" ); + $AGI->set_variable( 'DEST_CONTEXT', "\"$config->{lcrcontext}\"" ); + $AGI->exec( 'Set', "DEST_CONTEXT=$config->{lcrcontext}" ); + +} Property changes on: trunk/asterisk_apps/astpp-ani-map.agi ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/asterisk_apps/astpp-authorize.agi (from rev 2218, trunk/astpp-authorize.agi) =================================================================== --- trunk/asterisk_apps/astpp-authorize.agi (rev 0) +++ trunk/asterisk_apps/astpp-authorize.agi 2009-01-17 17:13:20 UTC (rev 2220) @@ -0,0 +1,197 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2004, DNW Consulting +# +# Darren Wiebe (da...@dn...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +############################################################ +# +# Usage-example: +# +# ; +# ; Card-number and number to dial derived from command-line. +# ; Call script with the card-number as first arg and the number +# ; to dial as the second arg. astpp-authorize will return a line containing info +# ; that will cut the call off before it goes over the users credit limit. The +# ; user can get over credit limit if they have multiple calls going at once. +# ; Presently the only way to stop that is to limit them to one call which is not +# ; a nice solution. +# ; +# ; The following variables must be set: +# ; USER1 = Username at IAX2 Provider #1 +# ; PASS1 = Password for User1 +# ; PROVIDER1 = IP address of IAX2 Provider #1 or else associate name from +# ; iax.conf +# ; +# With LCR +# [astpp] +# +# exten => _1XXXXXXXXXX,1,Set(GROUP()=${ACCOUNTCODE}) +# exten => _1XXXXXXXXXX,2,AGI(astpp-authorize.agi,${ACCOUNTCODE},${EXTEN}) +# exten => _1XXXXXXXXXX,3,GotoIf($["${CALLSTATUS}" = "0"]?60) ; Checks if account has sufficient funds +# exten => _1XXXXXXXXXX,4,GotoIf($["${CALLSTATUS}" = "1"]?70) ; Checks if the phone number exists +# exten => _1XXXXXXXXXX,5,GotoIf($["${CALLSTATUS}" = "2"]?80) ; Check if account exists +# exten => _1XXXXXXXXXX,6,GotoIf($["${GROUP_COUNT()}" > "${MAXCHANNELS}"]?90) ; Verify number of outgoing channels +# ; assigned to account. +# exten => _1XXXXXXXXXX,7,Set(GROUP(${TRUNK1}-OUTBOUND)=OUTBOUND) +# exten => _1XXXXXXXXXX,8,GotoIf($["${GROUP_COUNT(OUTBOUND@${TRUNK1}-OUTBOUND)}" > "${TRUNK1_MAXCHANNELS}"]?10) +# exten => _1XXXXXXXXXX,9,Dial(${LCRSTRING1}||${TIMELIMIT}|${OPTIONS}) +# exten => _1XXXXXXXXXX,110,Busy +# exten => _1XXXXXXXXXX,10,Set(GROUP(${TRUNK2}-OUTBOUND)=OUTBOUND) +# exten => _1XXXXXXXXXX,11,GotoIf($["${GROUP_COUNT(OUTBOUND@${TRUNK2}-OUTBOUND)}" > "${TRUNK2_MAXCHANNELS}"]?13) +# exten => _1XXXXXXXXXX,12,Dial(${LCRSTRING2}||${TIMELIMIT}|${OPTIONS}) +# exten => _1XXXXXXXXXX,113,Busy +# exten => _1XXXXXXXXXX,13,Set(GROUP(${TRUNK2}-OUTBOUND)=OUTBOUND) +# exten => _1XXXXXXXXXX,14,GotoIf($["${GROUP_COUNT(OUTBOUND@${TRUNK3}-OUTBOUND)}" > "${TRUNK3_MAXCHANNELS}"]?16) +# exten => _1XXXXXXXXXX,15,Dial(${LCRSTRING3}||${TIMELIMIT}|${OPTIONS}) +# exten => _1XXXXXXXXXX,116,Busy +# exten => _1XXXXXXXXXX,16,Set(GROUP(${TRUNK4}-OUTBOUND)=OUTBOUND) +# exten => _1XXXXXXXXXX,17,GotoIf($["${GROUP_COUNT(OUTBOUND@${TRUNK4}-OUTBOUND)}" > "${TRUNK4_MAXCHANNELS}"]?19) +# exten => _1XXXXXXXXXX,18,Dial(${LCRSTRING4}||${TIMELIMIT}|${OPTIONS}) +# exten => _1XXXXXXXXXX,119,Busy +# exten => _1XXXXXXXXXX,19,Set(GROUP(${TRUNK5}-OUTBOUND)=OUTBOUND) +# exten => _1XXXXXXXXXX,20,GotoIf($["${GROUP_COUNT(OUTBOUND@${TRUNK5})-OUTBOUND}" > "${TRUNK5_MAXCHANNELS}"]?22) +# exten => _1XXXXXXXXXX,21,Dial(${LCRSTRING5}||${TIMELIMIT}|${OPTIONS}) +# exten => _1XXXXXXXXXX,122,Busy +# exten => _1XXXXXXXXXX,22,Goto(100) +# exten => _1XXXXXXXXXX,60,Congestion ; '0' Tells them they do not have enough money +# exten => _1XXXXXXXXXX,61,Hangup +# exten => _1XXXXXXXXXX,70,Congestion '1' Bad Phone Number +# exten => _1XXXXXXXXXX,71,Hangup +# exten => _1XXXXXXXXXX,80,Congestion +# exten => _1XXXXXXXXXX,81,Hangup +# exten => _1XXXXXXXXXX,90,Congestion ; Their outgoing channel limit is full already +# exten => _1XXXXXXXXXX,91,Hangup +# exten => _1XXXXXXXXXX,100,Congestion ; No Route Available +# exten => _1XXXXXXXXXX,101,Hangup +# ; This lines are optional and would forward users to a help desk if the call did not go through. +# exten => _1XXXXXXXXXX,60,Dial(SIP/HELPDESK) ; '0' Tells them they do not have enough money +# exten => _1XXXXXXXXXX,61,Hangup +# exten => _1XXXXXXXXXX,70,Dial(SIP/HELPDESK) ; '1' Bad Phone Number +# exten => _1XXXXXXXXXX,71,Hangup +# exten => _1XXXXXXXXXX,80,Dial(SIP/HELPDESK) +# exten => _1XXXXXXXXXX,81,Hangup + +use DBI; +use Asterisk::AGI; +use strict; +use vars qw(@output $config $astpp_db $verbosity $AGI); +use Locale::gettext_pp qw(:locale_h); +require "/usr/local/astpp/astpp-common.pl"; +$ENV{LANGUAGE} = "en"; # de, es, br - whatever +print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; +bindtextdomain( "astpp", "/usr/local/share/locale" ); +textdomain("astpp"); +$verbosity = 2; +@output = ("STDERR"); +$AGI = new Asterisk::AGI; + +################# Programs start here ####################################### +my ( $accountcode, $phoneno ) = @ARGV; +my ( $maxlength, $maxmins,$callstatus ); +$AGI->set_variable( 'ASTPP', '1' ); +$AGI->verbose( "$accountcode, $phoneno", $verbosity ); +$config = &load_config(); +$astpp_db = &connect_db( $config, @output ); +$config = &load_config_db($astpp_db,$config); +my $carddata = &get_account( $astpp_db, $accountcode ); # Fetch all the account info from the db. + +if ( !$carddata->{number} ) { # Check to see if the account exists. If not then exit. + $AGI->verbose( "CALLSTATUS 2\n", $verbosity ); + $AGI->verbose( "CANNOT RETRIEVE CARD\n", $verbosity ); + $AGI->set_variable( 'CALLSTATUS', "\"2\"" ); + $AGI->exec( 'Set', "CALLSTATUS=2" ); + exit(0); +} + +if ($carddata->{dialed_modify}) { + my @regexs = split(m/,/m, $carddata->{dialed_modify}); + foreach my $regex (@regexs) { + $regex =~ s/"//g; #Strip off quotation marks + my ($grab,$replace) = split(m!/!i, $regex); # This will split the variable into a "grab" and "replace" as needed + $AGI->verbose( "Grab: $grab\n", $verbosity ) if $config->{debug} == 1; + $AGI->verbose( "Replacement: $replace\n", $verbosity ) if $config->{debug} == 1; + $AGI->verbose( "Phone Before: $phoneno\n", $verbosity ) if $config->{debug} == 1; + $phoneno =~ s/$grab/$replace/is; + $AGI->verbose( "Phone After: $phoneno\n", $verbosity ) if $config->{debug} == 1 + } + } + +print STDERR "\nFINDING LIMIT FOR: $carddata->{number}\n" if $config->{debug} == 1; +($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); +my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); +print STDERR "Minimum Charge on call = $routeinfo->{cost}" if $config->{debug} == 1; +my $minimumcharge = $routeinfo->{cost}; +my @reseller_list; +print STDERR "\nCALLSTATUS: $callstatus MAX_LENGTH: $maxlength\n" if $config->{debug} == 1; +while ( $carddata->{reseller} && $maxlength > 1 && $callstatus == 1) { + print STDERR "\nFINDING LIMIT FOR: $carddata->{reseller}\n" if $config->{debug} == 1; + $carddata = &get_account( $astpp_db, $carddata->{reseller} ); + push @reseller_list, $carddata->{number}; + print STDERR "ADDING $carddata->{number} to the list of resellers for this account\n" if $config->{debug} == 1; + my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); + my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); + if ($resellercallstatus != 1) { + $carddata->{reseller} = ""; + $callstatus = $resellercallstatus; + } elsif ($resellermaxlength < $maxlength) { + $maxlength = $resellermaxlength; + } + print STDERR "Reseller cost = $routeinfo->{cost} and minimum charge is $minimumcharge\n" if $config->{debug} == 1; + if ($resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) { + $AGI->verbose("Reseller call is priced too cheap! Call being barred!", $verbosity ) if $config->{debug} == 1; + $callstatus = 0; + $maxlength = 0; + } + print STDERR "\nRESELLER Max Length: $resellermaxlength\n" if $config->{debug} == 1; + print STDERR "RESELLER Call Status: $resellercallstatus\n" if $config->{debug} == 1; +} + +if ($config->{debug} == 1) { + $AGI->verbose( "PRINTING LIST OF RESELLERS FOR THIS ACCOUNT\n", $verbosity ); + foreach my $reseller (@reseller_list) { + $AGI->verbose( "RESELLER: $reseller", $verbosity ); + } +} + +$AGI->verbose( "Max Call Length: $maxlength minutes\n", $verbosity ); +$AGI->verbose( "Call Status: $callstatus\n", $verbosity ); + +if ( $maxlength <= 1 ) { + $AGI->verbose( "NOT ENOUGH CREDIT\n", $verbosity ); + $AGI->set_variable( 'CALLSTATUS', "\"0\"" ); + exit(0); +} + +# Set the timelimit as well as other variables which are needed in the dialplan. +my $timelimit = "L(" . sprintf( "%.0f", $maxlength * 60 * 1000 ) . ":60000:30000)"; +$AGI->set_variable( "\"TIMELIMIT\"", "\"$timelimit\"" ); +$AGI->set_variable( "\"OPTIONS\"", "\"Hj\"" ); +$AGI->set_variable( 'CALLSTATUS', "\"3\"" ); +$AGI->set_variable( 'MAXCHANNELS', "\"$carddata->{maxchannels}\"" ); +if ( $config->{enablelcr} == 1 ) { # Do we do LCR on our outgoing calls? If so then carry on. + $AGI->verbose( "Looking for outbound Route\n", $verbosity ); + my $routeinfo = &get_route($astpp_db,$config,$phoneno,$carddata->{pricelist},$carddata); + # Get the list of routes for the phone number. + my @outboundroutes = &get_outbound_routes( $astpp_db, $phoneno,$carddata,$routeinfo, @reseller_list ); + my $count = 1; + foreach my $route (@outboundroutes) { + $AGI->verbose( "$route->{trunk}: cost $route->{cost}\t $route->{pattern}", $verbosity ); + if ($route->{cost} > $routeinfo->{cost}) { + $AGI->verbose( "$route->{trunk}: $route->{cost} > $routeinfo->{cost}, skipping\n", $verbosity ); + } else { + my $trunkdata = &get_trunk($astpp_db, $route->{trunk}); + my $dialstring = &get_dial_string( $astpp_db, $route, $phoneno ); + $AGI->set_variable( "\"LCRTRUNKS\"", "\"$count\"" ); + $AGI->set_variable( "\"LCRSTRING$count\"", "\"$dialstring\"" ); + $AGI->set_variable( "\"TRUNK$count\"", "\"$route->{trunk}\"" ); + $AGI->set_variable( "\"TRUNK" . $count . "_MAXCHANNELS\"", "\"$trunkdata->{maxchannels}\"" ); + $count++; + } + } +} +exit(0); Property changes on: trunk/asterisk_apps/astpp-authorize.agi ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/asterisk_apps/astpp-callback-register.agi (from rev 2218, trunk/astpp-callback-register.agi) =================================================================== --- trunk/asterisk_apps/astpp-callback-register.agi (rev 0) +++ trunk/asterisk_apps/astpp-callback-register.agi 2009-01-17 17:13:20 UTC (rev 2220) @@ -0,0 +1,272 @@ +#!/usr/bin/perl +# +# ASTPP callfile creation +# +# Copyright (C) 2006, DNW Consulting +# +# Darren Wiebe <da...@dn...> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Contact information can be found @ www.dnwconsulting.net +# +# ANI Map Info +# Status 0 is for regular ASTPP accounts and status 1 is for calling cards +# that are ok. Status 2 is a blocked number. +# This program is used to request callbacks from ASTPP for calling cards. It's +# also used to register telephone numbers in the "ani_map" table. You can set it +# to register only by passing along "REGISTER" in the ${DESTINATION} field. Here's an +# example on how to call it. +# +# ${CARDNUMBER} = The calling card number we wish to register to. +# ${PIN} = The pin for ${CARDNUMBER} if appropriate. +# ${CALLERIDNUM} = Is the number we are calling from and will use for ANI authentication. +# This is also the number we will be called back at. +# ${DESTINATION} = The number we wish the system to call once we are authenticated. +# +# +# exten => 2,2,DeadAGI(astpp-register-card.agi,${CALLERIDNUM},${DESTINATION},${CARDNUMBER},${PIN}) +# +# +###########################################################################` + +use POSIX qw(ceil floor); +use POSIX qw(strftime); +use DBI; +use Asterisk::AGI; +use strict; +require "/usr/local/astpp/astpp-common.pl"; +use vars qw($vars $verbose $astpp_db $AGI $config @output $sound); +$verbose = 2; +@output = ("STDERR"); +$AGI = new Asterisk::AGI; +$config = &load_config(); +$astpp_db = &connect_db( $config, @output ); +$config = &load_config_db( $astpp_db, $config ); +my $brand = $AGI->get_variable("BRAND"); +if ($brand) { + my $brandinfo = &get_cc_brand($astpp_db, $brand); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$brand); +} +$sound = &define_sounds($astpp_db); +$SIG{HUP} = 'ignore_hup'; +my $verbosity = 2; +my $input_timeout = 15000; #How long do we wait for input? Specified in MS + +sub ignore_hup { + foreach my $handle (@output) { + print $handle "HUP received\n"; + } +} + +sub get_ani() { + my ($number) = @_; + my ($sql); + $sql = + $astpp_db->prepare( + "SELECT * FROM ani_map WHERE number = " . $astpp_db->quote($number) ); + $sql->execute; + $AGI->verbose( "$sql\n", $verbose ); + my $anidata = $sql->fetchrow_hashref; + $sql->finish; + return $anidata; +} + +###################################################################### +# Beginning of Program +###################################################################### +my ( $callerid, $destination, $cardnumber, $pin ) = @ARGV; +$AGI->answer(); +my ( $clidnumber, $retries ); +while ( !$clidnumber && $retries < $config->{card_retries} ) { + my $answer = $AGI->get_data( $sound->{number_to_register}, $input_timeout ); + if ( $answer == 1 ) { + $clidnumber = $callerid; + } elsif ( $answer > 1 ) { + $clidnumber = $answer; + } else { + $retries++; + } +} +if ( $retries > $config->{card_retries} ) { + $AGI->stream_file($sound->{goodbye}); + exit(0); +} + +my $numberdata = &get_ani($clidnumber); + +if ( $numberdata->{status} == 2 ) { #This number is in our "blocked" list. + $AGI->stream_file($sound->{badnumber}); + $AGI->stream_file($sound->{goodbye}); + exit(0); +} elsif ( !$numberdata ) { + my $cardinfo; + $cardinfo = &get_callingcard( $astpp_db, $cardnumber, $config ) if $cardnumber; + my $retries = 0; + while ( $cardinfo->{status} != 1 && $retries < $config->{card_retries} ) { + my $cardnum = $AGI->get_data( $sound->{cardnumber}, $input_timeout ); + $cardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); + $AGI->verbose( "ASTPP Number: $cardnum ", $verbosity ) + if $config->{debug} == 1; + $AGI->verbose( "ASTPP Number Status: $cardinfo->{status}", $verbosity ) + if $config->{debug} == 1; + if ( $cardinfo->{status} != 1 ) { + $AGI->stream_file($sound->{cardnumber_incorrect}); + } + $retries++; + } + if ( !$cardinfo->{status} ) { + my $sql = + "INSERT INTO ani_map (number,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", 0)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } elsif ( $cardinfo->{status} != 1 ) { + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } + if ( $pin != $cardinfo->{pin} ) { + $retries = 0; + while ( $cardinfo->{pin} != $pin && $retries < $config->{pin_retries} ) { + $pin = $AGI->get_data( $sound->{pin}, $input_timeout ); + if ( $cardinfo->{pin} != $pin ) { + $AGI->stream_file($sound->{pin_incorrect}); + } + $retries++; + } + } + if ( $pin != $cardinfo->{pin} ) { + my $sql = + "INSERT INTO ani_map (number,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", 0)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } + my $cardstatus = &check_card_status( $astpp_db, $cardinfo ); + # This subroutine returns the status of the card: + if ( $cardstatus == 1 ) { + $AGI->stream_file($sound->{card_inuse}); + $AGI->stream_file($sound->{goodbye}); + } elsif ( $cardstatus == 2 ) { + $AGI->stream_file($sound->{card_has_expired}); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + } elsif ( $cardstatus == 3 ) { + $AGI->stream_file($sound->{card_is_empty}); + $AGI->hangup(); + } + my $register = $AGI->get_data( $sound->{register_ani}, $input_timeout ); + if ( $register == 1 ) { + my $sql = + "INSERT INTO ani_map (number,account,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", " + . $astpp_db->quote( $cardinfo->{cardnumber} ) . ", 0)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + } +} else { + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); +} + +$numberdata = &get_ani($clidnumber); +if ( $numberdata->{status} == 1 && $destination ne "REGISTER" ) +{ #This number is registered to a calling card. + my $cardinfo = &get_callingcard( $astpp_db, $numberdata->{account}, $config ); + my $cardstatus = &check_card_status( $astpp_db, $cardinfo ); + # This subroutine returns the status of the card: + if ( $cardstatus == 1 ) { + $AGI->stream_file($sound->{card_inuse}); + $AGI->stream_file($sound->{goodbye}); + } elsif ( $cardstatus == 2 ) { + $AGI->stream_file($sound->{card_has_expired}); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + } elsif ( $cardstatus == 3 ) { + $AGI->stream_file($sound->{card_is_empty}); + $AGI->hangup(); + } elsif ( $cardstatus == 0 ) { + my $retries = 0; + my $desination; + while ( !$destination && $retries < $config->{number_retries} ) { + my $answer = $AGI->get_data( $sound->{where_to_call}, $input_timeout ); + if ( $answer == 1 ) { + $destination = $clidnumber; + } elsif ( $answer > 1 ) { + $destination = $answer; + } else { + $retries++; + } + } + if ( $retries > $config->{number_retries} ) { + $AGI->stream_file($sound->{goodbye}); + exit(0); + } + + # If we get this far then it means that the account is good to go. + my @variables; + my $brandinfo = &get_cc_brand( $astpp_db, $cardinfo->{brand} ); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$cardinfo->{brand}); + my $rateinfo = + &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, + $cardinfo ); + my $connectsurcharge->{name} = "CONNECTSURCHARGE"; + $connectsurcharge->{value} = $rateinfo->{connectcost}; + my $perminutesurcharge->{name} = "PERMINUTESURCHARGE"; + $perminutesurcharge->{value} = $rateinfo->{cost}; + $destination->{name} = "DESTINATION"; + $destination->{value} = $destination; + $pin->{name} = "PIN"; + $pin->{value} = $pin; + push @variables, $connectsurcharge; + push @variables, $perminutesurcharge; + push @variables, $destination; + push @variables, $pin; + &perform_callout( + $destination, + $config->{lcrcontext}, + $config->{callout_accountcode}, + $config->{maxretries}, + $config->{waittime}, + $config->{retrytime}, + $config->{clidname}, + $config->{clidnumber}, + $config->{callingcards_callback_context}, + $config->{callingcards_callback_extension}, + @variables + ); + $AGI->stream_file($sound->{callback_performed}); + $AGI->stream_file($sound->{goodbye}); + exit(0); + } +} + +exit(0); Property changes on: trunk/asterisk_apps/astpp-callback-register.agi ___________________________________________________________________ Added: svn:executable + * Added: svn:mergeinfo + Copied: trunk/asterisk_apps/astpp-callback.agi (from rev 2218, trunk/astpp-callback.agi) =================================================================== --- trunk/asterisk_apps/astpp-callback.agi (rev 0) +++ trunk/asterisk_apps/astpp-callback.agi 2009-01-17 17:13:20 UTC (rev 2220) @@ -0,0 +1,278 @@ +#!/usr/bin/perl +# +# ASTPP callfile creation +# +# Copyright (C) 2006, DNW Consulting +# +# Darren Wiebe <da...@dn...> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Contact information can be found @ www.dnwconsulting.net +# +# ANI Map Info +# Status 0 is for regular ASTPP accounts and status 1 is for calling cards +# that are ok. Status 2 is a blocked number. +# This program is used to request callbacks from ASTPP for calling cards. It's +# also used to register telephone numbers in the "ani_map" table. You can set it +# to register only by passing along "REGISTER" in the ${DESTINATION} field. Here's an +# example on how to call it. +# +# ${CARDNUMBER} = The calling card number we wish to register to. +# ${PIN} = The pin for ${CARDNUMBER} if appropriate. +# ${CALLERIDNUM} = Is the number we are calling from and will use for ANI authentication. +# This is also the number we will be called back at. +# ${DESTINATION} = The number we wish the system to call once we are authenticated. +# +# +# exten => 2,2,DeadAGI(astpp-register-card.agi,${CALLERIDNUM},${DESTINATION},${CARDNUMBER},${PIN}) +# +# +###########################################################################` + +use POSIX qw(ceil floor); +use POSIX qw(strftime); +use DBI; +use Asterisk::AGI; +use strict; +require "/usr/local/astpp/astpp-common.pl"; +use vars qw($vars $verbose $brandinfo $astpp_db $AGI $config @output $sound); +$verbose = 2; +@output = ("STDERR"); +$AGI = new Asterisk::AGI; + +sub initialize() { +$config = &load_config(); +$astpp_db = &connect_db( $config, @output ); +$config = &load_config_db( $astpp_db, $config ); +my $brand = $AGI->get_variable("BRAND"); +if ($brand) { + $brandinfo = &get_cc_brand($astpp_db, $brand); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$brand); +} +} +$sound = &define_sounds($astpp_db); +$SIG{HUP} = 'ignore_hup'; +my $verbosity = 2; +my $input_timeout = 15000; #How long do we wait for input? Specified in MS + +sub ignore_hup { + foreach my $handle (@output) { + print $handle "HUP received\n"; + } +} + +sub get_ani() { + my ($number) = @_; + my ($sql); + my $tmp = "SELECT * FROM ani_map WHERE number = " . $astpp_db->quote($number); + $sql = + $astpp_db->prepare($tmp); + $sql->execute; + $AGI->verbose( "$tmp\n", $verbose ); + my $anidata = $sql->fetchrow_hashref; + $sql->finish; + return $anidata; +} + +###################################################################### +# Beginning of Program +###################################################################### +my ( $callerid, $destination, $cardnumber, $pin ) = @ARGV; +$AGI->answer(); +my ( $clidnumber, $retries ); +&initialize(); +$retries = 0; +$clidnumber = $callerid if $destination ne "REGISTER"; +while ( !$clidnumber && $retries < $config->{card_retries} ) { + my $answer = $AGI->get_data( $sound->{number_to_register}, $input_timeout ); + if ( $answer == 1 ) { + $clidnumber = $callerid; + } elsif ( $answer > 1 ) { + $clidnumber = $answer; + } else { + $retries++; + } +} +if ( $retries > $config->{card_retries} ) { + $AGI->stream_file($sound->{goodbye}); + exit(0); +} + +my $numberdata = &get_ani($clidnumber); + +if ( $numberdata->{status} == 2 ) { #This number is in our "blocked" list. + $AGI->stream_file($sound->{badnumber}); + $AGI->stream_file($sound->{goodbye}); + exit(0); +} elsif ( !$numberdata->{number} ) { + my $cardinfo; + $cardinfo = &get_callingcard( $astpp_db, $cardnumber, $config ) if $cardnumber; + my $retries = 0; + while ( $cardinfo->{status} != 1 && $retries < $config->{card_retries} ) { + my $cardnum = $AGI->get_data( $sound->{cardnumber}, $input_timeout ); + $cardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); + $AGI->verbose( "ASTPP Number: $cardnum ", $verbosity ) + if $config->{debug} == 1; + $AGI->verbose( "ASTPP Number Status: $cardinfo->{status}", $verbosity ) + if $config->{debug} == 1; + if ( $cardinfo->{status} != 1 ) { + $AGI->stream_file($sound->{cardnumber_incorrect}); + } + $retries++; + } + if ( !$cardinfo->{status} ) { + my $sql = + "INSERT INTO ani_map (number,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", 2)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } elsif ( $cardinfo->{status} != 1 ) { + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } + if ( $pin != $cardinfo->{pin} ) { + $retries = 0; + while ( $cardinfo->{pin} != $pin && $retries < $config->{pin_retries} ) { + $pin = $AGI->get_data( $sound->{pin}, $input_timeout ); + if ( $cardinfo->{pin} != $pin ) { + $AGI->stream_file($sound->{pin_incorrect}); + } + $retries++; + } + } + if ( $pin != $cardinfo->{pin} ) { + my $sql = + "INSERT INTO ani_map (number,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", 2)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } + my $cardstatus = &check_card_status( $astpp_db, $cardinfo ); + # This subroutine returns the status of the card: + if ( $cardstatus == 1 ) { + $AGI->stream_file($sound->{card_inuse}); + $AGI->stream_file($sound->{goodbye}); + } elsif ( $cardstatus == 2 ) { + $AGI->stream_file($sound->{card_has_expired}); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + } elsif ( $cardstatus == 3 ) { + $AGI->stream_file($sound->{card_is_empty}); + $AGI->hangup(); + } + my $register = $AGI->get_data( $sound->{register_ani}, $input_timeout ); + if ( $register == 1 ) { + my $sql = + "INSERT INTO ani_map (number,account,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", " + . $astpp_db->quote( $cardinfo->{cardnumber} ) . ", 1)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + } +} else { + if ($destination eq "REGISTER") { + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } +} + +$numberdata = &get_ani($clidnumber); +if ( $numberdata->{status} == 1 && $destination ne "REGISTER" ) +{ #This number is registered to a calling card. + my $cardinfo = &get_callingcard( $astpp_db, $numberdata->{account}, $config ); + my $cardstatus = &check_card_status( $astpp_db, $cardinfo ); + # This subroutine returns the status of the card: + if ( $cardstatus == 1 ) { + $AGI->stream_file($sound->{card_inuse}); + $AGI->stream_file($sound->{goodbye}); + } elsif ( $cardstatus == 2 ) { + $AGI->stream_file($sound->{card_has_expired}); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + } elsif ( $cardstatus == 3 ) { + $AGI->stream_file($sound->{card_is_empty}); + $AGI->hangup(); + } elsif ( $cardstatus == 0 ) { + my $retries = 0; + my $destination; + while ( !$destination && $retries < $config->{number_retries} ) { + my $answer = $AGI->get_data( $sound->{where_to_call}, $input_timeout ); + if ( $answer == 1 ) { + $destination = $clidnumber; + } elsif ( $answer > 1 ) { + $destination = $answer; + } else { + $retries++; + } + } + if ( $retries > $config->{number_retries} ) { + $AGI->stream_file($sound->{goodbye}); + exit(0); + } + + # If we get this far then it means that the account is good to go. + my @variables; + my $brandinfo = &get_cc_brand( $astpp_db, $cardinfo->{brand} ); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$cardinfo->{brand}); + if ($destination =~ m/\d\d\d\d\d\d\d\d\d\d/) { + $destination = "1" . $destination; + } + my $rateinfo = + &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, + $cardinfo ); + $AGI->stream_file($sound->{callback_performed}); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + sleep 15; # This is to give the customer time to hang their phone up. + my %variables = ( CONNECTSURCHARGE => $rateinfo->{connectcost}, + PERMINUTESURCHARGE => $rateinfo->{cost}, + CARDNUMBER => $cardinfo->{cardnumber}, + PIN => $cardinfo->{pin}); + my $ActionID = &perform_callout( + $astpp_db, $config, + $destination, + $config->{lcrcontext}, + $config->{callout_accountcode}, + $config->{maxretries}, + $config->{waittime}, + $config->{retrytime}, + $config->{clidname}, + $config->{clidnumber}, + $config->{callingcards_callback_context}, + $config->{callingcards_callback_extension}, + %variables + ); + exit(0); + } +} + +exit(0); Property changes on: trunk/asterisk_apps/astpp-callback.agi ___________________________________________________________________ Added: svn:executable + * Added: svn:mergeinfo + Copied: trunk/asterisk_apps/astpp-callingcards.agi (from rev 2218, trunk/astpp-callingcards.agi) =================================================================== --- trunk/asterisk_apps/astpp-callingcards.agi (rev 0) +++ trunk/asterisk_apps/astpp-callingcards.agi 2009-01-17 17:13:20 UTC (rev 2220) @@ -0,0 +1,774 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2004, Aleph Communications +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +# +# Sample Configuration +# [astpp-callingcards] +# exten => s,1,Answer +# exten => s,n,DeadAGI(astpp-callingcards.agi) +# exten => s,n,GotoIf($["${NEWCALL}" = "1"]?60) +# exten => s,n,GotoIf($["${BALANCE}" = "1"]?70) +# exten => s,n,Hangup +# exten => s,60,DeadAGI(astpp-callingcards.agi,${CARDNUMBER}) +# exten => s,n,Hangup +# exten => s,70,DeadAGI(astpp-callingcards.agi,${CARDNUMBER},BALANCE) +# +############################################################################# +use DBI; +use Asterisk::AGI; +use POSIX qw(ceil floor); +use POSIX qw(strftime); +use Time::HiRes qw( gettimeofday tv_interval ); +use ASTPP; +#use strict; + +use vars qw(@output $verbosity $AGI $config $astpp_db $cdr_db + $ASTPP %stats %input $cc $pricelistinfo $brandinfo $sound @resellerlist $brand); +$stats{start_time} = [gettimeofday]; +$cc = 0; +$verbosity = 1; +require "/usr/local/astpp/astpp-common.pl"; + +$AGI = new Asterisk::AGI; +$AGI->set_variable( 'ASTPP', '1' ); +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to be. +#$ASTPP->set_asterisk_agi($AGI); + +sub initialize() { + $SIG{HUP} = 'ignore_hup'; # We ignore the HUP command that Asterisk sends on a call hangup. + $config = &load_config(); # Load /var/lib/astpp/astpp-config.conf + $astpp_db = &connect_db( $config, @output ); + $ASTPP->set_astpp_db($astpp_db); + $config = &load_config_db($astpp_db,$config); + $brand = $AGI->get_variable("BRAND"); + if ($brand && $brand ne "") { + my $brandinfo = &get_cc_brand($astpp_db, $brand); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$brand); + } + $cdr_db = &cdr_connect_db( $config, @output ); + $ASTPP->set_cdr_db($cdr_db); + $sound = &define_sounds($astpp_db); +} + +=over 4 + +=item bgplay([$filename1, $filename2, ..., $filenameN], $timeout, $maxdigit) + +Executes Asterisk Command "Background filename1&filename2...filenameN" And +Asterisk AGI Command "Get Data filename timeout, maxdigit". + +This command instructs Asterisk to play the given list of sound files and wait for user input in form of DTMF, +upto 'maxdigit' (optional) till timeout (optional) happens. Files extension must not be used in the filename +because Asterisk will find the most appropriate file type. + +Example: bgplay(["demo-echotest", "echo-test"], 10, 4); +Plays files "demo-echotest" and "echo-test" and waits for 10 seconds for user to enter 4 dight DTMF. + +Returns: -1 on error or hangup, +0 if timeout for user input happens, +or user input upto maxdigit value (default 1) + +=cut + +sub bgplay(\@;$$) +{ + my $files = shift; + my $timeout = shift||1; + my $maxdigit= shift||1; + + my $x = shift(@{$files}); + foreach (@{$files}) { + $x .= '&' . $_; + } + + my $res = $AGI->exec("Background $x"); + + if($res > 0) { + $res -= 48; + } + + if($maxdigit > 1) { + $res .= $AGI->get_data("silence/1", ($timeout * 1000), ($maxdigit - 1)); + } + + return $res; +} + +sub ignore_hup { + $ASTPP->debug( debug => "HUP received", + verbosity => $verbosity); +} + +sub set_in_use() { # Set the "inuse" flag on the calling cards. This prevents multiple people from +# using the same card. + my ( $cardinfo, $status ) = @_; + my $sql; + $sql = + "UPDATE callingcards SET inuse = " + . $astpp_db->quote($status) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); +} + +sub check_card() { # Check a few things before saying the card is ok. + my ($cardinfo) = @_; + my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; + $ASTPP->debug( debug => "Present Time: $now", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Expiration Date: $cardinfo->{expiry}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Valid for Days: $cardinfo->{validfordays}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "First Use: $cardinfo->{firstused}", + verbosity => $verbosity ); + if ( $cardinfo->{inuse} != 0 ) { # If the card is in use then say so and leave. + $AGI->stream_file($sound->{card_inuse}); + $AGI->stream_file($sound->{goodbye}); + &leave($cardinfo); + } + &set_in_use( $cardinfo, 1 ); # Now the card is in use and nobody else can use it. + if ( $cardinfo->{firstused} eq "00000000000000" || $cardinfo->{firstused} eq "0000-00-00 00:00:00" ) { # If "firstused" has not been set, we will set it now. + # At the same time we will update the "maint_day" field. + my $sql = + "UPDATE callingcards SET firstused = NOW() WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $sql = + "UPDATE callingcards SET maint_day = DATE_ADD(NOW(), INTERVAL " + . "$cardinfo->{maint_fee_days} day) WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + if ( $cardinfo->{maint_fee_days} > 0 ) { + $astpp_db->do($sql); + } +# $cardinfo = &get_callingcard( $astpp_db, $cardinfo->{cardnumber} ); + if ( $cardinfo->{validfordays} > 0 ) { #Check if the card is set to expire and deal with that as appropriate. + my $sql = +"UPDATE callingcards SET expiry = DATE_ADD(NOW(), INTERVAL " + . " $cardinfo->{validfordays} day) WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $cardinfo = &get_callingcard( $astpp_db, $cardinfo->{cardnumber}, $config ); + } + } + elsif ( $cardinfo->{validfordays} > 0 ) { + my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; + $cardinfo->{expiry} = $astpp_db->selectall_arrayref("SELECT DATE_FORMAT('$cardinfo->{expiry}' , '\%Y\%m\%d\%H\%i\%s')")->[0][0]; + if ( $now >= $cardinfo->{expiry} ) { + my $sql = + "UPDATE callingcards SET status = 2 WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $sql = + "DELETE FROM ani_map WHERE account = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $AGI->stream_file($sound->{card_has_expired}); + $AGI->stream_file($sound->{goodbye}); + &leave($cardinfo); + } + } + $ASTPP->debug( debug => "Present Time: $now", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Expiration Date: $cardinfo->{expiry}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Valid for Days: $cardinfo->{validfordays}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "First Use: $cardinfo->{firstused}", + verbosity => $verbosity ); +} + +sub tell_cost() { #Say how much the call will cost. + my ( $numberinfo, $pricelistinfo, $cardinfo ) = @_; + if ( $pricelistinfo->{markup} ne "" && $pricelistinfo->{markup} != 0 ) { + $ASTPP->debug( debug => "Adding Markup of $pricelistinfo->{markup}", + verbosity => $verbosity); + $numberinfo->{connectcost} = + $numberinfo->{connectcost} * + ( ( $pricelistinfo->{markup} / 10000 ) + 1 ); + $numberinfo->{cost} = + $numberinfo->{cost} * ( ( $pricelistinfo->{markup} / 10000 ) + 1 ); + } + if ($config->{calling_cards_rate_announce} == 1) { + if ( $numberinfo->{cost} > 0 ) { + $AGI->stream_file($sound->{call_will_cost}); +# $AGI->say_number(ceil($numberinfo->{cost} / 100)); +# $AGI->stream_file($sound->{currency}); + my @call_cost = split(/\./, ($numberinfo->{cost} / 100)); + $AGI->say_number(@call_cost[0]); + if (@call_cost[1]) { + $AGI->stream_file($sound->{point}); + $AGI->say_number(@call_cost[1]); + $AGI->stream_file($sound->{sub_currency}); + } + $AGI->stream_file($sound->{per}); + $AGI->stream_file($sound->{minute}); + } + if ( $numberinfo->{connectcost} > 0 ) { + $AGI->stream_file($sound->{a_connect_charge}); + $AGI->say_number(ceil($numberinfo->{connectcost} / 100)); + $AGI->stream_file($sound->{sub_currency}); + $AGI->stream_file($sound->{will_apply}); + } + } +} + +sub timelimit() { #Calculate and say the time limit. + my ( $numberinfo, $pricelistinfo, $cardinfo, $phoneno ) = @_; + my ( $connectfee, $cost, $timelimit, $available, $maxtime, $balance ); +# if ( $numberinfo->{connectfee} > 0 ) { +# $connectfee = $numberinfo->{connectfee} / 100; +# } +# if ( $numberinfo->{cost} > 0 ) { +# $cost = $numberinfo->{cost} / 100; +# } + # Timelimit is in seconds + if ($cc == 0) { +# $available = +# ( ( $cardinfo->{value} - $cardinfo->{used} ) / 100 ) - $numberinfo->{connectfee}; + $available = + ( $cardinfo->{value} - $cardinfo->{used} ) - $numberinfo->{connectfee}; + $ASTPP->debug( debug => "FUNDS AVAILABLE: $available", + verbosity => $verbosity); + } elsif ( $cc == 1 ) { + $balance = &accountbalance( $astpp_db, $cardinfo->{number} ); + $balance = ($balance * -1) + ( $cardinfo->{credit_limit}); + $available = ($balance - $numberinfo->{connectfee}) / 100; + } + if ( $available > 0 && $numberinfo->{cost} > 0 ) { + $timelimit = ( ( $available / $numberinfo->{cost} ) * 60 ); + } + elsif ( $available >= 0 && $numberinfo->{cost} <= 0 ) { + $timelimit = $config->{callingcards_max_length}; + } + if ( $timelimit > $config->{callingcards_max_length} ) { + $timelimit = $config->{callingcards_max_length}; + } + $ASTPP->debug( debug => "TIMELIMIT: $timelimit", + verbosity => $verbosity); + if ($brandinfo->{reseller} ne "") { + ASTPP->debug( debug => "THIS BRAND BELONGS TO $brandinfo->{reseller}!", + verbosity => $verbosity); + my $carddata = &get_account( $astpp_db, $brandinfo->{reseller} ); +# ($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); +# my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); + my $minimumcharge = $numberinfo->{cost}; + my $belongs_to_reseller = 1; + while ( $belongs_to_reseller == 1 ) { + $ASTPP->debug( debug => "FINDING LIMIT FOR: $carddata->{reseller}", + verbosity => $verbosity); + push @resellerlist, $carddata->{number}; + $ASTPP->debug( debug => "PUSHING $carddata->{number} ONTO THE LIST OF RESELLERS", + verbosity => $verbosity); + my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); + my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist}, $carddata, "CC" ); + if ($resellercallstatus != 1) { + $carddata->{reseller} = ""; + $timelimit = 0; + } elsif ($resellermaxlength < $timelimit / 60) { + $timelimit = $resellermaxlength * 60; + } + if ($resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) { + $carddata->{reseller} = ""; + $timelimit = 0; + } + $ASTPP->debug( debug => "RESELLER Max Length: $resellermaxlength", + verbosity => $verbosity); + $ASTPP->debug( debug => "RESELLER Call Status: $resellercallstatus", + verbosity => $verbosity); + if ($carddata->{reseller} && $carddata->{reseller} ne "") { + $carddata = &get_account( $astpp_db, $carddata->{reseller} ); + } else { + $belongs_to_reseller = 0; + } + } + } else { + $ASTPP->debug( debug => "THIS BRAND DOES NOT BELONG TO A RESELLER!", + verbosity => $verbosity); + } + $ASTPP->debug( debug =>"TIMELIMIT: $timelimit", verbosity => $verbosity); + my $minutes = $timelimit / 60; + $ASTPP->debug( debug => "MINUTES: $minutes", verbosity => $verbosity); + if ($minutes > 0 && $config->{calling_cards_timelimit_announce} == 1) { + my $minutes = $timelimit / 60; + $minutes = sprintf( "%.0f", $minutes ); + $AGI->stream_file($sound->{call_will_last}); + if ( $minutes == 1 ) { + $AGI->say_number($minutes); + $AGI->stream_file($sound->{minute}); + } + elsif ( $minutes > 1 ) { + $AGI->say_number($minutes); + $AGI->stream_file($sound->{minutes}); + } + } + elsif ($minutes < 1) { + $AGI->stream_file($sound->{not_enough_credit}); + $AGI->stream_file($sound->{goodbye}); + &leave($cardinfo); + } + $maxtime = $timelimit * 1000; + + + $timelimit = "\|30\|HL($maxtime:60000:30000)\|Hgj"; + $ASTPP->debug( debug => "Available: $available", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Balance: $balance", verbosity => $verbosity ); + $ASTPP->debug( debug => "Max Time: $maxtime", verbosity => $verbosity ); + return $timelimit; +} + +sub say_balance() { #Calculate and say the card balance. + my ($cardinfo) = @_; + my ( $connectfee, $cost, $included, $sub_balance, $balance, $main_balance ); + if ($cc == 0 ) { + $balance = $cardinfo->{value} - $cardinfo->{used}; + } elsif ($cc ==1) { + $balance = &accountbalance( $astpp_db, $cardinfo->{number} ); + $balance = ($balance * -1) + ( $cardinfo->{credit_limit} ); + } + if ( $balance > 0 ) { + $balance = $balance / 10000; + $balance = sprintf( "%.2f", $balance ); + $sub_balance = substr( $balance, -2, 2 ); + $main_balance = substr( $balance, 0, -2 ); + my $interrupt = &bgplay([$sound->{card_has_balance_of}], 0, 1); +# my $interrupt = $AGI->get_data($sound->{card_has_balance_of},0,1); + if (!$interrupt || $interrupt eq "" || $interrupt == 0) { + if ( $main_balance == 1 ) { + $AGI->say_number($main_balance); + $AGI->stream_file($sound->{main_currency}); + } + elsif ( $main_balance > 1 ) { + $AGI->say_number($main_balance); + $AGI->stream_file($sound->{main_currency_plural}); + } + if ( $sub_balance == 1 ) { + $AGI->say_number($sub_balance); + $AGI->stream_file($sound->{sub_currency}); + } + elsif ( $sub_balance > 1 ) { + $AGI->say_number($sub_balance); + $AGI->stream_file($sound->{sub_currency_plural}); + } + } + } + else { + $AGI->stream_file($sound->{card_is_empty}); + $AGI->stream_file($sound->{goodbye}); + &leave($cardinfo); + } + return $balance; +} + +sub update_balance() { #Update the available credit on the calling card. + my ( $cardinfo, $charge ) = @_; + my $sql = + "UPDATE callingcards SET used = " + . $astpp_db->quote( ($charge) + $cardinfo->{used} ) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); +} + +sub write_asterisk_cdr() { #Write the cdr record to the asterisk cdr db. This is done so we get a record of the call the callingcard user placed. + # This is especially important for resellers and calling cards. + my ( + $reseller, $clid, $destination, $status, + $callstart, $answeredtime, $dstchannel, $lastapp, $dialedtime, $uniqueid, $asterisk_time, $cdr_db + ) + = @_; + my ($sql); + if (!$status) {$status = gettext("N/A"); } + $sql = "INSERT INTO cdr (calldate,dst,clid,dstchannel,lastapp,duration,billsec,disposition,accountcode,uniqueid) VALUES(" + . $astpp_db->quote($asterisk_time) . ", " + . $astpp_db->quote($destination) . ", " + . $astpp_db->quote($clid) . ", " + . $astpp_db->quote($dstchannel) . ", " + . $astpp_db->quote($lastapp) . ", " + . $astpp_db->quote($dialedtime) . ", " + . $astpp_db->quote($answeredtime) . ", " + . $astpp_db->quote($status) . ", " + . $astpp_db->quote( $reseller ) . ", " + . $astpp_db->quote( $uniqueid ) . ")"; + $cdr_db->do($sql); + $AGI->set_variable( "\"ANSWEREDTIME\"", "0" ); + $AGI->set_variable( "\"DIALEDTIME\"", "0" ); + $AGI->set_variable( "\"DIALSTATUS\"", "NO ANSWER" ); +} + + +sub write_cdr() { # Write the callingcardcdr record if this is a calling card. + my ( + $cardinfo, $clid, $destination, $status, + $callstart, $charge, $answeredtime + ) + = @_; + my ($sql); + if (!$status) {$status = gettext("N/A"); } + $sql = +"INSERT INTO callingcardcdrs (cardnumber,clid,destination,disposition,callstart,seconds," + . "debit) VALUES (" + . $astpp_db->quote( $cardinfo->{cardnumber} ) . ", " + . $astpp_db->quote($clid) . ", " + . $astpp_db->quote($destination) . ", " + . $astpp_db->quote($status) . ", " + . $astpp_db->quote($callstart) . ", " + . $astpp_db->quote($answeredtime) . ", " + . $astpp_db->quote($charge) . ")"; + $astpp_db->do($sql); + $ASTPP->debug( debug => "$sql", verbosity => $verbosity ); + $ASTPP->debug( debug => "Resetting CDR Variables", verbosity => $verbosity ); + $AGI->set_variable( "\"ANSWEREDTIME\"", "0" ); + $AGI->set_variable( "\"DIALEDTIME\"", "0" ); + $AGI->set_variable( "\"DIALSTATUS\"", "NO ANSWER" ); +} + +sub dialout() { # Rig up the LCR stuff and do the outbound dialing. + # If a call does not go through we give the user the option + # of trying again. + my ( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ) = + @_; + my ( $status, $count, $increment ); + $ASTPP->debug( debug => "Looking for outbound Route", verbosity => $verbosity ); + my @outboundroutes = &get_outbound_routes( $astpp_db, $destination,$cardinfo,$numberinfo, @resellerlist ); + $count = @outboundroutes; + if ( $count == 0 ) { + $ASTPP->debug(debug => "NO OUTBOUND ROUTES FOUND!", verbosity => $verbosity ); + my $order = $AGI->get_data( $sound->{noanswer}, $config->{calling_cards_general_input_timeout}, 1 ); + if ( $order != 1 ) { + &write_cdr( $cardinfo, "", $destination, gettext("NO Route Found"), "", 0, 0 ); + &leave($cardinfo); + } + } + $count = 0; + foreach my $route (@outboundroutes) { + my $trunk = &get_dial_string( $astpp_db, $route, $destination ); + my $dialstring = $trunk . $timelimit; + my $callstart = localtime(); + my ($accountcode); + $callstart = &prettytimestamp if $cc == 1; + $AGI->set_variable( "\"LCRSTRING$count\"", + "\"$config->{callingcardowner}\"" ); + $AGI->exec( 'Set', "TRUNK_NAME$count=$route->{trunk}" ); + if ($brandinfo->{reseller} ne "" ) { + $AGI->exec( 'Set', "accountcode=$brandinfo->{reseller}" ); + $accountcode = $brandinfo->{reseller}; + + } else { + $AGI->exec( 'Set', "accountcode=$config->{callingcardowner}" ); + $accountcode = $config->{callingcardowner}; + } + my $res = $AGI->exec("DIAL $dialstring"); + my $status = $AGI->get_variable("DIALSTATUS"); + my $answeredtime = $AGI->get_variable("ANSWEREDTIME"); + $stats{answered_time} = $AGI->get_variable("ANSWEREDTIME"); + my $dialedtime = $AGI->get_variable("DIALEDTIME"); + my $uniqueid = $AGI->get_variable("UNIQUEID"); + $stats{uniqueid} = $AGI->get_variable("UNIQUEID"); + my $clid = $AGI->get_variable("CALLERID(all)"); + my $asterisk_time = &prettytimestamp; + $ASTPP->debug( debug => "CALL STATUS $status", verbosity => 1); + $ASTPP->debug( debug => "ANSWERED TIME $answeredtime", verbosity => $verbosity); + $ASTPP->debug( debug => "Account CC?: $cc", verbosity => $verbosity); + + if ( ( $status != ~/CHANUNAVAIL/ ) && ( $status != ~/CONGESTION/ ) ) { + if ( $status =~ /BUSY/ ) { + $ASTPP->debug( debug => "CALL BUSY", verbosity => $verbosity ); + my $order = $AGI->get_data( $sound->{busy}, $config->{calling_cards_general_input_timeout},1 ); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } else { + push @outboundroutes, $route; + } + } + elsif ( $status =~ /NOANSWER/ ) { + $ASTPP->debug(debug=> "NO ANSWER", verbosity => $verbosity ); + my $order = $AGI->get_data( $sound->{noanswer}, $config->{calling_cards_general_input_timeout},1 ); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } else { + push @outboundroutes, $route; + } + } + elsif ( $status =~ /ANSWER/ || $answeredtime > 0) { + $ASTPP->debug( debug => "CALL ANSWERED", verbosity => $verbosity ); + my $increment; + if ( $numberinfo->{inc} > 0 ) { + $increment = $numberinfo->{inc}; + } + else { + $increment = $pricelistinfo->{inc}; + } + $ASTPP->debug( debug => "$numberinfo->{connectcost}, $numberinfo->{cost}, $answeredtime, $increment, $numberinfo->{includedseconds}", + verbosity => $verbosity); + my $charge = &calc_call_cost( + $numberinfo->{connectcost}, $numberinfo->{cost}, + $answeredtime, $increment, + $numberinfo->{includedseconds} + ); + $ASTPP->debug( debug => "Cost $charge ", verbosity => $verbosity ); + if ($cardinfo->{minute_fee_pennies} > 0) { + $charge = (($cardinfo->{minute_fee_pennies} * 100) + $charge) if $cardinfo->{timeused} + $answeredtime => $cardinfo->{minute_fee_minutes}; + } + if ($cardinfo->{min_length_pennies} > 0 && ($cardinfo->{min_length_minutes}*60) > $answeredtime) { + $charge = (($cardinfo->{min_length_pennies} * 100) + $charge); + } + if ( $cc == 0 ) { + &write_cdr( + $cardinfo, $clid, $destination, $status, + $callstart, $charge, $answeredtime, $uniqueid + ); + &write_asterisk_cdr( $accountcode, $clid, $destination, "ANSWERED", + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &update_balance( $cardinfo, $charge ); + $astpp_db->do("UPDATE callingcards SET timeused = " + . $astpp_db->quote($cardinfo->{timeused} + $answeredtime) + . " WHERE cardnumber = " + . $astpp_db->quote($cardinfo->{cardnumber})); + } + elsif ( $cc == 1 ) { + my $status = + &write_account_cdr( $astpp_db, $cardinfo->{number}, + $charge, $destination, $callstart, $answeredtime, $uniqueid, $clid ); + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $ASTPP->debug( debug => $status, verbosity => $verbosity ); + } + $AGI->stream_file($sound->{call_completed}); + &leave($cardinfo); + } + elsif ( $status =~ /CANCEL/ ) { + $ASTPP->debug( debug => "CALL CANCELLED", verbosity => $verbosity ); + $AGI->stream_file($sound->{cancelled}) if $config->{calling_cards_cancelled_prompt} == 1; + &write_cdr( $cardinfo, $clid, $destination, $status, $callstart, 0, + 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } + else { + $ASTPP->debug( debug => "ERROR - ERROR - ERROR", verbosity => $verbosity ); + my $order = $AGI->get_data( $sound->{noanswer}, $config->{calling_cards_general_input_timeout},1 ); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } + } + } + } +} + +sub leave() { # Prepare everything and then leave the calling card app. + my ($cardinfo) = @_; + my ($whatnow); + my $retries = 0; + &set_in_use( $cardinfo, 0 ) if $cc == 0; + while ($retries < ... [truncated message content] |
From: <dar...@us...> - 2009-01-17 03:22:04
|
Revision: 2219 http://astpp.svn.sourceforge.net/astpp/?rev=2219&view=rev Author: darrenkw Date: 2009-01-17 02:19:55 +0000 (Sat, 17 Jan 2009) Log Message: ----------- Change auto_dialer license to BSD. Fix code that was causing invoices to be totaled incorrectly in oscommerce. Modified Paths: -------------- trunk/astpp-common.pl trunk/contrib/auto_dialer/LICENSE Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-12-07 01:06:53 UTC (rev 2218) +++ trunk/astpp-common.pl 2009-01-17 02:19:55 UTC (rev 2219) @@ -4772,7 +4772,7 @@ &markbilled( $astpp_db, $row->{id}, 1 ); } $subtotal = &osc_order_subtotal($osc_db, $config, $invoice_id); - $subtotal = sprintf( "%." . $config->{decimalpoints_total} . "f", $total ); + $subtotal = sprintf( "%." . $config->{decimalpoints_total} . "f", $subtotal ); print STDERR "ORDER $invoice_id SUBTOTAL: $subtotal"; $sort = 1; $tax_count = 1; Modified: trunk/contrib/auto_dialer/LICENSE =================================================================== --- trunk/contrib/auto_dialer/LICENSE 2008-12-07 01:06:53 UTC (rev 2218) +++ trunk/contrib/auto_dialer/LICENSE 2009-01-17 02:19:55 UTC (rev 2219) @@ -1,341 +1,12 @@ - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) 19yy <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. +THE BSD LICENSE + +Copyright (c) 2009, Aleph Communications +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the Aleph Communications nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-12-07 01:07:00
|
Revision: 2218 http://astpp.svn.sourceforge.net/astpp/?rev=2218&view=rev Author: darrenkw Date: 2008-12-07 01:06:53 +0000 (Sun, 07 Dec 2008) Log Message: ----------- Corrected Freeswitch max call length support. Modified Paths: -------------- trunk/astpp-common.pl trunk/freeswitch/astpp-fs-xml.pl trunk/sql/astpp-2008-12-06.sql Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-12-06 22:37:02 UTC (rev 2217) +++ trunk/astpp-common.pl 2008-12-07 01:06:53 UTC (rev 2218) @@ -3677,12 +3677,18 @@ } if ( $numdata->{cost} > 0 ) { $maxlength = ( ( $credit - $numdata->{connectcost} ) / $numdata->{cost} ); + if ($config->{call_max_length} && $maxlength < $config->{call_max_length} / 1000){ + $maxlength = $config->{call_max_length} / 1000 / 60; + } } else { $maxlength = $config->{max_free_length}; # If the call is set to be free then assign a max length. } if ( $numdata->{cost} > 0 ) { $maxlength = ( ( $credit - $numdata->{connectcost} ) / $numdata->{cost} ); + if ($config->{call_max_length} && $maxlength < $config->{call_max_length} / 1000){ + $maxlength = $config->{call_max_length} / 1000 / 60; + } } else { $maxlength = $config->{max_free_length}; # If the call is set to be free then assign a max length. Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2008-12-06 22:37:02 UTC (rev 2217) +++ trunk/freeswitch/astpp-fs-xml.pl 2008-12-07 01:06:53 UTC (rev 2218) @@ -190,6 +190,8 @@ $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); print $xml; exit(0); + } elsif ($config->{call_max_length} && $maxlength < $config->{call_max_length} / 1000){ + $maxlength = $config->{call_max_length} / 1000; } $xml = $ASTPP->fs_dialplan_xml_timelimit( @@ -229,6 +231,8 @@ } } $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); + $ASTPP->debug( debug => $xml ); + print $xml; } elsif ( $params->{section} eq "directory" ) { @@ -264,7 +268,7 @@ ); $xml = $ASTPP->fs_directory_xml_footer( xml => $xml ); } + $ASTPP->debug( debug => $xml ); + print $xml; } -$ASTPP->debug( debug => $xml ); -print $xml; exit(0); Modified: trunk/sql/astpp-2008-12-06.sql =================================================================== --- trunk/sql/astpp-2008-12-06.sql 2008-12-06 22:37:02 UTC (rev 2217) +++ trunk/sql/astpp-2008-12-06.sql 2008-12-07 01:06:53 UTC (rev 2218) @@ -782,6 +782,9 @@ INSERT INTO system (name, value, comment, timestamp) VALUES ( 'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'call_max_length','1440000','What is the maximum length (in ms) of a LCR call?',''); + ------ 3rd Party PBX Mods INSERT INTO system (name, value, comment, timestamp) VALUES ( 'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-12-06 22:37:08
|
Revision: 2217 http://astpp.svn.sourceforge.net/astpp/?rev=2217&view=rev Author: darrenkw Date: 2008-12-06 22:37:02 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Fix the code that causes astpp to return results for freeswitch directory even when no result is found. Also add code to round totals and taxes to a different number of decimal points than we bill to. This is useful to be able to bill calls accurately up to X decimal points but still present the customer with a bill where the totals are just rounded to 2 decimal points. Modified Paths: -------------- trunk/astpp-common.pl trunk/freeswitch/astpp-fs-xml.pl Added Paths: ----------- trunk/sql/astpp-2008-12-06.sql Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-12-06 18:35:51 UTC (rev 2216) +++ trunk/astpp-common.pl 2008-12-06 22:37:02 UTC (rev 2217) @@ -4672,7 +4672,6 @@ $desc = "$row->{callstart} SRC: $row->{callerid} DST: $row->{callednum} SEC:$row->{billseconds} $row->{notes}"; $price = $row->{debit} / 10000; if($config->{osc_post_nc} == 1 || $price != 0) { - $price = sprintf( "%." . $config->{decimalpoints} . "f", $price ); $tmp = "INSERT INTO `orders_products` (`orders_products_id`,`orders_id`,`products_id`,`products_name`,`products_price`," . "`final_price`,`products_tax`,`products_quantity`) VALUES (''," @@ -4767,6 +4766,7 @@ &markbilled( $astpp_db, $row->{id}, 1 ); } $subtotal = &osc_order_subtotal($osc_db, $config, $invoice_id); + $subtotal = sprintf( "%." . $config->{decimalpoints_total} . "f", $total ); print STDERR "ORDER $invoice_id SUBTOTAL: $subtotal"; $sort = 1; $tax_count = 1; @@ -4779,7 +4779,7 @@ $tax_priority = $tax->{tax_priority}; $tax_amount = $subtotal * ( $tax->{tax_rate} / 100 ); $sort++; - $tax_amount = sprintf( "%." . $config->{decimalpoints} . "f", $tax_amount ); + $tax_amount = sprintf( "%." . $config->{decimalpoints_tax} . "f", $tax_amount ); &osc_post_total( $osc_db, $config, $invoice_id, $tax->{tax_description}, "\$$tax_amount", $tax_amount, $sort, "ot_tax" ); $tax_count++; @@ -4791,14 +4791,14 @@ $tax_priority = $tax->{tax_priority}; $tax_amount = $subtotal * ( $tax->{tax_rate} / 100 ); $sort++; - $tax_amount = sprintf( "%." . $config->{decimalpoints} . "f", $tax_amount ); + $tax_amount = sprintf( "%." . $config->{decimalpoints_tax} . "f", $tax_amount ); &osc_post_total($osc_db, $config, $invoice_id, $tax->{tax_description}, "\$$tax_amount", $tax_amount, $sort, "ot_tax" ); } } $total = &osc_order_total($osc_db, $config, $invoice_id); $sort++; - $total = sprintf( "%." . $config->{decimalpoints} . "f", $total ); + $total = sprintf( "%." . $config->{decimalpoints_total} . "f", $total ); &osc_post_total($osc_db, $config, $invoice_id, "Total:", "<b>\$$total</b>", $total, $sort, "ot_total" ); &email_new_invoice( $astpp_db, "", $config, $account, $invoice_id, Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2008-12-06 18:35:51 UTC (rev 2216) +++ trunk/freeswitch/astpp-fs-xml.pl 2008-12-06 22:37:02 UTC (rev 2217) @@ -254,14 +254,16 @@ #domain 192.168.2.119 #ip 192.168.2.119 - $xml = $ASTPP->fs_directory_xml_header( xml => $xml ); - $xml = $ASTPP->fs_directory_xml( - xml => $xml, - ip => $params->{'ip'}, - user => $params->{'user'}, - domain => $params->{'domain'} - ); - $xml = $ASTPP->fs_directory_xml_footer( xml => $xml ); + if ($params->{'user'}) { + $xml = $ASTPP->fs_directory_xml_header( xml => $xml ); + $xml = $ASTPP->fs_directory_xml( + xml => $xml, + ip => $params->{'ip'}, + user => $params->{'user'}, + domain => $params->{'domain'} + ); + $xml = $ASTPP->fs_directory_xml_footer( xml => $xml ); + } } $ASTPP->debug( debug => $xml ); print $xml; Added: trunk/sql/astpp-2008-12-06.sql =================================================================== --- trunk/sql/astpp-2008-12-06.sql (rev 0) +++ trunk/sql/astpp-2008-12-06.sql 2008-12-06 22:37:02 UTC (rev 2217) @@ -0,0 +1,1316 @@ +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 ( +'decimalpoints_tax', '2','How many decimal points do we calculate taxes to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints_total', '2','How many decimal points do we calculate totals 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','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_post_nc','0','Do we post "free" items to the oscommerce invoice? 0=No 1=Yes',''); + +-- 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', ''); + +------ 3rd Party PBX Mods +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); + +-- +-- 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'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +Privilege VARCHAR(255) NULL, +Channel VARCHAR(255) NULL, +Cause VARCHAR(255) NULL, +Causetxt VARCHAR(255) NULL, +PeerStatus VARCHAR(255) NULL, +Peer VARCHAR(255) NULL, +Context VARCHAR(255) NULL, +Application VARCHAR(255) NULL, +AppData VARCHAR(255) NULL, +Priority VARCHAR(255) NULL, +Uniqueid VARCHAR(255) NULL, +Event VARCHAR(255) NULL, +State VARCHAR(255) NULL, +CallerIDName VARCHAR(255) NULL, +CallerID VARCHAR(255) NULL, +AstExtension VARCHAR(255) NULL, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + +CREATE TABLE sql_commands ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +sql TEXT NOT NULL default '', +comment TEXT NOT NULL default '', +timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`id`)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-12-06 18:35:57
|
Revision: 2216 http://astpp.svn.sourceforge.net/astpp/?rev=2216&view=rev Author: darrenkw Date: 2008-12-06 18:35:51 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Tidied the source code. Modified Paths: -------------- trunk/freeswitch/astpp-fs-xml.pl Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2008-12-03 06:14:49 UTC (rev 2215) +++ trunk/freeswitch/astpp-fs-xml.pl 2008-12-06 18:35:51 UTC (rev 2216) @@ -18,7 +18,8 @@ use CGI qw/:standard Vars/; use ASTPP; use strict; -use vars qw($params $ASTPP @output $config $freeswitch_db $astpp_db $verbosity ); +use vars + qw($params $ASTPP @output $config $freeswitch_db $astpp_db $verbosity ); use Locale::gettext_pp qw(:locale_h); require "/usr/local/astpp/astpp-common.pl"; $ENV{LANGUAGE} = "en"; # de, es, br - whatever @@ -26,11 +27,10 @@ bindtextdomain( "astpp", "/usr/local/share/locale" ); textdomain("astpp"); $verbosity = 2; -@output = ("STDERR"); -$ASTPP = ASTPP->new; -$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. +@output = ("STDERR"); +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. - sub initialize() { $config = &load_config(); $astpp_db = &connect_db( $config, @output ); @@ -42,161 +42,227 @@ ################# Programs start here ####################################### &initialize; -my ( $xml, $maxlength, $maxmins,$callstatus ); +my ( $xml, $maxlength, $maxmins, $callstatus ); foreach my $param ( param() ) { $params->{$param} = param($param); $ASTPP->debug( debug => "$param $params->{$param}" ); } -$xml = header(-type => 'text/plain'); +$xml = header( -type => 'text/plain' ); -$ASTPP->debug( debug => "Destination = $params->{'Caller-Destination-Number'}"); +$ASTPP->debug( + debug => "Destination = $params->{'Caller-Destination-Number'}" ); -if ($params->{section} eq "dialplan") { -$xml = $ASTPP->fs_dialplan_xml_header( xml => $xml, destination_number => $params->{'Caller-Destination-Number'}); +if ( $params->{section} eq "dialplan" ) { + $xml = $ASTPP->fs_dialplan_xml_header( + xml => $xml, + destination_number => $params->{'Caller-Destination-Number'} + ); -if (!$params->{variable_accountcode}) { -# First we strip off X digits to see if this account is prepending numbers -# as authentications - $ASTPP->debug( debug => "Checking CC Number: " . $params->{'Caller-Destination-Number'}); - my $cc = substr( $params->{'Caller-Destination-Number'}, 0, $config->{cardlength} ); - my $sql = $astpp_db->prepare("SELECT number FROM accounts WHERE cc = $cc"); - $sql->execute; - my $record = $sql->fetchrow_hashref; - $sql->finish; - $params->{variable_accountcode} = $record->{cardnum} if ($record->{cardnum}); -} -if (!$params->{variable_accountcode}) { - $ASTPP->debug( debug => "Checking IP Address:" . $params->{network_addr}); - my $ip_data = $ASTPP->ip_address_authenticate( ip_address => $params->{network_addr}, destination => $params->{'Caller-Destination-Number'}); - if ($ip_data) { - $params->{variable_accountcode} = $ip_data->{account}; - $params->{'Caller-Destination-Number'} =~ s/$ip_data->{prefix}//g; - } -} + if ( !$params->{variable_accountcode} ) { -$ASTPP->debug( debug => "$params->{variable_accountcode}, $params->{'Caller-Destination-Number'}"); + # First we strip off X digits to see if this account is prepending numbers + # as authentications + $ASTPP->debug( debug => "Checking CC Number: " + . $params->{'Caller-Destination-Number'} ); + my $cc = substr( $params->{'Caller-Destination-Number'}, + 0, $config->{cardlength} ); + my $sql = + $astpp_db->prepare("SELECT number FROM accounts WHERE cc = $cc"); + $sql->execute; + my $record = $sql->fetchrow_hashref; + $sql->finish; + $params->{variable_accountcode} = $record->{cardnum} + if ( $record->{cardnum} ); + } + if ( !$params->{variable_accountcode} ) { + $ASTPP->debug( + debug => "Checking IP Address:" . $params->{network_addr} ); + my $ip_data = $ASTPP->ip_address_authenticate( + ip_address => $params->{network_addr}, + destination => $params->{'Caller-Destination-Number'} + ); + if ($ip_data) { + $params->{variable_accountcode} = $ip_data->{account}; + $params->{'Caller-Destination-Number'} =~ s/$ip_data->{prefix}//g; + } + } -my $carddata = &get_account( $astpp_db, $params->{variable_accountcode} ); # Fetch all the account info from the db. + $ASTPP->debug( debug => +"$params->{variable_accountcode}, $params->{'Caller-Destination-Number'}" + ); -if ( !$carddata->{number} ) { # Check to see if the account exists. If not then exit. - $ASTPP->debug( debug => "CALLSTATUS 2"); - $ASTPP->debug( debug =>"CANNOT RETRIEVE CARD"); - $xml .= "<action application=\"reject\" data=\"CANNOT RETRIEVE ACCOUNT\"/>\n"; - $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); - print $xml; - exit(0); -} + my $carddata = + &get_account( $astpp_db, $params->{variable_accountcode} ) + ; # Fetch all the account info from the db. -if ($carddata->{dialed_modify}) { - my @regexs = split(m/,/m, $carddata->{dialed_modify}); + if ( !$carddata->{number} ) + { # Check to see if the account exists. If not then exit. + $ASTPP->debug( debug => "CALLSTATUS 2" ); + $ASTPP->debug( debug => "CANNOT RETRIEVE CARD" ); + $xml .= + "<action application=\"reject\" data=\"CANNOT RETRIEVE ACCOUNT\"/>\n"; + $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); + print $xml; + exit(0); + } + + if ( $carddata->{dialed_modify} ) { + my @regexs = split( m/,/m, $carddata->{dialed_modify} ); foreach my $regex (@regexs) { - $regex =~ s/"//g; #Strip off quotation marks - my ($grab,$replace) = split(m!/!i, $regex); # This will split the variable into a "grab" and "replace" as needed - $ASTPP->debug( debug => "Grab: $grab"); - $ASTPP->debug( debug => "Replacement: $replace"); - $ASTPP->debug( debug => "Phone Before: $params->{'Caller-Destination-Number'}"); - $$params->{'Caller-Destination-Number'} =~ s/$grab/$replace/is; - $ASTPP->debug( debug => "Phone After: $params->{'Caller-Destination-Number'}" ); + $regex =~ s/"//g; #Strip off quotation marks + my ( $grab, $replace ) = split( m!/!i, $regex ) + ; # This will split the variable into a "grab" and "replace" as needed + $ASTPP->debug( debug => "Grab: $grab" ); + $ASTPP->debug( debug => "Replacement: $replace" ); + $ASTPP->debug( debug => + "Phone Before: $params->{'Caller-Destination-Number'}" ); + $$params->{'Caller-Destination-Number'} =~ s/$grab/$replace/is; + $ASTPP->debug( debug => + "Phone After: $params->{'Caller-Destination-Number'}" ); } } -$ASTPP->debug( debug => "FINDING LIMIT FOR: " . $carddata->{number}); -($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $params->{'Caller-Destination-Number'}); -my $routeinfo = &get_route( $astpp_db, $config, $params->{'Caller-Destination-Number'}, $carddata->{pricelist},$carddata ); + $ASTPP->debug( debug => "FINDING LIMIT FOR: " . $carddata->{number} ); + ( $callstatus, $maxlength ) = + &max_length( $astpp_db, $config, $carddata, + $params->{'Caller-Destination-Number'} ); + my $routeinfo = &get_route( + $astpp_db, $config, + $params->{'Caller-Destination-Number'}, + $carddata->{pricelist}, $carddata + ); -$ASTPP->debug( debug => "Minimum Charge on call = " . $routeinfo->{cost}); -my $minimumcharge = $routeinfo->{cost}; -my @reseller_list; -$ASTPP->debug( debug => "CALLSTATUS: $callstatus MAX_LENGTH: $maxlength"); -while ( $carddata->{reseller} && $maxlength > 1 && $callstatus == 1) { - $ASTPP->debug( debug => "FINDING LIMIT FOR: $carddata->{reseller}"); - $carddata = &get_account( $astpp_db, $carddata->{reseller} ); - push @reseller_list, $carddata->{number}; - $ASTPP->debug( debug => "ADDING $carddata->{number} to the list of resellers for this account"); - my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $params->{'Caller-Destination-Number'}); - my $routeinfo = &get_route( $astpp_db, $config, $params->{'Caller-Destination-Number'}, $carddata->{pricelist},$carddata ); - if ($resellercallstatus != 1) { - $carddata->{reseller} = ""; - $callstatus = $resellercallstatus; - } elsif ($resellermaxlength < $maxlength) { - $maxlength = $resellermaxlength; - } - $ASTPP->debug( debug => "Reseller cost = $routeinfo->{cost} and minimum charge is $minimumcharge"); - if ($resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) { - $ASTPP->debug( debug => "Reseller call is priced too cheap! Call being barred!"); - $xml .= "<action application=\"reject\" data=\"Reseller call is priced too cheap! Call being barred!\"/>\n"; - $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); - print $xml; - exit(0); - } - $ASTPP->debug( debug => "RESELLER Max Length: $resellermaxlength"); - $ASTPP->debug( debug => "RESELLER Call Status: $resellercallstatus"); -} + $ASTPP->debug( debug => "Minimum Charge on call = " . $routeinfo->{cost} ); + my $minimumcharge = $routeinfo->{cost}; + my @reseller_list; + $ASTPP->debug( debug => "CALLSTATUS: $callstatus MAX_LENGTH: $maxlength" ); + while ( $carddata->{reseller} && $maxlength > 1 && $callstatus == 1 ) { + $ASTPP->debug( debug => "FINDING LIMIT FOR: $carddata->{reseller}" ); + $carddata = &get_account( $astpp_db, $carddata->{reseller} ); + push @reseller_list, $carddata->{number}; + $ASTPP->debug( debug => +"ADDING $carddata->{number} to the list of resellers for this account" + ); + my ( $resellercallstatus, $resellermaxlength ) = + &max_length( $astpp_db, $config, $carddata, + $params->{'Caller-Destination-Number'} ); + my $routeinfo = &get_route( + $astpp_db, $config, + $params->{'Caller-Destination-Number'}, + $carddata->{pricelist}, $carddata + ); + if ( $resellercallstatus != 1 ) { + $carddata->{reseller} = ""; + $callstatus = $resellercallstatus; + } + elsif ( $resellermaxlength < $maxlength ) { + $maxlength = $resellermaxlength; + } + $ASTPP->debug( debug => +"Reseller cost = $routeinfo->{cost} and minimum charge is $minimumcharge" + ); + if ( $resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) { + $ASTPP->debug( debug => + "Reseller call is priced too cheap! Call being barred!" ); + $xml .= +"<action application=\"reject\" data=\"Reseller call is priced too cheap! Call being barred!\"/>\n"; + $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); + print $xml; + exit(0); + } + $ASTPP->debug( debug => "RESELLER Max Length: $resellermaxlength" ); + $ASTPP->debug( debug => "RESELLER Call Status: $resellercallstatus" ); + } -if ($config->{debug} == 1) { - $ASTPP->debug( debug => "PRINTING LIST OF RESELLERS FOR THIS ACCOUNT" ); - foreach my $reseller (@reseller_list) { - $ASTPP->debugb( debug => "RESELLER: $reseller" ); - } -} + if ( $config->{debug} == 1 ) { + $ASTPP->debug( debug => "PRINTING LIST OF RESELLERS FOR THIS ACCOUNT" ); + foreach my $reseller (@reseller_list) { + $ASTPP->debugb( debug => "RESELLER: $reseller" ); + } + } -$ASTPP->debug( "Max Call Length: $maxlength minutes" ); -$ASTPP->debug( "Call Status: $callstatus" ); + $ASTPP->debug("Max Call Length: $maxlength minutes"); + $ASTPP->debug("Call Status: $callstatus"); -if ( $maxlength <= 1 ) { - $ASTPP->debug( debug => "NOT ENOUGH CREDIT" ); - $xml .= "<action application=\"reject\" data=\"NOT ENOUGH CREDIT\"/>\n"; - $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); - print $xml; - exit(0); -} + if ( $maxlength <= 1 ) { + $ASTPP->debug( debug => "NOT ENOUGH CREDIT" ); + $xml .= "<action application=\"reject\" data=\"NOT ENOUGH CREDIT\"/>\n"; + $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); + print $xml; + exit(0); + } -$xml = $ASTPP->fs_dialplan_xml_timelimit( xml => $xml, max_length => $maxlength); + $xml = $ASTPP->fs_dialplan_xml_timelimit( + xml => $xml, + max_length => $maxlength + ); + # Set the timelimit as well as other variables which are needed in the dialplan. -my $timelimit = "L(" . sprintf( "%.0f", $maxlength * 60 * 1000 ) . ":60000:30000)"; + my $timelimit = + "L(" . sprintf( "%.0f", $maxlength * 60 * 1000 ) . ":60000:30000)"; -$ASTPP->debug( debug => "Looking for outbound Route" ); -my $routeinfo = &get_route($astpp_db,$config,$params->{'Caller-Destination-Number'},$carddata->{pricelist},$carddata); -# Get the list of routes for the phone number. -my @outboundroutes = &get_outbound_routes( $astpp_db, $params->{'Caller-Destination-Number'},$carddata,$routeinfo, @reseller_list ); -foreach my $route (@outboundroutes) { - $ASTPP->debug( debug => "$route->{trunk}: cost $route->{cost}\t $route->{pattern}" ); - if ($route->{cost} > $routeinfo->{cost}) { - $ASTPP->debug( debug => "$route->{trunk}: $route->{cost} > $routeinfo->{cost}, skipping" ); - } else { - $xml .= $ASTPP->fs_dialplan_xml_bridge( destination_number => $params->{'Caller-Destination-Number'}, - route_prepend => $route->{prepend}, - trunk_name => $route->{trunk}); - } + $ASTPP->debug( debug => "Looking for outbound Route" ); + my $routeinfo = &get_route( + $astpp_db, $config, + $params->{'Caller-Destination-Number'}, + $carddata->{pricelist}, $carddata + ); + + # Get the list of routes for the phone number. + my @outboundroutes = + &get_outbound_routes( $astpp_db, $params->{'Caller-Destination-Number'}, + $carddata, $routeinfo, @reseller_list ); + foreach my $route (@outboundroutes) { + $ASTPP->debug( debug => + "$route->{trunk}: cost $route->{cost}\t $route->{pattern}" ); + if ( $route->{cost} > $routeinfo->{cost} ) { + $ASTPP->debug( debug => +"$route->{trunk}: $route->{cost} > $routeinfo->{cost}, skipping" + ); + } + else { + $xml .= $ASTPP->fs_dialplan_xml_bridge( + destination_number => $params->{'Caller-Destination-Number'}, + route_prepend => $route->{prepend}, + trunk_name => $route->{trunk} + ); + } + } + $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); } -$xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); -} elsif ($params->{section} eq "directory") { -#hostname darren-laptop -#section directory -#tag_name domain -#key_name name -#key_value 192.168.2.119 -#action sip_auth -#sip_profile internal -#sip_user_agent Zoiper rev.1118 -#sip_auth_username 1000 -#sip_auth_realm 192.168.2.119 -#sip_auth_nonce 83005e62-7e13-11dd-9eb1-25560b0691a8 -#sip_auth_uri sip:192.168.2.119;transport=UDP -#sip_auth_qop auth -#sip_auth_cnonce a79169d2656f292a -#sip_auth_nc 00000001 -#sip_auth_response 4475154556879ec2017978f1347192a6 -#sip_auth_method REGISTER -#key id -#user 1000 -#domain 192.168.2.119 -#ip 192.168.2.119 +elsif ( $params->{section} eq "directory" ) { - $xml = $ASTPP->fs_directory_xml_header( xml => $xml); - $xml = $ASTPP->fs_directory_xml( xml => $xml, ip => $params->{'ip'},user=> $params->{'user'},domain=> $params->{'domain'}); - $xml = $ASTPP->fs_directory_xml_footer( xml => $xml); + #hostname darren-laptop + #section directory + #tag_name domain + #key_name name + #key_value 192.168.2.119 + #action sip_auth + #sip_profile internal + #sip_user_agent Zoiper rev.1118 + #sip_auth_username 1000 + #sip_auth_realm 192.168.2.119 + #sip_auth_nonce 83005e62-7e13-11dd-9eb1-25560b0691a8 + #sip_auth_uri sip:192.168.2.119;transport=UDP + #sip_auth_qop auth + #sip_auth_cnonce a79169d2656f292a + #sip_auth_nc 00000001 + #sip_auth_response 4475154556879ec2017978f1347192a6 + #sip_auth_method REGISTER + #key id + #user 1000 + #domain 192.168.2.119 + #ip 192.168.2.119 + + $xml = $ASTPP->fs_directory_xml_header( xml => $xml ); + $xml = $ASTPP->fs_directory_xml( + xml => $xml, + ip => $params->{'ip'}, + user => $params->{'user'}, + domain => $params->{'domain'} + ); + $xml = $ASTPP->fs_directory_xml_footer( xml => $xml ); } -$ASTPP->debug( debug => $xml); +$ASTPP->debug( debug => $xml ); print $xml; exit(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-12-03 06:15:00
|
Revision: 2215 http://astpp.svn.sourceforge.net/astpp/?rev=2215&view=rev Author: darrenkw Date: 2008-12-03 06:14:49 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Fixed Thirdlane DID billing code. Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-12-02 03:35:36 UTC (rev 2214) +++ trunk/astpp-common.pl 2008-12-03 06:14:49 UTC (rev 2215) @@ -4128,6 +4128,17 @@ # $cdrinfo->{'cost'} = 'rating'; # } if ( $cdrinfo->{accountcode} ) { + if ($config->{thirdlane_mods} == 1 && $cdrinfo->{accountcode} =~ m/.\d\d\d-IN/) { + print STDERR "Call belongs to a Thirdlane(tm) DID.\n"; + my ($did,$record); + ($did = $cdrinfo->{accountcode}) =~ s/-IN//g; + print STDERR "DID: $did \n"; + $record = &get_did($astpp_db,$did); + $cdrinfo->{userfield} = $cdrinfo->{accountcode}; + $cdrinfo->{accountcode} = $record->{account}; + $cdrinfo->{dst} = $did; + } + my $carddata = &get_account( $astpp_db, $cdrinfo->{accountcode} ); if ($carddata->{number}) { if ( $cdrinfo->{lastapp} eq "MeetMe" ) { # There is an issue with calls that come out of meetmee This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-12-02 03:35:42
|
Revision: 2214 http://astpp.svn.sourceforge.net/astpp/?rev=2214&view=rev Author: darrenkw Date: 2008-12-02 03:35:36 +0000 (Tue, 02 Dec 2008) Log Message: ----------- Repair the thirdlane DID billing handling. Modified Paths: -------------- trunk/astpp-common.pl trunk/contrib/auto_dialer/aleph-autocall.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-12-02 02:39:15 UTC (rev 2213) +++ trunk/astpp-common.pl 2008-12-02 03:35:36 UTC (rev 2214) @@ -1732,7 +1732,7 @@ } elsif ($config->{thirdlane_mods} == 1 && $type =~ m/.\d\d\d-IN/) { print STDERR "Call belongs to a Thirdlane(tm) DID.\n"; - $destination = $type =~ s/-IN//g; + ($destination = $type) =~ s/-IN//g; print STDERR "Destination: $destination \n"; $record = &get_did_reseller($astpp_db,$destination,$carddata->{reseller}) if $carddata->{reseller} ne ""; $record = &get_did($astpp_db,$destination) if $carddata->{reseller} eq ""; @@ -4116,17 +4116,17 @@ print STDERR gettext("Processing Uniqueid: ") . $uniqueid . "\n"; $cdrinfo = ($vars) ? $vars : &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ); my $savedcdrinfo = $cdrinfo; - if(!$vars) { - my $tmp = "UPDATE $cdr_table SET cost = 'rating' WHERE uniqueid = " - . $cdr_db->quote($uniqueid) - . " AND cost = 'none'" - . " AND dst = " - . $cdr_db->quote($cdrinfo->{dst}) - . " LIMIT 1"; - $cdr_db->do($tmp); - } else { - $cdrinfo->{'cost'} = 'rating'; - } +# if(!$vars) { +# my $tmp = "UPDATE $cdr_table SET cost = 'rating' WHERE uniqueid = " +# . $cdr_db->quote($uniqueid) +# . " AND cost = 'none'" +# . " AND dst = " +# . $cdr_db->quote($cdrinfo->{dst}) +# . " LIMIT 1"; +# $cdr_db->do($tmp); +# } else { +# $cdrinfo->{'cost'} = 'rating'; +# } if ( $cdrinfo->{accountcode} ) { my $carddata = &get_account( $astpp_db, $cdrinfo->{accountcode} ); if ($carddata->{number}) { @@ -4145,7 +4145,7 @@ print STDERR "----------------------\n"; } elsif ( $cdrinfo->{accountcode} ) { - $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars); + $status = &rating( $astpp_db, $cdr_db,$cdr_table, $config, $cdrinfo, $carddata, $vars); $cdrinfo = &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ) if !$vars; if ( $status == 1 ) { my $previous_account = $carddata->{number}; @@ -4153,7 +4153,7 @@ $cdrinfo = &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ) if !$vars; print STDERR "Charge $uniqueid to $carddata->{reseller}" if $config->{debug} == 1; $carddata = &get_account( $astpp_db, $carddata->{reseller} ); - $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars); + $status = &rating( $astpp_db, $cdr_db, $cdr_table,$config, $cdrinfo, $carddata, $vars); my $tmp = "SELECT id FROM cdrs WHERE uniqueid = '" . $uniqueid . "' AND cardnum = '" . $previous_account . "' LIMIT 1"; print STDERR "$tmp\n" if $config->{debug} == 1; Modified: trunk/contrib/auto_dialer/aleph-autocall.pl =================================================================== --- trunk/contrib/auto_dialer/aleph-autocall.pl 2008-12-02 02:39:15 UTC (rev 2213) +++ trunk/contrib/auto_dialer/aleph-autocall.pl 2008-12-02 03:35:36 UTC (rev 2214) @@ -125,22 +125,20 @@ } sub perform_callout() { - my ($number) = @_; - my $out = new Asterisk::Outgoing; - my $channel = "Local\/" . $number->{number} . "\@$config->{destcontext}"; - $out->setvariable( 'Channel', $channel ); - $out->setvariable( 'MaxRetries', $config->{maxretries} ); - $out->setvariable( 'RetryTime', 60 ); - $out->setvariable( 'WaitTime', 60 ); -# $out->setvariable( "context", $config->{context} ); -# $out->setvariable( "extension", $number ); + my ($number) = @_; + my $out = new Asterisk::Outgoing; + my $channel = "Local\/" . $number->{number} . "\@$config->{destcontext}"; + $out->setvariable( 'Channel', $channel ); + $out->setvariable( 'MaxRetries', $config->{maxretries} ); + $out->setvariable( 'RetryTime', 60 ); + $out->setvariable( 'WaitTime', 60 ); $out->setvariable( 'Application', "DeadAGI"); $out->setvariable( 'Data', "aleph-aac.agi|" . $number->{id}); $out->setvariable( "CallerID", "<$number->{clidname}> $number->{clidnumber}" ); - $out->setvariable( "Account", "$number->{accountcode}" ); - $out->outtime( time() + 15 ); - $out->create_outgoing; + $out->setvariable( "Account", "$number->{accountcode}" ); + $out->outtime( time() + 15 ); + $out->create_outgoing; print STDERR "Created Call to: $number->{number}\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |