forked from phpcoinn/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·749 lines (675 loc) · 30.2 KB
/
index.php
File metadata and controls
executable file
·749 lines (675 loc) · 30.2 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
<?php
require_once dirname(__DIR__)."/apps.inc.php";
require_once ROOT. '/web/apps/explorer/include/functions.php';
define("PAGE", true);
define("APP_NAME", "Admin");
global $db, $_config;
if(!$_config['admin']) {
die("Admin mode not enabled!");
}
const APP_URL = "/apps/admin";
require_once __DIR__. '/../common/include/top.php';
$msg = [];
if(isset($_POST['action'])) {
$action = $_POST['action'];
if($action == "generate") {
$password = $_POST['password'];
$password2 = $_POST['password2'];
if($password != $password2) {
$msg=[['type'=>'danger', 'msg'=>'Password do not match']];
} else {
$uppercase = preg_match('@[A-Z]@', $password);
$lowercase = preg_match('@[a-z]@', $password);
$number = preg_match('@[0-9]@', $password);
$specialChars = preg_match('@[^\w]@', $password);
if(!$uppercase || !$lowercase || !$number || !$specialChars || strlen($password) < 8) {
$m = 'Password should be at least 8 characters in length and should include at least one upper case letter, one number, and one special character.';
$msg=[['type'=>'danger', 'msg'=>$m]];
} else {
$passwordHash = password_hash($password, HASHING_ALGO, HASHING_OPTIONS);
$m = 'Your password has is generated. Write this hash to config file: '.$passwordHash;
$msg=[['type'=>'success', 'msg'=>$m]];
}
}
}
if($action == "login") {
$password = $_POST['password'];
$passwordHash = $_config['admin_password'];
$verify = password_verify($password, $passwordHash);
if(!$verify) {
$msg=[['type'=>'danger', 'msg'=>'Invalid password']];
} else {
$_SESSION['login']=true;
header("location: ".APP_URL);
exit;
}
}
if($action == "private-key-login") {
$nonce = $_POST['nonce'];
$signature = $_POST['signature'];
$public_key = $_POST['public_key'];
$res = ec_verify($nonce, $signature, $public_key);
if(!$res) {
$msg=[['type'=>'danger', 'msg'=>'Invalid private key']];
} else {
$_SESSION['login']=true;
header("location: ".APP_URL);
exit;
}
}
if($action == "add_peer") {
$peer = $_POST['peer'];
$cmd = "php ".ROOT."/cli/util.php peer " . $peer . " > /dev/null 2>&1 &";
$res = shell_exec($cmd);
header("location: ".APP_URL."/?view=peers");
exit;
}
if($action == 'set_hostname') {
$db->setConfig('hostname', $_POST['hostname']);
header("location: ".APP_URL."/?view=config");
exit;
}
}
if(isset($_GET['action'])) {
$action = $_GET['action'];
if($action == "logout") {
$_SESSION['login']=false;
header("location: ".APP_URL);
exit;
}
if($action=="logging") {
$value = $_GET['value'];
$db->setConfig("enable_logging", $value);
header("location: ".APP_URL."/?view=config");
exit;
}
if($action=="offline") {
$value = $_GET['value'];
$db->setConfig("offline", $value);
header("location: ".APP_URL."/?view=config");
exit;
}
if($action == "delete_peer") {
$id = $_GET['id'];
if(!empty($id)) {
Peer::delete($id);
}
header("location: ".APP_URL."/?view=peers");
exit;
}
if($action == "repeer") {
$id = $_GET['id'];
$peer = $_GET['peer'];
if(!empty($id)) {
Peer::delete($id);
$cmd = "php ".ROOT."/cli/util.php peer " . $peer . " > /dev/null 2>&1 &";
$res = shell_exec($cmd);
}
header("location: ".APP_URL."/?view=peers");
exit;
}
if($action == "miner_enable") {
$db->setConfig("miner", true);
@unlink(ROOT. "/tmp/miner-lock");
header("location: ".APP_URL."/?view=server");
}
if($action == "miner_disable") {
$db->setConfig("miner", false);
@unlink(ROOT. "/tmp/miner-lock");
header("location: ".APP_URL."/?view=server");
}
if($action == "miner_restart") {
@unlink(ROOT. "/tmp/miner-lock");
header("location: ".APP_URL."/?view=server");
}
if($action == "delete_peers") {
Peer::deleteAll();
header("location: ".APP_URL."/?view=peers");
exit;
}
if($action == "mn_lock_clear") {
@rmdir(ROOT.'/tmp/mn-lock');
header("location: ".APP_URL."/?view=server");
exit;
}
}
$setAdminPass = !empty($_config['admin_password']);
$login = $_SESSION['login'] ?? false;
if(isset($_GET['view'])) {
$view = $_GET['view'];
} else {
$view = "server";
}
if($view == "db") {
$dbData = Nodeutil::getDbData();
}
if($view == "utils") {
}
if($view == "log") {
//TODO: replace @1.0.6.85
if(method_exists(Nodeutil::class, "getLogData")) {
$logData = Nodeutil::getLogData();
} else {
$log_file = $_config['log_file'];
if(substr($log_file, 0, 1)!= "/") {
$log_file = ROOT . "/" .$log_file;
}
$cmd = "tail -n 100 $log_file";
$logData = shell_exec($cmd);
}
}
if($view == "peers") {
$dm = get_data_model(-1, "/apps/admin/?view=peers");
$sorting = '';
if(isset($dm['sort'])) {
$sorting = ' order by '.$dm['sort'];
if(isset($dm['order'])){
$sorting.= ' ' . $dm['order'];
}
}
$peers = Peer::getAll($sorting);
}
$pubKeyLogin = isset($_config['admin_public_key']) && strlen($_config['admin_public_key']) > 0;
$nonce = uniqid();
?>
<?php if ($login) { ?>
<div class="row">
<div class="col-6 h3">Node Admin</div>
<div class="col-6 text-end">
<a href="<?php echo APP_URL ?>/?action=logout" class="btn btn-outline-primary">Logout</a>
</div>
</div>
<hr/>
<?php } ?>
<?php if($msg) { ?>
<?php foreach ($msg as $m) { ?>
<div class="alert alert-<?php echo $m['type'] ?>">
<?php echo $m['msg'] ?>
</div>
<?php }
}
?>
<?php if ($pubKeyLogin) { ?>
<?php if (!$login) { ?>
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<div class="card mt-5">
<div class="card-header">
<h4 class="card-title">Login</h4>
<p class="card-title-desc">Login and administer your node server</p>
</div>
<div class="card-body p-4">
<div class="row">
<div class="col-lg-12">
<form method="post" action="">
<input type="hidden" value="" name="public_key">
<input type="hidden" value="<?php echo $nonce ?>" name="nonce">
<input type="hidden" value="" name="signature">
<input type="hidden" value="private-key-login" name="action">
<div class="mb-3">
<label class="form-label" for="password">Private key</label>
<input type="password" class="form-control" id="private_key" name="private_key" value="" required/>
</div>
<div class="row mb-4">
<div class="col">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="rememberPrivateKey">
<label class="form-check-label" for="rememberPrivateKey">
Remember private key
</label>
</div>
<div class="help-block text-muted text-info">
Private key will be stored only locally in browser
</div>
</div>
</div>
<div class="mt-4">
<button type="button" class="btn btn-primary w-md" onclick="login()">Login</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-4"></div>
</div>
<script src="/apps/common/js/jquery.min.js"></script>
<script src="/apps/common/js/phpcoin-crypto.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
let privateKey = localStorage.getItem("adminPrivateKey")
if(privateKey) {
$("form [name=private_key]").val(privateKey)
$("#rememberPrivateKey").attr("checked", true)
}
})
function login() {
try {
let chainId = "<?php echo CHAIN_ID ?>"
let privateKey = $("form [name=private_key]").val().trim()
if(!privateKey) {
throw new Error("Empty private key");
}
let nonce = $("form [name=nonce]").val().trim()
let sig = sign(chainId+nonce, privateKey)
let publicKey = get_public_key(privateKey)
$("form [name=signature]").val(sig)
$("form [name=public_key]").val(publicKey)
$("form [name=private_key]").val("")
if($("#rememberPrivateKey").is(":checked")) {
localStorage.setItem("adminPrivateKey", privateKey)
} else {
localStorage.removeItem("adminPrivateKey")
}
$("form").submit();
} catch (e) {
console.log(e)
Swal.fire(
{
title: 'Login failed',
text: e.message,
icon: 'error'
}
)
event.preventDefault()
}
}
</script>
<?php } ?>
<?php } else { ?>
<?php if (!$setAdminPass) { ?>
<?php if(empty($passwordHash)) { ?>
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<div class="card mt-5">
<div class="card-header">
<h4 class="card-title">Login</h4>
<p class="card-title-desc">Please generate and save admin password</p>
</div>
<div class="card-body p-4">
<div class="row">
<div class="col-lg-12">
<form method="post" action="">
<div class="mb-3">
<label class="form-label" for="password">Enter password:</label>
<input type="password" class="form-control" id="password" name="password" value="" required/>
</div>
<div class="mb-3">
<label class="form-label" for="password2">Repeat password:</label>
<input type="password" class="form-control" id="password2" name="password2" value="" required/>
</div>
<div class="mt-4">
<button type="submit" class="btn btn-primary w-md">Generate</button>
</div>
<input type="hidden" name="action" value="generate">
</form>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-4"></div>
</div>
<?php } ?>
<?php } else { ?>
<?php if (!$login) { ?>
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<div class="card mt-5">
<div class="card-header">
<h4 class="card-title">Login</h4>
<p class="card-title-desc">Login and administer your node server</p>
</div>
<div class="card-body p-4">
<div class="row">
<div class="col-lg-12">
<form method="post" action="">
<div class="mb-3">
<label class="form-label" for="password">Node password</label>
<input type="text" class="d-none" id="username" value="<?php echo $_config['hostname'] ?>">
<input type="password" class="form-control" id="password" name="password" value="" required/>
</div>
<div class="mt-4">
<button type="submit" class="btn btn-primary w-md">Login</button>
</div>
<input type="hidden" name="action" value="login">
</form>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-4"></div>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
<?php if ($login) { ?>
<ul class="nav nav-tabs mb-3" role="tablist">
<li class="nav-item">
<a class="nav-link <?php if ($view == "server") { ?>active<?php } ?>" href="<?php echo APP_URL ?>/?view=server" role="tab" aria-selected="false">
<span>Server info</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($view == "php") { ?>active<?php } ?>" href="<?php echo APP_URL ?>/?view=php" role="tab" aria-selected="false">
<span>PHP info</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($view == "db") { ?>active<?php } ?>" href="<?php echo APP_URL ?>/?view=db" role="tab" aria-selected="false">
<span>DB info</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($view == "utils") { ?>active<?php } ?>" href="<?php echo APP_URL ?>/?view=utils" role="tab" aria-selected="false">
<span>Utils</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($view == "peers") { ?>active<?php } ?>" href="<?php echo APP_URL ?>/?view=peers" role="tab" aria-selected="false">
<span>Peers</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($view == "mempool") { ?>active<?php } ?>" href="<?php echo APP_URL ?>/?view=mempool" role="tab" aria-selected="false">
<span>Mempool</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($view == "config") { ?>active<?php } ?>" href="<?php echo APP_URL ?>/?view=config" role="tab" aria-selected="false">
<span>Config</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <?php if ($view == "log") { ?>active<?php } ?>" href="<?php echo APP_URL ?>/?view=log" role="tab" aria-selected="false">
<span>Log</span>
</a>
</li>
</ul>
<?php if(!empty($view)) { ?>
<?php if($view == "php") {
phpinfo();
} ?>
<?php if($view == "db") {
$sql="select count(id) from blocks";
$count = $db->single($sql);
$sql="select max(height) from blocks";
$max = $db->single($sql);
$blockchain_valid = ($count == $max);
if(!$blockchain_valid) {
$sql="select min(height) from (
select b.height, b.id, lead(b.height) over (),
lead(b.height) over () - b.height as diff
from blocks b
order by b.height asc) as b
where diff <> 1";
$invalid_height = $db->single($sql);
}
?>
<div class="row">
<div class="col-lg-4 col-sm-6">
<?php if (!$blockchain_valid) { ?>
<div class="alert alert-danger">
Blockchain is invalid.
<br/>
Blocks: <?php echo $count ?> - Max height: <?php echo $max ?> - Invalid height: <?php echo $invalid_height ?>
</div>
<?php } ?>
<div class="flex-row d-flex justify-content-between flex-wrap">
<label>Connection:</label>
<div><?php echo $dbData['connection'] ?></div>
</div>
<div class="flex-row d-flex justify-content-between flex-wrap">
<label>Server:</label>
<div><?php echo $dbData['server'] ?></div>
</div>
<div class="flex-row d-flex justify-content-between flex-wrap">
<label>DB Name:</label>
<div><?php echo $dbData['db_name'] ?></div>
</div>
<div class="flex-row d-flex justify-content-between flex-wrap">
<label>DB version:</label>
<div><?php echo $dbData['dbversion'] ?></div>
</div>
<hr/>
<?php foreach ($dbData['tables'] as $table => $rows) { ?>
<div class="flex-row d-flex justify-content-between flex-wrap">
<label><?php echo $table ?>:</label>
<div><?php echo $rows ?></div>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<?php if($view == "peers") {
$total = count(Peer::findPeers(null, null));
$blacklisted = count(Peer::findPeers(true, null));
$live = count(Peer::findPeers(null, true));
?>
<div class="mt-4">
<form class="row gx-3 gy-2 align-items-center" method="post" action="">
<input type="hidden" name="action" value="add_peer">
<div class="col-sm-2">
<input type="text" class="form-control" id="peer" name="peer" placeholder="Peer address" required="required">
</div>
<div class="col-sm-2">
<button type="submit" class="btn btn-success">Add Peer</button>
</div>
</form>
</div>
<hr/>
Total: <?php echo $total ?>
Blacklisted: <?php echo $blacklisted ?>
Live: <?php echo $live ?>
<h4>Peers</h4>
<div class="table-responsive">
<table class="table table-sm table-striped dataTable">
<thead class="table-light">
<tr>
<th>Action</th>
<?php echo sort_column("/apps/admin/index.php?view=peers", $dm, 'id', 'ID' ,'') ?>
<?php echo sort_column("/apps/admin/index.php?view=peers", $dm, 'hostname', 'Hostname' ,'') ?>
<?php echo sort_column("/apps/admin/index.php?view=peers", $dm, 'blacklisted', 'Blacklisted' ,'') ?>
<?php echo sort_column("/apps/admin/index.php?view=peers", $dm, 'ping', 'Ping' ,'') ?>
<?php echo sort_column("/apps/admin/index.php?view=peers", $dm, 'height', 'Height' ,'') ?>
<th>Block</th>
<th>Ip</th>
<?php echo sort_column("/apps/admin/index.php?view=peers", $dm, 'version', 'Version' ,'') ?>
<?php echo sort_column("/apps/admin/index.php?view=peers", $dm, 'fails', 'Fails' ,'') ?>
<th>Stuckfail</th>
<th>Reason</th>
<th>Miner</th>
<th>Generator</th>
<th>Masternode</th>
<?php echo sort_column("/apps/admin/index.php?view=peers", $dm, 'response_time', 'Response time' ,'') ?>
<?php echo sort_column("/apps/admin/index.php?view=peers", $dm, 'response_cnt', 'Response count' ,'') ?>
<?php echo sort_column("/apps/admin/index.php?view=peers", $dm, 'response_time/response_cnt', 'Response avg' ,'') ?>
</tr>
</thead>
<tbody>
<?php foreach ($peers as $peer) {
$live = time() - $peer['ping'] < Peer::PEER_PING_MAX_MINUTES*60;
$table_class = $peer['blacklisted'] > time() ? "table-danger" : ($live ? "table-success" : "");
?>
<tr class="<?php echo $table_class ?>">
<td class="text-nowrap">
<a class="btn btn-danger btn-xs" href="<?php echo APP_URL ?>/?action=delete_peer&id=<?php echo $peer['id'] ?>" onclick="if(!confirm('Delete peer?')) return false;">Delete</a>
<a class="btn btn-warning btn-xs" href="<?php echo APP_URL ?>/?action=repeer&id=<?php echo $peer['id'] ?>&peer=<?php echo $peer['hostname'] ?>">Re-peer</a>
</td>
<td><?php echo $peer['id'] ?></td>
<td>
<a href="<?php echo $peer['hostname'] ?>" target="_blank">
<?php echo $peer['hostname'] ?>
</a>
</td>
<td nowrap="nowrap">
<?php echo display_date($peer['blacklisted']) ?>
<?php if($peer['blacklisted'] > time()) {
echo " | " .durationFormat($peer['blacklisted'] - time());
}?>
</td>
<td nowrap="nowrap"><?php echo display_date($peer['ping']) . " | " . durationFormat(time() - $peer['ping']) ?></td>
<td><?php echo $peer['height'] ?></td>
<td><?php echo $peer['block_id'] ?></td>
<td><?php echo $peer['ip'] ?></td>
<td><?php echo $peer['version'] ?></td>
<td><?php echo $peer['fails'] ?></td>
<td><?php echo $peer['stuckfail'] ?></td>
<td><?php echo $peer['blacklist_reason'] ?></td>
<td><?php echo $peer['miner'] ?></td>
<td><?php echo $peer['generator'] ?></td>
<td><?php echo $peer['masternode'] ?></td>
<td><?php echo $peer['response_time'] ?></td>
<td><?php echo $peer['response_cnt'] ?></td>
<td>
<?php
$total = $peer['response_time'];
$cnt = $peer['response_cnt'];
if($cnt > 0) {
$avg = round($total / $cnt,3);
}
?>
<span title="total=<?php echo $total ?> cnt=<?php echo $cnt ?>"><?php echo $avg ?></span>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<a class="btn btn-danger" href="<?php echo APP_URL ?>/?action=delete_peers" onclick="if(!confirm('Delete all?')) return false">Delete all</a>
<?php } ?>
<?php if($view == "config") {
$display_config = $_config;
$display_config['db_pass']='****';
$display_config['generator_private_key']='****';
$display_config['miner_private_key']='****';
?>
<h3>Config</h3>
<div class="row">
<div class="col-sm-7">
<table class="table table-sm">
<?php foreach($display_config as $key=>$val) { ?>
<tr>
<td><?php echo $key ?></td>
<td style="word-break: break-all">
<?php
if(is_array($val)) {
echo implode('<br/>',$val);
} else {
echo $val;
}
?>
</td>
</tr>
<?php } ?>
</table>
</div>
<div class="col-sm-5">
<div class="form-check form-switch form-switch-lg mb-3" dir="ltr">
<input type="checkbox" class="form-check-input" id="customSwitchsizelg" <?php echo $_config['enable_logging'] ? 'checked=""' : '' ?>
onchange="document.location.href='<?php echo APP_URL ?>/?action=logging&value=<?php echo $_config['enable_logging'] ? 0 : 1 ?>'">
<label class="form-check-label" for="customSwitchsizelg">Logging</label>
</div>
<div class="form-check form-switch form-switch-lg mb-3" dir="ltr">
<input type="checkbox" class="form-check-input" id="customSwitchsizelg" <?php echo $_config['offline'] ? 'checked=""' : '' ?>
onchange="document.location.href='<?php echo APP_URL ?>/?action=offline&value=<?php echo $_config['offline'] ? 0 : 1 ?>'">
<label class="form-check-label" for="customSwitchsizelg">Offline</label>
</div>
<div class="mt-4">
<h3 class="font-size-16 mb-2"><i class="mdi mdi-arrow-right text-primary me-1"></i>Hostname</h3>
<form class="row gx-3 gy-2 align-items-center" method="post" action="">
<input type="hidden" name="action" value="set_hostname"/>
<div class="col-sm-8">
<input type="text" value="<?php echo $_config['hostname'] ?>" class="form-control" id="hostname" name="hostname" placeholder="" required="required">
</div>
<div class="col-sm-auto">
<button type="submit" class="btn btn-info">Set</button>
</div>
</form>
</div>
</div>
</div>
<?php } ?>
<?php if($view == "update") { ?>
<table class="table table-sm">
<tr>
<td>
<label>Apps hash (calculated):</label>
</td>
<td>
<?php echo $updateData['appsHash']['calculated'] ?>
</td>
</tr>
<tr>
<td>
<label>Apps hash (stored):</label>
</td>
<td>
<?php echo $updateData['appsHash']['stored'] ?>
</td>
</tr>
<tr>
<td>
<label>Apps hash (valid):</label>
</td>
<td>
<?php echo $updateData['appsHash']['valid'] ?>
</td>
</tr>
</table>
<?php if ($updateData['appsHash']['calculated'] != $updateData['appsHash']['valid']) { ?>
<a href="<?php echo APP_URL ?>/?action=update" class="btn btn-success">Update apps</a>
<?php } ?>
<?php if ($repoServer) {?>
<a href="<?php echo APP_URL ?>/?action=propagate_update" class="btn btn-success">Propagate</a>
<?php } ?>
<?php
$gitRev = trim(shell_exec("cd . ".ROOT." && git rev-parse HEAD"));
$remoteRev = trim(shell_exec("cd . ".ROOT.' && git ls-remote https://github.com/phpcoinn/node | head -1 | sed "s/HEAD//"'));
?>
<table class="table table-sm mt-5">
<tr>
<td><label>Node version</label></td>
<td><?php echo $gitRev?></td>
</tr>
<tr>
<td><label>Latest git version</label></td>
<td><?php echo $remoteRev?></td>
</tr>
</table>
<?php if ($gitRev != $remoteRev) {?>
Update node:
<pre>
git reset --hard HEAD
git pull
php cli/util.php download-apps
</pre>
<?php } ?>
<?php } ?>
<?php if($view == "log") { ?>
<h3>Log</h3>
<hr/>
<pre style="white-space: pre-line"><?php echo $logData ?></pre>
<?php } ?>
<?php
define("ADMIN_TAB", true);
if($view == "mempool") {
require_once __DIR__ ."/tabs/mempool.php";
}
if($view == "server") {
require_once __DIR__ ."/tabs/server.php";
}
if($view == "utils") {
require_once __DIR__ ."/tabs/utils.php";
}
?>
<?php } ?>
<?php } ?>
<?php
require_once __DIR__ . '/../common/include/bottom.php';
?>