<?php
   //define('NEW_UI', '1');

   class MyDB extends SQLite3 {
      function __construct() {
         $this->open('/kirac/db/sungateway.db');
      }
   }

   $db = new MyDB();
   if(!$db) {
      echo $db->lastErrorMsg();
   }

   $sql =<<<EOF
      SELECT * from tblipconfig;
EOF;

   $ret = $db->query($sql);
   while($row = $ret->fetchArray(SQLITE3_ASSOC) ) {
     if (!defined('NEW_UI')) {
     echo '<div class="row"><div class="col-25"><label for="floggerid">Logger ID</label></div><div class="col-75"><input type="text" name="floggerid" value="'. $row['logger_id'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="fip">Logger IP</label></div><div class="col-75"><input type="text" name="fip" value="'. $row['ip'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="fmask">Logger Mask</label></div><div class="col-75"><input type="text" name="fmask" value="'. $row['mask'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="fgateway">Logger Gateway</label></div><div class="col-75"><input type="text" name="fgateway" value="'. $row['gateway'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="fserverip">Sunucu IP</label></div><div class="col-75"><input type="text" name="fserverip" value="'. $row['server_ip'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="fserverport">Sunucu Port</label></div><div class="col-75"><input type="text" name="fserverport" value="'. $row['server_port'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="ftopic">MQTT Data Topic</label></div><div class="col-75"><input type="text" name="ftopic" value="'. $row['topic'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="ftopicstatus">MQTT Status Topic</label></div><div class="col-75"><input type="text" name="ftopicstatus" value="'. $row['topicstatus'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="fapn">APN</label></div><div class="col-75"><input type="text" name="fapn" value="'. $row['apn'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="fdebugip">Debug Sunucu IP</label></div><div class="col-75"><input type="text" name="fdebugip" value="'. $row['debug_ip'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="fdebugport">Debug Sunucu Port</label></div><div class="col-75"><input type="text" name="fdebugport" value="'. $row['debug_port'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="fupdateserverip">Güncelleme Sunucu IP</label></div><div class="col-75"><input type="text" name="fupdateserverip" value="'. $row['update_server_ip'] .'"></div></div>';
     echo '<div class="row"><div class="col-25"><label for="fupdateserverport">Güncelleme Sunucu Port </label></div><div class="col-75"><input type="text" name="fupdateserverport" value="'. $row['update_server_port'] .'"></div></div>';
     }else {
      
     }

   }
   $db->close();
?>
