Re: STS BUGFIX: contact_us.php and other form-using scripts

southmodel <[email protected]>
Newsgroups gmane.comp.web.oscommerce.contributions
Message-ID <c6cc48ea2f6dbb6f35a8c8eb3d896c53@osCommerce-Forums>
This message was sent from: Contributions
http://forums.oscommerce.com/viewtopic.php?p=226672#226672
----------------------------------------------------------------

[quote="DiamondSea"]Moved from General Support Forum
Post subject: Simple Template System (STS) 1.0):[quote="southmodel"]Hi, your script is wonderful but after installation, "contact_us.php" module don't work! please help[/quote]
Thanks!

I'm glad you like it!  Here's the fix:

Add the [b]second block of code[/b] below into the [b]strip_content_tags()[/b] function down near the bottom of [b]application_bottom.php[/b]:

[code]// 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");
[/code][code]  $formstart = strpos($tmpstr, "<form");
  
  // If there is a <form> tag before the <table> tag, keep it
  if ($formstart < $tablestart) {
     $tablestart = $formstart;
  }

[/code][code]  // 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 <!-- 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";
} 
[/code]

I'll wait a couple days for people to find any more bugs and then I'll put up an updated contribution with the fixes added.[/quote]

Now work it all perfectly, many, many, thanks.  :D
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.