Diff
Added: freeswitch/trunk/contrib/intralanman/PHP/fs_curl/fs_cdr.php (0 => 14914)
--- freeswitch/trunk/contrib/intralanman/PHP/fs_curl/fs_cdr.php (rev 0)
+++ freeswitch/trunk/contrib/intralanman/PHP/fs_curl/fs_cdr.php 2009-09-18 04:53:14 UTC (rev 14914)
@@ -0,0 +1,103 @@
+<?php
+/**
+ * @package FS_CURL
+ * fs_cdr.php
+ */
+if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
+ header('Location: index.php');
+}
+
+/**
+ * @package FS_CURL
+ * @license BSD
+ * @author Raymond Chandler (intralanman) <intralanman@gmail.com>
+ * @version 0.1
+ * Class for inserting xml CDR records
+ * @return object
+ */
+class fs_cdr extends fs_curl {
+/**
+ * This variable will hold the XML CDR string
+ * @var string
+ */
+ public $cdr;
+ /**
+ * This object is the objectified representation of the XML CDR
+ * @var XMLSimple Object
+ */
+ public $xml_cdr;
+
+ /**
+ * This array will hold the db field and their corresponding value
+ * @var array
+ */
+ public $values = array();
+
+ /**
+ * This array maps the database field names to XMLSimple paths
+ * @var array
+ */
+ public $fields = array(
+ 'caller_id_name' => '$this->xml_cdr->callflow[0]->caller_profile->caller_id_name',
+ 'caller_id_number' => '$this->xml_cdr->callflow[0]->caller_profile->caller_id_number',
+ 'destination_number' => '$this->xml_cdr->callflow[0]->caller_profile->destination_number',
+ 'context' => '$this->xml_cdr->callflow[0]->caller_profile->context',
+ 'start_stamp' => 'urldecode($this->xml_cdr->variables->start_stamp)',
+ 'answer_stamp' => 'urldecode($this->xml_cdr->variables->answer_stamp)',
+ 'end_stamp' => 'urldecode($this->xml_cdr->variables->end_stamp)',
+ 'duration' => '$this->xml_cdr->variables->duration',
+ 'billsec' => '$this->xml_cdr->variables->billsec',
+ 'hangup_cause' => '$this->xml_cdr->variables->hangup_cause',
+ 'uuid' => '$this->xml_cdr->callflow[0]->caller_profile->uuid',
+ 'bleg_uuid' => '$this->xml_cdr->callflow[0]->caller_profile->bleg_uuid',
+ 'accountcode' => '$this->xml_cdr->variables->accountcode',
+ 'read_codec' => '$this->xml_cdr->variables->read_codec',
+ 'write_codec' => '$this->xml_cdr->variables->write_codec'
+ );
+
+ /**
+ * This is where we instantiate our parent and set up our CDR object
+ */
+ public function fs_cdr() {
+ $this->fs_curl();
+ $this->cdr = $this->request['cdr'];
+ $this->xml_cdr = new SimpleXMLElement($this->cdr);
+ }
+
+ /**
+ * This is where we run the bulk of our logic through other methods
+ */
+ public function main() {
+ $this->set_record_values();
+ $this->insert_cdr();
+ }
+
+ /**
+ * This method will take the db fields and paths defined above and
+ * set the values array to be used for the insert
+ */
+ public function set_record_values() {
+ foreach ($this->fields as $field => $run) {
+ eval("\$str = $run;");
+ $this->values["$field"] = "'$str'";
+ $this->debug($str);
+ }
+ $this->debug(print_r($this->values, true));
+ print_r($this->values);
+ }
+
+ /**
+ * finally do the insert of the CDR
+ */
+ public function insert_cdr() {
+ $query = sprintf(
+ "INSERT INTO cdr (%s) VALUES (%s);",
+ join(',', array_keys($this->values)), join(',', $this->values)
+ );
+ $this->debug($query);
+ $this->db->exec($query);
+ }
+
+}
+
+
Modified: freeswitch/trunk/contrib/intralanman/PHP/fs_curl/fs_curl.php (14913 => 14914)
--- freeswitch/trunk/contrib/intralanman/PHP/fs_curl/fs_curl.php 2009-09-17 23:30:17 UTC (rev 14913)
+++ freeswitch/trunk/contrib/intralanman/PHP/fs_curl/fs_curl.php 2009-09-18 04:53:14 UTC (rev 14914)
@@ -166,7 +166,7 @@
for ($i = 0; $i < $comment_count; $i++) {
if (array_key_exists($i, $comments)) {
if (!is_array($comments[$i])) {
- $xml_obj -> writeComment($comments[$i]);
+ $xml_obj -> writeComment(" " . $comments[$i] . " ");
} else {
$this -> comments2xml($xml_obj, $comments[$i], $space_pad + 2);
}
@@ -269,7 +269,7 @@
if ($no == E_STRICT) {
return true;
}
- $file = ereg_replace('\.(inc|php)$', '', $file);
+ $file = preg_replace('/\.(inc|php)$/', '', $file);
$this -> comment(basename($file) . ":$line - $no:$str");
switch ($no) {
@@ -320,7 +320,7 @@
syslog(LOG_NOTICE, $debug_str);
break;
case 1:
- $debug_str = preg_replace('/-/', ' - ', $debug_str);
+ $debug_str = preg_replace('/--/', '- - ', $debug_str);
$this -> comment($debug_str);
break;
case 2:
Modified: freeswitch/trunk/contrib/intralanman/PHP/fs_curl/fs_dialplan.php (14913 => 14914)
--- freeswitch/trunk/contrib/intralanman/PHP/fs_curl/fs_dialplan.php 2009-09-17 23:30:17 UTC (rev 14913)
+++ freeswitch/trunk/contrib/intralanman/PHP/fs_curl/fs_dialplan.php 2009-09-18 04:53:14 UTC (rev 14914)
@@ -66,7 +66,7 @@
}
if ($res -> numRows() == 1) {
$row = $res -> fetchRow();
- $this -> special_class_file = $row['class_file'];
+ $this -> special_class_file = sprintf('dialplans/%s', $row['class_file']);
return true;
} else {
return false;
Modified: freeswitch/trunk/contrib/intralanman/PHP/fs_curl/index.php (14913 => 14914)
--- freeswitch/trunk/contrib/intralanman/PHP/fs_curl/index.php 2009-09-17 23:30:17 UTC (rev 14913)
+++ freeswitch/trunk/contrib/intralanman/PHP/fs_curl/index.php 2009-09-18 04:53:14 UTC (rev 14914)
@@ -54,7 +54,12 @@
if (!is_array($_REQUEST)) {
trigger_error('$_REQUEST is not an array');
}
-$section = $_REQUEST['section'];
+
+if (array_key_exists('cdr', $_REQUEST)) {
+ $section = 'cdr';
+} else {
+ $section = $_REQUEST['section'];
+}
$section_file = sprintf('fs_%s.php', $section);
/**
* this include will differ based on the section that's passed
@@ -82,6 +87,9 @@
case 'directory':
$conf = new fs_directory();
break;
+ case 'cdr':
+ $conf = new fs_cdr();
+ break;
}
$conf -> debug('---- Start _REQUEST ----');
Modified: freeswitch/trunk/contrib/intralanman/PHP/fs_curl/sql/mysql-5.0-with-samples.sql (14913 => 14914)
--- freeswitch/trunk/contrib/intralanman/PHP/fs_curl/sql/mysql-5.0-with-samples.sql 2009-09-17 23:30:17 UTC (rev 14913)
+++ freeswitch/trunk/contrib/intralanman/PHP/fs_curl/sql/mysql-5.0-with-samples.sql 2009-09-18 04:53:14 UTC (rev 14914)
@@ -67,6 +67,32 @@
-- --------------------------------------------------------
--
+-- Table structure for table `cdr`
+--
+
+CREATE TABLE IF NOT EXISTS `cdr` (
+ `id` int(11) NOT NULL auto_increment,
+ `caller_id_name` varchar(255) NOT NULL default '',
+ `caller_id_number` varchar(255) NOT NULL default '',
+ `destination_number` varchar(255) NOT NULL default '',
+ `context` varchar(255) NOT NULL default '',
+ `start_stamp` varchar(255) NOT NULL default '',
+ `answer_stamp` varchar(255) NOT NULL default '',
+ `end_stamp` varchar(255) NOT NULL default '',
+ `duration` varchar(255) NOT NULL default '',
+ `billsec` varchar(255) NOT NULL default '',
+ `hangup_cause` varchar(255) NOT NULL default '',
+ `uuid` varchar(255) NOT NULL default '',
+ `bleg_uuid` varchar(255) NOT NULL default '',
+ `accountcode` varchar(255) NOT NULL default '',
+ `read_codec` varchar(255) NOT NULL default '',
+ `write_codec` varchar(255) NOT NULL default '',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uuid` (`uuid`)
+) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
-- Table structure for table `conference_advertise`
--
Modified: freeswitch/trunk/contrib/intralanman/PHP/fs_curl/sql/mysql-5.0.sql (14913 => 14914)
--- freeswitch/trunk/contrib/intralanman/PHP/fs_curl/sql/mysql-5.0.sql 2009-09-17 23:30:17 UTC (rev 14913)
+++ freeswitch/trunk/contrib/intralanman/PHP/fs_curl/sql/mysql-5.0.sql 2009-09-18 04:53:14 UTC (rev 14914)
@@ -59,6 +59,39 @@
-- --------------------------------------------------------
--
+-- Table structure for table `cdr`
+--
+
+DROP TABLE IF EXISTS `cdr`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `cdr` (
+ `id` int(11) NOT NULL auto_increment,
+ `caller_id_name` varchar(255) NOT NULL default '',
+ `caller_id_number` varchar(255) NOT NULL default '',
+ `destination_number` varchar(255) NOT NULL default '',
+ `context` varchar(255) NOT NULL default '',
+ `start_stamp` varchar(255) NOT NULL default '',
+ `answer_stamp` varchar(255) NOT NULL default '',
+ `end_stamp` varchar(255) NOT NULL default '',
+ `duration` varchar(255) NOT NULL default '',
+ `billsec` varchar(255) NOT NULL default '',
+ `hangup_cause` varchar(255) NOT NULL default '',
+ `uuid` varchar(255) NOT NULL default '',
+ `bleg_uuid` varchar(255) NOT NULL default '',
+ `accountcode` varchar(255) NOT NULL default '',
+ `read_codec` varchar(255) NOT NULL default '',
+ `write_codec` varchar(255) NOT NULL default '',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uuid` (`uuid`)
+) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+
+-- --------------------------------------------------------
+
+
+--
-- Table structure for table `conference_advertise`
--