Changeset 99
- Timestamp:
- 02/25/05 18:40:03 (7 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/AMP/amp_conf/htdocs/admin/functions.php
r95 r99 1059 1059 die($results->getMessage()); 1060 1060 } 1061 1062 if (count($results) == 0) { 1063 // see if they're still using the old dialprefix method 1064 $sql = "SELECT variable,value FROM globals WHERE variable LIKE 'DIAL\\\_OUT\\\_%'"; 1065 // we SUBSTRING() to remove "outrt-" 1066 $results = $db->getAll($sql); 1067 if(DB::IsError($results)) { 1068 die($results->getMessage()); 1069 } 1070 1071 if (count($results) > 0) { 1072 // yes, they are using old method, let's update 1073 1074 // get the default trunk 1075 $sql = "SELECT value FROM globals WHERE variable = 'OUT'"; 1076 $results_def = $db->getAll($sql); 1077 if(DB::IsError($results_def)) { 1078 die($results_def->getMessage()); 1079 } 1080 1081 if (preg_match("/{OUT_(\d+)}/", $results_def[0][0], $matches)) { 1082 $def_trunk = $matches[1]; 1083 } else { 1084 $def_trunk = ""; 1085 } 1086 1087 $default_patterns = array( // default patterns that used to be in extensions.conf 1088 "NXXXXXX", 1089 "NXXNXXXXXX", 1090 "1800NXXXXXX", 1091 "1888NXXXXXX", 1092 "1877NXXXXXX", 1093 "1866NXXXXXX", 1094 "1NXXNXXXXXX", 1095 "011.", 1096 "911", 1097 "411", 1098 "311", 1099 ); 1100 1101 foreach ($results as $temp) { 1102 // temp[0] is "DIAL_OUT_1" 1103 // temp[1] is the dial prefix 1104 1105 $trunknum = substr($temp[0],9); 1106 1107 $name = "route".$trunknum; 1108 1109 $trunks = array(1=>"OUT_".$trunknum); // only one trunk to use 1110 1111 $patterns = array(); 1112 foreach ($default_patterns as $pattern) { 1113 $patterns[] = $temp[1]."|".$pattern; 1114 } 1115 1116 if ($trunknum == $def_trunk) { 1117 // this is the default trunk, add the patterns with no prefix 1118 $patterns = array_merge($patterns, $default_patterns); 1119 } 1120 1121 // add this as a new route 1122 addroute($name, $patterns, $trunks); 1123 } 1124 1125 1126 // delete old values 1127 $sql = "DELETE FROM globals WHERE (variable LIKE 'DIAL\\\_OUT\\\_%') OR (variable = 'OUT') "; 1128 $result = $db->query($sql); 1129 if(DB::IsError($result)) { 1130 die($result->getMessage()); 1131 } 1132 1133 // we need to re-generate extensions_additional.conf 1134 // i'm not sure how to do this from here 1135 1136 // re-run our query 1137 $sql = "SELECT DISTINCT SUBSTRING(context,7) FROM extensions WHERE context LIKE 'outrt-%' ORDER BY context "; 1138 // we SUBSTRING() to remove "outrt-" 1139 $results = $db->getAll($sql); 1140 if(DB::IsError($results)) { 1141 die($results->getMessage()); 1142 } 1143 } 1144 1145 } // else, it just means they have no routes. 1146 1061 1147 return $results; 1062 1148 } 1063 1064 // SQL to convert from "outboundroute-"1065 //TODO This comment should be removed before release1066 //UPDATE extensions SET context = CONCAT('outrt-',SUBSTRING(context,15)) WHERE context LIKE 'outboundroute-%'1067 1149 1068 1150 //get unique outbound route patterns for a given context trunk/AMP2-UseAmportal/amp_conf/var/www/html/admin/functions.php
r95 r99 1059 1059 die($results->getMessage()); 1060 1060 } 1061 1062 if (count($results) == 0) { 1063 // see if they're still using the old dialprefix method 1064 $sql = "SELECT variable,value FROM globals WHERE variable LIKE 'DIAL\\\_OUT\\\_%'"; 1065 // we SUBSTRING() to remove "outrt-" 1066 $results = $db->getAll($sql); 1067 if(DB::IsError($results)) { 1068 die($results->getMessage()); 1069 } 1070 1071 if (count($results) > 0) { 1072 // yes, they are using old method, let's update 1073 1074 // get the default trunk 1075 $sql = "SELECT value FROM globals WHERE variable = 'OUT'"; 1076 $results_def = $db->getAll($sql); 1077 if(DB::IsError($results_def)) { 1078 die($results_def->getMessage()); 1079 } 1080 1081 if (preg_match("/{OUT_(\d+)}/", $results_def[0][0], $matches)) { 1082 $def_trunk = $matches[1]; 1083 } else { 1084 $def_trunk = ""; 1085 } 1086 1087 $default_patterns = array( // default patterns that used to be in extensions.conf 1088 "NXXXXXX", 1089 "NXXNXXXXXX", 1090 "1800NXXXXXX", 1091 "1888NXXXXXX", 1092 "1877NXXXXXX", 1093 "1866NXXXXXX", 1094 "1NXXNXXXXXX", 1095 "011.", 1096 "911", 1097 "411", 1098 "311", 1099 ); 1100 1101 foreach ($results as $temp) { 1102 // temp[0] is "DIAL_OUT_1" 1103 // temp[1] is the dial prefix 1104 1105 $trunknum = substr($temp[0],9); 1106 1107 $name = "route".$trunknum; 1108 1109 $trunks = array(1=>"OUT_".$trunknum); // only one trunk to use 1110 1111 $patterns = array(); 1112 foreach ($default_patterns as $pattern) { 1113 $patterns[] = $temp[1]."|".$pattern; 1114 } 1115 1116 if ($trunknum == $def_trunk) { 1117 // this is the default trunk, add the patterns with no prefix 1118 $patterns = array_merge($patterns, $default_patterns); 1119 } 1120 1121 // add this as a new route 1122 addroute($name, $patterns, $trunks); 1123 } 1124 1125 1126 // delete old values 1127 $sql = "DELETE FROM globals WHERE (variable LIKE 'DIAL\\\_OUT\\\_%') OR (variable = 'OUT') "; 1128 $result = $db->query($sql); 1129 if(DB::IsError($result)) { 1130 die($result->getMessage()); 1131 } 1132 1133 // we need to re-generate extensions_additional.conf 1134 // i'm not sure how to do this from here 1135 1136 // re-run our query 1137 $sql = "SELECT DISTINCT SUBSTRING(context,7) FROM extensions WHERE context LIKE 'outrt-%' ORDER BY context "; 1138 // we SUBSTRING() to remove "outrt-" 1139 $results = $db->getAll($sql); 1140 if(DB::IsError($results)) { 1141 die($results->getMessage()); 1142 } 1143 } 1144 1145 } // else, it just means they have no routes. 1146 1061 1147 return $results; 1062 1148 } 1063 1064 // SQL to convert from "outboundroute-"1065 //TODO This comment should be removed before release1066 //UPDATE extensions SET context = CONCAT('outrt-',SUBSTRING(context,15)) WHERE context LIKE 'outboundroute-%'1067 1149 1068 1150 //get unique outbound route patterns for a given context
