-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
197 lines (173 loc) · 7.54 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
require __DIR__ . '/vendor/autoload.php';
use DigitalOceanV2\Adapter\GuzzleAdapter;
use DigitalOceanV2\DigitalOceanV2;
include_once 'config.php';
// create an adapter with DigitalOcean access token
// and initialize DigitalOceanV2 API object
$adapter = new GuzzleAdapter($apikey);
$digitalocean = new DigitalOceanV2($adapter);
$userInfo = $digitalocean->account()->getUserInformation();
// Get all available images
$allImages = $digitalocean->image()->getAll(['type' => 'snapshot', 'private' => true]);
$images = array();
foreach($allImages as $image) {
if (strpos($image->name, 'servman-') === 0) {
array_push($images, $image);
}
}
// Get all manageabe running droplets
$allDroplets = $digitalocean->droplet()->getAll();
$droplets = array();
foreach($allDroplets as $droplet) {
array_push($droplets, $droplet);
}
?>
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang=""> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>servman - Manage GodmodeX.de Servers</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
body {
padding-top: 50px;
padding-bottom: 20px;
}
</style>
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>
</head>
<body>
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">ServMan</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#">You are using the account <?=$userInfo->email?></a>
</li>
</ul>
</div><!--/.navbar-collapse -->
</div>
</nav>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<h1>Server Management</h1>
<p>This website can be used as a management console for game servers. Select one of the snapshots you want to create a server from, and get your gaming started.</p>
<p>And as always: <b>Get your Godmode on!</b></p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<h3>Images</h3>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Image Name</th>
<th>Date Created</th>
<th>Setup Server</th>
</tr>
</thead>
<tbody>
<?php foreach ($images as $image): ?>
<tr>
<td><?=$image->id?></td>
<td><?=str_replace('servman-', '', $image->name)?></td>
<td><?=$image->createdAt?></td>
<td><a class="btn btn-success" href="#" role="button"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>Servers</h3>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Server Name</th>
<th>Server IP</th>
<th>Server Status</th>
<th>Date Created</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($droplets as $server): ?>
<tr>
<td><?=$server->id?></td>
<td><?=str_replace('servman-', '', $server->name)?></td>
<td><?=$server->networks[0]->ipAddress?></td>
<td><?=$server->status?></td>
<td><?=$server->createdAt?></td>
<td>
<a class="btn btn-warning" href="#" role="button">Restart</a>
<a class="btn btn-danger" href="#" role="button">Destroy</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<!--div class="col-md-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-default" href="#" role="button">View details »</a></p>
</div>
</div-->
<hr>
<footer>
<p>© GodmodeX Germany</p>
</footer>
</div> <!-- /container --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.min.js"><\/script>')</script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/main.js"></script>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X','auto');ga('send','pageview');
</script>
</body>
</html>