Completed
Push — master ( 1692d5...827fdf )
by Frank
02:05
created

index.php ➔ cmd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<!DOCTYPE html>
2
<?php
3
4
function cmd($command)
5
{
6
    exec($command, $output);
7
    return $output;
8
}
9
$action = !empty($_GET['action']) ? $_GET['action'] : null;
10
switch ($action) {
11
    case 'start':
12
        $result = cmd('sudo /etc/init.d/botty start');
13
        break;
14
    case 'stop':
15
        $result = cmd('sudo /etc/init.d/botty stop');
16
        break;
17
    case 'restart':
18
        $result = cmd('sudo /etc/init.d/botty restart');
19
        break;
20
    default:
21
        $result = null;
22
}
23
?>
24
<html lang="en">
25
<head>
26
    <meta charset="utf-8">
27
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
28
    <meta name="viewport" content="width=device-width, initial-scale=1">
29
    <meta name="description" content="I am in each channel on slack, even if you do not see me. Talk to me by start a message with @T3Bot or with the command prefix.">
30
    <meta name="author" content="Frank Nägler">
31
    <link rel="apple-touch-icon" sizes="57x57" href="/Resources/Public/Assets/apple-touch-icon-57x57.png">
32
    <link rel="apple-touch-icon" sizes="114x114" href="/Resources/Public/Assets/apple-touch-icon-114x114.png">
33
    <link rel="apple-touch-icon" sizes="72x72" href="/Resources/Public/Assets/apple-touch-icon-72x72.png">
34
    <link rel="apple-touch-icon" sizes="144x144" href="/Resources/Public/Assets/apple-touch-icon-144x144.png">
35
    <link rel="apple-touch-icon" sizes="60x60" href="/Resources/Public/Assets/apple-touch-icon-60x60.png">
36
    <link rel="apple-touch-icon" sizes="120x120" href="/Resources/Public/Assets/apple-touch-icon-120x120.png">
37
    <link rel="apple-touch-icon" sizes="76x76" href="/Resources/Public/Assets/apple-touch-icon-76x76.png">
38
    <link rel="apple-touch-icon" sizes="152x152" href="/Resources/Public/Assets/apple-touch-icon-152x152.png">
39
    <link rel="icon" type="image/png" href="/Resources/Public/Assets/favicon-196x196.png" sizes="196x196">
40
    <link rel="icon" type="image/png" href="/Resources/Public/Assets/favicon-160x160.png" sizes="160x160">
41
    <link rel="icon" type="image/png" href="/Resources/Public/Assets/favicon-96x96.png" sizes="96x96">
42
    <link rel="icon" type="image/png" href="/Resources/Public/Assets/favicon-16x16.png" sizes="16x16">
43
    <link rel="icon" type="image/png" href="/Resources/Public/Assets/favicon-32x32.png" sizes="32x32">
44
    <meta name="msapplication-TileColor" content="#ffffff">
45
    <meta name="msapplication-TileImage" content="/Resources/Public/Assets/mstile-144x144.png">
46
47
    <title>T3Bot</title>
48
49
    <!-- Bootstrap core CSS -->
50
    <link href="/Resources/Public/Css/bootstrap.min.css" rel="stylesheet">
51
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
52
53
54
    <!-- Custom styles for this template -->
55
    <link href="/Resources/Public/Css/cover.css" rel="stylesheet">
56
57
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
58
    <!--[if lt IE 9]>
59
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
60
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
61
    <![endif]-->
62
</head>
63
<body>
64
<a href="https://github.com/NeoBlack/T3Bot"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/52760788cde945287fbb584134c4cbc2bc36f904/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png"></a>
65
<div class="site-wrapper">
66
    <div class="site-wrapper-inner">
67
        <div>
68
            <div class="inner cover">
69
                <h1>Botty Control Center</h1>
70
                <a href="index.php?action=start" class="btn btn-success col-lg-4">Start</a>
71
                <a href="index.php?action=restart" class="btn btn-warning col-lg-4">Restart</a>
72
                <a href="index.php?action=stop" class="btn btn-danger col-lg-4">Stop</a>
73
                <?php if ($result !== null) {
74
    ?>
75
                    <div class="result" style="text-align: left;">
76
<pre><?php foreach ($result as $row) {
77
        ?>
78
<?= $row . "\n" ?>
79
<?php 
80
    } ?></pre>
81
                    </div>
82
                <?php 
83
} ?>
84
            </div>
85
            <div class="mastfoot">
86
                <div class="inner">
87
                    <p>Cover template for <a href="http://getbootstrap.com">Bootstrap</a>, by <a href="https://twitter.com/mdo">@mdo</a>.</p>
88
                </div>
89
            </div>
90
        </div>
91
    </div>
92
</div>
93
94
<!-- Bootstrap core JavaScript
95
================================================== -->
96
<!-- Placed at the end of the document so the pages load faster -->
97
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
98
<script src="/Resources/Public/JavaScript/bootstrap.min.js"></script>
99
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
100
<script src="/Resources/Public/JavaScript/ie10-viewport-bug-workaround.js"></script>
101
</body>
102
</html>