4/16/09
Sometimes when using Wordpress you want to include a non-Wordpress page in your main navigation while still maintaining the simplicity of the wp_list_pages() function. I know there are plugins that do this type of thing, but many of them are just overkill. I just needed one non-Wordpress page on my menu, so here’s what I did. First, I created a page from within Wordpress and gave it a heading but left the body blank. My page was called “Purchase” but you can name it whatever you’d like. This is the name that will show up in your navigation menu. Then I went to the header.php file of my theme and added this at the top:
1 2 3 4 5 6 7 8 9
| <?php
if(is_page ('purchase')){
header("HTTP/1.1 301 Moved Permanently");
header("Status: 301 Moved Permanently");
header("Location: http://www.yoursalesforcebook.com/purchase");
header("Connection: close");
exit(0); // Optional, prevents any accidental output
}
?> |
Obiously, you’ll want to change the if statement to check for the blank page that you set up. Then change “http://www.example.com/” to whatever page you want the redirect to point to. Make sure that you put the code at the very top of the header.php file. If something else comes before it, it won’t work.
I first found this PHP redirect on Steven Hargrove’s blog. He gives examples of this in a number of different languages. However, I adapted it to Wordpress and added the ” header( “Connection: close”);” line to get it working properly. I’d love to hear how you solve this little Wordpress problem. If you have a different solution, please leave a comment below with a brief explaination. Thanks.
Posted in Wordpress |
3 Comments »
3/18/09
This is part two of a series of tutorials demonstrating how to setup a secure online form for your website. We will be using the GNU Privacy Guard (GPG or GnuPG) to encrypt and decrypt the messages for us. GPG is a complete and free implementation of the OpenPGP standard. Today we will look at how to create a public/private key pair and export it for use on our web server.
We’ll start off by opening the command prompt. Click Start and choose Run… Type in cmd and hit Enter. Now we’re ready to get to work. The first thing we need to do is create a public/private key pair. The public key will be used on the web server to encrypt the message, while the private key will be used on our local machine to decrypt the message. To create a key pair, type gpg –gen-key We will then be asked to choose what kind of key we want. We want the default option, which is number one (DSA and Elgamal), so we can just hit Enter to continue.

Next we must choose what key size we want. I’ll be accepting the default of 2048 for this tutorial, so I’ll just hit Enter and continue.

Next we need to specify how long we would like the key to be valid. Since we’ll be using this to encrypt forms from our website, we don’t really want it to expire. The default of 0 creates a key that doesn’t expire. It will ask for confirmation, so we’ll type y and hit Enter.

Next we need to enter a few details to create a user ID to identify our key. We will first be asked for our real name, after which we will be asked for our email address, and finally we must enter a comment. We will then have a chance to edit our choices before creating the key. When you have finished, type o and hit Enter to create the new key.

Finally, we need a passphrase. Whenever we receive an encrypted message from the our website, we will be asked to enter this passphrase before we can decrypt the message. (Please note: You will not be able to see the letters as you enter them, so you’ll have to keep track of what you’re typing yourself). We must then repeat the passphrase just to be safe.

After successfully setting our passphrase, the encryption key will be generated. This will take a little bit of time. Keystrokes and mouse movements will be used to ensure the generation of a random key, so feel free to move your mouse around and pound away at the keyboard. Here is the final output:

To ensure that our key was created, type gpg –list-keys

Perfect. Now all that’s left is to export the public key so that we can transfer it to our web server. The following command will export the key to My Documents and save it in a file called public.asc. gpg –export -a “User Name” > “my documents\public.asc” Replace User Name with the real name you entered when creating the key.

Now we’ll head over to My Documents to check out our new key. Windows most likely won’t recognize an .asc file and will tell us it cannot open it. It will however, give us the option of either using a Web service to find the appropriate program to open it, or choosing a program from a list of already installed programs. We’ll choose option two (Select the program from a list) since notepad will open our key file just fine.

Choose Notepad from the list and leave Always use the selected program to open this kind of file checked. Click OK and we should be set.

Here is the public key in all it’s glory:

That’s all for now folks. Next time we’ll take a look at moving the public key to the server where we can put it to use encrypting our messages.
Posted in Security |
No Comments »
2/24/09
This is part one of a series of tutorials demonstrating how to setup a secure online form for your website. We will be using the GNU Privacy Guard (GPG or GnuPG) to encrypt and decrypt the messages for us. GPG is a complete and free implementation of the OpenPGP standard. Today we will look at how to setup GPG on our personal computer.
We must have GPG installed locally to decrypt the messages that we’ll be receiving from our online form. We’ll also need a mail reader that can work with GPG, but we’ll cover that in a future lesson. Finally, although I personally use Linux, I’m going to be showing you how to set this up on a Windows XP machine.
First, we need to download GPG. The exact file we need is called gnupg-w32cli-1.4.9.exe and can be found at ftp://ftp.gnupg.org/gcrypt/binary/
Once it’s finished downloading, we’ll go ahead and install it. First, we’ll choose a language.

Choose a Language
Then we’ll start the installation by clicking Next.

Start the Installation
To continue with the installation, we have to agree to the GNU General Public License.

GNU General Public License
I don’t need support for languages other than English, so I’ve unchecked the NLS option. If you need support for other languages, leave the NLS option checked. I’ve left the Tools and Documentation options checked.

GPG Options
I’ll be installing GPG to it’s default location. While you are free to change this, be warned that you’ll have to modify some of the instructions later on if you choose a different location.

GPG Location
Next it will ask us to choose our preferred start menu folder for GPG. I accepted the default start menu folder, but feel free to change this if you’d like. Then click Install. When the installation is complete, click Next. Then choose whether on not you want to view the README file, and click Finish.
Now that we have GPG installed, we need to let Windows know where it’s stored so that other programs (such as Thuderbird) can access it. To do that, we’ll open the Start Menu, right-click on My Computer, and choose Properties. Under the Advanced tab, choose Environment Variables near the bottom.

Environment Variables
In the System Variables section, locate the Path variable. Click it once, and choose Edit.

Add a New Path
At the end of Variable value, add “;C:\Program Files\GNU\GnuPG” and click OK. A few notes on this step. First, the semi-colon at the begining is not a typo. You’ll need it there. Second, make sure you don’t leave a trailing space at the end of the line. Finally, if you decided to install GPG somewhere other than the default location, you will need to enter the path to the location you specified. However, if you used the default location (as I did in the example) you should be fine following my instructions to the letter.

Add GPG to Paths
Click OK on the Environmental Variables window, and then OK in the System Properties window. We should now be ready to use GPG. Just to make sure, we’ll run a quick little test. GPG is a command line program, so click the Start button and choose Run… Then type cmd and hit Enter. Now we should be ready to run some commands. To check what version of GPG is installed (and to make sure that it installed properly) type gpg –version and hit enter. You should see something like this:

gpg --version
Alright, that’s it for this lesson. In Secure Forms - Part 2 we’ll start learning how to actually use the program.
If you found this tutorial useful, or if you have any questions about this subject, please leave a comment below.
Posted in Security |
No Comments »
2/16/09
Outline is a seldom used and often misunderstood CSS property. An outline is a line that is drawn around an element outside of it’s border. By definition, it takes up no space. Sounds impossible, right? In reality, it does take up space (you can see it!) however, that space is not added to the width of the element like a border would be.
Most often, the outline is used to highlight an active link. By default this is a small dotted line that encapsulates the link. To be honest, as a designer I have often found the outline to be a bit ugly. There are some designers who hide the outline entirely (I used to be one of them). However, in Firefox, Internet Explorer and Chrome you can navigate the web using only the keyboard by tabbing through the links on each page. Each link is highlighted by an outline when you reach it. You can hit enter to follow the link. Hiding the outline entirely takes that feature away from users who prefer to use their keyboards. So to prevent the ugly outline while still retaining keyboard navigation we can style the outline using CSS.
This solution is not perfect, due to the lack of support by Internet Explorer (as of version 7). While Internet Explorer uses an outline to highlight links, it does not support styling it will CSS. Firefox, Safari, Opera and Chrome on the other hand, do allow you to specify your own styles.
The outline can be styled with the following properties:
- outline-color
- outline-style
- outline-width
- outline
Outline-color behaves like any other color declaration and also supports the value “invert” which performs a color inversion of the pixels on the screen. This is the default behavior and ensures that the outline will stand out from the background. Outline color can be set like this:
a{outline-color: white;}
Outline-style has the same possible values as the more common property border-style and is set like this:
a{outline-style: dashed;}
Outline-width can be set to thin, medium, thick, or can be specified with a length such as 3px.
a{outline-width: 1px;}
Finally, outline is a shorthand property for setting the previous three properties all at once. For example:
outline{2px solid red}
Keep in mind an outline is the same all sides. Unlike border, you cannot specify a style for only one side of an outline. To play around with the outline property, visit http://www.w3schools.com/CSS/tryit.asp?filename=trycss_outline
For even more information:
Posted in CSS |
3 Comments »
As you probably already know, my name is Alex Mansfield and I’m a web designer and developer from Bremerton, Washington. I’ve been creating websites for quite a few years now, but I spent this past year intensively studying the methods within the madness of this field. And while there is no end to learning, I think its about time I started to share what I’ve learned with others who are attempting to do the same.
Posted in News |
No Comments »