Completed
Push — master ( cce5ab...e98ea9 )
by Frank
02:49
created

index.php ➔ cmd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<!DOCTYPE html>
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 4 and the first side effect is on line 1.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

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