-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
71 lines (57 loc) · 1.67 KB
/
index.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
<html>
<head>
<title>
DB Manager
</title>
<script type="text/javascript">
function changeInputs(sel) {
var e = document.getElementsByName("val2")[0];
if (sel.options[sel.selectedIndex].value == 1) {
e.removeAttribute('disabled');
} else {
e.setAttribute('disabled', 'disabled');
}
}
</script>
</head>
<body>
<?php
function executeAction($string)
{
$host = '127.0.0.1';
$port = 3443;
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
$result = socket_connect($socket, $host, $port) or die("Could not connect to server\n");
socket_write($socket, $string, strlen($string)) or die("Could not send data to server\n");
$result = socket_read($socket, 1024) or die("Could not read server response\n");
socket_close($socket);
return $result;
}
if (count($_POST) > 0) {
$action = '';
if ($_POST['action'] != '1') {
$action = $_POST['action'] . ';' . $_POST['val1'];
} else {
$action = $_POST['action'] . ';' . $_POST['val1'] . ';' . $_POST['val2'];
}
echo $action, '<br />', 'Answer:', executeAction($action);
}
?>
<form action="index.php" method="post">
<select name="action" onchange="changeInputs(this)">
<option value="2" selected>INSERT</option>
<option value="1">UPDATE</option>
<option value="0">REMOVE</option>
</select>
<input type="text" name="val1"/>
<input type="text" name="val2" disabled="disabled"/>
<input type="submit" value="Action!"/>
</form>
<hr />
<pre>
<?php
include 'showTables.php';
?>
</pre>
</body>
</html>