I just want to suggest a minor improvement. In class.phpmailer.php, in the PHPMailer::SetLanguage() method there is attempt to check whether the language file that is about to be included exists:
Now, when files are included, they are looked for inside the INCLUDE_PATH, but file_exists() only checks within current working directory. To make sure that the file exists, it will be much better to also look inside INCLUDE_PATH too. Here's my suggestion (using fopen() since it allows to look inside include_path too):
function SetLanguage($lang_type, $lang_path = "language/") {
if ($fp = @fopen($lang_path.'phpmailer.lang-'.$lang_type.'.php', 'r', 1) ) {
fclose($fp);
include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
}
else if ($fp = @fopen($lang_path.'phpmailer.lang-en.php', 'r', 1) ) {
fclose($fp);
include($lang_path.'phpmailer.lang-en.php');
}
Please pay attention to the last argument to fopen() which we set to 1 is the flag that enables looking inside include_path too. The snippet above is not tested (I just copied from the svn repository) but I am sure you get the idea.
At the end, thanks for the great product and keep up the good work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I just want to suggest a minor improvement. In class.phpmailer.php, in the PHPMailer::SetLanguage() method there is attempt to check whether the language file that is about to be included exists:
596 function SetLanguage($lang_type, $lang_path = "language/") {
597 if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php'))
598 include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
599 else if(file_exists($lang_path.'phpmailer.lang-en.php'))
600 include($lang_path.'phpmailer.lang-en.php');
Now, when files are included, they are looked for inside the INCLUDE_PATH, but file_exists() only checks within current working directory. To make sure that the file exists, it will be much better to also look inside INCLUDE_PATH too. Here's my suggestion (using fopen() since it allows to look inside include_path too):
function SetLanguage($lang_type, $lang_path = "language/") {
if ($fp = @fopen($lang_path.'phpmailer.lang-'.$lang_type.'.php', 'r', 1) ) {
fclose($fp);
include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
}
else if ($fp = @fopen($lang_path.'phpmailer.lang-en.php', 'r', 1) ) {
fclose($fp);
include($lang_path.'phpmailer.lang-en.php');
}
Please pay attention to the last argument to fopen() which we set to 1 is the flag that enables looking inside include_path too. The snippet above is not tested (I just copied from the svn repository) but I am sure you get the idea.
At the end, thanks for the great product and keep up the good work.
I am sorry, this is for the /phpmailer/ project and not the /php-mailer/ one.