Completed
Push — master ( 7bb5bf...9a4e50 )
by Richard
28:24 queued 22s
created

htdocs/class/xoopslists.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * XOOPS listing utilities
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
13
 * @license             GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
14
 * @package             kernel
15
 * @since               2.0.0
16
 */
17
18
defined('XOOPS_ROOT_PATH') || exit('Restricted access');
19
20
if (!defined('XOOPS_LISTS_INCLUDED')) {
21
    define('XOOPS_LISTS_INCLUDED', 1);
22
23
    /**
24
     * XoopsLists
25
     *
26
     * @author              John Neill <[email protected]>
27
     * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
28
     * @package             kernel
29
     * @subpackage          form
30
     * @access              public
31
     */
32
    class XoopsLists
33
    {
34
        /**
35
         * @return array
36
         */
37
        public static function getTimeZoneList()
38
        {
39
            xoops_loadLanguage('timezone');
40
41
            $time_zone_list = array(
42
                '-12'  => _TZ_GMTM12,
43
                '-11'  => _TZ_GMTM11,
44
                '-10'  => _TZ_GMTM10,
45
                '-9'   => _TZ_GMTM9,
46
                '-8'   => _TZ_GMTM8,
47
                '-7'   => _TZ_GMTM7,
48
                '-6'   => _TZ_GMTM6,
49
                '-5'   => _TZ_GMTM5,
50
                '-4'   => _TZ_GMTM4,
51
                '-3.5' => _TZ_GMTM35,
52
                '-3'   => _TZ_GMTM3,
53
                '-2'   => _TZ_GMTM2,
54
                '-1'   => _TZ_GMTM1,
55
                '0'    => _TZ_GMT0,
56
                '1'    => _TZ_GMTP1,
57
                '2'    => _TZ_GMTP2,
58
                '3'    => _TZ_GMTP3,
59
                '3.5'  => _TZ_GMTP35,
60
                '4'    => _TZ_GMTP4,
61
                '4.5'  => _TZ_GMTP45,
62
                '5'    => _TZ_GMTP5,
63
                '5.5'  => _TZ_GMTP55,
64
                '6'    => _TZ_GMTP6,
65
                '7'    => _TZ_GMTP7,
66
                '8'    => _TZ_GMTP8,
67
                '9'    => _TZ_GMTP9,
68
                '9.5'  => _TZ_GMTP95,
69
                '10'   => _TZ_GMTP10,
70
                '11'   => _TZ_GMTP11,
71
                '12'   => _TZ_GMTP12);
72
73
            return $time_zone_list;
74
        }
75
76
        /**
77
         * gets list of themes folder from themes directory
78
         */
79
        public static function getThemesList()
80
        {
81
            return XoopsLists::getDirListAsArray(XOOPS_THEME_PATH . '/');
82
        }
83
84
        /**
85
         * gets a list of module folders from the modules directory
86
         */
87
        public static function getModulesList()
88
        {
89
            return XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/modules/');
90
        }
91
92
        /**
93
         * gets list of editors folder from xoopseditor directory
94
         */
95
        public static function getEditorList()
96
        {
97
            return XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/class/xoopseditor/');
98
        }
99
100
        /**
101
         * gets list of name of directories inside a directory
102
         * @param $dirname
103
         * @return array
104
         */
105
        public static function getDirListAsArray($dirname)
106
        {
107
            $ignored = array(
108
                'cvs',
109
                '_darcs');
110
            $list    = array();
111
            if (substr($dirname, -1) !== '/') {
112
                $dirname .= '/';
113
            }
114
            if ($handle = opendir($dirname)) {
115
                while ($file = readdir($handle)) {
116
                    if (substr($file, 0, 1) === '.' || in_array(strtolower($file), $ignored)) {
117
                        continue;
118
                    }
119
                    if (is_dir($dirname . $file)) {
120
                        $list[$file] = $file;
121
                    }
122
                }
123
                closedir($handle);
124
                asort($list);
125
                reset($list);
126
            }
127
128
            return $list;
129
        }
130
131
        /**
132
         * gets list of all files in a directory
133
         * @param        $dirname
134
         * @param string $prefix
135
         * @return array
136
         */
137
        public static function getFileListAsArray($dirname, $prefix = '')
138
        {
139
            $filelist = array();
140
            if (substr($dirname, -1) === '/') {
141
                $dirname = substr($dirname, 0, -1);
142
            }
143
            if (is_dir($dirname) && $handle = opendir($dirname)) {
144
                while (false !== ($file = readdir($handle))) {
145
                    if (!preg_match('/^[\.]{1,2}$/', $file) && is_file($dirname . '/' . $file)) {
146
                        $file            = $prefix . $file;
147
                        $filelist[$file] = $file;
148
                    }
149
                }
150
                closedir($handle);
151
                asort($filelist);
152
                reset($filelist);
153
            }
154
155
            return $filelist;
156
        }
157
158
        /**
159
         * get list of files in a directory matching a list of extensions
160
         *
161
         * @param string   $dirname    file system directory to process
162
         * @param string[] $extensions list of extensions to select
163
         * @param string   $prefix     prefix sny matching files returned with this string
164
         *
165
         * @return string[]
166
         */
167
        public static function getFileListByExtension($dirname, $extensions, $prefix = '')
168
        {
169
            $filelist = array();
170
171
            $extToLower = function($ext) {
172
                return strtolower($ext);
173
            };
174
175
            $extensionList = array_map($extToLower, $extensions);
176
177
            if ($handle = opendir($dirname)) {
178
                while (false !== ($file = readdir($handle))) {
179
                    $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
180
                    if (in_array(strtolower($ext), $extensionList)) {
181
                        $file            = $prefix . $file;
182
                        $filelist[$file] = $file;
183
                    }
184
                }
185
                closedir($handle);
186
                asort($filelist);
187
                reset($filelist);
188
            }
189
190
            return $filelist;
191
        }
192
193
        /**
194
         * Get a list of image file names in a directory.
195
         * This selects only the most common file extensions for web use,
196
         * gif, jpeg/jpg, and png
197
         *
198
         * @param string $dirname file system directory to process
199
         * @param string $prefix  prefix sny matching files returned with this string
200
         *
201
         * @return string[]
202
         */
203
        public static function getImgListAsArray($dirname, $prefix = '')
204
        {
205
            $extensions = array('gif','jpeg','jpg','png');
206
            return static::getFileListByExtension($dirname, $extensions, $prefix);
207
        }
208
209
        /**
210
         * gets list of html file names in a certain directory
211
         * @param        $dirname
212
         * @param string $prefix
213
         * @return array
214
         */
215
        public static function getHtmlListAsArray($dirname, $prefix = '')
216
        {
217
            $filelist = array();
218
            if ($handle = opendir($dirname)) {
219
                while (false !== ($file = readdir($handle))) {
220
                    if (preg_match('/(\.htm|\.html|\.xhtml|\.tpl)$/i', $file) && !is_dir($file)) {
221
                        $file            = $prefix . $file;
222
                        $filelist[$file] = $prefix . $file;
223
                    }
224
                }
225
                closedir($handle);
226
                asort($filelist);
227
                reset($filelist);
228
            }
229
230
            return $filelist;
231
        }
232
233
        /**
234
         * gets list of avatar file names in a certain directory
235
         *                             if directory is not specified, default directory will be searched
236
         * @param string $avatar_dir
237
         * @return array
238
         */
239
        public static function getAvatarsList($avatar_dir = '')
240
        {
241
            $avatars = array();
242
            if ($avatar_dir != '') {
243
                $avatars = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/avatar/' . $avatar_dir . '/', $avatar_dir . '/');
244
            } else {
245
                $avatars = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/avatar/');
246
            }
247
248
            return $avatars;
249
        }
250
251
        /**
252
         * gets list of all avatar image files inside default avatars directory
253
         */
254
        public static function getAllAvatarsList()
255
        {
256
            $avatars = array();
257
            $dirlist = array();
258
            $dirlist = XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/images/avatar/');
259
            if (count($dirlist) > 0) {
260
                foreach ($dirlist as $dir) {
261
                    $avatars[$dir] = &XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/avatar/' . $dir . '/', $dir . '/');
262
                }
263
            } else {
264
                return false;
265
            }
266
267
            return $avatars;
268
        }
269
270
        /**
271
         * gets list of subject icon image file names in a certain directory
272
         *                             if directory is not specified, default directory will be searched
273
         * @param string $sub_dir
274
         * @return array
275
         */
276
        public static function getSubjectsList($sub_dir = '')
277
        {
278
            $subjects = array();
279
            if ($sub_dir != '') {
280
                $subjects = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/subject/' . $sub_dir, $sub_dir . '/');
281
            } else {
282
                $subjects = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/subject/');
283
            }
284
285
            return $subjects;
286
        }
287
288
        /**
289
         * gets list of language folders inside default language directory
290
         */
291
        public static function getLangList()
292
        {
293
            $lang_list = array();
294
            $lang_list = XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/language/');
295
296
            return $lang_list;
297
        }
298
299
        /**
300
         * XoopsLists::getCountryList()
301
         *
302
         * @return array
303
         */
304
        public static function getCountryList()
305
        {
306
            xoops_loadLanguage('countries');
307
            $country_list = array(
308
                '' => '-',
309
                'AD' => _COUNTRY_AD,
310
                'AE' => _COUNTRY_AE,
311
                'AF' => _COUNTRY_AF,
312
                'AG' => _COUNTRY_AG,
313
                'AI' => _COUNTRY_AI,
314
                'AL' => _COUNTRY_AL,
315
                'AM' => _COUNTRY_AM,
316
                'AN' => _COUNTRY_AN,
317
                'AO' => _COUNTRY_AO,
318
                'AQ' => _COUNTRY_AQ,
319
                'AR' => _COUNTRY_AR,
320
                'AS' => _COUNTRY_AS,
321
                'AT' => _COUNTRY_AT,
322
                'AU' => _COUNTRY_AU,
323
                'AW' => _COUNTRY_AW,
324
                'AX' => _COUNTRY_AX,
325
                'AZ' => _COUNTRY_AZ,
326
                'BA' => _COUNTRY_BA,
327
                'BB' => _COUNTRY_BB,
328
                'BD' => _COUNTRY_BD,
329
                'BE' => _COUNTRY_BE,
330
                'BF' => _COUNTRY_BF,
331
                'BG' => _COUNTRY_BG,
332
                'BH' => _COUNTRY_BH,
333
                'BI' => _COUNTRY_BI,
334
                'BJ' => _COUNTRY_BJ,
335
                'BL' => _COUNTRY_BL,
336
                'BM' => _COUNTRY_BM,
337
                'BN' => _COUNTRY_BN,
338
                'BO' => _COUNTRY_BO,
339
                'BR' => _COUNTRY_BR,
340
                'BS' => _COUNTRY_BS,
341
                'BT' => _COUNTRY_BT,
342
                'BV' => _COUNTRY_BV,
343
                'BW' => _COUNTRY_BW,
344
                'BY' => _COUNTRY_BY,
345
                'BZ' => _COUNTRY_BZ,
346
                'CA' => _COUNTRY_CA,
347
                'CC' => _COUNTRY_CC,
348
                'CD' => _COUNTRY_CD,
349
                'CF' => _COUNTRY_CF,
350
                'CG' => _COUNTRY_CG,
351
                'CH' => _COUNTRY_CH,
352
                'CI' => _COUNTRY_CI,
353
                'CK' => _COUNTRY_CK,
354
                'CL' => _COUNTRY_CL,
355
                'CM' => _COUNTRY_CM,
356
                'CN' => _COUNTRY_CN,
357
                'CO' => _COUNTRY_CO,
358
                'CR' => _COUNTRY_CR,
359
                'CS' => _COUNTRY_CS,    //  Not listed in ISO 3166, former Serbia & Montenegro
360
                'CU' => _COUNTRY_CU,
361
                'CV' => _COUNTRY_CV,
362
                'CX' => _COUNTRY_CX,
363
                'CY' => _COUNTRY_CY,
364
                'CZ' => _COUNTRY_CZ,
365
                'DE' => _COUNTRY_DE,
366
                'DJ' => _COUNTRY_DJ,
367
                'DK' => _COUNTRY_DK,
368
                'DM' => _COUNTRY_DM,
369
                'DO' => _COUNTRY_DO,
370
                'DZ' => _COUNTRY_DZ,
371
                'EC' => _COUNTRY_EC,
372
                'EE' => _COUNTRY_EE,
373
                'EG' => _COUNTRY_EG,
374
                'EH' => _COUNTRY_EH,
375
                'ER' => _COUNTRY_ER,
376
                'ES' => _COUNTRY_ES,
377
                'ET' => _COUNTRY_ET,
378
                'FI' => _COUNTRY_FI,
379
                'FJ' => _COUNTRY_FJ,
380
                'FK' => _COUNTRY_FK,
381
                'FM' => _COUNTRY_FM,
382
                'FO' => _COUNTRY_FO,
383
                'FR' => _COUNTRY_FR,
384
                'FX' => _COUNTRY_FX,    //  Not listed in ISO 3166
385
                'GA' => _COUNTRY_GA,
386
                'GB' => _COUNTRY_GB,
387
                'GD' => _COUNTRY_GD,
388
                'GE' => _COUNTRY_GE,
389
                'GF' => _COUNTRY_GF,
390
                'GG' => _COUNTRY_GG,
391
                'GH' => _COUNTRY_GH,
392
                'GI' => _COUNTRY_GI,
393
                'GL' => _COUNTRY_GL,
394
                'GM' => _COUNTRY_GM,
395
                'GN' => _COUNTRY_GN,
396
                'GP' => _COUNTRY_GP,
397
                'GQ' => _COUNTRY_GQ,
398
                'GR' => _COUNTRY_GR,
399
                'GS' => _COUNTRY_GS,
400
                'GT' => _COUNTRY_GT,
401
                'GU' => _COUNTRY_GU,
402
                'GW' => _COUNTRY_GW,
403
                'GY' => _COUNTRY_GY,
404
                'HK' => _COUNTRY_HK,
405
                'HM' => _COUNTRY_HM,
406
                'HN' => _COUNTRY_HN,
407
                'HR' => _COUNTRY_HR,
408
                'HT' => _COUNTRY_HT,
409
                'HU' => _COUNTRY_HU,
410
                'ID' => _COUNTRY_ID,
411
                'IE' => _COUNTRY_IE,
412
                'IL' => _COUNTRY_IL,
413
                'IM' => _COUNTRY_IM,
414
                'IN' => _COUNTRY_IN,
415
                'IO' => _COUNTRY_IO,
416
                'IQ' => _COUNTRY_IQ,
417
                'IR' => _COUNTRY_IR,
418
                'IS' => _COUNTRY_IS,
419
                'IT' => _COUNTRY_IT,
420
                'JM' => _COUNTRY_JM,
421
                'JO' => _COUNTRY_JO,
422
                'JP' => _COUNTRY_JP,
423
                'KE' => _COUNTRY_KE,
424
                'KG' => _COUNTRY_KG,
425
                'KH' => _COUNTRY_KH,
426
                'KI' => _COUNTRY_KI,
427
                'KM' => _COUNTRY_KM,
428
                'KN' => _COUNTRY_KN,
429
                'KP' => _COUNTRY_KP,
430
                'KR' => _COUNTRY_KR,
431
                'KW' => _COUNTRY_KW,
432
                'KY' => _COUNTRY_KY,
433
                'KZ' => _COUNTRY_KZ,
434
                'LA' => _COUNTRY_LA,
435
                'LB' => _COUNTRY_LB,
436
                'LC' => _COUNTRY_LC,
437
                'LI' => _COUNTRY_LI,
438
                'LK' => _COUNTRY_LK,
439
                'LR' => _COUNTRY_LR,
440
                'LS' => _COUNTRY_LS,
441
                'LT' => _COUNTRY_LT,
442
                'LU' => _COUNTRY_LU,
443
                'LV' => _COUNTRY_LV,
444
                'LY' => _COUNTRY_LY,
445
                'MA' => _COUNTRY_MA,
446
                'MC' => _COUNTRY_MC,
447
                'MD' => _COUNTRY_MD,
448
                'ME' => _COUNTRY_ME,
449
                'MF' => _COUNTRY_MF,
450
                'MG' => _COUNTRY_MG,
451
                'MH' => _COUNTRY_MH,
452
                'MK' => _COUNTRY_MK,
453
                'ML' => _COUNTRY_ML,
454
                'MM' => _COUNTRY_MM,
455
                'MN' => _COUNTRY_MN,
456
                'MO' => _COUNTRY_MO,
457
                'MP' => _COUNTRY_MP,
458
                'MQ' => _COUNTRY_MQ,
459
                'MR' => _COUNTRY_MR,
460
                'MS' => _COUNTRY_MS,
461
                'MT' => _COUNTRY_MT,
462
                'MU' => _COUNTRY_MU,
463
                'MV' => _COUNTRY_MV,
464
                'MW' => _COUNTRY_MW,
465
                'MX' => _COUNTRY_MX,
466
                'MY' => _COUNTRY_MY,
467
                'MZ' => _COUNTRY_MZ,
468
                'NA' => _COUNTRY_NA,
469
                'NC' => _COUNTRY_NC,
470
                'NE' => _COUNTRY_NE,
471
                'NF' => _COUNTRY_NF,
472
                'NG' => _COUNTRY_NG,
473
                'NI' => _COUNTRY_NI,
474
                'NL' => _COUNTRY_NL,
475
                'NO' => _COUNTRY_NO,
476
                'NP' => _COUNTRY_NP,
477
                'NR' => _COUNTRY_NR,
478
                'NT' => _COUNTRY_NT,    //  Not listed in ISO 3166
479
                'NU' => _COUNTRY_NU,
480
                'NZ' => _COUNTRY_NZ,
481
                'OM' => _COUNTRY_OM,
482
                'PA' => _COUNTRY_PA,
483
                'PE' => _COUNTRY_PE,
484
                'PF' => _COUNTRY_PF,
485
                'PG' => _COUNTRY_PG,
486
                'PH' => _COUNTRY_PH,
487
                'PK' => _COUNTRY_PK,
488
                'PL' => _COUNTRY_PL,
489
                'PM' => _COUNTRY_PM,
490
                'PN' => _COUNTRY_PN,
491
                'PR' => _COUNTRY_PR,
492
                'PS' => _COUNTRY_PS,
493
                'PT' => _COUNTRY_PT,
494
                'PW' => _COUNTRY_PW,
495
                'PY' => _COUNTRY_PY,
496
                'QA' => _COUNTRY_QA,
497
                'RE' => _COUNTRY_RE,
498
                'RO' => _COUNTRY_RO,
499
                'RS' => _COUNTRY_RS,
500
                'RU' => _COUNTRY_RU,
501
                'RW' => _COUNTRY_RW,
502
                'SA' => _COUNTRY_SA,
503
                'SB' => _COUNTRY_SB,
504
                'SC' => _COUNTRY_SC,
505
                'SD' => _COUNTRY_SD,
506
                'SE' => _COUNTRY_SE,
507
                'SG' => _COUNTRY_SG,
508
                'SH' => _COUNTRY_SH,
509
                'SI' => _COUNTRY_SI,
510
                'SJ' => _COUNTRY_SJ,
511
                'SK' => _COUNTRY_SK,
512
                'SL' => _COUNTRY_SL,
513
                'SM' => _COUNTRY_SM,
514
                'SN' => _COUNTRY_SN,
515
                'SO' => _COUNTRY_SO,
516
                'SR' => _COUNTRY_SR,
517
                'ST' => _COUNTRY_ST,
518
                'SU' => _COUNTRY_SU,    //  Not listed in ISO 3166
519
                'SV' => _COUNTRY_SV,
520
                'SY' => _COUNTRY_SY,
521
                'SZ' => _COUNTRY_SZ,
522
                'TC' => _COUNTRY_TC,
523
                'TD' => _COUNTRY_TD,
524
                'TF' => _COUNTRY_TF,
525
                'TG' => _COUNTRY_TG,
526
                'TH' => _COUNTRY_TH,
527
                'TJ' => _COUNTRY_TJ,
528
                'TK' => _COUNTRY_TK,
529
                'TL' => _COUNTRY_TL,
530
                'TM' => _COUNTRY_TM,
531
                'TN' => _COUNTRY_TN,
532
                'TO' => _COUNTRY_TO,
533
                'TP' => _COUNTRY_TP,    //  Not listed in ISO 3166, has changed to TL
534
                'TR' => _COUNTRY_TR,
535
                'TT' => _COUNTRY_TT,
536
                'TV' => _COUNTRY_TV,
537
                'TW' => _COUNTRY_TW,
538
                'TZ' => _COUNTRY_TZ,
539
                'UA' => _COUNTRY_UA,
540
                'UG' => _COUNTRY_UG,
541
                //"UK" => _COUNTRY_UK,    //  Not listed in ISO 3166
542
                'UM' => _COUNTRY_UM,
543
                'US' => _COUNTRY_US,
544
                'UY' => _COUNTRY_UY,
545
                'UZ' => _COUNTRY_UZ,
546
                'VA' => _COUNTRY_VA,
547
                'VC' => _COUNTRY_VC,
548
                'VE' => _COUNTRY_VE,
549
                'VG' => _COUNTRY_VG,
550
                'VI' => _COUNTRY_VI,
551
                'VN' => _COUNTRY_VN,
552
                'VU' => _COUNTRY_VU,
553
                'WF' => _COUNTRY_WF,
554
                'WS' => _COUNTRY_WS,
555
                'YE' => _COUNTRY_YE,
556
                'YT' => _COUNTRY_YT,
557
                'YU' => _COUNTRY_YU,    //  Not listed in ISO 3166, former Yugoslavia
558
                'ZA' => _COUNTRY_ZA,
559
                'ZM' => _COUNTRY_ZM,
560
                'ZR' => _COUNTRY_ZR,    //  Not listed in ISO 3166
561
                'ZW' => _COUNTRY_ZW);
562
            asort($country_list);
563
            reset($country_list);
564
565
            return $country_list;
566
        }
567
568
        /**
569
         * XoopsLists::getHtmlList()
570
         *
571
         * This Function is no longer being used by the core
572
         *
573
         * @return array
574
         */
575
        public static function getHtmlList()
576
        {
577
            $html_list = array(
578
                'a'          => '&lt;a&gt;',
579
                'abbr'       => '&lt;abbr&gt;',
580
                'acronym'    => '&lt;acronym&gt;',
581
                'address'    => '&lt;address&gt;',
582
                'b'          => '&lt;b&gt;',
583
                'bdo'        => '&lt;bdo&gt;',
584
                'big'        => '&lt;big&gt;',
585
                'blockquote' => '&lt;blockquote&gt;',
586
                'br'         => '&lt;br&gt;',
587
                'caption'    => '&lt;caption&gt;',
588
                'cite'       => '&lt;cite&gt;',
589
                'code'       => '&lt;code&gt;',
590
                'col'        => '&lt;col&gt;',
591
                'colgroup'   => '&lt;colgroup&gt;',
592
                'dd'         => '&lt;dd&gt;',
593
                'del'        => '&lt;del&gt;',
594
                'dfn'        => '&lt;dfn&gt;',
595
                'div'        => '&lt;div&gt;',
596
                'dl'         => '&lt;dl&gt;',
597
                'dt'         => '&lt;dt&gt;',
598
                'em'         => '&lt;em&gt;',
599
                'font'       => '&lt;font&gt;',
600
                'h1'         => '&lt;h1&gt;',
601
                'h2'         => '&lt;h2&gt;',
602
                'h3'         => '&lt;h3&gt;',
603
                'h4'         => '&lt;h4&gt;',
604
                'h5'         => '&lt;h5&gt;',
605
                'h6'         => '&lt;h6&gt;',
606
                'hr'         => '&lt;hr&gt;',
607
                'i'          => '&lt;i&gt;',
608
                'img'        => '&lt;img&gt;',
609
                'ins'        => '&lt;ins&gt;',
610
                'kbd'        => '&lt;kbd&gt;',
611
                'li'         => '&lt;li&gt;',
612
                'map'        => '&lt;map&gt;',
613
                'object'     => '&lt;object&gt;',
614
                'ol'         => '&lt;ol&gt;',
615
                'p'          => '&lt;p&gt;',
616
                'pre'        => '&lt;pre&gt;',
617
                's'          => '&lt;s&gt;',
618
                'samp'       => '&lt;samp&gt;',
619
                'small'      => '&lt;small&gt;',
620
                'span'       => '&lt;span&gt;',
621
                'strike'     => '&lt;strike&gt;',
622
                'strong'     => '&lt;strong&gt;',
623
                'sub'        => '&lt;sub&gt;',
624
                'sup'        => '&lt;sup&gt;',
625
                'table'      => '&lt;table&gt;',
626
                'tbody'      => '&lt;tbody&gt;',
627
                'td'         => '&lt;td&gt;',
628
                'tfoot'      => '&lt;tfoot&gt;',
629
                'th'         => '&lt;th&gt;',
630
                'thead'      => '&lt;thead&gt;',
631
                'tr'         => '&lt;tr&gt;',
632
                'tt'         => '&lt;tt&gt;',
633
                'u'          => '&lt;u&gt;',
634
                'ul'         => '&lt;ul&gt;',
635
                'var'        => '&lt;var&gt;');
636
            asort($html_list);
637
            reset($html_list);
638
639
            return $html_list;
640
        }
641
642
        /**
643
         * XoopsLists::getUserRankList()
644
         *
645
         * @return array
646
         */
647
        public static function getUserRankList()
648
        {
649
            /** @var \XoopsMySQLDatabase $db */
650
            $db     = XoopsDatabaseFactory::getDatabaseConnection();
651
            $myts   = MyTextSanitizer::getInstance();
652
            $sql    = sprintf('SELECT rank_id, rank_title FROM ' . $db->prefix('ranks') . ' WHERE rank_special = %u', 1);
653
            $ret    = array();
654
            $result = $db->query($sql);
655
            while (false !== ($myrow = $db->fetchArray($result))) {
0 ignored issues
show
It seems like $result can also be of type boolean; however, parameter $result of XoopsMySQLDatabase::fetchArray() does only seem to accept mysqli_result, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

655
            while (false !== ($myrow = $db->fetchArray(/** @scrutinizer ignore-type */ $result))) {
Loading history...
656
                $ret[$myrow['rank_id']] = $myts->htmlSpecialChars($myrow['rank_title']);
657
            }
658
659
            return $ret;
660
        }
661
    }
662
}
663