Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] osC-PrintOrder with Store Logo v1.0


Guest

Recommended Posts

Found another bug :)

 

If you place an order which has payment infomation (such as with a cheque/money order) and then place another order afterwards which has no payment info (such as a PayPal order) you will find that the PayPal order will pick up the payment info from the previous order. You can check this by viewing the 'Order Printable' for the PayPal order - it will show 'Your order will not ship until we receive payment.'

 

This is caused because the payment_info for the order is stored in a global variable which is not cleared correctly between each order. To fix it, in checkout_confirmation.php change (around line 238)

<?php
 if (is_array($payment_modules->modules)) {
   if ($confirmation = $payment_modules->confirmation()) {
     $payment_info = $confirmation['title'];
     if (!tep_session_is_registered('payment_info')) tep_session_register('payment_info');

to

if (is_array($payment_modules->modules)) {
   if (tep_session_is_registered('payment_info'))
       tep_session_unregister('payment_info');

   if ($confirmation = $payment_modules->confirmation()) {
     $payment_info = $confirmation['title'];

     tep_session_register('payment_info');

 

Cheers

Link to comment
Share on other sites

  • Replies 165
  • Created
  • Last Reply

Top Posters In This Topic

Hi there

 

I'm getting the same error on checkout but I can't find where to change the code. I don't seem to have the lines mentioned. My file looks like this

 

<?php

if (is_array($payment_modules->modules)) {

if ($confirmation = $payment_modules->confirmation()) {

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td class="main"><b><?php echo HEADING_PAYMENT_INFORMATION; ?></b></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

<td><table border="0" cellspacing="0" cellpadding="2">

<tr>

<td class="main" colspan="4"><?php echo $confirmation['title']; ?></td>

</tr>

and I haven't changed anything.

 

Can you help please.

 

Thanks heaps

Toni

Link to comment
Share on other sites

You haven't installed it correctly then. You should have made this change as explained in the Readme.txt inside the contribution

 

########## CATALOG/CHECKOUT_CONFIRMATION.PHP ##########

Locate the following code in catalog/checkout_confirmation.php - (unmodified version of file - Line#238)

<?php
 if (is_array($payment_modules->modules)) {
   if ($confirmation = $payment_modules->confirmation()) {

Replace it with this...

<?php
 if (is_array($payment_modules->modules)) {
   if ($confirmation = $payment_modules->confirmation()) {
     $payment_info = $confirmation['title'];
     if (!tep_session_is_registered('payment_info')) tep_session_register('payment_info');

########## END ###

Link to comment
Share on other sites

  • 2 weeks later...

JAMES -

 

I'm using STS Templates and implemented your code here:

 

2) For those using STS, this is the way around it from Brian Gallagher

 

 

QUOTE

 

In sts_display_output.php change these lines:

 

CODE

// This is required to prevent display of standard page elements (header, footer, etc) from the template and allow javascript code to run properly

if (strpos($scriptname, "popup") !== false || strpos($scriptname, "info_shopping_cart") !== false) {

$display_normal_output = 1;

$display_template_output = 0;

}

 

 

to this:

 

 

QUOTE

// This is required to prevent display of standard page elements (header, footer, etc) from the template and allow javascript code to run properly

if (strpos($scriptname, "popup") !== false || strpos($scriptname, "info_shopping_cart") !== false || strpos($scriptname, "printorder.php") !== false) {

? $display_normal_output = 1;

? $display_template_output = 0;

}

 

 

That should keep STS from using the template on the printorder file.

 

- Brian

 

I'm getting this error:

 

Parse error: parse error in /var/www/html/catalog/includes_display_output.php on line 34.

 

Line 34 is:

 

? $display_normal_output = 1;

 

Any ideas???

 

Thanks!

Link to comment
Share on other sites

Hey Joshua,

 

Haven't got a clue - don't use STS templates myself and the piece of code you posted isn't related to the fix I posted above.

 

Parse error usually means you've got your brackets in the wrong place or something. Check the lines above and below for the correct number of brackets etc.

Link to comment
Share on other sites

I'm sorry, I'm an idiot, that was intended for James Ballenger who posted a message with the code on the previous page. I'll check the brackets though, that could defnitely be the problem. Thanks!

Link to comment
Share on other sites

K, here's my problem.

 

The problem is that the order slip popup shows the following error:

Fatal error: Cannot redeclare tep_db_connect() (previously declared in /www/v/villadecftp/htdocs/includes/functions/database.php:13) in /www/v/villadecftp/htdocs/includes/functions/database.php on line 13

This error only occurs in the catalog area. The admin directory works just fine.

Please email me at [email protected] with the solution, please.

Link to comment
Share on other sites

Well, I read my way through oodles of pages and saw that there were still ongoing problems. The last time a new file was added to the contributions was Dec 4, 2003 Does anyone have the complete and correct installation instructions (for the latest osC) for this contrib? :unsure:

 

spib maybe?

Edited by 420
Link to comment
Share on other sites

  • 2 weeks later...

Just ran into another issue with the Purchase Without Account contribution. If a customer selects the purchase without account option, on the checkout_success.php page they cannot print their order. By clicking the Print Order button the normal pop-up comes up but it goes to login.php instead of the order.

 

Has anyone exeprienced this conflict? Any ideas on a work around???

 

Thanks.

Link to comment
Share on other sites

Dan,

 

This contrib has 3 distinct forms for order printing. There is /catalog/print_order.php, /catalog/admin/invoice.php and /catalog/admin/packingslip.php. In my opinion, you NEVER want to define globals and allow customer access to the invoice.php or packingslip.php. In fact, everything in the admin directory should have .htaccess security or better.

 

Printorder.php has two security sections of code. The first insures that the user is valid for the session and requires a login if the user is not already logged in:

 

 

QUOTE

 

? if (!tep_session_is_registered('customer_id'))

? {

? ? $navigation->set_snapshot();

? ? tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

? }

 

 

Randy recently added another security feature that is supposed to close the window if the incorrect user is able to access the orders of others while logged in (by changing the orderid in the shortcut for the javascript window). As you have pointed out, this feature does not appear to work and still allows a user who is logged in to view other customers orders.

 

 

QUOTE

 

<script language="JavaScript">

<!--

function Lvl_P2P(url,closeIt,delay){ //ver1.0 4LevelWebs

? ? opener.location.href = url;

if (closeIt == true)setTimeout('self.close()',delay);

}

-->

</script>

 

 

I have not addressed this security hole because I allow guest login purchases and as such have had to remove all security on the order printing information (the guest is not logged in but should still be able to print the invoice so there cannot be any user validation). So I don't have any suggestions for you at this time, though if I get time I may take another look at it in the future.

 

pcs -

 

Have you had the chance to look at this issue again?

 

Also, this was provided by safoo in the PWA thread:

 

As long as it tries to pull info from the orders table, you should be able to get it to work. Look for an 'if' statement that checks if the cusotmer is logged in and compare it to the 'if' statements in the PWA.

 

A cusomter is logged in normally :

 

if(tep_session_is_registered('customer_id'))

 

A customer is logged in with PWA:

 

if (tep_session_is_registered('noaccount'))

 

The above should help when you post in the other thread.

 

I'm assuming the first security section indicated above can be edited with this code to be compatible with PWA:

 

if (tep_session_is_registered('noaccount'))

 

Is that correct?

Link to comment
Share on other sites

Any news on making PrintOrder work with the Purchase Without Account (PWA) contrib??? I've tried a few things but have had no success...

Link to comment
Share on other sites

  • 2 weeks later...

Hey all,

 

I know its been awhile, but let me jump in... here's what I see the problem with using osCPrintOrder with PWA...

 

With PWA, the customer never "logs in". The customers PWA session is killed when checkout_process.php is run. This means that when the customer reaches the Checkout_success, there is no customer infomation to be queried, and consequently, no way for osC to know the order info at that point.

 

The idea of PWA is the customers no longer have access to their order info once they reach checkout_success.php. Since they haven't created an account, there is no way for them to login to view information. In fact, that is what it states when the choice is given to either login, register or PWA.

 

Basically, PWA is only good during Checkout, after that, the customer no longer has access to order info.

 

Now, there are a couple of ways around it, BUT... you could be looking at security issues.

 

Instead of querying the customer info to get the Order Info, you could just make the query based on the order number. You could pass the order number itself to checkout sucess from checkout_process.php, then use this order number to query the order info.

 

The drawback to this is you are basically giving unsecure (not logged in) access to your order information to someone that is NOT LOGGED IN, which could then be used to gain access to your other customers orders and information.

 

The other, more secure option would be to move the killing of the session info to checkout_success. Instead of killing the session info in checkout_process.php and prior to reaching checkout_success.php, you would have to move this routine to checkout_success, which would kill the session info when the continue button is pressed. This would keep the Customer and Order info intact until the continue button is pressed... and allow the Customer to print the order info.

 

In order to accompish this, you would have to re-code checkout_success.php and checkout_process.php.

 

I hope all of this makes sense and it helps shed light on your issues with PWA.

 

-R

Link to comment
Share on other sites

Hi All!

 

Having Problems with print order on checkout_success.php all is ok but no info echoed i.e Date, invoice no, products etc.

 

allworks fine in account_history_info.php and admin copy of checkout_success.php below... please.. please.. help :D

 

<?php
/*
 $Id: checkout_success.php,v 1.49 2003/06/09 23:03:53 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

// if the customer is not logged on, redirect them to the shopping cart page
 if (!tep_session_is_registered('customer_id')) {
   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }

 if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'update')) {
   $notify_string = 'action=notify&';
   $notify = $HTTP_POST_VARS['notify'];
   if (!is_array($notify)) $notify = array($notify);
   for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
     $notify_string .= 'notify[]=' . $notify[$i] . '&';
   }
   if (strlen($notify_string) > 0) $notify_string = substr($notify_string, 0, -1);

   tep_redirect(tep_href_link(FILENAME_DEFAULT, $notify_string));
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_SUCCESS);

 $breadcrumb->add(NAVBAR_TITLE_1);
 $breadcrumb->add(NAVBAR_TITLE_2);

 $global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'");
 $global = tep_db_fetch_array($global_query);

 if ($global['global_product_notifications'] != '1') {
   $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
   $orders = tep_db_fetch_array($orders_query);

   $products_array = array();
   $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name");
   while ($products = tep_db_fetch_array($products_query)) {
     $products_array[] = array('id' => $products['products_id'],
                               'text' => $products['products_name']);
   }
 }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<script language="javascript"><!--
function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res
izable=yes,copyhistory=no,width=650,height=500,screenX=150,screenY=150,top=150,le
ft=150')
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><?php echo tep_draw_form('order', tep_href_link(FILENAME_CHECKOUT_SUCCESS, 'action=update', 'SSL')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="4" cellpadding="2">
         <tr>
           <td valign="top" class="main"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?><div align="left" class="pageHeading"><?php echo HEADING_TITLE; ?></div><br><?php echo TEXT_SUCCESS; ?><br><br>
<?php
 if ($global['global_product_notifications'] != '1') {
   echo TEXT_NOTIFY_PRODUCTS . '<br><p class="productsNotifications">';

   $products_displayed = array();
   for ($i=0, $n=sizeof($products_array); $i<$n; $i++) {
     if (!in_array($products_array[$i]['id'], $products_displayed)) {
       echo tep_draw_checkbox_field('notify[]', $products_array[$i]['id']) . ' ' . $products_array[$i]['text'] . '<br>';
       $products_displayed[] = $products_array[$i]['id'];
     }
   }

   echo '</p>';
 } else {
   echo TEXT_SEE_ORDERS . '<br><br>' . TEXT_CONTACT_STORE_OWNER;
 }
?>
           <h3><?php echo TEXT_THANKS_FOR_SHOPPING; ?></h3></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr> 
       <td align="left" class="main"><?php echo '<a href="javascript:popupWindow(\'' .  (HTTP_SERVER . DIR_WS_CATALOG . FILENAME_ORDERS_PRINTABLE) . '?' . (tep_get_all_get_params(array('order_id')) . 'order_id=' . $HTTP_GET_VARS['order_id']) . '\')">' . tep_image_button('button_printorder.gif', IMAGE_BUTTON_PRINT_ORDER) . '</a>'; ?></td>
       <td align="right" class="main"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td width="50%" align="right"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
             </tr>
           </table></td>
           <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
           <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
           <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
               <td width="50%"><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td>
             </tr>
           </table></td>
         </tr>
         <tr>
           <td align="center" width="25%" class="checkoutBarFrom"><?php echo CHECKOUT_BAR_DELIVERY; ?></td>
           <td align="center" width="25%" class="checkoutBarFrom"><?php echo CHECKOUT_BAR_PAYMENT; ?></td>
           <td align="center" width="25%" class="checkoutBarFrom"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
           <td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_FINISHED; ?></td>
         </tr>
       </table></td>
     </tr>
<?php if (DOWNLOAD_ENABLED == 'true') include(DIR_WS_MODULES . 'downloads.php'); ?>
   </table></form></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

ON my installation when I place a test order and then try to print an onvoice from the client side, it brings up the login screen requiring me to login again inside the popup window instead of just showing me the invoice. Does anyone know a way around this?

Link to comment
Share on other sites

I have found a very temporary way around the problem, but my biggest concern right now is the ability to view ANY invoice once the PrintOrder window does come up. How can we fix this???

Link to comment
Share on other sites

Hey there Josh,

 

I went to the PWA forum but really couldn't find a whole lot and didn't really want to go seaching through so many pages of posts.

 

Your problem basically comes down to session information. The customers PWA session info is killed just before checkout_success.php is run. I gave you some ideas in my last post... Did you try any of them? Because this functionality does not currently exist, you will either have to be creative in finding a solution, or pay someone to do it for you.

 

Let me know if I can help any further.

 

-R

Link to comment
Share on other sites

  • 2 weeks later...

Quick question for you all. I can see the store logo in the popup print windows in the invoice and packing slips from the admin pannel. When I log in as user the logo doesn't show on the print product details popup windows. How do I enable logo?

Link to comment
Share on other sites

  • 1 month later...

hi, i installed this contribution locally for testing and everything seemed to work fine.

 

So i decided to install it on my active site

 

btw: i only installed the catalog stuff and not the admin part

 

On my active website i don't get errors but when i click on the print onder button i am getting the following:

 

the java window pops up but i don't get to see the order, it only displays my background which was made with the sts template

 

Any idea's

Link to comment
Share on other sites

  • 2 weeks later...
I got almost everything working the way I want, here is some more of the things I did:

 

2) For those using STS, this is the way around it from Brian Gallagher

 

In sts_display_output.php change these lines:

 

CODE

// This is required to prevent display of standard page elements (header, footer, etc) from the template and allow javascript code to run properly

if (strpos($scriptname, "popup") !== false || strpos($scriptname, "info_shopping_cart") !== false) {

$display_normal_output = 1;

$display_template_output = 0;

}

 

 

to this:

 

 

QUOTE

// This is required to prevent display of standard page elements (header, footer, etc) from the template and allow javascript code to run properly

if (strpos($scriptname, "popup") !== false || strpos($scriptname, "info_shopping_cart") !== false || strpos($scriptname, "printorder.php") !== false) {

? $display_normal_output = 1;

? $display_template_output = 0;

}

 

 

That should keep STS from using the template on the printorder file.

 

- Brian

 

I implemented the changed code into the sts_display_output file but, one question, is it supposed to be commented out? Here's what mine is currently, continuing the commented out as was set before:

 

/*  /////////////////////////////////////  ERROR FIXED by Walo /////////////
/////////////////////////////////////////  ERROR FIXED by Walo /////////////
/////////////////////////////////////////  ERROR FIXED by Walo /////////////
// Override if we need to show a pop-up window
$scriptname = $_SERVER['PHP_SELF'];
$scriptname = getenv('SCRIPT_NAME');
$scriptbasename = substr($scriptname, strrpos($scriptname, '/') + 1);
// If script name contains "popup" then turn off templates and display the normal output
// This is required to prevent display of standard page elements (header, footer, etc) from the template and allow javascript code to run properly
if (strpos($scriptname, "popup") !== false || strpos($scriptname, "info_shopping_cart") !== false || strpos($scriptname, "printorder.php") !== false) {
 $display_normal_output = 1;
 $display_template_output = 0;
}
/////////////////////////////////////////  ERROR FIXED by Walo /////EOF/////
*/

 

Is this right?

 

If I uncomment it then it ends up showing me nothing - just a blank page. If I leave it commented, it just takes me back to my index page in my popup.

 

Please help.

 

- Nick

Link to comment
Share on other sites

I thought it might be more helpful if my entire sts_display_output.php file was here... So, here it is:

 

<?php
/*
$Id: sts_display_output.php,v 1.2 2004/02/05 05:57:12 jhtalk Exp $

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

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

/* 

 Simple Template System (STS) - Copyright (c) 2004 Brian Gallagher - [email protected]

*/

// Used for debugging, please don't change
$sts_version = "2.01";
$sts_osc_version = PROJECT_VERSION;
$sts_osc_version_required = "osCommerce 2.2-MS2";



// Perform OSC version checking
if ($sts_osc_version != $sts_osc_version_required) {
 echo "STS was designed to work with OSC version [$sts_osc_version_required].  This is version [$sts_osc_version].\n";
}

$template['debug'] .= ''; // Define as blank if not already defined

/////////////////////////////////////////////
// SELECT HOW TO DISPLAY THE OUTPUT
/////////////////////////////////////////////
$display_template_output = 1;
$display_normal_output = 0;
$display_debugging_output = 0;
$display_version_output = 0;

/*  /////////////////////////////////////  ERROR FIXED by Walo /////////////
/////////////////////////////////////////  ERROR FIXED by Walo /////////////
/////////////////////////////////////////  ERROR FIXED by Walo /////////////
// Override if we need to show a pop-up window
$scriptname = $_SERVER['PHP_SELF'];
$scriptname = getenv('SCRIPT_NAME');
$scriptbasename = substr($scriptname, strrpos($scriptname, '/') + 1);
// If script name contains "popup" then turn off templates and display the normal output
// This is required to prevent display of standard page elements (header, footer, etc) from the template and allow javascript code to run properly
if (strpos($scriptname, "popup") !== false || strpos($scriptname, "info_shopping_cart") !== false || strpos($scriptname, "printorder.php") !== false) {
 $display_normal_output = 1;
 $display_template_output = 0;
}
/////////////////////////////////////////  ERROR FIXED by Walo /////EOF/////
*/


// Override if we need to show a pop-up window
$scriptname = $_SERVER['PHP_SELF'];
$scriptname = strstr($scriptname, "popup");
$scriptname2 = strstr($scriptname, "info_shopping_cart");
// If script name contains "popup" then turn off templates and display the normal output
// This is required to prevent display of standard page elements (header, footer, etc) from the template and allow javascript code to run properly
if ($scriptname != false || $scriptname2 != false) {
$display_normal_output = 1;
$display_template_output = 0;
}

/* Added for popup printorder
// This is required to prevent display of standard page elements (header, footer, etc) from the template and allow javascript code to run properly
if (strpos($scriptname, "popup") !== false || strpos($scriptname, "info_shopping_cart") !== false) {
$display_normal_output = 1;
$display_template_output = 0;
} */

/////////////////////////////////////////////
// Allow the ability to turn on/off settings from the URL
// Set values to 0 or 1 as needed
/////////////////////////////////////////////

// Allow Template output control from the URL
if ($HTTP_GET_VARS['sts_template'] != "") {
$display_template_output = $HTTP_GET_VARS['sts_template'];
}

// Allow Normal output control from the URL
if ($HTTP_GET_VARS['sts_normal'] != "") {
$display_normal_output = $HTTP_GET_VARS['sts_normal'];
}

// Allow Debugging control from the URL
if ($HTTP_GET_VARS['sts_debug'] != "") {
$display_debugging_output = $HTTP_GET_VARS['sts_debug'];
}

// Allow Version control from the URL
if ($HTTP_GET_VARS['sts_version'] != "") {
$display_version_output = $HTTP_GET_VARS['sts_version'];
}

// Print out version number if needed
if ($display_version_output == 1 or $display_debugging_output == 1) {
print "STS_VERSION=[$sts_version]\n";
print "OSC_VERSION=[$sts_osc_version]\n";
}

// Start with the default template
$sts_template_file = STS_DEFAULT_TEMPLATE;

// See if there is a custom template file for the currently running script
$sts_check_file = STS_TEMPLATE_DIR . $scriptbasename . ".html";
if (file_exists($sts_check_file)) {
 // Use it
 $sts_template_file = $sts_check_file;
} 

// Are we in the index.php script?  If so, what is our Category Path (cPath)?
if ($scriptbasename == "index.php") {
 // If no cPath defined, default to 0 (the home page)
 if ($cPath == "") {
$sts_cpath = 0; 
 } else {
       $sts_cpath = $cPath;
 }

 // Look for category-specific template file like "index.php_1_17.html"
 $sts_check_file = STS_TEMPLATE_DIR . "index.php_$sts_cpath.html";

 if (file_exists($sts_check_file)) {
   // Use it
   $sts_template_file = $sts_check_file;
 } 

}

// Open Template file and read into a variable
if (! file_exists($sts_template_file)) {
 echo "Template file doesn't exist: [$sts_template_file]";
}  else {
 echo "<!-- Using Template File [$sts_template_file) -->\n";
}

if (! $fh = fopen($sts_template_file, 'r')) {
echo "Can't open Template file: [$sts_template_file]";
}

$template_html = fread($fh, filesize($sts_template_file));
fclose($fh);


/////////////////////////////////////////////
////// if product_info.php load data
/////////////////////////////////////////////
if ($scriptbasename == 'product_info.php') {
 require(STS_PRODUCT_INFO);
}

/////////////////////////////////////////////
////// Run any user code needed
/////////////////////////////////////////////
require(STS_USER_CODE);

/////////////////////////////////////////////
////// Set up template variables
/////////////////////////////////////////////

$template['title'] = (HEADING_TITLE);

/////////////////////////////////////////////
////// Capture <title> and <meta> tags
/////////////////////////////////////////////

// STS: ADD: Support for WebMakers.com's Header Tag Controller contribution
 // Capture the output
// Modified to work with Article Manager (which uses custom headers)
if ($use_ah_tags == 'true') {
require(DIR_WS_INCLUDES . 'article_header_tags.php');
// don't process HTC - use headertags from article_header_tags
} else {

 require(STS_START_CAPTURE);
if ($cPath && ($HTTP_GET_VARS['products_id'] < '20'))  {
 
 // RJW Begin Meta Tags Code
 if (file_exists(DIR_WS_INCLUDES . 'meta_tags.php')) {
   require(DIR_WS_INCLUDES . 'meta_tags.php');
 } else {
   echo '<title>' . TITLE . $title . '</title>';
 }
 // RJW End Meta Tags Code

} else  {
 // BOF: WebMakers.com Changed: Header Tag Controller v1.0
 // Replaced by header_tags.php
 if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {
//    require(DIR_WS_FUNCTIONS . 'clean_html_comments.php');
   require(DIR_WS_FUNCTIONS . 'header_tags.php');
   require(DIR_WS_INCLUDES . 'header_tags.php');
 } else {
   echo "<title>" . TITLE . $title . "</title>";
 }
 // EOF: WebMakers.com Changed: Header Tag Controller v1.0
}
 $sts_block_name = 'headertags';
 require(STS_STOP_CAPTURE);
}
// STS: EOADD: Support for WebMakers.com's Header Tag Controller contribution

/////////////////////////////////////////////
////// Set up template variables
/////////////////////////////////////////////

 $template['sid'] =  tep_session_name() . '=' . tep_session_id();

 // Strip out <title> variable
 $template['title'] = str_between($sts_block['headertags'], "<title>", "</title>");

 // Load up the <head> content that we need to link up everything correctly.  Append to anything that may have been set in sts_user_code.php
 $template['headcontent'] .= '<meta http-equiv="Content-Type" content="text/html; charset=' . CHARSET . '">' . "\n"; 
 $template['headcontent'] .= $sts_block['headertags'];
 $template['headcontent'] .= '<base href="' . (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG . '">' . "\n";
 // $template['headcontent'] .= '<link rel="stylesheet" type="text/css" href="stylesheet.css">' . "\n";
 $template['headcontent'] .= get_javascript($sts_block['applicationtop2header'],'get_javascript(applicationtop2header)');
  

 // Note: These values lifted from the stock /catalog/includes/header.php script's HTML
 // catalogurl: url to catalog's home page
 // catalog: link to catalog's home page
 $template['cataloglogo'] = '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . '</a>';
 $template['urlcataloglogo'] = tep_href_link(FILENAME_DEFAULT);

 $template['myaccountlogo'] = '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_account.gif', HEADER_TITLE_MY_ACCOUNT) . '</a>';
 $template['urlmyaccountlogo'] = tep_href_link(FILENAME_ACCOUNT, '', 'SSL');

 $template['cartlogo'] = '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image(DIR_WS_IMAGES . 'header_cart.gif', HEADER_TITLE_CART_CONTENTS) . '</a>';
 $template['urlcartlogo'] = tep_href_link(FILENAME_SHOPPING_CART);

 $template['checkoutlogo'] = '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_CHECKOUT) . '</a>';
 $template['urlcheckoutlogo'] = tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL');

 $template['breadcrumbs'] = $breadcrumb->trail(' » ');

 if (tep_session_is_registered('customer_id')) {
   $template['myaccount'] = '<a href=' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . ' class="headerNavigation">' . HEADER_TITLE_MY_ACCOUNT . '</a>';
   $template['urlmyaccount'] = tep_href_link(FILENAME_ACCOUNT, '', 'SSL');
   $template['logoff'] = '<a href=' . tep_href_link(FILENAME_LOGOFF, '', 'SSL')  . ' class="headerNavigation">' . HEADER_TITLE_LOGOFF . '</a>';
   $template['urllogoff'] = tep_href_link(FILENAME_LOGOFF, '', 'SSL');
   $template['myaccountlogoff'] = $template['myaccount'] . " | " . $template['logoff'];
 } else {
   $template['myaccount'] = '<a href=' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . ' class="headerNavigation">' . HEADER_TITLE_MY_ACCOUNT . '</a>';
   $template['urlmyaccount'] = tep_href_link(FILENAME_ACCOUNT, '', 'SSL');
   $template['logoff'] = '';
   $template['urllogoff'] = '';
   $template['myaccountlogoff'] = $template['myaccount'];
 }

 $template['cartcontents']    = '<a href=' . tep_href_link(FILENAME_SHOPPING_CART) . ' class="headerNavigation">' . HEADER_TITLE_CART_CONTENTS . '</a>';
 $template['urlcartcontents'] = '<a href=' . tep_href_link(FILENAME_SHOPPING_CART) . ' class="headerNavigation">' . HEADER_TITLE_CART_CONTENTS . '</a>';

 $template['checkout'] = '<a href=' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . ' class="headerNavigation">' . HEADER_TITLE_CHECKOUT . '</a>';
 $template['urlcheckout'] = tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL');

/////////////////////////////////////////////
////// Create custom boxes
/////////////////////////////////////////////
 $template['categorybox'] = strip_unwanted_tags($sts_block['categorybox'], 'categorybox');
 $template['manufacturerbox'] = strip_unwanted_tags($sts_block['manufacturerbox'], 'manufacturerbox');
 $template['whatsnewbox'] = strip_unwanted_tags($sts_block['whatsnewbox'], 'whatsnewbox');
 $template['searchbox'] = strip_unwanted_tags($sts_block['searchbox'], 'searchbox');
 $template['informationbox'] = strip_unwanted_tags($sts_block['informationbox'], 'informationbox');
 $template['cartbox'] = strip_unwanted_tags($sts_block['cartbox'], 'cartbox');
 $template['maninfobox'] = strip_unwanted_tags($sts_block['maninfobox'], 'maninfobox');
 $template['orderhistorybox'] = strip_unwanted_tags($sts_block['orderhistorybox'], 'orderhistorybox');
 $template['bestsellersbox'] = strip_unwanted_tags($sts_block['bestsellersbox'], 'bestsellersbox');
 $template['specialfriendbox'] = strip_unwanted_tags($sts_block['specialfriendbox'], 'specialfriendbox');
 $template['reviewsbox'] = strip_unwanted_tags($sts_block['reviewsbox'], 'reviewsbox');
 $template['languagebox'] = strip_unwanted_tags($sts_block['languagebox'], 'languagebox');
 $template['currenciesbox'] = strip_unwanted_tags($sts_block['currenciesbox'], 'currenciesbox');
 $template['content'] = strip_content_tags($sts_block['columnleft2columnright'], 'content');
 // Prepend any error/warning messages to $content
 if ($messageStack->size('header') > 0) {
   $template['content'] = $messageStack->output('header') . $template['content'];
 }
 $template['date'] = strftime(DATE_FORMAT_LONG);
 $template['numrequests'] = $counter_now . ' ' . FOOTER_TEXT_REQUESTS_SINCE . ' ' . $counter_startdate_formatted;
 $template['counter'] = $sts_block['counter'];
 $template['footer'] = $sts_block['footer'];
 $template['banner'] = $sts_block['banner'];

 
/////////////////////////////////////////////
////// Get Categories
/////////////////////////////////////////////
$get_categories_description_query = tep_db_query("SELECT categories_id, categories_name FROM " . TABLE_CATEGORIES_DESCRIPTION);
// Loop through each category (in each language) and create template variables for each name and path
while ($categories_description = tep_db_fetch_array($get_categories_description_query)) {
     $cPath_new = tep_get_path($categories_description['categories_id']);
     $path = substr($cPath_new, 6); // Strip off the "cPath=" from string

     $catname = $categories_description['categories_name'];
     $catname = str_replace(" ", "_", $catname); // Replace Spaces in Category Name with Underscores

     $template["cat_" . $catname] = tep_href_link(FILENAME_DEFAULT, $cPath_new);
     $template["urlcat_" . $catname] = tep_href_link(FILENAME_DEFAULT, $cPath_new);
     $template["cat_" . $path] = tep_href_link(FILENAME_DEFAULT, $cPath_new);
     $template["urlcat_" . $path] = tep_href_link(FILENAME_DEFAULT, $cPath_new);

     // print "<b>template[" . $categories_description['categories_name'] . "]=" . $template[$categories_description['categories_name']] . "<br>template[" . $path . "]=" . $template[$path] . "</b>";
}

/////////////////////////////////////////////
////// Display Template HTML
/////////////////////////////////////////////

 // Sort array by string length, so that longer strings are replaced first
 uksort($template, "sortbykeylength");

 // Manually replace the <!--$headcontent--> if present
   $template_html = str_replace('<!--$headcontent-->', $template['headcontent'], $template_html);

 // Automatically replace all the other template variables
 foreach ($template as $key=>$value) {
   $template_html = str_replace('$' . $key, $value, $template_html);
 }

 if ($display_template_output == 1) {
   echo $template_html;
 }


/////////////////////////////////////////////
////// Display HTML
/////////////////////////////////////////////
if ($display_normal_output == 1) {
 echo $sts_block['applicationtop2header'];
 echo $sts_block['header'];


 echo $sts_block['header2columnleft'];

 // print column_left stuff
 echo $sts_block['categorybox'];
 echo $sts_block['manufacturerbox'];
 echo $sts_block['whatsnewbox'];
 echo $sts_block['searchbox'];
 echo $sts_block['informationbox'];

 echo $sts_block['columnleft2columnright'];

 // print column_right stuff
 echo $sts_block['cartbox'];
 echo $sts_block['maninfobox'];
 echo $sts_block['orderhistorybox'];
 echo $sts_block['bestsellersbox'];
 echo $sts_block['specialfriendbox'];
 echo $sts_block['reviewsbox'];
 echo $sts_block['languagebox'];
 echo $sts_block['currenciesbox'];

 echo $sts_block['columnright2footer'];

 // print footer
 echo $sts_block['content'];
 echo $sts_block['counter'];
 echo $sts_block['footer'];
 echo $sts_block['banner'];
}
/////////////////////////////////////////////
////// End Display HTML
/////////////////////////////////////////////

if ($display_debugging_output == 1) {
 // Print Debugging Info
 print "\n<pre><hr>\n";
 print "STS_VERSION=[" . $sts_version . "]<br>\n";
 print "OSC_VERSION=[$sts_osc_version]\n";
 print "STS_TEMPLATE=[" . $sts_template_file . "]<hr>\n";
 // Replace $variable names in $sts_block_html_* with variables from the $template array
 foreach ($sts_block as $key=>$value) {
   print "<b>\$sts_block['$key']</b><hr>" . htmlspecialchars($value) . "<hr>\n";
 }

 foreach ($template as $key=>$value) {
   print "<b>\$template['$key']</b><hr>" . htmlspecialchars($value) . "<hr>\n";
 }

}

if ($display_normal_output == 1) {
 echo $sts_block['footer2applicationbottom'];
}

// STRIP_UNWANTED_TAGS() - Remove leading and trailing <tr><td> from strings
function strip_unwanted_tags($tmpstr, $commentlabel) {
 // Now lets remove the <tr><td> that the require puts in front of the tableBox
 $tablestart = strpos($tmpstr, "<table");

 // If empty, return nothing
 if ($tablestart < 1) {
	 return  "\n<!-- start $commentlabel //-->\n$tmpstr\n<!-- end $commentlabel //-->\n";
 }

 $tmpstr = substr($tmpstr, $tablestart); // strip off stuff before <table>

 // Now lets remove the </td></tr> at the end of the tableBox output
 // strrpos only works for chars, not strings, so we'll cheat and reverse the string and then use strpos
 $tmpstr = strrev($tmpstr);

 $tableend = strpos($tmpstr, strrev("</table>"), 1);
 $tmpstr = substr($tmpstr, $tableend);  // strip off stuff after </table>

 // Now let's un-reverse it
 $tmpstr = strrev($tmpstr);

 // print "<hr>After cleaning tmpstr:" . strlen($tmpstr) . ": FULL=[".  htmlspecialchars($tmpstr) . "]<hr>\n";
 return  "\n<!-- start $commentlabel //-->\n$tmpstr\n<!-- end $commentlabel //-->\n";
}


// STRIP_CONTENT_TAGS() - Remove text before "body_text" and after "body_text_eof"
function strip_content_tags($tmpstr, $commentlabel) {
 // Now lets remove the <tr><td> that the require puts in front of the tableBox
 $tablestart = strpos($tmpstr, "<table");
 $formstart = strpos($tmpstr, "<form");

 // If there is a <form> tag before the <table> tag, keep it
 if ($formstart !== false and $formstart < $tablestart) {
    $tablestart = $formstart;
    $formfirst = true;
 }

 // If empty, return nothing
 if ($tablestart < 1) {
       return  "\n<!-- start $commentlabel //-->\n$tmpstr\n<!-- end $commentlabel //-->\n";
 }
 
 $tmpstr = substr($tmpstr, $tablestart); // strip off stuff before <table>

 // Now lets remove the </td></tr> at the end of the tableBox output
 // strrpos only works for chars, not strings, so we'll cheat and reverse the string and then use strpos
 $tmpstr = strrev($tmpstr);

 if ($formfirst == true) {
   $tableend = strpos($tmpstr, strrev("</form>"), 1);
 } else {
   $tableend = strpos($tmpstr, strrev("</table>"), 1);
 } 

 $tmpstr = substr($tmpstr, $tableend);  // strip off stuff after <!-- body_text_eof //-->

 // Now let's un-reverse it
 $tmpstr = strrev($tmpstr);

 // print "<hr>After cleaning tmpstr:" . strlen($tmpstr) . ": FULL=[".  htmlspecialchars($tmpstr) . "]<hr>\n";
 return  "\n<!-- start $commentlabel //-->\n$tmpstr\n<!-- end $commentlabel //-->\n";
}


function get_javascript($tmpstr, $commentlabel) {
 // Now lets remove the <tr><td> that the require puts in front of the tableBox
 $tablestart = strpos($tmpstr, "<script");

 // If empty, return nothing
 if ($tablestart === false) {
	 return  "\n<!-- start $commentlabel //-->\n\n<!-- end $commentlabel //-->\n";
 }

 $tmpstr = substr($tmpstr, $tablestart); // strip off stuff before <table>

 // Now lets remove the </td></tr> at the end of the tableBox output
 // strrpos only works for chars, not strings, so we'll cheat and reverse the string and then use strpos
 $tmpstr = strrev($tmpstr);

 $tableend = strpos($tmpstr, strrev("</script>"), 1);
 $tmpstr = substr($tmpstr, $tableend);  // strip off stuff after </table>

 // Now let's un-reverse it
 $tmpstr = strrev($tmpstr);

 // print "<hr>After cleaning tmpstr:" . strlen($tmpstr) . ": FULL=[".  htmlspecialchars($tmpstr) . "]<hr>\n";
 return  "\n<!-- start $commentlabel //-->\n$tmpstr\n<!-- end $commentlabel //-->\n";
}

// Return the value between $startstr and $endstr in $tmpstr
function str_between($tmpstr, $startstr, $endstr) {
 $startpos = strpos($tmpstr, $startstr);

 // If empty, return nothing
 if ($startpos === false) {
       return  "";
 }

 $tmpstr = substr($tmpstr, $startpos + strlen($startstr)); // strip off stuff before $start

 // Now lets remove the </td></tr> at the end of the tableBox output
 // strrpos only works for chars, not strings, so we'll cheat and reverse the string and then use strpos
 $tmpstr = strrev($tmpstr);

 $endpos = strpos($tmpstr, strrev($endstr), 1);

 $tmpstr = substr($tmpstr, $endpos + strlen($endstr));  // strip off stuff after </table>

 // Now let's un-reverse it
 $tmpstr = strrev($tmpstr);

 return  $tmpstr;
}

function sortbykeylength($a,$b) {
 $alen = strlen($a);
 $blen = strlen($b);
 if ($alen == $blen) $r = 0;
 if ($alen < $blen) $r = 1;
 if ($alen > $blen) $r = -1;
 return $r;
}

?>

 

Please, anyone?

Link to comment
Share on other sites

I think that you can define how the date is shown in:

 

catalog/includes/languages/english.php

 

Look for:

 

define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime()

 

Try swapping %d and %B with each other... see if it works. Sorry I haven't tested so cannot be 100% sure if it will work. You may have to otherwise mess around with the database!

 

Regards

 

Jiten

Worked just fine... Thank you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...