| | 3039 | |
|---|
| | 3040 | function _module_distro_id() { |
|---|
| | 3041 | static $pbx_type; |
|---|
| | 3042 | static $pbx_version; |
|---|
| | 3043 | |
|---|
| | 3044 | if (isset($pbx_type)) { |
|---|
| | 3045 | return array('pbx_type' => $pbx_type, 'pbx_version' => $pbx_version); |
|---|
| | 3046 | } |
|---|
| | 3047 | |
|---|
| | 3048 | // FreePBX Distro |
|---|
| | 3049 | if (file_exists('/etc/asterisk/freepbxdistro-version')) { |
|---|
| | 3050 | $pbx_type = 'freepbxdistro'; |
|---|
| | 3051 | $pbx_version = trim(file_get_contents('/etc/asterisk/freepbxdistro-version')); |
|---|
| | 3052 | |
|---|
| | 3053 | // Trixbox |
|---|
| | 3054 | } elseif (file_exists('/etc/trixbox/trixbox-version')) { |
|---|
| | 3055 | $pbx_type = 'trixbox'; |
|---|
| | 3056 | $pbx_version = trim(file_get_contents('/etc/trixbox/trixbox-version')); |
|---|
| | 3057 | |
|---|
| | 3058 | // AsteriskNOW |
|---|
| | 3059 | } elseif (file_exists('/etc/asterisknow-version')) { |
|---|
| | 3060 | $pbx_type = 'asterisknow'; |
|---|
| | 3061 | $pbx_version = trim(file_get_contents('/etc/asterisknow-version')); |
|---|
| | 3062 | |
|---|
| | 3063 | // Elastix |
|---|
| | 3064 | } elseif (is_dir('/usr/share/elastix') || file_exists('/usr/share/elastix/pre_elastix_version.info')) { |
|---|
| | 3065 | $pbx_type = 'elastix'; |
|---|
| | 3066 | $pbx_version = ''; |
|---|
| | 3067 | if (class_exists('PDO') && file_exists('/var/www/db/settings.db')) { |
|---|
| | 3068 | $elastix_db = new PDO('sqlite:/var/www/db/settings.db'); |
|---|
| | 3069 | $result = $elastix_db->query("SELECT value FROM settings WHERE key='elastix_version_release'"); |
|---|
| | 3070 | if ($result !== false) foreach ($result as $row) { |
|---|
| | 3071 | if (isset($row['value'])) { |
|---|
| | 3072 | $pbx_version = $row['value']; |
|---|
| | 3073 | break; |
|---|
| | 3074 | } |
|---|
| | 3075 | } |
|---|
| | 3076 | } |
|---|
| | 3077 | if (!$pbx_version && file_exists('/usr/share/elastix/pre_elastix_version.info')) { |
|---|
| | 3078 | $pbx_version = trim(file_get_contents('/usr/share/elastix/pre_elastix_version.info')); |
|---|
| | 3079 | } |
|---|
| | 3080 | if (!$pbx_version) { |
|---|
| | 3081 | $pbx_version = '2.X+'; |
|---|
| | 3082 | } |
|---|
| | 3083 | |
|---|
| | 3084 | // PIAF |
|---|
| | 3085 | } elseif (file_exists('/etc/pbx/.version') || file_exists('/etc/pbx/.color')) { |
|---|
| | 3086 | $pbx_type = 'piaf'; |
|---|
| | 3087 | $pbx_version = ''; |
|---|
| | 3088 | if (file_exists('/etc/pbx/.version')) { |
|---|
| | 3089 | $pbx_version = trim(file_get_contents('/etc/pbx/.version')); |
|---|
| | 3090 | } |
|---|
| | 3091 | if (file_exists('/etc/pbx/.color')) { |
|---|
| | 3092 | $pbx_version .= '.' . trim(file_get_contents('/etc/pbx/.color')); |
|---|
| | 3093 | } |
|---|
| | 3094 | if (!$pbx_version) { |
|---|
| | 3095 | if (file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3096 | $pbx_ver_raw = trim(file_get_contents('/etc/pbx/ISO-Version')); |
|---|
| | 3097 | $pbx_arr = explode('=',$pbx_ver_raw); |
|---|
| | 3098 | $pbx_version = $pbx_arr[count($pbx_arr)-1]; |
|---|
| | 3099 | } else { |
|---|
| | 3100 | $pbx_version = 'unknown'; |
|---|
| | 3101 | } |
|---|
| | 3102 | } |
|---|
| | 3103 | |
|---|
| | 3104 | // Old PIAF or Fonica |
|---|
| | 3105 | } elseif (file_exists('/etc/pbx/version') || file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3106 | $pbx_type = 'fonica'; |
|---|
| | 3107 | if (file_exists('/etc/pbx/ISO-Version')) { |
|---|
| | 3108 | $pbx_ver_raw = trim(file_get_contents('/etc/pbx/ISO-Version')); |
|---|
| | 3109 | $pbx_arr = explode('=',$pbx_ver_raw); |
|---|
| | 3110 | $pbx_version = $pbx_arr[count($pbx_arr)-1]; |
|---|
| | 3111 | if (stristr($pbx_arr[0],'foncordiax') !== false) { |
|---|
| | 3112 | $pbx_version .= '.pro'; |
|---|
| | 3113 | } else { |
|---|
| | 3114 | $pbx_version = str_replace(' ','.',$pbx_version); |
|---|
| | 3115 | if ($pbx_version != '1.0.standard') { |
|---|
| | 3116 | $pbx_type = 'piaf'; |
|---|
| | 3117 | } |
|---|
| | 3118 | } |
|---|
| | 3119 | } else { |
|---|
| | 3120 | $pbx_version = 'unknown'; |
|---|
| | 3121 | } |
|---|
| | 3122 | } else { |
|---|
| | 3123 | $pbx_type = 'unknown'; |
|---|
| | 3124 | $pbx_version = 'unknown'; |
|---|
| | 3125 | } |
|---|
| | 3126 | return array('pbx_type' => $pbx_type, 'pbx_version' => $pbx_version); |
|---|
| | 3127 | } |
|---|