aboutsummaryrefslogtreecommitdiff
path: root/php
diff options
context:
space:
mode:
Diffstat (limited to 'php')
-rw-r--r--php/pager.php61
-rw-r--r--php/pgp.php64
2 files changed, 125 insertions, 0 deletions
diff --git a/php/pager.php b/php/pager.php
new file mode 100644
index 0000000..43b792c
--- /dev/null
+++ b/php/pager.php
@@ -0,0 +1,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>
diff --git a/php/pgp.php b/php/pgp.php
new file mode 100644
index 0000000..cd7c255
--- /dev/null
+++ b/php/pgp.php
@@ -0,0 +1,64 @@
+<?php
+
+$result = null;
+
+if (isset($_GET["op"])) {
+ if (!file_exists('/tmp/gpg')) {
+ mkdir('/tmp/gpg', 0700, true);
+ $result = shell_exec("gpg --homedir /tmp/gpg --import --trust-model always ../arf20.ecc.asc 2>&1");
+ echo "<pre>$result</pre>";
+ $result = shell_exec("echo \"071FD0F02A0292F08EE1A121EB74F0C93E429F8E:5\n6DDA5B0BF8F154C4C0542B92DEBF11CAEEFA5962:5\" | gpg --homedir /tmp/gpg --import-ownertrust 2>&1");
+ echo "<pre>$result</pre>";
+
+ }
+ $data = $_GET["data"];
+ if ($_GET["op"] == "Verify") {
+ if (preg_match("[^a-zA-Z0-9+/=- ]+", $data) == 1)
+ die("invalid message");
+ $result = shell_exec("echo \"".$data."\" | gpg --homedir /tmp/gpg --no-tty --trust-model always --verify 2>&1");
+ } else if ($_GET["op"] == "Encrypt") {
+ if (preg_match("[\"\''\\]+", $data) == 1)
+ die("invalid character(s)");
+
+ $result = shell_exec("echo \"".$data."\" | gpg --homedir /tmp/gpg --no-tty --always-trust --encrypt --armor -r 071FD0F02A0292F08EE1A121EB74F0C93E429F8E 2>&1");
+ }
+}
+
+?>
+
+
+<!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">OpenPGP</h2>
+ <form action="/php/pgp.php" method="GET">
+ <h3>Verify something arf20 said, or encrypt something for arf20</h3>
+ <textarea name="data" rows="25" cols="80"><?php echo $_GET["data"]; ?></textarea><br>
+ <input type="submit" name="op" value="Verify"><input type="submit" name="op" value="Encrypt"><br>
+
+ </form>
+<?php
+if (isset($result)) {
+ if ($result === null) {
+ echo "Null";
+ } else if ($result === false) {
+ echo "False";
+ } else {
+ echo "<textarea readonly rows=\"25\" cols=\"80\">\n$result\n</textarea>";
+ }
+}
+?>
+ </main>
+ </body>
+</html>