3 * insert flowIDs and info to submit into log_db.log_t.
 
   4 * log_db.log_t gets periodically checked by 
 
   5 * script whichs tries to submit flowids to gameserver.
 
   6 * Information about this status can be found in board.php
 
   8 * 2014 by Jan "Someone" Vales <someone@somenet.org>
 
  12 $GLOBALS['db'] = new PDO('pgsql:host=localhost;port=5432;dbname=postgres;user=postgres;password=dba');                                                                                                              
 
  13 $GLOBALS['db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);                                                                                            
 
  15 if (strcmp($_SERVER['REQUEST_METHOD'],"GET") === 0 || strcmp($_SERVER['REQUEST_METHOD'],"POST") === 0 ) {
 
  18   http_response_code(405); //Method not implemented
 
  19   exit("<p><b>what?</b> try GET or POST</p>");
 
  22 function handleRequest() {
 
  23   if (isset($_REQUEST['flag']) && isset($_REQUEST['service']) && strlen($_REQUEST['flag']) == 32 ) {
 
  24      insertData($_REQUEST['flag'],$_REQUEST['service']);
 
  26      echo "<p><b>usage:</b><br>";
 
  27      echo "GET /submit.php?flag=<i>STRING</i>&service=<i>STRING</i> <br>";
 
  28      echo "POST<br> flag=<i>STRING</i>&service=<i>STRING</i></p>";
 
  32 function insertData($flag, $service) {
 
  33   echo "<p><b>inserting data...</b></p>";
 
  34   echo "flag=".htmlentities($flag)."<br>";
 
  35   echo "service=".htmlentities($service)."</p>";
 
  38     $GLOBALS['db']->beginTransaction();
 
  39     $stmt = $GLOBALS['db']->prepare("INSERT INTO flags (flag, service) VALUES(?, ?)");
 
  40     $stmt->execute(array($flag, $service));
 
  41     $GLOBALS['db']->commit();
 
  43   }catch(PDOException $ex) {
 
  44     echo "<p><b>INSERT FAIL</b></p><p>".$ex->getMessage()."</p>";
 
  45     $GLOBALS['db']->rollBack();
 
  48   if ($success == 1) echo "<p><b>OK</b></p>";