-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwmi_tools.php
649 lines (559 loc) · 20.5 KB
/
wmi_tools.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2024 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
chdir('../../');
include('./include/auth.php');
include_once('./lib/snmp.php');
include_once('./lib/utility.php');
set_default_action();
process_request_vars();
switch (get_request_var('action')) {
case 'query':
walk_host();
break;
case 'queries':
common_queries_panel();
break;
case 'assistance':
assistance_panel();
break;
default:
top_header();
show_tools();
bottom_footer();
break;
}
function process_request_vars() {
/* ================= input validation and session storage ================= */
$filters = array(
'username' => array(
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'password' => array(
'filter' => FILTER_DEFAULT,
'pageset' => true,
'default' => '',
),
'namespace' => array(
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'keyname' => array(
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'frequency' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '120'
),
'host' => array(
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'name' => array(
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => 'New Query',
'options' => array('options' => 'sanitize_search_string')
)
);
validate_store_request_vars($filters, 'sess_wmic');
/* ================= input validation ================= */
}
function common_queries_panel() {
$common = array(
array(
'key' => 'None',
'tip' => __('Get Computer Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_ComputerSystem'
),
array(
'key' => 'ProcessId',
'tip' => __('Get System Processes', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_Process'
),
array(
'key' => 'Name',
'tip' => __('Get Installed Software', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_Product'
),
array(
'key' => 'None',
'tip' => __('Get Operating System Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_OperatingSystem'
),
array(
'key' => 'Name',
'tip' => __('Get OD Service Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_Service'
),
array(
'key' => 'None',
'tip' => __('Get System Enclosure Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_SystemEnclosure'
),
array(
'key' => 'InterleavePosition',
'tip' => __('Get System Physical Memory Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PhysicalMemory'
),
array(
'key' => 'DeviceID',
'tip' => __('Get Memory Device Details', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_MemoryDevice'
),
array(
'key' => 'None',
'tip' => __('Get System BIOS Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_BIOS'
),
array(
'key' => 'None',
'tip' => __('Get System Baseboard Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_BaseBoard'
),
array(
'key' => 'DeviceID',
'tip' => __('Get Processor Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_Processor'
),
array(
'key' => 'None',
'tip' => __('Ping a Known Address from Computer', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PingStatus where Address = "www.google.com"'
),
array(
'key' => 'None',
'tip' => __('Get Row System OS Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfRawData_PerfOS_System'
),
array(
'key' => 'None',
'tip' => __('Get Formatted System OS Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfFormattedData_PerfOS_System'
),
array(
'key' => 'Name',
'tip' => __('Get Formatted Phsycal Disk Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfFormattedData_PerfDisk_PhysicalDisk'
),
array(
'key' => 'Name',
'tip' => __('Get Raw Phsycal Disk Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfRawData_PerfDisk_PhysicalDisk'
),
array(
'key' => 'DeviceID',
'tip' => __('Get Logical Disk Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_LogicalDisk'
),
array(
'key' => 'Name',
'tip' => __('Get Formatted Logical Disk Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfFormattedData_PerfDisk_LogicalDisk'
),
array(
'key' => 'Name',
'tip' => __('Get Raw Logical Disk Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfRawData_PerfDisk_LogicalDisk'
),
array(
'key' => 'Name',
'tip' => __('Get Formatted CPU Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor'
),
array(
'key' => 'Name',
'tip' => __('Get Raw CPU Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfRawData_PerfOS_Processor'
),
array(
'key' => 'None',
'tip' => __('Get Raw Memory Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfRawData_PerfOS_Memory'
),
array(
'key' => 'Name',
'tip' => __('Get Formatted Network Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface'
),
array(
'key' => 'Name',
'tip' => __('Get Raw Network Performance Data', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface'
),
array(
'key' => 'DeviceID',
'tip' => __('Get Network Adapter Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_NetworkAdapter'
),
array(
'key' => 'None',
'tip' => __('Get Computer Asset Information', 'wmi'),
'namespace' => 'root\\\\CIMV2',
'query' => 'SELECT * FROM Win32_ComputerSystemProduct'
),
);
// Common Queries Panel
print "<div id='common_queries' style='display:none;'>";
html_start_box('', '100%', '', '3', 'center', '');
html_header(array(__('Description', 'wmi'), __('Primary Key', 'wmi'), __('Name Space', 'wmi'), __('Query', 'wmi')));
$i = 0;
foreach($common as $query) {
form_alternate_row('line' . $i, true);
print "<td style='font-weight:bold;'>" . $query['tip'] .
"</td><td class='keyname'>" . $query['key'] .
"</td><td class='namespace'>" . $query['namespace'] .
"</td><td class='query'>" . $query['query'] . "</td>";
form_end_row();
$i++;
}
print "<tr><td colspan='4' class='odd'><input type='button' id='close_queries' value='" . __('Close', 'wmi') . "'></td></tr>";
html_end_box(false);
print "</div>";
}
// Assistance Panel
function assistance_panel() {
print "<div id='assistance' style='display:none;'>";
html_start_box('', '100%', '', '3', 'center', '');
form_alternate_row();
print '<td>';
print '<p>' . __('If you need assistance on error codes, use google, or here use the following Link %s.', '<a target="_new" class="linkEditMain" href="https://msdn.microsoft.com/en-us/library/aa394559(v=vs.85).aspx">' . __('Microsoft Common WBEM Errors', 'wmi') . '</a>', 'wmi') . '</p>';
print '<p>' . __('For WMI to work the user account you are using must be granted Distributed COM permissions, and the Windows Firewall must be configured to allow Distributed COM communications. You can find a real good document on this procedure at the following Link %s.', '<a target="_new" class="linkEditMain" href="http://www-01.ibm.com/support/docview.wss?uid=swg21678809">' . __('Distributed COM Setup', 'wmi') . '</a>', 'wmi') . '</p>';
print '</td>';
form_end_row();
print "<tr><td colspan='4' class='odd'><input type='button' id='close_help' value='" . __('Close', 'wmi') . "'></td></tr>";
html_end_box(false);
print "</div>";
}
function show_tools() {
global $action, $host, $username, $password, $command, $wmi_frequencies;
html_start_box(__('WMI Query Tool', 'wmi') , '100%', '', '3', 'center', '');
print "<tr><td>";
form_start('wmi_tools.php?action=query&header=false', 'form_wmi');
print "<table width='100%'>";
print "<tr>";
print "<td valign='center' width='50'>" . __('Name', 'wmi') . "</td>";
print "<td><input type='text' size='40' id='name' value='" . html_escape_request_var('name') . "'></td>";
print "</tr><tr>";
print "<td valign='center' width='50'>" . __('Frequency', 'wmi') . "</td>";
print "<td><select id='frequency'>";
foreach($wmi_frequencies as $key => $name) {
print "<option value='$key'" . (get_request_var('frequency') == $key ? ' selected':'') . ">" . $name . "</option>";
}
print "</select></td>";
print "</tr><tr>";
print "<td valign='center' width='50'>" . __('Host', 'wmi') . "</td>";
print "<td><input type='text' size='40' id='host' value='" . html_escape_request_var('host') . "'></td>";
print "</tr><tr>";
print "<td class='nowrap'>" . __('Username', 'wmi') . "</td>";
print "<td><input type='text' size='30' id='username' value='" . html_escape_request_var('username') . "'></td>";
print "</tr><tr>";
print "<td class='nowrap'>" . __('Password', 'wmi') . "</td>";
print "<td><input type='password' size='30' id='password' value='" . html_escape_request_var('password') . "'></td>";
print "</tr><tr>";
print "<td class='nowrap'>" . __('Namespace', 'wmi') . "</td>";
print "<td><input type='text' size='30' id='namespace' value='" . html_escape_request_var('namespace') . "'></td>";
print "</tr><tr>";
print "<td class='nowrap'>" . __('Command', 'wmi') . "</td>";
print "<td><textarea class='textAreaNotes' rows='4' cols='80' id='command' value='" . html_escape_request_var('command') . "'></textarea></td>";
print "</tr><tr>";
print "<td class='nowrap'>" . __('Primary Key', 'wmi') . "</td>";
print "<td><input type='text' size='30' id='keyname' value='" . html_escape_request_var('keyname') . "'></td>";
print "</tr><tr>";
print "<td colspan='2' style='padding:5px 0px;'><a class='hyperLink' target='_new' href='" . html_escape('https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-provider') ."'>" . __('More Class Information @Microsoft', 'wmi') . "</a></td></tr>";
print "<tr><td colspan='2'>";
print "<input type='submit' value='" . __('Run', 'wmi') . "' id='submit' title='" . __('Run the WMI Query against the Device', 'wmi') . "'>";
print "<input type='button' value='" . __('Clear', 'wmi') . "' id='clear' title='" . __('Clear the results panel.', 'wmi') . "'>";
print "<input type='button' value='" . __('Queries', 'wmi') . "' id='queries' title='" . __('Pick from a list of common queries.', 'wmi') . "'>";
print "<input type='button' value='" . __('Help', 'wmi') . "' id='help' title='" . __('Get some help on setting up WMI', 'wmi') . "'>";
print "<input type='button' value='" . __('Add', 'wmi') . "' id='add' title='" . __('Create a new WMI Query from the existing Query.', 'wmi') . "'>";
print "</td></tr>";
print "</table>";
form_end();
print "</td></tr>";
html_end_box();
// Query Results Panel
html_start_box(__('Query Results', 'wmi') , '100%', '', '3', 'center', '');
form_alternate_row();
print "<td><div class='odd' style='min-height:200px;' id='results'></div></td>";
form_end_row();
html_end_box();
?>
<script type='text/javascript'>
$(function() {
<?php if (get_selected_theme() != 'classic') {?>
$('#add').button('disable');
<?php } else {?>
$('#add').prop('disabled', true);
<?php }?>
$('#form_wmi').unbind().submit(function(event) {
event.preventDefault();
runQuery();
});
$('#queries').click(function() {
$('#assistance').remove();
$.get('wmi_tools.php?action=queries', function(data) {
$('body').append(data);
$('#common_queries').dialog({
title: '<?php print __('Common Queries (Click to Select)', 'wmi');?>',
width: '1024',
});
$('tr[id^="line"]').css('cursor', 'pointer').attr('title', 'Click to use this Query').tooltip().click(function() {
$('#command').val($(this).find('.query').html());
$('#namespace').val($(this).find('.namespace').html());
$('#keyname').val($(this).find('.keyname').html());
$('tr[id^="line"]').not(this).removeClass('selected');
$(this).addClass('selected');
});
<?php if (get_selected_theme() != 'classic') {?>
$('#close_queries').button().click(function() {
$('#common_queries').remove();
});
<?php } else {?>
$('#close_queries').click(function() {
$('#common_queries').remove();
});
<?php }?>
});
});
$('#help').click(function() {
$('#common_queries').remove();
$.get('wmi_tools.php?action=assistance', function(data) {
$('body').append(data);
$('#assistance').dialog({
title: '<?php print __('WMI Setup Assistance', 'wmi');?>',
width: '1024',
});
<?php if (get_selected_theme() != 'classic') {?>
$('#close_help').button().click(function() {
$('#assistance').remove();
});
<?php } else {?>
$('#close_help').click(function() {
$('#assistance').remove();
});
<?php }?>
});
});
$('#wmi_tools1').find('.cactiTableTitle, .cactiTableBottom').css('cursor', 'pointer').click(function() {
$('#wmi_tools1_child').toggle();
});
$('#wmi_tools2').find('.cactiTableTitle, .cactiTableBottom').css('cursor', 'pointer').click(function() {
$('#wmi_tools2_child').toggle();
});
$('#wmi_tools3').find('.cactiTableTitle, .cactiTableBottom').css('cursor', 'pointer').click(function() {
$('#wmi_tools3_child').toggle();
});
$('#clear').click(function() {
$('#results').empty();
<?php if (get_selected_theme() != 'classic') {?>
$('#submit').button('enable');
<?php } else {?>
$('#submit').prop('disabled', false);
<?php }?>
});
$('#add').click(function() {
post = {
__csrf_magic: csrfMagicToken,
name: $('#name').val(),
frequency: $('#frequency').val(),
namespace: $('#namespace').val(),
enabled: '',
query: $('#command').val(),
primary_key: $('#keyname').val()
};
$.post('wmi_queries.php?action=save', post).done(function(data) {
$('#main').html(data);
applySkin();
});
});
});
function runQuery() {
$.post('wmi_tools.php?action=query&header=false', { host: $('#host').val(), username: $('#username').val(), password: $('#password').val(), namespace: $('#namespace').val(), command: $('#command').val(), __csrf_magic: csrfMagicToken }).done(function(data) {
$('#results').html(data);
applySkin();
<?php if (get_selected_theme() != 'classic') {?>
$('#submit').button('enable');
<?php } else {?>
$('#submit').prop('disabled', false);
<?php }?>
if (data.indexOf('ERROR:') == -1) {
<?php if (get_selected_theme() != 'classic') {?>
$('#add').button('enable');
<?php } else {?>
$('#add').prop('disabled', false);
<?php }?>
}
});
}
</script>
<?php
}
function walk_host() {
global $config, $host;
$host = get_nfilter_request_var('host');
$username = get_nfilter_request_var('username');
$password = get_nfilter_request_var('password');
$namespace = get_nfilter_request_var('namespace');
if (!isset_request_var('command')) {
$command = 'SELECT * FROM Win32_Process';
} else {
$command = get_nfilter_request_var('command');
}
$host = strtolower($host);
if ($username == '' || $password == '' || $host == '') {
print __('ERROR: You must provide a host, username, password and query', 'wmi');
exit;
}
if ($config['cacti_server_os'] != 'win32') {
include_once($config['base_path'] . '/plugins/wmi/linux_wmi.php');
$wmi = new Linux_WMI();
$wmi->hostname = $host;
$wmi->username = $username;
$wmi->password = $password;
$wmi->querynspace = $namespace;
$wmi->command = $command;
$wmi->binary = read_config_option('path_wmi');
if ($wmi->binary == '') {
$wmi->binary = '/usr/bin/wmic';
}
if ($wmi->querynspace == '') {
$wmi->querynspace = 'root\\\\CIMV2';
}
if ($wmi->fetch() !== false) {;
print "<table style='width:100%'><tr><td class='even'>";
$indexes = $wmi->fetch_indexes();
$class = $wmi->fetch_class();
$data = $wmi->fetch_data();
print "<h4>" . __('WMI Query Results for Device: %s, Class: %s, Columns: %s, Rows: %s', $host, $class, sizeof($indexes), sizeof($data), 'wmi') . "</h4>";
print "<p>" . __('Showing columns and first one or two rows of data.', 'wmi') . "</p>";
print "</table>";
print "<table style='width:100%'>";
$present = 'columns';
if ($present == 'columns') {
if (cacti_sizeof($data[0])) {
foreach($data[0] as $index => $r) {
form_alternate_row('line' . $index, true);
print "<td style='font-weight:bold;'>" . $indexes[$index] . "</td><td>" . $r . "</td>";
if (isset($data[1][$index])) {
print "<td style='font-weight:bold;'>" . $indexes[$index] . "</td><td>" . $data[1][$index] . "</td>";
}
form_end_row();
}
}
} else {
foreach($data as $row) {
$indexes = array_keys($row);
if (cacti_sizeof($indexes)) {
print "<tr>";
foreach($indexes as $col) {
print "<th>" . $col . "</th>";
}
print "</tr>";
}
print "<tr>";
foreach($row as $data) {
print "<td>" . $data . "</td>";
}
print "</tr>";
}
}
print "</table>";
} else {
print $wmi->error;
}
} else {
// Windows version
$wmi = new COM('WbemScripting.SWwebLocator');
$wmic = $wmi->ConnectServer($host, $namespace, $username, $password);
$wmic->Security_->ImpersonationLevel = 3;
$data = $wmic->ExecQuery($command);
if (cacti_sizeof($data)) {
$odata = (array) $data[0];
$indexes = array_keys($odata);
if (isset($data[1])) {
$odata1 = (array) $data[1];
} else {
$odata1 = array();
}
print "<table style='width:100%'><tr><td>";
print "<h4>" . __('WMI Query Results for Device: %s, Class: %s, Columns: %s, Rows: %s', $host, $namespace, sizeof($indexes), sizeof($data), 'wmi') . "</h4>";
print "<p>" . __('Showing columns and first one or two rows of data.', 'wmi') . "</p>";
print "</table>";
print "<table style='width:100%'>";
if (cacti_sizeof($odata)) {
foreach($odata as $index => $r) {
form_alternate_row('line' . $index, true);
print "<td style='font-weight:bold;'>" . $indexes[$index] . "</td><td>" . $r . "</td>";
if (cacti_sizeof($odata1)) {
print "<td style='font-weight:bold;'>" . $indexes[$index] . "</td><td>" . $odata1[$index] . "</td>";
}
form_end_row();
}
}
print "</table>";
}
}
}
function is_valid_host($host) {
if (preg_match('/^((([0-9]{1,3}\.){3}[0-9]{1,3})|([0-9a-z-.]{0,61})?\.[a-z]{2,4})$/i', $host)) {
return true;
}
return false;
}