getAll($sql); if(DB::IsError($results)) $results = null; foreach ($results as $val) $tmparray[] = $val[0]; return $tmparray; } function get_device_useragent($device) { global $astman; $response = $astman->send_request('Command',array('Command'=>"sip show peer $device")); $astout = explode("\n",$response['data']); $ua = ""; foreach($astout as $entry) { if(eregi("useragent",$entry)) { list(,$value) = split(":",$entry); $ua = trim($value); } } if($ua) { if(stristr($ua,"Aastra")) { return "aastra"; } if(stristr($ua,"Grandstream")) { return "grandstream"; } if(stristr($ua,"snom")) { return "snom"; } if(stristr($ua,"Cisco")) { return "cisco"; } if(stristr($ua,"Polycom")) { return "polycom"; } } return null; } function restart_device($device) { $ua = get_device_useragent($device); switch($ua) { case "aastra": sip_notify("aastra-check-cfg",$device); break; case "grandstream": sip_notify("grandstream-check-cfg",$device); break; case "snom": sip_notify("reboot-snom",$device); break; case "cisco": sip_notify("cisco-check-cfg",$device); break; case "polycom": sip_notify("polycom-check-cfg",$device); break; default: break; } } function sip_notify($event,$device) { global $astman; $command = 'sip notify '.$event; $command .= ' '.$device; // Send command $res = $astman->Command($command); } ?>