-
Notifications
You must be signed in to change notification settings - Fork 0
/
authkey_remove.php
86 lines (66 loc) · 1.49 KB
/
authkey_remove.php
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
require_once("auth.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CBSD Project</title>
<link type="text/css" href="./css/all.css" rel="stylesheet" />
<style>
body {
background-image: url("/img/adm_bg.jpg");
background-color: #84CF99;
font-size:14px;
}
</style>
</head>
<body>
<?php
require('cbsd.php');
if (!isset($_GET['idx'])) {
echo "Empty idx";
exit(0);
}
if (isset($_GET['sure'])) {
$sure=1;
} else {
$sure=0;
}
$idx=$_GET['idx'];
if ($sure==0) {
$str = <<<EOF
<script type="text/javascript">
<!--
var answer = confirm("Really remove key?")
if (!answer)
window.location="authkey.php"
else
window.location="authkey_remove.php?idx=$idx&sure=1"
// -->
</script>
EOF;
echo $str;
exit(0);
}
//$handle=popen("env NOCOLOR=1 /usr/local/bin/sudo /usr/local/bin/cbsd task owner=cbsdweb mode=new /usr/local/bin/cbsd node mode=remove inter=0 node=$idx", 'r');
//$read = fgets($handle, 4096);
//echo "Job Queued: $read";
//pclose($handle);
$dbfilepath="/var/db/webdev/authkey.sqlite";
$stat = file_exists($dbfilepath);
$str = "";
if (!$stat) {
echo "$dbfilepath not found";
sleep(10);
header( 'Location: authkey.php' ) ;
die();
}
$db = new SQLite3($dbfilepath); $db->busyTimeout(5000);
$query="DELETE FROM authkey WHERE idx='{$idx}');";
echo "$query";
$db->exec("DELETE FROM authkey WHERE idx='{$idx}';");
//$db->exec($query);
//$db->exec($query);
$db->close();
header( 'Location: authkey.php' ) ;
?>