Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Fatal error: Call to undefined function


sperdie

Recommended Posts

I successfully completed an install to a windows server after changing 10 files to allow register_globals to be set to off.

When Trying to open /admin/index.php I get the message:

 

Fatal error: Call to undefined function: link_session_variable() in C:\websites\508\passions-boutique.com\admin\includes\functions\sessions.php on line 90

 

Line 90 Reads: link_session_variable($variable, true);

This is one of the lines that the "patch" (actually a change to the sessions file) changed.

Could anyone give me some help with this problem?

Thanks

 

The text for the "patch" is as follows:

ADMIN PATCH:

CHANGES TO REMOVE register_globals REQUIREMENT for .../admin - V1.3 - 13/01/2005

------------------------------------------------------------

 

Before proceding, read the README file !

 

In the following instructions, I have commented out rather than delete the existing code (where

applicable). Of course, you are free to do what you like.

 

The following files need to be modified :

 

.../admin/products_attributes.php

.../admin/includes/application_top.php

.../admin/includes/functions/general.php

.../admin/includes/functions/sessions.php

 

If you are using the Easy Populate contribution then you may also want to modify this :

 

.../admin/easypopulate.php

 

================================================================================

 

.../admin/products_attributes.php

---------------------------------

 

At the very top of the file, just below...

 

require('includes/application_top.php');

$languages = tep_get_languages();

 

...add the following...

 

// >>> BEGIN REGISTER_GLOBALS

// These variables are accessed directly rather than through $HTTP_GET_VARS or $_GET later in this script

link_get_variable('option_page');

link_get_variable('value_page');

link_get_variable('attribute_page');

// <<< END REGISTER_GLOBALS

 

================================================================================

 

.../admin/includes/application_top.php

--------------------------------------

 

Comment out / delete the check at the top of the file...

 

// Check if register_globals is enabled.

// Since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.

// >>> BEGIN REGISTER_GLOBALS

// if (function_exists('ini_get')) {

// ini_get('register_globals') or exit('FATAL ERROR: register_globals is disabled in php.ini, please enable it!');

// }

// <<< END REGISTER_GLOBALS

 

================================================================================

 

.../admin/includes/functions/general.php

----------------------------------------

 

Change the EXISTING function...

 

tep_browser_detect()

 

...to read as follows :

 

function tep_browser_detect($component) {

// >>> BEGIN REGISTER_GLOBALS

// global $HTTP_USER_AGENT;

 

return stristr($_SERVER['HTTP_USER_AGENT'], $component);

// <<< END REGISTER_GLOBALS

}

 

-------------------------------------------

 

Add the following function to the very end of the general.php file (just before the last '?>')

(actually, it doesn't matter where in the file you put this)

 

// >>> BEGIN REGISTER_GLOBALS

// Work-around functions to allow disabling of register_globals in php.ini

// These functions perform a similar operation as the 'link_session_variable'

// function added to .../functions/sessions.php but for the GET, POST, etc

// variables

//

// Parameters:

// var_name - Name of session variable

//

// Returns:

// None

function link_get_variable($var_name)

{

// Map global to GET variable

if (isset($_GET[$var_name]))

{

$GLOBALS[$var_name] =& $_GET[$var_name];

}

}

 

function link_post_variable($var_name)

{

// Map global to POST variable

if (isset($_POST[$var_name]))

{

$GLOBALS[$var_name] =& $_POST[$var_name];

}

}

// <<< END REGISTER_GLOBALS

 

================================================================================

 

.../admin/includes/functions/sessions.php

-----------------------------------------

 

Change the EXISTING functions...

 

tep_session_start()

tep_session_register()

tep_session_is_registered()

tep_session_unregister

 

(these four functions are grouped together in the unmodified code, but

BE CAREFUL - don't just blindly cut and paste !)

 

...to read as follows :

 

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) {

// >>> BEGIN REGISTER_GLOBALS

// -skip- return session_register($variable);

 

// Work-around to allow disabling of register_globals - map session variable

link_session_variable($variable, true);

 

return true;

// <<< 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_globals - unmap session variable

link_session_variable($variable, false);

unset($_SESSION[$variable]);

 

// return session_unregister($variable);

return true;

// <<< END REGISTER_GLOBALS

}

 

-------------------------------------------

 

Change the EXISTING functions...

 

tep_session_close()

tep_session_destroy()

 

(these two functions are grouped together in the unmodified code, but

BE CAREFUL - don't just blindly cut and paste !)

 

...to read as follows :

 

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 (function_exists('session_close')) {

session_close();

}

// <<< END REGSTER_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();

}

 

-------------------------------------------

 

Add the following function to .../admin/includes/functions/sessions.php - it doesn't matter where -

I added it just below the tep_session_unregister() function.

 

NOTE: There are two versions of this function here - unless you have a particular need to do

---- otherwise then I STRONGLY suggest you use the first version. The second version is really

just for me as a debugging tool

 

VERSION 1 - USE THIS !!!

------------------------

 

// >>> 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

// 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 variable. 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

 

 

VERSION 2 - DON'T USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING AND HAVE A NEED FOR IT

------------------------------------------------------------------------------------

 

// >>> 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

// again

//

// Parameters:

// var_name - Name of session variable

// map - true = map variable, false = unmap varaible

//

// Returns:

// None. An error message is printed if no global variable is available to map to

// the supplied session variable

function link_session_variable($var_name, $map)

{

$var_refs = array

(

'messageToStack' => true,

'new_products_id_in_cart' => true,

'language' => true,

'languages_id' => true,

'selected_box' => true,

'current_path' => true

);

 

if(key_exists($var_name, $var_refs))

{

if ($map)

{

// Map global to session variable. If the global variable is already set to some value

// then its value overwrites the session variable. 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];

}

}

else

{

echo 'Fatal error: Session variable '.$var_name.' is not globally defined<br />';

}

}

// <<< END REGISTER_GLOBALS

 

================================================================================

The following patch only applies if you are using the Easy Populate contribution

 

I have tested this with EP v. 2.72-MS2 and it seems to be ok

I'm not sure about the 'Upload EP File' and the 'Split EP File' functions (they don't work

for me but I'm not entirely sure I'm using these corerectly - it's not something I normally

use), but the rest works ok.

 

.../admin/easypopulate.php

--------------------------

 

Just after the following two lines (approx line 160)....

 

require('includes/application_top.php');

require('includes/database_tables.php');

 

...add the following....

 

// >>> BEGIN REGISTER_GLOBALS

link_get_variable('download');

link_get_variable('dltype');

link_get_variable('split');

 

link_post_variable('MAX_FILE_SIZE');

link_post_variable('buttoninsert');

link_post_variable('buttonsplit');

link_post_variable('localfile');

 

// WARNING: I'm not sure about this line - maybe this is why 'Upload EP File' doesn't work

link_post_variable('usrfl');

// <<< END REGISTER_GLOABLS

 

================================================================================

 

-eof-

Link to comment
Share on other sites

  • 1 year later...

Did you ever get this worked out? I just did the patch also, manually and I'm getting the same error when trying to access the Admin page.

Link to comment
Share on other sites

You are missing "function " (without quotes) from the beginning of line 90 in your admin/includes/functions/sessions.php file.

 

The entire line should look like:

function link_session_variable($var_name, $map)

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...