forked from NEMSLinux/nconf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_item_step2.php
133 lines (94 loc) · 3.7 KB
/
add_item_step2.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
require_once 'include/head.php';
$step2 = "no";
if (DB_NO_WRITES == 1) {
message($info, "DB_NO_WRITES = 1: No DB inserts or modifications will be performed");
}
if( ( isset($_POST["config_class"]) ) AND ($_POST["config_class"] != "") ){
$config_class = $_POST["config_class"];
}
// DENY USER ADDING AN ADMIN ACCOUNT
if( ($_SESSION["group"] != "admin")
AND ($config_class == "contact")
AND ( isset($_POST[$_POST["ID_nc_permission"]]) AND ($_POST[$_POST["ID_nc_permission"]] == "admin") )
){
// Cache other infos
foreach ($_POST as $key => $value) {
$_SESSION["cache"]["handle"][$key] = $value;
}
unset($_SESSION["cache"]["handle"][$_POST["ID_nc_permission"]]);
include('include/stop_user_modifying_admin_account.php');
}
# Implode the splitet fields (exploded in handle_item.php)
if( isset($_POST["exploded"]) ){
prepare_check_command_params($_POST["exploded"]);
}
echo '
<table>
<tr>
<td>';
// Check if submit is allowed
if ( isset($_SESSION["submited"]) AND !empty($_POST["check_command_changed"]) ){
// Cache
$_SESSION["cache"]["use_cache"] = TRUE;
foreach ($_POST as $key => $value) {
$_SESSION["cache"]["handle"][$key] = $value;
}
# for debugging
//echo '<meta http-equiv="refresh" content="'.REDIRECTING_DELAY.'; url='.$_SESSION["go_back_page"].'">';
echo '<meta http-equiv="refresh" content="0; url='.$_SESSION["go_back_page"].'">';
NConf_DEBUG::set('<a href="'.$_SESSION["go_back_page"].'"> handle_item (back) </a>', 'INFO', "<br>redirecting to");
}elseif ( isset($_SESSION["submited"]) ){
// Write2DB (feedback: $step2)
require_once 'include/add_item_write2db.php';
unset($_SESSION["submited"]);
}else{
message($error, 'Submited data is not allowed to be resent');
if ( isset($_SESSION["created_id"]) ){
$id = $_SESSION["created_id"];
$step2 = "yes";
}
}
# Content of Page
echo NConf_HTML::title('Add '.$config_class, '', 'class="content_header"');
if ( !empty($_POST["check_command_changed"]) ){
# do nothing, just go back
}elseif ($step2 == "yes") {
// Host was added, go to service page
NConf_DEBUG::set('Proceeding to add services.', 'INFO');
// session $_SESSION["created_id"] should be checked for none F5 re-adding
// the step2 in url is only for not working session users...
$url = 'modify_item_service.php?id='.$id.'&step2=true';
echo '<meta http-equiv="refresh" content="'.REDIRECTING_DELAY.'; url='.$url.'">';
// add extra line (br) for more space
echo NConf_DEBUG::show_debug('INFO', TRUE);
// after echo because we want the redirect only in the footer
NConf_DEBUG::set('<a href="'.$url.'"> add services </a>', 'INFO', "<br>redirecting to");
}else{
// normal way to add items
if ( isset($_SESSION["cache"]["handle"]) ) unset($_SESSION["cache"]["handle"]);
if ( NConf_DEBUG::status('ERROR') ) {
echo NConf_HTML::show_error();
echo "<br><br>";
echo NConf_HTML::back_button($_SESSION["go_back_page"]);
// Cache
$_SESSION["cache"]["use_cache"] = TRUE;
foreach ($_POST as $key => $value) {
$_SESSION["cache"]["handle"][$key] = $value;
}
}else{
// Item added, go back to overview of its class
$url = 'overview.php?class='.$config_class;
echo '<meta http-equiv="refresh" content="'.REDIRECTING_DELAY.'; url='.$url.'">';
// add extra line (br) for more space
echo NConf_DEBUG::show_debug('INFO', TRUE);
NConf_DEBUG::set('<a href="'.$url.'"> overview </a>', 'INFO', "<br>redirecting to");
}
}
echo ' </td>
</tr>
</table>
';
mysqli_close($dbh);
require_once 'include/foot.php';
?>