benkaminski.com

write off the top of my head…

Javascript rewrite for Volusion templates

Written By: BEN - Sep• 22•10
avatar

Volusion is probably one of the top 3 eCommerce solutions for small businesses on the internet. They offer credit card online transactions through Visa and Mastercard for considerably less than other alternatives, and secure trading over the internet.

What they don’t offer is a lot of wiggle room to customize the look of the website. The templates are fully customizable, but not for the content are of the site, such as the product display and category displays. Since Volusion uses .ASP pages to call their data, the pages are encrypted and aren’t given access to.

One of the most important things that Volusion stresses in their training videos is the importance of visual presentation, and then they don’t give you the ability to edit the look of one of the most critical parts of the site!

Luckily, thanks to a little research, and guidance from fellow web developers, scripts of javascript code can be used to identify certain parts of the site, and insert your own lines of code.


Volusion’s .ASP pages write the code in tables, as opposed to div tags, which are horrendous for SEO purposes, and also, you won’t have a div class to identify and override in your CSS. What you essentially have to do is identify a page by it’s URL, identify a table cell by it’s tag, insert your div tag in the table cell, and then write the corresponding CSS for that tag. Here’s how, step by step:

1) Identify the page you want to make changes on:

In the template of your Volusion site, insert the following code after your final div tag, but before the tag:

<script type="text/javascript">
//var sPath = location.href;
//if(sPath.indexOf('URL element
defined by you') != -1) {

if(location.href.indexOf('URL element
defined by you') != -1) {
</script>

All this is doing is essentially telling the javascript, if the page you are currently on involves ‘this’ in the URL, begin the code. It SHOULD NOT be the entire URL, but a unique part of the URL that Volusion uses, for example : ‘category_s’ or ‘product_p’.

2) Tell the code to begin identifying tables by cell:

Now you have to tell the code to create a variable based on which block element you want to use.

var tdTags = new Array();
var tdTags = document.getElementsByTagName('td');

What you are doing is creating a variable called ‘tdTags’ and you are getting that specific block element by the type which in this case is a table cell (td). You can use this code later for other purposes, because it will identify block elements only, i.e. div, table, tr or whatever.

3) Call to a specific cell table by number:

This is the fun part. Since the pages are written in tables, and tables flow left to right, you basically have to call to them by number, like 1, 2, 3, and so on.

var replcode = tdTags[8].innerHTML;
tdTags[8].innerHTML = "<div class="YOUR CSS CLASS HERE ">"
+  replcode + "</div>"

So here, it’s calling to table cell # 8, and telling it, take that table cell, wrap it in a div tag with the class name of your choosing, put the code back in, and then close the div. You can now go to your CSS, write that class style, and it will now insert it for that particular table cell, for that page only.

Basically, when you are done, the code should look like this:

 <script type="text/javascript">
//var sPath = location.href;
//if(sPath.indexOf('URL element defined by you') != -1) {

if(location.href.indexOf('URL element
defined by you') != -1) {

var tdTags = new Array();
var tdTags = document.getElementsByTagName('td');

var replcode = tdTags[TABLE CELL NUMBER].innerHTML;
tdTags[TABLE CELL NUMBER].innerHTML =
"<div class="HERE ">" +  replcode + "</div>";

}
</script>

You can repeat the last 2 lines of code and change the numbers as much as you’d like in the script. You can edit multiple table cells in one particular page, but if you change pages, you will have to write a new script, with a new unique URL element. Try it out, and see how it works for you.

PROBLEMS WITH USING THIS CODE :

It doesn’t come without its strings. I’ve definately encountered a few problems using this trick to get the look you want. The most notable :

1) Elements change constantly on a Volusion store. The idea behind being a web developer is turning this online store over to a client after the finished product is there. Since this code is POST data retrieval, when a client finally has their store up and running, their products may change, descriptions will change, amounts will change, and thus the table element’s numbers will change. The code will still work, but it may not call to the table cells you want anymore. This is NOT a dynamic script, sadly.

This is especially tricky is when you have a page that contains say 10 items, and then the next page has 5. The table’s are written left to write, not up and down, so if there is only 5 items, the table cells’ numbers will change for that last product, and it will take on the wrong elements and insert them. Unless you’re a super incredible web developer and want to insert a loop into your javascript code to prevent this (which sounds like a shit load of work), your pretty much stuck. Try to work around this.

2) It takes a lot of time to define these table cells. It certainly isn’t easy to just say, “oh, ok, Volusion put table cell #2 here.” You’re going to need something in place already to define a table cell element, and then call it by number. A LOT of trial and error. What i found was best is to just use a class with a small, thin red border around it. Start trying different numbers in the script to see where these table cells are placed on your page.

All and all, this code is good for small, minor changes, but will never be as satisfactory as simply having access to the .ASP pages. It will never be truly dynamic unless Volusion lets you.

Good luck!

Author: Randy Neil
Courtesy of: www.theheadrush.com

How to: Never get another computer virus

Written By: BEN - Feb• 07•10
avatar

False anti-viruses inflicting damage…Stay off the internet!!! Seriously, it has just about come to that. It doesn’t matter where you go on the net, viruses are everywhere. Some more serious than others but all are equally annoying and intrusive. Or, you could always buy a Mac, but we’ll assume that you don’t want to do that.

Yet I always get asked the same question: “How did I get the virus?” and simply put it boils down to this… “were you on the internet?”.

Years ago, it used to only be certain sites or emails that would contain viral entities and most of the time they were pretty easy to spot, but now, they’re everywhere. Your favorite social networking sites, searching Google, online shopping, checking email, it matters not. The mere fact that you are connected to a network makes you susceptible to viruses. And they keep getting more sneaky with their tactics.

While the exact date of the official launch of the internet is debatable, it has been around and open to the public for at least 20 years, and there have been viruses all along. This huge speed-bump on the information super-highway keeps getting bigger and bigger and more and more users are falling victim to computer crashes and or total meltdowns due to virus programmers and hackers. This trend will continue on and on for years to come and as long as software is written, viruses will exist and thrive. So… get used to it.

Now, as I battle viruses all of the time (on computers other than my own of course), I see the same things happening. The same files being infected and basically the same tactics used for years. So, as usage of the world wide web continues to grow, more and more people will succumb to the throes of an infected computer often times causing costly repairs, loss of important files, exploitation of your personal information, and spy-ware that watches your browsing habits and reports back to someone, somewhere. I have even seen people throwing away brand new computers because they THINK all is lost.

I would like to share with you some basic things that you can do to avoid many causes of viruses and spy-ware. Some of these things my seem very simple to you, some may not. It’s a matter of thinking before you act, rather than going through the motions. Knowing what to trust and what not to.

Virus Delivery:
One of the first things I would like to discuss is virus delivery methods. Viruses don’t just magically appear on your computer. You have to allow it access. One thing is certain concerning virus delivery, viruses are programs and they have to be launched in order to work. In other words, you have to open the program (which can basically exist in any file format available) in order for it to begin its viral processes. One of the first things I ask clients with infections is: Did you download anything or open any email attachments that caused this to happen? Most of the time I get a “I don’t know or don’t remember” response. This to me, is due to the fact that just about everything you do on a computer and on the web has to do with opening and closing programs. It is such a routine procedure that most viruses catch you off guard by seeming routine. They trick you into opening them or downloading them by posing as a normal process or something enticing (ie: you just won 5 million dollars). And you, the end user, going through your routine processes almost out of habit just click away and allow these nasty bugs to access, embed, and destroy. Some of these newer viruses posing as “anti-virus” programs are the biggest culprits of infection I have seen as of late. I have seen some that replicate windows warning messages and seem like they are coming from a legitimate source. Nine times out of ten the end user accepts the “free scan” or “virus removal tool” that begins the infection process. Always keep in mind that you have to start a virus, so be alert of every item you click on because you might be one click away from infection. Anyhow, on to what you can do.


Pop-Up Ads:
First of all, never click on any pop-up ad… ever. Pop-up ads are annoying and intrusive and generally fall under the shady tactics category with me. In my own opinion, no professional website that is in good standing with the community would try to entice users with pop-up ads. But it can get even more confusing when the reputable website is in fact infected itself. Then what? Well, like I said before, these programs need you to activate them by clicking on them, and that is why I never click on a pop up ad. I either click the red “x” and close the window, or on Windows based machines you can push “ALT + F4″ to close the open dialogue box.

If you find yourself trapped in a barrage of continuous pop-ups, simply shut down your browser or restart your computer. The virus is trying to force itself upon you, don’t let it. Keeping in mind that this applies to pop-up ads only. Most advertisements are legitimate and click-worthy, but any that force themselves on you are not.

Staying on topic, lets say that a similar situation is happening on your desktop and not just the internet. You are getting pop-up messages warning you that your computer is infected and that you need to download a program to fix the issue. Don’t believe these messages! They are once again attempting to dupe you into submission. I always check for things like grammatical errors and misspellings. These are almost a dead giveaway of an attacker. I have seen viruses disguised as Windows Security Center and how I knew it was a virus was simply based on the bad grammar used in the warning messages. This should be a red-flag for any computer user. Generally, any legitimate programmer will take the time to ensure that every aspect of the program is correct, even down to spelling and grammar, so be on the lookout for this.

Social networking sites:
We all love them, but most of us don’t realize who is getting our information besides our “friends”. Social networking sites are the viral breeding ground of the future if you will. Most if not all social sites allow “apps” or applications to be installed or accessed via your profile. Now, once again I am not saying that all applications are viral, but if you want to remain on the safe side, don’t use them… at all! When I sign up for social networking websites, I usually only provide the bare minimum informational requirements as any information on your profile is search-able via search engines like Google and Yahoo!. Once I am in, the first thing I do is block application access to my account and adjust my privacy settings to make sure my information is at least somewhat protected. These seemingly harmless applications access your personal data in your profile to help direct advertisements and marketing towards a targeted demographic. Any of the surveys, community apps, and others you allow access to, you are essentially allowing the application to access all of your data that is stored in the social website in your profile. Some of these apps are designed just to do so, or to hijack your password and in turn use your profile to spam others. As well, social networking viruses can be tricky too. They can disguise themselves as messages from friends enticing you to click on a link or download a program. This is where you have to exercise good judgment. But to be absolutely safe, don’t click on any of the links contained in a message you think might be suspect. Pay close attention to the subject title of the message and once again, the grammar and spelling. Would your friend send you a message like this? Keeping in mind that opening the infected email or message generally doesn’t make you infected. It’s clicking on the link contained within or downloading the attachment that it came with. Once again, allowing viruses access by activating or launching them. In short, social networking sites: don’t allow apps, and beware of suspect messages even from friends! Taking these steps can help prevent the spread of social networking viruses.

Browsing or surfing the net:
Let’s think about things from a virus programmers point of view. How could a virus programmer spread his virus to the most people possible? Most likely by placing their viruses on websites that come up for common search terms. One of the most common search terms I find to produce a lot of viral results is the word “free”. Let’s say you’re looking for a free mp3 player or even free fonts for your computer. You browse through a few sites and don’t find what you’re looking for. You click on the next in a sequence of search engine results only to be presented with a onslaught of pop up windows. Most people end up engaging these pop-ups by trying to close them only to have them re-appear immediately, usually in a different place because eventually you will accidentally click on “OK”. So, what to do when presented with this situation? See above paragraph… no, I’ll say it again. First, attempt to close your web browser by right-clicking on it at the bottom of the screen where the program is docked and choosing quit or exit. Or press CTRL + F4 to force the open windows closed. If this fails, try pressing CTRL + ALT + DEL to bring up the task manager and end the process that way, and if that doesn’t work restart your computer… even if that means performing a dreaded “hard-reboot” by holding in the power button on the CPU until the system shuts down automatically. As often as “hard-reboots” are frowned upon, they have saved many a computer from being infected in my experience. You can nip viruses in the bud, but you have to know when they are attacking and when they have already embedded themselves.

E-Mail Viruses:
Finally, I’d like to touch on e-mail viruses. These are in my opinion the easiest to avoid. Simply put, don’t open ANY e-mails from people you don’t know. It’s really that simple. Ponder this, your e-mail address is almost like a cell phone number, it is unlisted in any phone book or online directory. Why or better yet how would someone get your email address unless you gave it to them? Viruses gather them from spam collected by any virus designed to collect email addresses, then they attack you by trying to get you to click on a link or download an attachment. Once again, using the same sneaky, enticing tactics. But, e-mail viruses fall under a similar umbrella as the social networking ones where you can get viruses from people you DO in fact know. But, if you know the red flags to look for (bad grammar, bad spelling) and ask yourself why would your friend whom has never sent you an attachment or link before all of a sudden start? You may be able to avoid infection.

Staying alert is key in being able to identify online viruses. If you use some of the simple judgment calls mentioned above, you can help prevent the spread of viruses and become more aware of how and when they attack.

Prevention:
One of the best possible things that you can do to help prevent the spread of viruses is keep your computer up to date. Meaning, don’t ignore those update windows. There is a reason that software is updated, usually due to bug-fixes and security flaws. When Windows prompts you that updates are ready to install, don’t ignore this! I can’t stress this enough. So many times I encounter out-of-date software that 9 out of 10 times had it been up to date, the issue wouldn’t have occurred in the first place. So, when your anti-virus software, Windows, Java, and other programs indicate that you need to update them, do it. Immediately.

Conclusion:
One last thing. Well, your saying… I have anti-virus programs, I don’t have to worry about viruses. You couldn’t be more wrong. Here is the harsh reality, the virus programmers are always one step ahead of the anti-virus programmers. Here is why, an anti virus program can not search for a virus that has not been detected by them. Meaning that when virus programmers release viruses into the internet, unless they call the police on themselves first, computers have to become infected before anti-virus software can start to define and attack the bug. Meaning that hundreds upon thousands may be infected before a resolution is concocted by the anti-virus software programmers. This is why I do not buy into anti-virus programs. There are plenty of good FREE anti-virus solutions for Windows users. I recommend AVG FREE Edition and Windows Defender. These programs cost you nothing and provide the same protection as ones that you would pay for. If you could call it protection in the first place. Either way, don’t waste your money buying expensive anti-virus software because you think you will be more protected than others. You’d be surprised how many PC’s end up in my office that have the latest and greatest anti-virus software installed yet still managed to get infected.

Hopefully you can learn from my experiences, be safe and learn to recognize threats before they can infect your computer.