@@ -213,26 +213,26 @@ discard block |
||
213 | 213 | } |
214 | 214 | function geoip_load_shared_mem ($file) { |
215 | 215 | |
216 | - $fp = fopen($file, "rb"); |
|
217 | - if (!$fp) { |
|
216 | + $fp = fopen($file, "rb"); |
|
217 | + if (!$fp) { |
|
218 | 218 | print "error opening $file: $php_errormsg\n"; |
219 | 219 | exit; |
220 | - } |
|
221 | - $s_array = fstat($fp); |
|
222 | - $size = $s_array['size']; |
|
223 | - if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) { |
|
220 | + } |
|
221 | + $s_array = fstat($fp); |
|
222 | + $size = $s_array['size']; |
|
223 | + if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) { |
|
224 | 224 | shmop_delete ($shmid); |
225 | 225 | shmop_close ($shmid); |
226 | - } |
|
227 | - $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size); |
|
228 | - shmop_write ($shmid, fread($fp, $size), 0); |
|
229 | - shmop_close ($shmid); |
|
226 | + } |
|
227 | + $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size); |
|
228 | + shmop_write ($shmid, fread($fp, $size), 0); |
|
229 | + shmop_close ($shmid); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | function _setup_segments($gi){ |
233 | - $gi->databaseType = GEOIP_COUNTRY_EDITION; |
|
234 | - $gi->record_length = STANDARD_RECORD_LENGTH; |
|
235 | - if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|
233 | + $gi->databaseType = GEOIP_COUNTRY_EDITION; |
|
234 | + $gi->record_length = STANDARD_RECORD_LENGTH; |
|
235 | + if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|
236 | 236 | $offset = @shmop_size ($gi->shmid) - 3; |
237 | 237 | for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { |
238 | 238 | $delim = @shmop_read ($gi->shmid, $offset, 3); |
@@ -245,19 +245,19 @@ discard block |
||
245 | 245 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; |
246 | 246 | } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ |
247 | 247 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
248 | - } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)|| |
|
248 | + } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)|| |
|
249 | 249 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) |
250 | 250 | || ($gi->databaseType == GEOIP_ORG_EDITION) |
251 | - || ($gi->databaseType == GEOIP_ISP_EDITION) |
|
252 | - || ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
|
251 | + || ($gi->databaseType == GEOIP_ISP_EDITION) |
|
252 | + || ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
|
253 | 253 | $gi->databaseSegments = 0; |
254 | 254 | $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH); |
255 | 255 | for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ |
256 | 256 | $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); |
257 | 257 | } |
258 | - if (($gi->databaseType == GEOIP_ORG_EDITION)|| |
|
259 | - ($gi->databaseType == GEOIP_ISP_EDITION)) { |
|
260 | - $gi->record_length = ORG_RECORD_LENGTH; |
|
258 | + if (($gi->databaseType == GEOIP_ORG_EDITION)|| |
|
259 | + ($gi->databaseType == GEOIP_ISP_EDITION)) { |
|
260 | + $gi->record_length = ORG_RECORD_LENGTH; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | break; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ |
271 | 271 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
272 | 272 | } |
273 | - } else { |
|
273 | + } else { |
|
274 | 274 | $filepos = ftell($gi->filehandle); |
275 | 275 | fseek($gi->filehandle, -3, SEEK_END); |
276 | 276 | for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { |
@@ -281,19 +281,19 @@ discard block |
||
281 | 281 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; |
282 | 282 | } |
283 | 283 | else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ |
284 | - $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
|
284 | + $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
|
285 | 285 | } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) || |
286 | 286 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || |
287 | 287 | ($gi->databaseType == GEOIP_ORG_EDITION) || |
288 | - ($gi->databaseType == GEOIP_ISP_EDITION) || |
|
288 | + ($gi->databaseType == GEOIP_ISP_EDITION) || |
|
289 | 289 | ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
290 | 290 | $gi->databaseSegments = 0; |
291 | 291 | $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH); |
292 | 292 | for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ |
293 | 293 | $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); |
294 | 294 | } |
295 | - if ($gi->databaseType == GEOIP_ORG_EDITION) { |
|
296 | - $gi->record_length = ORG_RECORD_LENGTH; |
|
295 | + if ($gi->databaseType == GEOIP_ORG_EDITION) { |
|
296 | + $gi->record_length = ORG_RECORD_LENGTH; |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | break; |
@@ -304,17 +304,17 @@ discard block |
||
304 | 304 | if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| |
305 | 305 | ($gi->databaseType == GEOIP_PROXY_EDITION)|| |
306 | 306 | ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ |
307 | - $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
|
307 | + $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
|
308 | 308 | } |
309 | 309 | fseek($gi->filehandle,$filepos,SEEK_SET); |
310 | - } |
|
311 | - return $gi; |
|
310 | + } |
|
311 | + return $gi; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | function geoip_open($filename, $flags) { |
315 | - $gi = new GeoIP; |
|
316 | - $gi->flags = $flags; |
|
317 | - if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|
315 | + $gi = new GeoIP; |
|
316 | + $gi->flags = $flags; |
|
317 | + if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|
318 | 318 | $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0); |
319 | 319 | } else { |
320 | 320 | $gi->filehandle = fopen($filename,"rb"); |
@@ -322,174 +322,174 @@ discard block |
||
322 | 322 | $s_array = fstat($gi->filehandle); |
323 | 323 | $gi->memory_buffer = fread($gi->filehandle, $s_array[size]); |
324 | 324 | } |
325 | - } |
|
325 | + } |
|
326 | 326 | |
327 | - $gi = _setup_segments($gi); |
|
328 | - return $gi; |
|
327 | + $gi = _setup_segments($gi); |
|
328 | + return $gi; |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | function geoip_close($gi) { |
332 | - if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|
332 | + if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|
333 | 333 | return true; |
334 | - } |
|
334 | + } |
|
335 | 335 | |
336 | - return fclose($gi->filehandle); |
|
336 | + return fclose($gi->filehandle); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | function geoip_country_id_by_name($gi, $name) { |
340 | - $addr = gethostbyname($name); |
|
341 | - if (!$addr || $addr == $name) { |
|
340 | + $addr = gethostbyname($name); |
|
341 | + if (!$addr || $addr == $name) { |
|
342 | 342 | return false; |
343 | - } |
|
344 | - return geoip_country_id_by_addr($gi, $addr); |
|
343 | + } |
|
344 | + return geoip_country_id_by_addr($gi, $addr); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | function geoip_country_code_by_name($gi, $name) { |
348 | - $country_id = geoip_country_id_by_name($gi,$name); |
|
349 | - if ($country_id !== false) { |
|
348 | + $country_id = geoip_country_id_by_name($gi,$name); |
|
349 | + if ($country_id !== false) { |
|
350 | 350 | return $gi->GEOIP_COUNTRY_CODES[$country_id]; |
351 | - } |
|
352 | - return false; |
|
351 | + } |
|
352 | + return false; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | function geoip_country_name_by_name($gi, $name) { |
356 | - $country_id = geoip_country_id_by_name($gi,$name); |
|
357 | - if ($country_id !== false) { |
|
356 | + $country_id = geoip_country_id_by_name($gi,$name); |
|
357 | + if ($country_id !== false) { |
|
358 | 358 | return $gi->GEOIP_COUNTRY_NAMES[$country_id]; |
359 | - } |
|
360 | - return false; |
|
359 | + } |
|
360 | + return false; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | function geoip_country_id_by_addr($gi, $addr) { |
364 | - $ipnum = ip2long($addr); |
|
365 | - return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN; |
|
364 | + $ipnum = ip2long($addr); |
|
365 | + return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | function geoip_country_code_by_addr($gi, $addr) { |
369 | - $country_id = geoip_country_id_by_addr($gi,$addr); |
|
370 | - if ($country_id !== false) { |
|
369 | + $country_id = geoip_country_id_by_addr($gi,$addr); |
|
370 | + if ($country_id !== false) { |
|
371 | 371 | return $gi->GEOIP_COUNTRY_CODES[$country_id]; |
372 | - } |
|
373 | - return false; |
|
372 | + } |
|
373 | + return false; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | function geoip_country_name_by_addr($gi, $addr) { |
377 | - $country_id = geoip_country_id_by_addr($gi,$addr); |
|
378 | - if ($country_id !== false) { |
|
377 | + $country_id = geoip_country_id_by_addr($gi,$addr); |
|
378 | + if ($country_id !== false) { |
|
379 | 379 | return $gi->GEOIP_COUNTRY_NAMES[$country_id]; |
380 | - } |
|
381 | - return false; |
|
380 | + } |
|
381 | + return false; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | function _geoip_seek_country($gi, $ipnum) { |
385 | - $offset = 0; |
|
386 | - for ($depth = 31; $depth >= 0; --$depth) { |
|
385 | + $offset = 0; |
|
386 | + for ($depth = 31; $depth >= 0; --$depth) { |
|
387 | 387 | if ($gi->flags & GEOIP_MEMORY_CACHE) { |
388 | - $buf = substr($gi->memory_buffer, |
|
388 | + $buf = substr($gi->memory_buffer, |
|
389 | 389 | 2 * $gi->record_length * $offset, |
390 | 390 | 2 * $gi->record_length); |
391 | 391 | } elseif ($gi->flags & GEOIP_SHARED_MEMORY) { |
392 | - $buf = @shmop_read ($gi->shmid, |
|
392 | + $buf = @shmop_read ($gi->shmid, |
|
393 | 393 | 2 * $gi->record_length * $offset, |
394 | 394 | 2 * $gi->record_length ); |
395 | 395 | } else { |
396 | - fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0 |
|
396 | + fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0 |
|
397 | 397 | or die("fseek failed"); |
398 | - $buf = fread($gi->filehandle, 2 * $gi->record_length); |
|
398 | + $buf = fread($gi->filehandle, 2 * $gi->record_length); |
|
399 | 399 | } |
400 | 400 | $x = array(0,0); |
401 | 401 | for ($i = 0; $i < 2; ++$i) { |
402 | - for ($j = 0; $j < $gi->record_length; ++$j) { |
|
402 | + for ($j = 0; $j < $gi->record_length; ++$j) { |
|
403 | 403 | $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8); |
404 | - } |
|
404 | + } |
|
405 | 405 | } |
406 | 406 | if ($ipnum & (1 << $depth)) { |
407 | - if ($x[1] >= $gi->databaseSegments) { |
|
407 | + if ($x[1] >= $gi->databaseSegments) { |
|
408 | 408 | return $x[1]; |
409 | - } |
|
410 | - $offset = $x[1]; |
|
409 | + } |
|
410 | + $offset = $x[1]; |
|
411 | 411 | } else { |
412 | - if ($x[0] >= $gi->databaseSegments) { |
|
412 | + if ($x[0] >= $gi->databaseSegments) { |
|
413 | 413 | return $x[0]; |
414 | - } |
|
415 | - $offset = $x[0]; |
|
414 | + } |
|
415 | + $offset = $x[0]; |
|
416 | + } |
|
416 | 417 | } |
417 | - } |
|
418 | - trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR); |
|
419 | - return false; |
|
418 | + trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR); |
|
419 | + return false; |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | function _get_org($gi,$ipnum){ |
423 | - $seek_org = _geoip_seek_country($gi,$ipnum); |
|
424 | - if ($seek_org == $gi->databaseSegments) { |
|
423 | + $seek_org = _geoip_seek_country($gi,$ipnum); |
|
424 | + if ($seek_org == $gi->databaseSegments) { |
|
425 | 425 | return NULL; |
426 | - } |
|
427 | - $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments; |
|
428 | - if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|
426 | + } |
|
427 | + $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments; |
|
428 | + if ($gi->flags & GEOIP_SHARED_MEMORY) { |
|
429 | 429 | $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH); |
430 | 430 | } else { |
431 | 431 | fseek($gi->filehandle, $record_pointer, SEEK_SET); |
432 | 432 | $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH); |
433 | - } |
|
434 | - $org_buf = substr($org_buf, 0, strpos($org_buf, 0)); |
|
435 | - return $org_buf; |
|
433 | + } |
|
434 | + $org_buf = substr($org_buf, 0, strpos($org_buf, 0)); |
|
435 | + return $org_buf; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | function geoip_org_by_addr ($gi,$addr) { |
439 | - if ($addr == NULL) { |
|
439 | + if ($addr == NULL) { |
|
440 | 440 | return 0; |
441 | - } |
|
442 | - $ipnum = ip2long($addr); |
|
443 | - return _get_org($gi, $ipnum); |
|
441 | + } |
|
442 | + $ipnum = ip2long($addr); |
|
443 | + return _get_org($gi, $ipnum); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | function _get_region($gi,$ipnum){ |
447 | - if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
447 | + if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
448 | 448 | $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0; |
449 | 449 | if ($seek_region >= 1000){ |
450 | - $country_code = "US"; |
|
451 | - $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65); |
|
450 | + $country_code = "US"; |
|
451 | + $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65); |
|
452 | 452 | } else { |
453 | 453 | $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region]; |
454 | - $region = ""; |
|
454 | + $region = ""; |
|
455 | 455 | } |
456 | - return array ($country_code,$region); |
|
456 | + return array ($country_code,$region); |
|
457 | 457 | } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
458 | 458 | $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1; |
459 | 459 | //print $seek_region; |
460 | 460 | if ($seek_region < US_OFFSET){ |
461 | - $country_code = ""; |
|
462 | - $region = ""; |
|
461 | + $country_code = ""; |
|
462 | + $region = ""; |
|
463 | 463 | } else if ($seek_region < CANADA_OFFSET) { |
464 | - $country_code = "US"; |
|
465 | - $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65); |
|
464 | + $country_code = "US"; |
|
465 | + $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65); |
|
466 | 466 | } else if ($seek_region < WORLD_OFFSET) { |
467 | - $country_code = "CA"; |
|
468 | - $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65); |
|
467 | + $country_code = "CA"; |
|
468 | + $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65); |
|
469 | 469 | } else { |
470 | 470 | $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE]; |
471 | - $region = ""; |
|
471 | + $region = ""; |
|
472 | + } |
|
473 | + return array ($country_code,$region); |
|
472 | 474 | } |
473 | - return array ($country_code,$region); |
|
474 | - } |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | function geoip_region_by_addr ($gi,$addr) { |
478 | - if ($addr == NULL) { |
|
478 | + if ($addr == NULL) { |
|
479 | 479 | return 0; |
480 | - } |
|
481 | - $ipnum = ip2long($addr); |
|
482 | - return _get_region($gi, $ipnum); |
|
480 | + } |
|
481 | + $ipnum = ip2long($addr); |
|
482 | + return _get_region($gi, $ipnum); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | function getdnsattributes ($l,$ip){ |
486 | - $r = new Net_DNS_Resolver(); |
|
487 | - $r->nameservers = array("ws1.maxmind.com"); |
|
488 | - $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); |
|
489 | - $str = is_object($p->answer[0])?$p->answer[0]->string():''; |
|
490 | - ereg("\"(.*)\"",$str,$regs); |
|
491 | - $str = $regs[1]; |
|
492 | - return $str; |
|
486 | + $r = new Net_DNS_Resolver(); |
|
487 | + $r->nameservers = array("ws1.maxmind.com"); |
|
488 | + $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); |
|
489 | + $str = is_object($p->answer[0])?$p->answer[0]->string():''; |
|
490 | + ereg("\"(.*)\"",$str,$regs); |
|
491 | + $str = $regs[1]; |
|
492 | + return $str; |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | ?> |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | shmop_close ($shmid); |
230 | 230 | } |
231 | 231 | |
232 | -function _setup_segments($gi){ |
|
232 | +function _setup_segments($gi) { |
|
233 | 233 | $gi->databaseType = GEOIP_COUNTRY_EDITION; |
234 | 234 | $gi->record_length = STANDARD_RECORD_LENGTH; |
235 | 235 | if ($gi->flags & GEOIP_SHARED_MEMORY) { |
@@ -241,18 +241,18 @@ discard block |
||
241 | 241 | $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1)); |
242 | 242 | $offset++; |
243 | 243 | |
244 | - if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
244 | + if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) { |
|
245 | 245 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; |
246 | - } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ |
|
246 | + } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
247 | 247 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
248 | 248 | } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)|| |
249 | 249 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) |
250 | 250 | || ($gi->databaseType == GEOIP_ORG_EDITION) |
251 | 251 | || ($gi->databaseType == GEOIP_ISP_EDITION) |
252 | - || ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
|
252 | + || ($gi->databaseType == GEOIP_ASNUM_EDITION)) { |
|
253 | 253 | $gi->databaseSegments = 0; |
254 | 254 | $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH); |
255 | - for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ |
|
255 | + for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++) { |
|
256 | 256 | $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); |
257 | 257 | } |
258 | 258 | if (($gi->databaseType == GEOIP_ORG_EDITION)|| |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | } |
268 | 268 | if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| |
269 | 269 | ($gi->databaseType == GEOIP_PROXY_EDITION)|| |
270 | - ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ |
|
270 | + ($gi->databaseType == GEOIP_NETSPEED_EDITION)) { |
|
271 | 271 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
272 | 272 | } |
273 | 273 | } else { |
@@ -275,21 +275,20 @@ discard block |
||
275 | 275 | fseek($gi->filehandle, -3, SEEK_END); |
276 | 276 | for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { |
277 | 277 | $delim = fread($gi->filehandle,3); |
278 | - if ($delim == (chr(255).chr(255).chr(255))){ |
|
278 | + if ($delim == (chr(255).chr(255).chr(255))) { |
|
279 | 279 | $gi->databaseType = ord(fread($gi->filehandle,1)); |
280 | - if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
280 | + if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) { |
|
281 | 281 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; |
282 | - } |
|
283 | - else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ |
|
282 | + } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
284 | 283 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
285 | - } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) || |
|
284 | + } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) || |
|
286 | 285 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || |
287 | 286 | ($gi->databaseType == GEOIP_ORG_EDITION) || |
288 | 287 | ($gi->databaseType == GEOIP_ISP_EDITION) || |
289 | - ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
|
288 | + ($gi->databaseType == GEOIP_ASNUM_EDITION)) { |
|
290 | 289 | $gi->databaseSegments = 0; |
291 | 290 | $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH); |
292 | - for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ |
|
291 | + for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++) { |
|
293 | 292 | $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); |
294 | 293 | } |
295 | 294 | if ($gi->databaseType == GEOIP_ORG_EDITION) { |
@@ -303,7 +302,7 @@ discard block |
||
303 | 302 | } |
304 | 303 | if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| |
305 | 304 | ($gi->databaseType == GEOIP_PROXY_EDITION)|| |
306 | - ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ |
|
305 | + ($gi->databaseType == GEOIP_NETSPEED_EDITION)) { |
|
307 | 306 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
308 | 307 | } |
309 | 308 | fseek($gi->filehandle,$filepos,SEEK_SET); |
@@ -419,7 +418,7 @@ discard block |
||
419 | 418 | return false; |
420 | 419 | } |
421 | 420 | |
422 | -function _get_org($gi,$ipnum){ |
|
421 | +function _get_org($gi,$ipnum) { |
|
423 | 422 | $seek_org = _geoip_seek_country($gi,$ipnum); |
424 | 423 | if ($seek_org == $gi->databaseSegments) { |
425 | 424 | return NULL; |
@@ -443,10 +442,10 @@ discard block |
||
443 | 442 | return _get_org($gi, $ipnum); |
444 | 443 | } |
445 | 444 | |
446 | -function _get_region($gi,$ipnum){ |
|
447 | - if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
445 | +function _get_region($gi,$ipnum) { |
|
446 | + if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) { |
|
448 | 447 | $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0; |
449 | - if ($seek_region >= 1000){ |
|
448 | + if ($seek_region >= 1000) { |
|
450 | 449 | $country_code = "US"; |
451 | 450 | $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65); |
452 | 451 | } else { |
@@ -454,10 +453,10 @@ discard block |
||
454 | 453 | $region = ""; |
455 | 454 | } |
456 | 455 | return array ($country_code,$region); |
457 | - } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
456 | + } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
458 | 457 | $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1; |
459 | 458 | //print $seek_region; |
460 | - if ($seek_region < US_OFFSET){ |
|
459 | + if ($seek_region < US_OFFSET) { |
|
461 | 460 | $country_code = ""; |
462 | 461 | $region = ""; |
463 | 462 | } else if ($seek_region < CANADA_OFFSET) { |
@@ -482,7 +481,7 @@ discard block |
||
482 | 481 | return _get_region($gi, $ipnum); |
483 | 482 | } |
484 | 483 | |
485 | -function getdnsattributes ($l,$ip){ |
|
484 | +function getdnsattributes ($l,$ip) { |
|
486 | 485 | $r = new Net_DNS_Resolver(); |
487 | 486 | $r->nameservers = array("ws1.maxmind.com"); |
488 | 487 | $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | function _get_org($gi,$ipnum){ |
423 | 423 | $seek_org = _geoip_seek_country($gi,$ipnum); |
424 | 424 | if ($seek_org == $gi->databaseSegments) { |
425 | - return NULL; |
|
425 | + return null; |
|
426 | 426 | } |
427 | 427 | $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments; |
428 | 428 | if ($gi->flags & GEOIP_SHARED_MEMORY) { |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | } |
437 | 437 | |
438 | 438 | function geoip_org_by_addr ($gi,$addr) { |
439 | - if ($addr == NULL) { |
|
439 | + if ($addr == null) { |
|
440 | 440 | return 0; |
441 | 441 | } |
442 | 442 | $ipnum = ip2long($addr); |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | function geoip_region_by_addr ($gi,$addr) { |
478 | - if ($addr == NULL) { |
|
478 | + if ($addr == null) { |
|
479 | 479 | return 0; |
480 | 480 | } |
481 | 481 | $ipnum = ip2long($addr); |
@@ -138,25 +138,25 @@ discard block |
||
138 | 138 | "VU", "WF", "WS", "YE", "YT", "CS", "ZA", "ZM", "ZR", "ZW", "A1", "A2", "O1" |
139 | 139 | ); |
140 | 140 | var $GEOIP_COUNTRY_CODES3 = array( |
141 | -"","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG", |
|
142 | -"ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI", |
|
143 | -"BEN","BMU","BRN","BOL","BRA","BHS","BTN","BV","BWA","BLR","BLZ","CAN","CC", |
|
144 | -"COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV", |
|
145 | -"CX","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH", |
|
146 | -"ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD", |
|
147 | -"GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","GS","GTM","GUM", |
|
148 | -"GNB","GUY","HKG","HM","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IO", |
|
149 | -"IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA", |
|
150 | -"PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU", |
|
151 | -"LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC", |
|
152 | -"MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL", |
|
153 | -"NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER", |
|
154 | -"PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT", |
|
155 | -"REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM", |
|
156 | -"SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","TF", |
|
157 | -"TGO","THA","TJK","TKL","TLS","TKM","TUN","TON","TUR","TTO","TUV","TWN","TZA", |
|
158 | -"UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT", |
|
159 | - "WLF","WSM","YEM","YT","SCG","ZAF","ZMB","ZR","ZWE","A1","A2","O1" |
|
141 | +"", "AP", "EU", "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", "ANT", "AGO", "AQ", "ARG", |
|
142 | +"ASM", "AUT", "AUS", "ABW", "AZE", "BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI", |
|
143 | +"BEN", "BMU", "BRN", "BOL", "BRA", "BHS", "BTN", "BV", "BWA", "BLR", "BLZ", "CAN", "CC", |
|
144 | +"COD", "CAF", "COG", "CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI", "CUB", "CPV", |
|
145 | +"CX", "CYP", "CZE", "DEU", "DJI", "DNK", "DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH", |
|
146 | +"ERI", "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA", "FX", "GAB", "GBR", "GRD", |
|
147 | +"GEO", "GUF", "GHA", "GIB", "GRL", "GMB", "GIN", "GLP", "GNQ", "GRC", "GS", "GTM", "GUM", |
|
148 | +"GNB", "GUY", "HKG", "HM", "HND", "HRV", "HTI", "HUN", "IDN", "IRL", "ISR", "IND", "IO", |
|
149 | +"IRQ", "IRN", "ISL", "ITA", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR", "COM", "KNA", |
|
150 | +"PRK", "KOR", "KWT", "CYM", "KAZ", "LAO", "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU", |
|
151 | +"LUX", "LVA", "LBY", "MAR", "MCO", "MDA", "MDG", "MHL", "MKD", "MLI", "MMR", "MNG", "MAC", |
|
152 | +"MNP", "MTQ", "MRT", "MSR", "MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM", "NCL", |
|
153 | +"NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL", "NRU", "NIU", "NZL", "OMN", "PAN", "PER", |
|
154 | +"PYF", "PNG", "PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT", "PLW", "PRY", "QAT", |
|
155 | +"REU", "ROU", "RUS", "RWA", "SAU", "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM", |
|
156 | +"SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "STP", "SLV", "SYR", "SWZ", "TCA", "TCD", "TF", |
|
157 | +"TGO", "THA", "TJK", "TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV", "TWN", "TZA", |
|
158 | +"UKR", "UGA", "UM", "USA", "URY", "UZB", "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", |
|
159 | + "WLF", "WSM", "YEM", "YT", "SCG", "ZAF", "ZMB", "ZR", "ZWE", "A1", "A2", "O1" |
|
160 | 160 | ); |
161 | 161 | var $GEOIP_COUNTRY_NAMES = array( |
162 | 162 | "", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates", |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | Grenadines", "Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.", |
209 | 209 | "Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte", |
210 | 210 | "Serbia and Montenegro", "South Africa", "Zambia", "Zaire", "Zimbabwe", |
211 | -"Anonymous Proxy","Satellite Provider","Other" |
|
211 | +"Anonymous Proxy", "Satellite Provider", "Other" |
|
212 | 212 | ); |
213 | 213 | } |
214 | -function geoip_load_shared_mem ($file) { |
|
214 | +function geoip_load_shared_mem($file) { |
|
215 | 215 | |
216 | 216 | $fp = fopen($file, "rb"); |
217 | 217 | if (!$fp) { |
@@ -220,42 +220,42 @@ discard block |
||
220 | 220 | } |
221 | 221 | $s_array = fstat($fp); |
222 | 222 | $size = $s_array['size']; |
223 | - if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) { |
|
224 | - shmop_delete ($shmid); |
|
225 | - shmop_close ($shmid); |
|
223 | + if ($shmid = @shmop_open(GEOIP_SHM_KEY, "w", 0, 0)) { |
|
224 | + shmop_delete($shmid); |
|
225 | + shmop_close($shmid); |
|
226 | 226 | } |
227 | - $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size); |
|
228 | - shmop_write ($shmid, fread($fp, $size), 0); |
|
229 | - shmop_close ($shmid); |
|
227 | + $shmid = shmop_open(GEOIP_SHM_KEY, "c", 0644, $size); |
|
228 | + shmop_write($shmid, fread($fp, $size), 0); |
|
229 | + shmop_close($shmid); |
|
230 | 230 | } |
231 | 231 | |
232 | -function _setup_segments($gi){ |
|
232 | +function _setup_segments($gi) { |
|
233 | 233 | $gi->databaseType = GEOIP_COUNTRY_EDITION; |
234 | 234 | $gi->record_length = STANDARD_RECORD_LENGTH; |
235 | 235 | if ($gi->flags & GEOIP_SHARED_MEMORY) { |
236 | - $offset = @shmop_size ($gi->shmid) - 3; |
|
236 | + $offset = @shmop_size($gi->shmid) - 3; |
|
237 | 237 | for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { |
238 | - $delim = @shmop_read ($gi->shmid, $offset, 3); |
|
238 | + $delim = @shmop_read($gi->shmid, $offset, 3); |
|
239 | 239 | $offset += 3; |
240 | 240 | if ($delim == (chr(255).chr(255).chr(255))) { |
241 | - $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1)); |
|
241 | + $gi->databaseType = ord(@shmop_read($gi->shmid, $offset, 1)); |
|
242 | 242 | $offset++; |
243 | 243 | |
244 | - if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
244 | + if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) { |
|
245 | 245 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; |
246 | - } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ |
|
246 | + } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
247 | 247 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
248 | - } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)|| |
|
248 | + } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) || |
|
249 | 249 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) |
250 | 250 | || ($gi->databaseType == GEOIP_ORG_EDITION) |
251 | 251 | || ($gi->databaseType == GEOIP_ISP_EDITION) |
252 | - || ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
|
252 | + || ($gi->databaseType == GEOIP_ASNUM_EDITION)) { |
|
253 | 253 | $gi->databaseSegments = 0; |
254 | - $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH); |
|
255 | - for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ |
|
256 | - $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); |
|
254 | + $buf = @shmop_read($gi->shmid, $offset, SEGMENT_RECORD_LENGTH); |
|
255 | + for ($j = 0; $j < SEGMENT_RECORD_LENGTH; $j++) { |
|
256 | + $gi->databaseSegments += (ord($buf[$j]) << ($j*8)); |
|
257 | 257 | } |
258 | - if (($gi->databaseType == GEOIP_ORG_EDITION)|| |
|
258 | + if (($gi->databaseType == GEOIP_ORG_EDITION) || |
|
259 | 259 | ($gi->databaseType == GEOIP_ISP_EDITION)) { |
260 | 260 | $gi->record_length = ORG_RECORD_LENGTH; |
261 | 261 | } |
@@ -265,32 +265,32 @@ discard block |
||
265 | 265 | $offset -= 4; |
266 | 266 | } |
267 | 267 | } |
268 | - if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| |
|
269 | - ($gi->databaseType == GEOIP_PROXY_EDITION)|| |
|
270 | - ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ |
|
268 | + if (($gi->databaseType == GEOIP_COUNTRY_EDITION) || |
|
269 | + ($gi->databaseType == GEOIP_PROXY_EDITION) || |
|
270 | + ($gi->databaseType == GEOIP_NETSPEED_EDITION)) { |
|
271 | 271 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
272 | 272 | } |
273 | 273 | } else { |
274 | 274 | $filepos = ftell($gi->filehandle); |
275 | 275 | fseek($gi->filehandle, -3, SEEK_END); |
276 | 276 | for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { |
277 | - $delim = fread($gi->filehandle,3); |
|
278 | - if ($delim == (chr(255).chr(255).chr(255))){ |
|
279 | - $gi->databaseType = ord(fread($gi->filehandle,1)); |
|
280 | - if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
277 | + $delim = fread($gi->filehandle, 3); |
|
278 | + if ($delim == (chr(255).chr(255).chr(255))) { |
|
279 | + $gi->databaseType = ord(fread($gi->filehandle, 1)); |
|
280 | + if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) { |
|
281 | 281 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0; |
282 | 282 | } |
283 | - else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){ |
|
283 | + else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
284 | 284 | $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1; |
285 | - } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) || |
|
285 | + } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) || |
|
286 | 286 | ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || |
287 | 287 | ($gi->databaseType == GEOIP_ORG_EDITION) || |
288 | 288 | ($gi->databaseType == GEOIP_ISP_EDITION) || |
289 | - ($gi->databaseType == GEOIP_ASNUM_EDITION)){ |
|
289 | + ($gi->databaseType == GEOIP_ASNUM_EDITION)) { |
|
290 | 290 | $gi->databaseSegments = 0; |
291 | - $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH); |
|
292 | - for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){ |
|
293 | - $gi->databaseSegments += (ord($buf[$j]) << ($j * 8)); |
|
291 | + $buf = fread($gi->filehandle, SEGMENT_RECORD_LENGTH); |
|
292 | + for ($j = 0; $j < SEGMENT_RECORD_LENGTH; $j++) { |
|
293 | + $gi->databaseSegments += (ord($buf[$j]) << ($j*8)); |
|
294 | 294 | } |
295 | 295 | if ($gi->databaseType == GEOIP_ORG_EDITION) { |
296 | 296 | $gi->record_length = ORG_RECORD_LENGTH; |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | fseek($gi->filehandle, -4, SEEK_CUR); |
302 | 302 | } |
303 | 303 | } |
304 | - if (($gi->databaseType == GEOIP_COUNTRY_EDITION)|| |
|
305 | - ($gi->databaseType == GEOIP_PROXY_EDITION)|| |
|
306 | - ($gi->databaseType == GEOIP_NETSPEED_EDITION)){ |
|
304 | + if (($gi->databaseType == GEOIP_COUNTRY_EDITION) || |
|
305 | + ($gi->databaseType == GEOIP_PROXY_EDITION) || |
|
306 | + ($gi->databaseType == GEOIP_NETSPEED_EDITION)) { |
|
307 | 307 | $gi->databaseSegments = GEOIP_COUNTRY_BEGIN; |
308 | 308 | } |
309 | - fseek($gi->filehandle,$filepos,SEEK_SET); |
|
309 | + fseek($gi->filehandle, $filepos, SEEK_SET); |
|
310 | 310 | } |
311 | 311 | return $gi; |
312 | 312 | } |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | $gi = new GeoIP; |
316 | 316 | $gi->flags = $flags; |
317 | 317 | if ($gi->flags & GEOIP_SHARED_MEMORY) { |
318 | - $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0); |
|
318 | + $gi->shmid = @shmop_open(GEOIP_SHM_KEY, "a", 0, 0); |
|
319 | 319 | } else { |
320 | - $gi->filehandle = fopen($filename,"rb"); |
|
320 | + $gi->filehandle = fopen($filename, "rb"); |
|
321 | 321 | if ($gi->flags & GEOIP_MEMORY_CACHE) { |
322 | 322 | $s_array = fstat($gi->filehandle); |
323 | 323 | $gi->memory_buffer = fread($gi->filehandle, $s_array[size]); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | } |
346 | 346 | |
347 | 347 | function geoip_country_code_by_name($gi, $name) { |
348 | - $country_id = geoip_country_id_by_name($gi,$name); |
|
348 | + $country_id = geoip_country_id_by_name($gi, $name); |
|
349 | 349 | if ($country_id !== false) { |
350 | 350 | return $gi->GEOIP_COUNTRY_CODES[$country_id]; |
351 | 351 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | function geoip_country_name_by_name($gi, $name) { |
356 | - $country_id = geoip_country_id_by_name($gi,$name); |
|
356 | + $country_id = geoip_country_id_by_name($gi, $name); |
|
357 | 357 | if ($country_id !== false) { |
358 | 358 | return $gi->GEOIP_COUNTRY_NAMES[$country_id]; |
359 | 359 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | } |
367 | 367 | |
368 | 368 | function geoip_country_code_by_addr($gi, $addr) { |
369 | - $country_id = geoip_country_id_by_addr($gi,$addr); |
|
369 | + $country_id = geoip_country_id_by_addr($gi, $addr); |
|
370 | 370 | if ($country_id !== false) { |
371 | 371 | return $gi->GEOIP_COUNTRY_CODES[$country_id]; |
372 | 372 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | } |
375 | 375 | |
376 | 376 | function geoip_country_name_by_addr($gi, $addr) { |
377 | - $country_id = geoip_country_id_by_addr($gi,$addr); |
|
377 | + $country_id = geoip_country_id_by_addr($gi, $addr); |
|
378 | 378 | if ($country_id !== false) { |
379 | 379 | return $gi->GEOIP_COUNTRY_NAMES[$country_id]; |
380 | 380 | } |
@@ -386,21 +386,21 @@ discard block |
||
386 | 386 | for ($depth = 31; $depth >= 0; --$depth) { |
387 | 387 | if ($gi->flags & GEOIP_MEMORY_CACHE) { |
388 | 388 | $buf = substr($gi->memory_buffer, |
389 | - 2 * $gi->record_length * $offset, |
|
390 | - 2 * $gi->record_length); |
|
389 | + 2*$gi->record_length*$offset, |
|
390 | + 2*$gi->record_length); |
|
391 | 391 | } elseif ($gi->flags & GEOIP_SHARED_MEMORY) { |
392 | - $buf = @shmop_read ($gi->shmid, |
|
393 | - 2 * $gi->record_length * $offset, |
|
394 | - 2 * $gi->record_length ); |
|
392 | + $buf = @shmop_read($gi->shmid, |
|
393 | + 2*$gi->record_length*$offset, |
|
394 | + 2*$gi->record_length); |
|
395 | 395 | } else { |
396 | - fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0 |
|
396 | + fseek($gi->filehandle, 2*$gi->record_length*$offset, SEEK_SET) == 0 |
|
397 | 397 | or die("fseek failed"); |
398 | - $buf = fread($gi->filehandle, 2 * $gi->record_length); |
|
398 | + $buf = fread($gi->filehandle, 2*$gi->record_length); |
|
399 | 399 | } |
400 | - $x = array(0,0); |
|
400 | + $x = array(0, 0); |
|
401 | 401 | for ($i = 0; $i < 2; ++$i) { |
402 | 402 | for ($j = 0; $j < $gi->record_length; ++$j) { |
403 | - $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8); |
|
403 | + $x[$i] += ord($buf[$gi->record_length*$i + $j]) << ($j*8); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | if ($ipnum & (1 << $depth)) { |
@@ -419,23 +419,23 @@ discard block |
||
419 | 419 | return false; |
420 | 420 | } |
421 | 421 | |
422 | -function _get_org($gi,$ipnum){ |
|
423 | - $seek_org = _geoip_seek_country($gi,$ipnum); |
|
422 | +function _get_org($gi, $ipnum) { |
|
423 | + $seek_org = _geoip_seek_country($gi, $ipnum); |
|
424 | 424 | if ($seek_org == $gi->databaseSegments) { |
425 | 425 | return NULL; |
426 | 426 | } |
427 | - $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments; |
|
427 | + $record_pointer = $seek_org + (2*$gi->record_length - 1)*$gi->databaseSegments; |
|
428 | 428 | if ($gi->flags & GEOIP_SHARED_MEMORY) { |
429 | - $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH); |
|
429 | + $org_buf = @shmop_read($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH); |
|
430 | 430 | } else { |
431 | 431 | fseek($gi->filehandle, $record_pointer, SEEK_SET); |
432 | - $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH); |
|
432 | + $org_buf = fread($gi->filehandle, MAX_ORG_RECORD_LENGTH); |
|
433 | 433 | } |
434 | 434 | $org_buf = substr($org_buf, 0, strpos($org_buf, 0)); |
435 | 435 | return $org_buf; |
436 | 436 | } |
437 | 437 | |
438 | -function geoip_org_by_addr ($gi,$addr) { |
|
438 | +function geoip_org_by_addr($gi, $addr) { |
|
439 | 439 | if ($addr == NULL) { |
440 | 440 | return 0; |
441 | 441 | } |
@@ -443,38 +443,38 @@ discard block |
||
443 | 443 | return _get_org($gi, $ipnum); |
444 | 444 | } |
445 | 445 | |
446 | -function _get_region($gi,$ipnum){ |
|
447 | - if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){ |
|
448 | - $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0; |
|
449 | - if ($seek_region >= 1000){ |
|
446 | +function _get_region($gi, $ipnum) { |
|
447 | + if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) { |
|
448 | + $seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV0; |
|
449 | + if ($seek_region >= 1000) { |
|
450 | 450 | $country_code = "US"; |
451 | - $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65); |
|
451 | + $region = chr(($seek_region - 1000)/26 + 65).chr(($seek_region - 1000)%26 + 65); |
|
452 | 452 | } else { |
453 | 453 | $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region]; |
454 | 454 | $region = ""; |
455 | 455 | } |
456 | - return array ($country_code,$region); |
|
457 | - } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
458 | - $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1; |
|
456 | + return array($country_code, $region); |
|
457 | + } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) { |
|
458 | + $seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV1; |
|
459 | 459 | //print $seek_region; |
460 | - if ($seek_region < US_OFFSET){ |
|
460 | + if ($seek_region < US_OFFSET) { |
|
461 | 461 | $country_code = ""; |
462 | 462 | $region = ""; |
463 | 463 | } else if ($seek_region < CANADA_OFFSET) { |
464 | 464 | $country_code = "US"; |
465 | - $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65); |
|
465 | + $region = chr(($seek_region - US_OFFSET)/26 + 65).chr(($seek_region - US_OFFSET)%26 + 65); |
|
466 | 466 | } else if ($seek_region < WORLD_OFFSET) { |
467 | 467 | $country_code = "CA"; |
468 | - $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65); |
|
468 | + $region = chr(($seek_region - CANADA_OFFSET)/26 + 65).chr(($seek_region - CANADA_OFFSET)%26 + 65); |
|
469 | 469 | } else { |
470 | - $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE]; |
|
470 | + $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET)/FIPS_RANGE]; |
|
471 | 471 | $region = ""; |
472 | 472 | } |
473 | - return array ($country_code,$region); |
|
473 | + return array($country_code, $region); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | |
477 | -function geoip_region_by_addr ($gi,$addr) { |
|
477 | +function geoip_region_by_addr($gi, $addr) { |
|
478 | 478 | if ($addr == NULL) { |
479 | 479 | return 0; |
480 | 480 | } |
@@ -482,12 +482,12 @@ discard block |
||
482 | 482 | return _get_region($gi, $ipnum); |
483 | 483 | } |
484 | 484 | |
485 | -function getdnsattributes ($l,$ip){ |
|
485 | +function getdnsattributes($l, $ip) { |
|
486 | 486 | $r = new Net_DNS_Resolver(); |
487 | 487 | $r->nameservers = array("ws1.maxmind.com"); |
488 | - $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); |
|
489 | - $str = is_object($p->answer[0])?$p->answer[0]->string():''; |
|
490 | - ereg("\"(.*)\"",$str,$regs); |
|
488 | + $p = $r->search($l.".".$ip.".s.maxmind.com", "TXT", "IN"); |
|
489 | + $str = is_object($p->answer[0]) ? $p->answer[0]->string() : ''; |
|
490 | + ereg("\"(.*)\"", $str, $regs); |
|
491 | 491 | $str = $regs[1]; |
492 | 492 | return $str; |
493 | 493 | } |
@@ -88,18 +88,18 @@ |
||
88 | 88 | $errno = 0; |
89 | 89 | $errstr = ''; |
90 | 90 | |
91 | - if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) { |
|
91 | + if (false === $this->socket->fsockopen('ssl://'.self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) { |
|
92 | 92 | return self::BAD_REQUEST; |
93 | 93 | } |
94 | 94 | |
95 | 95 | $content = $params->toQueryString(); |
96 | 96 | |
97 | - $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n"; |
|
98 | - $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n"; |
|
97 | + $request = "POST ".self::SITE_VERIFY_PATH." HTTP/1.1\r\n"; |
|
98 | + $request .= "Host: ".self::RECAPTCHA_HOST."\r\n"; |
|
99 | 99 | $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
100 | - $request .= "Content-length: " . strlen($content) . "\r\n"; |
|
100 | + $request .= "Content-length: ".strlen($content)."\r\n"; |
|
101 | 101 | $request .= "Connection: close\r\n\r\n"; |
102 | - $request .= $content . "\r\n\r\n"; |
|
102 | + $request .= $content."\r\n\r\n"; |
|
103 | 103 | |
104 | 104 | $this->socket->fwrite($request); |
105 | 105 | $response = ''; |
@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | * instead of get_file_contents(). This is to account for people who may be on |
35 | 35 | * servers where allow_furl_open is disabled. |
36 | 36 | */ |
37 | -class SocketPost implements RequestMethod |
|
38 | -{ |
|
37 | +class SocketPost implements RequestMethod { |
|
39 | 38 | /** |
40 | 39 | * reCAPTCHA service host. |
41 | 40 | * @const string |
@@ -68,8 +67,7 @@ discard block |
||
68 | 67 | * |
69 | 68 | * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing |
70 | 69 | */ |
71 | - public function __construct(Socket $socket = null) |
|
72 | - { |
|
70 | + public function __construct(Socket $socket = null) { |
|
73 | 71 | if (!is_null($socket)) { |
74 | 72 | $this->socket = $socket; |
75 | 73 | } else { |
@@ -83,8 +81,7 @@ discard block |
||
83 | 81 | * @param RequestParameters $params Request parameters |
84 | 82 | * @return string Body of the reCAPTCHA response |
85 | 83 | */ |
86 | - public function submit(RequestParameters $params) |
|
87 | - { |
|
84 | + public function submit(RequestParameters $params) { |
|
88 | 85 | $errno = 0; |
89 | 86 | $errstr = ''; |
90 | 87 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | function send_friend_request_email($src_user, $dest_user, $msg) { |
53 | - $message = " |
|
53 | + $message = " |
|
54 | 54 | $src_user->name has added you as a friend at ".PROJECT.". |
55 | 55 | "; |
56 | 56 | if (strlen($msg)) { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | function send_friend_accept_email($dest_user, $src_user, $msg) { |
75 | - $message = " |
|
75 | + $message = " |
|
76 | 76 | $dest_user->name has confirmed you as a friend at ".PROJECT.". |
77 | 77 | "; |
78 | 78 | if (strlen($msg)) { |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | // Some of this should be merged with translation.inc |
21 | 21 | |
22 | 22 | function get_lang_list() { |
23 | - if (isset($_COOKIE['lang'])){ |
|
23 | + if (isset($_COOKIE['lang'])) { |
|
24 | 24 | $language_string = $_COOKIE['lang'].","; |
25 | 25 | } else { |
26 | 26 | $language_string = ''; |
@@ -28,28 +28,28 @@ discard block |
||
28 | 28 | if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) { |
29 | 29 | $language_string .= strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]); |
30 | 30 | } |
31 | - $client_languages = explode(",",$language_string); |
|
31 | + $client_languages = explode(",", $language_string); |
|
32 | 32 | |
33 | 33 | $lang_list = array(); |
34 | - for ($i=0; $i<sizeof($client_languages); $i++) { |
|
35 | - if ((strlen($client_languages[$i])>2) |
|
36 | - && (substr($client_languages[$i],2,1)=="_" || substr($client_languages[$i],2,1)=="-")) |
|
34 | + for ($i = 0; $i < sizeof($client_languages); $i++) { |
|
35 | + if ((strlen($client_languages[$i]) > 2) |
|
36 | + && (substr($client_languages[$i], 2, 1) == "_" || substr($client_languages[$i], 2, 1) == "-")) |
|
37 | 37 | { |
38 | 38 | // If this is defined as primary-secondary, represent it as xx_YY |
39 | 39 | // |
40 | 40 | $language = substr( |
41 | - $client_languages[$i],0,2)."_".strtoupper(substr($client_languages[$i],3,2) |
|
41 | + $client_languages[$i], 0, 2)."_".strtoupper(substr($client_languages[$i], 3, 2) |
|
42 | 42 | ); |
43 | 43 | $lang_list[] = $language; |
44 | 44 | |
45 | 45 | // And also check for the primary language |
46 | 46 | // |
47 | - $language = substr($client_languages[$i],0,2); |
|
47 | + $language = substr($client_languages[$i], 0, 2); |
|
48 | 48 | $lang_list[] = $language; |
49 | 49 | } else { |
50 | 50 | // else just use xx |
51 | 51 | // |
52 | - $language = substr($client_languages[$i],0,2); |
|
52 | + $language = substr($client_languages[$i], 0, 2); |
|
53 | 53 | $lang_list[] = $language; |
54 | 54 | } |
55 | 55 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | // Some of this should be merged with translation.inc |
21 | 21 | |
22 | 22 | function get_lang_list() { |
23 | - if (isset($_COOKIE['lang'])){ |
|
23 | + if (isset($_COOKIE['lang'])) { |
|
24 | 24 | $language_string = $_COOKIE['lang'].","; |
25 | 25 | } else { |
26 | 26 | $language_string = ''; |
@@ -33,8 +33,7 @@ discard block |
||
33 | 33 | $lang_list = array(); |
34 | 34 | for ($i=0; $i<sizeof($client_languages); $i++) { |
35 | 35 | if ((strlen($client_languages[$i])>2) |
36 | - && (substr($client_languages[$i],2,1)=="_" || substr($client_languages[$i],2,1)=="-")) |
|
37 | - { |
|
36 | + && (substr($client_languages[$i],2,1)=="_" || substr($client_languages[$i],2,1)=="-")) { |
|
38 | 37 | // If this is defined as primary-secondary, represent it as xx_YY |
39 | 38 | // |
40 | 39 | $language = substr( |
@@ -46,7 +46,7 @@ |
||
46 | 46 | return; |
47 | 47 | } |
48 | 48 | |
49 | - $news_date=gmdate('D, d M Y H:i:s',$notify->create_time) . ' GMT'; |
|
49 | + $news_date = gmdate('D, d M Y H:i:s', $notify->create_time).' GMT'; |
|
50 | 50 | echo "<item> |
51 | 51 | <title><![CDATA[$title]]></title> |
52 | 52 | <guid>".url_base()."_notify_$notify->id</guid> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | $master_url_enc = urlencode($master_url); |
28 | 28 | $response = akismet_request("key=$key&blog=$master_url_enc", "rest.akismet.com", "/1.1/verify-key"); |
29 | - if ("valid" == $response[1] ) { |
|
29 | + if ("valid" == $response[1]) { |
|
30 | 30 | $post = urlencode($post); |
31 | 31 | $ip = urlencode($_SERVER['REMOTE_ADDR']); |
32 | 32 | $referrer = urlencode($_SERVER['HTTP_REFERER']); |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | $http_request = "POST $path HTTP/1.0\r\n"; |
57 | 57 | $http_request .= "Host: $host\r\n"; |
58 | 58 | $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n"; |
59 | - $http_request .= "Content-Length: " . strlen($request) . "\r\n"; |
|
59 | + $http_request .= "Content-Length: ".strlen($request)."\r\n"; |
|
60 | 60 | $http_request .= "User-Agent: BOINC | Akismet 1.1\r\n"; |
61 | 61 | $http_request .= "\r\n"; |
62 | 62 | $http_request .= $request; |
63 | 63 | |
64 | 64 | $response = ''; |
65 | - if( false !== ( $fs = @fsockopen($host, $port, $errno, $errstr, 3) ) ) { |
|
65 | + if (false !== ($fs = @fsockopen($host, $port, $errno, $errstr, 3))) { |
|
66 | 66 | fwrite($fs, $http_request); |
67 | - while ( !feof($fs) ) |
|
67 | + while (!feof($fs)) |
|
68 | 68 | $response .= fgets($fs, 1160); // One TCP-IP packet |
69 | 69 | fclose($fs); |
70 | 70 | $response = explode("\r\n\r\n", $response, 2); |
@@ -42,7 +42,8 @@ discard block |
||
42 | 42 | |
43 | 43 | $response = akismet_request($request, "$key.rest.akismet.com", "/1.1/comment-check"); |
44 | 44 | |
45 | - if ("true" == $response[1]) { // Akismet says it's spam |
|
45 | + if ("true" == $response[1]) { |
|
46 | +// Akismet says it's spam |
|
46 | 47 | return false; |
47 | 48 | } else { |
48 | 49 | return true; |
@@ -64,8 +65,10 @@ discard block |
||
64 | 65 | $response = ''; |
65 | 66 | if( false !== ( $fs = @fsockopen($host, $port, $errno, $errstr, 3) ) ) { |
66 | 67 | fwrite($fs, $http_request); |
67 | - while ( !feof($fs) ) |
|
68 | - $response .= fgets($fs, 1160); // One TCP-IP packet |
|
68 | + while ( !feof($fs) ) { |
|
69 | + $response .= fgets($fs, 1160); |
|
70 | + } |
|
71 | + // One TCP-IP packet |
|
69 | 72 | fclose($fs); |
70 | 73 | $response = explode("\r\n\r\n", $response, 2); |
71 | 74 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | function akismet_request($request, $host, $path, $port = 80) { |
56 | - $http_request = "POST $path HTTP/1.0\r\n"; |
|
56 | + $http_request = "post $path HTTP/1.0\r\n"; |
|
57 | 57 | $http_request .= "Host: $host\r\n"; |
58 | 58 | $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n"; |
59 | 59 | $http_request .= "Content-Length: " . strlen($request) . "\r\n"; |
@@ -7,15 +7,15 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | class views_handler_argument_boincteam_id extends views_handler_argument_numeric { |
10 | - function construct() { |
|
10 | + function construct() { |
|
11 | 11 | parent::construct(); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - function set_argument($arg) { |
|
14 | + function set_argument($arg) { |
|
15 | 15 | // When setting the ID argument, convert to BOINC ID |
16 | 16 | $id = is_numeric($arg) ? $arg : 0; |
17 | 17 | $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = %d", $id)); |
18 | 18 | $this->argument = $boinc_id; |
19 | 19 | return $this->validate_arg($boinc_id); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -7,15 +7,15 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | class views_handler_argument_boincuser_id extends views_handler_argument_numeric { |
10 | - function construct() { |
|
10 | + function construct() { |
|
11 | 11 | parent::construct(); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - function set_argument($arg) { |
|
14 | + function set_argument($arg) { |
|
15 | 15 | // When setting the ID argument, convert to BOINC ID |
16 | 16 | $id = is_numeric($arg) ? $arg : 0; |
17 | 17 | $boinc_id = db_result(db_query("SELECT boinc_id FROM {boincuser} WHERE uid = %d", $id)); |
18 | 18 | $this->argument = $boinc_id; |
19 | 19 | return $this->validate_arg($boinc_id); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |
@@ -7,15 +7,15 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | class views_handler_argument_boincteam_id extends views_handler_argument_numeric { |
10 | - function construct() { |
|
10 | + function construct() { |
|
11 | 11 | parent::construct(); |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - function set_argument($arg) { |
|
14 | + function set_argument($arg) { |
|
15 | 15 | // When setting the ID argument, convert to BOINC ID |
16 | 16 | $id = is_numeric($arg) ? $arg : 0; |
17 | 17 | $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = %d", $id)); |
18 | 18 | $this->argument = $boinc_id; |
19 | 19 | return $this->validate_arg($boinc_id); |
20 | - } |
|
20 | + } |
|
21 | 21 | } |