| | 3571 | |
|---|
| | 3572 | function _module_distro_id() { |
|---|
| | 3573 | static $pbx_type; |
|---|
| | 3574 | static $pbx_version; |
|---|
| | 3575 | |
|---|
| | 3576 | if (isset($pbx_type)) { |
|---|
| | 3577 | return array('pbx_type' => $pbx_type, 'pbx_version' => $pbx_version); |
|---|
| | 3578 | } |
|---|
| | 3579 | |
|---|
| | 3580 | // FreePBX Distro |
|---|
| | 3581 | if (file_exists('/etc/asterisk/freepbxdistro-version')) { |
|---|
| | 3582 | $pbx_type = 'freepbxdistro'; |
|---|
| | 3583 | $pbx_version = trim(file_get_contents('/etc/asterisk/freepbxdistro-version')); |
|---|
| | 3584 | |
|---|
| | 3585 | // Trixbox |
|---|
| | 3586 | } elseif (file_exists('/etc/trixbox/trixbox-version')) { |
|---|
| | 3587 | $pbx_type = 'trixbox'; |
|---|
| | 3588 | $pbx_version = trim(file_get_contents('/etc/trixbox/trixbox-version')); |
|---|
| | 3589 | |
|---|
| | 3590 | // AsteriskNOW |
|---|
| | 3591 | } elseif (file_exists('/etc/asterisknow-version')) { |
|---|
| | 3592 | $pbx_type = 'asterisknow'; |
|---|
| | 3593 | $pbx_version = trim(file_get_contents('/etc/asterisknow-version')); |
|---|
| | 3594 | |
|---|
| | 3595 | // Elastix |
|---|
| | 3596 | } elseif (is_dir('/usr/share/elastix') || file_exists('/usr/share/elastix/pre_elastix_version.info')) { |
|---|
| | 3597 | $pbx_type = 'elastix'; |
|---|
| | 3598 | $pbx_version = ''; |
|---|
| | 3599 | if (class_exists('PDO') && file_exists('/var/www/db/settings.db')) { |
|---|
| | 3600 | $elastix_db = new PDO('sqlite:/var/www/db/settings.db'); |
|---|
| | 3601 | $result = $elastix_db->query("SELECT value FROM settings WHERE key='elastix_version_release'"); |
|---|
| | 3602 | if ($result !== false) foreach ($result as $row) { |
|---|
| | 3603 | if (isset($row['value'])) { |
|---|
| | 3604 | $pbx_version = $row['value']; |
|---|
| | 3605 | break; |
|---|
| | 3606 | } |
|---|
| | 3607 | } |
|---|
| | 3608 | } |
|---|
| | 3609 | if (!$pbx_version && file_exists('/usr/share/elastix/pre_elastix_version.info')) { |
|---|
| | 3610 | $pbx_version = trim(file_get_contents('/usr/share/elastix/pre_elastix_version.info')); |
|---|
| | 3611 | } |
|---|
| | 3612 | if (!$pbx_version) { |
|---|
| | 3613 | $pbx_version = '2.X+'; |
|---|
| | 3614 | } |
|---|
| | 3615 | |
|---|
| | 3616 | // PIAF |
|---|
| | 3617 | } elseif (file_exists('/etc/pbx/.version') || file_exists('/etc/pbx/.color')) { |
|---|
| | 3618 | $pbx_type = 'piaf'; |
|---|
| | 3619 | $pbx_version = ''; |
|---|
| | 3620 | if (file_exists('/etc/pbx/.version')) { |
|---|
| | 3621 | $pbx_version = trim(file_get_contents('/etc/pbx/.version')); |
|---|
| | 3622 | } |
|---|
| | 3623 | if (file_exists('/etc/pbx/.color')) { |
|---|
| | 3624 | $pbx_version .= '.' . trim(file_get_contents('/etc/pbx/.color')); |
|---|
| | 3625 | } |
|---|
| | 3626 | if (!$pbx_version) { |
|---|
| | 3627 | if (file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3628 | $pbx_ver_raw = trim(file_get_contents('/etc/pbx/ISO-Version')); |
|---|
| | 3629 | $pbx_arr = explode('=',$pbx_ver_raw); |
|---|
| | 3630 | $pbx_version = $pbx_arr[count($pbx_arr)-1]; |
|---|
| | 3631 | } else { |
|---|
| | 3632 | $pbx_version = 'unknown'; |
|---|
| | 3633 | } |
|---|
| | 3634 | } |
|---|
| | 3635 | |
|---|
| | 3636 | // Old PIAF or Fonica |
|---|
| | 3637 | } elseif (file_exists('/etc/pbx/version') || file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3638 | $pbx_type = 'fonica'; |
|---|
| | 3639 | if (file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3640 | $pbx_ver_raw = trim(file_get_contents('/etc/pbx/ISO-Version')); |
|---|
| | 3641 | $pbx_arr = explode('=',$pbx_ver_raw); |
|---|
| | 3642 | $pbx_version = $pbx_arr[count($pbx_arr)-1]; |
|---|
| | 3643 | if (stristr($pbx_arr[0],'foncordiax') !== false) { |
|---|
| | 3644 | $pbx_version .= '.pro'; |
|---|
| | 3645 | } else { |
|---|
| | 3646 | $pbx_version = str_replace(' ','.',$pbx_version); |
|---|
| | 3647 | if ($pbx_version != '1.0.standard') { |
|---|
| | 3648 | $pbx_type = 'piaf'; |
|---|
| | 3649 | } |
|---|
| | 3650 | } |
|---|
| | 3651 | } else { |
|---|
| | 3652 | $pbx_version = 'unknown'; |
|---|
| | 3653 | } |
|---|
| | 3654 | } else { |
|---|
| | 3655 | $pbx_type = 'unknown'; |
|---|
| | 3656 | $pbx_version = 'unknown'; |
|---|
| | 3657 | } |
|---|
| | 3658 | return array('pbx_type' => $pbx_type, 'pbx_version' => $pbx_version); |
|---|
| | 3659 | } |
|---|