55use function Tables \TablesDir \open_td_Tables_file ;
66
77// Get request parameters with defaults
8- $ site = $ _GET ["site " ] ?? "all " ;
9- $ heads_limit = $ _GET ["heads_limit " ] ?? 50 ;
10- $ title_limit = $ _GET ["title_limit " ] ?? 150 ;
8+ $ site = htmlspecialchars ($ _GET ['site ' ] ?? 'all ' , ENT_QUOTES , 'UTF-8 ' );
9+ $ heads_limit = filter_input (INPUT_GET , 'heads_limit ' , FILTER_VALIDATE_INT , [
10+ 'options ' => ['default ' => 50 , 'min_range ' => 1 , 'max_range ' => 1000 ]
11+ ]);
12+
13+ $ title_limit = filter_input (INPUT_GET , 'title_limit ' , FILTER_VALIDATE_INT , [
14+ 'options ' => ['default ' => 150 , 'min_range ' => 10 , 'max_range ' => 1000 ]
15+ ]);
16+
1117$ items_with_no_links = isset ($ _GET ["items_with_no_links " ]) ? "checked " : "" ;
1218
1319// Generate form inputs
@@ -65,7 +71,7 @@ function generateFormInputs(array $params, string $items_with_no_links): string
6571$ qids_all = $ data2 ['qids ' ] ?? [];
6672
6773// Sort QIDs by sitelinks count
68- uasort ($ qids_all , fn ($ a , $ b ) => count ($ b ['sitelinks ' ]) <=> count ($ a ['sitelinks ' ]));
74+ uasort ($ qids_all , fn ($ a , $ b ) => count ($ b ['sitelinks ' ]) <=> count ($ a ['sitelinks ' ]));
6975
7076test_print ("$ file2: qids_all: " . count ($ qids_all ));
7177test_print ("$ file2: heads_all: " . count ($ heads_all ));
@@ -82,11 +88,11 @@ function generateFormInputs(array $params, string $items_with_no_links): string
8288// Filter QIDs based on user selection
8389if ($ items_with_no_links ) {
8490 $ heads = [];
85- $ qids_o = array_filter ($ qids_all , fn ($ tab ) => count ($ tab ['sitelinks ' ]) == 0 );
91+ $ qids_o = array_filter ($ qids_all , fn ($ tab ) => count ($ tab ['sitelinks ' ]) == 0 );
8692} elseif (!empty ($ site ) && $ site != "all " ) {
8793 $ notitle = false ;
8894 $ heads = [$ site ];
89- $ len_items_with_site = count (array_filter ($ qids_all , fn ($ tab ) => $ tab ['sitelinks ' ][$ site ] ?? false ));
95+ $ len_items_with_site = count (array_filter ($ qids_all , fn ($ tab ) => $ tab ['sitelinks ' ][$ site ] ?? false ));
9096 $ no_site_link = $ len_qids_all - $ len_items_with_site ;
9197 $ with_site_note = " (with site: $ len_items_with_site, no site link: $ no_site_link) " ;
9298}
0 commit comments