Drupal – Encoding Email Addresses to Deter Spam-bots

While working on my latest Drupal project, I really wanted an easy, brainless way for users to create clickable "mailto:" links that gave pesky spam-bots a hard time.

Turns out, the Bbcode module does just the trick. Even if you don't normally use it, you can add this input filter to your standard HTML filters, and it will work. The first step is to download and install the module.

Next up, enable the module, and add it to your input filters (located at /admin/settings/filters):

input-filters.png

As you can see,  you don't even need to assign it any roles. However, the Filtered HTML and Full HTML filters can use it, just set them up like so:

Input Filters

Next, go in and and configure the Bbcode module to encode email addresses:

bbcode-email.png

Now, to use it - just use the standard bbcode to encode any email address:

[email]someone@domain.com[/email]

And when the page is rendered, the underlying HTML will all be JavaScript gobbly-gook, but to the end user, it will be a normal link.

Posted in Drupal | 3 Comments

Transferring IMAP email to Google Apps for Your Domain

Over the holiday break, I took the plunge and migrated my businesses email service over to Gmail, using Google Apps for Your Domain (GAFYD) Premier Edition for businesses. For $50 per user per year, a 99.9% SAL, 25 gigs of space, extra bad-ass spam filtering, virus protection, backups, etc. I figured why the heck not.

Modifying the DNS and MX records was very easy (note if you use Postini, you will need to use different records) - they provide clear directions on this. However, make sure you install SPF records, this gives Google/Postini permission to send email on behalf of your domain. This will ensure you make it through today's highly sensitive spam filters.

The only part of the transfer that made me a little nervous, and gave me a little trouble, was migrating my existing IMAP email over to the GAFYD servers. It's really just a matter of knowing what IMAP client your current email server uses, and then entering the correct settings. Google provides a handy tool for doing this, but only supports certain IMAP servers, so check that yours is on the list. As of this writing, the supported IMAP servers are: Microsoft Exchange Server 2003, Cyrus IMAP Server, Courier-IMAP, and Dovecot.

Here are the settings I used:

gmail-imap-xfer.jpg

143 is the default IMAP port. The thing that was tripping me up was the "IMAP Path Prefix." Is this the path to where the email is stored on the server? A folder prefix name? It seemed no matter what I put in there, the only email folder it could find was "Inbox" - none of my subfolders where showing up.

Finally, I just left it blank, and whammo! All my subfolders were found. However, the "exclude" option did not work for me, which is fine - I can clean that up later.

After verifying that everything looked OK, I started the transfer. When I got back from lunch, it was finished! Cool.

Folders to Labels

This feature didn't quite work as I expected it to. All my IMAP folders were indeed correctly labeled, but they were labeled with the full folder path. For example, if I had "folder-b" inside "folder-a" which was inside my Inbox, the label would be: "Inbox.folder-a.folder-b" - which is actually a smart way to do it because it takes into account that 2 folders may have the same name, but be in different locations. After the import, all I had to do was tweak my label names.

Am I Glad I Did It?

Absolutely. I love it. Being a huge fan of keyboard shortcuts, I can fly around Gmail like no other email program. And the spam filtering (along with Postini - a GAFYD free add-on), is the best. It just works, even better than Spam Assasin. Postini sends me a daily email with whatever emails it has quarantined, so I don't have to constantly log in and check to see if a legitimate message was caught. I also enjoy the full suite of GAFYD apps - in particular the Calendar. And if you're on a Mac, you'll want to check out MailPlane - an excellent way to work in Gmail.

Cheers.

Posted in GAFYD | Tagged | Leave a comment

Use Terminal to Find and Create a Textmate Project

I've been spending more time than usual using the Terminal, and I like how quick it to get around the file system. Today, while messing with the linux find command, I started to wonder if I could search for a folder, and then open it as a project in TextMate, all with a one line command. Turns out you can!

In the following example, my current location is my Desktop, and I'm looking for a newsletter folder called "goodie69." Assuming it's found, open it in TextMate:

[ ~/Desktop ]$ find . -type d -name 'goodie69' -exec mate {} \;

Note that you need the TextMate command line tool installed and in your path to do this.

So, first I'm issuing the find command, the single dot specifies start in the directory I'm currently in, the "-type d" means I'm only looking for directory names, and then I'm taking the results and executing the "mate" command. You need to close out the exec command with the brackets, backslash and semi-colon.

If you use BBEdit, and have the bbedit command line tool installed, you can replace "mate" with "bbedit".

You can also specify any directory to start looking in (by default, this command will look in subdirectories). For example, if you have a folder called "clients" inside your home folder, and want to look in there for a particular folder, you can do something like this:

[ ~/Desktop ]$ find ~/clients -type d -name 'goodie69' -exec mate {} \;

And if you want to search for a file and open it in TextMate:

[ ~/Desktop ]$ find ~/clients -type f -name 'i-like-muffins.txt' -exec mate {} \;

Or,  you can just use Quicksilver ;)

To do this in Quicksilver - you just start typing the name of the folder, then tab over and select "open with" as the next option (or just start typing "with"), then tab over start typing "TextMate" until TextMate shows up. Then Enter. Whamo. If you don't see the "open with" option, refer to the article above.

Posted in OS X | Tagged | Leave a comment

phpMyAdmin: Bypass File Upload Size Limit

When you want to import a large SQL query in phpMyAdmin, you can run into problems as the default upload size limit is restricted by whatever it is in the php.ini file - and often, you cannot change this or simply don't want to. It tends to default to a measly 2MB.

However, there's a feature that will allow you to FTP your SQL file to an upload directory of your choosing, and then instruct phpMyAdmin to run the query file. Here's how you do it.

  1. Open up your FTP program, and navigate to the phpmyadmin folder on your server. Inside that folder is a file called config.inc.php - open this up in your trusty text editor.
  2. While you're still in your FTP program - create a directory inside the phpmyadmin directory called upload:
    phpmyadmin-trans.png
  3. Towards the bottom of the config file, you'll notice a potential setting for $cfg['UploadDir']. Change it so that it reads the following:
    phpmyadmin-config.png
    Don't forget to add the "./" before "upload" - this just tells the program to look in the existing directory (phpmyadmin) for a folder called "upload" - there's no need to change file permissions or anything.
  4. Save it, and then go back to your ftp program, and upload a sql file to that directory.
  5. When you go to the Import tab in phpMyAdmin, you'll now see a drop-down list of available files within your upload directory. Pick the one you want to run.
    phpmyadmin2.png
  6. Sit back, have some coffee.

Some Notes

  • You can compress the file, which will certainly make your FTP upload time shorter. I found that gzip works best for that. Sometimes a zip file would give me an error.
  • Note that you can still run into trouble if your query is HUGE. If your php execution time and/or timeout settings are not big enough in your php.ini file, executing your query can be problematic. However, you can always chop up your data inserts into numerous files, although that can be a pain. (Or, if you have SSH access, you can execute the query file that way.) I encountered this problem while trying to import a big Drupal database. I solved it be emptying (NOT dropping) all the search-related database tables, and then re-indexing the site once all the other data was inserted.

That's it - I was pleased to discover this feature and hope it helps someone else out too!

Posted in mysql, PHP | Tagged , | 18 Comments

Narrowing Your Google Search Results

There are a few simple tricks that can help you narrow down what you are Googling for. Let's just use an example and dive right in.

I'm looking for a band in Chicago called Sugar Beat. So, I start my search like this:

search-sweets.png

Hmmm... Even though I'm not looking for anything about cooking or food, I do need to trim the fat here.

By placing the words "sugar beat" in quotes, I tell Google that I am looking for this phrase - in other words, do not show me a page that contains sugar AND/OR beat - only return pages that have the words "sugar beat" right next to each other and in that order. Furthermore, let's get rid of the word "sweets" - we do this by simply ending our query with "-sweets" - that's a minus sign, and the word sweets (no space in between). This will help disassociate our search from pages related to food/desert:

search-gb.png

This still isn't perfect, but I think you're getting the idea. One thing I want to point out here is that Google ignores punctuation - notice in the above example, that "... sugar. Beat..." turns up. So, if you are writing for search engines and need to use certain keyword phrases, keep in mind that you can use punctuation within your keyword phrase without risk.

Also, note that you can subtract more that one word from your query like this:

"sugar beat" chicago -sweets -cookies

So, if we can remove words from our queries, can we remove phrases? Yes, just put a phrase in quotes:

"sugar beat" chicago -"sweet tasty goodies"

And if we can subtract, surely we can add - right? You betcha - this next query will only return pages that have the phrase "sugar beat" along with the word music, but that do not have the word sweets:

search-plus-minus.png

Now we're getting closer!  That first site listing looks interesting... Can I limit a search to just one website? Sure can:

search-site.png

By simply finishing our query with site:www.songkick.com - we restrict our search to that site.

So, by simply altering our search query in some intuitive ways, you can find what you are looking for faster by either filtering out, or forcibly including, keywords & phrases into your search. I do this so much it's become second nature - hope you find it useful too!

Posted in SEO | Leave a comment

Using “Go to Symbol” in a Texmate CSS File

CSS files have a tendency to get unruly - I feel like I'm always scrolling up and down the file, even when I have it nice and organized by section, just to find a section. Sure, sometimes I bring up the Find dialog. Using the keyboard shortcut of Apple+f is handy enough. But when I started working with Drupal, I found a better way.

Drupal uses a style of commenting that I haven't used much before, called Doxygen:

/**
 * Your comment text
 */

I like this quite a bit - not only is it nice and clean looking, but software has an easy time picking up on it (such as for generating documentation). It can be used to comment in both CSS and PHP.

In the following screenshot/example, you can see how Textmate picks up on this, and adds the comment text to the symbol menu in the lower right corner:

Symbol menu in Textmate

So now, not only can I access every CSS rule via this symbol pop-up menu, but I can access my sections as well. For those of us that don't like to switch to the mouse, you can bring up the go to symbol pop-up box with the Shift+Apple+T keyboard shortcut, then start typing into the Filter box what you're looking for. In this example I started typing "right" and since my Right Oriented Section starts with an asterisk, it jumps right to the top:

Go to symbol

Then I just press Enter, and it jumps to that point in the file for me, with the cursor right there too.

Anyways - so there you have it!

Posted in CSS | Tagged , | 2 Comments