Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: [php] B³±d w skrypcie
Forum PHP.pl > Forum > Przedszkole
PIKeR
Witam,
kumpel podes³a³ mi gotowy skrypt do zainstalowania, niestety - jest w nim b³±d:
Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in /search/includes/ip.php on line 11
Proszê o pomoc, o to owy plik:
  1. <?php
  2.  
  3. define('SMALL', 0);
  4. define('BIG',  1);
  5.  
  6. class ClientInfo {
  7.  
  8. var $flag_dirs = array(SMALL => 'assets/flags/small', BIG => 'assets/flags/big');
  9. var $flag_ext = 'png';
  10.  
  11. cfunction getctrybycode ($code) {
  12. $countryArray = array();
  13. $input = "includes/countries.dat";
  14. $fd = fopen($input,"r") or die("Error: cannot open $input!");
  15. while ($buffer = fgets($fd,4096))
  16. {
  17. $buffer = preg_replace("/n/","",$buffer);  //chomp()
  18. $pieces = explode(",",$buffer);
  19. $countryCode = $pieces[0]; $countryName = $pieces[1];
  20. $countryArray[$countryCode] = $countryName;
  21. }
  22. fclose($fd);
  23. return $countryArray[$code];
  24. }
  25.  
  26.  
  27. cfunction getctrybyhost($hostname) {
  28.  
  29. return($this->getctrybycode($this->getctrycodebyhost($hostname)));
  30. }
  31.  
  32. cfunction getctrycodebyhost($hostname) {
  33. return(substr(strrchr($hostname,'.'),1));
  34. }
  35.  
  36. cfunction MaskOtherIP($IP) {
  37.  
  38. if($IP==getenv("REMOTE_ADDR"))
  39. return($IP);
  40.  
  41.  $IP=strtr($IP,"0123456789","##########");
  42.  return($IP);
  43. }
  44.  
  45. cfunction getClientIP() {
  46. $IP = getenv('REMOTE_ADDR');
  47. return $IP;
  48. }
  49.  
  50. cfunction getClientHostname()
  51. {
  52. $error = 0;
  53. $IP = $this->getClientIP();
  54. $hostname = gethostbyaddr($IP);
  55.  
  56.  if(!strcmp($hostname,$IP)) $error = 1; // if failure, gethostbyaddr() returns the IP
  57. if (!$error) //if no error
  58. {
  59. return $hostname;
  60. }
  61. //else
  62. return "";
  63. }
  64.  
  65. cfunction getClientCountry()
  66. {
  67. $error = 0;
  68. $hostname = $this->getClientHostname();
  69. if (!strcmp($hostname,"")) $error = 1;
  70. if (!$error)
  71. {
  72. $country = $this->getctrybyhost($hostname);
  73. return $country;
  74. }
  75. //else
  76. return "";
  77. }
  78.  
  79. cfunction getClientFlag($size)
  80. {
  81. $error = 0;
  82. $hostname = $this->getClientHostname();
  83. if (!strcmp($hostname,"")) $error = 1;
  84. if (!$error)
  85. {
  86. $country_code = strtolower($this->getctrycodebyhost($hostname));
  87. $file_name = $this->flag_dirs[$size] . '/' . $country_code . '.' . $this->flag_ext;
  88. if (is_readable($file_name))
  89. {
  90. return $file_name;
  91. }
  92. }
  93. //else
  94. return "";
  95. }
  96.  
  97. cfunction getClientFlagHTML($size)
  98. {
  99. $error = 0;
  100. $flag = $this->getClientFlag($size);
  101. if (!strcmp($flag,"")) $error = 1;
  102. if (!$error)
  103. {
  104. return '<img src="' . $flag . '">';
  105. }
  106. //else
  107. return "";
  108. }
  109. };
  110. ?>
nospor
ten kumpel to cie chyba testowal...
a co to sa te cfunction? Nie uwazasz ze powinno byc function bez c?
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.