| | 3644 | |
|---|
| | 3645 | function _module_distro_id() { |
|---|
| | 3646 | static $pbx_type; |
|---|
| | 3647 | static $pbx_version; |
|---|
| | 3648 | |
|---|
| | 3649 | if (isset($pbx_type)) { |
|---|
| | 3650 | return array('pbx_type' => $pbx_type, 'pbx_version' => $pbx_version); |
|---|
| | 3651 | } |
|---|
| | 3652 | |
|---|
| | 3653 | // FreePBX Distro |
|---|
| | 3654 | if (file_exists('/etc/asterisk/freepbxdistro-version')) { |
|---|
| | 3655 | $pbx_type = 'freepbxdistro'; |
|---|
| | 3656 | $pbx_version = trim(file_get_contents('/etc/asterisk/freepbxdistro-version')); |
|---|
| | 3657 | |
|---|
| | 3658 | // Trixbox |
|---|
| | 3659 | } elseif (file_exists('/etc/trixbox/trixbox-version')) { |
|---|
| | 3660 | $pbx_type = 'trixbox'; |
|---|
| | 3661 | $pbx_version = trim(file_get_contents('/etc/trixbox/trixbox-version')); |
|---|
| | 3662 | |
|---|
| | 3663 | // AsteriskNOW |
|---|
| | 3664 | } elseif (file_exists('/etc/asterisknow-version')) { |
|---|
| | 3665 | $pbx_type = 'asterisknow'; |
|---|
| | 3666 | $pbx_version = trim(file_get_contents('/etc/asterisknow-version')); |
|---|
| | 3667 | |
|---|
| | 3668 | // Elastix |
|---|
| | 3669 | } elseif (is_dir('/usr/share/elastix') || file_exists('/usr/share/elastix/pre_elastix_version.info')) { |
|---|
| | 3670 | $pbx_type = 'elastix'; |
|---|
| | 3671 | $pbx_version = ''; |
|---|
| | 3672 | if (class_exists('PDO') && file_exists('/var/www/db/settings.db')) { |
|---|
| | 3673 | $elastix_db = new PDO('sqlite:/var/www/db/settings.db'); |
|---|
| | 3674 | $result = $elastix_db->query("SELECT value FROM settings WHERE key='elastix_version_release'"); |
|---|
| | 3675 | if ($result !== false) foreach ($result as $row) { |
|---|
| | 3676 | if (isset($row['value'])) { |
|---|
| | 3677 | $pbx_version = $row['value']; |
|---|
| | 3678 | break; |
|---|
| | 3679 | } |
|---|
| | 3680 | } |
|---|
| | 3681 | } |
|---|
| | 3682 | if (!$pbx_version && file_exists('/usr/share/elastix/pre_elastix_version.info')) { |
|---|
| | 3683 | $pbx_version = trim(file_get_contents('/usr/share/elastix/pre_elastix_version.info')); |
|---|
| | 3684 | } |
|---|
| | 3685 | if (!$pbx_version) { |
|---|
| | 3686 | $pbx_version = '2.X+'; |
|---|
| | 3687 | } |
|---|
| | 3688 | |
|---|
| | 3689 | // PIAF |
|---|
| | 3690 | } elseif (file_exists('/etc/pbx/.version') || file_exists('/etc/pbx/.color')) { |
|---|
| | 3691 | $pbx_type = 'piaf'; |
|---|
| | 3692 | $pbx_version = ''; |
|---|
| | 3693 | if (file_exists('/etc/pbx/.version')) { |
|---|
| | 3694 | $pbx_version = trim(file_get_contents('/etc/pbx/.version')); |
|---|
| | 3695 | } |
|---|
| | 3696 | if (file_exists('/etc/pbx/.color')) { |
|---|
| | 3697 | $pbx_version .= '.' . trim(file_get_contents('/etc/pbx/.color')); |
|---|
| | 3698 | } |
|---|
| | 3699 | if (!$pbx_version) { |
|---|
| | 3700 | if (file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3701 | $pbx_ver_raw = trim(file_get_contents('/etc/pbx/ISO-Version')); |
|---|
| | 3702 | $pbx_arr = explode('=',$pbx_ver_raw); |
|---|
| | 3703 | $pbx_version = $pbx_arr[count($pbx_arr)-1]; |
|---|
| | 3704 | } else { |
|---|
| | 3705 | $pbx_version = 'unknown'; |
|---|
| | 3706 | } |
|---|
| | 3707 | } |
|---|
| | 3708 | |
|---|
| | 3709 | // Old PIAF or Fonica |
|---|
| | 3710 | } elseif (file_exists('/etc/pbx/version') || file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3711 | $pbx_type = 'fonica'; |
|---|
| | 3712 | if (file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3713 | $pbx_ver_raw = trim(file_get_contents('/etc/pbx/ISO-Version')); |
|---|
| | 3714 | $pbx_arr = explode('=',$pbx_ver_raw); |
|---|
| | 3715 | $pbx_version = $pbx_arr[count($pbx_arr)-1]; |
|---|
| | 3716 | if (stristr($pbx_arr[0],'foncordiax') !== false) { |
|---|
| | 3717 | $pbx_version .= '.pro'; |
|---|
| | 3718 | } else { |
|---|
| | 3719 | $pbx_version = str_replace(' ','.',$pbx_version); |
|---|
| | 3720 | if ($pbx_version != '1.0.standard') { |
|---|
| | 3721 | $pbx_type = 'piaf'; |
|---|
| | 3722 | } |
|---|
| | 3723 | } |
|---|
| | 3724 | } else { |
|---|
| | 3725 | $pbx_version = 'unknown'; |
|---|
| | 3726 | } |
|---|
| | 3727 | } else { |
|---|
| | 3728 | $pbx_type = 'unknown'; |
|---|
| | 3729 | $pbx_version = 'unknown'; |
|---|
| | 3730 | } |
|---|
| | 3731 | return array('pbx_type' => $pbx_type, 'pbx_version' => $pbx_version); |
|---|
| | 3732 | } |
|---|