Author: intralanman Date: Fri Jun 6 13:45:47 2008 New Revision: 8782 Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/console.conf.php freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php Log: added a couple of bug fixes to the dialplan_importer and fs_dialplan so that there's no longer a requirement for continue to be numeric. this implies changing the .sql so that ext_continue is no longer an int field. Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/console.conf.php ============================================================================== --- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/console.conf.php (original) +++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/console.conf.php Fri Jun 6 13:45:47 2008 @@ -30,21 +30,36 @@ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php')); $this -> xmlw -> writeAttribute('description', 'Console configuration'); + $this -> xmlw -> startElement('mappings'); + + $this -> xmlw -> startElement('map'); + $this -> xmlw -> writeAttribute('name', 'all'); + $this -> xmlw -> writeAttribute('value', 'notice,warning,error,crit,alert,info,debug'); + $this -> xmlw -> endElement(); + + $this -> xmlw -> endElement(); + + + + $this -> xmlw -> startElement('settings'); - $this -> xmlw -> startElement('param'); + + $this -> xmlw -> startElement('param'); $this -> xmlw -> writeAttribute('name', 'colorize'); $this -> xmlw -> writeAttribute('value', 'true'); - $this -> xmlw -> endElement(); - $this -> xmlw -> endElement(); + $this -> xmlw -> endElement(); + + $this -> xmlw -> startElement('param'); + $this -> xmlw -> writeAttribute('name', 'loglevel'); + $this -> xmlw -> writeAttribute('value', 'debug'); + $this -> xmlw -> endElement(); + + $this -> xmlw -> endElement(); + + - $this -> xmlw -> startElement('mappings'); - $this -> xmlw -> startElement('map'); - $this -> xmlw -> writeAttribute('name', 'all'); - $this -> xmlw -> writeAttribute('value', 'notice,warning,error,crit,alert'); - $this -> xmlw -> endElement(); - $this -> xmlw -> endElement(); $this -> xmlw -> endElement(); } } -?> \ No newline at end of file +?> Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php ============================================================================== --- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php (original) +++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php Fri Jun 6 13:45:47 2008 @@ -39,12 +39,13 @@ * @return null */ function run_query($db, $query) { + syslog(LOG_INFO, $query); $affected = $db -> exec($query); if (MDB2::isError($affected)) { if (!defined('UNSUCCESSFUL_QUERY')) { define('UNSUCCESSFUL_QUERY', true); } - echo "$query\n"; + echo "$query<br>\n"; echo $affected -> getMessage() . "\n"; } } @@ -96,7 +97,7 @@ $xml_file = $_FILES['file']['tmp_name']; move_uploaded_file($tmp_file, $xml_file); //echo $xml_file . "\n<br>"; - $xml_str = sprintf('<?xml version="1.0" encoding="UTF-8" standalone="no"?>%s', file_get_contents($xml_file)); + $xml_str = sprintf('%s', file_get_contents($xml_file)); //echo $xml_str; } @@ -111,27 +112,29 @@ $global_weight = 100; foreach ($context -> extension as $extension) { $en = $extension['name']; - $ec = is_numeric($extension['continue']) ? $extension['continue'] : '0'; + //printf("<pre>%s</pre>", print_r($extension, true)); + $ec = $extension['continue']; $global_weight+=100; foreach ($extension -> condition as $condition) { //print_r($condition); $cf = $condition['field']; - $ce = $condition['expression']; - $cc = $condition['continue']; + $ce = str_replace('\\', '\\\\', $condition['expression']); + //echo "<pre>Condidtion Expression for $en:\n before: " . $condition['expression'] . "\n after: $ce</pre>"; + $cb = $condition['break']; $weight = 0; foreach ($condition as $type => $action) { //echo "-------------------$type-----------------------------\n"; $app_name = $action['application']; - $app_data = $action['data']; + $app_data = str_replace('\\', '\\\\', $action['data']); $weight++; //echo "$cn\t$en\t$cf\t$ce\t$cc\t$app_name\t$app_data\t$ec\t$global_weight\t$weight\n"; $query = sprintf('%s %s %s %s %s %s;', - "INSERT INTO curl_dialplan SET", + "INSERT INTO dialplan SET", "context='$cn', extension='$en', condition_field='$cf',", "condition_expression='$ce', application_name='$app_name',", "application_data='$app_data', weight='$weight', type='$type',", "ext_continue='$ec', global_weight='$global_weight',", - "condition_continue='$cc'" + "cond_break='$cb'" ); run_query($db, $query); } @@ -144,4 +147,6 @@ echo "<h2>File Successfully Imported</h2>"; } upload_form(); -?> \ No newline at end of file + +//printf("<pre>%s</pre>", print_r($xml_obj, true); +?> Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php ============================================================================== --- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php (original) +++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php Fri Jun 6 13:45:47 2008 @@ -26,7 +26,7 @@ /** * This is the method that determines the XML output. Customized dialplans can - * be easily created by adding a record to the dialplan_special table with the + * be easily created by adding a record to the dialplan_special table with the * appropriate values. The php class MUST contain a "main()" method. The method * should write directly to the xmlw obj that's pased or take care of writing * out the xml itself and exiting as to not return. @@ -120,7 +120,7 @@ * @see fs_dialplan::get_dialplan * @param array $dpArray Multi-dimentional array from which we write the XML * @todo this method should REALLY be broken down into several smaller methods - * + * */ private function writeDialplan($dpArray) { //print_r($dpArray); @@ -140,7 +140,7 @@ $ex_split = split(';', $extension); $this -> xmlw -> startElement('extension'); $this -> xmlw -> writeAttribute('name', $ex_split[0]); - if ($ex_split[1] > 0) { + if (strlen($ex_split[1]) > 0) { $this -> xmlw -> writeAttribute('continue', $ex_split[1]); } $this -> debug($conditions); Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php ============================================================================== --- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php (original) +++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php Fri Jun 6 13:45:47 2008 @@ -43,7 +43,7 @@ /** * Define debug level... should not be used in production for performance reasons */ -define('FS_CURL_DEBUG', 0); +define('FS_CURL_DEBUG', 9); /** * define how debugging should be done (depends on FS_CURL_DEBUG) @@ -62,4 +62,4 @@ //define('', ''); -?> \ No newline at end of file +?>