XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
xoopslists.php
1<?php
13
14if (!defined('XOOPS_LISTS_INCLUDED')) {
15 define('XOOPS_LISTS_INCLUDED', 1);
16 class xoopslists
17 {
18 public static function getTimeZoneList()
19 {
20 $root =& XCube_Root::getSingleton();
21 if (null !== $root->mLanguageManager && !defined('_TZ_GMT0')) {
22 $root->mLanguageManager->loadPageTypeMessageCatalog('timezone');
23 }
24 $time_zone_list = [
25 '-12' => _TZ_GMTM12,
26 '-11' => _TZ_GMTM11,
27 '-10' => _TZ_GMTM10,
28 '-9' => _TZ_GMTM9,
29 '-8' => _TZ_GMTM8,
30 '-7' => _TZ_GMTM7,
31 '-6' => _TZ_GMTM6,
32 '-5' => _TZ_GMTM5,
33 '-4.5' => _TZ_GMTM45,
34 '-4' => _TZ_GMTM4,
35 '-3.5' => _TZ_GMTM35,
36 '-3' => _TZ_GMTM3,
37 '-2' => _TZ_GMTM2,
38 '-1' => _TZ_GMTM1,
39 '0' => _TZ_GMT0,
40 '1' => _TZ_GMTP1,
41 '2' => _TZ_GMTP2,
42 '3' => _TZ_GMTP3,
43 '3.5' => _TZ_GMTP35,
44 '4' => _TZ_GMTP4,
45 '4.5' => _TZ_GMTP45,
46 '5' => _TZ_GMTP5,
47 '5.5' => _TZ_GMTP55,
48 '5.75' => _TZ_GMTP575,
49 '6' => _TZ_GMTP6,
50 '6.5' => _TZ_GMTP65,
51 '7' => _TZ_GMTP7,
52 '8' => _TZ_GMTP8,
53 '9' => _TZ_GMTP9,
54 '9.5' => _TZ_GMTP95,
55 '10' => _TZ_GMTP10,
56 '11' => _TZ_GMTP11,
57 '12' => _TZ_GMTP12,
58 '13' => _TZ_GMTP13
59 ];
60 return $time_zone_list;
61 }
62
63 /*
64 * gets list of themes folder from themes directory
65 */
66 public static function &getThemesList()
67 {
68 $ret =& XoopsLists::getDirListAsArray(XOOPS_THEME_PATH.'/');
69 return $ret;
70 }
71
72 /*
73 * gets a list of module folders from the modules directory
74 */
75 public static function &getModulesList()
76 {
77 $ret =& XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/modules/');
78 return $ret;
79 }
80
81 /*
82 * gets list of name of directories inside a directory
83 */
84 public static function &getDirListAsArray($dirname)
85 {
86 $dirlist = [];
87 if (is_dir($dirname) && $handle = opendir($dirname)) {
88 while (false !== ($file = readdir($handle))) {
89 if (!preg_match("/^\..*$/", $file)) {
90 if ('cvs' != strtolower($file) && is_dir($dirname . $file)) {
91 $dirlist[$file]=$file;
92 }
93 }
94 }
95 closedir($handle);
96 asort($dirlist);
97 reset($dirlist);
98 }
99 return $dirlist;
100 }
101
102 /*
103 * gets list of all files in a directory
104 */
105 public static function &getFileListAsArray($dirname, $prefix= '')
106 {
107 $filelist = [];
108 if ('/' == substr($dirname, -1)) {
109 $dirname = substr($dirname, 0, -1);
110 }
111 if (is_dir($dirname) && $handle = opendir($dirname)) {
112 while (false !== ($file = readdir($handle))) {
113 if (!preg_match("/^[\.]{1,2}$/", $file) && is_file($dirname.'/'.$file)) {
114 $file = $prefix.$file;
115 $filelist[$file]=$file;
116 }
117 }
118 closedir($handle);
119 asort($filelist);
120 reset($filelist);
121 }
122 return $filelist;
123 }
124
125 /*
126 * gets list of image file names in a directory
127 */
128 public static function &getImgListAsArray($dirname, $prefix= '')
129 {
130 $filelist = [];
131 if ($handle = opendir($dirname)) {
132 while (false !== ($file = readdir($handle))) {
133 if (!preg_match("/^[\.]{1,2}$/", $file) && preg_match("/(\.gif|\.jpg|\.png)$/i", $file)) {
134 $file = $prefix.$file;
135 $filelist[$file]=$file;
136 }
137 }
138 closedir($handle);
139 asort($filelist);
140 reset($filelist);
141 }
142 return $filelist;
143 }
144
145 /*
146 * gets list of html file names in a certain directory
147 */
148 public static function &getHtmlListAsArray($dirname, $prefix= '')
149 {
150 $filelist = [];
151 if ($handle = opendir($dirname)) {
152 while (false !== ($file = readdir($handle))) {
153 if ((!preg_match("/^[\.]{1,2}$/", $file) && preg_match("/(\.htm|\.html|\.xhtml)$/i", $file) && !is_dir($file)) && 'cvs' != strtolower($file) && !is_dir($file)) {
154 $file = $prefix.$file;
155 $filelist[$file] = $prefix.$file;
156 }
157 }
158 closedir($handle);
159 asort($filelist);
160 reset($filelist);
161 }
162 return $filelist;
163 }
164
165 /*
166 * gets list of avatar file names in a certain directory
167 * if directory is not specified, default directory will be searched
168 */
169 public static function &getAvatarsList($avatar_dir= '')
170 {
171 $avatars = [];
172 if ('' !== $avatar_dir) {
173 $avatars =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/avatar/' . $avatar_dir . '/', $avatar_dir . '/');
174 } else {
175 $avatars =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/avatar/');
176 }
177 return $avatars;
178 }
179
180 /*
181 * gets list of all avatar image files inside default avatars directory
182 */
183 public static function &getAllAvatarsList()
184 {
185 $avatars = [];
186 $dirlist = [];
187 $dirlist =& XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/images/avatar/');
188 if (count($dirlist) > 0) {
189 foreach ($dirlist as $dir) {
190 $avatars[$dir] =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/avatar/' . $dir . '/', $dir . '/');
191 }
192 return $avatars;
193 }
194 $ret = false;
195 return $ret;
196 }
197
198 /*
199 * gets list of subject icon image file names in a certain directory
200 * if directory is not specified, default directory will be searched
201 */
202 public static function &getSubjectsList($sub_dir= '')
203 {
204 $subjects = [];
205 if ('' !== $sub_dir) {
206 $subjects =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/subject/' . $sub_dir, $sub_dir . '/');
207 } else {
208 $subjects =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/subject/');
209 }
210 return $subjects;
211 }
212
213 /*
214 * gets list of language folders inside default language directory
215 */
216 public static function &getLangList()
217 {
218 $lang_list = [];
219 $lang_list =& XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/language/');
220 return $lang_list;
221 }
222
223 public static function &getCountryList()
224 {
225 $country_list = [
226 '' => '-',
227 'AD' => 'Andorra',
228 'AE' => 'United Arab Emirates',
229 'AF' => 'Afghanistan',
230 'AG' => 'Antigua and Barbuda',
231 'AI' => 'Anguilla',
232 'AL' => 'Albania',
233 'AM' => 'Armenia',
234 'AN' => 'Netherlands Antilles',
235 'AO' => 'Angola',
236 'AQ' => 'Antarctica',
237 'AR' => 'Argentina',
238 'AS' => 'American Samoa',
239 'AT' => 'Austria',
240 'AU' => 'Australia',
241 'AW' => 'Aruba',
242 'AZ' => 'Azerbaijan',
243 'BA' => 'Bosnia and Herzegovina',
244 'BB' => 'Barbados',
245 'BD' => 'Bangladesh',
246 'BE' => 'Belgium',
247 'BF' => 'Burkina Faso',
248 'BG' => 'Bulgaria',
249 'BH' => 'Bahrain',
250 'BI' => 'Burundi',
251 'BJ' => 'Benin',
252 'BM' => 'Bermuda',
253 'BN' => 'Brunei Darussalam',
254 'BO' => 'Bolivia',
255 'BR' => 'Brazil',
256 'BS' => 'Bahamas',
257 'BT' => 'Bhutan',
258 'BV' => 'Bouvet Island',
259 'BW' => 'Botswana',
260 'BY' => 'Belarus',
261 'BZ' => 'Belize',
262 'CA' => 'Canada',
263 'CC' => 'Cocos (Keeling) Islands',
264 'CF' => 'Central African Republic',
265 'CG' => 'Congo',
266 'CH' => 'Switzerland',
267 'CI' => "Cote D'Ivoire (Ivory Coast)",
268 'CK' => 'Cook Islands',
269 'CL' => 'Chile',
270 'CM' => 'Cameroon',
271 'CN' => 'China',
272 'CO' => 'Colombia',
273 'CR' => 'Costa Rica',
274 'CS' => 'Czechoslovakia (former)',
275 'CU' => 'Cuba',
276 'CV' => 'Cape Verde',
277 'CX' => 'Christmas Island',
278 'CY' => 'Cyprus',
279 'CZ' => 'Czech Republic',
280 'DE' => 'Germany',
281 'DJ' => 'Djibouti',
282 'DK' => 'Denmark',
283 'DM' => 'Dominica',
284 'DO' => 'Dominican Republic',
285 'DZ' => 'Algeria',
286 'EC' => 'Ecuador',
287 'EE' => 'Estonia',
288 'EG' => 'Egypt',
289 'EH' => 'Western Sahara',
290 'ER' => 'Eritrea',
291 'ES' => 'Spain',
292 'ET' => 'Ethiopia',
293 'FI' => 'Finland',
294 'FJ' => 'Fiji',
295 'FK' => 'Falkland Islands (Malvinas)',
296 'FM' => 'Micronesia',
297 'FO' => 'Faroe Islands',
298 'FR' => 'France',
299 'FX' => 'France, Metropolitan',
300 'GA' => 'Gabon',
301 'GB' => 'Great Britain (UK)',
302 'GD' => 'Grenada',
303 'GE' => 'Georgia',
304 'GF' => 'French Guiana',
305 'GH' => 'Ghana',
306 'GI' => 'Gibraltar',
307 'GL' => 'Greenland',
308 'GM' => 'Gambia',
309 'GN' => 'Guinea',
310 'GP' => 'Guadeloupe',
311 'GQ' => 'Equatorial Guinea',
312 'GR' => 'Greece',
313 'GS' => 'S. Georgia and S. Sandwich Isls.',
314 'GT' => 'Guatemala',
315 'GU' => 'Guam',
316 'GW' => 'Guinea-Bissau',
317 'GY' => 'Guyana',
318 'HK' => 'Hong Kong',
319 'HM' => 'Heard and McDonald Islands',
320 'HN' => 'Honduras',
321 'HR' => 'Croatia (Hrvatska)',
322 'HT' => 'Haiti',
323 'HU' => 'Hungary',
324 'ID' => 'Indonesia',
325 'IE' => 'Ireland',
326 'IL' => 'Israel',
327 'IN' => 'India',
328 'IO' => 'British Indian Ocean Territory',
329 'IQ' => 'Iraq',
330 'IR' => 'Iran',
331 'IS' => 'Iceland',
332 'IT' => 'Italy',
333 'JM' => 'Jamaica',
334 'JO' => 'Jordan',
335 'JP' => 'Japan',
336 'KE' => 'Kenya',
337 'KG' => 'Kyrgyzstan',
338 'KH' => 'Cambodia',
339 'KI' => 'Kiribati',
340 'KM' => 'Comoros',
341 'KN' => 'Saint Kitts and Nevis',
342 'KP' => 'Korea (North)',
343 'KR' => 'Korea (South)',
344 'KW' => 'Kuwait',
345 'KY' => 'Cayman Islands',
346 'KZ' => 'Kazakhstan',
347 'LA' => 'Laos',
348 'LB' => 'Lebanon',
349 'LC' => 'Saint Lucia',
350 'LI' => 'Liechtenstein',
351 'LK' => 'Sri Lanka',
352 'LR' => 'Liberia',
353 'LS' => 'Lesotho',
354 'LT' => 'Lithuania',
355 'LU' => 'Luxembourg',
356 'LV' => 'Latvia',
357 'LY' => 'Libya',
358 'MA' => 'Morocco',
359 'MC' => 'Monaco',
360 'MD' => 'Moldova',
361 'MG' => 'Madagascar',
362 'MH' => 'Marshall Islands',
363 'MK' => 'Macedonia',
364 'ML' => 'Mali',
365 'MM' => 'Myanmar',
366 'MN' => 'Mongolia',
367 'MO' => 'Macau',
368 'MP' => 'Northern Mariana Islands',
369 'MQ' => 'Martinique',
370 'MR' => 'Mauritania',
371 'MS' => 'Montserrat',
372 'MT' => 'Malta',
373 'MU' => 'Mauritius',
374 'MV' => 'Maldives',
375 'MW' => 'Malawi',
376 'MX' => 'Mexico',
377 'MY' => 'Malaysia',
378 'MZ' => 'Mozambique',
379 'NA' => 'Namibia',
380 'NC' => 'New Caledonia',
381 'NE' => 'Niger',
382 'NF' => 'Norfolk Island',
383 'NG' => 'Nigeria',
384 'NI' => 'Nicaragua',
385 'NL' => 'Netherlands',
386 'NO' => 'Norway',
387 'NP' => 'Nepal',
388 'NR' => 'Nauru',
389 'NT' => 'Neutral Zone',
390 'NU' => 'Niue',
391 'NZ' => 'New Zealand (Aotearoa)',
392 'OM' => 'Oman',
393 'PA' => 'Panama',
394 'PE' => 'Peru',
395 'PF' => 'French Polynesia',
396 'PG' => 'Papua New Guinea',
397 'PH' => 'Philippines',
398 'PK' => 'Pakistan',
399 'PL' => 'Poland',
400 'PM' => 'St. Pierre and Miquelon',
401 'PN' => 'Pitcairn',
402 'PR' => 'Puerto Rico',
403 'PT' => 'Portugal',
404 'PW' => 'Palau',
405 'PY' => 'Paraguay',
406 'QA' => 'Qatar',
407 'RE' => 'Reunion',
408 'RO' => 'Romania',
409 'RU' => 'Russian Federation',
410 'RW' => 'Rwanda',
411 'SA' => 'Saudi Arabia',
412 'Sb' => 'Solomon Islands',
413 'SC' => 'Seychelles',
414 'SD' => 'Sudan',
415 'SE' => 'Sweden',
416 'SG' => 'Singapore',
417 'SH' => 'St. Helena',
418 'SI' => 'Slovenia',
419 'SJ' => 'Svalbard and Jan Mayen Islands',
420 'SK' => 'Slovak Republic',
421 'SL' => 'Sierra Leone',
422 'SM' => 'San Marino',
423 'SN' => 'Senegal',
424 'SO' => 'Somalia',
425 'SR' => 'Suriname',
426 'ST' => 'Sao Tome and Principe',
427 'SU' => 'USSR (former)',
428 'SV' => 'El Salvador',
429 'SY' => 'Syria',
430 'SZ' => 'Swaziland',
431 'TC' => 'Turks and Caicos Islands',
432 'TD' => 'Chad',
433 'TF' => 'French Southern Territories',
434 'TG' => 'Togo',
435 'TH' => 'Thailand',
436 'TJ' => 'Tajikistan',
437 'TK' => 'Tokelau',
438 'TM' => 'Turkmenistan',
439 'TN' => 'Tunisia',
440 'TO' => 'Tonga',
441 'TP' => 'East Timor',
442 'TR' => 'Turkey',
443 'TT' => 'Trinidad and Tobago',
444 'TV' => 'Tuvalu',
445 'TW' => 'Taiwan',
446 'TZ' => 'Tanzania',
447 'UA' => 'Ukraine',
448 'UG' => 'Uganda',
449 'UK' => 'United Kingdom',
450 'UM' => 'US Minor Outlying Islands',
451 'US' => 'United States',
452 'UY' => 'Uruguay',
453 'UZ' => 'Uzbekistan',
454 'VA' => 'Vatican City State (Holy See)',
455 'VC' => 'Saint Vincent and the Grenadines',
456 'VE' => 'Venezuela',
457 'VG' => 'Virgin Islands (British)',
458 'VI' => 'Virgin Islands (U.S.)',
459 'VN' => 'Viet Nam',
460 'VU' => 'Vanuatu',
461 'WF' => 'Wallis and Futuna Islands',
462 'WS' => 'Samoa',
463 'YE' => 'Yemen',
464 'YT' => 'Mayotte',
465 'YU' => 'Yugoslavia',
466 'ZA' => 'South Africa',
467 'ZM' => 'Zambia',
468 'ZR' => 'Zaire',
469 'ZW' => 'Zimbabwe'
470 ];
471 asort($country_list);
472 reset($country_list);
473 return $country_list;
474 }
475
476 public static function &getHtmlList()
477 {
478 $html_list = [
479 'a' => '&lt;a&gt;',
480 'abbr' => '&lt;abbr&gt;',
481 'acronym' => '&lt;acronym&gt;',
482 'address' => '&lt;address&gt;',
483 'b' => '&lt;b&gt;',
484 'bdo' => '&lt;bdo&gt;',
485 'big' => '&lt;big&gt;',
486 'blockquote' => '&lt;blockquote&gt;',
487 'caption' => '&lt;caption&gt;',
488 'cite' => '&lt;cite&gt;',
489 'code' => '&lt;code&gt;',
490 'col' => '&lt;col&gt;',
491 'colgroup' => '&lt;colgroup&gt;',
492 'dd' => '&lt;dd&gt;',
493 'del' => '&lt;del&gt;',
494 'dfn' => '&lt;dfn&gt;',
495 'div' => '&lt;div&gt;',
496 'dl' => '&lt;dl&gt;',
497 'dt' => '&lt;dt&gt;',
498 'em' => '&lt;em&gt;',
499 'font' => '&lt;font&gt;',
500 'h1' => '&lt;h1&gt;',
501 'h2' => '&lt;h2&gt;',
502 'h3' => '&lt;h3&gt;',
503 'h4' => '&lt;h4&gt;',
504 'h5' => '&lt;h5&gt;',
505 'h6' => '&lt;h6&gt;',
506 'hr' => '&lt;hr&gt;',
507 'i' => '&lt;i&gt;',
508 'img' => '&lt;img&gt;',
509 'ins' => '&lt;ins&gt;',
510 'kbd' => '&lt;kbd&gt;',
511 'li' => '&lt;li&gt;',
512 'map' => '&lt;map&gt;',
513 'object' => '&lt;object&gt;',
514 'ol' => '&lt;ol&gt;',
515 'samp' => '&lt;samp&gt;',
516 'small' => '&lt;small&gt;',
517 'strong' => '&lt;strong&gt;',
518 'sub' => '&lt;sub&gt;',
519 'sup' => '&lt;sup&gt;',
520 'table' => '&lt;table&gt;',
521 'tbody' => '&lt;tbody&gt;',
522 'td' => '&lt;td&gt;',
523 'tfoot' => '&lt;tfoot&gt;',
524 'th' => '&lt;th&gt;',
525 'thead' => '&lt;thead&gt;',
526 'tr' => '&lt;tr&gt;',
527 'tt' => '&lt;tt&gt;',
528 'ul' => '&lt;ul&gt;',
529 'var' => '&lt;var&gt;'
530 ];
531 asort($html_list);
532 reset($html_list);
533 return $html_list;
534 }
535
536 public static function &getUserRankList()
537 {
538 //$db =& Database::getInstance();
541 $sql = 'SELECT rank_id, rank_title FROM ' . $db->prefix('ranks') . ' WHERE rank_special = 1';
542 $ret = [];
543 $result = $db->query($sql);
544 while ($myrow = $db->fetchArray($result)) {
545 $ret[$myrow['rank_id']] = $myts->makeTboxData4Show($myrow['rank_title']);
546 }
547 return $ret;
548 }
549 }
550}
static & getDatabaseConnection()