Esempio n. 1
0
  <up>
    <backlight>
    </backlight>
  </up>
  <voice>
    <codecPref>
    </codecPref>
  </voice>
  <voIpProt>
    <SIP>
      <alertInfo>
      </alertInfo>
    </SIP>
  </voIpProt>
</polycomConfig>');
$id = polycomphones_lookup_mac($_GET['mac']);
$polycom_request = strpos($_SERVER['HTTP_USER_AGENT'], 'Polycom') !== false;
if ($id == null && !$polycom_request) {
    die;
}
if ($polycom_request) {
    $matches = array();
    preg_match('/FileTransport Polycom([^\\/.]*)/', $_SERVER['HTTP_USER_AGENT'], $matches);
    if ($id == null) {
        sql("INSERT INTO polycom_devices (name, mac, model, lastconfig, lastip) \n\t\t\tVALUES ('Auto Added','" . $db->escapeSimple($_GET['mac']) . "','" . $db->escapeSimple($matches[1]) . "',NOW(),'" . $db->escapeSimple($_SERVER['REMOTE_ADDR']) . "')");
        $id = sql("SELECT LAST_INSERT_ID()", 'getOne');
        polycomphones_clear_overrides($_GET['mac']);
        polycomphones_save_phones_directory($_GET['mac'], array());
    } else {
        sql("UPDATE polycom_devices SET lastconfig = NOW(), \n\t\t\tmodel = '" . $db->escapeSimple($matches[1]) . "',\n\t\t\tlastip = '" . $db->escapeSimple($_SERVER['REMOTE_ADDR']) . "'\n\t\t\tWHERE id = '" . $db->escapeSimple($id) . "'");
    }
         $directory = array();
         foreach ($fields as $field) {
             foreach ($_POST[$field] as $key => $value) {
                 $key++;
                 if ($field == 'sd') {
                     $directory[$key][$field] = $value == '1' ? $key : '';
                 } elseif ($field == 'rt' && $value == '') {
                     $directory[$key][$field] = 'default';
                 } else {
                     $directory[$key][$field] = $value;
                 }
             }
         }
         polycomphones_save_phones_directory($_GET['edit'], $directory);
         // Use SIP notify to reboot phone
         polycomphones_checkconfig(polycomphones_lookup_mac($_GET['edit']));
         redirect('config.php?type=setup&display=polycomphones&polycomphones_form=phones_list');
     }
     $directory = polycomphones_get_phones_directory($_GET['edit']);
     foreach ($directory as $key => $contact) {
         if ($contact['sd'] != '') {
             $directory[$key]['sd'] = '1';
         }
         if ($contact['rt'] == 'default') {
             $directory[$key]['rt'] = '';
         }
     }
     require 'modules/polycomphones/views/polycomphones_phones_directory.php';
     break;
 case 'externallines_list':
     if (isset($_GET['delete'])) {