PDA

View Full Version : MyRxBiz? Don’t Look Stupid, Stupid!



scottdaman
October 12th, 2003, 05:15 PM
LOL, sorry for the catchy title. smileys/smiley8.gif


Hey, I am a huge fan of Server Side Includes (SSI) and I just figured out something sweet and kinda easy to pull off if you are an affiliate of MyRxBiz and use their templates to pull prices via PHP (read: you are on a unix server).


Kinda easy because you have to know how to use SSI.


Don't look stupid, stupid!?!


Sorry, but go into your browser settings:
Tools > Internet Options > Security Tab > Custom Level (button) > Switch all "Scripting" to Disable.


Click ok through everything and look at your MyRxBiz site through some people's eyes (albeit only a few people.. but a few sales is worth it, right?)


If you followed along and are using a default template, all your prices DO NOT LOAD. Now the people that teased that newbie that they didn't have prices, eat your words! HAHA! smileys/smiley4.gif


Note: This is also what google sees as far as I understand. It don't read javascript either.. (read: higher relevancy for the product keywords if you fix this)


So, what'd I do to fix this?
(Yanno, I have kids who watch Bob the Builder. That damn "Can he fix it!" saying keeps coming up in my head.. LMAO)smileys/smiley23.gif


SSI baby!


In your html files where the prices are pulled, you'll notice:
<script language="JavaScript" type="text/JavaScript"src="order/table.php?cat=phentermine"></script>
<script language="JavaScript">writeTable();</script>


Ahhh, javascript patooey!


I changed it to read:
<!--#include virtual="/order/table.php?cat=phentermine" -->


Doing this, you'll get the prices but some stupid lookin' javascript code will also show up in your browser.


Don't worry, easy fix.


Open /order/table.php in your text editor like notepad (or DreamWeaver)


On line 18 of this file, you'll see:
print "function writeTable() { document.write('".$output."'); }";


Change this to:
print "$output"


Now, the bad part is your file extensions need to be *.shtml instead of *.htm. I don't know the code offhand but you can edit your .htaccess file in your server to parse *.htm as *.shtml so the server knows it needs to look for SSI to include in your html documents.


I'm hoping a .htaccess guru will step in and fill this part up for your folks. I simply renamed my files...


Don't say I didn't help you!


Giving back...


Now, if someone can return the favor and hook me up with some PHP scripts to parse EVA's XML files to plain text so I can get my prices to load without javascript, I'd appreciate it big time!


Scott


P.S. I recommend copying a html doc that has prices and make a table2.php to test first BEFORE you go live. Use the SSI above but just point the temporary test file to table2.php to test with.


P.S.S. If you don't test it first, use this info at your own risk! smileys/smiley4.gif

redex
October 12th, 2003, 08:52 PM
Kinda easy because you have to know how to use SSI.


Why use SSI and rename your files? You already have PHP capabilities and the file you are getting the info from is PHP??????



Now, if someone can return the favor and hook me up with some PHP scripts to parse EVA's XML files to plain text so I can get my prices to load without javascript, I'd appreciate it big time!


RxRob already did this in another thread.


tss.eapps.com XML price schedules and PHP (http://www.rxaffiliateforum.com/forum_posts.asp?TID=267&KW=curl)

scottdaman
October 13th, 2003, 01:15 AM
Redex,


The way MyRxBiz shipped this to me, the price tables are pulled from the PHP file system via javascript.


If someone has javascript disabled, the PHP file stuff is NOT LOADED. That's why I went the SSI route. I did it because I already converted my files to SSI so I can use SSI for a lot of other includes.


http://www.rxaffiliateforum.com/forum_posts.asp?TID=267&PN=0&TPN=2


First post, awesome. Thanks.

scottdaman
October 13th, 2003, 03:16 AM
.htaccess mod to not have to change extension to .shtml


AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm

rxcdn
October 13th, 2003, 04:03 AM
Or so you don't have to use SSI and can use straight php


in .htaccess


AddType application/x-httpd-php htm


On med page replacejs crap with:


<? $_GET['cat'] = 'viagra'; include('table.php'); echo $output; ?>


--

scottdaman
October 13th, 2003, 04:19 AM
@rxcdn


Obviously I am very very very new with PHP.


Because I don't want .php extensions and want .htm extensions, the .htaccess you entered above will execute .htm as .php. Right?


Now, take a look at:
http://www.rxaffiliateforum.com/forum_posts.asp?TID=267&PN=0&TPN=2


I saved this script as prices.php.


For an eva page, how do I call the prices.php to use the command:
echo $drugs['Xenical90'];
Within my .htm document?


Obviously, one, I need to make the .htaccess change. Then?

rxcdn
October 13th, 2003, 04:36 AM
In .htaccess (makes .htm the same as .php)


AddType application/x-httpd-php .htm


--


At the top of your med page


<? include('prices.php'); ?>


--


In your med page exactly where you want the price to appear:


<?=$_drugs['Xenical90']?>


--


For incresed efficiency, sessions should be used, as right now you are fetching/parsing the XML file on every page load, but make sure this works first.

scottdaman
October 13th, 2003, 06:28 AM
Not working for me.


Right now, I am going .php extension first to see if it works. If I take that php script and use command:
echo $drugs['viag0'];


Outside of the comment tag in that script, I do in fact get the price for Viagra. So, I know the php script is in fact working.


However, I put
<? include('prices.php'); ?>
On line one of a new .php file (test.php)above the <html> commands then in the body I put:
<?=$_drugs['viag0']?>


Nothing loads and I get a blank page. Any suggestions?

redex
October 13th, 2003, 06:35 AM
<TABLE cellSpacing=0 cellPadding=0 width="95%" align=center>
<T>
<TR>
<TD class=bold>rxcdn wrote:

<TABLE cellSpacing=0 cellPadding=1 width="100%" bgColor=#999999>
<T>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=2 width="100%" bgColor=#ffffff>
<T>
<TR>
<TD class=text>In .htaccess (makes .htm the same as .php)





AddType application/x-httpd-php .htm


--</TD></TR></T></TABLE></TD></TR></T></TABLE></TD></TR></T></TABLE>


Only problem with that is no modified date is passed with the page.Bad forSE spiders. Add this at the top of your code on every .htm page before the opening &lt;HTML&gt; tag:


&lt;? header("Last-Modified: " . date("r", filemtime($SCRIPT_FILENAME))); ?&gt;

scottdaman
October 13th, 2003, 06:44 AM
Ok, got it working!


Simple error:
&lt;?=$_drugs['viag0']?&gt;


Needs to be:
&lt;?=$drugs['viag0']?&gt;


Redex, how do you handle the php file? Do you use a *.htm extension or are you use *.php for your pages?


If using *.htm, is the method above the way you are handling this?Or are you doing something slightly different.


Good tip about the last modified date. Didn't know the SE's would see a page unmodified when it really was.

rxcdn
October 13th, 2003, 06:47 AM
Sorry about the bad code, there is an extra underscore in there.


&lt;?=$_drugs['Xenical90']?&gt; should be &lt;?=$drugs['Xenical90']?&gt;


(BTW, the line &lt;?= $var ?&gt; is just shorthand for&lt;?php echo $var; ?&gt;)


------------


Here is the complete code with sessions (modified from RxRob) in case you want to explore this option more:


&lt;?php if (isset($_SESSION['drugs'])) return;
$host=$_SERVER['HTTP_HOST'];
if (substr($host,0,4)=='www.') $host=substr($host,4);//get rid of www, we'll add it later.
$ch = curl_init('https://tss.eapps.com/www.'.$host.'.xml');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
$file = explode("\n", $data);
$drugs=array();
function startElement($parser, $name, $attrs) {
global $drugs;
if ($attrs['LINK']) {
$drugs[$attrs['LINK']] = $attrs['PRICE'];
$drugs[$attrs['LINK'].'ship'] = $attrs['SHIPPING'];
}
}
function endElement($parser, $name) {
// Nothing to do.
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
while ($line=array_shift($file)){
xml_parse($xml_parser, $line);
}
xml_parser_free($xml_parser); $_SESSION['drugs']=$drugs;?&gt;


--


At the top of each med page &lt;? session_start(); include('prices.php'); ?&gt;


and to display it on your med page: &lt;?=$_SESSION['drugs']['viagra']?&gt;

redex
October 13th, 2003, 06:55 AM
Redex, how do you handle the php file? Do you use a *.htm extension or are you use *.php for your pages?


If using *.htm, is the method above the way you are handling this?Or are you doing something slightly different.





I use both, tried retaining the .htm or .html extensions but I think I prefer .php (keep it native)



Good tip about the last modified date. Didn't know the SE's would see a page unmodified when it really was.


Not that it wouldn't see an unmodified page, it woul;d get no mod date at all and maybe just bypass the page altogether. Wish I rememberd where I got that tip from. They explained it well and it made sense to me.

scottdaman
October 13th, 2003, 07:24 AM
@rxcdn


Thank you for the session code. That is working for me as well. No problems.


If I can figure out what a session does, it basically will only pull the XML doc from eapps once per user instead of once per page.


Effectively, it pulls the xml file once even if they view 50 med pages vs with no session, it would be pulled 50 times.


@redex


Thank you for the input. All this has been very helpful.


Now, how hard would it be *if possible at all* to get SSI working as well with this. Typically, it has to be *.shtml. I'm thinking something bad would happen if I did a .htaccess mod to treat *.shtml as PHP. Even if it did work, I don't think any SSI commands will work.


I have a feeling I have to recode my entire site to get everything working and use some sort of include via PHP commands.


In that case, I will use this PHP info on my next EVA site and code it right from the get go.


Scott

scottdaman
October 13th, 2003, 08:02 AM
Well, that was easy. I changed the typical SSI path to:


&lt;?php
include 'filename.htm';
?&gt;


That will be easy to batch find/replace with dreamweaver.


I got everything I need now.


Thanks everyone!


Scott

smokey
October 13th, 2003, 11:41 PM
use asp and you wont have that problem....smileys/smiley16.gif

redex
October 13th, 2003, 11:56 PM
use asp and you wont have that problem....smileys/smiley16.gif


A-W-F-U-L-L-Y S-L-O-W P-E-R-F-O-R-M-A-N-C-E smileys/smiley8.gif


Sorry. My opinion. smileys/smiley14.gif


Yeah I know, opinions are like assholes, everybody's got one. Besides, I hate Billy G. and MircoShaft. Especially when it comes to web servers.

smokey
October 14th, 2003, 12:21 AM
No offence taken...


Not much choice100% Microsoft Network Here.

scottdaman
October 14th, 2003, 01:45 AM
Yeah, I'd rather go through this than go NT.....smileys/smiley14.gif

rxcdn
October 14th, 2003, 03:21 AM
There is nothing wrong with ASP.


Apache::ASP with mod_perl that is. smileys/smiley1.gif

smokey
October 14th, 2003, 03:32 AM
I currently don't have any performance problems with asp right now but I'm starting down the road to migrate everthing over to asp.net.

redex
October 14th, 2003, 03:39 AM
A prime example of how slow ASP is, is this forum. Sometines the page takes for ever it seems. (no offense admin!)

smokey
October 14th, 2003, 03:57 AM
it seems like the html editor is what is taking so long to load..