Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Bug Fixes
Author Message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17077

PostPosted: Wed Oct 01, 2003 5:01 pm Reply with quote

Warning: get_lang(modules/somemodule/language/lang-english.php):

I think I may uncovered a bug and a fix for this. I need you all to shoot holes in this, because this has been coded like this since at least 6.5. In mainfile.php is this code. I added the numbers for reference.
Code:
1. function get_lang($module) { 

2.     global $currentlang, $language;
3.     if (file_exists("modules/$module/language/lang-$currentlang.php")) {
4.         if ($module == admin) {
5.             include_once("admin/language/lang-$currentlang.php");
6.         } else {
7.             include_once("modules/$module/language/lang-$currentlang.php");
8.         }
9,     } else {
10.         if ($module == admin) {
11.             include_once("admin/language/lang-$currentlang.php");
12.         } else {
13.             include_once("modules/$module/language/lang-$language.php");
14.         }
15.    }
16.   }

Line 3 does an IF test to see if there is a language file in the module/MODULENAME folder. If NOT the IF test fails and the logic drops into Line 9. If the $module is NOT equal to admin, which is also an error as it should be "admin" if not something else (who knows?) it has to drop into line 13 which is also looking for a language folder in the module/MODULENAME (but a different language variable). But, if the language folder is non existent then it errors. Thus, you get the infamous Warning: get_lang error!

I believe the function should be written like this, at a minimum.
Code:
function get_lang($module) { 

    global $currentlang, $language;
    if (file_exists("modules/$module/language/lang-$currentlang.php")) {
      if ($module == "admin") {
          include_once("admin/language/lang-$currentlang.php");
      } else {
          include_once("modules/$module/language/lang-$currentlang.php");
      }
   }
    elseif (file_exists("modules/$module/language/lang-$language.php")) {
      if ($module == "admin") {
          include_once("admin/language/lang-$language.php");
      } else {
          include_once("modules/$module/language/lang-$language.php");
      }
    } else {
      if ($module == "admin") {
          include_once("admin/language/lang-$currentlang.php");
      } else {
          include_once("language/lang-$language.php");
      }
    }
}

I also am very unclear as to why/how the usage of the 2 different language variables come into play on this. But, that's neither here nor there right now. Please help prove/disprove this code. It certainly cleared up errors for several people so far. Thanks!
 
View user's profile Send private message
vjg
New Member
New Member


Joined: Mar 09, 2004
Posts: 1

PostPosted: Tue Mar 09, 2004 4:46 pm Reply with quote

As I read it, the two language variables represent the currently selected language ($currentlang) and the default language for the site ($language ... from nuke_config table).

I think the code is assuming that the language in the nuke_config will always be correct and available, but you're correct that it should be more informative when it fails.

- Virgil
 
View user's profile Send private message
CoLoR
New Member
New Member


Joined: Aug 11, 2004
Posts: 2

PostPosted: Sat Oct 16, 2004 2:49 pm Reply with quote

perfect Raven,


It is working for me,

Thankzzz Very Happy Very Happy
 
View user's profile Send private message
cybercase
New Member
New Member


Joined: May 12, 2005
Posts: 1
Location: Germany

PostPosted: Thu May 12, 2005 1:27 pm Reply with quote

I found your patch and although were now in May 2005 , I inserted the code in mainfile.php (PHP-Nuke 7.6) and it is working like a dream
Thanks Very Happy
 
View user's profile Send private message ICQ Number
Raven
PostPosted: Thu May 12, 2005 3:32 pm Reply with quote

RavensScripts
 
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6792
Location: Ha Noi, Viet Nam

PostPosted: Thu May 12, 2005 7:38 pm Reply with quote

OK, lets have a bet to see which version Fb includes this is and which subsequent version it gets dropped from.
I have $20 on 7.8 and 7.9 respectively hehehe.
Well caught Raven!
 
View user's profile Send private message Send e-mail
Raven
PostPosted: Thu May 12, 2005 7:45 pm Reply with quote

Quote:
Posted: Wed Oct 01, 2003 6:01 pm
After 2 years, and the fact that I doubt if FB ever stops by here, I doubt if my code gets targeted ROTFL
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Bug Fixes

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©