Mysterious Solutions to Tracking Mysteries

greenspun.com : LUSENET : S-Mart Shopping Cart : One Thread

Some time ago, a fellow posted a message about tracking solutions that others criticized as "clear as mud". Since I was having problems with that same issue, I dove into his mud and waded through the mud of my scripts. I think I've discovered a conflict in the various calls the scripts make which probably only arises when your server treats all cgi operations as "anonymous".

When that's the case, of course, you have to have world permissions to various files that are written to -- 777, right? This ain't a problem unless you can't or don't want to do that with your cgi-bin directories or wherever you are storing the cgi programs themselves.

But I do have that server situation and I have a problem with making my cgi-bin world everything since there are some nasties in this wonderful world.

I think it's worth working through all this because, when these conflicts are removed, this is a pretty damned amazing shopping cart program for freeware!!! Truly amazing code writing, in my opinion.

Here's what I think and others please correct me if I'm off base.

smart.cfg configures /tmp and track.db as if they are merely tags to the basepath configuration. In other words, you configure the basepath there and then /tmp and track.db should be automatically added when the script calls them. Right?

But I don't think S-Mart.cgi gets the point because it seems to treat those two files (and maybe a couple of others...not sure) as if they reside in the same folder as it does. In my case, it's a sub-directory of cgi-bin. So the main program, S-Mart.cgi, looks at its config cousin -- smart.cfg -- sees the temporary file called /tmp and says, "That's right here in the same directory as I." and then tries to write to it.

Of course, it can't if your server doesn't allow this kind of writing. And you'll NEVER know it because there is no err code to tell you that there was an error writing to these files! At least I didn't see any and none came up while I was suffering through these travails.

What I've done is to put those files (tmp and track.db) in another directory that is hidden on my server (not public, in others words) and then in smart.cfg I just wrote the entire path -- something like /home/web/mydirectory/thedirectorythestuffisin/tmp and I did the same with track.db. That's NOT close to what my paths look like but you get the point I hope.

Then, because only in a perfect world would one be finished, I had to go into smartadmin.cgi. As most of us know, THAT is the program that now does the track (smarttrack was scuttled for security reasons).

smartadmin.cgi DOES including the basepath when it calls tmp and other files. It makes the calls just as it should if you didn't include the full path in smart.cfg. So you have to go through that script in the "tracking section" and eliminate all "$basepath" write code. For instance,

$basepath$delim$trackdb

now becomes just

$trackdb

and this works famously. Except for one thing:

I can't get the program to write and retrieve a tracking number. That is writing a "NULL" in the track.db file.

Same again with /tmp file. Wasn't working and I did this and voila.

OH YES!!! and I couldn't get the program to update my item id number. I put the full path in THAT configuration in smart.cfg and the program is purring! :-)

Two problems with this approach. One, I've no idea if my theory about permissions is correct although my hunch is that this IS the problem. Two, I don't know if these reconfigurations will adversely affect other operations although I've tested them a lot and it all works. Three, nobody else may have been having these problems in which case I apologize to those of you who have read this far. Four, the entire above explanation is probably also as "clear as mud" but here in Brooklyn, New York "mud is the staff of life".

So? Does this help anybody but me?

-- Alfredo Lopez (alfredo@people-link.com), May 04, 1999

Answers

Hi,

You might of went the long way around to fix an easy problem. In the "s-mart.cfg" file where the "$basepath" is that is fine if you look in "s-mart.cgi" file you will see "$basepath$delim$trackdb" or "$basepath$delim$tmpdir" the "$delim" is another way of putting "/" for Unix or "\" for Windows NT or ":" for useing Mac if you pick the setting for your server you do not have to rewrite the whole script. So "$basepath$delim" = "/www/user/cgi-bin" for "$basepath" and "/" for "$delim". If in the "s-mart.cfg" file you use "/tmp" that is useing two "/" one in the ".cgi" script and one in the ".cfg" script when I did not use the extra "/" in front of "tmp" everything worked fine. If you use a different directory for "tmp" you can set your "$basepath" then stack your "tmp" directory like this "smart/tmp" or "cgi-bin/smart/tmp" for how ever you set the file directory up. Most of the problems I came across was because of the "smart.cfg" file having the wrong settings. Check your ".cfg" file before you change the ".cgi" file.

And after all that I am probaly "just as clear as mud".

Jim

-- James L. Farmer (jim@team-blankets.com), June 07, 1999.


Moderation questions? read the FAQ