Changeset 11299
- Timestamp:
- 02/05/11 18:01:45 (2 years ago)
- Files:
-
- contributed_modules/modules/extcfg/astman.inc (modified) (1 diff)
- contributed_modules/modules/extcfg/functions.inc.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
contributed_modules/modules/extcfg/astman.inc
r7577 r11299 279 279 } 280 280 } 281 ?>contributed_modules/modules/extcfg/functions.inc.php
r7577 r11299 26 26 define("CFIM", "CF"); 27 27 define("YAC", "YAC"); 28 define("DND", "DND"); 28 29 29 30 require("astman.inc"); 30 31 31 32 function extcfg_init(){ 32 global $server; 33 global $server, $amp_conf; 34 33 35 /* mysql_connect('localhost', 'asteriskuser', 'amp109') or die ("Could not connect to MySQL"); 34 36 mysql_select_db('asterisk') or die ("Could not select asterisk database" . mysql_error()); … … 51 53 $i++; 52 54 } 55 53 56 */ 54 57 55 58 $server[] = array( 56 "db_host" => "localhost",57 "db_user" => "asteriskuser",58 "db_passwd" => "amp109",59 "db_db" => "asterisk",60 "astman_host" => "localhost",61 "astman_user" => "admin",62 "astman_passwd" => "amp111",63 "name" => " mlin1",59 "db_host" => $amp_conf['AMPDBHOST'], 60 "db_user" => $amp_conf['AMPDBUSER'], 61 "db_passwd" => $amp_conf['AMPDBPASS'], 62 "db_db" => $amp_conf['AMPDBNAME'], 63 "astman_host" => 'localhost', 64 "astman_user" => $amp_conf['AMPMGRUSER'], 65 "astman_passwd" => $amp_conf['AMPMGRPASS'], 66 "name" => "localhost", 64 67 "astman" => new AstMan 65 68 ); … … 110 113 sort($exts); 111 114 112 echo "<table border='0' cellspacing='0' cellpadding='3' ><tr><th>Ext</th><th>DND</th><th>Call<br>Waiting</th><th>Call Forward<br>All</th><th>Call Forward<br>Busy</th><th>Call Forward<br>No Answer</th><th>IP</th><th>port</th><th>Status</th><th>Device</th><th>Tech</th></tr>";115 echo "<table border='0' cellspacing='0' cellpadding='3' style=''><tr><th></th><th>Extension</th><th>DND</th><th>Call<br>Waiting</th><th>Call Forward<br>All</th><th>Call Forward<br>Busy</th><th>Call Forward<br>No Answer</th><th>IP</th><th>port</th><th>Status</th><th>Device</th><th>Tech</th></tr>"; 113 116 114 117 foreach($exts as $ext){ 115 $status_bg = $status_arr[$ext[0]]['ok'] ? '#8f8' : '#f88'; 118 $status_bg = $status_arr[$ext[0]]['ok'] ? '#88ff88' : '#ff8888'; 119 $dnd_f = empty($dnd[$ext[1]][$ext[0]]) ? '' : '<img src="/admin/images/accept.png" border="0">'; 120 $cw_f = ''; 121 if(!empty($cw[$ext[1]][$ext[0]])){ 122 if($cw[$ext[1]][$ext[0]] == 'ENABLED'){ 123 $cw_f = '<img src="/admin/images/accept.png" border="0">'; 124 } 125 } 126 $cfim_f = empty($cfim[$ext[1]][$ext[0]]) ? '' : $cfim[$ext[1]][$ext[0]]; 127 $cfbs_f = empty($cfbs[$ext[1]][$ext[0]]) ? '' : $cfbs[$ext[1]][$ext[0]]; 128 $cfna_f = empty($cfna[$ext[1]][$ext[0]]) ? '' : $cfna[$ext[1]][$ext[0]]; 129 $ip = empty($status_arr[$ext[0]]['ip']) ? '' : $status_arr[$ext[0]]['ip']; 130 $port = empty($status_arr[$ext[0]]['port']) ? '' : $status_arr[$ext[0]]['port']; 131 $status = empty($status_arr[$ext[0]]['status']) ? '' : $status_arr[$ext[0]]['status']; 132 $device = empty($status_arr[$ext[0]]['device']) ? '' : $status_arr[$ext[0]]['device']; 133 $type = empty($status_arr[$ext[0]]['type']) ? '' : $status_arr[$ext[0]]['type']; 116 134 echo "<tr bgcolor='" . varBg($i++) . "'> 117 <td><a href='" . $PHP_SELF . "?display=extcfg&type=tool&action=phone&phone={$ext[0]}&srv={$ext[1]}'>{$ext[0]}</a></td> 118 <td>{$dnd[$ext[1]][$ext[0]]} </td> 119 <td>{$cw[$ext[1]][$ext[0]]} </td> 120 <td>{$cfim[$ext[1]][$ext[0]]} </td> 121 <td>{$cfbs[$ext[1]][$ext[0]]} </td> 122 <td>{$cfna[$ext[1]][$ext[0]]} </td> 123 <td>{$status_arr[$ext[0]]['ip']}</td> 124 <td>{$status_arr[$ext[0]]['port']}</td> 125 <td style='background-color: $status_bg;'>{$status_arr[$ext[0]]['status']}</td> 126 <td>{$status_arr[$ext[0]]['device']}</td> 127 <td>{$status_arr[$ext[0]]['type']}</td> 135 <td><a href='/admin/config.php?type=setup&display=extensions&extdisplay={$ext[0]}'><img src='/admin/images/telephone_edit.png' border=0 title='Edit extension'></a></td> 136 <td><a href='" . $_SERVER['PHP_SELF'] . "?display=extcfg&type=tool&action=phone&phone={$ext[0]}&srv={$ext[1]}'>{$ext[0]} - {$ext[2]}</a></td> 137 <td style='text-align: center;'>$dnd_f </td> 138 <td style='text-align: center;'>$cw_f </td> 139 <td>$cfim_f </td> 140 <td>$cfbs_f </td> 141 <td>$cfna_f </td> 142 <td>$ip</td> 143 <td>$port</td> 144 <td style='background-color: $status_bg;'>$status</td> 145 <td>$device</td> 146 <td>$type</td> 128 147 </tr>"; 129 148 } … … 194 213 $serv = $server[$srv]; 195 214 196 /* if ($_REQUEST["YAC"]) 197 $serv['astman']->PutDB(YAC, $ext, $_REQUEST["YAC"]); 198 else 199 $serv['astman']->DelDB(YAC, $ext); */ 200 if ($_REQUEST["DND"]) 215 if (isset($_REQUEST["DND"])) 201 216 $serv['astman']->PutDB(DND, $ext, "YES"); 202 217 else 203 218 $serv['astman']->DelDB(DND, $ext); 204 if ( $_REQUEST["CW"])219 if (isset($_REQUEST["CW"])) 205 220 $serv['astman']->PutDB(CW, $ext, "ENABLED"); 206 221 else 207 222 $serv['astman']->DelDB(CW, $ext); 208 if ( $_REQUEST["CFBS"])223 if (!empty($_REQUEST["CFBS"])) 209 224 $serv['astman']->PutDB(CFBS, $ext, $_REQUEST["CFBS"]); 210 225 else 211 226 $serv['astman']->DelDB(CFBS, $ext); 212 if ( $_REQUEST["CFIM"])227 if (!empty($_REQUEST["CFIM"])) 213 228 $serv['astman']->PutDB(CFIM, $ext, $_REQUEST["CFIM"]); 214 229 else 215 230 $serv['astman']->DelDB(CFIM, $ext); 216 if ( $_REQUEST["CFNA"])231 if (!empty($_REQUEST["CFNA"])) 217 232 $serv['astman']->PutDB(CFNA, $ext, $_REQUEST["CFNA"]); 218 233 else … … 224 239 $exts = array(); 225 240 226 $sql = "SELECT id FROM devices d WHERE LENGTH(id) < 6 ORDER BY CAST(id AS UNSIGNED);"; 227 $sql_iax = "SELECT id,data FROM iax WHERE keyword = 'callerid' ORDER BY id"; 228 $sql_sip = "SELECT id,data FROM sip WHERE keyword = 'callerid' ORDER BY id"; 229 $sql_zap = "SELECT id,data FROM zap WHERE keyword = 'callerid' ORDER BY id"; 241 $sql = "SELECT id, description FROM devices d ORDER BY CAST(id AS UNSIGNED);"; 230 242 231 243 mysql_connect($server, $user, $passwd) or die ("Could not connect to MySQL"); 232 244 mysql_select_db($db) or die ("Could not select $db database"); 233 245 234 $result = mysql_query($sql) or die ("Query failed");246 $result = mysql_query($sql) or die ("Query failed"); 235 247 while ($kolumn = mysql_fetch_array($result)) { 236 $exts[] = array($kolumn["id"], $astman_nr );248 $exts[] = array($kolumn["id"], $astman_nr, $kolumn['description']); 237 249 } 238 250 239 251 return ($exts); 240 241 $result = mysql_query($sql_iax) or die ("IAX Query failed");242 while ($kolumn = mysql_fetch_array($result)) {243 $exts[] = array($kolumn["id"],$astman_nr);244 }245 246 $result = mysql_query($sql_sip) or die ("SIP Query failed");247 while ($kolumn = mysql_fetch_array($result)) {248 $exts[] = array($kolumn["id"],$astman_nr);249 }250 251 $result = mysql_query($sql_zap) or die ("ZAP Query failed");252 while ($kolumn = mysql_fetch_array($result)) {253 $exts[] = array($kolumn["id"],$astman_nr);254 }255 sort($exts);256 return ($exts);257 252 } 258 253 … … 336 331 $sep = trim(substr($sccp_device, -27, 16)); 337 332 $ip = trim(substr($sccp_device, -43, 15)); 338 $extension = $sccp_sep_arr[$sep];333 $extension = empty($sccp_sep_arr[$sep]) ? null : $sccp_sep_arr[$sep]; 339 334 $ok = $sep == '--' ? false : true; 340 335 if ($extension){ … … 346 341 347 342 $mgcp_endpoints_res = $astman->Query("Action: Command\r\nCommand: mgcp show endpoints\r\n\r\n"); 343 344 if (strpos($mgcp_endpoints_res, 'Gateway')){ 348 345 349 346 $mgcp_endpoints = get_astman_lines($mgcp_endpoints_res); 350 347 unset($mgcp_endpoints[0]); 351 348 352 349 foreach($mgcp_endpoints as $mgcp_endpoint){ 353 350 $extension = ''; … … 377 374 } 378 375 } 376 } 379 377 380 378 return $arr; … … 394 392 function varBg($i = 0){ 395 393 if($i%2 == 0) 396 return '#fff ';394 return '#ffffff'; 397 395 else 398 return '#eee ';396 return '#eeeeee'; 399 397 } 400 398 ?>
