Issues (6)

demos/index.php (1 issue)

Labels
Severity
1
<?php
2
require_once 'vendor/autoload.php';
3
$successMsg = false;
4
$errorMsg   = false;
5
$message    = "";
6
if (isset($_GET['backup']) && $_GET['backup'] == 'success') {
7
    $successMsg = true;
8
    $message    = "Database backedup successfully";
9
}
10
if (isset($_GET['backup']) && $_GET['backup'] == 'fail') {
11
    $errorMsg = true;
12
    $message  = "Database backedup failed";
13
}
14
if (isset($_GET['restore']) && $_GET['restore'] == 'success') {
15
    $successMsg = true;
16
    $message    = "Database restored successfully";
17
}
18
if (isset($_GET['restore']) && $_GET['restore'] == 'fail') {
19
    $errorMsg = true;
20
    $message  = "Database restored failed";
21
}
22
if (isset($_GET['message'])) {
23
    $message = $_GET['message'];
24
}
25
?>
26
<!DOCTYPE html>
27
<html>
28
<head>
29
 <title>Backup lists</title>
30
 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
31
</head>
32
<body>
33
 <div class="container">
34
  <div class="card mt-5 mx-auto">
35
    <div class="card-body">
36
     <div class="success">
37
      <?php if ($successMsg): ?>
38
       <p class="alert alert-success"><?php echo $message; ?></p>
39
      <?php endif;?>
40
     </div>
41
     <div class="error">
42
      <?php if ($errorMsg): ?>
43
       <p class="alert alert-danger"><?php echo $message; ?></p>
44
      <?php endif;?>
45
     </div>
46
     <a href="backup.php" class="btn btn-success my-3">Create a new backup</a>
47
     <a href="index.php" class="btn btn-info my-3">Reload</a>
48
<?php $files = glob(__DIR__ . '/backups/*');?>
49
     <?php if (count($files)): ?>
0 ignored issues
show
It seems like $files can also be of type false; however, parameter $var of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

49
     <?php if (count(/** @scrutinizer ignore-type */ $files)): ?>
Loading history...
50
<table class="table table-bordered">
51
     <thead>
52
       <tr>
53
         <th scope="col">#</th>
54
         <th scope="col">Name</th>
55
         <th scope="col">Directory</th>
56
         <th scope="col">Actions</th>
57
       </tr>
58
     </thead>
59
     <tbody>
60
   <?php foreach ($files as $key => $file): ?>
61
    <?php $info = pathinfo($file);?>
62
    <tr>
63
      <th scope="row"><?php echo $key + 1 ?></th>
64
      <td><?php echo $info['basename'] ?></td>
65
      <td><?php echo $info['dirname'] ?></td>
66
      <td class="d-flex">
67
       <form action="restore.php" method="GET" class="inline-flex mr-2">
68
        <input type="hidden" name="restore_path" value="<?php echo $file ?>">
69
        <input type="submit" name="restore" class="btn btn-success" value="Restore">
70
       </form>
71
       <form action="remove.php" method="POST" class="inline-flex">
72
        <input type="hidden" name="restore_path" value="<?php echo $file ?>">
73
        <input type="submit" name="remove" class="btn btn-danger" value="Remove">
74
       </form>
75
      </td>
76
    </tr>
77
    <?php endforeach;?>
78
     </tbody>
79
   </table>
80
   <?php else: ?>
81
    <p class="alert alert-danger">There is no backup</p>
82
   <?php endif;?>
83
    </div>
84
  </div>
85
 </div>
86
 <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
87
 <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
88
 <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
89
</body>
90
</html>