@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | ***********************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # fetch users to receive notification and filter |
11 | 11 | $users = $Admin->fetch_multiple_objects ("users", "role", "Administrator"); |
@@ -16,89 +16,89 @@ discard block |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | # fetch mailer settings |
19 | -$mail_settings = $Admin->fetch_object("settingsMail", "id", 1); |
|
19 | +$mail_settings = $Admin->fetch_object ("settingsMail", "id", 1); |
|
20 | 20 | |
21 | 21 | # verify admin mail and name |
22 | -if (strlen($mail_settings->mAdminMail)==0 || strlen($mail_settings->mAdminName)==0) { |
|
23 | - $Result->show("danger", _("Cannot send mail, mail settings are missing. Please set them under administration > Mail Settings !"), true); |
|
22 | +if (strlen ($mail_settings->mAdminMail) == 0 || strlen ($mail_settings->mAdminName) == 0) { |
|
23 | + $Result->show ("danger", _ ("Cannot send mail, mail settings are missing. Please set them under administration > Mail Settings !"), true); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | # initialize mailer |
27 | -$phpipam_mail = new phpipam_mail($User->settings, $mail_settings); |
|
28 | -$phpipam_mail->initialize_mailer(); |
|
27 | +$phpipam_mail = new phpipam_mail ($User->settings, $mail_settings); |
|
28 | +$phpipam_mail->initialize_mailer (); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | # set subject |
32 | -if ($_POST['action'] == "Add") { $subject = _('New ipam account created'); } |
|
33 | -else if ($_POST['action'] == "Edit") { $subject = _('User ipam account updated'); } |
|
34 | -else { $subject = _('IPAM account details'); } |
|
32 | +if ($_POST['action'] == "Add") { $subject = _ ('New ipam account created'); } |
|
33 | +else if ($_POST['action'] == "Edit") { $subject = _ ('User ipam account updated'); } |
|
34 | +else { $subject = _ ('IPAM account details'); } |
|
35 | 35 | |
36 | 36 | |
37 | 37 | # set html content |
38 | 38 | $content[] = "<table style='margin-left:10px;margin-top:5px;width:auto;padding:0px;border-collapse:collapse;'>"; |
39 | 39 | $content[] = "<tr><td style='padding:5px;margin:0px;color:#333;font-size:16px;text-shadow:1px 1px 1px white;border-bottom:1px solid #eeeeee;' colspan='2'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:16px;'>$subject</font></td></tr>"; |
40 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-top:1px solid white;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Name').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'. $_POST['real_name'] .'</font></td></tr>'; |
|
40 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-top:1px solid white;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Name').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;padding-top:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'.$_POST['real_name'].'</font></td></tr>'; |
|
41 | 41 | //we dont need pass for domain account |
42 | -if($auth_method->type == "local") { |
|
43 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Username').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'. $_POST['username'] .'</font></td></tr>'; |
|
44 | -if(strlen($_POST['password2']) != 0) { |
|
45 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Password').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'. $_POST['password2'] .'</font></td></tr>'; |
|
42 | +if ($auth_method->type == "local") { |
|
43 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Username').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'.$_POST['username'].'</font></td></tr>'; |
|
44 | +if (strlen ($_POST['password2']) != 0) { |
|
45 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Password').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'.$_POST['password2'].'</font></td></tr>'; |
|
46 | 46 | }} |
47 | 47 | else { |
48 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Username').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">* '._('your domain username').' ('. $_POST['username'] .')</font></td></tr>'; |
|
49 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Password').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">* '._('your domain password').'</font></td></tr>'; |
|
48 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Username').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">* '._ ('your domain username').' ('.$_POST['username'].')</font></td></tr>'; |
|
49 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Password').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">* '._ ('your domain password').'</font></td></tr>'; |
|
50 | 50 | } |
51 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Email').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;"><a href="mailto:'.$_POST['email'].'" style="color:#08c;">'.$_POST['email'].'</a></font></td></tr>'; |
|
52 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('Role').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'. $_POST['role'] .'</font></td></tr>'; |
|
53 | -$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-bottom:1px solid #eeeeee;padding-bottom:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._('WebApp').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;border-bottom:1px solid #eeeeee;padding-bottom:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;"> <a href="'. $User->settings->siteURL .'" style="color:#08c;">'. $User->settings->siteURL. '</font></a><td></tr>'; |
|
54 | -$content[] = "<tr><td style='padding:5px;padding-left:15px;margin:0px;font-style:italic;padding-bottom:3px;text-align:right;color:#ccc;text-shadow:1px 1px 1px white;border-top:1px solid white;' colspan='2'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:11px;'>"._('Sent by user')." ".$User->user->real_name." at ".date('Y/m/d H:i')."</font></td></tr>"; |
|
51 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Email').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;"><a href="mailto:'.$_POST['email'].'" style="color:#08c;">'.$_POST['email'].'</a></font></td></tr>'; |
|
52 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('Role').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">'.$_POST['role'].'</font></td></tr>'; |
|
53 | +$content[] = '<tr><td style="padding: 0px;padding-left:10px;margin:0px;line-height:18px;text-align:left;border-bottom:1px solid #eeeeee;padding-bottom:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;">• '._ ('WebApp').'</font></td> <td style="padding: 0px;padding-left:15px;margin:0px;line-height:18px;text-align:left;border-bottom:1px solid #eeeeee;padding-bottom:10px;"><font face="Helvetica, Verdana, Arial, sans-serif" style="font-size:13px;"> <a href="'.$User->settings->siteURL.'" style="color:#08c;">'.$User->settings->siteURL.'</font></a><td></tr>'; |
|
54 | +$content[] = "<tr><td style='padding:5px;padding-left:15px;margin:0px;font-style:italic;padding-bottom:3px;text-align:right;color:#ccc;text-shadow:1px 1px 1px white;border-top:1px solid white;' colspan='2'><font face='Helvetica, Verdana, Arial, sans-serif' style='font-size:11px;'>"._ ('Sent by user')." ".$User->user->real_name." at ".date ('Y/m/d H:i')."</font></td></tr>"; |
|
55 | 55 | $content[] = "</table>"; |
56 | 56 | |
57 | 57 | # plain |
58 | 58 | $content_plain[] = "$subject"."\r\n------------------------------\r\n"; |
59 | -$content_plain[] = _("Name").": $_POST[real_name]"; |
|
59 | +$content_plain[] = _ ("Name").": $_POST[real_name]"; |
|
60 | 60 | # we dont need pass for domain account |
61 | -if($auth_method->type == "local") { |
|
62 | -$content_plain[] = _("Username").": $_POST[username]"; |
|
63 | -if(strlen($_POST['password2']) != 0) { |
|
64 | -$content_plain[] = _("Password").": $_POST[password2]"; |
|
61 | +if ($auth_method->type == "local") { |
|
62 | +$content_plain[] = _ ("Username").": $_POST[username]"; |
|
63 | +if (strlen ($_POST['password2']) != 0) { |
|
64 | +$content_plain[] = _ ("Password").": $_POST[password2]"; |
|
65 | 65 | }} |
66 | 66 | else { |
67 | -$content_plain[] = _("Username").": * your domain username($_POST[username]"; |
|
68 | -$content_plain[] = _("Password").": * your domain password"; |
|
67 | +$content_plain[] = _ ("Username").": * your domain username($_POST[username]"; |
|
68 | +$content_plain[] = _ ("Password").": * your domain password"; |
|
69 | 69 | } |
70 | -$content_plain[] = _("Email").": $_POST[email]"; |
|
71 | -$content_plain[] = _("Role").": $_POST[role]"; |
|
72 | -$content_plain[] = _("WebApp").": ".$User->settings->siteURL; |
|
73 | -$content_plain[] = "\r\n"._("Sent by user")." ".$User->user->real_name." at ".date('Y/m/d H:i'); |
|
70 | +$content_plain[] = _ ("Email").": $_POST[email]"; |
|
71 | +$content_plain[] = _ ("Role").": $_POST[role]"; |
|
72 | +$content_plain[] = _ ("WebApp").": ".$User->settings->siteURL; |
|
73 | +$content_plain[] = "\r\n"._ ("Sent by user")." ".$User->user->real_name." at ".date ('Y/m/d H:i'); |
|
74 | 74 | |
75 | 75 | |
76 | 76 | # set content |
77 | -$content = $phpipam_mail->generate_message (implode("\r\n", $content)); |
|
78 | -$content_plain = implode("\r\n",$content_plain); |
|
77 | +$content = $phpipam_mail->generate_message (implode ("\r\n", $content)); |
|
78 | +$content_plain = implode ("\r\n", $content_plain); |
|
79 | 79 | |
80 | 80 | # try to send |
81 | 81 | try { |
82 | - $phpipam_mail->Php_mailer->setFrom($mail_settings->mAdminMail, $mail_settings->mAdminName); |
|
83 | - $phpipam_mail->Php_mailer->addAddress(addslashes(trim($_POST['email'])), addslashes(trim($_POST['real_name']))); |
|
82 | + $phpipam_mail->Php_mailer->setFrom ($mail_settings->mAdminMail, $mail_settings->mAdminName); |
|
83 | + $phpipam_mail->Php_mailer->addAddress (addslashes (trim ($_POST['email'])), addslashes (trim ($_POST['real_name']))); |
|
84 | 84 | //add all admins to CC |
85 | - if (sizeof($users)>0) { |
|
86 | - foreach($users as $admin) { |
|
87 | - $phpipam_mail->Php_mailer->AddCC($admin->email); |
|
85 | + if (sizeof ($users) > 0) { |
|
86 | + foreach ($users as $admin) { |
|
87 | + $phpipam_mail->Php_mailer->AddCC ($admin->email); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | $phpipam_mail->Php_mailer->Subject = $subject; |
91 | - $phpipam_mail->Php_mailer->msgHTML($content); |
|
91 | + $phpipam_mail->Php_mailer->msgHTML ($content); |
|
92 | 92 | $phpipam_mail->Php_mailer->AltBody = $content_plain; |
93 | 93 | //send |
94 | - $phpipam_mail->Php_mailer->send(); |
|
94 | + $phpipam_mail->Php_mailer->send (); |
|
95 | 95 | } catch (phpmailerException $e) { |
96 | - $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
96 | + $Result->show ("danger", "Mailer Error: ".$e->errorMessage (), true); |
|
97 | 97 | } catch (Exception $e) { |
98 | - $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
98 | + $Result->show ("danger", "Mailer Error: ".$e->errorMessage (), true); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | //if error not sent print ok |
102 | -$Result->show("success", _('Notification mail for new account sent').'!', true); |
|
102 | +$Result->show ("success", _ ('Notification mail for new account sent').'!', true); |
|
103 | 103 | |
104 | 104 | ?> |
105 | 105 | \ No newline at end of file |
@@ -5,24 +5,24 @@ discard block |
||
5 | 5 | *************************************************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # fetch all APIs |
11 | -$users = $Admin->fetch_all_objects("users", "username"); |
|
11 | +$users = $Admin->fetch_all_objects ("users", "username"); |
|
12 | 12 | # fetch custom fields |
13 | -$custom = $Tools->fetch_custom_fields('users'); |
|
13 | +$custom = $Tools->fetch_custom_fields ('users'); |
|
14 | 14 | |
15 | 15 | /* check customfields */ |
16 | -$ffields = json_decode($User->settings->hiddenCustomFields, true); |
|
17 | -$ffields = is_array(@$ffields['users']) ? $ffields['users'] : array(); |
|
16 | +$ffields = json_decode ($User->settings->hiddenCustomFields, true); |
|
17 | +$ffields = is_array (@$ffields['users']) ? $ffields['users'] : array (); |
|
18 | 18 | ?> |
19 | 19 | |
20 | 20 | <!-- display existing users --> |
21 | -<h4><?php print _('User management'); ?></h4> |
|
21 | +<h4><?php print _ ('User management'); ?></h4> |
|
22 | 22 | <hr><br> |
23 | 23 | |
24 | 24 | <!-- Add new --> |
25 | -<button class='btn btn-sm btn-default editUser' style="margin-bottom:10px;" data-action='add'><i class='fa fa-plus'></i> <?php print _('Create user'); ?></button> |
|
25 | +<button class='btn btn-sm btn-default editUser' style="margin-bottom:10px;" data-action='add'><i class='fa fa-plus'></i> <?php print _ ('Create user'); ?></button> |
|
26 | 26 | |
27 | 27 | <!-- table --> |
28 | 28 | <table id="userPrint1" class="table sorted table-striped table-top"> |
@@ -31,19 +31,19 @@ discard block |
||
31 | 31 | <thead> |
32 | 32 | <tr> |
33 | 33 | <th></th> |
34 | - <th><?php print _('Real Name'); ?></th> |
|
35 | - <th><?php print _('Username'); ?></th> |
|
36 | - <th><?php print _('E-mail'); ?></th> |
|
37 | - <th><?php print _('Role'); ?></th> |
|
38 | - <th><?php print _('Language'); ?></th> |
|
39 | - <th><?php print _('Authentication'); ?></th> |
|
40 | - <th><?php print _('PowerDNS'); ?></th> |
|
41 | - <th><?php print _('Groups'); ?></th> |
|
42 | - <th><?php print _('Last login'); ?></th> |
|
34 | + <th><?php print _ ('Real Name'); ?></th> |
|
35 | + <th><?php print _ ('Username'); ?></th> |
|
36 | + <th><?php print _ ('E-mail'); ?></th> |
|
37 | + <th><?php print _ ('Role'); ?></th> |
|
38 | + <th><?php print _ ('Language'); ?></th> |
|
39 | + <th><?php print _ ('Authentication'); ?></th> |
|
40 | + <th><?php print _ ('PowerDNS'); ?></th> |
|
41 | + <th><?php print _ ('Groups'); ?></th> |
|
42 | + <th><?php print _ ('Last login'); ?></th> |
|
43 | 43 | <?php |
44 | - if(sizeof(@$custom) > 0) { |
|
45 | - foreach($custom as $field) { |
|
46 | - if(!in_array($field['name'], $ffields)) { |
|
44 | + if (sizeof (@$custom) > 0) { |
|
45 | + foreach ($custom as $field) { |
|
46 | + if (!in_array ($field['name'], $ffields)) { |
|
47 | 47 | print "<th>$field[name]</th>"; |
48 | 48 | } |
49 | 49 | } |
@@ -59,21 +59,21 @@ discard block |
||
59 | 59 | foreach ($users as $user) { |
60 | 60 | //cast |
61 | 61 | $user = (array) $user; |
62 | - print '<tr>' . "\n"; |
|
62 | + print '<tr>'."\n"; |
|
63 | 63 | |
64 | 64 | # set icon based on normal user or admin |
65 | - if($user['role'] == "Administrator") { print ' <td><img src="css/1.2/images/userVader.png" rel="tooltip" title="'._('Administrator').'"></td>'. "\n"; } |
|
66 | - else { print ' <td><img src="css/1.2/images/userTrooper.png" rel="tooltip" title="'. _($user['role']) .'"></td>'. "\n"; } |
|
65 | + if ($user['role'] == "Administrator") { print ' <td><img src="css/1.2/images/userVader.png" rel="tooltip" title="'._ ('Administrator').'"></td>'."\n"; } |
|
66 | + else { print ' <td><img src="css/1.2/images/userTrooper.png" rel="tooltip" title="'._ ($user['role']).'"></td>'."\n"; } |
|
67 | 67 | |
68 | - print ' <td><a href="'.create_link("administration","users",$user['id']).'">' . $user['real_name'] . '</a></td>'. "\n"; |
|
69 | - print ' <td>' . $user['username'] . '</td>'. "\n"; |
|
70 | - print ' <td>' . $user['email'] . '</td>'. "\n"; |
|
71 | - print ' <td>' . $user['role'] . '</td>'. "\n"; |
|
68 | + print ' <td><a href="'.create_link ("administration", "users", $user['id']).'">'.$user['real_name'].'</a></td>'."\n"; |
|
69 | + print ' <td>'.$user['username'].'</td>'."\n"; |
|
70 | + print ' <td>'.$user['email'].'</td>'."\n"; |
|
71 | + print ' <td>'.$user['role'].'</td>'."\n"; |
|
72 | 72 | |
73 | 73 | # language |
74 | - if(strlen($user['lang'])>0) { |
|
74 | + if (strlen ($user['lang']) > 0) { |
|
75 | 75 | # get lang name |
76 | - $lname = $Admin->fetch_object("lang", "l_id", $user['lang']); |
|
76 | + $lname = $Admin->fetch_object ("lang", "l_id", $user['lang']); |
|
77 | 77 | print "<td>$lname->l_name</td>"; |
78 | 78 | } |
79 | 79 | else { |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | # check users auth method |
84 | - $auth_method = $Admin->fetch_object("usersAuthMethod", "id", $user['authMethod']); |
|
84 | + $auth_method = $Admin->fetch_object ("usersAuthMethod", "id", $user['authMethod']); |
|
85 | 85 | //false |
86 | 86 | print "<td>"; |
87 | - if($auth_method===false) { print "<span class='text-muted'>No auth method</span>"; } |
|
88 | - else { print $auth_method->type." <span class='text-muted'>(".$auth_method->description."</a>)"; } |
|
87 | + if ($auth_method === false) { print "<span class='text-muted'>No auth method</span>"; } |
|
88 | + else { print $auth_method->type." <span class='text-muted'>(".$auth_method->description."</a>)"; } |
|
89 | 89 | print "</span></td>"; |
90 | 90 | |
91 | 91 | # powerDNS |
@@ -94,44 +94,44 @@ discard block |
||
94 | 94 | print "</td>"; |
95 | 95 | |
96 | 96 | # groups |
97 | - if($user['role'] == "Administrator") { |
|
98 | - print ' <td>'._('All groups').'</td>'. "\n"; |
|
97 | + if ($user['role'] == "Administrator") { |
|
98 | + print ' <td>'._ ('All groups').'</td>'."\n"; |
|
99 | 99 | } |
100 | 100 | else { |
101 | - $groups = json_decode($user['groups'], true); |
|
102 | - $gr = $Admin->groups_parse($groups); |
|
101 | + $groups = json_decode ($user['groups'], true); |
|
102 | + $gr = $Admin->groups_parse ($groups); |
|
103 | 103 | |
104 | 104 | print ' <td>'; |
105 | - if(sizeof($gr)>0) { |
|
106 | - foreach($gr as $group) { |
|
105 | + if (sizeof ($gr) > 0) { |
|
106 | + foreach ($gr as $group) { |
|
107 | 107 | print $group['g_name']."<br>"; |
108 | 108 | } |
109 | 109 | } |
110 | 110 | else { |
111 | 111 | print "<span class='text-muted'>No groups</span>"; |
112 | 112 | } |
113 | - print ' </td>'. "\n"; |
|
113 | + print ' </td>'."\n"; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | # last login |
117 | 117 | print "<td>"; |
118 | - print strlen($user['lastLogin'])>0 ? $user['lastLogin'] : "<span class='text-muted'>"._("Never")."</span>"; |
|
118 | + print strlen ($user['lastLogin']) > 0 ? $user['lastLogin'] : "<span class='text-muted'>"._ ("Never")."</span>"; |
|
119 | 119 | print "</td>"; |
120 | 120 | |
121 | 121 | # custom |
122 | - if(sizeof($custom) > 0) { |
|
123 | - foreach($custom as $field) { |
|
124 | - if(!in_array($field['name'], $ffields)) { |
|
122 | + if (sizeof ($custom) > 0) { |
|
123 | + foreach ($custom as $field) { |
|
124 | + if (!in_array ($field['name'], $ffields)) { |
|
125 | 125 | print "<td>"; |
126 | 126 | //booleans |
127 | - if($field['type']=="tinyint(1)") { |
|
128 | - if($user[$field['name']] == "0") { print _("No"); } |
|
129 | - elseif($user[$field['name']] == "1") { print _("Yes"); } |
|
127 | + if ($field['type'] == "tinyint(1)") { |
|
128 | + if ($user[$field['name']] == "0") { print _ ("No"); } |
|
129 | + elseif ($user[$field['name']] == "1") { print _ ("Yes"); } |
|
130 | 130 | } |
131 | 131 | //text |
132 | - elseif($field['type']=="text") { |
|
133 | - if(strlen($user[$field['name']])>0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $user[$field['name']])."'>"; } |
|
134 | - else { print ""; } |
|
132 | + elseif ($field['type'] == "text") { |
|
133 | + if (strlen ($user[$field['name']]) > 0) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace ("\n", "<br>", $user[$field['name']])."'>"; } |
|
134 | + else { print ""; } |
|
135 | 135 | } |
136 | 136 | else { |
137 | 137 | print $user[$field['name']]; |
@@ -145,16 +145,16 @@ discard block |
||
145 | 145 | # edit, delete |
146 | 146 | print " <td class='actions'>"; |
147 | 147 | print " <div class='btn-group'>"; |
148 | - print " <a class='btn btn-xs btn-default' href='".create_link("administration","users",$user['id'])."'><i class='fa fa-eye'></i></a></button>"; |
|
148 | + print " <a class='btn btn-xs btn-default' href='".create_link ("administration", "users", $user['id'])."'><i class='fa fa-eye'></i></a></button>"; |
|
149 | 149 | print " <button class='btn btn-xs btn-default editUser' data-userid='$user[id]' data-action='edit' ><i class='fa fa-pencil'></i></button>"; |
150 | 150 | print " <a class='btn btn-xs btn-default"; |
151 | - if($_SESSION['realipamusername']) { print " disabled";} |
|
152 | - print "' href='".create_link("administration","users","switch","$user[username]")."'><i class='fa fa-exchange'></i></a></button>"; |
|
151 | + if ($_SESSION['realipamusername']) { print " disabled"; } |
|
152 | + print "' href='".create_link ("administration", "users", "switch", "$user[username]")."'><i class='fa fa-exchange'></i></a></button>"; |
|
153 | 153 | print " <button class='btn btn-xs btn-default editUser' data-userid='$user[id]' data-action='delete'><i class='fa fa-times'></i></button>"; |
154 | 154 | print " </div>"; |
155 | 155 | print " </td>"; |
156 | 156 | |
157 | - print '</tr>' . "\n"; |
|
157 | + print '</tr>'."\n"; |
|
158 | 158 | } |
159 | 159 | ?> |
160 | 160 | </tbody> |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | <div class="alert alert-info alert-absolute"> |
164 | 164 | <ul> |
165 | - <li><?php print _('Administrator users will be able to view and edit all sections and subnets'); ?></li> |
|
166 | - <li><?php print _('Normal users will have permissions set based on group access to sections and subnets'); ?></li> |
|
165 | + <li><?php print _ ('Administrator users will be able to view and edit all sections and subnets'); ?></li> |
|
166 | + <li><?php print _ ('Normal users will have permissions set based on group access to sections and subnets'); ?></li> |
|
167 | 167 | </ul> |
168 | 168 | </div> |
@@ -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 --> |
@@ -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> |
@@ -5,50 +5,50 @@ 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 | # scan disabled |
21 | -if ($User->settings->enableSNMP!="1") { $Result->show("danger", _("SNMP module disbled"), true, true); } |
|
21 | +if ($User->settings->enableSNMP != "1") { $Result->show ("danger", _ ("SNMP module disbled"), true, true); } |
|
22 | 22 | # admin check |
23 | -if($User->is_admin()!==true) { $Result->show("danger", _('Admin privileges required'), true, true); } |
|
23 | +if ($User->is_admin () !== true) { $Result->show ("danger", _ ('Admin privileges required'), true, true); } |
|
24 | 24 | |
25 | 25 | # domain Id must be int |
26 | -if (!is_numeric($_POST['domainId'])) { $Result->show("danger", _("Invalid domain Id"), true, true); } |
|
26 | +if (!is_numeric ($_POST['domainId'])) { $Result->show ("danger", _ ("Invalid domain Id"), true, true); } |
|
27 | 27 | # fetch domain |
28 | 28 | $domain = $Tools->fetch_object ("vlanDomains", "id", $_POST['domainId']); |
29 | -if ($domain===false) { $Result->show("danger", _("Invalid domain Id"), true, true); } |
|
29 | +if ($domain === false) { $Result->show ("danger", _ ("Invalid domain Id"), true, true); } |
|
30 | 30 | |
31 | 31 | # fetch devices that use get_routing_table query |
32 | 32 | $scan_devices = $Tools->fetch_multiple_objects ("devices", "snmp_queries", "%get_vlan_table%", "id", true, true); |
33 | 33 | |
34 | 34 | // if none set die |
35 | -if ($scan_devices===false) { $Result->show("danger", _("No devices for SNMP VLAN query available"), true, true); } |
|
35 | +if ($scan_devices === false) { $Result->show ("danger", _ ("No devices for SNMP VLAN query available"), true, true); } |
|
36 | 36 | |
37 | 37 | ?> |
38 | 38 | |
39 | 39 | <!-- header --> |
40 | -<div class='pHeader'><?php print _("Select devices"); ?></div> |
|
40 | +<div class='pHeader'><?php print _ ("Select devices"); ?></div> |
|
41 | 41 | |
42 | 42 | <!-- content --> |
43 | 43 | <div class='pContent'> |
44 | - <h4><?php print _("Select devices to query VLAN table from"); ?></h4><hr> |
|
44 | + <h4><?php print _ ("Select devices to query VLAN table from"); ?></h4><hr> |
|
45 | 45 | |
46 | 46 | <div style="padding: 20px;"> |
47 | 47 | <form name="select-devices" id="select-devices-vlan-scan"> |
48 | 48 | <?php |
49 | 49 | // loop |
50 | 50 | foreach ($scan_devices as $d) { |
51 | - $description = strlen($d->description)>0 ? "<span class='text-muted'>$d->description</span>" : ""; |
|
51 | + $description = strlen ($d->description) > 0 ? "<span class='text-muted'>$d->description</span>" : ""; |
|
52 | 52 | print " <input type='checkbox' name='device-$d->id' checked> $d->hostname ($d->ip_addr) $description<br>"; |
53 | 53 | } |
54 | 54 | ?> |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | <!-- footer --> |
65 | 65 | <div class="pFooter"> |
66 | 66 | <div class="btn-group"> |
67 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
68 | - <button class="btn btn-sm btn-success show-vlan-scan-result"><?php print _('Scan'); ?></button> |
|
67 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
68 | + <button class="btn btn-sm btn-success show-vlan-scan-result"><?php print _ ('Scan'); ?></button> |
|
69 | 69 | |
70 | 70 | </div> |
71 | 71 | </div> |
72 | 72 | \ No newline at end of file |
@@ -5,51 +5,51 @@ 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 | # fake error |
21 | 21 | print "<div class='alert-danger hidden'></div>"; |
22 | 22 | |
23 | 23 | # scan disabled |
24 | -if ($User->settings->enableSNMP!="1") { $Result->show("danger", _("SNMP module disbled"), true); } |
|
24 | +if ($User->settings->enableSNMP != "1") { $Result->show ("danger", _ ("SNMP module disbled"), true); } |
|
25 | 25 | # admin check |
26 | -if($User->is_admin()!==true) { $Result->show("danger", _('Admin privileges required'), true); } |
|
26 | +if ($User->is_admin () !== true) { $Result->show ("danger", _ ('Admin privileges required'), true); } |
|
27 | 27 | |
28 | 28 | # set class |
29 | 29 | $Snmp = new phpipamSNMP (); |
30 | 30 | |
31 | 31 | # domain Id must be int |
32 | -if (!is_numeric($_POST['domainId'])) { $Result->show("danger", _("Invalid domain Id"), true); } |
|
32 | +if (!is_numeric ($_POST['domainId'])) { $Result->show ("danger", _ ("Invalid domain Id"), true); } |
|
33 | 33 | # fetch domain |
34 | 34 | $domain = $Tools->fetch_object ("vlanDomains", "id", $_POST['domainId']); |
35 | -if ($domain===false) { $Result->show("danger", _("Invalid domain Id"), true); } |
|
35 | +if ($domain === false) { $Result->show ("danger", _ ("Invalid domain Id"), true); } |
|
36 | 36 | |
37 | 37 | # get existing vlans |
38 | 38 | $existing_vlans = $Tools->fetch_multiple_objects ("vlans", "domainId", $domain->id, "vlanId"); |
39 | -if ($existing_vlans!==false) { |
|
39 | +if ($existing_vlans !== false) { |
|
40 | 40 | foreach ($existing_vlans as $v) { |
41 | 41 | $ex_vlans[$v->number] = $name; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | // no errors |
46 | -error_reporting(E_ERROR); |
|
46 | +error_reporting (E_ERROR); |
|
47 | 47 | |
48 | 48 | # set devices |
49 | 49 | foreach ($_POST as $k=>$p) { |
50 | - if (strpos($k, "device-")!==false) { |
|
50 | + if (strpos ($k, "device-") !== false) { |
|
51 | 51 | # fetch device |
52 | - $device = $Tools->fetch_object ("devices", "id", str_replace("device-", "", $k)); |
|
52 | + $device = $Tools->fetch_object ("devices", "id", str_replace ("device-", "", $k)); |
|
53 | 53 | if ($device !== false) { |
54 | 54 | $scan_devices[] = $device; |
55 | 55 | } |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | // if none set die |
60 | -if (!isset($scan_devices)) { $Result->show("danger", _("No devices for SNMP VLAN query available"), true); } |
|
60 | +if (!isset($scan_devices)) { $Result->show ("danger", _ ("No devices for SNMP VLAN query available"), true); } |
|
61 | 61 | |
62 | 62 | // init result array |
63 | -$new_vlans = array(); |
|
63 | +$new_vlans = array (); |
|
64 | 64 | |
65 | 65 | // ok, we have devices, connect to each device and do query |
66 | 66 | foreach ($scan_devices as $d) { |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | $Snmp->set_snmp_device ($d); |
69 | 69 | // fetch arp table |
70 | 70 | try { |
71 | - $res = $Snmp->get_query("get_vlan_table"); |
|
71 | + $res = $Snmp->get_query ("get_vlan_table"); |
|
72 | 72 | // remove those not in subnet |
73 | - if (sizeof($res)>0) { |
|
73 | + if (sizeof ($res) > 0) { |
|
74 | 74 | // save for debug |
75 | 75 | $debug[$d->hostname]["get_vlan_table"] = $res; |
76 | 76 | // loop and save |
77 | 77 | foreach ($res as $k=>$r) { |
78 | - if (!array_key_exists($k, $new_vlans) && !array_key_exists($k, $ex_vlans) ) { |
|
78 | + if (!array_key_exists ($k, $new_vlans) && !array_key_exists ($k, $ex_vlans)) { |
|
79 | 79 | $new_vlans[$k] = $r; |
80 | 80 | } |
81 | 81 | } |
@@ -83,31 +83,31 @@ discard block |
||
83 | 83 | } catch (Exception $e) { |
84 | 84 | // save for debug |
85 | 85 | $debug[$d->hostname]["get_vlan_table"] = $res; |
86 | - $errors[] = $e->getMessage(); |
|
86 | + $errors[] = $e->getMessage (); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | 90 | # none and errors |
91 | -if(sizeof($new_vlans)==0 && isset($errors)) { |
|
92 | - $Result->show("info", _("No VLANS found"), false); |
|
93 | - $Result->show("warning", implode("<hr>", $errors), false); |
|
91 | +if (sizeof ($new_vlans) == 0 && isset($errors)) { |
|
92 | + $Result->show ("info", _ ("No VLANS found"), false); |
|
93 | + $Result->show ("warning", implode ("<hr>", $errors), false); |
|
94 | 94 | } |
95 | 95 | # none |
96 | -elseif(sizeof($new_vlans)==0) { $Result->show("info", _("No VLANS found")."!", false); } |
|
96 | +elseif (sizeof ($new_vlans) == 0) { $Result->show ("info", _ ("No VLANS found")."!", false); } |
|
97 | 97 | # ok |
98 | 98 | else { |
99 | 99 | // fetch custom fields and check for required |
100 | 100 | $required_fields = $Tools->fetch_custom_fields ('vlans'); |
101 | - if($required_fields!==false) { |
|
101 | + if ($required_fields !== false) { |
|
102 | 102 | foreach ($required_fields as $k=>$f) { |
103 | - if ($f['Null']!="NO") { |
|
103 | + if ($f['Null'] != "NO") { |
|
104 | 104 | unset($required_fields[$k]); |
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | 109 | // calculate colspan |
110 | - $colspan = 4 + sizeof(@$required_fields); |
|
110 | + $colspan = 4 + sizeof (@$required_fields); |
|
111 | 111 | |
112 | 112 | |
113 | 113 | //form |
@@ -116,21 +116,21 @@ discard block |
||
116 | 116 | |
117 | 117 | // titles |
118 | 118 | print "<tr>"; |
119 | - print " <th>"._("Number")."</th>"; |
|
120 | - print " <th>"._("Name")."</th>"; |
|
121 | - print " <th>"._("Description")."</th>"; |
|
119 | + print " <th>"._ ("Number")."</th>"; |
|
120 | + print " <th>"._ ("Name")."</th>"; |
|
121 | + print " <th>"._ ("Description")."</th>"; |
|
122 | 122 | // custom |
123 | 123 | if (isset($required_fields)) { |
124 | 124 | foreach ($required_fields as $field) { |
125 | - print "<th>"._($field['name'])."</th>"; |
|
125 | + print "<th>"._ ($field['name'])."</th>"; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | print " <th></th>"; |
129 | 129 | print "</tr>"; |
130 | 130 | |
131 | 131 | // alive |
132 | - $m=0; |
|
133 | - foreach ($new_vlans as $number=>$name ) { |
|
132 | + $m = 0; |
|
133 | + foreach ($new_vlans as $number=>$name) { |
|
134 | 134 | print "<tr class='result$m'>"; |
135 | 135 | //number |
136 | 136 | print "<td>$number</td>"; |
@@ -149,28 +149,28 @@ discard block |
||
149 | 149 | if (isset($required_fields)) { |
150 | 150 | foreach ($required_fields as $field) { |
151 | 151 | # replace spaces with | |
152 | - $field['nameNew'] = str_replace(" ", "___", $field['name']); |
|
152 | + $field['nameNew'] = str_replace (" ", "___", $field['name']); |
|
153 | 153 | |
154 | - print ' <td>'. "\n"; |
|
154 | + print ' <td>'."\n"; |
|
155 | 155 | |
156 | 156 | //set type |
157 | - if(substr($field['type'], 0,3) == "set" || substr($field['type'], 0,4) == "enum") { |
|
157 | + if (substr ($field['type'], 0, 3) == "set" || substr ($field['type'], 0, 4) == "enum") { |
|
158 | 158 | //parse values |
159 | - $tmp = substr($field['type'], 0,3)=="set" ? explode(",", str_replace(array("set(", ")", "'"), "", $field['type'])) : explode(",", str_replace(array("enum(", ")", "'"), "", $field['type'])); |
|
159 | + $tmp = substr ($field['type'], 0, 3) == "set" ? explode (",", str_replace (array ("set(", ")", "'"), "", $field['type'])) : explode (",", str_replace (array ("enum(", ")", "'"), "", $field['type'])); |
|
160 | 160 | //null |
161 | - if($field['Null']!="NO") { array_unshift($tmp, ""); } |
|
161 | + if ($field['Null'] != "NO") { array_unshift ($tmp, ""); } |
|
162 | 162 | |
163 | 163 | print "<select name='$field[nameNew]$m' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
164 | - foreach($tmp as $v) { |
|
165 | - if($v==@$address[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
166 | - else { print "<option value='$v'>$v</option>"; } |
|
164 | + foreach ($tmp as $v) { |
|
165 | + if ($v == @$address[$field['name']]) { print "<option value='$v' selected='selected'>$v</option>"; } |
|
166 | + else { print "<option value='$v'>$v</option>"; } |
|
167 | 167 | } |
168 | 168 | print "</select>"; |
169 | 169 | } |
170 | 170 | //date and time picker |
171 | - elseif($field['type'] == "date" || $field['type'] == "datetime") { |
|
171 | + elseif ($field['type'] == "date" || $field['type'] == "datetime") { |
|
172 | 172 | // just for first |
173 | - if($timeP==0) { |
|
173 | + if ($timeP == 0) { |
|
174 | 174 | print '<link rel="stylesheet" type="text/css" href="css/1.2/bootstrap/bootstrap-datetimepicker.min.css">'; |
175 | 175 | print '<script type="text/javascript" src="js/1.2/bootstrap-datetimepicker.min.js"></script>'; |
176 | 176 | print '<script type="text/javascript">'; |
@@ -186,30 +186,30 @@ discard block |
||
186 | 186 | $timeP++; |
187 | 187 | |
188 | 188 | //set size |
189 | - if($field['type'] == "date") { $size = 10; $class='datepicker'; $format = "yyyy-MM-dd"; } |
|
190 | - else { $size = 19; $class='datetimepicker'; $format = "yyyy-MM-dd"; } |
|
189 | + if ($field['type'] == "date") { $size = 10; $class = 'datepicker'; $format = "yyyy-MM-dd"; } |
|
190 | + else { $size = 19; $class = 'datetimepicker'; $format = "yyyy-MM-dd"; } |
|
191 | 191 | |
192 | 192 | //field |
193 | - if(!isset($address[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'].$m .'" maxlength="'.$size.'" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
194 | - else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'. $field['nameNew'].$m .'" maxlength="'.$size.'" value="'. $address[$field['name']]. '" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; } |
|
193 | + if (!isset($address[$field['name']])) { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].$m.'" maxlength="'.$size.'" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; } |
|
194 | + else { print ' <input type="text" class="'.$class.' form-control input-sm input-w-auto" data-format="'.$format.'" name="'.$field['nameNew'].$m.'" maxlength="'.$size.'" value="'.$address[$field['name']].'" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; } |
|
195 | 195 | } |
196 | 196 | //boolean |
197 | - elseif($field['type'] == "tinyint(1)") { |
|
197 | + elseif ($field['type'] == "tinyint(1)") { |
|
198 | 198 | print "<select name='$field[nameNew]$m' class='form-control input-sm input-w-auto' rel='tooltip' data-placement='right' title='$field[Comment]'>"; |
199 | - $tmp = array(0=>"No",1=>"Yes"); |
|
199 | + $tmp = array (0=>"No", 1=>"Yes"); |
|
200 | 200 | //null |
201 | - if($field['Null']!="NO") { $tmp[2] = ""; } |
|
201 | + if ($field['Null'] != "NO") { $tmp[2] = ""; } |
|
202 | 202 | |
203 | - foreach($tmp as $k=>$v) { |
|
204 | - if(strlen(@$address[$field['name']])==0 && $k==2) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
205 | - elseif($k==@$address[$field['name']]) { print "<option value='$k' selected='selected'>"._($v)."</option>"; } |
|
206 | - else { print "<option value='$k'>"._($v)."</option>"; } |
|
203 | + foreach ($tmp as $k=>$v) { |
|
204 | + if (strlen (@$address[$field['name']]) == 0 && $k == 2) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; } |
|
205 | + elseif ($k == @$address[$field['name']]) { print "<option value='$k' selected='selected'>"._ ($v)."</option>"; } |
|
206 | + else { print "<option value='$k'>"._ ($v)."</option>"; } |
|
207 | 207 | } |
208 | 208 | print "</select>"; |
209 | 209 | } |
210 | 210 | //default - input field |
211 | 211 | else { |
212 | - print ' <input type="text" class="ip_addr form-control input-sm" name="'. $field['nameNew'].$m .'" placeholder="'. $field['name'] .'" value="'. @$address[$field['name']]. '" size="30" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'. "\n"; |
|
212 | + print ' <input type="text" class="ip_addr form-control input-sm" name="'.$field['nameNew'].$m.'" placeholder="'.$field['name'].'" value="'.@$address[$field['name']].'" size="30" '.$delete.' rel="tooltip" data-placement="right" title="'.$field['Comment'].'">'."\n"; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | print " </td>"; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | print "<tr>"; |
227 | 227 | print " <td colspan='$colspan'>"; |
228 | 228 | print " <div id='vlanScanAddResult'></div>"; |
229 | - print " <a href='' class='btn btn-sm btn-success pull-right' id='saveVlanScanResults' data-script='vlans-scan' data-subnetId='".$_POST['subnetId']."'><i class='fa fa-plus'></i> "._("Add discovered VLANS")."</a>"; |
|
229 | + print " <a href='' class='btn btn-sm btn-success pull-right' id='saveVlanScanResults' data-script='vlans-scan' data-subnetId='".$_POST['subnetId']."'><i class='fa fa-plus'></i> "._ ("Add discovered VLANS")."</a>"; |
|
230 | 230 | print " </td>"; |
231 | 231 | print "</tr>"; |
232 | 232 | |
@@ -254,5 +254,5 @@ discard block |
||
254 | 254 | print "</div>"; |
255 | 255 | |
256 | 256 | # show debug? |
257 | -if($_POST['debug']==1) { print "<pre>"; print_r($debug); print "</pre>"; } |
|
257 | +if ($_POST['debug'] == 1) { print "<pre>"; print_r ($debug); print "</pre>"; } |
|
258 | 258 | ?> |
259 | 259 | \ No newline at end of file |
@@ -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 |
@@ -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 --> |
@@ -4,6 +4,6 @@ |
||
4 | 4 | * Script to display available VLANs |
5 | 5 | */ |
6 | 6 | |
7 | -include(dirname(__FILE__) . "/../../tools/vlan/index.php"); |
|
7 | +include(dirname (__FILE__)."/../../tools/vlan/index.php"); |
|
8 | 8 | |
9 | 9 | ?> |
10 | 10 | \ No newline at end of file |