Hi there,
I have a website build for php4 and have recently migrated to a VPS host where they have php 5.
The script is generally working fine however I get lots of errors in my log file.
I have a general functions repository file called delegate.php
The site is bilingual so i have two text files ( one for each language.)
The delegate.php file has the following functions dealing with the dictionary files :
/*function load a file into a dictionary*/
function loadDictionary($fileName){
$dictionary = array();
$fh = fopen($fileName, "r");
while($line = fgets($fh, 1024)){
//trim the line
$line = trim($line);
if(strlen($line)==0 || $line[0] == '#'){
//skip empty lines and comments line
continue;
}
//asign key&value
//list($key, $value) = split("=", $line); // replaced by Luc so that = sign from the language file is correctly parsed by php
list($key, $value) = explode("=", $line, 2);
$dictionary[trim($key)] = trim($value);
}
fclose($fh);
return $dictionary;
}
/*display a dictionary*/
function printDictionary($d){
foreach($d as $key => $value){
echo("$key ==> $value\n<br>");
}
}
/*display a single key*/
function trad($dictionary, $key){
return $dictionary[$key];
}
//load the dictionary
$language = getLanguageSite();
$file_name = WEB_ROOT . "/dictionaries/" . $language->language . ".txt";
$dictionary = loadDictionary($file_name);
I am getting SOMETIMES, not all the time sort of a kickup when the pages are displayed, in wich - of course - I don't have any text displayed that is in the dictionary files.
Here are my apache logs, as an example :
[Fri Oct 24 18:33:04 2008] [error] [client 84.151.62.36] PHP Warning: fopen() [<a href='function.fopen'>function.fopen</a>]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/admin/mydomain.com/v1/common/delegate.php on line 85
[Fri Oct 24 18:33:04 2008] [error] [client 84.151.62.36] PHP Warning: fopen(http://www.mydomain.com/v1/dictionaries/eng.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Success in /home/admin/mydomain/v1/common/delegate.php on line 85
and also
[Fri Oct 24 18:03:44 2008] [error] [client 84.151.62.36] PHP Warning: fgets(): supplied argument is not a valid stream resource in /home/admin/mydomain.com/v1/common/delegate.php on line 86, referer: http://www.mydomain.com/v1/user/common/mainPage.php
[Fri Oct 24 18:03:44 2008] [error] [client 84.151.62.36] PHP Notice: Undefined index: user.loginPage in /home/admin/mydomain.com/v1/user/loginForm.php on line 17, referer: http://www.mydomain/v1/user/common/mainPage.php
"user.loginpage" is a variable referenced in the file, that is translated in 2 languages in the 2 respective dictionary files.
My question is :
The coded functions might not be php 5 compliant ?
Can anyone throp an opinion ?
Thanks a lot !