<?php
include_once(_DIR_TO_CLASS."/c_page.php");

class c_page_cab_esmo_setting_ssl_check extends c_page
{
  public $h1='Проверка настроек SSL для связи с терминалом' ;

  function set_head_tags()
   { parent::set_head_tags() ;
     $this->HEAD['css'][]=_PATH_TO_EXT.'/aspmo_setting/style.css' ;
     $this->caCert = isset($_SESSION['ca_cert']) ? $_SESSION['ca_cert'] : _CA_CERT ;
     $this->serverCert = isset($_SESSION['server_cert']) ? $_SESSION['server_cert'] : _SERVER_CERT ;
     $this->serverKey = isset($_SESSION['server_key']) ? $_SESSION['server_key'] : _SERVER_KEY ;
   }

 function second_menu_config()
 { $this->second_menu=$this->menu['/cab/setting/']['items']['/cab/setting/members/']['items'] ;
 }



 function block_main()
 { $this->page_title() ;
    $recs=ESMO()->get_list_terminals(MEMBER()->cur_group_id) ;
  ?>
  <style>
    .path_input {
      width: 300px;
    }
    .error {
      font-weight: bold;
      color: red;
    }
  </style>

  <form>
    <table class="setting">
      <tr>
        <td><label>Корневой сертификат</label></td>
        <td><input name="ca_cert" value="<?=$this->caCert?>" class="path_input"></input> <button class="v2" cmd="esmo_setting/ca_check">Проверить</button></td>
      </tr>
      <tr>
        <td><label>Сертификат сервера</label></td>
        <td><input name="server_cert" value="<?=$this->serverCert?>" class="path_input"></input> <button class="v2" cmd="esmo_setting/server_cert_check">Проверить</button></td></td>
      </tr>
      <tr>
        <td><label>Закрытый ключ сервера</label></td>
        <td><input name="server_key" value="<?=$this->serverKey?>" class="path_input"></input> <button class="v2" cmd="esmo_setting/server_key_check">Проверить</button></td>
      </tr>
      <tr>
        <td><label>Адрес терминала для проверки</label>
        <td>
          <select name="terminal_address" style="width:300px;" data-select>
             <? if (_sizeof($recs)) foreach($recs as $rec) {?><option value="<?=$rec['ip']?>"><?=$rec['ip']?> [<?=$rec['obj_name']?>]</option><?}?>
          </select>
        </td>
        <!--td><input name="terminal_address" value="127.0.0.1"></td-->
      </tr>
      <tr>
        <td><label>Порт терминала</label>
        <td><input name="terminal_port" value="443"></td>
      </tr>
      <tr>
        <td></td>
        <td><button class="v2" cmd="esmo_setting/terminal_cert_check">Проверить сертификат терминала</button>
      </tr>
    </table>
  </form>
  <?php
  }
}
