-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlavarunfinal.php
47 lines (47 loc) · 1.97 KB
/
lavarunfinal.php
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
<?php
require('vendor/autoload.php');
use WebSocket\Client;
$error = "";
/**
* Created by PhpStorm.
* User: Sava
* Date: 21.8.2016.
* Time: 20.04
*/
if(isset($_GET["token_type"]) && $_GET["token_type"]=="Bearer") {
if (!isset($_GET["access_token"]) || !isset($_GET["state"])){
$error = "Parameters incorrect error, please try again";
}elseif (!isset($_COOKIE["state"]) || $_GET["state"] != $_COOKIE["state"]){
$error = "Security token error, please try again later";
}elseif (!isset($_COOKIE["ip"]) || !isset($_COOKIE["port"]) || !isset($_COOKIE["confirmation"]) || !isset($_COOKIE["username"])) {
$error = "Data storage error";
}else{
try {
$client = new Client("ws://".$_COOKIE["ip"].":".$_COOKIE["port"]);
$ip = $_SERVER['HTTP_CLIENT_IP']?:($_SERVER['HTTP_X_FORWARDED_FOR']?:$_SERVER['REMOTE_ADDR']);
$client->send("{\"ip\":\"".$ip."\",\"username\":\"".$_COOKIE["username"]."\",\"port\":\"".$_COOKIE["port"]."\",\"serverIP\":\"".$_COOKIE["ip"]."\",\"confirmation\":\"".$_COOKIE["confirmation"]."\",\"token\":\"".$_GET["access_token"]."\"}");
$client->close();
}
catch (WebSocket\ConnectionException $e) {
$error = $e;
}
}
}else{
$error = "Wrong token type, please try again";
}
?>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Lava run beam integration</title>
<link rel="stylesheet" href="main.css"/>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="https://use.fontawesome.com/929b26d666.js"></script>
</head>
<body>
<?php if ($error != ""){
echo "<div><i class=\"fa fa-times error\" aria-hidden=\"true\"></i> <p class = \"error\">".$error."</p></div>";
}else {
echo "<div> <i class=\"fa fa-check success\" aria-hidden=\"true\"></i> <p class = \"success\">Success, you can close this tab now</p></div>";
}
?>
</body>