|
25 | 25 | * You should have received a copy of the GNU General Public License |
26 | 26 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 | 27 | * |
| 28 | + * @changes P.Peyremorte |
| 29 | + * - added display of ports checked (80 may be not used!) |
| 30 | + * - refactored (replacement of duplicate string constructions by a fucntion) |
28 | 31 | */ |
29 | 32 | class module_controller extends ctrl_module |
30 | 33 | { |
| 34 | + static private function status_port($PortNum, $iconpath) |
| 35 | + { |
| 36 | + $status = sys_monitoring::LocalPortStatus($PortNum); |
| 37 | + return ($status ? $iconpath.'up.gif">' : $iconpath.'down.gif">') . ' (port ' . $PortNum .' is ' . ($status ? 'open' : 'closed') . ')'; |
| 38 | + } |
31 | 39 |
|
32 | 40 | static public function getServices() |
33 | 41 | { |
34 | 42 | global $controller; |
| 43 | + $iconpath = '<img src="modules/' . $controller->GetControllerRequest('URL', 'module') . '/assets/'; |
| 44 | + |
35 | 45 | $line = "<h2>" . ui_language::translate("Checking status of services...") . "</h2>"; |
36 | 46 | $line .= "<table>"; |
37 | | - $line .= "<tr>"; |
38 | | - $line .= "<th>HTTP</th>"; |
39 | | - $line .= "<td>"; |
40 | | - |
41 | | - if (fs_director::CheckForEmptyValue(sys_monitoring::PortStatus(80))) { |
42 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/down.gif\">"; |
43 | | - } else { |
44 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/up.gif\">"; |
45 | | - } |
46 | | - |
47 | | - $line .= "</td>"; |
48 | | - $line .= "</tr>"; |
49 | | - $line .= "<tr>"; |
50 | | - $line .= "<th>FTP</th>"; |
51 | | - $line .= "<td>"; |
52 | | - |
53 | | - if (fs_director::CheckForEmptyValue(sys_monitoring::PortStatus(21))) { |
54 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/down.gif\">"; |
55 | | - } else { |
56 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/up.gif\">"; |
57 | | - } |
58 | | - |
59 | | - $line .= "</td>"; |
60 | | - $line .= "</tr>"; |
61 | | - $line .= "<tr>"; |
62 | | - $line .= "<th>SMTP</th>"; |
63 | | - $line .= "<td>"; |
64 | | - |
65 | | - if (fs_director::CheckForEmptyValue(sys_monitoring::PortStatus(25))) { |
66 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/down.gif\">"; |
67 | | - } else { |
68 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/up.gif\">"; |
69 | | - } |
70 | | - |
71 | | - $line .= "</td>"; |
72 | | - $line .= "</tr>"; |
73 | | - $line .= "<tr>"; |
74 | | - $line .= "<th>POP3</th>"; |
75 | | - $line .= "<td>"; |
76 | | - |
77 | | - if (fs_director::CheckForEmptyValue(sys_monitoring::PortStatus(110))) { |
78 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/down.gif\">"; |
79 | | - } else { |
80 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/up.gif\">"; |
81 | | - } |
82 | | - |
83 | | - $line .= "</td>"; |
84 | | - $line .= "</tr>"; |
85 | | - $line .= "<tr>"; |
86 | | - $line .= "<th>IMAP</th>"; |
87 | | - $line .= "<td>"; |
88 | | - |
89 | | - if (fs_director::CheckForEmptyValue(sys_monitoring::PortStatus(143))) { |
90 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/down.gif\">"; |
91 | | - } else { |
92 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/up.gif\">"; |
93 | | - } |
94 | | - |
95 | | - $line .= "</td>"; |
96 | | - $line .= "</tr>"; |
97 | | - $line .= "<tr>"; |
98 | | - $line .= "<th>MySQL</th>"; |
99 | | - $line .= "<td>"; |
100 | | - /* MySQL has to be on-line as you are viewing this page, we made this 'static' to save on port queries (saves time) amongst other reasons. */ |
101 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/up.gif\">"; |
102 | | - |
103 | | - $line .= "</td>"; |
104 | | - $line .= "</tr>"; |
105 | | - $line .= "<tr>"; |
106 | | - $line .= "<th>DNS</th>"; |
107 | | - $line .= "<td>"; |
108 | | - |
109 | | - if (fs_director::CheckForEmptyValue(sys_monitoring::PortStatus(53))) { |
110 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/down.gif\">"; |
111 | | - } else { |
112 | | - $line .= "<img src=\"modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/up.gif\">"; |
113 | | - } |
114 | | - |
115 | | - $line .= "</td>"; |
116 | | - $line .= "</tr>"; |
117 | | - $line .= "</table>"; |
118 | | - $line .= "<br><h2>" . ui_language::translate("Server Uptime") . "</h2>"; |
119 | | - $line .= ui_language::translate("Uptime") . ": " . sys_monitoring::ServerUptime(); |
| 47 | + |
| 48 | + $status = fs_director::CheckForEmptyValue(sys_monitoring::PortStatus($PortNum)); |
| 49 | + |
| 50 | + $line .= '<tr><th>HTTP</th><td>' . module_controller::status_port(80, $iconpath) . '</td></tr>'; |
| 51 | + $line .= '<tr><th>FTP</th><td>' . module_controller::status_port(21, $iconpath) . '</td></tr>'; |
| 52 | + $line .= '<tr><th>SMTP</th><td>' . module_controller::status_port(25, $iconpath) . '</td></tr>'; |
| 53 | + $line .= '<tr><th>POP3</th><td>' . module_controller::status_port(110, $iconpath) . '</td></tr>'; |
| 54 | + $line .= '<tr><th>IMAP</th><td>' . module_controller::status_port(143, $iconpath) . '</td></tr>'; |
| 55 | + $line .= '<tr><th>MySQL</th><td>' . module_controller::status_port(3306, $iconpath) . '</td></tr>'; |
| 56 | + $line .= '<tr><th>DNS</th><td>' . module_controller::status_port(53, $iconpath) . '</td></tr>'; |
| 57 | + $line .= '</table>'; |
| 58 | + $line .= '<br><h2>' . ui_language::translate('Server Uptime') . '</h2>'; |
| 59 | + $line .= ui_language::translate('Uptime') . ": " . sys_monitoring::ServerUptime(); |
120 | 60 | return $line; |
121 | 61 | } |
122 | 62 |
|
|
0 commit comments