Problem: writing the startingpoint of a phone before it is hanged up

Asterisk 1.4.13
Beronet BN4S0
Open-Suse 10.3

At the end of each phone call the “CALLDATE”, “SRC”, “DST” and many more variables are written into the database “asteriskcdrdb” in the table “cdr”.
But we want to write at the beginn of a phone call the “CALLDATE”, “SRC” and “DST” into a seperate table in the “asteriskcdrdb”-database.

Tries up until now:

  1. Changes at the graphical interface of FreePBX (no option found to do this)
  2. changes at the extensions.conf and extensions_additional.conf (these files are overwritten by FreePBX)
  3. Changes at the extensions_custom.conf (our script run, but the people could not phone any more)
  4. Changes at the extensions_override_freepbx.conf (we tried to rebuild the extensions.conf but there were over 150 goto’s)

Used script:
#!/usr/bin/php -q

<?php $pcname = "***"; $username = "***"; $pw = "***"; $calldate = $argv[1]; $src = $argv[2]; $dst = $argv[3]; $db = mysql_connect($pcname,$username,$pw); mysql_select_db("asteriskcdrdb"); if((strlen($src) != 3) || ((strlen($dst) != 3))) { mysql_query("INSERT INTO info(calldate,src,dst) VALUES('$calldate','$src','$dst')"); } mysql_close($db); ?>

Usage of Script:
exten => _.,1,AGI(writeinfo.agi|${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)}|${EXTEN}|${CALLERID(num)})