Guest Posted August 28, 2006 Posted August 28, 2006 Hi, I am in the middle of writing a bridge for Joomla and osCommerce. (One that will be completed this time as there have been many attempts to write a brige between the two platforms in the past but all have dropped off the face of the earth) I need to know in which files, the 'value' variable is being written to the 'sessions' in the database for each part of the session data (e.g. nav-history, language, currency, etc, etc, etc). I can get the session_id and session key generated, but it is not writing into the 'value' field. I know I am probably asking a lot here as no one can see my code as yet. Can someone please help me here? Regards, Dan
Guest Posted August 28, 2006 Posted August 28, 2006 Can someone please help me with this? Thanks, Dan
Guest Posted August 29, 2006 Posted August 29, 2006 Dan, I think you and I are in the same boat. I'm trying to launch a site that requires users to login in order to have access to post discussion topics, etc. Only problem is, I can't seem to get my user interface to merge with the one provided by OSCommerce. I don't mind using the one included, but I can't figure out how to use the session files that are included for the rest of my site. Have you had any luck yet on your integration?
Guest Posted August 29, 2006 Posted August 29, 2006 No, not yet. I am hoping someone in the forums here can shed some light. Anyone?????
jpweber Posted August 29, 2006 Posted August 29, 2006 Catalog/includes/functions/sessions.php Jason Simple 1-2-3 Intructions on how to get, install and configure SSL The Google Sandbox explained Simple to follow instructions on how to change the look of your OSC How To Make A Horrible OSC Website my toolbox: All things WordPress-related - All things Adobe-related - PHP Designer 2007 - Codecanyon Junkie - Crimson Editor - Winmerge - phpMyAdmin - WS_FTP my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...
Guest Posted August 29, 2006 Posted August 29, 2006 Thanks jpweber. OK, so the "_sess_write()" function is the function that inserts or updates the data in the sessions table, but in which file(s) is this function called? I am sort of guessing that it probably starts somewhere in catalog/includes/application_top.php as the session data can everytime a user changes the page and the application_top.php file seems to be the only common file included in every page. If this is the case, at which point in application_top.php does the session data get inserted/updated? Like "navigation_history", "language", "currency", etc, etc, etc. Thanks for your help, Dan
jpweber Posted August 29, 2006 Posted August 29, 2006 Thanks jpweber. OK, so the "_sess_write()" function is the function that inserts or updates the data in the sessions table, but in which file(s) is this function called? I am sort of guessing that it probably starts somewhere in catalog/includes/application_top.php as the session data can everytime a user changes the page and the application_top.php file seems to be the only common file included in every page. If this is the case, at which point in application_top.php does the session data get inserted/updated? Like "navigation_history", "language", "currency", etc, etc, etc. Thanks for your help, Dan Yes, in the catalog/includes/functions/sessions.php file, the _sess_write() handler is what updates the sessions table in the database. In which file or files is this function called? I would assume application_top, as well, Dan, for precisely the reason you mentioned. But as far as where to go from there, I don't think I'm knowledgable enough to answer that one, Dan. Perhaps if I were a Kiwi from Wellington, I'd know more about databases, but I rely on others for help with databases. Regardless, continue to post in here, and eventually someone with the proper knowledge will see (and response to) your post. Good luck. Jason Simple 1-2-3 Intructions on how to get, install and configure SSL The Google Sandbox explained Simple to follow instructions on how to change the look of your OSC How To Make A Horrible OSC Website my toolbox: All things WordPress-related - All things Adobe-related - PHP Designer 2007 - Codecanyon Junkie - Crimson Editor - Winmerge - phpMyAdmin - WS_FTP my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...
Guest Posted August 29, 2006 Posted August 29, 2006 Thanks for your help anyway Jason. Anyone else game enough??? Thanks, Dan
Guest Posted August 31, 2006 Posted August 31, 2006 Well, I figures out that the data is being written using the tep_session_register() function. I have now been able to extract some of the session data from osCommerce and they are now being successfully parsed into Joomla. I anticipate being able to have an osCommerce and Joomla compatible component ready in about 1 - 1.5 months. If anyone is interested in this, they can PM me.
PD_Steve Posted August 31, 2006 Posted August 31, 2006 Sounds good to me. I was aware of modules and components for Joomla which had an oscommerce conversion, but a bridge sounds like a great idea. I am definitely interested in this when its finished. Are you releasing GPL or Commercial? Steve My Toolbox: Crimson Editor, Adobe Photoshop CS2.0, Expression Web, Macromedia Suite 8.0, Cinema 4D, Nvu.
Guest Posted August 31, 2006 Posted August 31, 2006 Hi Steve, I envisage I will release a "Lite" free version and a commercial version with more customization features. I will be releasing the "Lite" version first. Dan
Guest Posted August 31, 2006 Posted August 31, 2006 Finally! I got it. here is what I did, and I can't explain it all. I first changed configure.php so that the cookie path is "/" and not "catalog" or your oscommerce folder. Next I created an include for the rest of my site that does not require oscommerce code. The problem with just including sessions.php is that it requires all of the function files and tons of includes. you end up with a mess if you want to use the os commerce user stuff without including application_top in your own files. So, I created an include that includes all functions and variables necessary and it works great. below is what you need in this separate include file. In the page you want to read the user info, simply require this file, and then you can echo out any user variables such as $customer_first_name etc etc... <?php // include server parameters define('DB_SERVER', 'localhost'); // eg, localhost - should not be empty for productive servers define('DB_SERVER_USERNAME', 'username here'); define('DB_SERVER_PASSWORD', 'password here'); define('DB_DATABASE', 'define your database here'); function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; $$link = mysql_connect($server, $username, $password); if ($$link) mysql_select_db($database); return $$link; } function tep_db_close($link = 'db_link') { global $$link; return mysql_close($$link); } function tep_db_query($query, $link = 'db_link') { global $$link; $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error()); return $result; } function tep_db_fetch_array($db_query) { return mysql_fetch_array($db_query, MYSQL_ASSOC); } function tep_db_input($string, $link = 'db_link') { global $$link; return addslashes($string); } tep_db_connect() or die('Unable to connect to database server!'); 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 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 sessions where sesskey = '" . tep_db_input($key) . "'"); $check = tep_db_fetch_array($check_query); if ($check['total'] > 0) { return tep_db_query("update 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 sessions values ('" . tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . tep_db_input($value) . "')"); } } function _sess_destroy($key) { return tep_db_query("delete from sessions where sesskey = '" . tep_db_input($key) . "'"); } function _sess_gc($maxlifetime) { tep_db_query("delete from sessions where expiry < '" . time() . "'"); return true; } session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc'); session_name('osCsid'); session_start(); ?>
Recommended Posts
Archived
This topic is now archived and is closed to further replies.