<?php

include 'config/database.php';

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>NOTIFY API | @MYBOT</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>

  <nav class="navbar navbar-light bg-light">
    <a class="navbar-brand" href="#">
      <img src="/docs/4.4/assets/brand/bootstrap-solid.svg" width="30" height="30" class="d-inline-block align-top" alt="">
      @MYBOT
    </a>
  </nav>

<div class="container">
  <div class="row">
    <div class="col-sm-12">

    <br>
<!--       <form method="get" action="https://notify-bot.line.me/oauth/authorize">
          <input class="form-control" type="hidden" name="response_type" value="code">
          <input class="form-control" type="hidden" name="redirect_uri" value='http://at-mybot.me:8000/callback.php'>
          <input class="form-control" type="hidden" name="scope" value="notify">
          <input class="form-control" type="hidden" name="state" value="push">

          <select name="client_id" class="form-control">
              <option value="KuL3lBRRRuofauZBW0Tv6C">J V1</option>
              <option value="NuVhLreKgHcIt6wRebAHZL">JET V2</option>
              <option value="iAFisyx20FwTuhhyAqhOgr">H V1</option>
          </select>
          <br>
          <button class="btn btn-primary" type="submit">
            Go.
          </button>
      </form>
 -->
 <?php $res = get_notify(); ?>

<div class="row">
  <?php
  $i = 0;
  $drop = [];
  foreach ($res as $key => $value) {
    $i = $i+1;
    $drop[$i] = $value['n_cliend_id'];
    $icon = 'mybot.jpg';
    //if($value['n_category'] == 'JET'){ $icon = 'jet-notify.png'; continue;}
    //else if($value['n_category'] == 'HUAY'){ $icon = 'huay-notify.png'; }
    $status = '';
    if($value['n_status'] == 'ON'){
       $status = '<b style="color:green">Active</b>';
    }else{
      $status = '<b style="color:red">Offline</b>';
    }
    /*
  ?>
  <div class="col-md-4">
    <div class="card" style="width: 100%;float: left;margin-right: 10px;margin-bottom: 10px;">
      <img src="icon/<?php echo $icon;?>" class="card-img-top">
      <div class="card-body">
        <h6 class="card-title" style="margin-bottom: 0px !important;"><?php echo $value['n_name'];?></h6>
        <p class="card-text" style="margin-bottom: 0px !important;">ใช้งาน : <?php echo (int)$value['n_online'];?> กลุ่ม</p>
        <p class="card-text" style="margin-bottom: 0px !important;">หาย : <?php echo (int)$value['n_missing'];?> กลุ่ม</p>
        <p class="card-text" style="margin-bottom: 0px !important;">สถานะ : <?php echo $status;?> </p>
        <a href="https://notify-bot.line.me/oauth/authorize?response_type=code&redirect_uri=http://at-mybot.me:8000/callback.php&scope=notify&state=<?php echo $value['n_cliend_id'];?>&client_id=<?php echo $value['n_cliend_id'];?>&a=10" class="btn btn-primary">ลบทะเบียน</a>
      </div>
    </div>
  </div>
  <?php */ } ?>

<?php  


$rand = rand(1,$i);

$BOT = $drop[$rand];
header("Location: https://notify-bot.line.me/oauth/authorize?response_type=code&redirect_uri=http://at-mybot.me:8001/callback.php&scope=notify&state=$BOT&client_id=$BOT&a=10");

?>

  </div>

    </div>

  </div>
</div>



<!--
https://notify-bot.line.me/oauth/authorize?
response_type=code&
client_id=KuL3lBRRRuofauZBW0Tv6C&
redirect_uri=http://150.95.89.148:8001/callback.php&
scope=notify&
state=push

-->
</body>
</html>

<!--

https://notify-bot.line.me/oauth/authorize
?response_type=code
&client_id=KuL3lBRRRuofauZBW0Tv6C
&redirect_uri=http://localhost:80/callback
&scope=notify
&state=abcdef123456


 -->