aboutsummaryrefslogtreecommitdiff
path: root/php/pager.php
blob: 43b792cdec209e769eb710f7befe55c934cc6829 (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
<?php

$auth = "ea5jgx:KjNHWkLpy3XaJv2N7WIZ";//"callsign:password";
$url = "http://www.hampager.de:8080/calls";

if (isset($_GET["msg"])) {
    $data = [
        'text' => $_GET["msg"],
        'callSignNames' => array( 'ea5jgx' ),
        'transmitterGroupNames' => array( 'ea-all' ),
        'emergency' => 'false'
    ];

    $options = [
        'http' => [
            'method'  => 'POST',
            'header'  => "Content-type: application/json\r\n".
                "Authorization: Basic ".base64_encode("$auth")."\r\n",
            'content' => json_encode($data),
        ],
    ];

    $context  = stream_context_create($options);

    $response = file_get_contents($url, false, $context);
}

?>


<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" type="text/css" href="https://arf20.com/style.css">
        <title>ARFNET</title>
    </head>

    <body>
        <header><a href="/">
            <img src="http://arf20.com/arfnet_logo.png" width="64"><span class="title"><strong>ARFNET</strong></span>
        </a></header>
        <hr>
        <main>
            <h2 class="center">Pager service</h2>
            <form action="/php/pager.php" method="GET">
                <h3>Page arf20!</h3>
                <input type="text" name="msg">
                <input type="submit" value="Page"><br>
<?php 
if (isset($response)) {
    if ($response === false)
        echo "<span>Error</span>";
    else
        echo "<pre>$response</pre>";
}
?>
            </form>
        </main>
    </body>
</html>