Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Language session related problem


cretbogdan

Recommended Posts

Posted

I am running a osc 2.3.1 store and I think there is a problem regarding language session .

I think many people can't access the store due to this problem ,which today happened to me suddently .

 

I can't visit the front office of my store . The back office is working .

If i try to access the front office nothing happens and after 2 minutes i got internal server error .

I tried to add after website address "index.html?set_language=en" and it worked and now all is fine .

If I try to visit the site using the other browser i still can't view it . I get the same error that i had got with the first browser .

 

Is there any solution to this problem ? Beside that adding index.html?set_language=en ??

Posted

@@cretbogdan

http://www.oscommerce.com/forums/topic/391674-localization/

 

I wonder what did you before! The set_language=en is not osCommerce standard!

 

Regards,

Gergely

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Posted

Thank you very much for your answer !

I modified the application_top.php file and now i can access the website from any browser without the need to add that set_language at the end of the url .

 

I didn't do anything . Today suddently i could not access the website .

I remember in the past some people were reporting exactly what I have experienced today and it was very annoying that I didn't knew what was the problem .

 

Now i think this was the problem and I think it is solved since I don't have any troubles .

 

Here is a part of the error log from the past . I think this problem caused this error .

I am right ?

[Thu Apr 18 04:55:04 2013] [error] [client 82.154.215.91] PHP Fatal error: require(): Failed opening required 'includes/languages/.php' (include_path='.:') in /var/www/vhosts/ecig-vapo.com/httpdocs/includes/application_top.php on line 289

Posted

@@cretbogdan

 

The session broken or language saved with false or empty value. Do you use something which write values into sessions? For example viewed products or forget to clear something from the session?

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Posted

The $language variable was not set. The best and easiest fix is to upgrade to 2.3.3, which should fix this particular problem. Otherwise read up on many discussions about it and patch the code yourself.

Posted

@@cretbogdan

 

The session broken or language saved with false or empty value. Do you use something which write values into sessions? For example viewed products or forget to clear something from the session?

 

I really don't know if I use something which write values into sessions . I am not so good at coding ...

I noticed something . If i try to switch the language to another one on the product page or category page it always switch to english .

If i try to change the language when I am on index page , shopping cart than it is ok . This happens only on product and category page

 

edit :

maybe i did something wrong when i modified the application_top.php file

Here is the code i edited regarding the language

// set the language
 if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['set_language'])) {
   if (!tep_session_is_registered('language')) {
  tep_session_register('language');
  tep_session_register('languages_id');
  tep_session_register('language_code');
   }
   include(DIR_WS_CLASSES . 'language.php');
   $lng = new language();
  if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
	 // first choice is language=XX query string, if any
	 $lng->set_language($HTTP_GET_VARS['language']);
} else {
	 // second choice is DEFAULT_LANGUAGE selection, if any
	 $lng->set_language('');
}
   $language = $lng->language['directory'];
   $languages_id = $lng->language['id'];
if (!tep_not_null($language)) {
    // still don't have a language, so see if the browser suggests something
    // third choice is browser configuration language
    $lng->get_browser_language();
    $language = $lng->language['directory'];
if (!tep_not_null($language)) {
	   $language = 'english';
	   $languages_id = 1;
    }
}
 if (!tep_not_null($language)) {
	   $lng->set_language('en');
	   $language = $lng->language['directory'];
	   $languages_id = $lng->language['id'];
    }
if (!tep_not_null($language)) {
    // try the DEFAULT_LANGUAGE and then the browser, and then English
    $lng->set_language('');
    $language = $lng->language['directory'];
    $languages_id = $lng->language['id'];
    if (!tep_not_null($language)) {
	   $lng->get_browser_language();
	   $language = $lng->language['directory'];
	   $languages_id = $lng->language['id'];
	   if (!tep_not_null($language)) {
			  // nothing yet? fall back to English
			  $language = 'english';
			  $languages_id = 1;
	   }
    }
}
    $languages_id = $lng->language['id'];
   $language_code = $lng->language['code'];

   $_SESSION['language']=$language;
   $_SESSION['languages_id']=$languages_id;
   $_SESSION['language_code']=$language_code;

// if (!isset($_GET['set_language'])) {
//  tep_redirect(tep_href_link(basename($_SERVER['PHP_SELF'])), tep_get_all_get_params(array('set_language', 'language')));
//    }
 }

// include the language translations
 require(DIR_WS_LANGUAGES . $language . '.php');
// Ultimate SEO URLs v2.2d
if ((!defined(SEO_ENABLED)) || (SEO_ENABLED == 'true')) {
  include_once(DIR_WS_CLASSES . 'seo.class.php');
  if ( !is_object($seo_urls) ){
 $seo_urls = new SEO_URL($languages_id);
  }
}

Posted

@@MrPhil

 

Here is a tester

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Posted

@@cretbogdan

 

moreover would be better update to v2.3.3 as Phill suggested. I hope Phill will help in the code.

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Posted

That looks like you started out with my code from a while back, but have made modifications that I don't know where they came from. First, what is $HTTP_GET_VARS['set_language']? Did someone change the Query String from language=en to set_language=en? If so, the later use of $HTTP_GET_VARS['language'] needs to be changed to $HTTP_GET_VARS['set_language']. The existing box module for languages only uses language=.

 

Is there now a variable $language_code? I see it used locally in the Chronopay module. Where is it originally set? Is it used elsewhere in your add-ons? If I understand this session stuff now, $language and $languages_id will be set from the session (as well as $language_code). Note that $language_code had better be set somewhere, as it isn't set here.

 

You had a bunch of old code afterwards that may have been overriding what you did in the new code. I don't know what you're using the $_SESSION stuff for, but I left it in. With some additional commentary and minor code changes:

// set the language
// it should go through this block once per run OR the user requests a language change
 if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) { 
   if (!tep_session_is_registered('language')) {
     // set up language session once per run
     tep_session_register('language');
     tep_session_register('languages_id');
     tep_session_register('language_code');  // *NEW* ???
   }

   include(DIR_WS_CLASSES . 'language.php');
   $lng = new language();

   if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
     // first choice is language=XX query string, if any
     $lng->set_language($HTTP_GET_VARS['language']);
   } else {
     // second choice is DEFAULT_LANGUAGE selection, if any
     $lng->set_language('');
   }
   $language = $lng->language['directory'];
   $languages_id = $lng->language['id'];

   if (!tep_not_null($language)) {
     // still don't have a language, so see if the browser suggests something
     // third choice is browser configuration language
     $lng->get_browser_language();
     $language = $lng->language['directory'];
     $languages_id = $lng->language['id'];
   }

 }

 // if session already set, and not specifying a GET[language], fall through to here. is it possible to have a bad
 // language in the session? just in case, let's check, and fall back to English
 if (!isset($language) || !tep_not_null($language)) {
   // fourth and last choice... hard coded English
   $lng->set_language('en');
   $language = $lng->language['directory'];  // should be 'english'
   $languages_id = $lng->language['id'];     // should be 1
 } 

 $_SESSION['language']=$language;                // *NEW* ???
 $_SESSION['languages_id']=$languages_id;
 $_SESSION['language_code']=$language_code;

// include the language translations
 require(DIR_WS_LANGUAGES . $language . '.php');

 

If this doesn't do it, all I can suggest is going to 2.3.3.

Posted

I couldn't find $language_code anywhere other than the chronopay modules as Phil pointed out. That should not be set anywhere else in osCommerce and if it is, then it is something added as an attempt to "make things work". The "not set language" problem is a session related problem which was fixed in the 2.3.2 to 2.3.3 update...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...