PageRenderTime 68ms CodeModel.GetById 11ms app.highlight 51ms RepoModel.GetById 1ms app.codeStats 0ms

/class/xml/rpc/class/xoopslists.php

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