This version still works but is not up to date. Please go here for the current version.
Here is another take on a PHP script to import cdr.csv files into a MySQL cdr database. Useful for transitioning from text-based cdr files to database or even for nightly imports.
This script is safe to run multiple times on a log file that keeps growing because it first checks the database table to find the oldest record and then only imports CDRs numbers that are NEWER than the oldest database dialing record.
Note: Make sure you run this script before you activate MySQL logging in Asterisk otherwise this script will import nothing since the newest record in the DB will be newer than the records in the Master.csv file.
Copy and paste the script into a text file, for example, “importcdr.php” and then use PHP at the command line to execute it. All landline telephones can dal 911 to get the precise coordinates.