blob: af1bcfad676a59ac220af8d6e19aa256d619a06e (
plain)
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
|
<?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'; ?>
|