justpete Posted January 18, 2005 Posted January 18, 2005 When I go to mysite.host.com/catalog, the following error comes up: Fatal error: Call to undefined function: tep_session_name() in /home/vhosts/mysite.host.com/catalog/includes/application_top.php on line 137 Lines 136-140 of application_top.php have been pasted below. Please help me resolve this error. Thanks in advance. // set the session name and save path tep_session_name('osCsid'); tep_session_save_path(SESSION_WRITE_DIRECTORY); // set the session cookie parameters Best Regards Pete P.S. In your replies, please keep in mind i'm a newbie, thanks again.
justpete Posted January 18, 2005 Author Posted January 18, 2005 I have been told that this refers to the function in catalog/includes/functions/sessions.php function tep_session_name($name = '') { ? if (!empty($name)) { ? ? return session_name($name); ? } else { ? ? return session_name(); ? } } Apparently, it is supposed to indicate that the fundtion code is missing. If so, what should I do about it?
Guest Posted January 18, 2005 Posted January 18, 2005 You should check your functions directory for the file :D You have probably had a bad upload - the file either does not exist or is zero bytes in size. Matti
justpete Posted January 18, 2005 Author Posted January 18, 2005 Which file should i search for. What should i do if i find it?
justpete Posted January 18, 2005 Author Posted January 18, 2005 Nope, nothing out of the ordinary in the functions directory.
avoisin Posted January 18, 2005 Posted January 18, 2005 You could start by checking the DIR_WS_FUNCTIONS variable that resides in catalog/includes/configure.php, which points also to DIR_WS_INCLUDES. For my system, I have the following for those: define('DIR_WS_INCLUDES', 'includes/'); define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/'); Perhaps one of these isn't going to the right place? That error suggests it can't find the sessions.php file at all, so it's probably looking in the wrong place.
justpete Posted January 18, 2005 Author Posted January 18, 2005 Lines 26-29 show that the 'DIR_WS_FUNCTIONS' in catalog/includes/configure.php Don't think there's an error there. define('DIR_WS_INCLUDES', 'includes/'); define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/'); define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/'); define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/'); So, what could it be. Just to note also, I implemented a register_globals contribution when i first downloaded OSCommerce. Any further help would be greatly appreciated.
boxtel Posted January 18, 2005 Posted January 18, 2005 Lines 26-29 show that the 'DIR_WS_FUNCTIONS' in catalog/includes/configure.php Don't think there's an error there. define('DIR_WS_INCLUDES', 'includes/'); define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/'); define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/'); define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/'); So, what could it be. Just to note also, I implemented a register_globals contribution when i first downloaded OSCommerce. Any further help would be greatly appreciated. <{POST_SNAPBACK}> all I can deduce is that you tried to install register_globals modification and made some errors there. So I suggest to UN-install the modifications, restore the old files because it seems that your sessions.php file is no longer what it should be. Treasurer MFC
justpete Posted January 18, 2005 Author Posted January 18, 2005 Thats what i'm trying to avoid because it takes ages. Thanks anyway. Can anyone find any other errors?
justpete Posted January 18, 2005 Author Posted January 18, 2005 I just don't know what's wrong with line 137 in application_top.php!!!
Guest Posted January 18, 2005 Posted January 18, 2005 There is nothing wrong with line 137 - it is calling a function from the sessions.php file which is not there (either the function is no longer there or the file is zero bytes in size) - replace the sessions.php file (backup your old if you have modified it), then see what happens :D Matti
justpete Posted January 18, 2005 Author Posted January 18, 2005 If i replace sessions.php with an old version, will i have to go through the installation process again? Will the configure.php files change? Moreover, is it possible to get rid of this function, if replacing the file still causes errors. If so how? Thanks alot for all ur help
justpete Posted January 18, 2005 Author Posted January 18, 2005 I replaced it session.php , and still the same error appears. How can i just get rid of this function.
justpete Posted January 18, 2005 Author Posted January 18, 2005 I have pasted the sessions.php file below for your viewing. What are the errors and how should i correct them? <?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) { // >>> 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 } // >>> 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; $GLOBALS[$var_name] =& $nothing; unset($GLOBALS[$var_name]); $GLOBALS[$var_name] = $_SESSION[$var_name]; } } // <<< 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; $GLOBALS[$var_name] =& $nothing; unset($GLOBALS[$var_name]); $GLOBALS[$var_name] = $_SESSION[$var_name]; } } // <<< END REGISTER_GLOBALS 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); } } // <<< END REGSTER_GLOBALS if (function_exists('session_close')) { return session_close(); } } 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_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); } } ?>
justpete Posted January 18, 2005 Author Posted January 18, 2005 Someone must know how to easily resolve this issue...
Guest Posted January 18, 2005 Posted January 18, 2005 Someone must know how to easily resolve this issue... <{POST_SNAPBACK}> Have you checked your application_top code above line 137?
justpete Posted January 18, 2005 Author Posted January 18, 2005 I don't know what to check. Can someone please see if sessions.php is okay. Cheers.
avoisin Posted January 18, 2005 Posted January 18, 2005 You've got this in your code, which is different from your original code post: // <<< END REGISTER_GLOBALS function tep_session_name($name = '') { if (!empty($name)) { return session_name($name); } else { return session_name(); } which is wrong. You goofed when doing the install, and have commented out the function name! It should read: // <<< END REGISTER_GLOBALS function tep_session_name($name = '') { if (!empty($name)) { return session_name($name); } else { return session_name(); } } As to where the PHP experts are, they are right here - but you need to be patient with everyone, this is a free environment, and we certainly aren't getting paid to monitor the forums! Patience is a virtue ... :) Hope this helps.
justpete Posted January 18, 2005 Author Posted January 18, 2005 Thanks very much indeed. The error has gone. Just like to further stress how grateful I am to everyone for helping out. Cheers.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.