From 057d487ee7de995da8a5e667f1ed4c21bca2dcb8 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 2 Feb 2016 19:08:19 +0300 Subject: [PATCH 1/6] Fix. Do not build context if there error. --- .../resources/scripts/dialplan/dialplan.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua index d07f6090f8..1925250d38 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua @@ -108,8 +108,12 @@ if (debug["sql"]) then log.notice("SQL: " .. sql); end - x = 0; + local x = 0; + local pass dbh:query(sql, function(row) + --clear flag pass + pass = false + --get the dialplan domain_uuid = row.domain_uuid; dialplan_uuid = row.dialplan_uuid; @@ -281,8 +285,16 @@ --increment the x x = x + 1; + + --set flag pass + pass = true end); + -- prevent partial dialplan (pass=nil may be error in sql or empty resultset) + if pass == false then + error('error while build context: ' .. call_context) + end + --close the extension tag if it was left open if (dialplan_tag_status == "open") then table.insert(xml, [[ ]]); From 48b3aa2917d3422fe2a39c3f38a55b0825eb6e59 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 2 Feb 2016 19:32:27 +0300 Subject: [PATCH 2/6] Add. debug message to log. --- .../resources/scripts/dialplan/dialplan.lua | 10 ++++++++++ resources/install/scripts/resources/functions/log.lua | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua index 1925250d38..55f479aed5 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua @@ -292,6 +292,16 @@ -- prevent partial dialplan (pass=nil may be error in sql or empty resultset) if pass == false then + log.errf('context: %s, extension: %s, type: %s, data: %s ', + call_context, + dialplan_name or '----', + dialplan_detail_tag or '----', + dialplan_detail_data or '----' + ) + + --close the database connection + dbh:release(); + error('error while build context: ' .. call_context) end diff --git a/resources/install/scripts/resources/functions/log.lua b/resources/install/scripts/resources/functions/log.lua index eb73e5c13c..5b60091484 100644 --- a/resources/install/scripts/resources/functions/log.lua +++ b/resources/install/scripts/resources/functions/log.lua @@ -42,7 +42,7 @@ local function tracef(type, name, level, ...) end local LEVELS = { - 'error', + 'err', 'warning', 'notice', 'info', From ca4e1b8a671850da7ee421493edada7289e216b0 Mon Sep 17 00:00:00 2001 From: mafoo Date: Thu, 4 Feb 2016 11:14:26 +0000 Subject: [PATCH 3/6] only offer the source upgrade if it is writeable this check will prevent the source upgrade rendering if the .git folder is not writeable --- core/upgrade/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/upgrade/index.php b/core/upgrade/index.php index 7106b320ed..7f14dcda17 100644 --- a/core/upgrade/index.php +++ b/core/upgrade/index.php @@ -142,7 +142,7 @@ echo "

"; echo "
\n"; -if (permission_exists("upgrade_source") && !is_dir("/usr/share/examples/fusionpbx")) { +if (permission_exists("upgrade_source") && !is_dir("/usr/share/examples/fusionpbx") && is_writeable($_SERVER["PROJECT_ROOT"]."/.git")) { echo "\n"; echo "\n"; echo " \n"; echo "
\n"; From 057acf09bf81750c3628270130e96a408dcc5606 Mon Sep 17 00:00:00 2001 From: mafoo Date: Thu, 4 Feb 2016 12:17:38 +0000 Subject: [PATCH 4/6] Normalized and fixed htaccess added comments explaining each rule normalized tabbing converted captures where not needed (note use of ?: means don't capture) updated Yealink comment as it also covers Polycom added missing $mac-directory.xml for Polycom removed ^(?:.*/) as it is technically not needed, the test that showed it was needed turned out to be invalid --- .htaccess | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/.htaccess b/.htaccess index 948308689e..4044c1d190 100644 --- a/.htaccess +++ b/.htaccess @@ -1,26 +1,31 @@ RewriteEngine On -RewriteRule ^([A-Fa-f0-9]{12})(\.(xml|cfg))?$ app/provision/index.php?mac=$1 [QSA] -RewriteRule ^([A-Fa-f0-9]{2}[:-][A-Fa-f0-9]{2}[:-][A-Fa-f0-9]{2}[:-][A-Fa-f0-9]{2}[:-][A-Fa-f0-9]{2}[:-][A-Fa-f0-9]{2}[:-])(\.(xml|cfg))?$ app/provision/index.php?mac=$1 [QSA] -RewriteRule ^(kt.*?-)([A-Fa-f0-9]{12})(\.(xml))$ app/provision/index.php?mac=$2 [QSA] -RewriteRule ^(cfg)([A-Fa-f0-9]{12})(\.(xml))$ app/provision/index.php?mac=$2 [QSA] +# $mac or $mac.cfg/xml +RewriteRule ^([A-Fa-f0-9]{12})(?:\.xml|\.cfg)?$ app/provision/index.php?mac=$1 [QSA] +# $m:a:c or $m:a:c.cfg/xml +RewriteRule ^((?:[A-Fa-f0-9]{2}[:-]){5}[A-Fa-f0-9]{2})(?:\.xml|\.cfg)?$ app/provision/index.php?mac=$1 [QSA] +# kt*-$mac.xml +RewriteRule ^kt.*?-([A-Fa-f0-9]{12})\.xml$ app/provision/index.php?mac=$1 [QSA] +# cfg-$mac.xml +RewriteRule ^cfg([A-Fa-f0-9]{12})\.xml$ app/provision/index.php?mac=$1 [QSA] #Snom m3 -RewriteRule ^(m3/settings/)([A-Fa-f0-9]{12})(\.(cfg))?$ app/provision/index.php?mac=$2 [QSA] +RewriteRule ^m3/settings/([A-Fa-f0-9]{12})(?:\.cfg)?$ app/provision/index.php?mac=$1 [QSA] #Grandstream -RewriteRule ^(?:.*/)?provision/cfg([A-Fa-f0-9]{12})(\.(xml|cfg))?$ app/provision/?mac=$1 [QSA] +RewriteRule ^provision/cfg([A-Fa-f0-9]{12})(?:\.xml|\.cfg)?$ app/provision/?mac=$1 [QSA] -#Yealink -RewriteRule ^(?:.*/)?provision/([A-Fa-f0-9]{12})(\.(xml|cfg))?$ app/provision/index.php?mac=$1 [QSA] +#Yealink and Polycom +RewriteRule ^provision/([A-Fa-f0-9]{12})(?:\.xml|\.cfg)?$ app/provision/index.php?mac=$1 [QSA] #Polycom -RewriteRule ^(?:.*/)?provision/000000000000.cfg$ app/provison/?mac=$1&file={$mac}.cfg [QSA] -RewriteRule ^(?:.*/)?provision/features.cfg$ app/provision/?mac=$1&file=features.cfg [QSA] -RewriteRule ^(?:.*/)?provision/([A-Fa-f0-9]{12})-sip.cfg$ app/provision/?mac=$1&file=sip.cfg [QSA] -RewriteRule ^(?:.*/)?provision/([A-Fa-f0-9]{12})-phone.cfg$ app/provision/?mac=$1 [QSA] -RewriteRule ^(?:.*/)?provision/([A-Fa-f0-9]{12})-registration.cfg$ app/provision/?mac=$1&file={$mac}-registration.cfg [QSA] -RewriteRule ^(?:.*/)?provision/([A-Fa-f0-9]{12})-site.cfg$ app/provision/?mac=$1&file=site.cfg [QSA] -RewriteRule ^(?:.*/)?provision/([A-Fa-f0-9]{12})-web.cfg$ app/provision/?mac=$1&file=web.cfg [QSA] +RewriteRule ^provision/000000000000.cfg$ app/provision/?mac=$1&file={$mac}.cfg [QSA] +RewriteRule ^provision/features.cfg$ app/provision/?mac=$1&file=features.cfg [QSA] +RewriteRule ^provision/([A-Fa-f0-9]{12})-sip.cfg$ app/provision/?mac=$1&file=sip.cfg [QSA] +RewriteRule ^provision/([A-Fa-f0-9]{12})-phone.cfg$ app/provision/?mac=$1 [QSA] +RewriteRule ^provision/([A-Fa-f0-9]{12})-registration.cfg$ app/provision/?mac=$1&file={$mac}-registration.cfg [QSA] +RewriteRule ^provision/([A-Fa-f0-9]{12})-site.cfg$ app/provision/?mac=$1&file=site.cfg [QSA] +RewriteRule ^provision/([A-Fa-f0-9]{12})-web.cfg$ app/provision/?mac=$1&file=web.cfg [QSA] +RewriteRule ^provision/([A-Fa-f0-9]{12})-directory.xml$ app/provision/?mac=$1&file=directory.xml [QSA] Options -Indexes From 010963aa2f2a7b5c7335a63d0d232c29bb1796f5 Mon Sep 17 00:00:00 2001 From: mafoo Date: Thu, 4 Feb 2016 15:49:03 +0000 Subject: [PATCH 5/6] fix for incorrect destinations --- app/phrases/app_config.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/phrases/app_config.php b/app/phrases/app_config.php index 58423e6a79..818d4f3bc3 100644 --- a/app/phrases/app_config.php +++ b/app/phrases/app_config.php @@ -28,10 +28,11 @@ $apps[$x]['destinations'][$y]['name'] = "phrases"; $apps[$x]['destinations'][$y]['where'] = "where domain_uuid = '\${domain_uuid}' and phrase_enabled = 'true' "; $apps[$x]['destinations'][$y]['order_by'] = "phrase_name asc"; + $apps[$x]['destinations'][$y]['field']['uuid'] = "phrase_uuid"; $apps[$x]['destinations'][$y]['field']['name'] = "phrase_name"; $apps[$x]['destinations'][$y]['field']['destination'] = "phrase_name"; - $apps[$x]['destinations'][$y]['select_value']['dialplan'] = "phrase:\${destination}.\${domain_uuid}"; - $apps[$x]['destinations'][$y]['select_value']['ivr'] = "menu-exec-app:phrase \${destination}.\${domain_uuid}"; + $apps[$x]['destinations'][$y]['select_value']['dialplan'] = "phrase:\${uuid}"; + $apps[$x]['destinations'][$y]['select_value']['ivr'] = "menu-exec-app:phrase \${uuid}"; $apps[$x]['destinations'][$y]['select_label'] = "\${name}"; //permission details From 416a704c12371d3fbf5f8fe323b53dcd1a655428 Mon Sep 17 00:00:00 2001 From: mafoo Date: Thu, 4 Feb 2016 16:19:27 +0000 Subject: [PATCH 6/6] made it possible to find phrases fixed string replace not taking out spaces aswell --- app/ivr_menus/ivr_menu_edit.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/ivr_menus/ivr_menu_edit.php b/app/ivr_menus/ivr_menu_edit.php index 01ebdf7c0e..a1abb509f9 100644 --- a/app/ivr_menus/ivr_menu_edit.php +++ b/app/ivr_menus/ivr_menu_edit.php @@ -644,14 +644,28 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $ivr_menu_option_param = $field['ivr_menu_option_action']; } $ivr_menu_option_param = str_replace("menu-", "", $ivr_menu_option_param); - $ivr_menu_option_param = str_replace("XML", "", $ivr_menu_option_param); - $ivr_menu_option_param = str_replace("transfer", "", $ivr_menu_option_param); - $ivr_menu_option_param = str_replace("bridge", "", $ivr_menu_option_param); + $ivr_menu_option_param = str_replace("XML ", "", $ivr_menu_option_param); + $ivr_menu_option_param = str_replace("transfer ", "", $ivr_menu_option_param); + $ivr_menu_option_param = str_replace("bridge ", "", $ivr_menu_option_param); $ivr_menu_option_param = str_replace($_SESSION['domain_name'], "", $ivr_menu_option_param); $ivr_menu_option_param = str_replace("\${domain_name}", "", $ivr_menu_option_param); $ivr_menu_option_param = str_replace("\${domain}", "", $ivr_menu_option_param); $ivr_menu_option_param = str_replace(".".$_SESSION['domain_uuid'], "", $ivr_menu_option_param); $ivr_menu_option_param = str_replace("//", "/", $ivr_menu_option_param); + if (preg_match( "/^phrase /", $ivr_menu_option_param )) { + // parse out phrase uuid + $phrase_uuid = str_replace("phrase ", "", $ivr_menu_option_param); + // retrieve phrase name from db + $sql = "select phrase_name from v_phrases where phrase_uuid = '$phrase_uuid' limit 1"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) > 0) { + $phrase_name = $result[0]['phrase_name']; + $ivr_menu_option_param = "phrase: $phrase_name"; + } + unset ($prep_statement, $sql, $phrase_uuid, $phrase_name); + } //$ivr_menu_option_param = ucfirst(trim($ivr_menu_option_param)); echo "
\n";