REQUIREMENTS
------------

Minimum software versions:

PHP version 5.2 or higher
MYSQL version 5.0 or higher

In Centos 5 systems, be sure to install php-pecl-zip package:

yum install php-pecl-zip


INSTALL
-------

1) Download the software and place the tarball into /usr/src or some
other location on your drive (outside your web root). 

#> cd /usr/src
#> wget http://download.asternic.net/asternic-cdr-1.0.0.tgz

2) Extract the tarball file:

#> tar zxvf asternic-cdr-1.0.0.tgz

3) Change to the extraction directory

#> cd asternic-cdr-1.0.0

4) Install with make:

#> make

This process will work in most Asterisk distributions like Elastix
or FreePBX. If you have issues or run a vanilla Asterisk install, 
review the next section for a manual installation process.

5) Point your browser to:

http://your.server/cdrstats

6) Enter the activation code and chose any registration name you
want to identify the license.


To load the reports. The default user/password to login is the same
admin you have in FreePBX. If you do not use FreePBX, then try with
user 'admin', password 'admin'.

NOTE
----
You do not need to do anything else, skip the next sections, they
are for reference and for vanilla asterisk installations where the
'make' command might fail.


MANUAL INSTALL
--------------

1) Untar de file (you already done that). It is best to extract
the file OUTSIDE your web root.

2) Populate the mysql tables. In many Asterisk distribtuions the
database name used for storing the cdr table is named "asteriskcdrdb"
so we will follow that example:

   #> mysql -uroot -p asteriskcdrdb < ./sql/db.sql

3) Copy or move /html to a suitable place on your web root

   #> mv html /var/www/html/cdr-reports

4) To activate the software, the destination directory must be owned
by the same user apache is running as. So you might need to issue
the appropiate chown command, for example, in FreePBX based distributions
you might need to do:

   #> chown asterisk.asterisk /var/www/html/cdr-reports
   #> chown asterisk.asterisk /var/www/html/cdr-reports/* -R

Another option is to create an empty license file and give 666 permissions
to it. For example:

   #> touch /var/www/html/cdr-reports/cdrlicense.php
   #> chmod 666 /var/www/html/cdr-reports/cdrlicense.php


IONCUBE LOADER
--------------

Asternic CDR Reports requires the free ioncube loaders for Php. You can 
get them from : http://www.ioncube.com/loaders.php. Be sure to download 
the correct tarball for your platform. 

Installation is quite simple: extract the downloaded ioncube tarball, 
it will create an ioncube directory with all the loaders for different 
php versions, move that directory to its permanent location (we 
recommend to install them in /usr/local with the command:

For 32 bits systems:

 #> wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
 #> tar zxvf ioncube_loaders_lin_x86.tar.gz
 #> mv ioncube /usr/local

For 64 bits systems:

 #> wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
 #> tar zxvf ioncube_loaders_lin_x86.tar.gz
 #> mv ioncube /usr/local

In a centos system you can write a special ini file to load the extension
with this command:

 #> echo "zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.1.so" >/etc/php.d/ioncube.ini

If you do not use Centos, you can modify the php.ini file, (but please do 
not do it if you performed the above actions or you will have problems with 
duplicate loading of the library, which causes segfaults and strange errors. 
So, if you did not create the ioncube.ini file as told above, you can add 
the following line to php.ini, (usually located in the /etc directory):

  !! ONLY ADD THIS IF YOU DID NOT RUN THE PREVIOUS COMMAND !!
  zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.1.so

Where 5.1 is your PHP version. You will have to select the correct file 
depending on your PHP version, that you can find out by running in the 
command line the command "php -v"


ACTIVATING THE LICENSE
----------------------

After the installation, you need to activate the software. The license
is tied to the MAC address of your server network interface. You will 
also need internet access from the server in order to activate it.

If you do not have an internet connection, contact us to do an offline
activation.

Once you load the web page for the first time, it will prompt you for
the activation code (You have received that code via email), and a Licensee
Name. The Licensee Name can be anything you want, it will be displayed on 
the footer of every report.

Once you enter both fields, you can press the "Generate Request" button.
When you do that it will contact our registration servers, validate your
code, send the license request and retrieve the final license. If all goes
well, you will be prompted with a login box. The default admin user is "admin"
with password "admin".

If you get an error, you will have to contact us. If your server crashes or if
you need to move licenses around, you will also have to contact us. 

The license is stored in the cdrlicense.php file on the same directory as 
the reports themselves. Be sure to back the directory up just in case.


ACCESING CDR REPORTS 
--------------------

Point your browser to the new url. If you followed this guide it would be

http://your.server/cdr-reports

The default user is "admin", password "admin". If you have a session already
opened with Elastix or a FreePBX based distro, the software should detect
that session and allow the login without prompting for user/pass.

If you use FreePBX, the application will use the same users/passwords you have
defined in FreePBX itself, unless you deactivate it in config.php setting:

define('USE_BACKEND_AUTH',false);

With the above set, you can use the built in user authentication/authorization
system.


VANILLA ASTERISK INSTALLATIONS
------------------------------

When using vanilla Asterisk you will need to set the proper mysql values
in config.php. Also, the reports will read the file /etc/asterisk/sip.conf
and look there for valid extensions. Any sip peer listed there with a callerid
set will be treated like an extension, anything else found on the CDRs will
be considered a trunk. The file functions-astdb.php can be modified to suite
your particular details.


FINAL CONFIGURATION
-------------------

IMPORTANT! You might want to change the user/password from the default
values. In order to do so, log into the CDR reports application  as admin
and go to Setup/Users to modify the password.

