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