@@ -1,3 +1,3 @@ |
||
1 | 1 | <?php |
2 | -print str_shuffle(md5(microtime())); |
|
2 | +print str_shuffle (md5 (microtime ())); |
|
3 | 3 | ?> |
4 | 4 | \ No newline at end of file |
@@ -26,34 +26,34 @@ |
||
26 | 26 | $error = array(); |
27 | 27 | |
28 | 28 | if($_POST['action']!="delete") { |
29 | - # code must be exactly 32 chars long and alfanumeric if app_security = crypt |
|
30 | - if($_POST['app_security']=="crypt") { |
|
31 | - if(strlen($_POST['app_code'])!=32 || !ctype_alnum($_POST['app_code'])) { $error[] = "Invalid application code"; } |
|
32 | - } |
|
33 | - # name must be more than 2 and alphanumberic |
|
34 | - if(strlen($_POST['app_id'])<3 || strlen($_POST['app_id'])>12 || !ctype_alnum($_POST['app_id'])) { $error[] = "Invalid application id"; } |
|
35 | - # permissions must be 0,1,2 |
|
36 | - if($_POST['app_security']!="user") { |
|
37 | - if(!($_POST['app_permissions']==0 || $_POST['app_permissions']==1 || $_POST['app_permissions'] ==2 || $_POST['app_permissions'] ==3 )) { $error[] = "Invalid permissions"; } |
|
38 | - } |
|
29 | + # code must be exactly 32 chars long and alfanumeric if app_security = crypt |
|
30 | + if($_POST['app_security']=="crypt") { |
|
31 | + if(strlen($_POST['app_code'])!=32 || !ctype_alnum($_POST['app_code'])) { $error[] = "Invalid application code"; } |
|
32 | + } |
|
33 | + # name must be more than 2 and alphanumberic |
|
34 | + if(strlen($_POST['app_id'])<3 || strlen($_POST['app_id'])>12 || !ctype_alnum($_POST['app_id'])) { $error[] = "Invalid application id"; } |
|
35 | + # permissions must be 0,1,2 |
|
36 | + if($_POST['app_security']!="user") { |
|
37 | + if(!($_POST['app_permissions']==0 || $_POST['app_permissions']==1 || $_POST['app_permissions'] ==2 || $_POST['app_permissions'] ==3 )) { $error[] = "Invalid permissions"; } |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | # die if errors |
42 | 42 | if(sizeof($error) > 0) { |
43 | - $Result->show("danger", $error, true); |
|
43 | + $Result->show("danger", $error, true); |
|
44 | 44 | } |
45 | 45 | else { |
46 | - # create array of values for modification |
|
47 | - $values = array("id"=>@$_POST['id'], |
|
48 | - "app_id"=>$_POST['app_id'], |
|
49 | - "app_code"=>@$_POST['app_code'], |
|
50 | - "app_permissions"=>@$_POST['app_permissions'], |
|
51 | - "app_security"=>@$_POST['app_security'], |
|
52 | - "app_comment"=>@$_POST['app_comment']); |
|
53 | - |
|
54 | - # execute |
|
55 | - if(!$Admin->object_modify("api", $_POST['action'], "id", $values)) { $Result->show("danger", _("API $_POST[action] error"), true); } |
|
56 | - else { $Result->show("success", _("API $_POST[action] success"), true); } |
|
46 | + # create array of values for modification |
|
47 | + $values = array("id"=>@$_POST['id'], |
|
48 | + "app_id"=>$_POST['app_id'], |
|
49 | + "app_code"=>@$_POST['app_code'], |
|
50 | + "app_permissions"=>@$_POST['app_permissions'], |
|
51 | + "app_security"=>@$_POST['app_security'], |
|
52 | + "app_comment"=>@$_POST['app_comment']); |
|
53 | + |
|
54 | + # execute |
|
55 | + if(!$Admin->object_modify("api", $_POST['action'], "id", $values)) { $Result->show("danger", _("API $_POST[action] error"), true); } |
|
56 | + else { $Result->show("success", _("API $_POST[action] success"), true); } |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | ?> |
60 | 60 | \ No newline at end of file |
@@ -5,46 +5,46 @@ discard block |
||
5 | 5 | *************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Result = new Result (); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # strip input tags |
20 | -$_POST = $Admin->strip_input_tags($_POST); |
|
20 | +$_POST = $Admin->strip_input_tags ($_POST); |
|
21 | 21 | |
22 | 22 | # validate csrf cookie |
23 | -$User->csrf_cookie ("validate", "apiedit", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
23 | +$User->csrf_cookie ("validate", "apiedit", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
24 | 24 | |
25 | 25 | /* checks */ |
26 | -$error = array(); |
|
26 | +$error = array (); |
|
27 | 27 | |
28 | -if($_POST['action']!="delete") { |
|
28 | +if ($_POST['action'] != "delete") { |
|
29 | 29 | # code must be exactly 32 chars long and alfanumeric if app_security = crypt |
30 | - if($_POST['app_security']=="crypt") { |
|
31 | - if(strlen($_POST['app_code'])!=32 || !ctype_alnum($_POST['app_code'])) { $error[] = "Invalid application code"; } |
|
30 | + if ($_POST['app_security'] == "crypt") { |
|
31 | + if (strlen ($_POST['app_code']) != 32 || !ctype_alnum ($_POST['app_code'])) { $error[] = "Invalid application code"; } |
|
32 | 32 | } |
33 | 33 | # name must be more than 2 and alphanumberic |
34 | - if(strlen($_POST['app_id'])<3 || strlen($_POST['app_id'])>12 || !ctype_alnum($_POST['app_id'])) { $error[] = "Invalid application id"; } |
|
34 | + if (strlen ($_POST['app_id']) < 3 || strlen ($_POST['app_id']) > 12 || !ctype_alnum ($_POST['app_id'])) { $error[] = "Invalid application id"; } |
|
35 | 35 | # permissions must be 0,1,2 |
36 | - if($_POST['app_security']!="user") { |
|
37 | - if(!($_POST['app_permissions']==0 || $_POST['app_permissions']==1 || $_POST['app_permissions'] ==2 || $_POST['app_permissions'] ==3 )) { $error[] = "Invalid permissions"; } |
|
36 | + if ($_POST['app_security'] != "user") { |
|
37 | + if (!($_POST['app_permissions'] == 0 || $_POST['app_permissions'] == 1 || $_POST['app_permissions'] == 2 || $_POST['app_permissions'] == 3)) { $error[] = "Invalid permissions"; } |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | 41 | # die if errors |
42 | -if(sizeof($error) > 0) { |
|
43 | - $Result->show("danger", $error, true); |
|
42 | +if (sizeof ($error) > 0) { |
|
43 | + $Result->show ("danger", $error, true); |
|
44 | 44 | } |
45 | 45 | else { |
46 | 46 | # create array of values for modification |
47 | - $values = array("id"=>@$_POST['id'], |
|
47 | + $values = array ("id"=>@$_POST['id'], |
|
48 | 48 | "app_id"=>$_POST['app_id'], |
49 | 49 | "app_code"=>@$_POST['app_code'], |
50 | 50 | "app_permissions"=>@$_POST['app_permissions'], |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | "app_comment"=>@$_POST['app_comment']); |
53 | 53 | |
54 | 54 | # execute |
55 | - if(!$Admin->object_modify("api", $_POST['action'], "id", $values)) { $Result->show("danger", _("API $_POST[action] error"), true); } |
|
56 | - else { $Result->show("success", _("API $_POST[action] success"), true); } |
|
55 | + if (!$Admin->object_modify ("api", $_POST['action'], "id", $values)) { $Result->show ("danger", _ ("API $_POST[action] error"), true); } |
|
56 | + else { $Result->show ("success", _ ("API $_POST[action] success"), true); } |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | ?> |
60 | 60 | \ No newline at end of file |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | |
25 | 25 | # fetch api for edit / add |
26 | 26 | if($_POST['action']!="add") { |
27 | - # fetch api details |
|
28 | - $api = $Admin->fetch_object ("api", "id", $_POST['appid']); |
|
29 | - # null ? |
|
30 | - $api===false ? $Result->show("danger", _("Invalid ID"), true) : null; |
|
31 | - # title |
|
32 | - $title = ucwords($_POST['action']) .' '._('api').' '.$api->app_id; |
|
27 | + # fetch api details |
|
28 | + $api = $Admin->fetch_object ("api", "id", $_POST['appid']); |
|
29 | + # null ? |
|
30 | + $api===false ? $Result->show("danger", _("Invalid ID"), true) : null; |
|
31 | + # title |
|
32 | + $title = ucwords($_POST['action']) .' '._('api').' '.$api->app_id; |
|
33 | 33 | } else { |
34 | - # generate new code |
|
35 | - $api = new StdClass; |
|
36 | - $api->app_code = str_shuffle(md5(microtime())); |
|
37 | - # title |
|
38 | - $title = _('Add new api key'); |
|
34 | + # generate new code |
|
35 | + $api = new StdClass; |
|
36 | + $api->app_code = str_shuffle(md5(microtime())); |
|
37 | + # title |
|
38 | + $title = _('Add new api key'); |
|
39 | 39 | } |
40 | 40 | ?> |
41 | 41 | |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | <td> |
75 | 75 | <select name="app_permissions" class="form-control input-sm input-w-auto"> |
76 | 76 | <?php |
77 | - $perms = array(0=>"Disabled",1=>"Read",2=>"Read / Write",3=>"Read / Write / Admin"); |
|
78 | - foreach($perms as $k=>$p) { |
|
79 | - if($k==$api->app_permissions) { print "<option value='$k' selected='selected'>"._($p)."</option>"; } |
|
80 | - else { print "<option value='$k' >"._($p)."</option>"; } |
|
81 | - } |
|
82 | - ?> |
|
77 | + $perms = array(0=>"Disabled",1=>"Read",2=>"Read / Write",3=>"Read / Write / Admin"); |
|
78 | + foreach($perms as $k=>$p) { |
|
79 | + if($k==$api->app_permissions) { print "<option value='$k' selected='selected'>"._($p)."</option>"; } |
|
80 | + else { print "<option value='$k' >"._($p)."</option>"; } |
|
81 | + } |
|
82 | + ?> |
|
83 | 83 | </select> |
84 | 84 | <td class="info2"><?php print _('Application permissions'); ?></td> |
85 | 85 | </tr> |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | <td> |
91 | 91 | <select name="app_security" class="form-control input-sm input-w-auto"> |
92 | 92 | <?php |
93 | - $perms = array(0=>"crypt",1=>"ssl",2=>"none",3=>"user"); |
|
93 | + $perms = array(0=>"crypt",1=>"ssl",2=>"none",3=>"user"); |
|
94 | 94 | |
95 | - // user not yet supported |
|
96 | - unset($perms[3]); |
|
95 | + // user not yet supported |
|
96 | + unset($perms[3]); |
|
97 | 97 | |
98 | - foreach($perms as $k=>$p) { |
|
99 | - if($p==$api->app_security) { print "<option value='$p' selected='selected'>"._($p)."</option>"; } |
|
100 | - else { print "<option value='$p' >"._($p)."</option>"; } |
|
101 | - } |
|
102 | - ?> |
|
98 | + foreach($perms as $k=>$p) { |
|
99 | + if($p==$api->app_security) { print "<option value='$p' selected='selected'>"._($p)."</option>"; } |
|
100 | + else { print "<option value='$p' >"._($p)."</option>"; } |
|
101 | + } |
|
102 | + ?> |
|
103 | 103 | </select> |
104 | 104 | <td class="info2"><?php print _('Application security'); ?></td> |
105 | 105 | </tr> |
@@ -30,7 +30,8 @@ discard block |
||
30 | 30 | $api===false ? $Result->show("danger", _("Invalid ID"), true) : null; |
31 | 31 | # title |
32 | 32 | $title = ucwords($_POST['action']) .' '._('api').' '.$api->app_id; |
33 | -} else { |
|
33 | +} |
|
34 | +else { |
|
34 | 35 | # generate new code |
35 | 36 | $api = new StdClass; |
36 | 37 | $api->app_code = str_shuffle(md5(microtime())); |
@@ -53,7 +54,10 @@ discard block |
||
53 | 54 | <tr> |
54 | 55 | <td><?php print _('App id'); ?></td> |
55 | 56 | <td> |
56 | - <input type="text" name="app_id" class="form-control input-sm" value="<?php print @$api->app_id; ?>" <?php if($_POST['action'] == "delete") print "readonly"; ?>> |
|
57 | + <input type="text" name="app_id" class="form-control input-sm" value="<?php print @$api->app_id; ?>" <?php if($_POST['action'] == "delete") { |
|
58 | + print "readonly"; |
|
59 | +} |
|
60 | +?>> |
|
57 | 61 | <input type="hidden" name="id" value="<?php print $api->id; ?>"> |
58 | 62 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
59 | 63 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
@@ -64,7 +68,10 @@ discard block |
||
64 | 68 | <!-- code --> |
65 | 69 | <tr> |
66 | 70 | <td><?php print _('App code'); ?></td> |
67 | - <td><input type="text" id="appcode" name="app_code" class="form-control input-sm" value="<?php print @$api->app_code; ?>" maxlength='32' <?php if($_POST['action'] == "delete") print "readonly"; ?>></td> |
|
71 | + <td><input type="text" id="appcode" name="app_code" class="form-control input-sm" value="<?php print @$api->app_code; ?>" maxlength='32' <?php if($_POST['action'] == "delete") { |
|
72 | + print "readonly"; |
|
73 | +} |
|
74 | +?>></td> |
|
68 | 75 | <td class="info2"><?php print _('Application code'); ?> <button class="btn btn-xs btn-default" id="regApiKey"><i class="fa fa-random"></i> <?php print _('Regenerate'); ?></button></td> |
69 | 76 | </tr> |
70 | 77 | |
@@ -108,7 +115,10 @@ discard block |
||
108 | 115 | <tr> |
109 | 116 | <td><?php print _('Description'); ?></td> |
110 | 117 | <td> |
111 | - <input type="text" name="app_comment" class="form-control input-sm" value="<?php print @$api->app_comment; ?>" <?php if($_POST['action'] == "delete") print "readonly"; ?>> |
|
118 | + <input type="text" name="app_comment" class="form-control input-sm" value="<?php print @$api->app_comment; ?>" <?php if($_POST['action'] == "delete") { |
|
119 | + print "readonly"; |
|
120 | +} |
|
121 | +?>> |
|
112 | 122 | </td> |
113 | 123 | <td class="info2"><?php print _('Enter description'); ?></td> |
114 | 124 | </tr> |
@@ -125,7 +135,10 @@ discard block |
||
125 | 135 | <div class="pFooter"> |
126 | 136 | <div class="btn-group"> |
127 | 137 | <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
128 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="apiEditSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
138 | + <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } |
|
139 | +else { print "btn-success"; } ?>" id="apiEditSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } |
|
140 | +else if ($_POST['action']=="delete") { print "fa-trash-o"; } |
|
141 | +else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
129 | 142 | </div> |
130 | 143 | <!-- Result --> |
131 | 144 | <div class="apiEditResult"></div> |
@@ -5,37 +5,37 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Result = new Result (); |
15 | 15 | |
16 | 16 | # verify that user is logged in |
17 | -$User->check_user_session(); |
|
17 | +$User->check_user_session (); |
|
18 | 18 | |
19 | 19 | # create csrf token |
20 | 20 | $csrf = $User->csrf_cookie ("create", "apiedit"); |
21 | 21 | |
22 | 22 | # ID must be numeric |
23 | -if($_POST['action']!="add" && !is_numeric($_POST['appid'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
23 | +if ($_POST['action'] != "add" && !is_numeric ($_POST['appid'])) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
24 | 24 | |
25 | 25 | # fetch api for edit / add |
26 | -if($_POST['action']!="add") { |
|
26 | +if ($_POST['action'] != "add") { |
|
27 | 27 | # fetch api details |
28 | 28 | $api = $Admin->fetch_object ("api", "id", $_POST['appid']); |
29 | 29 | # null ? |
30 | - $api===false ? $Result->show("danger", _("Invalid ID"), true) : null; |
|
30 | + $api === false ? $Result->show ("danger", _ ("Invalid ID"), true) : null; |
|
31 | 31 | # title |
32 | - $title = ucwords($_POST['action']) .' '._('api').' '.$api->app_id; |
|
32 | + $title = ucwords ($_POST['action']).' '._ ('api').' '.$api->app_id; |
|
33 | 33 | } else { |
34 | 34 | # generate new code |
35 | 35 | $api = new StdClass; |
36 | - $api->app_code = str_shuffle(md5(microtime())); |
|
36 | + $api->app_code = str_shuffle (md5 (microtime ())); |
|
37 | 37 | # title |
38 | - $title = _('Add new api key'); |
|
38 | + $title = _ ('Add new api key'); |
|
39 | 39 | } |
40 | 40 | ?> |
41 | 41 | |
@@ -51,66 +51,66 @@ discard block |
||
51 | 51 | |
52 | 52 | <!-- id --> |
53 | 53 | <tr> |
54 | - <td><?php print _('App id'); ?></td> |
|
54 | + <td><?php print _ ('App id'); ?></td> |
|
55 | 55 | <td> |
56 | - <input type="text" name="app_id" class="form-control input-sm" value="<?php print @$api->app_id; ?>" <?php if($_POST['action'] == "delete") print "readonly"; ?>> |
|
56 | + <input type="text" name="app_id" class="form-control input-sm" value="<?php print @$api->app_id; ?>" <?php if ($_POST['action'] == "delete") print "readonly"; ?>> |
|
57 | 57 | <input type="hidden" name="id" value="<?php print $api->id; ?>"> |
58 | 58 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
59 | 59 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
60 | 60 | </td> |
61 | - <td class="info2"><?php print _('Enter application identifier'); ?></td> |
|
61 | + <td class="info2"><?php print _ ('Enter application identifier'); ?></td> |
|
62 | 62 | </tr> |
63 | 63 | |
64 | 64 | <!-- code --> |
65 | 65 | <tr> |
66 | - <td><?php print _('App code'); ?></td> |
|
67 | - <td><input type="text" id="appcode" name="app_code" class="form-control input-sm" value="<?php print @$api->app_code; ?>" maxlength='32' <?php if($_POST['action'] == "delete") print "readonly"; ?>></td> |
|
68 | - <td class="info2"><?php print _('Application code'); ?> <button class="btn btn-xs btn-default" id="regApiKey"><i class="fa fa-random"></i> <?php print _('Regenerate'); ?></button></td> |
|
66 | + <td><?php print _ ('App code'); ?></td> |
|
67 | + <td><input type="text" id="appcode" name="app_code" class="form-control input-sm" value="<?php print @$api->app_code; ?>" maxlength='32' <?php if ($_POST['action'] == "delete") print "readonly"; ?>></td> |
|
68 | + <td class="info2"><?php print _ ('Application code'); ?> <button class="btn btn-xs btn-default" id="regApiKey"><i class="fa fa-random"></i> <?php print _ ('Regenerate'); ?></button></td> |
|
69 | 69 | </tr> |
70 | 70 | |
71 | 71 | <!-- permissions --> |
72 | 72 | <tr> |
73 | - <td><?php print _('App permissions'); ?></td> |
|
73 | + <td><?php print _ ('App permissions'); ?></td> |
|
74 | 74 | <td> |
75 | 75 | <select name="app_permissions" class="form-control input-sm input-w-auto"> |
76 | 76 | <?php |
77 | - $perms = array(0=>"Disabled",1=>"Read",2=>"Read / Write",3=>"Read / Write / Admin"); |
|
78 | - foreach($perms as $k=>$p) { |
|
79 | - if($k==$api->app_permissions) { print "<option value='$k' selected='selected'>"._($p)."</option>"; } |
|
80 | - else { print "<option value='$k' >"._($p)."</option>"; } |
|
77 | + $perms = array (0=>"Disabled", 1=>"Read", 2=>"Read / Write", 3=>"Read / Write / Admin"); |
|
78 | + foreach ($perms as $k=>$p) { |
|
79 | + if ($k == $api->app_permissions) { print "<option value='$k' selected='selected'>"._ ($p)."</option>"; } |
|
80 | + else { print "<option value='$k' >"._ ($p)."</option>"; } |
|
81 | 81 | } |
82 | 82 | ?> |
83 | 83 | </select> |
84 | - <td class="info2"><?php print _('Application permissions'); ?></td> |
|
84 | + <td class="info2"><?php print _ ('Application permissions'); ?></td> |
|
85 | 85 | </tr> |
86 | 86 | |
87 | 87 | <!-- Security --> |
88 | 88 | <tr> |
89 | - <td><?php print _('App security'); ?></td> |
|
89 | + <td><?php print _ ('App security'); ?></td> |
|
90 | 90 | <td> |
91 | 91 | <select name="app_security" class="form-control input-sm input-w-auto"> |
92 | 92 | <?php |
93 | - $perms = array(0=>"crypt",1=>"ssl",2=>"none",3=>"user"); |
|
93 | + $perms = array (0=>"crypt", 1=>"ssl", 2=>"none", 3=>"user"); |
|
94 | 94 | |
95 | 95 | // user not yet supported |
96 | 96 | unset($perms[3]); |
97 | 97 | |
98 | - foreach($perms as $k=>$p) { |
|
99 | - if($p==$api->app_security) { print "<option value='$p' selected='selected'>"._($p)."</option>"; } |
|
100 | - else { print "<option value='$p' >"._($p)."</option>"; } |
|
98 | + foreach ($perms as $k=>$p) { |
|
99 | + if ($p == $api->app_security) { print "<option value='$p' selected='selected'>"._ ($p)."</option>"; } |
|
100 | + else { print "<option value='$p' >"._ ($p)."</option>"; } |
|
101 | 101 | } |
102 | 102 | ?> |
103 | 103 | </select> |
104 | - <td class="info2"><?php print _('Application security'); ?></td> |
|
104 | + <td class="info2"><?php print _ ('Application security'); ?></td> |
|
105 | 105 | </tr> |
106 | 106 | |
107 | 107 | <!-- description --> |
108 | 108 | <tr> |
109 | - <td><?php print _('Description'); ?></td> |
|
109 | + <td><?php print _ ('Description'); ?></td> |
|
110 | 110 | <td> |
111 | - <input type="text" name="app_comment" class="form-control input-sm" value="<?php print @$api->app_comment; ?>" <?php if($_POST['action'] == "delete") print "readonly"; ?>> |
|
111 | + <input type="text" name="app_comment" class="form-control input-sm" value="<?php print @$api->app_comment; ?>" <?php if ($_POST['action'] == "delete") print "readonly"; ?>> |
|
112 | 112 | </td> |
113 | - <td class="info2"><?php print _('Enter description'); ?></td> |
|
113 | + <td class="info2"><?php print _ ('Enter description'); ?></td> |
|
114 | 114 | </tr> |
115 | 115 | |
116 | 116 | </table> |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | <!-- footer --> |
125 | 125 | <div class="pFooter"> |
126 | 126 | <div class="btn-group"> |
127 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
128 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="apiEditSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
127 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
128 | + <button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="apiEditSubmit"><i class="fa <?php if ($_POST['action'] == "add") { print "fa-plus"; } else if ($_POST['action'] == "delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button> |
|
129 | 129 | </div> |
130 | 130 | <!-- Result --> |
131 | 131 | <div class="apiEditResult"></div> |
@@ -34,22 +34,22 @@ discard block |
||
34 | 34 | |
35 | 35 | # ok, lets get results form post array! |
36 | 36 | foreach($_POST as $key=>$line) { |
37 | - // IP address |
|
38 | - if(substr($key, 0,4)=="name") { $res[substr($key, 4)]['name'] = $line; } |
|
39 | - // mac |
|
40 | - elseif(substr($key, 0,6)=="number") { $res[substr($key, 6)]['number'] = $line; } |
|
41 | - // device |
|
42 | - elseif(substr($key, 0,8)=="domainId") { $res[substr($key, 8)]['domainId'] = $line; } |
|
43 | - // description |
|
44 | - elseif(substr($key, 0,11)=="description") { $res[substr($key, 11)]['description'] = $line; } |
|
45 | - // custom fields |
|
46 | - elseif (isset($required_fields)) { |
|
47 | - foreach ($required_fields as $k=>$f) { |
|
48 | - if((strpos($key, $f['name'])) !== false) { |
|
37 | + // IP address |
|
38 | + if(substr($key, 0,4)=="name") { $res[substr($key, 4)]['name'] = $line; } |
|
39 | + // mac |
|
40 | + elseif(substr($key, 0,6)=="number") { $res[substr($key, 6)]['number'] = $line; } |
|
41 | + // device |
|
42 | + elseif(substr($key, 0,8)=="domainId") { $res[substr($key, 8)]['domainId'] = $line; } |
|
43 | + // description |
|
44 | + elseif(substr($key, 0,11)=="description") { $res[substr($key, 11)]['description'] = $line; } |
|
45 | + // custom fields |
|
46 | + elseif (isset($required_fields)) { |
|
47 | + foreach ($required_fields as $k=>$f) { |
|
48 | + if((strpos($key, $f['name'])) !== false) { |
|
49 | 49 | { $res[substr($key, strlen($f['name']))][$f['name']] = $line; } |
50 | - } |
|
51 | - } |
|
52 | - } |
|
50 | + } |
|
51 | + } |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /* |
@@ -60,26 +60,26 @@ discard block |
||
60 | 60 | |
61 | 61 | # insert entries |
62 | 62 | if(sizeof($res)>0) { |
63 | - $errors = 0; |
|
64 | - foreach($res as $r) { |
|
65 | - # set insert values |
|
66 | - $values = array("number"=>$r['number'], |
|
67 | - "name"=>$r['name'], |
|
68 | - "domainId"=>$r['domainId'], |
|
69 | - "description"=>$r['description'] |
|
70 | - ); |
|
63 | + $errors = 0; |
|
64 | + foreach($res as $r) { |
|
65 | + # set insert values |
|
66 | + $values = array("number"=>$r['number'], |
|
67 | + "name"=>$r['name'], |
|
68 | + "domainId"=>$r['domainId'], |
|
69 | + "description"=>$r['description'] |
|
70 | + ); |
|
71 | 71 | # custom fields |
72 | - if (isset($required_fields)) { |
|
73 | - foreach ($required_fields as $k=>$f) { |
|
74 | - $values[$f['name']] = $r[$f['name']]; |
|
75 | - } |
|
76 | - } |
|
72 | + if (isset($required_fields)) { |
|
73 | + foreach ($required_fields as $k=>$f) { |
|
74 | + $values[$f['name']] = $r[$f['name']]; |
|
75 | + } |
|
76 | + } |
|
77 | 77 | # insert vlans |
78 | 78 | if(!$Admin->object_modify("vlans", "add", "vlanId", $values)) { $Result->show("danger", _("Failed to import entry")." ".$r['number']." ".$r['name'], false); $errors++; } |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - # success if no errors |
|
82 | - if($errors==0) { $Result->show("success", _("Scan results added to database")."!", true); } |
|
81 | + # success if no errors |
|
82 | + if($errors==0) { $Result->show("success", _("Scan results added to database")."!", true); } |
|
83 | 83 | } |
84 | 84 | # error |
85 | 85 | else { $Result->show("danger", _("No entries available"), true); } |
@@ -4,49 +4,49 @@ discard block |
||
4 | 4 | *******************************/ |
5 | 5 | |
6 | 6 | /* functions */ |
7 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
7 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
8 | 8 | |
9 | 9 | # initialize user object |
10 | -$Database = new Database_PDO; |
|
11 | -$User = new User ($Database); |
|
10 | +$Database = new Database_PDO; |
|
11 | +$User = new User ($Database); |
|
12 | 12 | $Admin = new Admin ($Database); |
13 | 13 | $Subnets = new Subnets ($Database); |
14 | -$Addresses = new Addresses ($Database); |
|
15 | -$Tools = new Tools ($Database); |
|
14 | +$Addresses = new Addresses ($Database); |
|
15 | +$Tools = new Tools ($Database); |
|
16 | 16 | $Result = new Result (); |
17 | 17 | |
18 | 18 | # verify that user is logged in |
19 | -$User->check_user_session(); |
|
19 | +$User->check_user_session (); |
|
20 | 20 | |
21 | 21 | # check for number of input values |
22 | -$max = ini_get("max_input_vars"); |
|
23 | -if(sizeof($_POST)>=ini_get("max_input_vars")) { $Result->show("danger", _("Number of discovered hosts exceed maximum possible defined by php.ini - set to ")." $max <hr>"._("Please adjust your php.ini settings for value `max_input_vars`"), true); } |
|
22 | +$max = ini_get ("max_input_vars"); |
|
23 | +if (sizeof ($_POST) >= ini_get ("max_input_vars")) { $Result->show ("danger", _ ("Number of discovered hosts exceed maximum possible defined by php.ini - set to ")." $max <hr>"._ ("Please adjust your php.ini settings for value `max_input_vars`"), true); } |
|
24 | 24 | |
25 | 25 | // fetch custom fields and check for required |
26 | 26 | $required_fields = $Tools->fetch_custom_fields ('vlans'); |
27 | -if($required_fields!==false) { |
|
27 | +if ($required_fields !== false) { |
|
28 | 28 | foreach ($required_fields as $k=>$f) { |
29 | - if ($f['Null']!="NO") { |
|
29 | + if ($f['Null'] != "NO") { |
|
30 | 30 | unset($required_fields[$k]); |
31 | 31 | } |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | 35 | # ok, lets get results form post array! |
36 | -foreach($_POST as $key=>$line) { |
|
36 | +foreach ($_POST as $key=>$line) { |
|
37 | 37 | // IP address |
38 | - if(substr($key, 0,4)=="name") { $res[substr($key, 4)]['name'] = $line; } |
|
38 | + if (substr ($key, 0, 4) == "name") { $res[substr ($key, 4)]['name'] = $line; } |
|
39 | 39 | // mac |
40 | - elseif(substr($key, 0,6)=="number") { $res[substr($key, 6)]['number'] = $line; } |
|
40 | + elseif (substr ($key, 0, 6) == "number") { $res[substr ($key, 6)]['number'] = $line; } |
|
41 | 41 | // device |
42 | - elseif(substr($key, 0,8)=="domainId") { $res[substr($key, 8)]['domainId'] = $line; } |
|
42 | + elseif (substr ($key, 0, 8) == "domainId") { $res[substr ($key, 8)]['domainId'] = $line; } |
|
43 | 43 | // description |
44 | - elseif(substr($key, 0,11)=="description") { $res[substr($key, 11)]['description'] = $line; } |
|
44 | + elseif (substr ($key, 0, 11) == "description") { $res[substr ($key, 11)]['description'] = $line; } |
|
45 | 45 | // custom fields |
46 | 46 | elseif (isset($required_fields)) { |
47 | 47 | foreach ($required_fields as $k=>$f) { |
48 | - if((strpos($key, $f['name'])) !== false) { |
|
49 | - { $res[substr($key, strlen($f['name']))][$f['name']] = $line; } |
|
48 | + if ((strpos ($key, $f['name'])) !== false) { |
|
49 | + { $res[substr ($key, strlen ($f['name']))][$f['name']] = $line; } |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | */ |
60 | 60 | |
61 | 61 | # insert entries |
62 | -if(sizeof($res)>0) { |
|
62 | +if (sizeof ($res) > 0) { |
|
63 | 63 | $errors = 0; |
64 | - foreach($res as $r) { |
|
64 | + foreach ($res as $r) { |
|
65 | 65 | # set insert values |
66 | - $values = array("number"=>$r['number'], |
|
66 | + $values = array ("number"=>$r['number'], |
|
67 | 67 | "name"=>$r['name'], |
68 | 68 | "domainId"=>$r['domainId'], |
69 | 69 | "description"=>$r['description'] |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | } |
76 | 76 | } |
77 | 77 | # insert vlans |
78 | - if(!$Admin->object_modify("vlans", "add", "vlanId", $values)) { $Result->show("danger", _("Failed to import entry")." ".$r['number']." ".$r['name'], false); $errors++; } |
|
78 | + if (!$Admin->object_modify ("vlans", "add", "vlanId", $values)) { $Result->show ("danger", _ ("Failed to import entry")." ".$r['number']." ".$r['name'], false); $errors++; } |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | # success if no errors |
82 | - if($errors==0) { $Result->show("success", _("Scan results added to database")."!", true); } |
|
82 | + if ($errors == 0) { $Result->show ("success", _ ("Scan results added to database")."!", true); } |
|
83 | 83 | } |
84 | 84 | # error |
85 | -else { $Result->show("danger", _("No entries available"), true); } |
|
85 | +else { $Result->show ("danger", _ ("No entries available"), true); } |
|
86 | 86 | ?> |
87 | 87 | \ No newline at end of file |
@@ -100,7 +100,10 @@ |
||
100 | 100 | <div class="pFooter"> |
101 | 101 | <div class="btn-group"> |
102 | 102 | <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
103 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?> editVLANdomainsubmit" id="editVLANdomainsubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
103 | + <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } |
|
104 | +else { print "btn-success"; } ?> editVLANdomainsubmit" id="editVLANdomainsubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } |
|
105 | +else if ($_POST['action']=="delete") { print "fa-trash-o"; } |
|
106 | +else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
104 | 107 | </div> |
105 | 108 | |
106 | 109 | <!-- result --> |
@@ -70,19 +70,19 @@ discard block |
||
70 | 70 | <td style="vertical-align: top !important"><?php print _('Sections to display domain in'); ?>:</td> |
71 | 71 | <td> |
72 | 72 | <?php |
73 | - # select sections |
|
74 | - $sections = $Sections->fetch_all_sections(); |
|
75 | - # reformat domains sections to array |
|
76 | - $domain_sections = explode(";", @$l2_domain['permissions']); |
|
77 | - $domain_sections = is_array($domain_sections) ? $domain_sections : array(); |
|
78 | - // loop |
|
79 | - if($sections!==false) { |
|
80 | - foreach($sections as $section) { |
|
81 | - if(in_array($section->id, @$domain_sections) || @$l2_domain['id']=="1") { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on" checked> '. $section->name .'</div>'. "\n"; } |
|
82 | - else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on">'. $section->name .'</span></div>'. "\n"; } |
|
83 | - } |
|
84 | - } |
|
85 | - ?> |
|
73 | + # select sections |
|
74 | + $sections = $Sections->fetch_all_sections(); |
|
75 | + # reformat domains sections to array |
|
76 | + $domain_sections = explode(";", @$l2_domain['permissions']); |
|
77 | + $domain_sections = is_array($domain_sections) ? $domain_sections : array(); |
|
78 | + // loop |
|
79 | + if($sections!==false) { |
|
80 | + foreach($sections as $section) { |
|
81 | + if(in_array($section->id, @$domain_sections) || @$l2_domain['id']=="1") { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on" checked> '. $section->name .'</div>'. "\n"; } |
|
82 | + else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on">'. $section->name .'</span></div>'. "\n"; } |
|
83 | + } |
|
84 | + } |
|
85 | + ?> |
|
86 | 86 | </td> |
87 | 87 | </tr> |
88 | 88 | |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | </form> |
91 | 91 | |
92 | 92 | <?php |
93 | - //print delete warning |
|
94 | - if($_POST['action'] == "delete") { $Result->show("warning", _('Warning').':</strong> '._('removing vlan domain will move all belonging vlans to default domain')."!", false); } |
|
95 | - ?> |
|
93 | + //print delete warning |
|
94 | + if($_POST['action'] == "delete") { $Result->show("warning", _('Warning').':</strong> '._('removing vlan domain will move all belonging vlans to default domain')."!", false); } |
|
95 | + ?> |
|
96 | 96 | </div> |
97 | 97 | |
98 | 98 |
@@ -5,28 +5,28 @@ discard block |
||
5 | 5 | ************************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | -$Sections = new Sections ($Database); |
|
15 | +$Sections = new Sections ($Database); |
|
16 | 16 | $Result = new Result (); |
17 | 17 | |
18 | 18 | # verify that user is logged in |
19 | -$User->check_user_session(); |
|
19 | +$User->check_user_session (); |
|
20 | 20 | |
21 | 21 | # create csrf token |
22 | 22 | $csrf = $User->csrf_cookie ("create", "vlan_domain"); |
23 | 23 | |
24 | 24 | # fetch vlan details |
25 | 25 | $l2_domain = $Admin->fetch_object ("vlanDomains", "id", @$_POST['id']); |
26 | -$l2_domain = $l2_domain!==false ? (array) $l2_domain : array(); |
|
26 | +$l2_domain = $l2_domain !== false ? (array) $l2_domain : array (); |
|
27 | 27 | |
28 | 28 | # set readonly flag |
29 | -$readonly = $_POST['action']=="delete" ? "readonly" : ""; |
|
29 | +$readonly = $_POST['action'] == "delete" ? "readonly" : ""; |
|
30 | 30 | |
31 | 31 | ?> |
32 | 32 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | |
40 | 40 | <!-- header --> |
41 | -<div class="pHeader"><?php print ucwords(_("$_POST[action]")); ?> <?php print _('l2 domain'); ?></div> |
|
41 | +<div class="pHeader"><?php print ucwords (_ ("$_POST[action]")); ?> <?php print _ ('l2 domain'); ?></div> |
|
42 | 42 | |
43 | 43 | <!-- content --> |
44 | 44 | <div class="pContent"> |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | <table class="table table-noborder table-condensed"> |
48 | 48 | <!-- number --> |
49 | 49 | <tr> |
50 | - <td><?php print _('Name'); ?></td> |
|
50 | + <td><?php print _ ('Name'); ?></td> |
|
51 | 51 | <td> |
52 | - <input type="text" class="number form-control input-sm" name="name" placeholder="<?php print _('domain name'); ?>" value="<?php print @$l2_domain['name']; ?>" <?php print $readonly; ?>> |
|
52 | + <input type="text" class="number form-control input-sm" name="name" placeholder="<?php print _ ('domain name'); ?>" value="<?php print @$l2_domain['name']; ?>" <?php print $readonly; ?>> |
|
53 | 53 | </td> |
54 | 54 | </tr> |
55 | 55 | <!-- Description --> |
56 | 56 | <tr> |
57 | - <td><?php print _('Description'); ?></td> |
|
57 | + <td><?php print _ ('Description'); ?></td> |
|
58 | 58 | <td> |
59 | - <input type="text" class="description form-control input-sm" name="description" placeholder="<?php print _('Description'); ?>" value="<?php print @$l2_domain['description']; ?>" <?php print $readonly; ?>> |
|
59 | + <input type="text" class="description form-control input-sm" name="description" placeholder="<?php print _ ('Description'); ?>" value="<?php print @$l2_domain['description']; ?>" <?php print $readonly; ?>> |
|
60 | 60 | <input type="hidden" name="id" value="<?php print @$_POST['id']; ?>"> |
61 | 61 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
62 | 62 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
@@ -67,19 +67,19 @@ discard block |
||
67 | 67 | </tr> |
68 | 68 | <!-- sections --> |
69 | 69 | <tr> |
70 | - <td style="vertical-align: top !important"><?php print _('Sections to display domain in'); ?>:</td> |
|
70 | + <td style="vertical-align: top !important"><?php print _ ('Sections to display domain in'); ?>:</td> |
|
71 | 71 | <td> |
72 | 72 | <?php |
73 | 73 | # select sections |
74 | - $sections = $Sections->fetch_all_sections(); |
|
74 | + $sections = $Sections->fetch_all_sections (); |
|
75 | 75 | # reformat domains sections to array |
76 | - $domain_sections = explode(";", @$l2_domain['permissions']); |
|
77 | - $domain_sections = is_array($domain_sections) ? $domain_sections : array(); |
|
76 | + $domain_sections = explode (";", @$l2_domain['permissions']); |
|
77 | + $domain_sections = is_array ($domain_sections) ? $domain_sections : array (); |
|
78 | 78 | // loop |
79 | - if($sections!==false) { |
|
80 | - foreach($sections as $section) { |
|
81 | - if(in_array($section->id, @$domain_sections) || @$l2_domain['id']=="1") { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on" checked> '. $section->name .'</div>'. "\n"; } |
|
82 | - else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'. $section->id .'" value="on">'. $section->name .'</span></div>'. "\n"; } |
|
79 | + if ($sections !== false) { |
|
80 | + foreach ($sections as $section) { |
|
81 | + if (in_array ($section->id, @$domain_sections) || @$l2_domain['id'] == "1") { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'.$section->id.'" value="on" checked> '.$section->name.'</div>'."\n"; } |
|
82 | + else { print '<div class="checkbox" style="margin:0px;"><input type="checkbox" name="section-'.$section->id.'" value="on">'.$section->name.'</span></div>'."\n"; } |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | ?> |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | <?php |
93 | 93 | //print delete warning |
94 | - if($_POST['action'] == "delete") { $Result->show("warning", _('Warning').':</strong> '._('removing vlan domain will move all belonging vlans to default domain')."!", false); } |
|
94 | + if ($_POST['action'] == "delete") { $Result->show ("warning", _ ('Warning').':</strong> '._ ('removing vlan domain will move all belonging vlans to default domain')."!", false); } |
|
95 | 95 | ?> |
96 | 96 | </div> |
97 | 97 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | <!-- footer --> |
100 | 100 | <div class="pFooter"> |
101 | 101 | <div class="btn-group"> |
102 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
103 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?> editVLANdomainsubmit" id="editVLANdomainsubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
102 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
103 | + <button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?> editVLANdomainsubmit" id="editVLANdomainsubmit"><i class="fa <?php if ($_POST['action'] == "add") { print "fa-plus"; } else if ($_POST['action'] == "delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button> |
|
104 | 104 | </div> |
105 | 105 | |
106 | 106 | <!-- result --> |
@@ -33,26 +33,26 @@ discard block |
||
33 | 33 | |
34 | 34 | // set sections |
35 | 35 | if(@$_POST['id']!=1) { |
36 | - foreach($_POST as $key=>$line) { |
|
37 | - if (strlen(strstr($key,"section-"))>0) { |
|
38 | - $key2 = str_replace("section-", "", $key); |
|
39 | - $temp[] = $key2; |
|
40 | - unset($_POST[$key]); |
|
41 | - } |
|
42 | - } |
|
43 | - # glue sections together |
|
44 | - $_POST['permissions'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
|
36 | + foreach($_POST as $key=>$line) { |
|
37 | + if (strlen(strstr($key,"section-"))>0) { |
|
38 | + $key2 = str_replace("section-", "", $key); |
|
39 | + $temp[] = $key2; |
|
40 | + unset($_POST[$key]); |
|
41 | + } |
|
42 | + } |
|
43 | + # glue sections together |
|
44 | + $_POST['permissions'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
|
45 | 45 | } |
46 | 46 | else { |
47 | - $_POST['permissions'] = ""; |
|
47 | + $_POST['permissions'] = ""; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | # set update values |
51 | 51 | $values = array("id"=>@$_POST['id'], |
52 | - "name"=>@$_POST['name'], |
|
53 | - "description"=>@$_POST['description'], |
|
54 | - "permissions"=>@$_POST['permissions'] |
|
55 | - ); |
|
52 | + "name"=>@$_POST['name'], |
|
53 | + "description"=>@$_POST['description'], |
|
54 | + "permissions"=>@$_POST['permissions'] |
|
55 | + ); |
|
56 | 56 | |
57 | 57 | # update domain |
58 | 58 | if(!$Admin->object_modify("vlanDomains", $_POST['action'], "id", $values)) {} |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | # if delete move all vlans to default domain! |
62 | 62 | if($_POST['action']=="delete") { |
63 | - $Admin->update_object_references ("vlans", "domainId", $_POST['id'], 1); |
|
63 | + $Admin->update_object_references ("vlans", "domainId", $_POST['id'], 1); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | ?> |
67 | 67 | \ No newline at end of file |
@@ -5,61 +5,61 @@ |
||
5 | 5 | ***************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # strip input tags |
21 | -$_POST = $Admin->strip_input_tags($_POST); |
|
21 | +$_POST = $Admin->strip_input_tags ($_POST); |
|
22 | 22 | |
23 | 23 | # validate csrf cookie |
24 | -$User->csrf_cookie ("validate", "vlan_domain", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
24 | +$User->csrf_cookie ("validate", "vlan_domain", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
25 | 25 | |
26 | 26 | # we cannot delete default domain |
27 | -if(@$_POST['id']==1 && $_POST['action']=="delete") { $Result->show("danger", _("Default domain cannot be deleted"), true); } |
|
27 | +if (@$_POST['id'] == 1 && $_POST['action'] == "delete") { $Result->show ("danger", _ ("Default domain cannot be deleted"), true); } |
|
28 | 28 | // ID must be numeric |
29 | -if($_POST['action']!="add" && !is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true); } |
|
29 | +if ($_POST['action'] != "add" && !is_numeric ($_POST['id'])) { $Result->show ("danger", _ ("Invalid ID"), true); } |
|
30 | 30 | // Hostname must be present |
31 | -if(@$_POST['name'] == "") { $Result->show("danger", _('Name is mandatory').'!', true); } |
|
31 | +if (@$_POST['name'] == "") { $Result->show ("danger", _ ('Name is mandatory').'!', true); } |
|
32 | 32 | |
33 | 33 | |
34 | 34 | // set sections |
35 | -if(@$_POST['id']!=1) { |
|
36 | - foreach($_POST as $key=>$line) { |
|
37 | - if (strlen(strstr($key,"section-"))>0) { |
|
38 | - $key2 = str_replace("section-", "", $key); |
|
35 | +if (@$_POST['id'] != 1) { |
|
36 | + foreach ($_POST as $key=>$line) { |
|
37 | + if (strlen (strstr ($key, "section-")) > 0) { |
|
38 | + $key2 = str_replace ("section-", "", $key); |
|
39 | 39 | $temp[] = $key2; |
40 | 40 | unset($_POST[$key]); |
41 | 41 | } |
42 | 42 | } |
43 | 43 | # glue sections together |
44 | - $_POST['permissions'] = sizeof($temp)>0 ? implode(";", $temp) : null; |
|
44 | + $_POST['permissions'] = sizeof ($temp) > 0 ? implode (";", $temp) : null; |
|
45 | 45 | } |
46 | 46 | else { |
47 | 47 | $_POST['permissions'] = ""; |
48 | 48 | } |
49 | 49 | |
50 | 50 | # set update values |
51 | -$values = array("id"=>@$_POST['id'], |
|
51 | +$values = array ("id"=>@$_POST['id'], |
|
52 | 52 | "name"=>@$_POST['name'], |
53 | 53 | "description"=>@$_POST['description'], |
54 | 54 | "permissions"=>@$_POST['permissions'] |
55 | 55 | ); |
56 | 56 | |
57 | 57 | # update domain |
58 | -if(!$Admin->object_modify("vlanDomains", $_POST['action'], "id", $values)) {} |
|
59 | -else { $Result->show("success", _("Domain $_POST[action] successfull").'!', false); } |
|
58 | +if (!$Admin->object_modify ("vlanDomains", $_POST['action'], "id", $values)) {} |
|
59 | +else { $Result->show ("success", _ ("Domain $_POST[action] successfull").'!', false); } |
|
60 | 60 | |
61 | 61 | # if delete move all vlans to default domain! |
62 | -if($_POST['action']=="delete") { |
|
62 | +if ($_POST['action'] == "delete") { |
|
63 | 63 | $Admin->update_object_references ("vlans", "domainId", $_POST['id'], 1); |
64 | 64 | } |
65 | 65 |
@@ -59,14 +59,14 @@ |
||
59 | 59 | <input type="hidden" name="vlanId" value="<?php print $vlan->vlanId; ?>"> |
60 | 60 | <select name="newDomainId" class="form-control input-w-auto input-sm"> |
61 | 61 | <?php |
62 | - $m=0; |
|
63 | - foreach($vlan_domains as $d) { |
|
64 | - if($d->id!=$vlan_domain->id) { |
|
65 | - print "<option value='$d->id'>$d->name ($d->description)</option>"; |
|
66 | - $m++; |
|
67 | - } |
|
68 | - } |
|
69 | - ?> |
|
62 | + $m=0; |
|
63 | + foreach($vlan_domains as $d) { |
|
64 | + if($d->id!=$vlan_domain->id) { |
|
65 | + print "<option value='$d->id'>$d->name ($d->description)</option>"; |
|
66 | + $m++; |
|
67 | + } |
|
68 | + } |
|
69 | + ?> |
|
70 | 70 | </select> |
71 | 71 | </td> |
72 | 72 | </tr> |
@@ -74,7 +74,10 @@ |
||
74 | 74 | </table> |
75 | 75 | </form> |
76 | 76 | |
77 | - <?php if($m==0) $Result->show("warning", _("No domains available!"), false); ?> |
|
77 | + <?php if($m==0) { |
|
78 | + $Result->show("warning", _("No domains available!"), false); |
|
79 | +} |
|
80 | +?> |
|
78 | 81 | |
79 | 82 | </div> |
80 | 83 |
@@ -5,29 +5,29 @@ discard block |
||
5 | 5 | ************************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | |
21 | 21 | # fetch vlan details |
22 | 22 | $vlan = $Admin->fetch_object ("vlans", "vlanId", @$_POST['vlanId']); |
23 | -if($vlan===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
23 | +if ($vlan === false) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
24 | 24 | |
25 | 25 | # fetch current domain |
26 | -$vlan_domain = $Admin->fetch_object("vlanDomains", "id", $vlan->domainId); |
|
27 | -if($vlan_domain===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
26 | +$vlan_domain = $Admin->fetch_object ("vlanDomains", "id", $vlan->domainId); |
|
27 | +if ($vlan_domain === false) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
28 | 28 | |
29 | 29 | # fetch all l2 domains |
30 | -$vlan_domains = $Admin->fetch_all_objects("vlanDomains", "id"); |
|
30 | +$vlan_domains = $Admin->fetch_all_objects ("vlanDomains", "id"); |
|
31 | 31 | ?> |
32 | 32 | |
33 | 33 | <script type="text/javascript"> |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | </script> |
38 | 38 | |
39 | 39 | <!-- header --> |
40 | -<div class="pHeader"><?php print ucwords("Move VLAN to new domain"); ?></div> |
|
40 | +<div class="pHeader"><?php print ucwords ("Move VLAN to new domain"); ?></div> |
|
41 | 41 | |
42 | 42 | <!-- content --> |
43 | 43 | <div class="pContent"> |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | <table class="table table-noborder table-condensed"> |
47 | 47 | <!-- domain --> |
48 | 48 | <tr> |
49 | - <td><?php print _('Current l2 domain'); ?></td> |
|
49 | + <td><?php print _ ('Current l2 domain'); ?></td> |
|
50 | 50 | <th><?php print $vlan_domain->name." (".$vlan_domain->description.")"; ?></th> |
51 | 51 | </tr> |
52 | 52 | <tr> |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | </tr> |
55 | 55 | <!-- new domain --> |
56 | 56 | <tr> |
57 | - <td><?php print _('New domain'); ?></td> |
|
57 | + <td><?php print _ ('New domain'); ?></td> |
|
58 | 58 | <td> |
59 | 59 | <input type="hidden" name="vlanId" value="<?php print $vlan->vlanId; ?>"> |
60 | 60 | <select name="newDomainId" class="form-control input-w-auto input-sm"> |
61 | 61 | <?php |
62 | - $m=0; |
|
63 | - foreach($vlan_domains as $d) { |
|
64 | - if($d->id!=$vlan_domain->id) { |
|
62 | + $m = 0; |
|
63 | + foreach ($vlan_domains as $d) { |
|
64 | + if ($d->id != $vlan_domain->id) { |
|
65 | 65 | print "<option value='$d->id'>$d->name ($d->description)</option>"; |
66 | 66 | $m++; |
67 | 67 | } |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | </table> |
75 | 75 | </form> |
76 | 76 | |
77 | - <?php if($m==0) $Result->show("warning", _("No domains available!"), false); ?> |
|
77 | + <?php if ($m == 0) $Result->show ("warning", _ ("No domains available!"), false); ?> |
|
78 | 78 | |
79 | 79 | </div> |
80 | 80 | |
81 | 81 | <!-- footer --> |
82 | 82 | <div class="pFooter"> |
83 | 83 | <div class="btn-group"> |
84 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
85 | - <?php if($m>0) { ?> |
|
84 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
85 | + <?php if ($m > 0) { ?> |
|
86 | 86 | <button class="btn btn-sm btn-default btn-success" id="moveVLANsubmit"><?php print ("Move"); ?></button> |
87 | 87 | <?php } ?> |
88 | 88 | </div> |
@@ -28,46 +28,46 @@ |
||
28 | 28 | |
29 | 29 | //if it already exist die |
30 | 30 | if($User->settings->vlanDuplicate==0 && $_POST['action']=="add") { |
31 | - $check_vlan = $Admin->fetch_multiple_objects ("vlans", "domainId", $_POST['domainId'], "vlanId"); |
|
32 | - if($check_vlan!==false) { |
|
33 | - foreach($check_vlan as $v) { |
|
34 | - if($v->number == $_POST['number']) { |
|
35 | - { $Result->show("danger", _("VLAN already exists"), true); } |
|
36 | - } |
|
37 | - } |
|
38 | - } |
|
31 | + $check_vlan = $Admin->fetch_multiple_objects ("vlans", "domainId", $_POST['domainId'], "vlanId"); |
|
32 | + if($check_vlan!==false) { |
|
33 | + foreach($check_vlan as $v) { |
|
34 | + if($v->number == $_POST['number']) { |
|
35 | + { $Result->show("danger", _("VLAN already exists"), true); } |
|
36 | + } |
|
37 | + } |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // if unique required |
42 | 42 | if (isset($_POST['unique'])) { |
43 | - if ($_POST['unique']=="on") { |
|
44 | - if ($Tools->fetch_object ("vlans", "number", $_POST['number'])!==false) { $Result->show("danger", _("VLAN already exists in another domain!"), true); } |
|
45 | - } |
|
43 | + if ($_POST['unique']=="on") { |
|
44 | + if ($Tools->fetch_object ("vlans", "number", $_POST['number'])!==false) { $Result->show("danger", _("VLAN already exists in another domain!"), true); } |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | //if number too high |
49 | 49 | if($_POST['number']>$User->settings->vlanMax && $_POST['action']!="delete") { $Result->show("danger", _('Highest possible VLAN number is ').$settings['vlanMax'].'!', true); } |
50 | 50 | if($_POST['action']=="add") { |
51 | - if($_POST['number']<0) { $Result->show("danger", _('VLAN number cannot be negative').'!', true); } |
|
52 | - elseif(!is_numeric($_POST['number'])) { $Result->show("danger", _('Not number').'!', true); } |
|
51 | + if($_POST['number']<0) { $Result->show("danger", _('VLAN number cannot be negative').'!', true); } |
|
52 | + elseif(!is_numeric($_POST['number'])) { $Result->show("danger", _('Not number').'!', true); } |
|
53 | 53 | } |
54 | 54 | if(strlen($_POST['name'])==0) { $Result->show("danger", _('Name is required').'!', true); } |
55 | 55 | |
56 | 56 | |
57 | 57 | # formulate update query |
58 | 58 | $values = array("vlanId"=>@$_POST['vlanId'], |
59 | - "number"=>$_POST['number'], |
|
60 | - "name"=>$_POST['name'], |
|
61 | - "description"=>@$_POST['description'], |
|
62 | - "domainId"=>$_POST['domainId'] |
|
63 | - ); |
|
59 | + "number"=>$_POST['number'], |
|
60 | + "name"=>$_POST['name'], |
|
61 | + "description"=>@$_POST['description'], |
|
62 | + "domainId"=>$_POST['domainId'] |
|
63 | + ); |
|
64 | 64 | # append custom |
65 | 65 | if(sizeof($custom) > 0) { |
66 | - foreach($custom as $myField) { |
|
67 | - # replace possible ___ back to spaces! |
|
68 | - $myField['nameTest'] = str_replace(" ", "___", $myField['name']); |
|
69 | - if(isset($_POST[$myField['nameTest']])) { $values[$myField['name']] = @$_POST[$myField['nameTest']];} |
|
70 | - } |
|
66 | + foreach($custom as $myField) { |
|
67 | + # replace possible ___ back to spaces! |
|
68 | + $myField['nameTest'] = str_replace(" ", "___", $myField['name']); |
|
69 | + if(isset($_POST[$myField['nameTest']])) { $values[$myField['name']] = @$_POST[$myField['nameTest']];} |
|
70 | + } |
|
71 | 71 | } |
72 | 72 | |
73 | 73 |
@@ -5,34 +5,34 @@ discard block |
||
5 | 5 | *******************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # strip input tags |
21 | -$_POST = $Admin->strip_input_tags($_POST); |
|
21 | +$_POST = $Admin->strip_input_tags ($_POST); |
|
22 | 22 | |
23 | 23 | # validate csrf cookie |
24 | -$User->csrf_cookie ("validate", "vlan", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : ""; |
|
24 | +$User->csrf_cookie ("validate", "vlan", $_POST['csrf_cookie']) === false ? $Result->show ("danger", _ ("Invalid CSRF cookie"), true) : ""; |
|
25 | 25 | |
26 | 26 | # fetch custom fields |
27 | -$custom = $Tools->fetch_custom_fields('vlans'); |
|
27 | +$custom = $Tools->fetch_custom_fields ('vlans'); |
|
28 | 28 | |
29 | 29 | //if it already exist die |
30 | -if($User->settings->vlanDuplicate==0 && $_POST['action']=="add") { |
|
30 | +if ($User->settings->vlanDuplicate == 0 && $_POST['action'] == "add") { |
|
31 | 31 | $check_vlan = $Admin->fetch_multiple_objects ("vlans", "domainId", $_POST['domainId'], "vlanId"); |
32 | - if($check_vlan!==false) { |
|
33 | - foreach($check_vlan as $v) { |
|
34 | - if($v->number == $_POST['number']) { |
|
35 | - { $Result->show("danger", _("VLAN already exists"), true); } |
|
32 | + if ($check_vlan !== false) { |
|
33 | + foreach ($check_vlan as $v) { |
|
34 | + if ($v->number == $_POST['number']) { |
|
35 | + { $Result->show ("danger", _ ("VLAN already exists"), true); } |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
@@ -40,45 +40,45 @@ discard block |
||
40 | 40 | |
41 | 41 | // if unique required |
42 | 42 | if (isset($_POST['unique'])) { |
43 | - if ($_POST['unique']=="on") { |
|
44 | - if ($Tools->fetch_object ("vlans", "number", $_POST['number'])!==false) { $Result->show("danger", _("VLAN already exists in another domain!"), true); } |
|
43 | + if ($_POST['unique'] == "on") { |
|
44 | + if ($Tools->fetch_object ("vlans", "number", $_POST['number']) !== false) { $Result->show ("danger", _ ("VLAN already exists in another domain!"), true); } |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | 48 | //if number too high |
49 | -if($_POST['number']>$User->settings->vlanMax && $_POST['action']!="delete") { $Result->show("danger", _('Highest possible VLAN number is ').$settings['vlanMax'].'!', true); } |
|
50 | -if($_POST['action']=="add") { |
|
51 | - if($_POST['number']<0) { $Result->show("danger", _('VLAN number cannot be negative').'!', true); } |
|
52 | - elseif(!is_numeric($_POST['number'])) { $Result->show("danger", _('Not number').'!', true); } |
|
49 | +if ($_POST['number'] > $User->settings->vlanMax && $_POST['action'] != "delete") { $Result->show ("danger", _ ('Highest possible VLAN number is ').$settings['vlanMax'].'!', true); } |
|
50 | +if ($_POST['action'] == "add") { |
|
51 | + if ($_POST['number'] < 0) { $Result->show ("danger", _ ('VLAN number cannot be negative').'!', true); } |
|
52 | + elseif (!is_numeric ($_POST['number'])) { $Result->show ("danger", _ ('Not number').'!', true); } |
|
53 | 53 | } |
54 | -if(strlen($_POST['name'])==0) { $Result->show("danger", _('Name is required').'!', true); } |
|
54 | +if (strlen ($_POST['name']) == 0) { $Result->show ("danger", _ ('Name is required').'!', true); } |
|
55 | 55 | |
56 | 56 | |
57 | 57 | # formulate update query |
58 | -$values = array("vlanId"=>@$_POST['vlanId'], |
|
58 | +$values = array ("vlanId"=>@$_POST['vlanId'], |
|
59 | 59 | "number"=>$_POST['number'], |
60 | 60 | "name"=>$_POST['name'], |
61 | 61 | "description"=>@$_POST['description'], |
62 | 62 | "domainId"=>$_POST['domainId'] |
63 | 63 | ); |
64 | 64 | # append custom |
65 | -if(sizeof($custom) > 0) { |
|
66 | - foreach($custom as $myField) { |
|
65 | +if (sizeof ($custom) > 0) { |
|
66 | + foreach ($custom as $myField) { |
|
67 | 67 | # replace possible ___ back to spaces! |
68 | - $myField['nameTest'] = str_replace(" ", "___", $myField['name']); |
|
69 | - if(isset($_POST[$myField['nameTest']])) { $values[$myField['name']] = @$_POST[$myField['nameTest']];} |
|
68 | + $myField['nameTest'] = str_replace (" ", "___", $myField['name']); |
|
69 | + if (isset($_POST[$myField['nameTest']])) { $values[$myField['name']] = @$_POST[$myField['nameTest']]; } |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | 74 | # update |
75 | -if(!$Admin->object_modify("vlans", $_POST['action'], "vlanId", $values)) { $Result->show("danger", _("Failed to $_POST[action] VLAN").'!', true); } |
|
76 | -else { $Result->show("success", _("VLAN $_POST[action] successfull").'!', false); } |
|
75 | +if (!$Admin->object_modify ("vlans", $_POST['action'], "vlanId", $values)) { $Result->show ("danger", _ ("Failed to $_POST[action] VLAN").'!', true); } |
|
76 | +else { $Result->show ("success", _ ("VLAN $_POST[action] successfull").'!', false); } |
|
77 | 77 | |
78 | 78 | # remove all references if delete |
79 | -if($_POST['action']=="delete") { $Admin->remove_object_references ("subnets", "vlanId", $_POST['vlanId']); } |
|
79 | +if ($_POST['action'] == "delete") { $Admin->remove_object_references ("subnets", "vlanId", $_POST['vlanId']); } |
|
80 | 80 | |
81 | 81 | # print value for on the fly |
82 | -if($_POST['action']=="add") { print '<p id="vlanidforonthefly" style="display:none">'.$Admin->lastId.'</p>'; } |
|
82 | +if ($_POST['action'] == "add") { print '<p id="vlanidforonthefly" style="display:none">'.$Admin->lastId.'</p>'; } |
|
83 | 83 | |
84 | 84 | ?> |
85 | 85 | \ No newline at end of file |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | |
40 | 40 | # fetch l2 domain |
41 | 41 | if($_POST['action']=="add") { |
42 | - # all |
|
43 | - if (@$_POST['domain']=="all") { |
|
44 | - $vlan_domains = $Admin->fetch_all_objects("vlanDomains"); |
|
45 | - } else { |
|
46 | - $vlan_domain = $Admin->fetch_object("vlanDomains", "id", $_POST['domain']); |
|
47 | - } |
|
42 | + # all |
|
43 | + if (@$_POST['domain']=="all") { |
|
44 | + $vlan_domains = $Admin->fetch_all_objects("vlanDomains"); |
|
45 | + } else { |
|
46 | + $vlan_domain = $Admin->fetch_object("vlanDomains", "id", $_POST['domain']); |
|
47 | + } |
|
48 | 48 | } else { |
49 | - $vlan_domain = $Admin->fetch_object("vlanDomains", "id", $vlan['domainId']); |
|
49 | + $vlan_domain = $Admin->fetch_object("vlanDomains", "id", $vlan['domainId']); |
|
50 | 50 | } |
51 | 51 | if($vlan_domain===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
52 | 52 | ?> |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | <td><?php print _('l2 domain'); ?></td> |
72 | 72 | <th> |
73 | 73 | <?php |
74 | - # not all |
|
75 | - if (@$_POST['domain']!="all") { |
|
76 | - print $vlan_domain->name." (".$vlan_domain->description.")"; |
|
77 | - } else { |
|
78 | - print "<select name='domainId' class='form-control input-sm'>"; |
|
79 | - foreach ($vlan_domains as $d) { |
|
80 | - print "<option value='$d->id'>$d->name</option>"; |
|
81 | - } |
|
82 | - print "</select>"; |
|
83 | - } |
|
84 | - ?> |
|
74 | + # not all |
|
75 | + if (@$_POST['domain']!="all") { |
|
76 | + print $vlan_domain->name." (".$vlan_domain->description.")"; |
|
77 | + } else { |
|
78 | + print "<select name='domainId' class='form-control input-sm'>"; |
|
79 | + foreach ($vlan_domains as $d) { |
|
80 | + print "<option value='$d->id'>$d->name</option>"; |
|
81 | + } |
|
82 | + print "</select>"; |
|
83 | + } |
|
84 | + ?> |
|
85 | 85 | </th> |
86 | 86 | </tr> |
87 | 87 | <tr> |
@@ -133,105 +133,105 @@ discard block |
||
133 | 133 | |
134 | 134 | <!-- Custom --> |
135 | 135 | <?php |
136 | - if(sizeof($custom) > 0) { |
|
137 | - |
|
138 | - print '<tr>'; |
|
139 | - print ' <td colspan="2"><hr></td>'; |
|
140 | - print '</tr>'; |
|
141 | - |
|
142 | - foreach($custom as $field) { |
|
143 | - |
|
144 | - # replace spaces |
|
145 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
146 | - |
|
147 | - # required |
|
148 | - if($field['Null']=="NO") { $required = "*"; } |
|
149 | - else { $required = ""; } |
|
150 | - |
|
151 | - # set default value ! |
|
152 | - if ($_POST['action']=="add") { $vlan[$field['name']] = $field['Default']; } |
|
153 | - |
|
154 | - print '<tr>'. "\n"; |
|
155 | - print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
156 | - print ' <td>'. "\n"; |
|
157 | - |
|
158 | - //set type |
|
159 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
160 | - //parse values |
|
161 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
162 | - |
|
163 | - //null |
|
164 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
165 | - |
|
166 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
167 | - foreach($tmp as $v) { |
|
168 | - if($v==$vlan[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
169 | - else { print "<option value='$v'>$v</option>"; } |
|
170 | - } |
|
171 | - print "</select>"; |
|
172 | - } |
|
173 | - //date and time picker |
|
174 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
175 | - // just for first |
|
176 | - if($timeP==0) { |
|
177 | - print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
178 | - print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
179 | - print '<script type="text/javascript">'; |
|
180 | - print '$(document).ready(function() {'; |
|
181 | - //date only |
|
182 | - print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
183 | - //date + time |
|
184 | - print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
185 | - |
|
186 | - print '})'; |
|
187 | - print '</script>'; |
|
188 | - } |
|
189 | - $timeP++; |
|
190 | - |
|
191 | - //set size |
|
192 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
193 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
194 | - |
|
195 | - //field |
|
196 | - if(!isset($vlan[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
197 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $vlan[$field['name']]. '" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
198 | - } |
|
199 | - //boolean |
|
200 | - elseif($field['type'] == "tinyint(1)") { |
|
201 | - print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
202 | - $tmp = array(0=>"No",1=>"Yes"); |
|
203 | - //null |
|
204 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
205 | - |
|
206 | - foreach($tmp as $k=>$v) { |
|
207 | - if(strlen($vlan[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
208 | - elseif($k==$vlan[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
209 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
210 | - } |
|
211 | - print "</select>"; |
|
212 | - } |
|
213 | - //text |
|
214 | - elseif($field['type'] == "text") { |
|
215 | - print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" '.$readonly.' rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. $vlan[$field['name']]. '</textarea>'. "\n"; |
|
216 | - } |
|
217 | - //default - input field |
|
218 | - else { |
|
219 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. @$vlan[$field['name']]. '" size="30" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
220 | - } |
|
221 | - |
|
222 | - print ' </td>'. "\n"; |
|
223 | - print '</tr>'. "\n"; |
|
224 | - } |
|
225 | - } |
|
226 | - ?> |
|
136 | + if(sizeof($custom) > 0) { |
|
137 | + |
|
138 | + print '<tr>'; |
|
139 | + print ' <td colspan="2"><hr></td>'; |
|
140 | + print '</tr>'; |
|
141 | + |
|
142 | + foreach($custom as $field) { |
|
143 | + |
|
144 | + # replace spaces |
|
145 | + $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
146 | + |
|
147 | + # required |
|
148 | + if($field['Null']=="NO") { $required = "*"; } |
|
149 | + else { $required = ""; } |
|
150 | + |
|
151 | + # set default value ! |
|
152 | + if ($_POST['action']=="add") { $vlan[$field['name']] = $field['Default']; } |
|
153 | + |
|
154 | + print '<tr>'. "\n"; |
|
155 | + print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
156 | + print ' <td>'. "\n"; |
|
157 | + |
|
158 | + //set type |
|
159 | + if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
160 | + //parse values |
|
161 | + $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
162 | + |
|
163 | + //null |
|
164 | + if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
165 | + |
|
166 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
167 | + foreach($tmp as $v) { |
|
168 | + if($v==$vlan[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
169 | + else { print "<option value='$v'>$v</option>"; } |
|
170 | + } |
|
171 | + print "</select>"; |
|
172 | + } |
|
173 | + //date and time picker |
|
174 | + elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
175 | + // just for first |
|
176 | + if($timeP==0) { |
|
177 | + print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
|
178 | + print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
|
179 | + print '<script type="text/javascript">'; |
|
180 | + print '$(document).ready(function() {'; |
|
181 | + //date only |
|
182 | + print ' $(".datepicker").datetimepicker( {pickDate: true, pickTime: false, pickSeconds: false });'; |
|
183 | + //date + time |
|
184 | + print ' $(".datetimepicker").datetimepicker( { pickDate: true, pickTime: true } );'; |
|
185 | + |
|
186 | + print '})'; |
|
187 | + print '</script>'; |
|
188 | + } |
|
189 | + $timeP++; |
|
190 | + |
|
191 | + //set size |
|
192 | + if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
193 | + else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
194 | + |
|
195 | + //field |
|
196 | + if(!isset($vlan[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
197 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $vlan[$field['name']]. '" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
198 | + } |
|
199 | + //boolean |
|
200 | + elseif($field['type'] == "tinyint(1)") { |
|
201 | + print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
|
202 | + $tmp = array(0=>"No",1=>"Yes"); |
|
203 | + //null |
|
204 | + if($field['Null']!="NO") { $tmp[2] = ""; } |
|
205 | + |
|
206 | + foreach($tmp as $k=>$v) { |
|
207 | + if(strlen($vlan[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
208 | + elseif($k==$vlan[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
209 | + else { print "<option value='$k'>"._($v)."</option>"; } |
|
210 | + } |
|
211 | + print "</select>"; |
|
212 | + } |
|
213 | + //text |
|
214 | + elseif($field['type'] == "text") { |
|
215 | + print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" '.$readonly.' rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. $vlan[$field['name']]. '</textarea>'. "\n"; |
|
216 | + } |
|
217 | + //default - input field |
|
218 | + else { |
|
219 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. @$vlan[$field['name']]. '" size="30" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
220 | + } |
|
221 | + |
|
222 | + print ' </td>'. "\n"; |
|
223 | + print '</tr>'. "\n"; |
|
224 | + } |
|
225 | + } |
|
226 | + ?> |
|
227 | 227 | |
228 | 228 | </table> |
229 | 229 | </form> |
230 | 230 | |
231 | 231 | <?php |
232 | - //print delete warning |
|
233 | - if($_POST['action'] == "delete") { $Result->show("warning", _('Warning').':</strong> '._('removing VLAN will also remove VLAN reference from belonging subnets')."!", false); } |
|
234 | - ?> |
|
232 | + //print delete warning |
|
233 | + if($_POST['action'] == "delete") { $Result->show("warning", _('Warning').':</strong> '._('removing VLAN will also remove VLAN reference from belonging subnets')."!", false); } |
|
234 | + ?> |
|
235 | 235 | </div> |
236 | 236 | |
237 | 237 |
@@ -42,10 +42,12 @@ discard block |
||
42 | 42 | # all |
43 | 43 | if (@$_POST['domain']=="all") { |
44 | 44 | $vlan_domains = $Admin->fetch_all_objects("vlanDomains"); |
45 | - } else { |
|
45 | + } |
|
46 | + else { |
|
46 | 47 | $vlan_domain = $Admin->fetch_object("vlanDomains", "id", $_POST['domain']); |
47 | 48 | } |
48 | -} else { |
|
49 | +} |
|
50 | +else { |
|
49 | 51 | $vlan_domain = $Admin->fetch_object("vlanDomains", "id", $vlan['domainId']); |
50 | 52 | } |
51 | 53 | if($vlan_domain===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
@@ -74,7 +76,8 @@ discard block |
||
74 | 76 | # not all |
75 | 77 | if (@$_POST['domain']!="all") { |
76 | 78 | print $vlan_domain->name." (".$vlan_domain->description.")"; |
77 | - } else { |
|
79 | + } |
|
80 | + else { |
|
78 | 81 | print "<select name='domainId' class='form-control input-sm'>"; |
79 | 82 | foreach ($vlan_domains as $d) { |
80 | 83 | print "<option value='$d->id'>$d->name</option>"; |
@@ -238,8 +241,12 @@ discard block |
||
238 | 241 | <!-- footer --> |
239 | 242 | <div class="pFooter"> |
240 | 243 | <div class="btn-group"> |
241 | - <button class="btn btn-sm btn-default <?php if(isset($_POST['fromSubnet'])) { print "hidePopup2"; } else { print "hidePopups"; } ?>"><?php print _('Cancel'); ?></button> |
|
242 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?> vlanManagementEditFromSubnetButton" id="editVLANsubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
244 | + <button class="btn btn-sm btn-default <?php if(isset($_POST['fromSubnet'])) { print "hidePopup2"; } |
|
245 | +else { print "hidePopups"; } ?>"><?php print _('Cancel'); ?></button> |
|
246 | + <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } |
|
247 | +else { print "btn-success"; } ?> vlanManagementEditFromSubnetButton" id="editVLANsubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } |
|
248 | +else if ($_POST['action']=="delete") { print "fa-trash-o"; } |
|
249 | +else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
243 | 250 | </div> |
244 | 251 | |
245 | 252 | <!-- result --> |
@@ -5,49 +5,49 @@ discard block |
||
5 | 5 | ************************************************/ |
6 | 6 | |
7 | 7 | /* functions */ |
8 | -require( dirname(__FILE__) . '/../../../functions/functions.php'); |
|
8 | +require(dirname (__FILE__).'/../../../functions/functions.php'); |
|
9 | 9 | |
10 | 10 | # initialize user object |
11 | -$Database = new Database_PDO; |
|
12 | -$User = new User ($Database); |
|
11 | +$Database = new Database_PDO; |
|
12 | +$User = new User ($Database); |
|
13 | 13 | $Admin = new Admin ($Database); |
14 | 14 | $Tools = new Tools ($Database); |
15 | 15 | $Result = new Result (); |
16 | 16 | |
17 | 17 | # verify that user is logged in |
18 | -$User->check_user_session(); |
|
18 | +$User->check_user_session (); |
|
19 | 19 | |
20 | 20 | # create csrf token |
21 | 21 | $csrf = $User->csrf_cookie ("create", "vlan"); |
22 | 22 | |
23 | 23 | # fetch vlan details |
24 | 24 | $vlan = $Admin->fetch_object ("vlans", "vlanId", @$_POST['vlanId']); |
25 | -$vlan = $vlan!==false ? (array) $vlan : array(); |
|
25 | +$vlan = $vlan !== false ? (array) $vlan : array (); |
|
26 | 26 | # fetch custom fields |
27 | -$custom = $Tools->fetch_custom_fields('vlans'); |
|
27 | +$custom = $Tools->fetch_custom_fields ('vlans'); |
|
28 | 28 | |
29 | 29 | # set readonly flag |
30 | -$readonly = $_POST['action']=="delete" ? "readonly" : ""; |
|
30 | +$readonly = $_POST['action'] == "delete" ? "readonly" : ""; |
|
31 | 31 | |
32 | 32 | # set form name! |
33 | -if(isset($_POST['fromSubnet'])) { $formId = "vlanManagementEditFromSubnet"; } |
|
34 | -else { $formId = "vlanManagementEdit"; } |
|
33 | +if (isset($_POST['fromSubnet'])) { $formId = "vlanManagementEditFromSubnet"; } |
|
34 | +else { $formId = "vlanManagementEdit"; } |
|
35 | 35 | |
36 | 36 | # domain |
37 | -if(!isset($_POST['domain'])) { $_POST['domain']=1; } |
|
37 | +if (!isset($_POST['domain'])) { $_POST['domain'] = 1; } |
|
38 | 38 | |
39 | 39 | # fetch l2 domain |
40 | -if($_POST['action']=="add") { |
|
40 | +if ($_POST['action'] == "add") { |
|
41 | 41 | # all |
42 | - if (@$_POST['domain']=="all") { |
|
43 | - $vlan_domains = $Admin->fetch_all_objects("vlanDomains"); |
|
42 | + if (@$_POST['domain'] == "all") { |
|
43 | + $vlan_domains = $Admin->fetch_all_objects ("vlanDomains"); |
|
44 | 44 | } else { |
45 | - $vlan_domain = $Admin->fetch_object("vlanDomains", "id", $_POST['domain']); |
|
45 | + $vlan_domain = $Admin->fetch_object ("vlanDomains", "id", $_POST['domain']); |
|
46 | 46 | } |
47 | 47 | } else { |
48 | - $vlan_domain = $Admin->fetch_object("vlanDomains", "id", $vlan['domainId']); |
|
48 | + $vlan_domain = $Admin->fetch_object ("vlanDomains", "id", $vlan['domainId']); |
|
49 | 49 | } |
50 | -if($vlan_domain===false) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
50 | +if ($vlan_domain === false) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
51 | 51 | ?> |
52 | 52 | |
53 | 53 | <script type="text/javascript"> |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | |
60 | 60 | <!-- header --> |
61 | -<div class="pHeader"><?php print ucwords(_("$_POST[action]")); ?> <?php print _('VLAN'); ?></div> |
|
61 | +<div class="pHeader"><?php print ucwords (_ ("$_POST[action]")); ?> <?php print _ ('VLAN'); ?></div> |
|
62 | 62 | |
63 | 63 | <!-- content --> |
64 | 64 | <div class="pContent"> |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | <table id="vlanManagementEdit2" class="table table-noborder table-condensed"> |
68 | 68 | <!-- domain --> |
69 | 69 | <tr> |
70 | - <td><?php print _('l2 domain'); ?></td> |
|
70 | + <td><?php print _ ('l2 domain'); ?></td> |
|
71 | 71 | <th> |
72 | 72 | <?php |
73 | 73 | # not all |
74 | - if (@$_POST['domain']!="all") { |
|
74 | + if (@$_POST['domain'] != "all") { |
|
75 | 75 | print $vlan_domain->name." (".$vlan_domain->description.")"; |
76 | 76 | } else { |
77 | 77 | print "<select name='domainId' class='form-control input-sm'>"; |
@@ -88,27 +88,27 @@ discard block |
||
88 | 88 | </tr> |
89 | 89 | <!-- number --> |
90 | 90 | <tr> |
91 | - <td><?php print _('Number'); ?></td> |
|
91 | + <td><?php print _ ('Number'); ?></td> |
|
92 | 92 | <td> |
93 | - <input type="text" class="number form-control input-sm" name="number" placeholder="<?php print _('VLAN number'); ?>" value="<?php print @$vlan['number']; ?><?php print @$_POST['vlanNum']; ?>" <?php print $readonly; ?>> |
|
93 | + <input type="text" class="number form-control input-sm" name="number" placeholder="<?php print _ ('VLAN number'); ?>" value="<?php print @$vlan['number']; ?><?php print @$_POST['vlanNum']; ?>" <?php print $readonly; ?>> |
|
94 | 94 | </td> |
95 | 95 | </tr> |
96 | 96 | |
97 | 97 | <!-- hostname --> |
98 | 98 | <tr> |
99 | - <td><?php print _('Name'); ?></td> |
|
99 | + <td><?php print _ ('Name'); ?></td> |
|
100 | 100 | <td> |
101 | - <input type="text" class="name form-control input-sm" name="name" placeholder="<?php print _('VLAN name'); ?>" value="<?php print @$vlan['name']; ?>" <?php print $readonly; ?>> |
|
101 | + <input type="text" class="name form-control input-sm" name="name" placeholder="<?php print _ ('VLAN name'); ?>" value="<?php print @$vlan['name']; ?>" <?php print $readonly; ?>> |
|
102 | 102 | </td> |
103 | 103 | </tr> |
104 | 104 | |
105 | 105 | <!-- Description --> |
106 | 106 | <tr> |
107 | - <td><?php print _('Description'); ?></td> |
|
107 | + <td><?php print _ ('Description'); ?></td> |
|
108 | 108 | <td> |
109 | - <input type="text" class="description form-control input-sm" name="description" placeholder="<?php print _('Description'); ?>" value="<?php print @$vlan['description']; ?>" <?php print $readonly; ?>> |
|
109 | + <input type="text" class="description form-control input-sm" name="description" placeholder="<?php print _ ('Description'); ?>" value="<?php print @$vlan['description']; ?>" <?php print $readonly; ?>> |
|
110 | 110 | <input type="hidden" name="vlanId" value="<?php print @$_POST['vlanId']; ?>"> |
111 | - <?php if(@$_POST['domain']!=="all") { ?> |
|
111 | + <?php if (@$_POST['domain'] !== "all") { ?> |
|
112 | 112 | <input type="hidden" name="domainId" value="<?php print $vlan_domain->id; ?>"> |
113 | 113 | <?php } ?> |
114 | 114 | <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
@@ -116,63 +116,63 @@ discard block |
||
116 | 116 | </td> |
117 | 117 | </tr> |
118 | 118 | |
119 | - <?php if($_POST['action']=="add" || $_POST['action']=="edit") { ?> |
|
119 | + <?php if ($_POST['action'] == "add" || $_POST['action'] == "edit") { ?> |
|
120 | 120 | <!-- require unique --> |
121 | 121 | <tr> |
122 | 122 | <td colspan="2"><hr></td> |
123 | 123 | </tr> |
124 | 124 | <tr> |
125 | - <td><?php print _('Unique VLAN'); ?></td> |
|
125 | + <td><?php print _ ('Unique VLAN'); ?></td> |
|
126 | 126 | <td> |
127 | 127 | <input type="checkbox" name="unique" value="on"> |
128 | - <span class="text-muted"><?php print _('Require unique vlan accross domains'); ?></span> |
|
128 | + <span class="text-muted"><?php print _ ('Require unique vlan accross domains'); ?></span> |
|
129 | 129 | </td> |
130 | 130 | </tr> |
131 | 131 | <?php } ?> |
132 | 132 | |
133 | 133 | <!-- Custom --> |
134 | 134 | <?php |
135 | - if(sizeof($custom) > 0) { |
|
135 | + if (sizeof ($custom) > 0) { |
|
136 | 136 | |
137 | 137 | print '<tr>'; |
138 | 138 | print ' <td colspan="2"><hr></td>'; |
139 | 139 | print '</tr>'; |
140 | 140 | |
141 | - foreach($custom as $field) { |
|
141 | + foreach ($custom as $field) { |
|
142 | 142 | |
143 | 143 | # replace spaces |
144 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
144 | + $field['nameNew'] = str_replace (" ", "___", $field['name']); |
|
145 | 145 | |
146 | 146 | # required |
147 | - if($field['Null']=="NO") { $required = "*"; } |
|
148 | - else { $required = ""; } |
|
147 | + if ($field['Null'] == "NO") { $required = "*"; } |
|
148 | + else { $required = ""; } |
|
149 | 149 | |
150 | 150 | # set default value ! |
151 | - if ($_POST['action']=="add") { $vlan[$field['name']] = $field['Default']; } |
|
151 | + if ($_POST['action'] == "add") { $vlan[$field['name']] = $field['Default']; } |
|
152 | 152 | |
153 | - print '<tr>'. "\n"; |
|
154 | - print ' <td>'. $field['name'] .' '.$required.'</td>'. "\n"; |
|
155 | - print ' <td>'. "\n"; |
|
153 | + print '<tr>'."\n"; |
|
154 | + print ' <td>'.$field['name'].' '.$required.'</td>'."\n"; |
|
155 | + print ' <td>'."\n"; |
|
156 | 156 | |
157 | 157 | //set type |
158 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
158 | + if (substr ($field['type'], 0, 3) == "set" || substr ($field['type'], 0, 4) == "enum") { |
|
159 | 159 | //parse values |
160 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
160 | + $tmp = substr ($field['type'], 0, 3) == "set" ? explode (",", str_replace (array ("set(", ")", "'"), "", $field['type'])) : explode (",", str_replace (array ("enum(", ")", "'"), "", $field['type'])); |
|
161 | 161 | |
162 | 162 | //null |
163 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
163 | + if ($field['Null'] != "NO") { array_unshift ($tmp, ""); } |
|
164 | 164 | |
165 | 165 | print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
166 | - foreach($tmp as $v) { |
|
167 | - if($v==$vlan[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
168 | - else { print "<option value='$v'>$v</option>"; } |
|
166 | + foreach ($tmp as $v) { |
|
167 | + if ($v == $vlan[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
168 | + else { print "<option value='$v'>$v</option>"; } |
|
169 | 169 | } |
170 | 170 | print "</select>"; |
171 | 171 | } |
172 | 172 | //date and time picker |
173 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
173 | + elseif ($field['type'] == "date" || $field['type'] == "datetime") { |
|
174 | 174 | // just for first |
175 | - if($timeP==0) { |
|
175 | + if ($timeP == 0) { |
|
176 | 176 | print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
177 | 177 | print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
178 | 178 | print '<script type="text/javascript">'; |
@@ -188,38 +188,38 @@ discard block |
||
188 | 188 | $timeP++; |
189 | 189 | |
190 | 190 | //set size |
191 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
192 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
191 | + if ($field['type'] == "date") { $size = 10; $class = 'datepicker'; $format = "yyyy-MM-dd"; } |
|
192 | + else { $size = 19; $class = 'datetimepicker'; $format = "yyyy-MM-dd"; } |
|
193 | 193 | |
194 | 194 | //field |
195 | - if(!isset($vlan[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
196 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'] .'" maxlength="'.$size.'" value="'. $vlan[$field['name']]. '" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
195 | + if (!isset($vlan[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].'" maxlength="'.$size.'" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; } |
|
196 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].'" maxlength="'.$size.'" value="'.$vlan[$field['name']].'" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; } |
|
197 | 197 | } |
198 | 198 | //boolean |
199 | - elseif($field['type'] == "tinyint(1)") { |
|
199 | + elseif ($field['type'] == "tinyint(1)") { |
|
200 | 200 | print "<select name='$field[nameNew]' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
201 | - $tmp = array(0=>"No",1=>"Yes"); |
|
201 | + $tmp = array (0=>"No", 1=>"Yes"); |
|
202 | 202 | //null |
203 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
203 | + if ($field['Null'] != "NO") { $tmp[2] = ""; } |
|
204 | 204 | |
205 | - foreach($tmp as $k=>$v) { |
|
206 | - if(strlen($vlan[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
207 | - elseif($k==$vlan[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
208 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
205 | + foreach ($tmp as $k=>$v) { |
|
206 | + if (strlen ($vlan[$field['name']]) == 0 && $k == 2) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; } |
|
207 | + elseif ($k == $vlan[$field['name']]) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; } |
|
208 | + else { print "<option value='$k'>"._ ($v)."</option>"; } |
|
209 | 209 | } |
210 | 210 | print "</select>"; |
211 | 211 | } |
212 | 212 | //text |
213 | - elseif($field['type'] == "text") { |
|
214 | - print ' <textarea class="form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" '.$readonly.' rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. $vlan[$field['name']]. '</textarea>'. "\n"; |
|
213 | + elseif ($field['type'] == "text") { |
|
214 | + print ' <textarea class="form-control input-sm" name="'.$field['nameNew'].'" placeholder="'.$field['name'].'" '.$readonly.' rowspan=3 rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'.$vlan[$field['name']].'</textarea>'."\n"; |
|
215 | 215 | } |
216 | 216 | //default - input field |
217 | 217 | else { |
218 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'] .'" placeholder="'. $field['name'] .'" value="'. @$vlan[$field['name']]. '" size="30" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
218 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'.$field['nameNew'].'" placeholder="'.$field['name'].'" value="'.@$vlan[$field['name']].'" size="30" '.$readonly.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; |
|
219 | 219 | } |
220 | 220 | |
221 | - print ' </td>'. "\n"; |
|
222 | - print '</tr>'. "\n"; |
|
221 | + print ' </td>'."\n"; |
|
222 | + print '</tr>'."\n"; |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | ?> |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | <?php |
231 | 231 | //print delete warning |
232 | - if($_POST['action'] == "delete") { $Result->show("warning", _('Warning').':</strong> '._('removing VLAN will also remove VLAN reference from belonging subnets')."!", false); } |
|
232 | + if ($_POST['action'] == "delete") { $Result->show ("warning", _ ('Warning').':</strong> '._ ('removing VLAN will also remove VLAN reference from belonging subnets')."!", false); } |
|
233 | 233 | ?> |
234 | 234 | </div> |
235 | 235 | |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | <!-- footer --> |
238 | 238 | <div class="pFooter"> |
239 | 239 | <div class="btn-group"> |
240 | - <button class="btn btn-sm btn-default <?php if(isset($_POST['fromSubnet'])) { print "hidePopup2"; } else { print "hidePopups"; } ?>"><?php print _('Cancel'); ?></button> |
|
241 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?> vlanManagementEditFromSubnetButton" id="editVLANsubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
240 | + <button class="btn btn-sm btn-default <?php if (isset($_POST['fromSubnet'])) { print "hidePopup2"; } else { print "hidePopups"; } ?>"><?php print _ ('Cancel'); ?></button> |
|
241 | + <button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?> vlanManagementEditFromSubnetButton" id="editVLANsubmit"><i class="fa <?php if ($_POST['action'] == "add") { print "fa-plus"; } else if ($_POST['action'] == "delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button> |
|
242 | 242 | </div> |
243 | 243 | |
244 | 244 | <!-- result --> |