aboutsummaryrefslogtreecommitdiff
path: root/index.php
blob: 39a38ab0c3a6b45cc4a0226ee5ebe0ebe9cdd2ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width initial-scale=1.0"/>
  <link href="style.css" rel="stylesheet" type="text/css"/>
  <title>Yota Callplan</title>
</head>
<body>
<header><a href="http://yota.yu1srs.org.rs/">YOTA</a></header>
<nav>
  <a class="active" href="index.php">Activity Plan</a>
  <a href="reservation.php">Make reservation</a>
  <span class="right">
<?php
  if (isset($_SESSION['admin']) && $_SESSION['admin'] == true) {
    echo '<a class="right" href="/logout.php">Logout</a>';
  	echo '<a class="right" href="admin.php">Administration</a>';
  } else {
    echo '<a class="right" href="/admin.php">Login</a>';
  }
?>
  </span>
</nav>
<main>
<?php
  $user = "yota_user";
  $password = "gahdeer6shai9hogai2sai4quuaj1eVu";
  $database = "yota_call_db";
  $table = "activities";

  try {
    $db = new PDO("mysql:host=localhost;dbname=$database", $user, $password);
		$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

		echo '<div style="overflow-x:auto;">';
    echo "<table>\n";
    echo "<thead><tr>";
    echo "<th>Operator</th>";
    echo "<th>From</th>";
    echo "<th>To</th>";
    echo "<th>Special sign</th>";
    echo "<th>Frequencies</th>";
    echo "<th>QSO</th>";
    echo "</tr></thead><tbody>\n";

    foreach($db->query("SELECT * FROM $table where approved=true ORDER BY `id` DESC") as $row) {
      echo "<tr>";
      echo "<td>" . $row['operatorCall'] . "</td>";
      echo "<td>" . $row['fromTime'] . "</td>";
      echo "<td>" . $row['toTime'] . "</td>";
      echo "<td>" . $row['specialCall'] . "</td>";
      echo "<td>" . $row['frequencies'] . "</td>";
      echo "<td>" . $row['qso'] . "</td>";
      echo "</tr>\n";
    }

    echo "</tbody></table>\n</div>\n";
  } catch (PDOException $e) {
    echo "<p>Error!: " . $e->getMessage() . "</p>";
    die();
  }
?>
</main>
</body>
</html>