Jump to content
Skittles

Optional Related Products, Version 4.0

Recommended Posts

Thank you so much, that worked like a charm... However I have one more question, is there any way to make it automatically relate products in a category? I have quite a few items and I don't want to go in manually and assign each one to other items. Any help is appreciated!

macatticus,

 

Sorry, this contribution won't do that.

 

However, you may be able to streamline the process to make a little less work for yourself.

 

First: In Configuration->Related Products, set the Insert and Inherit option to 'True'.

 

Second: Select one product from the category as the Master and Insert all the other items in the category to the one Master.

 

Third: Select each of the other items as Master, one at a time, and Inherit the first product.

 

I am assuming you want to display a random selection of x number of items in the category. A better solution might be to use the module file as a starting point and modify the sql query to return products in the same category "order by rand() limit x". Just hard code in the options you want, rename the file to something descriptive and call it from the product info file the same as this module is called. You can uninstall this contribution completely.

 

The most work you'll put into it is modifying the sql query. When it's done, just set it and forget it...

 

Good luck, either way.

-Skittles

Share this post


Link to post
Share on other sites
Becki,

 

First and foremost, apply the changes to force the table cells to have equal widths. Then see if you still have the "Random" behavior. If so, try changing another option and see if that change is ignored, too. If all option changes are being ignored, we need to take a look at the database.

 

 

Talk to you soon,

-Skittles

 

Hi Skittles,

 

Thanks again for the information! I made the changes in your previous post to set equal widths, I hard coded the '100' to suit the width of my site, however I presume the 100 can be 100% - although i tired that and didn't get it to work!

 

I checked last night (it's 9.25am at the moment in England) and they do display randomly even when the 'random' setting is false. Hence they don't sort by product name (so couldn't test that fix but sure it'll work).

 

I'll check tonight for the duplicate entries, although I had a thought that I just a couple of days ago I changed the code in product_info.php so that the new products would display randomly - does related products use this code? contrib 'RandomNewProducts1.1'

 

Also while I'm here if a product does not have a related product does the 'Customers also bought' default box show?

 

Many thanks, look like we're just missing each other with the posts so I'll probably pick your reply up tomorrow morning!

 

Becki

Share this post


Link to post
Share on other sites
Hi Skittles,

 

Thanks again for the information! I made the changes in your previous post to set equal widths, I hard coded the '100' to suit the width of my site, however I presume the 100 can be 100% - although i tired that and didn't get it to work!

 

I checked last night (it's 9.25am at the moment in England) and they do display randomly even when the 'random' setting is false. Hence they don't sort by product name (so couldn't test that fix but sure it'll work).

 

I'll check tonight for the duplicate entries, although I had a thought that I just a couple of days ago I changed the code in product_info.php so that the new products would display randomly - does related products use this code? contrib 'RandomNewProducts1.1'

 

Also while I'm here if a product does not have a related product does the 'Customers also bought' default box show?

 

Many thanks, look like we're just missing each other with the posts so I'll probably pick your reply up tomorrow morning!

 

Becki

Becki,

 

I waited up for your post...

 

This contribution uses a configuration key I added. The original code was a modification of the product listing. I have no idea if this contribution uses any of the same code as RandomNewProducts, but I'll take a look at it tomorrow.

 

It looks like the code I gave you for setting the width is wrong! :blush: It was working on my site, but still, it should have included the percent sign like this:

echo '<td class="productListing-data" align="center" valign="top" width="'. 100/RELATED_PRODUCTS_PER_ROW . '%">' . "\n";

 

What it does is divide 100 by the number of products, so four products would cause the width to be 25%, and so on.

 

The default behavior is to insert the related products box if there are related products, otherwise do nothing. You can modify the code to show something else if there aren't any related products. On one site I manage, it is set to show new products, randomly, when the product doesn't have any related products.

 

Well, time to shut down the box and head to bed. Talk to you tomorrow.

-Skittles

Share this post


Link to post
Share on other sites

I've installed this great contribution, and everything went ok, but when I try do insert a related product nothing happens. The record is not inserted in the table. I get no errors at all.

 

Any help?

 

Thanks.

Share this post


Link to post
Share on other sites
Becki,

 

I waited up for your post...

 

This contribution uses a configuration key I added. The original code was a modification of the product listing. I have no idea if this contribution uses any of the same code as RandomNewProducts, but I'll take a look at it tomorrow.

 

It looks like the code I gave you for setting the width is wrong! :blush: It was working on my site, but still, it should have included the percent sign like this:

echo '<td class="productListing-data" align="center" valign="top" width="'. 100/RELATED_PRODUCTS_PER_ROW . '%">' . "\n";

 

What it does is divide 100 by the number of products, so four products would cause the width to be 25%, and so on.

 

The default behavior is to insert the related products box if there are related products, otherwise do nothing. You can modify the code to show something else if there aren't any related products. On one site I manage, it is set to show new products, randomly, when the product doesn't have any related products.

 

Well, time to shut down the box and head to bed. Talk to you tomorrow.

-Skittles

 

Thanks! :) That's very nice of you, sorry I'm not at home to test it out!

 

All i can say is the random products modification just makes a couple of changes in product_info and that's it - i just thought that maybe that is overriding the related products behaviour.

 

I'll get back to you tomorrow once i've looked at the database.

 

many thanks

 

Becki

Share this post


Link to post
Share on other sites

Sorry for double post, but the 'Reciprocate' button works, but the 'Insert' button does not! Nothing happens, the record is not save in the database.

 

Any help?

Share this post


Link to post
Share on other sites

Evening Skittles,

 

I've come to my sisters to use the internet!

 

I checked and I don't have double entries in the database so it can't be that. All the other settings seem to work except the random! Even when i give them sort numbers they still show randomly.

 

My product_info.php is the same as the one that came with RandomNewProducts1.1 except for a slight optimisation and obviously the related products code, I'm hoping this is the problem but don't know, I can post the file if you like or send it to you?

 

Many Thanks

 

Becki

Share this post


Link to post
Share on other sites
Evening Skittles,

 

I've come to my sisters to use the internet!

 

I checked and I don't have double entries in the database so it can't be that. All the other settings seem to work except the random! Even when i give them sort numbers they still show randomly.

 

My product_info.php is the same as the one that came with RandomNewProducts1.1 except for a slight optimisation and obviously the related products code, I'm hoping this is the problem but don't know, I can post the file if you like or send it to you?

 

Many Thanks

 

Becki

 

I had p.m you skittles but for the purpose of others reading this thread I was completely confused by the looks of things (must have been a long day!) - the random new products only modifies modules/new_products.php which related products doesn't change at all - so it's probably not that!

 

Becki

Share this post


Link to post
Share on other sites
I had p.m you skittles but for the purpose of others reading this thread I was completely confused by the looks of things (must have been a long day!) - the random new products only modifies modules/new_products.php which related products doesn't change at all - so it's probably not that!

 

Becki

Becki,

 

I just sent you a PM, but I'm not sure it went through, as it stalled after I hit send. So screw it! Here's the message:

 

Hi,

 

I'm sorry I must have been getting confused yesterday! The random products is for the new products box, hence changes were in modules/new_products.php NOT product_info! So I don't think it has anything to do with random new products unless related products uses that file, which i doubt it does?!

 

Random behaviour still there so not sure what to do?

 

Many Thanks

Becki

Hi Becki,

 

OK. Let's try changing this (in [catalog/]includes/modules/optional_related_products.php):

  $orderBy .= (RELATED_PRODUCTS_RANDOMIZE)?'rand()':'pop_order_id, products_name';

 

to this:

  $orderBy .= (RELATED_PRODUCTS_RANDOMIZE == 'True')?'rand()':'pop_order_id, products_name';

 

It may be that the program is seeing 'False' as a string rather than as a boolean false. If so, it could be considering it true simply because it holds a string. I played around with this when I was developing it, but osc treated "True" as "true" and "False" as "false", and it's the same way it's written in other contributions. I thought it was as it should be.

 

Could be the difference is with the version/update of osCommerce you're using. Or could be something to do with the operating system of your site. Or it could be this won't fix it, because something else is causing the problem...

 

So, what version/update of osc are you running, anyway?

 

If this latest attempt doesn't fix it, is it possible to access the site via ftp? Or is this installed on a local server? I'd be willing to poke around in the files if I can get ftp access.

 

-Anita

 

If the above code change doesn't work, try making the following change, as a troubleshooting step:

 

  $orderBy .= (false)?'rand()':'pop_order_id, products_name';

This should force the statement to "order by pop_order_id, products_name". If not, try changing that line of code to this:

 

  $orderBy .= 'pop_order_id, products_name';

 

Let me know the results of your changes.

Share this post


Link to post
Share on other sites
Sorry for double post, but the 'Reciprocate' button works, but the 'Insert' button does not! Nothing happens, the record is not save in the database.

 

Any help?

Rantas,

 

I think I may be too busy for my own good... I totally missed your post! :(

 

I'm not sure what is going on, but it sounds like you may have tried to 'Insert' a product association that already exists. This code actually checks, and if the record already exists, it does nothing. Also, the code prevents creating a relationship between a product and itself.

 

Are you still having problems? Or was it one of these situations?

 

-Skittles

Share this post


Link to post
Share on other sites
OK. Let's try changing this (in [catalog/]includes/modules/optional_related_products.php):

  $orderBy .= (RELATED_PRODUCTS_RANDOMIZE)?'rand()':'pop_order_id, products_name';

 

to this:

  $orderBy .= (RELATED_PRODUCTS_RANDOMIZE == 'True')?'rand()':'pop_order_id, products_name';

 

Skittles,

 

This worked! thank you so much for your help! Got to rush, speak soon.

 

Becki

Share this post


Link to post
Share on other sites
Rantas,

 

I think I may be too busy for my own good... I totally missed your post! :(

 

I'm not sure what is going on, but it sounds like you may have tried to 'Insert' a product association that already exists. This code actually checks, and if the record already exists, it does nothing. Also, the code prevents creating a relationship between a product and itself.

 

Are you still having problems? Or was it one of these situations?

 

-Skittles

 

Well, I deleted all the relationships. I confirmed in the table that there were no records. Then I tried to make a new relation with the Insert button, but nothing happens. I checked in the table and no records were created.

 

What could it be?

Share this post


Link to post
Share on other sites
Well, I deleted all the relationships. I confirmed in the table that there were no records. Then I tried to make a new relation with the Insert button, but nothing happens. I checked in the table and no records were created.

 

What could it be?

Rantas,

 

Try using "find and replace" in you text editor and change '$_REQUEST' to '$_GET'.

 

$_REQUEST is a merged version of the $_GET, $_POST and $_COOKIE arrays. I'm not sure what version it was implemented, so it may be your server is running an earlier version of PHP and doesn't support $_REQUEST.

 

Anyway, make that change, then let us know whether or not it fixes the problem.

 

-Skittles

Share this post


Link to post
Share on other sites
Skittles,

 

This worked! thank you so much for your help! Got to rush, speak soon.

 

Becki

 

Thanks again skittles for the help, what do you think caused this problem - do you think it was the update I'm using? off the top of your head is there anywhere else in the code that might need changing?

 

A while ago I asked about making the default 'customers also bought' box appear if a product didn't have any related products, could you tell me where abouts this modification needs to go? I think this would be good practice and others could use this function to, what do other people think?

 

Many Thanks

 

Becki

Share this post


Link to post
Share on other sites
Rantas,

 

Try using "find and replace" in you text editor and change '$_REQUEST' to '$_GET'.

 

$_REQUEST is a merged version of the $_GET, $_POST and $_COOKIE arrays. I'm not sure what version it was implemented, so it may be your server is running an earlier version of PHP and doesn't support $_REQUEST.

 

Anyway, make that change, then let us know whether or not it fixes the problem.

 

-Skittles

 

 

Sorry. my fault . I translate the buttons values to portuguese but forgot to translate in:

 

switch ($action) {

case 'Insert':

 

Now everything is working fine. Thank your help.

Share this post


Link to post
Share on other sites
Sorry. my fault . I translate the buttons values to portuguese but forgot to translate in:

 

switch ($action) {

case 'Insert':

 

Now everything is working fine. Thank your help.

Rantas,

 

Glad you got it working.

 

By the way, would you be willing to share your Optional Related Products language files, so I could create a language option pack for Portuguese?

 

Thanks in advance for thinking about it.

-Skittles

Share this post


Link to post
Share on other sites
Thanks again skittles for the help, what do you think caused this problem - do you think it was the update I'm using? off the top of your head is there anywhere else in the code that might need changing?

 

A while ago I asked about making the default 'customers also bought' box appear if a product didn't have any related products, could you tell me where abouts this modification needs to go? I think this would be good practice and others could use this function to, what do other people think?

 

Many Thanks

 

Becki

Becki,

 

I checked, and that is the only one that didn't have the " == 'True' " specified...

 

Now, to add 'customers also bought' box to appear only if there are no related products, open the module file ([catalog/]includes/modules/optional_related_products.php) and go to the end of the file.

 

Replace the final:

 

<?php
}
?>

with:

 

<?php
} else { /* option: call another module instead */
?>
  <tr>
	<td>
<?php
if ((USE_CACHE == 'true') && empty($SID)) {
  echo tep_cache_also_purchased(3600);
} else {
  include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
}
 }
?>
	</td>
  </tr>
<?php
}
?>

 

Now go into product_info.php and remove this code from the file:

 

	  <tr>
	<td>
<?php
if ((USE_CACHE == 'true') && empty($SID)) {
  echo tep_cache_also_purchased(3600);
} else {
  include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
}
 }
?>
	</td>
  </tr>

Otherwise, you could end up with the 'also purchased' displayed twice!

 

-Anita

Share this post


Link to post
Share on other sites

I'm not sure if this has been posted yet, but just to be sure:

 

When trying to install a new install SQL the script will give errors on all 'insert into' when using MySQL5. I'm not sure if mysql5 is even officially supported and there probably is a config possible to avoid this error as it occurs on:

 

insert into <table> values (''

 

The auto increment demands a number and cannot handle 'null' input. If you use a 0, everything will work fine. Another way is to configure mysql to accept null as an autoincrement, but mysql5 does not accept it out of the box.

 

Of course somebody must have noticed this before and i was wondering what their solution was.

Share this post


Link to post
Share on other sites
I'm not sure if this has been posted yet, but just to be sure:

 

When trying to install a new install SQL the script will give errors on all 'insert into' when using MySQL5. I'm not sure if mysql5 is even officially supported and there probably is a config possible to avoid this error as it occurs on:

 

insert into <table> values (''

 

The auto increment demands a number and cannot handle 'null' input. If you use a 0, everything will work fine. Another way is to configure mysql to accept null as an autoincrement, but mysql5 does not accept it out of the box.

 

Of course somebody must have noticed this before and i was wondering what their solution was.

Hi ardr!

 

I had not heard of this issue prior to your post. So I did some checking online, and found this forum thread. Apparently, according to one post, the problem only affects Windows versions of MySQL. That would explain why I didn't have a problem when I developed this contribution on a local install (XAMPP) which uses PHP Version 5.1.4, Apache 2.2.2, and MySQL 5.0.21.

 

Additionally, I had several beta testers with a variety of environments and none of the beta testers experienced the problem you are describing. After what I read, I assume none of them were using a Windows version of MySQL 5.

 

Two solutions were suggested. Simply not specifying the id in the statement sounds like the simplest, and I think it should work for earlier version of MySQL as well.

 

If you will send me your email address by PM, (please do not post your email address,) I will email you an updated SQL Utility file. Then let us all know if that solves the issue for you.

 

Thanks for bringing this to our attention!

-Skittles

Share this post


Link to post
Share on other sites
Hi ardr!

My apologies... I'm mortified... :blush: I miss-spelled your name!

 

In the immortal words of Bugs Bunny, "what a maroon."

 

Anyway, arbr, welcome to the forum.

 

-Skittles

Share this post


Link to post
Share on other sites

I am getting a few errors on the main page:

 



Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/anything/public_html/x/includes/application_top.php:1) in /home/anything/public_html/x/includes/functions/sessions.php on line 97

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/anything/public_html/x/includes/application_top.php:1) in /home/anything/public_html/x/includes/functions/sessions.php on line 97

 

and the following code in the admin section:

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/anything/public_html/x/admin/categories.php:1) in /home/anything/public_html/x/admin/includes/functions/sessions.php on line 67

 

as well as these errors when I enter the Related Products under Admin:

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/anything/public_html/x/admin/includes/filenames.php:1) in /home/anything/public_html/x/admin/includes/functions/sessions.php on line 67



Warning: Cannot modify header information - headers already sent by (output started at /home/anything/public_html/x/admin/includes/filenames.php:1) in /home/anything/public_html/x/admin/includes/functions/general.php on line 22

 

I have no other contributions added, so there should not be anything wrong, right? If you can guide me in the right direction, I would appreciate it very much :)

 

Thanks.

Share this post


Link to post
Share on other sites
I am getting a few errors on the main page:

 



Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/anything/public_html/x/includes/application_top.php:1) in /home/anything/public_html/x/includes/functions/sessions.php on line 97

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/anything/public_html/x/includes/application_top.php:1) in /home/anything/public_html/x/includes/functions/sessions.php on line 97

 

and the following code in the admin section:

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/anything/public_html/x/admin/categories.php:1) in /home/anything/public_html/x/admin/includes/functions/sessions.php on line 67

 

as well as these errors when I enter the Related Products under Admin:

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/anything/public_html/x/admin/includes/filenames.php:1) in /home/anything/public_html/x/admin/includes/functions/sessions.php on line 67



Warning: Cannot modify header information - headers already sent by (output started at /home/anything/public_html/x/admin/includes/filenames.php:1) in /home/anything/public_html/x/admin/includes/functions/general.php on line 22

 

I have no other contributions added, so there should not be anything wrong, right? If you can guide me in the right direction, I would appreciate it very much :)

 

Thanks.

daniaw,

 

This particular error is quite common in php.

 

The reason seen most often on the osCommerce forums is white-space following the last php end tag (?>)of a required or included file. However, any output to the browser will send a header, so any characters above the first beginning php tag (<?php) could also produce this error.

 

Your error messages actually tell you where the problem is: for example "output started at /home/anything/public_html/x/admin/includes/filenames.php:1" tells you that the header was sent from filenames.php line 1. Open the file in your text editor and remove any text or white space (space, tab, new line, whatever) that occurs before the <?php tag. This tag should be at the very top of the page and snug up to the left of the line.

 

It looks like you have the same problem in each file listed in the error messages you have provided.

 

This only affects php files called prior to the actual page header being sent, that is, anything before the html <header> tag. If an included/required file--like application_top.php--also includes/requires files, each of those files must also begin with <?php and end with ?> without any text or white space outside of those tags.

 

I hope this explanation will help you now and in the future.

-Skittles

Share this post


Link to post
Share on other sites
daniaw,

 

This particular error is quite common in php.

 

The reason seen most often on the osCommerce forums is white-space following the last php end tag (?>)of a required or included file. However, any output to the browser will send a header, so any characters above the first beginning php tag (<?php) could also produce this error.

 

Your error messages actually tell you where the problem is: for example "output started at /home/anything/public_html/x/admin/includes/filenames.php:1" tells you that the header was sent from filenames.php line 1. Open the file in your text editor and remove any text or white space (space, tab, new line, whatever) that occurs before the <?php tag. This tag should be at the very top of the page and snug up to the left of the line.

 

It looks like you have the same problem in each file listed in the error messages you have provided.

 

This only affects php files called prior to the actual page header being sent, that is, anything before the html <header> tag. If an included/required file--like application_top.php--also includes/requires files, each of those files must also begin with <?php and end with ?> without any text or white space outside of those tags.

 

I hope this explanation will help you now and in the future.

-Skittles

Skittles,

 

If I follow your directions (and I do below I can comprehend them just fine), then there shouldn't be any spaces between beginning and ending of the pages... I have "attached" my pages here, and used ************** to show the beginning and ending of the pages.

 

I still can't see that there is anything wrong with the pages in accordance to your directions... or maybe I am wrong??!

 

APPLICATION_TOP.PHP

**************

<?php

/*

$Id: application_top.php,v 1.162 2003/07/12 09:39:03 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

// Start the clock for the page parse time log

define('PAGE_PARSE_START_TIME', microtime());

 

// Set the level of error reporting

error_reporting(E_ALL & ~E_NOTICE);

 

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

if (function_exists('ini_get')) {

ini_get('register_globals') or exit('Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.');

}

 

// Set the local configuration parameters - mainly for developers

if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');

 

// Include application configuration parameters

require('includes/configure.php');

 

// Define the project version

define('PROJECT_VERSION', 'osCommerce 2.2-MS2');

 

// set php_self in the local scope

$PHP_SELF = (isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']);

 

// Used in the "Backup Manager" to compress backups

define('LOCAL_EXE_GZIP', '/usr/bin/gzip');

define('LOCAL_EXE_GUNZIP', '/usr/bin/gunzip');

define('LOCAL_EXE_ZIP', '/usr/local/bin/zip');

define('LOCAL_EXE_UNZIP', '/usr/local/bin/unzip');

 

// include the list of project filenames

require(DIR_WS_INCLUDES . 'filenames.php');

 

// include the list of project database tables

require(DIR_WS_INCLUDES . 'database_tables.php');

 

// customization for the design layout

define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125)

 

// Define how do we update currency exchange rates

// Possible values are 'oanda' 'xe' or ''

define('CURRENCY_SERVER_PRIMARY', 'oanda');

define('CURRENCY_SERVER_BACKUP', 'xe');

 

// include the database functions

require(DIR_WS_FUNCTIONS . 'database.php');

 

// make a connection to the database... now

tep_db_connect() or die('Unable to connect to database server!');

 

// set application wide parameters

$configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);

while ($configuration = tep_db_fetch_array($configuration_query)) {

define($configuration['cfgKey'], $configuration['cfgValue']);

}

 

// define our general functions used application-wide

require(DIR_WS_FUNCTIONS . 'general.php');

require(DIR_WS_FUNCTIONS . 'html_output.php');

 

// initialize the logger class

require(DIR_WS_CLASSES . 'logger.php');

 

// include shopping cart class

require(DIR_WS_CLASSES . 'shopping_cart.php');

 

// some code to solve compatibility issues

require(DIR_WS_FUNCTIONS . 'compatibility.php');

 

// check to see if php implemented session management functions - if not, include php3/php4 compatible session class

if (!function_exists('session_start')) {

define('PHP_SESSION_NAME', 'osCAdminID');

define('PHP_SESSION_PATH', '/');

define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY);

 

include(DIR_WS_CLASSES . 'sessions.php');

}

 

// define how the session functions will be used

require(DIR_WS_FUNCTIONS . 'sessions.php');

 

// set the session name and save path

tep_session_name('osCAdminID');

tep_session_save_path(SESSION_WRITE_DIRECTORY);

 

// set the session cookie parameters

if (function_exists('session_set_cookie_params')) {

session_set_cookie_params(0, DIR_WS_ADMIN);

} elseif (function_exists('ini_set')) {

ini_set('session.cookie_lifetime', '0');

ini_set('session.cookie_path', DIR_WS_ADMIN);

}

 

// lets start our session

tep_session_start();

 

// set the language

if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) {

if (!tep_session_is_registered('language')) {

tep_session_register('language');

tep_session_register('languages_id');

}

 

include(DIR_WS_CLASSES . 'language.php');

$lng = new language();

 

if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {

$lng->set_language($HTTP_GET_VARS['language']);

} else {

$lng->get_browser_language();

}

 

$language = $lng->language['directory'];

$languages_id = $lng->language['id'];

}

 

// include the language translations

require(DIR_WS_LANGUAGES . $language . '.php');

$current_page = basename($PHP_SELF);

if (file_exists(DIR_WS_LANGUAGES . $language . '/' . $current_page)) {

include(DIR_WS_LANGUAGES . $language . '/' . $current_page);

}

 

// define our localization functions

require(DIR_WS_FUNCTIONS . 'localization.php');

 

// Include validation functions (right now only email address)

require(DIR_WS_FUNCTIONS . 'validations.php');

 

// setup our boxes

require(DIR_WS_CLASSES . 'table_block.php');

require(DIR_WS_CLASSES . 'box.php');

 

// initialize the message stack for output messages

require(DIR_WS_CLASSES . 'message_stack.php');

$messageStack = new messageStack;

 

// split-page-results

require(DIR_WS_CLASSES . 'split_page_results.php');

 

// entry/item info classes

require(DIR_WS_CLASSES . 'object_info.php');

 

// email classes

require(DIR_WS_CLASSES . 'mime.php');

require(DIR_WS_CLASSES . 'email.php');

 

// file uploading class

require(DIR_WS_CLASSES . 'upload.php');

 

// calculate category path

if (isset($HTTP_GET_VARS['cPath'])) {

$cPath = $HTTP_GET_VARS['cPath'];

} else {

$cPath = '';

}

 

if (tep_not_null($cPath)) {

$cPath_array = tep_parse_category_path($cPath);

$cPath = implode('_', $cPath_array);

$current_category_id = $cPath_array[(sizeof($cPath_array)-1)];

} else {

$current_category_id = 0;

}

 

// default open navigation box

if (!tep_session_is_registered('selected_box')) {

tep_session_register('selected_box');

$selected_box = 'configuration';

}

 

if (isset($HTTP_GET_VARS['selected_box'])) {

$selected_box = $HTTP_GET_VARS['selected_box'];

}

 

// the following cache blocks are used in the Tools->Cache section

// ('language' in the filename is automatically replaced by available languages)

$cache_blocks = array(array('title' => TEXT_CACHE_CATEGORIES, 'code' => 'categories', 'file' => 'categories_box-language.cache', 'multiple' => true),

array('title' => TEXT_CACHE_MANUFACTURERS, 'code' => 'manufacturers', 'file' => 'manufacturers_box-language.cache', 'multiple' => true),

array('title' => TEXT_CACHE_ALSO_PURCHASED, 'code' => 'also_purchased', 'file' => 'also_purchased-language.cache', 'multiple' => true)

);

 

// check if a default currency is set

if (!defined('DEFAULT_CURRENCY')) {

$messageStack->add(ERROR_NO_DEFAULT_CURRENCY_DEFINED, 'error');

}

 

// check if a default language is set

if (!defined('DEFAULT_LANGUAGE')) {

$messageStack->add(ERROR_NO_DEFAULT_LANGUAGE_DEFINED, 'error');

}

 

if (function_exists('ini_get') && ((bool)ini_get('file_uploads') == false) ) {

$messageStack->add(WARNING_FILE_UPLOADS_DISABLED, 'warning');

}

?>

**************

 

SESSIONS.PHP

**************

<?php

/*

$Id: sessions.php,v 1.9 2003/06/23 01:20:05 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

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

$qid = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "' and expiry > '" . time() . "'");

 

$value = tep_db_fetch_array($qid);

if ($value['value']) {

return $value['value'];

}

 

return false;

}

 

function _sess_write($key, $val) {

global $SESS_LIFE;

 

$expiry = time() + $SESS_LIFE;

$value = $val;

 

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

$total = tep_db_fetch_array($qid);

 

if ($total['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() {

return session_start();

}

 

function tep_session_register($variable) {

return session_register($variable);

}

 

function tep_session_is_registered($variable) {

return session_is_registered($variable);

}

 

function tep_session_unregister($variable) {

return session_unregister($variable);

}

 

function tep_session_id($sessid = '') {

if ($sessid != '') {

return session_id($sessid);

} else {

return session_id();

}

}

 

function tep_session_name($name = '') {

if ($name != '') {

return session_name($name);

} else {

return session_name();

}

}

 

function tep_session_close() {

if (function_exists('session_close')) {

return session_close();

}

}

 

function tep_session_destroy() {

return session_destroy();

}

 

function tep_session_save_path($path = '') {

if ($path != '') {

return session_save_path($path);

} else {

return session_save_path();

}

}

?>

**************

 

FILENAMES.PHP:

**************

<?php

/*

$Id: filenames.php,v 1.1 2003/06/20 00:18:30 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

// define the filenames used in the project

define('FILENAME_BACKUP', 'backup.php');

define('FILENAME_BANNER_MANAGER', 'banner_manager.php');

define('FILENAME_BANNER_STATISTICS', 'banner_statistics.php');

define('FILENAME_CACHE', 'cache.php');

define('FILENAME_CATALOG_ACCOUNT_HISTORY_INFO', 'account_history_info.php');

define('FILENAME_CATEGORIES', 'categories.php');

define('FILENAME_CONFIGURATION', 'configuration.php');

define('FILENAME_COUNTRIES', 'countries.php');

define('FILENAME_CURRENCIES', 'currencies.php');

define('FILENAME_CUSTOMERS', 'customers.php');

define('FILENAME_DEFAULT', 'index.php');

define('FILENAME_DEFINE_LANGUAGE', 'define_language.php');

define('FILENAME_FILE_MANAGER', 'file_manager.php');

define('FILENAME_GEO_ZONES', 'geo_zones.php');

define('FILENAME_LANGUAGES', 'languages.php');

define('FILENAME_MAIL', 'mail.php');

define('FILENAME_MANUFACTURERS', 'manufacturers.php');

define('FILENAME_MODULES', 'modules.php');

define('FILENAME_NEWSLETTERS', 'newsletters.php');

define('FILENAME_ORDERS', 'orders.php');

define('FILENAME_ORDERS_INVOICE', 'invoice.php');

define('FILENAME_ORDERS_PACKINGSLIP', 'packingslip.php');

define('FILENAME_ORDERS_STATUS', 'orders_status.php');

define('FILENAME_POPUP_IMAGE', 'popup_image.php');

define('FILENAME_PRODUCTS_ATTRIBUTES', 'products_attributes.php');

define('FILENAME_PRODUCTS_EXPECTED', 'products_expected.php');

define('FILENAME_REVIEWS', 'reviews.php');

define('FILENAME_SERVER_INFO', 'server_info.php');

define('FILENAME_SHIPPING_MODULES', 'shipping_modules.php');

define('FILENAME_SPECIALS', 'specials.php');

define('FILENAME_STATS_CUSTOMERS', 'stats_customers.php');

define('FILENAME_STATS_PRODUCTS_PURCHASED', 'stats_products_purchased.php');

define('FILENAME_STATS_PRODUCTS_VIEWED', 'stats_products_viewed.php');

define('FILENAME_TAX_CLASSES', 'tax_classes.php');

define('FILENAME_TAX_RATES', 'tax_rates.php');

define('FILENAME_WHOS_ONLINE', 'whos_online.php');

define('FILENAME_ZONES', 'zones.php');

define('FILENAME_RELATED_PRODUCTS', 'optional_related_products.php');

?>

**************

 

Thanks for your so promptly response - that is highly appreciated :)

Share this post


Link to post
Share on other sites
Skittles,

 

If I follow your directions (and I do below I can comprehend them just fine), then there shouldn't be any spaces between beginning and ending of the pages... I have "attached" my pages here, and used ************** to show the beginning and ending of the pages.

 

I still can't see that there is anything wrong with the pages in accordance to your directions... or maybe I am wrong??!

 

APPLICATION_TOP.PHP

**************

<?php

--code--

?>

**************

 

SESSIONS.PHP

**************

<?php

--code--

?>

**************

 

FILENAMES.PHP:

**************

<?php

--code--

?>

**************

 

Thanks for your so promptly response - that is highly appreciated :)

daniaw,

 

I don't know what is wrong, then. According to the error messages, the headers have "already been sent". What I've read says that the line number in the error message could be the last line of several that caused the output. But as it says line 1...

 

Is it safe to assume everything was working fine before you added this contribution?

 

Perhaps you should revert to the backed up files and verify the errors go away. Then try adding changes in blocks, for example only the changes to functions/general.php, then verify the errors are still gone. In this way, you can isolate which changes introduced the error. At that point, it will be easier to figure out what needs to be done.

 

-Skittles

Share this post


Link to post
Share on other sites
daniaw,

 

I don't know what is wrong, then. According to the error messages, the headers have "already been sent". What I've read says that the line number in the error message could be the last line of several that caused the output. But as it says line 1...

 

Is it safe to assume everything was working fine before you added this contribution?

 

Perhaps you should revert to the backed up files and verify the errors go away. Then try adding changes in blocks, for example only the changes to functions/general.php, then verify the errors are still gone. In this way, you can isolate which changes introduced the error. At that point, it will be easier to figure out what needs to be done.

 

-Skittles

 

But, but, but... of course... everything was working before :D This site is so new that it still has the default OSC layout, and even the default home page with the default message. I haven't even changed that part yet :)

 

Would it have something to do with the version of OSC to do? Like the version I have running is Ver 2.2-MS2, and the server version of PHP is 4.4.4 - would that do anything to the coding part of the of the compatibility? Just a thought...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×