-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverifyAQLConfiguration.php
More file actions
1666 lines (1528 loc) · 61.5 KB
/
verifyAQLConfiguration.php
File metadata and controls
1666 lines (1528 loc) · 61.5 KB
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
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
* verifyAQLConfiguration.php - Configuration verification and setup guidance
*
* This page helps new users verify their AQL configuration and provides
* actionable guidance for fixing issues. Unlike testAQL.php, this page
* works even with incomplete configuration.
*
* aql - Active Query Listing
*
* Copyright (C) 2018 Kevin Benton - kbcmdba [at] gmail [dot] com
*
* 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.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
namespace com\kbcmdba\aql ;
require 'vendor/autoload.php' ;
use com\kbcmdba\aql\Libs\WebPage ;
// Minimal bootstrap - don't fail if config is broken
error_reporting( E_ALL ) ;
ini_set( 'display_errors', 0 ) ;
$page = new WebPage( 'AQL Configuration Verification' ) ;
// Start output buffering to capture body content
ob_start() ;
$configFile = __DIR__ . '/aql_config.xml' ;
$sampleFile = __DIR__ . '/config_sample.xml' ;
// Status icons
$passIcon = "<span class='status-pass'>✔</span>" ;
$failIcon = "<span class='status-fail'>✘</span>" ;
$warnIcon = "<span class='status-warn'>⚠</span>" ;
$infoIcon = "<span class='status-info'>●</span>" ;
// Track overall status
$criticalErrors = 0 ;
$warnings = 0 ;
$configValues = [] ;
$configLoaded = false ;
// Try to load configuration
if ( file_exists( $configFile ) && is_readable( $configFile ) ) {
$xml = @simplexml_load_file( $configFile ) ;
if ( $xml ) {
foreach ( $xml as $v ) {
$key = (string) $v['name'] ;
$configValues[$key] = (string) $v ;
}
$configLoaded = true ;
}
}
// Define all parameters with metadata
$allParams = [
// Required parameters
'dbHost' => [
'required' => true,
'description' => 'Database server hostname or IP',
'example' => '127.0.0.1',
'validate' => 'notEmpty'
],
'dbPort' => [
'required' => true,
'description' => 'Database server port',
'example' => '3306',
'validate' => 'numeric'
],
'dbUser' => [
'required' => true,
'description' => 'Database username for AQL',
'example' => 'aql_app',
'validate' => 'notEmpty'
],
'dbPass' => [
'required' => true,
'description' => 'Database password',
'example' => 'YourSecurePassword',
'validate' => 'notEmpty',
'sensitive' => true
],
'dbName' => [
'required' => true,
'description' => 'AQL database name',
'example' => 'aql_db',
'validate' => 'notEmpty'
],
'baseUrl' => [
'required' => true,
'description' => 'Full URL to AJAXgetaql.php',
'example' => 'https://yourserver.com/aql/AJAXgetaql.php',
'validate' => 'url'
],
'timeZone' => [
'required' => true,
'description' => 'PHP timezone identifier',
'example' => 'America/Chicago',
'validate' => 'timezone'
],
'issueTrackerBaseUrl' => [
'required' => true,
'description' => 'Base URL for your issue tracker',
'example' => 'https://yourcompany.atlassian.net/',
'validate' => 'url'
],
'roQueryPart' => [
'required' => true,
'description' => 'SQL expression to check read-only status',
'example' => '@@global.read_only',
'validate' => 'notEmpty',
'default' => '@@global.read_only'
],
// Optional parameters - Database
'dbInstanceName' => [
'required' => false,
'description' => 'MS-SQL instance name (if applicable)',
'example' => 'SQLEXPRESS',
'validate' => 'none',
'default' => ''
],
'globalStatusDb' => [
'required' => false,
'description' => 'Database containing global_status table',
'example' => 'performance_schema',
'validate' => 'notEmpty',
'default' => 'performance_schema'
],
'killStatement' => [
'required' => false,
'description' => 'SQL to kill a query (use :pid placeholder)',
'example' => 'CALL mysql.rds_kill(:pid)',
'validate' => 'notEmpty',
'default' => 'kill :pid'
],
'showSlaveStatement' => [
'required' => false,
'description' => 'SQL to check replication status',
'example' => 'show slave status',
'validate' => 'notEmpty',
'default' => 'show slave status'
],
// Optional parameters - Refresh
'minRefresh' => [
'required' => false,
'description' => 'Minimum refresh interval (seconds)',
'example' => '15',
'validate' => 'numeric',
'default' => '15'
],
'defaultRefresh' => [
'required' => false,
'description' => 'Default refresh interval (seconds)',
'example' => '60',
'validate' => 'numeric',
'default' => '60'
],
// Optional parameters - LDAP
'doLDAPAuthentication' => [
'required' => false,
'description' => 'Enable LDAP/AD authentication',
'example' => 'true',
'validate' => 'boolean',
'default' => 'false',
'group' => 'ldap'
],
'ldapHost' => [
'required' => false,
'description' => 'LDAP server URL',
'example' => 'ldaps://ad.yourcompany.com/',
'validate' => 'url',
'conditionalOn' => 'doLDAPAuthentication',
'group' => 'ldap'
],
'ldapDomainName' => [
'required' => false,
'description' => 'LDAP domain DN',
'example' => 'DC=yourcompany,DC=com',
'validate' => 'notEmpty',
'conditionalOn' => 'doLDAPAuthentication',
'group' => 'ldap'
],
'ldapUserGroup' => [
'required' => false,
'description' => 'LDAP group for authorized users',
'example' => 'DBAs',
'validate' => 'notEmpty',
'conditionalOn' => 'doLDAPAuthentication',
'group' => 'ldap'
],
'ldapUserDomain' => [
'required' => false,
'description' => 'LDAP user domain prefix',
'example' => 'YOURCOMPANY',
'validate' => 'notEmpty',
'conditionalOn' => 'doLDAPAuthentication',
'group' => 'ldap'
],
'ldapVerifyCert' => [
'required' => false,
'description' => 'Verify LDAP SSL certificate',
'example' => 'true',
'validate' => 'boolean',
'default' => 'true',
'group' => 'ldap'
],
'ldapDebugConnection' => [
'required' => false,
'description' => 'Show LDAP debug output',
'example' => 'false',
'validate' => 'boolean',
'default' => 'false',
'group' => 'ldap'
],
// Optional parameters - Jira
'jiraEnabled' => [
'required' => false,
'description' => 'Enable Jira integration',
'example' => 'true',
'validate' => 'boolean',
'default' => 'false',
'group' => 'jira'
],
'jiraProjectId' => [
'required' => false,
'description' => 'Jira project ID (numeric)',
'example' => '10010',
'validate' => 'numeric',
'conditionalOn' => 'jiraEnabled',
'group' => 'jira'
],
'jiraIssueTypeId' => [
'required' => false,
'description' => 'Jira issue type ID (numeric)',
'example' => '10001',
'validate' => 'numeric',
'conditionalOn' => 'jiraEnabled',
'group' => 'jira'
],
'jiraQueryHashFieldId' => [
'required' => false,
'description' => 'Custom field ID for query hash',
'example' => 'customfield_10100',
'validate' => 'none',
'group' => 'jira'
],
// Optional parameters - Test Harness
'testDbUser' => [
'required' => false,
'description' => 'Test database username',
'example' => 'aql_test',
'validate' => 'notEmpty',
'group' => 'test'
],
'testDbPass' => [
'required' => false,
'description' => 'Test database password',
'example' => 'TestPassword',
'validate' => 'notEmpty',
'sensitive' => true,
'group' => 'test'
],
'testDbName' => [
'required' => false,
'description' => 'Test database name',
'example' => 'aql_test',
'validate' => 'notEmpty',
'group' => 'test'
],
// Optional parameters - Features
'enableMaintenanceWindows' => [
'required' => false,
'description' => 'Enable maintenance window feature',
'example' => 'true',
'validate' => 'boolean',
'default' => 'false'
],
'dbaSessionTimeout' => [
'required' => false,
'description' => 'DBA session timeout (seconds)',
'example' => '86400',
'validate' => 'numeric',
'default' => '86400'
],
'enableSpeechAlerts' => [
'required' => false,
'description' => 'Announce alerts via speech synthesis',
'example' => 'true',
'validate' => 'boolean',
'default' => 'true'
],
// Optional parameters - Redis
'redisEnabled' => [
'required' => false,
'description' => 'Enable Redis monitoring',
'example' => 'true',
'validate' => 'boolean',
'default' => 'false',
'group' => 'redis'
],
'redisPassword' => [
'required' => false,
'description' => 'Shared password for all Redis hosts',
'example' => 'YourRedisPassword',
'validate' => 'none',
'sensitive' => true,
'conditionalOn' => 'redisEnabled',
'group' => 'redis'
],
'redisUsername' => [
'required' => false,
'description' => 'Redis username (Redis 6+ ACL)',
'example' => 'default',
'validate' => 'none',
'conditionalOn' => 'redisEnabled',
'group' => 'redis'
],
'redisConnectTimeout' => [
'required' => false,
'description' => 'Redis connection timeout (seconds)',
'example' => '2',
'validate' => 'numeric',
'default' => '2',
'group' => 'redis'
],
'redisDatabase' => [
'required' => false,
'description' => 'Redis database number (0-15)',
'example' => '0',
'validate' => 'numeric',
'default' => '0',
'group' => 'redis'
]
] ;
// Validation helper functions
function validateParam( $value, $type ) {
if ( $type === 'none' ) return [ true, '' ] ;
if ( $type === 'notEmpty' ) {
return [ !empty( $value ), 'Value is required' ] ;
}
if ( $type === 'numeric' ) {
return [ is_numeric( $value ), 'Must be a number' ] ;
}
if ( $type === 'url' ) {
if ( empty( $value ) ) return [ false, 'URL is required' ] ;
return [ filter_var( $value, FILTER_VALIDATE_URL ) !== false, 'Invalid URL format' ] ;
}
if ( $type === 'timezone' ) {
try {
new \DateTimeZone( $value ) ;
return [ true, '' ] ;
} catch ( \Exception $e ) {
return [ false, 'Invalid timezone' ] ;
}
}
if ( $type === 'boolean' ) {
return [ in_array( strtolower( $value ), [ 'true', 'false', '1', '0', '' ] ), 'Must be true or false' ] ;
}
return [ true, '' ] ;
}
function isFeatureEnabled( $param, $configValues ) {
$value = $configValues[$param] ?? 'false' ;
return strtolower( $value ) === 'true' ;
}
?>
<div class="verify-container">
<h1>AQL Configuration Verification</h1>
<?php
// ============================================================================
// SECTION 0: PHP Requirements Check
// ============================================================================
// Check required PHP extensions
$requiredExtensions = [
'mysqli' => [ 'required' => true, 'purpose' => 'MySQL/MariaDB database connectivity' ],
'simplexml' => [ 'required' => true, 'purpose' => 'Parse aql_config.xml' ],
'curl' => [ 'required' => true, 'purpose' => 'Jira integration, smoke tests' ],
'json' => [ 'required' => true, 'purpose' => 'AJAX responses' ],
'ldap' => [ 'required' => false, 'purpose' => 'LDAP/AD authentication (if enabled)' ],
'openssl' => [ 'required' => false, 'purpose' => 'HTTPS and LDAPS connections' ],
'redis' => [ 'required' => false, 'purpose' => 'Redis monitoring (if enabled)' ]
] ;
$missingRequired = [] ;
$missingOptional = [] ;
foreach ( $requiredExtensions as $ext => $info ) {
if ( !extension_loaded( $ext ) ) {
if ( $info['required'] ) {
$missingRequired[] = $ext ;
} else {
$missingOptional[] = $ext ;
}
}
}
// Only show this section if there are issues
if ( !empty( $missingRequired ) || !empty( $missingOptional ) ) :
?>
<h2>0. PHP Requirements</h2>
<?php if ( !empty( $missingRequired ) ) : ?>
<?php $criticalErrors += count( $missingRequired ) ; ?>
<div class="summary-box error">
<p><?php echo $failIcon ; ?> <strong>Missing required PHP extensions:</strong>
<code><?php echo htmlspecialchars( implode( ', ', $missingRequired ) ) ; ?></code></p>
</div>
<div class="fix-section">
<h3>Install Missing Extensions</h3>
<p>On Debian/Ubuntu:</p>
<div class="code-block">
<button class="copy-btn" onclick="copyCodeBlock(this)">Copy</button>
<pre>apt-get install <?php
foreach ( $missingRequired as $ext ) {
echo "php-$ext " ;
}
?></pre>
</div>
<p>On RHEL/CentOS/Fedora:</p>
<div class="code-block">
<button class="copy-btn" onclick="copyCodeBlock(this)">Copy</button>
<pre>dnf install <?php
foreach ( $missingRequired as $ext ) {
echo "php-$ext " ;
}
?></pre>
</div>
<p>Then restart your web server:</p>
<div class="code-block">
<button class="copy-btn" onclick="copyCodeBlock(this)">Copy</button>
<pre># Apache
systemctl restart apache2 # Debian/Ubuntu
systemctl restart httpd # RHEL/CentOS/Fedora
# nginx + php-fpm
systemctl restart php-fpm
systemctl restart nginx</pre>
</div>
</div>
<?php endif ; ?>
<?php if ( !empty( $missingOptional ) ) : ?>
<div class="summary-box warning">
<p><?php echo $warnIcon ; ?> <strong>Missing optional PHP extensions:</strong>
<code><?php echo htmlspecialchars( implode( ', ', $missingOptional ) ) ; ?></code></p>
<ul>
<?php foreach ( $missingOptional as $ext ) : ?>
<li><code><?php echo $ext ; ?></code> - <?php echo htmlspecialchars( $requiredExtensions[$ext]['purpose'] ) ; ?></li>
<?php endforeach ; ?>
</ul>
</div>
<?php endif ; ?>
<?php else : ?>
<!-- All PHP requirements met, show brief confirmation -->
<?php endif ; ?>
<?php
// ============================================================================
// SECTION 1: Configuration File Check
// ============================================================================
?>
<h2>1. Configuration File</h2>
<?php if ( !file_exists( $configFile ) ) : ?>
<?php $criticalErrors++ ; ?>
<div class="summary-box error">
<p><?php echo $failIcon ; ?> <strong>Configuration file not found!</strong></p>
<p>Expected location: <code><?php echo htmlspecialchars( $configFile ) ; ?></code></p>
</div>
<div class="fix-section">
<h3>How to Fix</h3>
<p>Copy the sample configuration file and edit it:</p>
<div class="code-block">
<button class="copy-btn" onclick="copyCodeBlock(this)">Copy</button>
<pre>cp <?php echo htmlspecialchars( basename( $sampleFile ) ) ; ?> <?php echo htmlspecialchars( basename( $configFile ) ) ; ?>
# Then edit <?php echo htmlspecialchars( basename( $configFile ) ) ; ?> with your settings</pre>
</div>
</div>
<?php elseif ( !is_readable( $configFile ) ) : ?>
<?php $criticalErrors++ ; ?>
<div class="summary-box error">
<p><?php echo $failIcon ; ?> <strong>Configuration file is not readable!</strong></p>
<p>File exists but PHP cannot read it: <code><?php echo htmlspecialchars( $configFile ) ; ?></code></p>
</div>
<div class="fix-section">
<h3>How to Fix</h3>
<p>Check file permissions:</p>
<div class="code-block">
<button class="copy-btn" onclick="copyCodeBlock(this)">Copy</button>
<pre>chmod 640 <?php echo htmlspecialchars( basename( $configFile ) ) ; ?>
chown www-data:www-data <?php echo htmlspecialchars( basename( $configFile ) ) ; ?></pre>
</div>
</div>
<?php elseif ( !$configLoaded ) : ?>
<?php $criticalErrors++ ; ?>
<div class="summary-box error">
<p><?php echo $failIcon ; ?> <strong>Configuration file has invalid XML!</strong></p>
</div>
<div class="fix-section">
<h3>How to Fix</h3>
<p>Check for XML syntax errors. Common issues:</p>
<ul>
<li>Unescaped special characters in values (use <code>&amp;</code> for &, <code>&lt;</code> for <)</li>
<li>Missing closing tags</li>
<li>Invalid characters</li>
</ul>
<p>Validate your XML:</p>
<div class="code-block">
<button class="copy-btn" onclick="copyCodeBlock(this)">Copy</button>
<pre>xmllint --noout <?php echo htmlspecialchars( basename( $configFile ) ) ; ?></pre>
</div>
</div>
<?php else : ?>
<div class="summary-box success">
<p><?php echo $passIcon ; ?> Configuration file loaded successfully</p>
<p>Location: <code><?php echo htmlspecialchars( $configFile ) ; ?></code></p>
</div>
<?php endif ; ?>
<?php if ( $configLoaded ) : ?>
<?php
// ============================================================================
// SECTION 2: Required Parameters
// ============================================================================
?>
<h2>2. Required Parameters</h2>
<p>These parameters must be configured for AQL to function.</p>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Current Value</th>
<th>Status</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
$missingRequired = [] ;
foreach ( $allParams as $name => $info ) :
if ( !$info['required'] ) continue ;
$value = $configValues[$name] ?? '' ;
$displayValue = ( $info['sensitive'] ?? false ) ? ( empty( $value ) ? '(not set)' : '********' ) : $value ;
if ( empty( $displayValue ) ) $displayValue = '(not set)' ;
list( $valid, $validMsg ) = validateParam( $value, $info['validate'] ) ;
if ( empty( $value ) || !$valid ) {
$criticalErrors++ ;
$missingRequired[$name] = $info ;
$statusIcon = $failIcon ;
$statusText = empty( $value ) ? 'Missing' : $validMsg ;
} else {
$statusIcon = $passIcon ;
$statusText = 'OK' ;
}
?>
<tr>
<td><code><?php echo htmlspecialchars( $name ) ; ?></code></td>
<td><code><?php echo htmlspecialchars( $displayValue ) ; ?></code></td>
<td><?php echo $statusIcon . ' ' . htmlspecialchars( $statusText ) ; ?></td>
<td><?php echo htmlspecialchars( $info['description'] ) ; ?></td>
</tr>
<?php endforeach ; ?>
</tbody>
</table>
<?php if ( !empty( $missingRequired ) ) : ?>
<div class="fix-section">
<h3>Missing Required Parameters</h3>
<p>Add these to your <code>aql_config.xml</code>:</p>
<pre><?php
foreach ( $missingRequired as $name => $info ) {
echo '<param name="' . htmlspecialchars( $name ) . '">' . htmlspecialchars( $info['example'] ) . '</param>' . "\n" ;
}
?></pre>
</div>
<?php endif ; ?>
<?php
// ============================================================================
// SECTION 3: Optional Parameters
// ============================================================================
?>
<h2>3. Optional Parameters</h2>
<p>These parameters have sensible defaults but can be customized.</p>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Current Value</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $allParams as $name => $info ) :
if ( $info['required'] ) continue ;
if ( isset( $info['group'] ) ) continue ; // Skip grouped params, shown below
$value = $configValues[$name] ?? '' ;
$default = $info['default'] ?? '' ;
$displayValue = ( $info['sensitive'] ?? false ) ? ( empty( $value ) ? '(not set)' : '********' ) : $value ;
if ( empty( $displayValue ) ) $displayValue = '(using default)' ;
$statusIcon = !empty( $value ) ? $passIcon : $infoIcon ;
?>
<tr>
<td><code><?php echo htmlspecialchars( $name ) ; ?></code></td>
<td><code><?php echo htmlspecialchars( $displayValue ) ; ?></code></td>
<td><code><?php echo htmlspecialchars( $default ) ; ?></code></td>
<td><?php echo htmlspecialchars( $info['description'] ) ; ?></td>
</tr>
<?php endforeach ; ?>
</tbody>
</table>
<?php
// ============================================================================
// SECTION 4: Feature Groups (LDAP, Jira, Test Harness)
// ============================================================================
?>
<h2>4. Feature Configuration</h2>
<?php
// LDAP Configuration
$ldapEnabled = isFeatureEnabled( 'doLDAPAuthentication', $configValues ) ;
?>
<div class="param-group">
<h3>LDAP/Active Directory Authentication</h3>
<p>Status: <?php echo $ldapEnabled ? "$passIcon <strong>Enabled</strong>" : "$infoIcon Disabled" ; ?></p>
<?php if ( $ldapEnabled ) : ?>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $allParams as $name => $info ) :
if ( ( $info['group'] ?? '' ) !== 'ldap' ) continue ;
if ( $name === 'doLDAPAuthentication' ) continue ;
$value = $configValues[$name] ?? '' ;
$isConditional = isset( $info['conditionalOn'] ) ;
if ( $isConditional && empty( $value ) ) {
$warnings++ ;
$statusIcon = $warnIcon ;
$statusText = 'Required when LDAP enabled' ;
} elseif ( !empty( $value ) ) {
$statusIcon = $passIcon ;
$statusText = 'OK' ;
} else {
$statusIcon = $infoIcon ;
$statusText = 'Using default' ;
}
?>
<tr>
<td><code><?php echo htmlspecialchars( $name ) ; ?></code></td>
<td><code><?php echo htmlspecialchars( $value ?: '(not set)' ) ; ?></code></td>
<td><?php echo $statusIcon . ' ' . $statusText ; ?></td>
</tr>
<?php endforeach ; ?>
</tbody>
</table>
<?php else : ?>
<p><em>Set <code>doLDAPAuthentication</code> to <code>true</code> to enable LDAP authentication.</em></p>
<?php endif ; ?>
</div>
<?php
// Jira Configuration
$jiraEnabled = isFeatureEnabled( 'jiraEnabled', $configValues ) ;
?>
<div class="param-group">
<h3>Jira Integration</h3>
<p>Status: <?php echo $jiraEnabled ? "$passIcon <strong>Enabled</strong>" : "$infoIcon Disabled" ; ?></p>
<?php if ( $jiraEnabled ) : ?>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $allParams as $name => $info ) :
if ( ( $info['group'] ?? '' ) !== 'jira' ) continue ;
if ( $name === 'jiraEnabled' ) continue ;
$value = $configValues[$name] ?? '' ;
$isConditional = isset( $info['conditionalOn'] ) ;
if ( $isConditional && empty( $value ) ) {
$warnings++ ;
$statusIcon = $warnIcon ;
$statusText = 'Required when Jira enabled' ;
} elseif ( !empty( $value ) ) {
$statusIcon = $passIcon ;
$statusText = 'OK' ;
} else {
$statusIcon = $infoIcon ;
$statusText = 'Optional' ;
}
?>
<tr>
<td><code><?php echo htmlspecialchars( $name ) ; ?></code></td>
<td><code><?php echo htmlspecialchars( $value ?: '(not set)' ) ; ?></code></td>
<td><?php echo $statusIcon . ' ' . $statusText ; ?></td>
</tr>
<?php endforeach ; ?>
</tbody>
</table>
<?php else : ?>
<p><em>Set <code>jiraEnabled</code> to <code>true</code> to enable the "File Issue" button.</em></p>
<?php endif ; ?>
</div>
<?php
// Test Harness Configuration
$testConfigured = !empty( $configValues['testDbUser'] ?? '' ) && !empty( $configValues['testDbPass'] ?? '' ) ;
?>
<div class="param-group">
<h3>Test Harness</h3>
<p>Status: <?php echo $testConfigured ? "$passIcon <strong>Configured</strong>" : "$infoIcon Not configured" ; ?></p>
<?php if ( $testConfigured ) : ?>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $allParams as $name => $info ) :
if ( ( $info['group'] ?? '' ) !== 'test' ) continue ;
$value = $configValues[$name] ?? '' ;
$displayValue = ( $info['sensitive'] ?? false ) ? ( empty( $value ) ? '(not set)' : '********' ) : $value ;
$statusIcon = !empty( $value ) ? $passIcon : $warnIcon ;
?>
<tr>
<td><code><?php echo htmlspecialchars( $name ) ; ?></code></td>
<td><code><?php echo htmlspecialchars( $displayValue ?: '(not set)' ) ; ?></code></td>
<td><?php echo $statusIcon ; ?></td>
</tr>
<?php endforeach ; ?>
</tbody>
</table>
<?php else : ?>
<p><em>Configure <code>testDbUser</code>, <code>testDbPass</code>, and <code>testDbName</code> to use the <a href="testAQL.php">Test Harness</a>.</em></p>
<?php endif ; ?>
</div>
<?php
// Redis Configuration
$redisEnabled = isFeatureEnabled( 'redisEnabled', $configValues ) ;
?>
<div class="param-group">
<h3>Redis Monitoring</h3>
<p>Status: <?php echo $redisEnabled ? "$passIcon <strong>Enabled</strong>" : "$infoIcon Disabled" ; ?></p>
<?php if ( $redisEnabled ) : ?>
<?php if ( !extension_loaded( 'redis' ) ) : ?>
<div class="summary-box error">
<p><?php echo $failIcon ; ?> <strong>PHP Redis extension not installed</strong></p>
<p>Redis monitoring is enabled but the phpredis extension is not available.</p>
</div>
<div class="fix-section">
<h3>Install phpredis</h3>
<p>On Debian/Ubuntu:</p>
<div class="code-block">
<button class="copy-btn" onclick="copyCodeBlock(this)">Copy</button>
<pre>apt-get install php-redis
systemctl restart apache2</pre>
</div>
<p>On RHEL/CentOS/Fedora:</p>
<div class="code-block">
<button class="copy-btn" onclick="copyCodeBlock(this)">Copy</button>
<pre>dnf install php-redis
systemctl restart httpd</pre>
</div>
</div>
<?php else : ?>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $allParams as $name => $info ) :
if ( ( $info['group'] ?? '' ) !== 'redis' ) continue ;
if ( $name === 'redisEnabled' ) continue ;
$value = $configValues[$name] ?? '' ;
$displayValue = ( $info['sensitive'] ?? false ) ? ( empty( $value ) ? '(not set)' : '********' ) : $value ;
$isConditional = isset( $info['conditionalOn'] ) ;
if ( !empty( $value ) ) {
$statusIcon = $passIcon ;
$statusText = 'OK' ;
} elseif ( isset( $info['default'] ) ) {
$statusIcon = $infoIcon ;
$statusText = 'Using default' ;
} else {
$statusIcon = $infoIcon ;
$statusText = 'Optional' ;
}
?>
<tr>
<td><code><?php echo htmlspecialchars( $name ) ; ?></code></td>
<td><code><?php echo htmlspecialchars( $displayValue ?: '(not set)' ) ; ?></code></td>
<td><?php echo $statusIcon . ' ' . $statusText ; ?></td>
</tr>
<?php endforeach ; ?>
</tbody>
</table>
<?php endif ; ?>
<?php else : ?>
<p><em>Set <code>redisEnabled</code> to <code>true</code> to enable Redis monitoring.</em></p>
<?php endif ; ?>
</div>
<?php
// ============================================================================
// SECTION 5: Connectivity Tests
// ============================================================================
?>
<h2>5. Connectivity Tests</h2>
<?php
// Database connectivity test
$dbHost = $configValues['dbHost'] ?? '' ;
$dbPort = $configValues['dbPort'] ?? '3306' ;
$dbUser = $configValues['dbUser'] ?? '' ;
$dbPass = $configValues['dbPass'] ?? '' ;
$dbName = $configValues['dbName'] ?? '' ;
if ( !empty( $dbHost ) && !empty( $dbUser ) && !empty( $dbPass ) && !empty( $dbName ) ) :
?>
<div class="test-section">
<h3>Database Connection</h3>
<?php
$dbConnected = false ;
$dbError = '' ;
// Track privileges found
$privileges = [
'PROCESS' => false,
'REPLICATION CLIENT' => false,
'SUPER' => false,
'ALL PRIVILEGES' => false,
'perf_schema_select' => false
] ;
$grantStatements = [] ;
$actualUserHost = '' ; // Will store 'user'@'host' from GRANT output
try {
$mysqli = @new \mysqli( $dbHost, $dbUser, $dbPass, $dbName, $dbPort ) ;
if ( $mysqli->connect_error ) {
throw new \Exception( $mysqli->connect_error ) ;
}
$dbConnected = true ;
// Get the actual user@host we connected as
$result = @$mysqli->query( "SELECT CURRENT_USER()" ) ;
if ( $result && $row = $result->fetch_row() ) {
$actualUserHost = $row[0] ; // Returns 'user@host' format
$result->free() ;
}
// Get actual grants using SHOW GRANTS
$result = @$mysqli->query( "SHOW GRANTS" ) ;
if ( $result ) {
while ( $row = $result->fetch_row() ) {
$grant = $row[0] ;
$grantStatements[] = $grant ;
// Check for global privileges
if ( preg_match( '/GRANT\s+(.+?)\s+ON\s+\*\.\*/i', $grant, $matches ) ) {
$privList = strtoupper( $matches[1] ) ;
if ( strpos( $privList, 'ALL PRIVILEGES' ) !== false ) {
$privileges['ALL PRIVILEGES'] = true ;
$privileges['PROCESS'] = true ;
$privileges['REPLICATION CLIENT'] = true ;
$privileges['SUPER'] = true ;
}
if ( strpos( $privList, 'PROCESS' ) !== false ) {
$privileges['PROCESS'] = true ;
}
if ( strpos( $privList, 'REPLICATION CLIENT' ) !== false ) {
$privileges['REPLICATION CLIENT'] = true ;
}
if ( strpos( $privList, 'SUPER' ) !== false ) {
$privileges['SUPER'] = true ;
}
}
// Check for performance_schema access
if ( preg_match( '/GRANT\s+(.+?)\s+ON\s+[`"]?performance_schema[`"]?\.\*/i', $grant, $matches ) ) {
$privList = strtoupper( $matches[1] ) ;
if ( strpos( $privList, 'SELECT' ) !== false || strpos( $privList, 'ALL' ) !== false ) {
$privileges['perf_schema_select'] = true ;
}
}
}
$result->free() ;
}
$mysqli->close() ;
} catch ( \Exception $e ) {
$dbError = $e->getMessage() ;
}
// Fallback if we couldn't get user@host
if ( empty( $actualUserHost ) ) {
$actualUserHost = $dbUser . '@localhost' ;
}
// Parse user and host for warnings
$userParts = explode( '@', $actualUserHost ) ;
$actualUser = $userParts[0] ?? $dbUser ;
$actualHostMask = $userParts[1] ?? 'localhost' ;
$isRootUser = ( strtolower( $actualUser ) === 'root' ) ;
if ( $dbConnected ) :
// Determine status for each privilege
$processOk = $privileges['PROCESS'] || $privileges['ALL PRIVILEGES'] ;
$replOk = $privileges['REPLICATION CLIENT'] || $privileges['ALL PRIVILEGES'] ;
$perfSchemaOk = $privileges['perf_schema_select'] || $privileges['ALL PRIVILEGES'] ;
$hasSuper = $privileges['SUPER'] || $privileges['ALL PRIVILEGES'] ;
?>
<p><?php echo $passIcon ; ?> Connected to <code><?php echo htmlspecialchars( "$dbHost:$dbPort" ) ; ?></code></p>
<p><?php echo $passIcon ; ?> Database <code><?php echo htmlspecialchars( $dbName ) ; ?></code> accessible</p>
<p><?php echo $passIcon ; ?> Connected as <code><?php echo htmlspecialchars( $actualUserHost ) ; ?></code></p>
<?php if ( $isRootUser ) : ?>
<div class="summary-box error">
<p><?php echo $failIcon ; ?> <strong>Security Warning: Using 'root' user</strong></p>
<p>Do not use the MySQL root account for applications. Create a dedicated user with only the privileges AQL needs.</p>
</div>
<?php endif ; ?>