| | 194 | |
|---|
| | 195 | //---------- DEPRECATED functions added here so installs work from tarball -------------- |
|---|
| | 196 | |
|---|
| | 197 | function __core_routing_getroutenames() |
|---|
| | 198 | { |
|---|
| | 199 | global $amp_conf; |
|---|
| | 200 | |
|---|
| | 201 | if ($amp_conf["AMPDBENGINE"] == "sqlite3") |
|---|
| | 202 | { |
|---|
| | 203 | $results = sql("SELECT DISTINCT context FROM extensions WHERE context LIKE 'outrt-%' ORDER BY context ","getAll"); |
|---|
| | 204 | foreach( array_keys($results) as $idx ) |
|---|
| | 205 | { |
|---|
| | 206 | $results[$idx][0] = substr( $results[$idx][0], 6); |
|---|
| | 207 | } |
|---|
| | 208 | } |
|---|
| | 209 | else |
|---|
| | 210 | { |
|---|
| | 211 | $results = sql("SELECT DISTINCT SUBSTRING(context,7) FROM extensions WHERE context LIKE 'outrt-%' ORDER BY context ","getAll"); |
|---|
| | 212 | } |
|---|
| | 213 | return $results; |
|---|
| | 214 | } |
|---|
| | 215 | function __core_routing_getroutecid($route) { |
|---|
| | 216 | global $db; |
|---|
| | 217 | |
|---|
| | 218 | $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'ROUTECID%' OR args LIKE 'EXTEN_ROUTE_CID%') "; |
|---|
| | 219 | $results = $db->getOne($sql); |
|---|
| | 220 | if(DB::IsError($results)) { |
|---|
| | 221 | die_freepbx($results->getMessage()); |
|---|
| | 222 | } |
|---|
| | 223 | if (preg_match('/^(.*)=(.*)/', $results, $matches)) { |
|---|
| | 224 | $routecid = $matches[2]; |
|---|
| | 225 | $routecid_mode = $matches[1] == 'ROUTECID' ? 'override_extension':''; |
|---|
| | 226 | } else { |
|---|
| | 227 | $routecid = ''; |
|---|
| | 228 | $routecid_mode = ''; |
|---|
| | 229 | } |
|---|
| | 230 | return array('routecid' => $routecid, 'routecid_mode' => $routecid_mode); |
|---|
| | 231 | } |
|---|
| | 232 | function __core_routing_getroutepassword($route) { |
|---|
| | 233 | global $db; |
|---|
| | 234 | $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'dialout-trunk,%' OR args LIKE 'dialout-enum,%' OR args LIKE 'dialout-dundi,%') ORDER BY CAST(priority as UNSIGNED) "; |
|---|
| | 235 | $results = $db->getOne($sql); |
|---|
| | 236 | if(DB::IsError($results)) { |
|---|
| | 237 | die_freepbx($results->getMessage()); |
|---|
| | 238 | } |
|---|
| | 239 | if (preg_match('/^.*,.*,.*,(\d+|\/\S+)/', $results, $matches)) { |
|---|
| | 240 | $password = $matches[1]; |
|---|
| | 241 | } else { |
|---|
| | 242 | $password = ""; |
|---|
| | 243 | } |
|---|
| | 244 | return $password; |
|---|
| | 245 | } |
|---|
| | 246 | function __core_routing_getrouteemergency($route) { |
|---|
| | 247 | global $db; |
|---|
| | 248 | $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'EMERGENCYROUTE%') "; |
|---|
| | 249 | $results = $db->getOne($sql); |
|---|
| | 250 | if(DB::IsError($results)) { |
|---|
| | 251 | die_freepbx($results->getMessage()); |
|---|
| | 252 | } |
|---|
| | 253 | if (preg_match('/^.*=(.*)/', $results, $matches)) { |
|---|
| | 254 | $emergency = $matches[1]; |
|---|
| | 255 | } else { |
|---|
| | 256 | $emergency = ""; |
|---|
| | 257 | } |
|---|
| | 258 | return $emergency; |
|---|
| | 259 | } |
|---|
| | 260 | function __core_routing_getrouteintracompany($route) { |
|---|
| | 261 | global $db; |
|---|
| | 262 | $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'INTRACOMPANYROUTE%') "; |
|---|
| | 263 | $results = $db->getOne($sql); |
|---|
| | 264 | if(DB::IsError($results)) { |
|---|
| | 265 | die_freepbx($results->getMessage()); |
|---|
| | 266 | } |
|---|
| | 267 | if (preg_match('/^.*=(.*)/', $results, $matches)) { |
|---|
| | 268 | $intracompany = $matches[1]; |
|---|
| | 269 | } else { |
|---|
| | 270 | $intracompany = ""; |
|---|
| | 271 | } |
|---|
| | 272 | return $intracompany; |
|---|
| | 273 | } |
|---|
| | 274 | function __core_routing_getroutemohsilence($route) { |
|---|
| | 275 | global $db; |
|---|
| | 276 | $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'MOHCLASS%') "; |
|---|
| | 277 | $results = $db->getOne($sql); |
|---|
| | 278 | if(DB::IsError($results)) { |
|---|
| | 279 | die_freepbx($results->getMessage()); |
|---|
| | 280 | } |
|---|
| | 281 | if (preg_match('/^.*=(.*)/', $results, $matches)) { |
|---|
| | 282 | $mohsilence = $matches[1]; |
|---|
| | 283 | } else { |
|---|
| | 284 | $mohsilence = ""; |
|---|
| | 285 | } |
|---|
| | 286 | return $mohsilence; |
|---|
| | 287 | } |
|---|
| | 288 | function __core_routing_getroutepatterns($route) { |
|---|
| | 289 | global $db; |
|---|
| | 290 | $sql = "SELECT extension, args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'dialout-trunk%' OR args LIKE 'dialout-enum%' OR args LIKE 'dialout-dundi%') ORDER BY extension "; |
|---|
| | 291 | $results = $db->getAll($sql); |
|---|
| | 292 | if(DB::IsError($results)) { |
|---|
| | 293 | die_freepbx($results->getMessage()); |
|---|
| | 294 | } |
|---|
| | 295 | |
|---|
| | 296 | $patterns = array(); |
|---|
| | 297 | foreach ($results as $row) { |
|---|
| | 298 | if ($row[0][0] == "_") { |
|---|
| | 299 | // remove leading _ |
|---|
| | 300 | $pattern = substr($row[0],1); |
|---|
| | 301 | } else { |
|---|
| | 302 | $pattern = $row[0]; |
|---|
| | 303 | } |
|---|
| | 304 | |
|---|
| | 305 | if (preg_match("/{EXTEN:(\d+)}/", $row[1], $matches)) { |
|---|
| | 306 | // this has a digit offset, we need to insert a | |
|---|
| | 307 | $pattern = substr($pattern,0,$matches[1])."|".substr($pattern,$matches[1]); |
|---|
| | 308 | } |
|---|
| | 309 | |
|---|
| | 310 | $patterns[] = $pattern; |
|---|
| | 311 | } |
|---|
| | 312 | return array_unique($patterns); |
|---|
| | 313 | } |
|---|
| | 314 | function __core_routing_getroutetrunks($route) { |
|---|
| | 315 | global $db; |
|---|
| | 316 | $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'dialout-trunk,%' OR args LIKE 'dialout-enum,%' OR args LIKE 'dialout-dundi,%') ORDER BY CAST(priority as UNSIGNED) "; |
|---|
| | 317 | $results = $db->getAll($sql); |
|---|
| | 318 | if(DB::IsError($results)) { |
|---|
| | 319 | die_freepbx($results->getMessage()); |
|---|
| | 320 | } |
|---|
| | 321 | $trunks = array(); |
|---|
| | 322 | foreach ($results as $row) { |
|---|
| | 323 | if (preg_match('/^dialout-trunk,(\d+)/', $row[0], $matches)) { |
|---|
| | 324 | // check in_array -- even though we did distinct |
|---|
| | 325 | // we still might get ${EXTEN} and ${EXTEN:1} if they used | to split a pattern |
|---|
| | 326 | if (!in_array("OUT_".$matches[1], $trunks)) { |
|---|
| | 327 | $trunks[] = "OUT_".$matches[1]; |
|---|
| | 328 | } |
|---|
| | 329 | } else if (preg_match('/^dialout-enum,(\d+)/', $row[0], $matches)) { |
|---|
| | 330 | if (!in_array("OUT_".$matches[1], $trunks)) { |
|---|
| | 331 | $trunks[] = "OUT_".$matches[1]; |
|---|
| | 332 | } |
|---|
| | 333 | } else if (preg_match('/^dialout-dundi,(\d+)/', $row[0], $matches)) { |
|---|
| | 334 | if (!in_array("OUT_".$matches[1], $trunks)) { |
|---|
| | 335 | $trunks[] = "OUT_".$matches[1]; |
|---|
| | 336 | } |
|---|
| | 337 | } |
|---|
| | 338 | } |
|---|
| | 339 | return $trunks; |
|---|
| | 340 | } |
|---|