Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] Błąd w skrypcie
PIKeR
post 13.06.2007, 19:53:34
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 17.02.2006

Ostrzeżenie: (0%)
-----


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. ?>
Go to the top of the page
+Quote Post
nospor
post 13.06.2007, 19:56:11
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




ten kumpel to cie chyba testowal...
a co to sa te cfunction? Nie uwazasz ze powinno byc function bez c?


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 31.07.2025 - 07:51