Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/localization
In directory usw-pr-cvs1:/tmp/cvs-serv20013/chat/localization
Modified Files:
languages.lib.php3
Log Message:
Available languages list now cached for better performances
Index: languages.lib.php3
===================================================================
RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/localization/languages.lib.php3,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** languages.lib.php3 2001/11/26 22:50:54 1.10
--- languages.lib.php3 2001/11/30 11:52:22 1.11
***************
*** 71,98 ****
// Defines the path to the localization directory
$localizationPath = (defined('_CHAT_PATH') ? _CHAT_PATH : '') . 'localization/';
! // Defines available languages
! $availableLanguages = array();
! $languageDirectories = dir($localizationPath);
! while ($name = $languageDirectories->read())
{
! if (is_dir($localizationPath . $name)
! && file_exists($localizationPath . $name . '/regex.txt')
! && file_exists($localizationPath . $name . '/chat.loc')
! && file_exists($localizationPath . $name . '/flag.gif'))
! {
! list($key) = file($localizationPath . $name . '/regex.txt');
! $availableLanguages[$key] = $name;
! }
}
! $languageDirectories->close();
!
! // Sorts the $availableLanguages array in a convenient order
! if (!@function_exists('krsort'))
{
! include($localizationPath . 'sort_languages.lib.' . C_EXTENSION);
}
- krsort($availableLanguages);
-
/**
--- 71,113 ----
// Defines the path to the localization directory
$localizationPath = (defined('_CHAT_PATH') ? _CHAT_PATH : '') . 'localization/';
+ $localizationCache = $localizationPath.'availableLanguages.cache';
! if(file_exists($localizationCache) && filemtime($localizationCache) + 60*60 - time()) > 0)
{
! // Cache is up to date, we use it
! $availableLanguages = unserialize(implode('', file($localizationCache)));
}
! else
{
! // Defines available languages
! $availableLanguages = array();
! $languageDirectories = dir($localizationPath);
! while ($name = $languageDirectories->read())
! {
! if (is_dir($localizationPath . $name)
! && file_exists($localizationPath . $name . '/regex.txt')
! && file_exists($localizationPath . $name . '/chat.loc')
! && file_exists($localizationPath . $name . '/flag.gif'))
! {
! list($key) = file($localizationPath . $name . '/regex.txt');
! $availableLanguages[$key] = $name;
! }
! }
! $languageDirectories->close();
!
! // Sorts the $availableLanguages array in a convenient order
! if (!@function_exists('krsort'))
! {
! include($localizationPath . 'sort_languages.lib.' . C_EXTENSION);
! }
! krsort($availableLanguages);
!
! // Store the result in a cache file to limit server load
! if($cacheFile = @fopen($localizationCache, "w"))
! {
! fwrite($cacheFile, serialize($availableLanguages));
! fclose($cacheFile);
! }
}
/**
|