| 183 | | |
|---|
| | 267 | |
|---|
| | 268 | foreach ($results as $result) { |
|---|
| | 269 | $account = $result['data']; |
|---|
| | 270 | $id = $result['id']; |
|---|
| | 271 | $output .= "[$account]\n"; |
|---|
| | 272 | |
|---|
| | 273 | $sql = "SELECT keyword,data from $table_name where id='$id' and keyword <> 'account' and flags <> 1 order by flags, keyword DESC"; |
|---|
| | 274 | $results2 = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 275 | if(DB::IsError($results2)) { |
|---|
| | 276 | die($results2->getMessage()); |
|---|
| | 277 | } |
|---|
| | 278 | foreach ($results2 as $result2) { |
|---|
| | 279 | $options = explode("&", $result2['data']); |
|---|
| | 280 | if ($ver12) { |
|---|
| | 281 | foreach ($options as $option) { |
|---|
| | 282 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 283 | } |
|---|
| | 284 | } else { |
|---|
| | 285 | foreach ($options as $option) { |
|---|
| | 286 | switch ($result2['keyword']) { |
|---|
| | 287 | case 'allow': |
|---|
| | 288 | case 'disallow': |
|---|
| | 289 | if ($option != '') |
|---|
| | 290 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 291 | break; |
|---|
| | 292 | default: |
|---|
| | 293 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 294 | } |
|---|
| | 295 | } |
|---|
| | 296 | } |
|---|
| | 297 | } |
|---|
| | 298 | if ($call_limit && (substr($id,0,4) != "9999" | $id < 99990)) { |
|---|
| | 299 | |
|---|
| | 300 | $output .= $call_limit; |
|---|
| | 301 | } |
|---|
| | 302 | $output .= $additional."\n"; |
|---|
| | 303 | } |
|---|
| | 304 | return $output; |
|---|
| | 305 | } |
|---|
| | 306 | |
|---|
| | 307 | function generate_sip_registrations($ast_version) { |
|---|
| | 308 | global $db; |
|---|
| | 309 | |
|---|
| | 310 | $table_name = "sip"; |
|---|
| | 311 | $output = ""; |
|---|
| | 312 | |
|---|
| | 313 | // items with id like 9999999% get put in registrations file |
|---|
| | 314 | // |
|---|
| | 315 | $sql = "SELECT keyword,data from $table_name where id LIKE '9999999%' and keyword <> 'account' and flags <> 1"; |
|---|
| | 316 | $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 317 | if(DB::IsError($results)) { |
|---|
| | 318 | die($results->getMessage()); |
|---|
| | 319 | } |
|---|
| | 320 | |
|---|
| | 321 | foreach ($results as $result) { |
|---|
| | 322 | $output .= $result['keyword']."=".$result['data']."\n"; |
|---|
| | 323 | } |
|---|
| | 324 | |
|---|
| | 325 | return $output; |
|---|
| | 326 | } |
|---|
| | 327 | |
|---|
| | 328 | function generate_iax_additional($ast_version) { |
|---|
| | 329 | global $db; |
|---|
| | 330 | |
|---|
| | 331 | $table_name = "iax"; |
|---|
| | 332 | $additional = ""; |
|---|
| | 333 | $output = ""; |
|---|
| | 334 | |
|---|
| | 335 | $ver12 = version_compare($ast_version, '1.4', 'lt'); |
|---|
| | 336 | |
|---|
| | 337 | $sql = "SELECT keyword,data from $table_name where id=-1 and keyword <> 'account' and flags <> 1"; |
|---|
| | 338 | $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 339 | if(DB::IsError($results)) { |
|---|
| | 340 | die($results->getMessage()); |
|---|
| | 341 | } |
|---|
| | 342 | foreach ($results as $result) { |
|---|
| | 343 | if ($ver12) { |
|---|
| | 344 | $additional .= $result['keyword']."=".$result['data']."\n"; |
|---|
| | 345 | } else { |
|---|
| | 346 | $option = $result['data']; |
|---|
| | 347 | switch ($result['keyword']) { |
|---|
| | 348 | case 'notransfer': |
|---|
| | 349 | if (strtolower($option) == 'yes') { |
|---|
| | 350 | $additional .= "transfer=no\n"; |
|---|
| | 351 | } else if (strtolower($option) == 'no') { |
|---|
| | 352 | $additional .= "transfer=yes\n"; |
|---|
| | 353 | } else if (strtolower($option) == 'mediaonly') { |
|---|
| | 354 | $additional .= "transfer=mediaonly\n"; |
|---|
| | 355 | } else { |
|---|
| | 356 | $additional .= $result['keyword']."=$option\n"; |
|---|
| | 357 | } |
|---|
| | 358 | break; |
|---|
| | 359 | case 'allow': |
|---|
| | 360 | case 'disallow': |
|---|
| | 361 | if ($option != '') |
|---|
| | 362 | $additional .= $result['keyword']."=$option\n"; |
|---|
| | 363 | break; |
|---|
| | 364 | default: |
|---|
| | 365 | $additional .= $result['keyword']."=$option\n"; |
|---|
| | 366 | } |
|---|
| | 367 | } |
|---|
| | 368 | } |
|---|
| | 369 | |
|---|
| | 370 | $sql = "SELECT data,id from $table_name where keyword='account' and flags <> 1 group by data"; |
|---|
| | 371 | $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 372 | if(DB::IsError($results)) { |
|---|
| | 373 | die($results->getMessage()); |
|---|
| | 374 | } |
|---|
| | 375 | |
|---|
| | 376 | foreach ($results as $result) { |
|---|
| | 377 | $account = $result['data']; |
|---|
| | 378 | $id = $result['id']; |
|---|
| | 379 | $output .= "[$account]\n"; |
|---|
| | 380 | |
|---|
| | 381 | $sql = "SELECT keyword,data from $table_name where id='$id' and keyword <> 'account' and flags <> 1 order by flags, keyword DESC"; |
|---|
| | 382 | $results2 = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 383 | if(DB::IsError($results2)) { |
|---|
| | 384 | die($results2->getMessage()); |
|---|
| | 385 | } |
|---|
| | 386 | foreach ($results2 as $result2) { |
|---|
| | 387 | $options = explode("&", $result2['data']); |
|---|
| | 388 | if ($ver12) { |
|---|
| | 389 | foreach ($options as $option) { |
|---|
| | 390 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 391 | } |
|---|
| | 392 | } else { |
|---|
| | 393 | foreach ($options as $option) { |
|---|
| | 394 | switch ($result2['keyword']) { |
|---|
| | 395 | case 'notransfer': |
|---|
| | 396 | if (strtolower($option) == 'yes') { |
|---|
| | 397 | $output .= "transfer=no\n"; |
|---|
| | 398 | } else if (strtolower($option) == 'no') { |
|---|
| | 399 | $output .= "transfer=yes\n"; |
|---|
| | 400 | } else if (strtolower($option) == 'mediaonly') { |
|---|
| | 401 | $output .= "transfer=mediaonly\n"; |
|---|
| | 402 | } else { |
|---|
| | 403 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 404 | } |
|---|
| | 405 | break; |
|---|
| | 406 | case 'allow': |
|---|
| | 407 | case 'disallow': |
|---|
| | 408 | if ($option != '') |
|---|
| | 409 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 410 | break; |
|---|
| | 411 | default: |
|---|
| | 412 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 413 | } |
|---|
| | 414 | } |
|---|
| | 415 | } |
|---|
| | 416 | } |
|---|
| | 417 | $output .= $additional."\n"; |
|---|
| | 418 | } |
|---|
| | 419 | return $output; |
|---|
| | 420 | } |
|---|
| | 421 | |
|---|
| | 422 | function generate_iax_registrations($ast_version) { |
|---|
| | 423 | global $db; |
|---|
| | 424 | |
|---|
| | 425 | $table_name = "iax"; |
|---|
| | 426 | $output = ""; |
|---|
| | 427 | |
|---|
| | 428 | // items with id like 9999999% get put in the registration file |
|---|
| | 429 | // |
|---|
| | 430 | $sql = "SELECT keyword,data from $table_name where id LIKE '9999999%' and keyword <> 'account' and flags <> 1"; |
|---|
| | 431 | $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 432 | if(DB::IsError($results)) { |
|---|
| | 433 | die($results->getMessage()); |
|---|
| | 434 | } |
|---|
| | 435 | |
|---|
| | 436 | foreach ($results as $result) { |
|---|
| | 437 | $output .= $result['keyword']."=".$result['data']."\n"; |
|---|
| | 438 | } |
|---|
| | 439 | |
|---|
| | 440 | return $output; |
|---|
| | 441 | } |
|---|
| | 442 | |
|---|
| | 443 | function generate_h323_additional($ast_version) { |
|---|
| | 444 | global $db; |
|---|
| | 445 | |
|---|
| | 446 | $table_name = "h323"; |
|---|
| | 447 | $additional = ""; |
|---|
| | 448 | $output = ""; |
|---|
| | 449 | |
|---|
| | 450 | $ver12 = version_compare($ast_version, '1.4', 'lt'); |
|---|
| | 451 | |
|---|
| | 452 | $sql = "SELECT keyword,data from $table_name where id=-1 and keyword <> 'account' and flags <> 1"; |
|---|
| | 453 | $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 454 | if(DB::IsError($results)) { |
|---|
| | 455 | die($results->getMessage()); |
|---|
| | 456 | } |
|---|
| | 457 | foreach ($results as $result) { |
|---|
| | 458 | if ($ver12) { |
|---|
| | 459 | $additional .= $result['keyword']."=".$result['data']."\n"; |
|---|
| | 460 | } else { |
|---|
| | 461 | $option = $result['data']; |
|---|
| | 462 | switch ($result['keyword']) { |
|---|
| | 463 | case 'notransfer': |
|---|
| | 464 | if (strtolower($option) == 'yes') { |
|---|
| | 465 | $additional .= "transfer=no\n"; |
|---|
| | 466 | } else if (strtolower($option) == 'no') { |
|---|
| | 467 | $additional .= "transfer=yes\n"; |
|---|
| | 468 | } else if (strtolower($option) == 'mediaonly') { |
|---|
| | 469 | $additional .= "transfer=mediaonly\n"; |
|---|
| | 470 | } else { |
|---|
| | 471 | $additional .= $result['keyword']."=$option\n"; |
|---|
| | 472 | } |
|---|
| | 473 | break; |
|---|
| | 474 | case 'allow': |
|---|
| | 475 | case 'disallow': |
|---|
| | 476 | if ($option != '') |
|---|
| | 477 | $additional .= $result['keyword']."=$option\n"; |
|---|
| | 478 | break; |
|---|
| | 479 | default: |
|---|
| | 480 | $additional .= $result['keyword']."=$option\n"; |
|---|
| | 481 | } |
|---|
| | 482 | } |
|---|
| | 483 | } |
|---|
| | 484 | |
|---|
| | 485 | $sql = "SELECT data,id from $table_name where keyword='account' and flags <> 1 group by data"; |
|---|
| | 486 | $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 487 | if(DB::IsError($results)) { |
|---|
| | 488 | die($results->getMessage()); |
|---|
| | 489 | } |
|---|
| | 490 | |
|---|
| | 491 | foreach ($results as $result) { |
|---|
| | 492 | $account = $result['data']; |
|---|
| | 493 | $id = $result['id']; |
|---|
| | 494 | $output .= "[$account]\n"; |
|---|
| | 495 | |
|---|
| | 496 | $sql = "SELECT keyword,data from $table_name where id='$id' and keyword <> 'account' and flags <> 1 order by flags, keyword DESC"; |
|---|
| | 497 | $results2 = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 498 | if(DB::IsError($results2)) { |
|---|
| | 499 | die($results2->getMessage()); |
|---|
| | 500 | } |
|---|
| | 501 | foreach ($results2 as $result2) { |
|---|
| | 502 | $options = explode("&", $result2['data']); |
|---|
| | 503 | if ($ver12) { |
|---|
| | 504 | foreach ($options as $option) { |
|---|
| | 505 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 506 | } |
|---|
| | 507 | } else { |
|---|
| | 508 | foreach ($options as $option) { |
|---|
| | 509 | switch ($result2['keyword']) { |
|---|
| | 510 | case 'notransfer': |
|---|
| | 511 | if (strtolower($option) == 'yes') { |
|---|
| | 512 | $output .= "transfer=no\n"; |
|---|
| | 513 | } else if (strtolower($option) == 'no') { |
|---|
| | 514 | $output .= "transfer=yes\n"; |
|---|
| | 515 | } else if (strtolower($option) == 'mediaonly') { |
|---|
| | 516 | $output .= "transfer=mediaonly\n"; |
|---|
| | 517 | } else { |
|---|
| | 518 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 519 | } |
|---|
| | 520 | break; |
|---|
| | 521 | case 'allow': |
|---|
| | 522 | case 'disallow': |
|---|
| | 523 | if ($option != '') |
|---|
| | 524 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 525 | break; |
|---|
| | 526 | default: |
|---|
| | 527 | $output .= $result2['keyword']."=$option\n"; |
|---|
| | 528 | } |
|---|
| | 529 | } |
|---|
| | 530 | } |
|---|
| | 531 | } |
|---|
| | 532 | $output .= $additional."\n"; |
|---|
| | 533 | } |
|---|
| | 534 | return $output; |
|---|
| | 535 | } |
|---|
| | 536 | |
|---|
| | 537 | function generate_h323_registrations($ast_version) { |
|---|
| | 538 | global $db; |
|---|
| | 539 | |
|---|
| | 540 | $table_name = "h323"; |
|---|
| | 541 | $output = ""; |
|---|
| | 542 | |
|---|
| | 543 | // items with id like 9999999% get put in the registration file |
|---|
| | 544 | // |
|---|
| | 545 | $sql = "SELECT keyword,data from $table_name where id LIKE '9999999%' and keyword <> 'account' and flags <> 1"; |
|---|
| | 546 | $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 547 | if(DB::IsError($results)) { |
|---|
| | 548 | die($results->getMessage()); |
|---|
| | 549 | } |
|---|
| | 550 | |
|---|
| | 551 | foreach ($results as $result) { |
|---|
| | 552 | $output .= $result['keyword']."=".$result['data']."\n"; |
|---|
| | 553 | } |
|---|
| | 554 | |
|---|
| | 555 | return $output; |
|---|
| | 556 | } |
|---|
| | 557 | |
|---|
| | 558 | function generate_mgcp_additional($ast_version) { |
|---|
| | 559 | global $db; |
|---|
| | 560 | |
|---|
| | 561 | $table_name = "mgcp"; |
|---|
| | 562 | $additional = ""; |
|---|
| | 563 | $output = ""; |
|---|
| | 564 | |
|---|
| | 565 | $ver12 = version_compare($ast_version, '1.4', 'lt'); |
|---|
| | 566 | |
|---|
| | 567 | $sql = "SELECT keyword,data from $table_name where id=-1 and keyword <> 'account' and flags <> 1"; |
|---|
| | 568 | $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 569 | if(DB::IsError($results)) { |
|---|
| | 570 | die($results->getMessage()); |
|---|
| | 571 | } |
|---|
| | 572 | foreach ($results as $result) { |
|---|
| | 573 | if ($ver12) { |
|---|
| | 574 | $additional .= $result['keyword']."=".$result['data']."\n"; |
|---|
| | 575 | } else { |
|---|
| | 576 | $option = $result['data']; |
|---|
| | 577 | switch ($result['keyword']) { |
|---|
| | 578 | case 'notransfer': |
|---|
| | 579 | if (strtolower($option) == 'yes') { |
|---|
| | 580 | $additional .= "transfer=no\n"; |
|---|
| | 581 | } else if (strtolower($option) == 'no') { |
|---|
| | 582 | $additional .= "transfer=yes\n"; |
|---|
| | 583 | } else if (strtolower($option) == 'mediaonly') { |
|---|
| | 584 | $additional .= "transfer=mediaonly\n"; |
|---|
| | 585 | } else { |
|---|
| | 586 | $additional .= $result['keyword']."=$option\n"; |
|---|
| | 587 | } |
|---|
| | 588 | break; |
|---|
| | 589 | case 'allow': |
|---|
| | 590 | case 'disallow': |
|---|
| | 591 | if ($option != '') |
|---|
| | 592 | $additional .= $result['keyword']."=$option\n"; |
|---|
| | 593 | break; |
|---|
| | 594 | default: |
|---|
| | 595 | $additional .= $result['keyword']."=$option\n"; |
|---|
| | 596 | } |
|---|
| | 597 | } |
|---|
| | 598 | } |
|---|
| | 599 | |
|---|
| | 600 | $sql = "SELECT data,id from $table_name where keyword='account' and flags <> 1 group by data"; |
|---|
| | 601 | $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); |
|---|
| | 602 | if(DB::IsError($results)) { |
|---|
| | 603 | die($results->getMessage()); |
|---|
| | 604 | } |
|---|
| | 605 | |
|---|
| | 2578 | //add to h323 table |
|---|
| | 2579 | function core_devices_addh323($account) { |
|---|
| | 2580 | global $db; |
|---|
| | 2581 | global $currentFile; |
|---|
| | 2582 | |
|---|
| | 2583 | foreach ($_REQUEST as $req=>$data) { |
|---|
| | 2584 | if ( substr($req, 0, 8) == 'devinfo_' ) { |
|---|
| | 2585 | $keyword = substr($req, 8); |
|---|
| | 2586 | if ( $keyword == 'dial' && $data == '' ) { |
|---|
| | 2587 | $h323fields[] = array($account, $keyword, 'OOH323/'.$h323id."@".$ip); |
|---|
| | 2588 | // $h323fields[] = array($account, $keyword, 'OOH323/'.$account.'@'.$ip); |
|---|
| | 2589 | } elseif ($keyword == 'mailbox' && $data == '') { |
|---|
| | 2590 | $h323fields[] = array($account,'mailbox',$account.'@device'); |
|---|
| | 2591 | } else { |
|---|
| | 2592 | $h323fields[] = array($account, $keyword, $data); |
|---|
| | 2593 | } |
|---|
| | 2594 | } |
|---|
| | 2595 | } |
|---|
| | 2596 | |
|---|
| | 2597 | if ( !is_array($h323fields) ) { // left for compatibilty....lord knows why ! |
|---|
| | 2598 | $h323fields = array( |
|---|
| | 2599 | //array($account,'account',$account), |
|---|
| | 2600 | array($account,'type',($_REQUEST['context'])?$_REQUEST['context']:'friend'), |
|---|
| | 2601 | array($account,'ip',($_REQUEST['ip'])?$_REQUEST['ip']:''), |
|---|
| | 2602 | array($account,'port',($_REQUEST['port'])?$_REQUEST['port']:'1720'), |
|---|
| | 2603 | array($account,'h323id',($_REQUEST['h323id'])?$_REQUEST['h323id']:$account), |
|---|
| | 2604 | array($account,'rtptimeout',($_REQUEST['rtptimeout'])?$_REQUEST['rtptimeout']:'60'), |
|---|
| | 2605 | array($account,'dtmfmode',($_REQUEST['dtmfmode'])?$_REQUEST['dtmfmode']:'rfc2833'), |
|---|
| | 2606 | array($account,'context',($_REQUEST['context'])?$_REQUEST['context']:'from-internal'), |
|---|
| | 2607 | array($account,'mailbox',($_REQUEST['mailbox'])?$_REQUEST['mailbox']:$account.'@device'), |
|---|
| | 2608 | array($account,'amaflags',($_REQUEST['amaflags'])?$_REQUEST['amaflags']:'default'), |
|---|
| | 2609 | array($account,'disallow',($_REQUEST['disallow'])?$_REQUEST['disallow']:'all'), |
|---|
| | 2610 | array($account,'allow',($_REQUEST['allow'])?$_REQUEST['allow']:'ulaw'), |
|---|
| | 2611 | array($account,'accountcode',($_REQUEST['accountcode'])?$_REQUEST['accountcode']:''), |
|---|
| | 2612 | array($account,'e164',($_REQUEST['e164'])?$_REQUEST['e164']:''), |
|---|
| | 2613 | array($account,'email',($_REQUEST['email'])?$_REQUEST['email']:''), |
|---|
| | 2614 | array($account,'url',($_REQUEST['url'])?$_REQUEST['url']:'') |
|---|
| | 2615 | //array($account,'record_in',($_REQUEST['record_in'])?$_REQUEST['record_in']:'On-Demand'), |
|---|
| | 2616 | //array($account,'record_out',($_REQUEST['record_out'])?$_REQUEST['record_out']:'On-Demand'), |
|---|
| | 2617 | //array($account,'callerid',($_REQUEST['description'])?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>') |
|---|
| | 2618 | ); |
|---|
| | 2619 | } |
|---|
| | 2620 | |
|---|
| | 2621 | // Very bad |
|---|
| | 2622 | $h323fields[] = array($account,'account',$account); |
|---|
| | 2623 | $h323fields[] = array($account,'callerid',(isset($_REQUEST['description']) && $_REQUEST['description'] != '')?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>'); |
|---|
| | 2624 | // Asterisk treats no caller ID from an h323 device as 'hide callerid', and ignores the caller ID |
|---|
| | 2625 | // set in h323.conf. As we rely on this for pretty much everything, we need to specify the |
|---|
| | 2626 | // callerid as a variable which gets picked up in macro-callerid. |
|---|
| | 2627 | // Ref - http://bugs.digium.com/view.php?id=456 |
|---|
| | 2628 | $h323fields[] = array($account,'setvar',"REALCALLERIDNUM=$account"); |
|---|
| | 2629 | |
|---|
| | 2630 | // Where is this in the interface ?????? |
|---|
| | 2631 | $h323fields[] = array($account,'record_in',($_REQUEST['record_in'])?$_REQUEST['record_in']:'On-Demand'); |
|---|
| | 2632 | $h323fields[] = array($account,'record_out',($_REQUEST['record_out'])?$_REQUEST['record_out']:'On-Demand'); |
|---|
| | 2633 | |
|---|
| | 2634 | $compiled = $db->prepare('INSERT INTO h323 (id, keyword, data) values (?,?,?)'); |
|---|
| | 2635 | $result = $db->executeMultiple($compiled,$h323fields); |
|---|
| | 2636 | if(DB::IsError($result)) { |
|---|
| | 2637 | die_freepbx($result->getMessage()."<br><br>error adding to h323 table"); |
|---|
| | 2638 | } |
|---|
| | 2639 | } |
|---|
| | 2640 | |
|---|
| | 2641 | function core_devices_delh323($account) { |
|---|
| | 2642 | global $db; |
|---|
| | 2643 | global $currentFile; |
|---|
| | 2644 | |
|---|
| | 2645 | $sql = "DELETE FROM h323 WHERE id = '$account'"; |
|---|
| | 2646 | $result = $db->query($sql); |
|---|
| | 2647 | |
|---|
| | 2648 | if(DB::IsError($result)) { |
|---|
| | 2649 | die_freepbx($result->getMessage().$sql); |
|---|
| | 2650 | } |
|---|
| | 2651 | } |
|---|
| | 2652 | |
|---|
| | 2653 | function core_devices_geth323($account) { |
|---|
| | 2654 | global $db; |
|---|
| | 2655 | $sql = "SELECT keyword,data FROM h323 WHERE id = '$account'"; |
|---|
| | 2656 | $results = $db->getAssoc($sql); |
|---|
| | 2657 | if(DB::IsError($results)) { |
|---|
| | 2658 | $results = null; |
|---|
| | 2659 | } |
|---|
| | 2660 | |
|---|
| | 2661 | return $results; |
|---|
| | 2662 | } |
|---|
| | 2663 | |
|---|
| | 2664 | //add to mgcp table |
|---|
| | 2665 | function core_devices_addmgcp($account) { |
|---|
| | 2666 | global $db; |
|---|
| | 2667 | global $currentFile; |
|---|
| | 2668 | |
|---|
| | 2669 | foreach ($_REQUEST as $req=>$data) { |
|---|
| | 2670 | if ( substr($req, 0, 8) == 'devinfo_' ) { |
|---|
| | 2671 | $keyword = substr($req, 8); |
|---|
| | 2672 | if ( $keyword == 'dial' && $data == '' ) { |
|---|
| | 2673 | $mgcpfields[] = array($account, $keyword, 'MGCP/'.$line."@".$account); |
|---|
| | 2674 | // $mgcpfields[] = array($account, $keyword, 'MGCP/aaln/1/@'.$account); |
|---|
| | 2675 | } elseif ($keyword == 'mailbox' && $data == '') { |
|---|
| | 2676 | $mgcpfields[] = array($account,'mailbox',$account.'@device'); |
|---|
| | 2677 | } else { |
|---|
| | 2678 | $mgcpfields[] = array($account, $keyword, $data); |
|---|
| | 2679 | } |
|---|
| | 2680 | } |
|---|
| | 2681 | } |
|---|
| | 2682 | |
|---|
| | 2683 | if ( !is_array($mgcpfields) ) { // left for compatibilty....lord knows why ! |
|---|
| | 2684 | $mgcpfields = array( |
|---|
| | 2685 | //array($account,'account',$account), |
|---|
| | 2686 | array($account,'type',($_REQUEST['context'])?$_REQUEST['context']:'friend'), |
|---|
| | 2687 | array($account,'host',(isset($_REQUEST['host']))?$_REQUEST['host']:'dynamic'), |
|---|
| | 2688 | array($account,'line',(isset($_REQUEST['line']))?$_REQUEST['line']:'aaln/1'), |
|---|
| | 2689 | array($account,'slowsequence',(isset($_REQUEST['slowsequence']))?$_REQUEST['slowsequence']:'yes'), |
|---|
| | 2690 | array($account,'dtmfmode',(isset($_REQUEST['dtmfmode']))?$_REQUEST['dtmfmode']:'rfc2833'), |
|---|
| | 2691 | array($account,'nat',(isset($_REQUEST['nat']))?$_REQUEST['nat']:'no'), |
|---|
| | 2692 | array($account,'disallow',(isset($_REQUEST['disallow']))?$_REQUEST['disallow']:'all'), |
|---|
| | 2693 | array($account,'allow',(isset($_REQUEST['allow']))?$_REQUEST['allow']:'ulaw'), |
|---|
| | 2694 | array($account,'context',(isset($_REQUEST['context']))?$_REQUEST['context']:'from-internal'), |
|---|
| | 2695 | array($account,'mailbox',($_REQUEST['mailbox'])?$_REQUEST['mailbox']:$account.'@device'), |
|---|
| | 2696 | array($account,'callgroup',(isset($_REQUEST['callgroup']))?$_REQUEST['callgroup']:''), |
|---|
| | 2697 | array($account,'pickupgroup',(isset($_REQUEST['pickupgroup']))?$_REQUEST['pickupgroup']:''), |
|---|
| | 2698 | array($account,'accountcode',(isset($_REQUEST['accountcode']))?$_REQUEST['accountcode']:'') |
|---|
| | 2699 | //array($account,'record_in',(isset($_REQUEST['record_in']))?$_REQUEST['record_in']:'On-Demand'), |
|---|
| | 2700 | //array($account,'record_out',(isset($_REQUEST['record_out']))?$_REQUEST['record_out']:'On-Demand'), |
|---|
| | 2701 | //array($account,'callerid',(isset($_REQUEST['description']))?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>') |
|---|
| | 2702 | ); |
|---|
| | 2703 | } |
|---|
| | 2704 | |
|---|
| | 2705 | // Very bad |
|---|
| | 2706 | $mgcpfields[] = array($account,'account',$account); |
|---|
| | 2707 | $mgcpfields[] = array($account,'callerid',(isset($_REQUEST['description']) && $_REQUEST['description'])?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>'); |
|---|
| | 2708 | |
|---|
| | 2709 | // Where is this in the interface ?????? |
|---|
| | 2710 | $mgcpfields[] = array($account,'record_in',($_REQUEST['record_in'])?$_REQUEST['record_in']:'On-Demand'); |
|---|
| | 2711 | $mgcpfields[] = array($account,'record_out',($_REQUEST['record_out'])?$_REQUEST['record_out']:'On-Demand'); |
|---|
| | 2712 | |
|---|
| | 2713 | $compiled = $db->prepare('INSERT INTO mgcp (id, keyword, data) values (?,?,?)'); |
|---|
| | 2714 | $result = $db->executeMultiple($compiled,$mgcpfields); |
|---|
| | 2715 | if(DB::IsError($result)) { |
|---|
| | 2716 | die_freepbx($result->getDebugInfo()."<br><br>".'error adding to mgcp table'); |
|---|
| | 2717 | } |
|---|
| | 2718 | } |
|---|
| | 2719 | |
|---|
| | 2720 | function core_devices_delmgcp($account) { |
|---|
| | 2721 | global $db; |
|---|
| | 2722 | global $currentFile; |
|---|
| | 2723 | |
|---|
| | 2724 | $sql = "DELETE FROM mgcp WHERE id = '$account'"; |
|---|
| | 2725 | $result = $db->query($sql); |
|---|
| | 2726 | |
|---|
| | 2727 | if(DB::IsError($result)) { |
|---|
| | 2728 | die_freepbx($result->getMessage().$sql); |
|---|
| | 2729 | } |
|---|
| | 2730 | } |
|---|
| | 2731 | |
|---|
| | 2732 | function core_devices_getmgcp($account) { |
|---|
| | 2733 | global $db; |
|---|
| | 2734 | $sql = "SELECT keyword,data FROM mgcp WHERE id = '$account'"; |
|---|
| | 2735 | $results = $db->getAssoc($sql); |
|---|
| | 2736 | if(DB::IsError($results)) { |
|---|
| | 2737 | $results = null; |
|---|
| | 2738 | } |
|---|
| | 2739 | |
|---|
| | 2740 | return $results; |
|---|
| | 2741 | } |
|---|
| | 2742 | |
|---|
| | 2743 | //add to skinny table |
|---|
| | 2744 | function core_devices_addskinny($account) { |
|---|
| | 2745 | global $db; |
|---|
| | 2746 | global $currentFile; |
|---|
| | 2747 | |
|---|
| | 2748 | foreach ($_REQUEST as $req=>$data) { |
|---|
| | 2749 | if ( substr($req, 0, 8) == 'devinfo_' ) { |
|---|
| | 2750 | $keyword = substr($req, 8); |
|---|
| | 2751 | if ( $keyword == 'dial' && $data == '' ) { |
|---|
| | 2752 | $skinnyfields[] = array($account, $keyword, 'skinny/'.$line."@".$account); |
|---|
| | 2753 | } elseif ($keyword == 'mailbox' && $data == '') { |
|---|
| | 2754 | $skinnyfields[] = array($account,'mailbox',$account.'@device'); |
|---|
| | 2755 | } else { |
|---|
| | 2756 | $skinnyfields[] = array($account, $keyword, $data); |
|---|
| | 2757 | } |
|---|
| | 2758 | } |
|---|
| | 2759 | } |
|---|
| | 2760 | |
|---|
| | 2761 | if ( !is_array($skinnyfields) ) { // left for compatibilty....lord knows why ! |
|---|
| | 2762 | $skinnyfields = array( |
|---|
| | 2763 | //array($account,'account',$account), |
|---|
| | 2764 | array($account,'secret',($_REQUEST['secret'])?$_REQUEST['secret']:''), |
|---|
| | 2765 | array($account,'type',($_REQUEST['context'])?$_REQUEST['context']:'friend'), |
|---|
| | 2766 | array($account,'host',(isset($_REQUEST['host']))?$_REQUEST['host']:'dynamic'), |
|---|
| | 2767 | array($account,'model',(isset($_REQUEST['model']))?$_REQUEST['model']:'79xx'), |
|---|
| | 2768 | array($account,'device',(isset($_REQUEST['device']))?$_REQUEST['device']:'SEP0007EBxxxxxx'), |
|---|
| | 2769 | array($account,'version',(isset($_REQUEST['version']))?$_REQUEST['version']:'P03-08-02'), |
|---|
| | 2770 | array($account,'permit',(isset($_REQUEST['permit']))?$_REQUEST['permit']:'0.0.0.0/0.0.0.0'), |
|---|
| | 2771 | array($account,'line',(isset($_REQUEST['line']))?$_REQUEST['line']:''), |
|---|
| | 2772 | array($account,'linelabel',(isset($_REQUEST['linelabel']))?$_REQUEST['linelabel']:''), |
|---|
| | 2773 | array($account,'context',(isset($_REQUEST['context']))?$_REQUEST['context']:'from-internal'), |
|---|
| | 2774 | array($account,'nat',(isset($_REQUEST['nat']))?$_REQUEST['nat']:'no'), |
|---|
| | 2775 | array($account,'dtmfmode',(isset($_REQUEST['dtmfmode']))?$_REQUEST['dtmfmode']:'inband'), |
|---|
| | 2776 | array($account,'disallow',(isset($_REQUEST['disallow']))?$_REQUEST['disallow']:'all'), |
|---|
| | 2777 | array($account,'allow',(isset($_REQUEST['allow']))?$_REQUEST['allow']:''), |
|---|
| | 2778 | array($account,'mailbox',($_REQUEST['mailbox'])?$_REQUEST['mailbox']:$account.'@device'), |
|---|
| | 2779 | array($account,'callwaiting',($_REQUEST['callwaiting'])?$_REQUEST['callwaiting']:'1'), |
|---|
| | 2780 | array($account,'transfer',($_REQUEST['transfer'])?$_REQUEST['transfer']:'1'), |
|---|
| | 2781 | array($account,'threewaycalling',($_REQUEST['threewaycalling'])?$_REQUEST['threewaycalling']:'1'), |
|---|
| | 2782 | array($account,'callgroup',(isset($_REQUEST['callgroup']))?$_REQUEST['callgroup']:''), |
|---|
| | 2783 | array($account,'pickupgroup',(isset($_REQUEST['pickupgroup']))?$_REQUEST['pickupgroup']:''), |
|---|
| | 2784 | array($account,'accountcode',(isset($_REQUEST['accountcode']))?$_REQUEST['accountcode']:'') |
|---|
| | 2785 | //array($account,'record_in',(isset($_REQUEST['record_in']))?$_REQUEST['record_in']:'On-Demand'), |
|---|
| | 2786 | //array($account,'record_out',(isset($_REQUEST['record_out']))?$_REQUEST['record_out']:'On-Demand'), |
|---|
| | 2787 | //array($account,'callerid',(isset($_REQUEST['description']))?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>') |
|---|
| | 2788 | ); |
|---|
| | 2789 | } |
|---|
| | 2790 | |
|---|
| | 2791 | // Very bad |
|---|
| | 2792 | $skinnyfields[] = array($account,'account',$account); |
|---|
| | 2793 | $skinnyfields[] = array($account,'callerid',(isset($_REQUEST['description']) && $_REQUEST['description'])?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>'); |
|---|
| | 2794 | |
|---|
| | 2795 | // Where is this in the interface ?????? |
|---|
| | 2796 | $skinnyfields[] = array($account,'record_in',($_REQUEST['record_in'])?$_REQUEST['record_in']:'On-Demand'); |
|---|
| | 2797 | $skinnyfields[] = array($account,'record_out',($_REQUEST['record_out'])?$_REQUEST['record_out']:'On-Demand'); |
|---|
| | 2798 | |
|---|
| | 2799 | $compiled = $db->prepare('INSERT INTO skinny (id, keyword, data) values (?,?,?)'); |
|---|
| | 2800 | $result = $db->executeMultiple($compiled,$skinnyfields); |
|---|
| | 2801 | if(DB::IsError($result)) { |
|---|
| | 2802 | die_freepbx($result->getDebugInfo()."<br><br>".'error adding to skinny table'); |
|---|
| | 2803 | } |
|---|
| | 2804 | } |
|---|
| | 2805 | |
|---|
| | 2806 | function core_devices_delskinny($account) { |
|---|
| | 2807 | global $db; |
|---|
| | 2808 | global $currentFile; |
|---|
| | 2809 | |
|---|
| | 2810 | $sql = "DELETE FROM skinny WHERE id = '$account'"; |
|---|
| | 2811 | $result = $db->query($sql); |
|---|
| | 2812 | |
|---|
| | 2813 | if(DB::IsError($result)) { |
|---|
| | 2814 | die_freepbx($result->getMessage().$sql); |
|---|
| | 2815 | } |
|---|
| | 2816 | } |
|---|
| | 2817 | |
|---|
| | 2818 | function core_devices_getskinny($account) { |
|---|
| | 2819 | global $db; |
|---|
| | 2820 | $sql = "SELECT keyword,data FROM skinny WHERE id = '$account'"; |
|---|
| | 2821 | $results = $db->getAssoc($sql); |
|---|
| | 2822 | if(DB::IsError($results)) { |
|---|
| | 2823 | $results = null; |
|---|
| | 2824 | } |
|---|
| | 2825 | |
|---|
| | 2826 | return $results; |
|---|
| | 2827 | } |
|---|
| | 2828 | |
|---|
| | 4890 | // mgcp |
|---|
| | 4891 | $tmparr = array(); |
|---|
| | 4892 | $tmparr['host'] = array('value' => 'dynamic', 'level' => 1); |
|---|
| | 4893 | $tmparr['type'] = array('value' => 'friend', 'level' => 1); |
|---|
| | 4894 | $tmparr['wcardep'] = array('value' => '*', 'level' => 1); |
|---|
| | 4895 | $tmparr['slowsequence'] = array('value' => 'yes', 'level' => 1); |
|---|
| | 4896 | $tmparr['line'] = array('value' => '', 'level' => 0); |
|---|
| | 4897 | $tmparr['dial'] = array('value' => '', 'level' => 0); |
|---|
| | 4898 | $tmparr['dtmfmode'] = array('value' => 'rfc2833', 'level' => 1); |
|---|
| | 4899 | $tmparr['context'] = array('value' => 'from-internal', 'level' => 1); |
|---|
| | 4900 | $tmparr['canreinvite'] = array('value' => 'no', 'level' => 1); |
|---|
| | 4901 | $tmparr['nat'] = array('value' => 'no', 'level' => 1); |
|---|
| | 4902 | $tmparr['callgroup'] = array('value' => '', 'level' => 1); |
|---|
| | 4903 | $tmparr['pickupgroup'] = array('value' => '', 'level' => 1); |
|---|
| | 4904 | $tmparr['disallow'] = array('value' => 'all', 'level' => 1); |
|---|
| | 4905 | $tmparr['allow'] = array('value' => 'ulaw', 'level' => 1); |
|---|
| | 4906 | $tmparr['accountcode'] = array('value' => '', 'level' => 1); |
|---|
| | 4907 | $tmparr['mailbox'] = array('value' => '', 'level' => 1); |
|---|
| | 4908 | $currentcomponent->addgeneralarrayitem('devtechs', 'mgcp', $tmparr); |
|---|
| | 4909 | unset($tmparr); |
|---|
| | 4910 | |
|---|
| | 4911 | // skinny |
|---|
| | 4912 | $tmparr = array(); |
|---|
| | 4913 | $tmparr['secret'] = array('value' => '', 'level' => 0, 'jsvalidation' => 'isEmpty() && !confirm("'.$msgConfirmSecret.'")', 'failvalidationmsg' => $msgInvalidSecret); |
|---|
| | 4914 | $tmparr['host'] = array('value' => 'dynamic', 'level' => 0); |
|---|
| | 4915 | $tmparr['type'] = array('value' => 'friend', 'level' => 1); |
|---|
| | 4916 | $tmparr['model'] = array('value' => '79xx', 'level' => 0); |
|---|
| | 4917 | $tmparr['device'] = array('value' => 'SEP0007EBxxxxxx', 'level' => 0); |
|---|
| | 4918 | $tmparr['version'] = array('value' => 'P03-0x-0x', 'level' => 0); |
|---|
| | 4919 | $tmparr['permit'] = array('value' => '', 'level' => 0); |
|---|
| | 4920 | $tmparr['line'] = array('value' => '', 'level' => 0); |
|---|
| | 4921 | $tmparr['linelabel'] = array('value' => '', 'level' => 0); |
|---|
| | 4922 | $tmparr['dial'] = array('value' => '', 'level' => 0); |
|---|
| | 4923 | $tmparr['dtmfmode'] = array('value' => 'rfc2833', 'level' => 1); |
|---|
| | 4924 | $tmparr['context'] = array('value' => 'from-internal', 'level' => 1); |
|---|
| | 4925 | $tmparr['canreinvite'] = array('value' => 'no', 'level' => 1); |
|---|
| | 4926 | $tmparr['nat'] = array('value' => 'no', 'level' => 1); |
|---|
| | 4927 | $tmparr['callgroup'] = array('value' => '', 'level' => 1); |
|---|
| | 4928 | $tmparr['pickupgroup'] = array('value' => '', 'level' => 1); |
|---|
| | 4929 | $tmparr['callwaiting'] = array('value' => '', 'level' => 1); |
|---|
| | 4930 | $tmparr['transfer'] = array('value' => '', 'level' => 1); |
|---|
| | 4931 | $tmparr['threewaycalling'] = array('value' => '', 'level' => 1); |
|---|
| | 4932 | $tmparr['disallow'] = array('value' => 'all', 'level' => 1); |
|---|
| | 4933 | $tmparr['allow'] = array('value' => 'ulaw', 'level' => 1); |
|---|
| | 4934 | $tmparr['mailbox'] = array('value' => '', 'level' => 1); |
|---|
| | 4935 | $tmparr['accountcode'] = array('value' => '', 'level' => 1); |
|---|
| | 4936 | |
|---|
| | 4937 | $currentcomponent->addgeneralarrayitem('devtechs', 'skinny', $tmparr); |
|---|
| | 4938 | unset($tmparr); |
|---|
| | 4939 | |
|---|