Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Fatal Error after Installing!


Guest

Recommended Posts

Posted

Fatal error: Call to undefined function: link_session_variable() in A:\www\webshop\includes\functions\sessions.php on line 95

 

What is wrong ?

 

Im running a PHP4+ server with OSCMS2.2 and Register Globals "OFF" Contrib.

 

The Installation runs fine but when i view the page this is what?s shown.

 

Any ideas ?

 

Oh yea.. A: is not the Scratch drive :P

Posted

It looks as though the session has not started. Above that code there is already a reference to link_session_variable, so if it was not recognised then the error would have shown on line 77.

 

Vger

Posted
It looks as though the session has not started.  Above that code there is already a reference to link_session_variable, so if it was not recognised then the error would have shown on line 77.

 

Vger

 

You lost me there :blush:

Ive pasted the code as it is after the Register_Globals_Off Contrib and as it was modded before installation.

 

<?php
/*
 $Id: sessions.php,v 1.19 2003/07/02 22:10:34 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 if (STORE_SESSIONS == 'mysql') {
   if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
     $SESS_LIFE = 1440;
   }

   function _sess_open($save_path, $session_name) {
     return true;
   }

   function _sess_close() {
     return true;
   }

   function _sess_read($key) {
     $value_query = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "' and expiry > '" . time() . "'");
     $value = tep_db_fetch_array($value_query);

     if (isset($value['value'])) {
       return $value['value'];
     }

     return false;
   }

   function _sess_write($key, $val) {
     global $SESS_LIFE;

     $expiry = time() + $SESS_LIFE;
     $value = $val;

     $check_query = tep_db_query("select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
     $check = tep_db_fetch_array($check_query);

     if ($check['total'] > 0) {
       return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . tep_db_input($expiry) . "', value = '" . tep_db_input($value) . "' where sesskey = '" . tep_db_input($key) . "'");
     } else {
       return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . tep_db_input($value) . "')");
     }
   }

   function _sess_destroy($key) {
     return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
   }

   function _sess_gc($maxlifetime) {
     tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" . time() . "'");

     return true;
   }

   session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc');
 }

  function tep_session_start() {
// >>> BEGIN REGISTER_GLOBALS
   $success = session_start();

   // Work-around to allow disabling of register_globals - map all defined
   // session variables
   if ($success && count($_SESSION))
   {
     $session_keys = array_keys($_SESSION);
     foreach($session_keys as $variable)
     {
       link_session_variable($variable, true);
     }
   }

   return $success;
// <<< END REGISTER_GLOBALS
 }

 function tep_session_register($variable) {
   global $session_started;

// >>> BEGIN REGISTER_GLOBALS
   $success = false;

   if ($session_started == true) {
// -skip-   return session_register($variable);

     // Work-around to allow disabling of register_globals - map session variable
     link_session_variable($variable, true);
     $success = true;
   }

   return $success;
// <<< END SESSION_REGISTER
 }

 function tep_session_is_registered($variable) {
// >>> BEGIN REGISTER_GLOBALS
//    return session_is_registered($variable);
   return isset($_SESSION[$variable]);
// <<< END REGISTER_GLOBALS
 }

 function tep_session_unregister($variable) {
// >>> BEGIN REGISTER_GLOBALS
   // Work-around to allow disabling of register_gloabls - unmap session variable
   link_session_variable($variable, false);
   unset($_SESSION[$variable]);

//  return session_unregister($variable);
   return true;
// <<< END REGISTER_GLOBALS

// >>> BEGIN REGISTER_GLOBALS
 // Work-around function to allow disabling of register_globals in php.ini
 // This is pretty crude but it works. What it does is map session variables to
 // a corresponding global variable.
 // In this way, the main application code can continue to use the existing
 // global varaible names but they are actually redirected to the real session
 // variables
 //
 // If the global variable is already set with a value at the time of the mapping
 // then it is copied over to the real session variable before being mapped back
 // back again
 //
 // Parameters:
 // var_name - Name of session variable
 // map - true = map variable, false = unmap varaible
 //
 // Returns:
 // None
 function link_session_variable($var_name, $map)
 {
   if ($map)
   {
     // Map global to session variable. If the global variable is already set to some value
     // then its value overwrites the session varibale. I **THINK** this is correct behaviour
     if (isset($GLOBALS[$var_name]))
     {
       $_SESSION[$var_name] = $GLOBALS[$var_name];
     }

     $GLOBALS[$var_name] =& $_SESSION[$var_name];
   }
   else
  {
     // Unmap global from session variable (note that the global variable keeps the value of
     // the session variable. This should be unnecessary but it reflects the same behaviour
     // as having register_globals enabled, so in case the OSC code assumes this behaviour,
     // it is reproduced here
     $nothing = 0;
     $GLOBALS[$var_name] =& $nothing;
     unset($GLOBALS[$var_name]);
     $GLOBALS[$var_name] = $_SESSION[$var_name];
   }
 }
// <<< END REGISTER_GLOBALS 


 } 

 function tep_session_id($sessid = '') {
   if (!empty($sessid)) {
     return session_id($sessid);
   } else {
     return session_id();
   }
 }

 function tep_session_name($name = '') {
   if (!empty($name)) {
     return session_name($name);
   } else {
     return session_name();
   }
 }

 function tep_session_close() {
// >>> BEGIN REGISTER_GLOBALS
   // Work-around to allow disabling of register_gloabls - unmap all defined
   // session variables
   if (count($_SESSION))
   {
     $session_keys = array_keys($_SESSION);
     foreach($session_keys as $variable)
     {
       link_session_variable($variable, false);
     }
   }

   if (PHP_VERSION >= '4.0.4') {
     session_write_close();
   } elseif (function_exists('session_close')) {
     session_close();
   }
// <<< END REGSITER_GLOBALS
 }


 function tep_session_destroy() {
// >>> BEGIN REGISTER_GLOBALS
   // Work-around to allow disabling of register_gloabls - unmap all defined
   // session variables
   if (count($_SESSION))
   {
     $session_keys = array_keys($_SESSION);
     foreach($session_keys as $variable)
     {
       link_session_variable($variable, false);
       unset($_SESSION[$variable]);
     }
   }
// <<< END REGISTER_GLOBALS
   return session_destroy();
 } 

 function tep_session_save_path($path = '') {
   if (!empty($path)) {
     return session_save_path($path);
   } else {
     return session_save_path();
   }
 }

 function tep_session_recreate() {
   if (PHP_VERSION >= 4.1) {
     $session_backup = $_SESSION;

     unset($_COOKIE[tep_session_name()]);

     tep_session_destroy();

     if (STORE_SESSIONS == 'mysql') {
       session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc');
     }

// >>> BEGIN REGISTER_GLOBALS
//    tep_session_start();
//    $_SESSION = $session_backup;

     session_start();
     $_SESSION = $session_backup;

     // Work-around to allow disabling of register_globals - map all defined
     // session variables
     if (count($_SESSION))
     {
       $session_keys = array_keys($_SESSION);
       foreach($session_keys as $variable)
       {
         link_session_variable($variable, true);
       }
     }
// <<< END REGISTER_GLOBALS

     unset($session_backup);
   }
 }
?>

  • 2 weeks later...
  • 4 weeks later...
Posted

Where you have:

return $success;

it's actually:

return success

 

Where you have:

$nothing = 0;

it's actually:

$nothing

 

Vger

Posted
Where you have:

return $success;

it's actually:

return success

 

Where you have:

$nothing = 0;

it's actually:

$nothing

 

Vger

 

 

That?s strange <_<

 

I downloaded a clean install of OSCms2.2 and applied the Register globals patch to it.

 

Seems as someone maby missspelled something or maby i did something wrong :blush:

Posted
That?s strange  <_<

 

I downloaded a clean install of OSCms2.2 and applied the Register globals patch to it.

 

Seems as someone maby missspelled something or maby i did something wrong  :blush:

 

 

Well ive patched that up and now i face yet another problem <_<

 

Parse error: parse error, unexpected '}' in a:\www\webshop\includes\functions\sessions.php on line 83

Fatal error: Call to undefined function: tep_session_name() in a:\www\webshop\includes\application_top.php on line 145

 

any ideas or should i just eraze all and start over ?

 

1. Deleting all old code.

2. Download another fresh OSCms2.2 install

3. Patch with a Register Globals OFF patch

 

or what do you guys think..

Posted
Well ive patched that up and now i face yet another problem  <_<

 

Parse error: parse error, unexpected '}' in a:\www\webshop\includes\functions\sessions.php on line 83

Fatal error: Call to undefined function: tep_session_name() in a:\www\webshop\includes\application_top.php on line 145

 

any ideas or should i just eraze all and start over ?

 

1. Deleting all old code.

2. Download another fresh OSCms2.2 install

3. Patch with a Register Globals OFF patch

 

or what do you guys think..

 

You have a simple typo in \includes\functions\sessions.php - I would just fix that.

 

Looks like you have an extra curl bracket on line 83 :-"

 

Matti

Posted
Where you have:

return $success;

it's actually:

return success

 

Where you have:

$nothing = 0;

it's actually:

$nothing

 

Vger

 

 

So when i change all return $success; to $success

and all $nothing = 0 to $nothing

 

i get:

 

Parse error: parse error, unexpected '}' in a:\www\webshop\includes\functions\sessions.php on line 83

Fatal error: Call to undefined function: tep_session_name() in a:\www\webshop\includes\application_top.php on line 158

 

In line 83 i find a } and when i delete it i get this:

 

Parse error: parse error, unexpected T_FUNCTION in a:\www\webshop\includes\functions\sessions.php on line 85

Fatal error: Call to undefined function: tep_session_name() in a:\www\webshop\includes\application_top.php on line 158

 

Line 85 says: function tep_session_register($variable) {

and Line 158 says: $GLOBALS[$var_name] =& $nothing;

 

 

Just tell me it?s simpler to reinstall the whole shop and the n apply the Register globals patch ?

 

Thing is that i started like this....

 

My webhotel dosent support script?s wuth Register globals set to ON because of the unsecure injection possibillity...

 

so i installed the shop this way..

 

1. i downloaded the OSCms2.2 from you guys "A clean install"

2. i downloaded the contrib Register globlas OFF and patched the code..

3. i uploaded it all "Patched and ready to my webhotel"

4. i ran the installation... then i got the errors above...

 

The missspelling and extra lines and extra chars must come from the contrib..

because i shure didn?t edit any lines myselve :P

Posted

Which Register Globals Patch did you install? There is the original one, where you have to appy the edits yourself to the pages - and this is a long install and it's dead easy to make an error or two. This is why I put them all together into a set of Register Globals Patch Files - specificlly for new installs. All you have to do is to overwrite the default files with the patched files and you're good to go.

 

The link to the ready-made patched files is below my name.

 

If you already used that contribution of mine then there's a problem somewhere else that's affecting it (providing you installed all of the files from my contribution) - because no one else has a problem after installing this contribution.

 

Vger

Posted
Which Register Globals Patch did you install?  There is the original one, where you have to appy the edits yourself to the pages - and this is a long install and it's dead easy to make an error or two.  This is why I put them all together into a set of Register Globals Patch Files - specificlly for new installs.  All you have to do is to overwrite the default files with the patched files and you're good to go.

 

The link to the ready-made patched files is below my name.

 

If you already used that contribution of mine then there's a problem somewhere else that's affecting it (providing you installed all of the files from my contribution) - because no one else has a problem after installing this contribution.

 

Vger

 

 

I think it was the long install where you had to edit meny specific files...

so ill just end this with a "Ill delete all files and install a fresh ms2.2 with your patch instead :P

 

hope that saves me bounch of time :D

 

ill try to post a result afterwards :thumbsup:

Archived

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

×
×
  • Create New...