-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteCore.php
More file actions
71 lines (63 loc) · 1.99 KB
/
Copy pathdeleteCore.php
File metadata and controls
71 lines (63 loc) · 1.99 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
<?php
include("includes/header.php");
include("functions/functions.php");
include("includes/settings.php");
?>
<div class="jumbotron">
<div class="row text-center">
<form action="" method="get" class="navbar-form">
<div class="input-group">
<div class="input-group add-on">
<?php
coreDisplay();
?>
<div class="input-group-btn">
<button class="btn btn-default" type="submit" name="submit" value="submit">Delete Core
</button>
</div>
</div>
</div>
<br>
</form>
</div>
</div>
<?php
function deleteDir($path)
{
if (is_dir($path) === true) {
$files = array_diff(scandir($path), array('.', '..'));
foreach ($files as $file) {
deleteDir(realpath($path) . '/' . $file);
}
return rmdir($path);
} else if (is_file($path) === true) {
return unlink($path);
}
return false;
}
if (isset($_GET['submit'])) {
if ($_GET['submit'] == 'submit') {
$coreName = '';
if (isset($_GET["selectCore"]) && $_GET["selectCore"] != '') {
echo "<div class='jumbotron'>";
$coreName = $_GET["selectCore"];
deleteDir($target_dir . $coreName);
$realPath = escapeshellarg(realpath("./pyCalculation"));
$operation = "delete";
exec("py $realPath\coreOperations.py $operation $coreName 2>&1", $output, $ret_code);
echo "<pre>";
foreach ($output as $val) {
echo $val;
echo "<br>";
}
echo "</pre>";
echo "</div>";
} else {
echo '<script type="text/javascript">alert("Please choose core name from dropdown!!!");</script>';
}
}
}
?>
<?php
include("includes/footer.php");
?>