PHP Web Host - Quality Web Hosting For All PHP Applications Just Great Software
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 14946
Location: Kansas

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

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 Visit poster's website AIM Address Yahoo Messenger
vjg
New Member
New Member


Joined: Mar 09, 2004
Posts: 1

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

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 Back to top

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 Back to top

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
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 14946
Location: Kansas

PostPosted: Thu May 12, 2005 3:32 pm Reply with quote Back to top

RavensScripts
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 4581
Location: Slovakia - working my way around Eastern Europe

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

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 Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 14946
Location: Kansas

PostPosted: Thu May 12, 2005 7:45 pm Reply with quote Back to top

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2008 by Raven
Proud to be listed at Lobo Links Web Directory

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::

:: fisubice Theme Recoded To 100% W3C CSS & HTML 4.01 Transitional Compliance by Raven and 64bitguy ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum