Merge branch 'main/rendor-staging' into main/atys-live
[ryzomcore.git] / web / public_php / ams / inc / settings.php
blobd045413974789928a558ac877abcd84ca618258d
1 <?php
2 /**
3 * This function is beign used to load info that's needed for the settings page.
4 * check if the person who wants to view this page is a mod/admin or the user to whom te settings belong himself, if this is not the case, he will be redirected to an error page.
5 * it will return a lot of information of that user, that's being used for loading the template.
6 * @author Daan Janssens, mentored by Matthew Lagoe
7 */
8 function settings(){
9 if(WebUsers::isLoggedIn()){
10 //in case id-GET param set it's value as target_id, if no id-param is given, ue the session id.
11 if(isset($_GET['id'])){
12 if(($_GET['id'] != $_SESSION['id']) && (!Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) ){
13 //ERROR: No access!
14 $_SESSION['error_code'] = "403";
15 header("Cache-Control: max-age=1");
16 header("Location: index.php?page=error");
17 throw new SystemExit();
18 }else{
19 $webUser = new Webusers($_GET['id']);
20 $result = $webUser->getInfo();
21 if(Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) && ($_GET['id']!= $_SESSION['id'])){
22 $result['changesOther'] = "TRUE";
24 $result['target_id'] = $_GET['id'];
25 $result['current_mail'] = $webUser->getEmail();
26 $result['target_username'] = $webUser->getUsername();
28 }else{
29 $webUser = new Webusers($_SESSION['id']);
30 $result = $webUser->getInfo();
31 $result['target_id'] = $_SESSION['id'];
32 $result['current_mail'] = $webUser->getEmail();
33 $result['target_username'] = $webUser->getUsername();
36 //Sanitize Data
37 $result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL);
38 $result['target_username'] = filter_var($result['target_username'], FILTER_SANITIZE_STRING);
39 $result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING);
40 $result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING);
41 $result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING);
42 $result['Gender'] = filter_var($result['Gender'], FILTER_SANITIZE_NUMBER_INT);
43 $result['ReceiveMail'] = filter_var($result['ReceiveMail'], FILTER_SANITIZE_NUMBER_INT);
44 $result['country_array'] = getCountryArray();
45 global $INGAME_WEBPATH;
46 $result['ingame_webpath'] = $INGAME_WEBPATH;
49 $dbl = new DBLayer("lib");
50 $statement = $dbl->executeWithoutParams("SELECT * FROM settings");
51 $rows = $statement->fetchAll();
53 foreach ($rows as &$value) {
54 $result[$value['Setting']] = $value['Value'];
57 return $result;
58 }else{
59 //ERROR: not logged in!
60 header("Location: index.php");
61 header("Cache-Control: max-age=1");
62 throw new SystemExit();
67 function getCountryArray(){
69 $countries = array(
70 'AA'=>'None Selected',
71 'AF'=>'Afghanistan',
72 'AL'=>'Albania',
73 'DZ'=>'Algeria',
74 'AS'=>'American Samoa',
75 'AD'=>'Andorra',
76 'AO'=>'Angola',
77 'AI'=>'Anguilla',
78 'AQ'=>'Antarctica',
79 'AG'=>'Antigua And Barbuda',
80 'AR'=>'Argentina',
81 'AM'=>'Armenia',
82 'AW'=>'Aruba',
83 'AU'=>'Australia',
84 'AT'=>'Austria',
85 'AZ'=>'Azerbaijan',
86 'BS'=>'Bahamas',
87 'BH'=>'Bahrain',
88 'BD'=>'Bangladesh',
89 'BB'=>'Barbados',
90 'BY'=>'Belarus',
91 'BE'=>'Belgium',
92 'BZ'=>'Belize',
93 'BJ'=>'Benin',
94 'BM'=>'Bermuda',
95 'BT'=>'Bhutan',
96 'BO'=>'Bolivia',
97 'BA'=>'Bosnia And Herzegovina',
98 'BW'=>'Botswana',
99 'BV'=>'Bouvet Island',
100 'BR'=>'Brazil',
101 'IO'=>'British Indian Ocean Territory',
102 'BN'=>'Brunei',
103 'BG'=>'Bulgaria',
104 'BF'=>'Burkina Faso',
105 'BI'=>'Burundi',
106 'KH'=>'Cambodia',
107 'CM'=>'Cameroon',
108 'CA'=>'Canada',
109 'CV'=>'Cape Verde',
110 'KY'=>'Cayman Islands',
111 'CF'=>'Central African Republic',
112 'TD'=>'Chad',
113 'CL'=>'Chile',
114 'CN'=>'China',
115 'CX'=>'Christmas Island',
116 'CC'=>'Cocos (Keeling) Islands',
117 'CO'=>'Columbia',
118 'KM'=>'Comoros',
119 'CG'=>'Congo',
120 'CK'=>'Cook Islands',
121 'CR'=>'Costa Rica',
122 'CI'=>'Cote D\'Ivorie (Ivory Coast)',
123 'HR'=>'Croatia (Hrvatska)',
124 'CU'=>'Cuba',
125 'CY'=>'Cyprus',
126 'CZ'=>'Czech Republic',
127 'CD'=>'Democratic Republic Of Congo (Zaire)',
128 'DK'=>'Denmark',
129 'DJ'=>'Djibouti',
130 'DM'=>'Dominica',
131 'DO'=>'Dominican Republic',
132 'TP'=>'East Timor',
133 'EC'=>'Ecuador',
134 'EG'=>'Egypt',
135 'SV'=>'El Salvador',
136 'GQ'=>'Equatorial Guinea',
137 'ER'=>'Eritrea',
138 'EE'=>'Estonia',
139 'ET'=>'Ethiopia',
140 'FK'=>'Falkland Islands (Malvinas)',
141 'FO'=>'Faroe Islands',
142 'FJ'=>'Fiji',
143 'FI'=>'Finland',
144 'FR'=>'France',
145 'FX'=>'France, Metropolitan',
146 'GF'=>'French Guinea',
147 'PF'=>'French Polynesia',
148 'TF'=>'French Southern Territories',
149 'GA'=>'Gabon',
150 'GM'=>'Gambia',
151 'GE'=>'Georgia',
152 'DE'=>'Germany',
153 'GH'=>'Ghana',
154 'GI'=>'Gibraltar',
155 'GR'=>'Greece',
156 'GL'=>'Greenland',
157 'GD'=>'Grenada',
158 'GP'=>'Guadeloupe',
159 'GU'=>'Guam',
160 'GT'=>'Guatemala',
161 'GN'=>'Guinea',
162 'GW'=>'Guinea-Bissau',
163 'GY'=>'Guyana',
164 'HT'=>'Haiti',
165 'HM'=>'Heard And McDonald Islands',
166 'HN'=>'Honduras',
167 'HK'=>'Hong Kong',
168 'HU'=>'Hungary',
169 'IS'=>'Iceland',
170 'IN'=>'India',
171 'ID'=>'Indonesia',
172 'IR'=>'Iran',
173 'IQ'=>'Iraq',
174 'IE'=>'Ireland',
175 'IL'=>'Israel',
176 'IT'=>'Italy',
177 'JM'=>'Jamaica',
178 'JP'=>'Japan',
179 'JO'=>'Jordan',
180 'KZ'=>'Kazakhstan',
181 'KE'=>'Kenya',
182 'KI'=>'Kiribati',
183 'KW'=>'Kuwait',
184 'KG'=>'Kyrgyzstan',
185 'LA'=>'Laos',
186 'LV'=>'Latvia',
187 'LB'=>'Lebanon',
188 'LS'=>'Lesotho',
189 'LR'=>'Liberia',
190 'LY'=>'Libya',
191 'LI'=>'Liechtenstein',
192 'LT'=>'Lithuania',
193 'LU'=>'Luxembourg',
194 'MO'=>'Macau',
195 'MK'=>'Macedonia',
196 'MG'=>'Madagascar',
197 'MW'=>'Malawi',
198 'MY'=>'Malaysia',
199 'MV'=>'Maldives',
200 'ML'=>'Mali',
201 'MT'=>'Malta',
202 'MH'=>'Marshall Islands',
203 'MQ'=>'Martinique',
204 'MR'=>'Mauritania',
205 'MU'=>'Mauritius',
206 'YT'=>'Mayotte',
207 'MX'=>'Mexico',
208 'FM'=>'Micronesia',
209 'MD'=>'Moldova',
210 'MC'=>'Monaco',
211 'MN'=>'Mongolia',
212 'MS'=>'Montserrat',
213 'MA'=>'Morocco',
214 'MZ'=>'Mozambique',
215 'MM'=>'Myanmar (Burma)',
216 'NA'=>'Namibia',
217 'NR'=>'Nauru',
218 'NP'=>'Nepal',
219 'NL'=>'Netherlands',
220 'AN'=>'Netherlands Antilles',
221 'NC'=>'New Caledonia',
222 'NZ'=>'New Zealand',
223 'NI'=>'Nicaragua',
224 'NE'=>'Niger',
225 'NG'=>'Nigeria',
226 'NU'=>'Niue',
227 'NF'=>'Norfolk Island',
228 'KP'=>'North Korea',
229 'MP'=>'Northern Mariana Islands',
230 'NO'=>'Norway',
231 'OM'=>'Oman',
232 'PK'=>'Pakistan',
233 'PW'=>'Palau',
234 'PA'=>'Panama',
235 'PG'=>'Papua New Guinea',
236 'PY'=>'Paraguay',
237 'PE'=>'Peru',
238 'PH'=>'Philippines',
239 'PN'=>'Pitcairn',
240 'PL'=>'Poland',
241 'PT'=>'Portugal',
242 'PR'=>'Puerto Rico',
243 'QA'=>'Qatar',
244 'RE'=>'Reunion',
245 'RO'=>'Romania',
246 'RU'=>'Russia',
247 'RW'=>'Rwanda',
248 'SH'=>'Saint Helena',
249 'KN'=>'Saint Kitts And Nevis',
250 'LC'=>'Saint Lucia',
251 'PM'=>'Saint Pierre And Miquelon',
252 'VC'=>'Saint Vincent And The Grenadines',
253 'SM'=>'San Marino',
254 'ST'=>'Sao Tome And Principe',
255 'SA'=>'Saudi Arabia',
256 'SN'=>'Senegal',
257 'SC'=>'Seychelles',
258 'SL'=>'Sierra Leone',
259 'SG'=>'Singapore',
260 'SK'=>'Slovak Republic',
261 'SI'=>'Slovenia',
262 'SB'=>'Solomon Islands',
263 'SO'=>'Somalia',
264 'ZA'=>'South Africa',
265 'GS'=>'South Georgia And South Sandwich Islands',
266 'KR'=>'South Korea',
267 'ES'=>'Spain',
268 'LK'=>'Sri Lanka',
269 'SD'=>'Sudan',
270 'SR'=>'Suriname',
271 'SJ'=>'Svalbard And Jan Mayen',
272 'SZ'=>'Swaziland',
273 'SE'=>'Sweden',
274 'CH'=>'Switzerland',
275 'SY'=>'Syria',
276 'TW'=>'Taiwan',
277 'TJ'=>'Tajikistan',
278 'TZ'=>'Tanzania',
279 'TH'=>'Thailand',
280 'TG'=>'Togo',
281 'TK'=>'Tokelau',
282 'TO'=>'Tonga',
283 'TT'=>'Trinidad And Tobago',
284 'TN'=>'Tunisia',
285 'TR'=>'Turkey',
286 'TM'=>'Turkmenistan',
287 'TC'=>'Turks And Caicos Islands',
288 'TV'=>'Tuvalu',
289 'UG'=>'Uganda',
290 'UA'=>'Ukraine',
291 'AE'=>'United Arab Emirates',
292 'UK'=>'United Kingdom',
293 'US'=>'United States',
294 'UM'=>'United States Minor Outlying Islands',
295 'UY'=>'Uruguay',
296 'UZ'=>'Uzbekistan',
297 'VU'=>'Vanuatu',
298 'VA'=>'Vatican City (Holy See)',
299 'VE'=>'Venezuela',
300 'VN'=>'Vietnam',
301 'VG'=>'Virgin Islands (British)',
302 'VI'=>'Virgin Islands (US)',
303 'WF'=>'Wallis And Futuna Islands',
304 'EH'=>'Western Sahara',
305 'WS'=>'Western Samoa',
306 'YE'=>'Yemen',
307 'YU'=>'Yugoslavia',
308 'ZM'=>'Zambia',
309 'ZW'=>'Zimbabwe'
312 return $countries;