summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/thinkpad.inc50
1 files changed, 50 insertions, 0 deletions
diff --git a/pages/thinkpad.inc b/pages/thinkpad.inc
new file mode 100644
index 0000000..af1bcfa
--- /dev/null
+++ b/pages/thinkpad.inc
@@ -0,0 +1,50 @@
+<?php
+
+// 2:20
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';
+
+$password = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["thinkpad"]["password"];
+$mac = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["thinkpad"]["mac"];
+$error = "";
+$success = "";
+
+if (isset($_POST["submit"]) && isset($_POST["pwd"])) {
+ if (password_verify($_POST["pwd"], $password)) {
+ $out = [];
+ exec("bash -c '/usr/sbin/ether-wake " . $mac . "'", $out);
+
+ if (count($out) === 0) {
+ $success = "Successfully turned laptop on, please wait 5 minutes before connecting to it, and don't forget to turn it back off afterwards you dork";
+ } else {
+ $error = "Failed to initiate Wake on LAN message: " . implode(", ", $out);
+ }
+ } else {
+ $error = "Invalid password, I am going to burn down your house if you're trying to touch my laptop";
+ }
+}
+
+?>
+
+<br>
+<div class="container">
+ <div id="page-content">
+ <h2>ThinkPad</h2>
+
+ <?php if (trim($error) !== ""): ?>
+ <div class="alert alert-danger"><b>Error:</b> <?= $error ?></div>
+ <?php endif; ?>
+ <?php if (trim($success) !== ""): ?>
+ <div class="alert alert-success"><b>Success:</b> <?= $success ?></div>
+ <?php endif; ?>
+
+ <form method="post">
+ <input type="hidden" name="submit" action="/-/thinkpad">
+ <p><input type="password" name="pwd" class="form-control" placeholder="Password" style="filter: invert(1) hue-rotate(180deg);"></p>
+ <button class="btn btn-primary">Flip the switch!</button>
+ </form>
+ </div>
+</div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?>