Code Duplication    Length = 11-14 lines in 4 locations

class/Utility.php 3 locations

@@ 350-363 (lines=14) @@
347
    $catids        = implode(',', $allowed_cats);
348
    $catperms      = " AND categoryID IN ($catids) ";
349
    $alpha         = [];
350
    for ($a = 48; $a < (48 + 10); ++$a) {
351
        $letterlinks             = []; 
352
        $initial                 = uchr($a);
353
        $sql                     = $xoopsDB->query('SELECT entryID FROM '
354
                                                       . $xoopsDB->prefix('lxentries')
355
                                                       . " WHERE init = '$initial' AND submit = '0' AND offline ='0' AND request = '0' "
356
                                                       . $catperms
357
                                                       . '');
358
        $howmany                 = $xoopsDB->getRowsNum($sql);
359
        $letterlinks['total']    = $howmany;
360
        $letterlinks['id']       = uchr($a);
361
        $letterlinks['linktext'] = uchr($a);
362
        $alpha['initial'][] = $letterlinks;
363
    }
364
    for ($a = 65; $a < (65 + 26); ++$a) {
365
        $letterlinks             = []; 
366
        $initial                 = uchr($a);
@@ 364-377 (lines=14) @@
361
        $letterlinks['linktext'] = uchr($a);
362
        $alpha['initial'][] = $letterlinks;
363
    }
364
    for ($a = 65; $a < (65 + 26); ++$a) {
365
        $letterlinks             = []; 
366
        $initial                 = uchr($a);
367
        $sql                     = $xoopsDB->query('SELECT entryID FROM '
368
                                                       . $xoopsDB->prefix('lxentries')
369
                                                       . " WHERE init = '$initial' AND submit = '0' AND offline ='0' AND request = '0' "
370
                                                       . $catperms
371
                                                       . '');
372
        $howmany                 = $xoopsDB->getRowsNum($sql);
373
        $letterlinks['total']    = $howmany;
374
        $letterlinks['id']       = uchr($a);
375
        $letterlinks['linktext'] = uchr($a);
376
        $alpha['initial'][] = $letterlinks;
377
    }
378
    /* help code https://unicode-table.com/en/#control-character */ 
379
    for ($a = 1040; $a < (1040 + 32); ++$a) {
380
        $letterlinks             = [];
@@ 379-392 (lines=14) @@
376
        $alpha['initial'][] = $letterlinks;
377
    }
378
    /* help code https://unicode-table.com/en/#control-character */ 
379
    for ($a = 1040; $a < (1040 + 32); ++$a) {
380
        $letterlinks             = [];
381
        $initial                 = uchr($a);
382
        $sql                     = $xoopsDB->query('SELECT entryID FROM '
383
                                                       . $xoopsDB->prefix('lxentries')
384
                                                       . " WHERE init = '$initial' AND submit = '0' AND offline ='0' AND request = '0' "
385
                                                       . $catperms
386
                                                       . '');
387
        $howmany                 = $xoopsDB->getRowsNum($sql);
388
        $letterlinks['total']    = $howmany;
389
        $letterlinks['id']       = uchr($a);
390
        $letterlinks['linktext'] = uchr($a);
391
        $alpha['initial'][] = $letterlinks;
392
    }   
393
    
394
    return $alpha;
395
}

include/functions.php 1 location

@@ 167-177 (lines=11) @@
164
    $catids = implode(',', $allowed_cats);
165
      $catperms = " AND categoryID IN ($catids) ";
166
    $alpha = [];
167
    for ($a = 65; $a < (65+26); $a++ ) {
168
        $letterlinks = [];
169
        $initial = chr($a);
170
        $sql = $xoopsDB -> query ( "SELECT entryID FROM " . $xoopsDB -> prefix ( "lxentries") . " WHERE init = '$initial' AND submit = '0' AND offline ='0' AND request = '0' ".$catperms."");
171
        $howmany = $xoopsDB -> getRowsNum( $sql );
172
        $letterlinks['total'] = $howmany;
173
        $letterlinks['id'] = chr($a);
174
        $letterlinks['linktext'] = chr($a);
175
176
        $alpha['initial'][] = $letterlinks;
177
    }
178
179
    return $alpha;
180
}