Howto:Is there any example code or simple scripts/programs in order to put call-information into an MySQL (or similiar) database in order to build CRM-alike solutions towards the MySQL DB?
Is there any example code or simple scripts/programs in order to put call-information into an MySQL (or similiar) database in order to build CRM-alike solutions towards the MySQL DB?
Sample PHP Script
The script cdr.php takes CDRs via HTTP GET requests and stores them in following files in the subfolder
- data/cdr_pbx.txt - PBX CDRs in text file
- data/cdr_gw.txt - Gateway CDRs in text file
- data/db_pbx.sq3 - PBX CDRs in SQLite DB
- data/db_gw.sq3 - Gateway CDRs in SQLite DB
Make sure subfolder
data exists and web server can write into this folder.
The script will create a local SQLite DB using PDO abstraction layer.
Make sure folowing extensions are enabled in php.ini:
You can easily switch to another DB like Postgres using other PDO extension.
To check the contents of the DB browse files
The PHP version used in this example is 5.2.17.
Sample Active Server Page
This is somewhat outdated pre-.Net ASP sample code. It may help to get the idea though
This example outlines the storage of CDRs using an ASP-enabled Web Service (tested with MS’s IIS5).
The application lives in the URL
/cdr. It will by default create logfiles named
cdrlog_date_srcip.txt in a subdirectory
/cdr. Thus, a logfile may be found e.g. on
The application is made up of 3 files, all located in
global.asa, initialises system parameter.
Cdrwrite.asp, actually writes the CDR entries to the log file
Cdrform.htm, sample HTML form to debug the installation
- copy all files into your web servers
- create a subdirectory called
- make sure your web server processes ASP applications in the
- Point your browser to the server and open
/cdr/cdrform.htm. You should see a form that allows to submit Time and Event
- Fill in the fields and submit the form. You should see something like
Event: A:Disc CDR LOG Entry saved to d:\inetpub\wwwroot\cdr\CDR\cdrlog_20010208_127.0.0.1.txt Tag: time = 100 Tag: event = A:Disc CDR ENTRY(082829 time='100' event='A:Disc' ) Done.
- open your Gateways configuration UI
- set CDR-Logging parameters to log to your web server, using method HTTP, URL
It has been reported that later .ASP platforms will not accept the HTTP GET requests used to send the CDR data from the PBX to the .ASP Web server. To work around this issue, it has been reported that the following must be done:
- set the web services config as follows
- on the page that receives the CDR data, disable request verification
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="log.aspx.cs" Inherits="innoLog.Log" ValidateRequest="false" %>
- Download the complete file package of scripts and files described in this article.