| | 3445 | |
|---|
| | 3446 | function _module_distro_id() { |
|---|
| | 3447 | static $pbx_type; |
|---|
| | 3448 | static $pbx_version; |
|---|
| | 3449 | |
|---|
| | 3450 | if (isset($pbx_type)) { |
|---|
| | 3451 | return array('pbx_type' => $pbx_type, 'pbx_version' => $pbx_version); |
|---|
| | 3452 | } |
|---|
| | 3453 | |
|---|
| | 3454 | // FreePBX Distro |
|---|
| | 3455 | if (file_exists('/etc/asterisk/freepbxdistro-version')) { |
|---|
| | 3456 | $pbx_type = 'freepbxdistro'; |
|---|
| | 3457 | $pbx_version = trim(file_get_contents('/etc/asterisk/freepbxdistro-version')); |
|---|
| | 3458 | |
|---|
| | 3459 | // Trixbox |
|---|
| | 3460 | } elseif (file_exists('/etc/trixbox/trixbox-version')) { |
|---|
| | 3461 | $pbx_type = 'trixbox'; |
|---|
| | 3462 | $pbx_version = trim(file_get_contents('/etc/trixbox/trixbox-version')); |
|---|
| | 3463 | |
|---|
| | 3464 | // AsteriskNOW |
|---|
| | 3465 | } elseif (file_exists('/etc/asterisknow-version')) { |
|---|
| | 3466 | $pbx_type = 'asterisknow'; |
|---|
| | 3467 | $pbx_version = trim(file_get_contents('/etc/asterisknow-version')); |
|---|
| | 3468 | |
|---|
| | 3469 | // Elastix |
|---|
| | 3470 | } elseif (is_dir('/usr/share/elastix') || file_exists('/usr/share/elastix/pre_elastix_version.info')) { |
|---|
| | 3471 | $pbx_type = 'elastix'; |
|---|
| | 3472 | $pbx_version = ''; |
|---|
| | 3473 | if (class_exists('PDO') && file_exists('/var/www/db/settings.db')) { |
|---|
| | 3474 | $elastix_db = new PDO('sqlite:/var/www/db/settings.db'); |
|---|
| | 3475 | $result = $elastix_db->query("SELECT value FROM settings WHERE key='elastix_version_release'"); |
|---|
| | 3476 | if ($result !== false) foreach ($result as $row) { |
|---|
| | 3477 | if (isset($row['value'])) { |
|---|
| | 3478 | $pbx_version = $row['value']; |
|---|
| | 3479 | break; |
|---|
| | 3480 | } |
|---|
| | 3481 | } |
|---|
| | 3482 | } |
|---|
| | 3483 | if (!$pbx_version && file_exists('/usr/share/elastix/pre_elastix_version.info')) { |
|---|
| | 3484 | $pbx_version = trim(file_get_contents('/usr/share/elastix/pre_elastix_version.info')); |
|---|
| | 3485 | } |
|---|
| | 3486 | if (!$pbx_version) { |
|---|
| | 3487 | $pbx_version = '2.X+'; |
|---|
| | 3488 | } |
|---|
| | 3489 | |
|---|
| | 3490 | // PIAF |
|---|
| | 3491 | } elseif (file_exists('/etc/pbx/.version') || file_exists('/etc/pbx/.color')) { |
|---|
| | 3492 | $pbx_type = 'piaf'; |
|---|
| | 3493 | $pbx_version = ''; |
|---|
| | 3494 | if (file_exists('/etc/pbx/.version')) { |
|---|
| | 3495 | $pbx_version = trim(file_get_contents('/etc/pbx/.version')); |
|---|
| | 3496 | } |
|---|
| | 3497 | if (file_exists('/etc/pbx/.color')) { |
|---|
| | 3498 | $pbx_version .= '.' . trim(file_get_contents('/etc/pbx/.color')); |
|---|
| | 3499 | } |
|---|
| | 3500 | if (!$pbx_version) { |
|---|
| | 3501 | if (file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3502 | $pbx_ver_raw = trim(file_get_contents('/etc/pbx/ISO-Version')); |
|---|
| | 3503 | $pbx_arr = explode('=',$pbx_ver_raw); |
|---|
| | 3504 | $pbx_version = $pbx_arr[count($pbx_arr)-1]; |
|---|
| | 3505 | } else { |
|---|
| | 3506 | $pbx_version = 'unknown'; |
|---|
| | 3507 | } |
|---|
| | 3508 | } |
|---|
| | 3509 | |
|---|
| | 3510 | // Old PIAF or Fonica |
|---|
| | 3511 | } elseif (file_exists('/etc/pbx/version') || file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3512 | $pbx_type = 'fonica'; |
|---|
| | 3513 | if (file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3514 | $pbx_ver_raw = trim(file_get_contents('/etc/pbx/ISO-Version')); |
|---|
| | 3515 | $pbx_arr = explode('=',$pbx_ver_raw); |
|---|
| | 3516 | $pbx_version = $pbx_arr[count($pbx_arr)-1]; |
|---|
| | 3517 | if (stristr($pbx_arr[0],'foncordiax') !== false) { |
|---|
| | 3518 | $pbx_version .= '.pro'; |
|---|
| | 3519 | } else { |
|---|
| | 3520 | $pbx_version = str_replace(' ','.',$pbx_version); |
|---|
| | 3521 | if ($pbx_version != '1.0.standard') { |
|---|
| | 3522 | $pbx_type = 'piaf'; |
|---|
| | 3523 | } |
|---|
| | 3524 | } |
|---|
| | 3525 | } else { |
|---|
| | 3526 | $pbx_version = 'unknown'; |
|---|
| | 3527 | } |
|---|
| | 3528 | } else { |
|---|
| | 3529 | $pbx_type = 'unknown'; |
|---|
| | 3530 | $pbx_version = 'unknown'; |
|---|
| | 3531 | } |
|---|
| | 3532 | return array('pbx_type' => $pbx_type, 'pbx_version' => $pbx_version); |
|---|
| | 3533 | } |
|---|