Completed
Pull Request — master (#4584)
by Neil
05:43
created

html/pages/device/logs/syslog.inc.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
2
  <hr />
3
4
  <form method="post" action="">
5
  <div class="row">
6
    <div class="col-md-4">
7
      <input class="form-control" type="text" name="string" palaceholder="Search" id="string" value="<?php echo $_POST['string']; ?>">
8
    </div>
9
    <div class="col-md-4">
10
      <select name="program" class="form-control" id="program">
11
        <option value="">All Programs</option>
12
            <?php
13
            $datas = dbFetchRows('SELECT `program` FROM `syslog` WHERE device_id = ? GROUP BY `program` ORDER BY `program`', array($device['device_id']));
14
            foreach ($datas as $data) {
15
                echo "<option value='".$data['program']."'";
16
                if ($data['program'] == $_POST['program']) {
17
                    echo 'selected';
18
                }
19
20
                echo '>'.$data['program'].'</option>';
21
            }
22
            ?>
23
      </select>
24
    </div>
25
    <div class="col-md-4">
26
      <input class="btn btn-default" type="submit" value="Search">
27
    </div>
28
  </div>
29
</form>
30
31
<?php
32
 print_optionbar_end();
33
34
$param = array($device['device_id']);
35
36 View Code Duplication
if ($_POST['string']) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    $where   = ' AND msg LIKE ?';
38
    $param[] = '%'.$_POST['string'].'%';
39
}
40
41
if ($_POST['program']) {
42
    $where  .= ' AND program = ?';
43
    $param[] = $_POST['program'];
44
}
45
46
$sql  = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? $where";
47
$sql .= ' ORDER BY timestamp DESC LIMIT 1000';
48
echo '      <div class="panel panel-default panel-condensed">
49
              <div class="panel-heading">
50
                <strong>Syslog entries</strong>
51
              </div>
52
              <table class="table table-hover table-condensed table-striped">';
53
foreach (dbFetchRows($sql, $param) as $entry) {
54
    unset($syslog_output);
55
    include 'includes/print-syslog.inc.php';
56
    echo $syslog_output;
57
}
58
59
echo '        </table>
60
            </div>';
61
$pagetitle[] = 'Syslog';
62