<?php
/** board script
* Displayes the submitted flag_ids of the
* last X time with meta information
* If the submission to gameserver was successfull (submitsuccess)
* and we got points for it (scoresuccess) it should be green bg
*
* 2014-15 by Jan "Someone" Vales <someone@somenet.org>
* do not publish!
*/

$GLOBALS['db'] = new PDO('pgsql:host=localhost;port=5432;dbname=flagbot;user=flagbot;password=flagbotpw');
$GLOBALS['db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = "SELECT service,count(*) as cnt FROM flag_ids WHERE (received + INTERVAL '30 minute') > now() group by service ORDER BY service";

?>
<!DOCTYPE html>
  <html>
  <head>
    <link rel="stylesheet" type="text/css" href="styles.css"></link>
  </head>
  <body>
    <h1>Submission Board - flag_id - count()</h1>
    <p><a href="./index.php">go to flags</a></p>
    <p>Shows all submissions of the last 30 min<br>
    NUM ROWS: <?php echo sizeof($GLOBALS['db']->query($query)->fetchAll()); ?></p>
    <table style="width: 100%">
      <thead>
        <tr>
            <th>service</th>
            <th>count</th>
          </tr>
        </thead>
        <tbody>
          <?php
          $stmt = $GLOBALS['db']->query($query);
          while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
          ?>
            <tr class="score-<?php echo $row['service']; ?>">
              <td><?php echo $row['service']; ?>&nbsp;</td>
              <td><?php echo $row['cnt']; ?>&nbsp;</td>
            </tr>
            <?php
          }
          ?>
        </tbody>
      </table>
    <p>Status: 0=new; 1=depleted</p>
    </body>
    </html>