-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloggerAdd.php
More file actions
85 lines (83 loc) · 2.42 KB
/
loggerAdd.php
File metadata and controls
85 lines (83 loc) · 2.42 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
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
include('lock.php');
include_once('auditTrial.php');
$groupID = $_SESSION['s_loginGroupid'];
if (isset($groupID)) {
if ($groupID==0) {
if($_SERVER["REQUEST_METHOD"] == "POST") {
// ip, port, description sent by the form
$ip=addslashes($_POST['ip']);
$port=addslashes($_POST['port']);
$description=addslashes($_POST['description']);
if (strlen($ip) && strlen($port)) {
$sql = "INSERT into t_astsrvinfo (id_srvip, id_srvport, id_description) VALUES ('$ip', $port, '$description')";
$result=mysql_query($sql);
if (mysql_affected_rows()==1) {
$_SESSION['s_systemMessage'] = "Add logger IP:$ip Port:$port successfully.";
// audit trial
$auditTrial = "add logger IP:$ip Port:$port successfully.";
insertAuditTrial($auditTrial);
} else {
$_SESSION['s_systemMessage'] = "Add logger IP:$ip Port:$port failed.";
// audit trial
$auditTrial = "add logger IP:$ip Port:$port failed.";
insertAuditTrial($auditTrial);
}
} else {
$_SESSION['s_systemMessage'] = "Mandatory fileds are not provided, add logger failed.";
}
header("location: welcome.php?action=loggerAdd");
} else {
$form = "
<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"libs/css/astlogger.css\">
<form class=\"loggerAddForm\" id=\"loggerAddForm\" action=\"loggerAdd.php\" method=\"post\">
<table>
<tr>
<td >Logger IP(*)</td>
<td >:</td>
<td ><input name=\"ip\" type=\"text\" id=\"ip\"></td>
</tr>
<tr>
<td >Logger Port(*)</td>
<td >:</td>
<td ><input name=\"port\" type=\"text\" id=\"port\"></td>
</tr>
<tr>
<td >Description</td>
<td >:</td>
<td ><input name=\"description\" type=\"text\" id=\"description\"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type=\"submit\" value=\" Submit \"></td>
</tr>
</table>
</form>
";
echo $form;
}
}
}
?>
<script type="text/javascript">
$(function(){
jQuery.validator.addMethod('ipv4', function(value) {
var ipv4 = /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/;
return value.match(ipv4);
}, 'Invalid IPv4 address');
$('#loggerAddForm').validate({
rules: {
ip: {
required: true,
ipv4: true,
},
port: {
required: true,
number: true,
},
}
});
});
</script>