| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- $pdo = null;
- try {
- $pdo = new PDO("sqlite:" . './slork.sqlite');
- } catch (PDOException $e) {
- // handle the exception here
- }
- require "functions.php";
- /**
- * BUSINESS LOGIC
- *
- * $screen = 0; // start
- * 1) First we validate or create a maintainer.
- * Adding a maintainer is a detour but results
- * in the same situation as selecting one.
- * 1b) Cannot validate maintainer
- * $screen = 1;
- * 1a) Can validate maintainer
- * $screen = 2; $_REQUEST['m']; // maintainer exists
- * 2) The maintainer will be presented a page with
- * players. He can edit or remove a player.
- * $screen = 3; $_REQUEST['e']; // edit player
- * $screen = 4; $_REQUEST['x']; // remove player
- * 3) The edit page allows the maintainer to add
- * or remove features from the player.
- */
- // global
- $screen = 0;
- $maintainer = array(0, '?');
- $action = '';
- if ( isset( $_REQUEST['action'] ) ) {
- $action = $_REQUEST['action'];
- }
- if ( $action == 'i' ) {
- // Try adding new maintainer ...
- $maintainer = add_maintainer( $_REQUEST['api'] );
- // ... then return to start screen
- $screen = 0;
- }
- if ( $action == 'm' ) {
- // There is a maintainer
- $maintainer = get_maintainer( $_REQUEST['maintainer'] );
- $screen = 2;
- }
- if ( $action == 'e' ) {
- // Request for edit screen
- $screen = 3;
- }
- if ( $action == 'x' ) {
- // Request to remove player
- $screen = 4;
- }
- assert( '$screen >= 0', "By now \$screen should be set to a value >= 0." );
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <!-- Required meta tags -->
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <!-- Bootstrap CSS -->
- <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
- <title>Hello, world!</title>
- </head>
- <body>
- <div class="container">
- <div class="row">
- <div class="col-md">
- One of three columns
- </div>
- <div class="col-md">
- <?php
- require "snippets.php";
- if ( $maintainer[0] > 0 && $maintainer[0] < 100 ) {
- // Error in creating maintainer
- print( "<pre>" );
- print( "ERROR $maintainer[0]: $maintainer[1]" );
- print( "</pre>" );
- // Try again
- $screen = 0;
- }
- // Choose or add a maintainer; default screen
- print( $snippets[$screen] );
- ?>
- </div>
- <div class="col-md">
- <pre>
- <?php
- print_r( $_REQUEST );
- ?>
- </pre>
- </div>
- </div>
- </div>
- <!-- Optional JavaScript -->
- <!-- jQuery first, then Popper.js, then Bootstrap JS -->
- <script src="//code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
- <script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
- <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
- </body>
|