source: temp/test-xoops.ec-cube.net/html/class/xoopslists.php @ 405

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