Pages

Wednesday, October 2, 2013

PHP update, 2 chars in a regexp: search doesn't function

Just experienced a problem on an old Drupal 6 installation I use for www.kindmankind.net. The search stopped working and complained that “you need a keyword of at least 3 chars”. As usual, I googled this sentence, and as usual, the answer popped up. In the file search-module.php, a few chars had to be changed. In case you have Drupal 6 and for no reason your side-wide search suddenly stopped working, here is the patch:

diff --git a/modules/search/search.module b/modules/search/search.module
index cb6d0f7..fbd4438 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -43,7 +43,7 @@ define('PREG_CLASS_SEARCH_EXCLUDE',
'\x{2ce5}-\x{2cff}\x{2d6f}\x{2e00}-\x{3005}\x{3007}-\x{303b}\x{303d}-\x{303f}'.
'\x{3099}-\x{309e}\x{30a0}\x{30fb}\x{30fd}\x{30fe}\x{3190}-\x{319f}\x{31c0}-'.
'\x{31cf}\x{3200}-\x{33ff}\x{4dc0}-\x{4dff}\x{a015}\x{a490}-\x{a716}\x{a802}'.
-'\x{a806}\x{a80b}\x{a823}-\x{a82b}\x{d800}-\x{f8ff}\x{fb1e}\x{fb29}\x{fd3e}'.
+'\x{a806}\x{a80b}\x{a823}-\x{a82b}\x{e000}-\x{f8ff}\x{fb1e}\x{fb29}\x{fd3e}'.
'\x{fd3f}\x{fdfc}-\x{fe6b}\x{feff}-\x{ff0f}\x{ff1a}-\x{ff20}\x{ff3b}-\x{ff40}'.
'\x{ff5b}-\x{ff65}\x{ff70}\x{ff9e}\x{ff9f}\x{ffe0}-\x{fffd}');

Wednesday, March 20, 2013

Beware of Naughty Plugins

I was working on my WordPress empire, and got a bit too careless with updating plugins. I tried out a host of new things for collaborative editing, multilingual WordPress, slideshows, backups, and so on.
And then: snap! The back end was inaccessible, even to me, the superadmin. I googled the error message, as you should always do, but to no avail. En passant I found a useful tip on the site of WPML: If you haven’t done yet, generate your Nonces and Salts in wp-config. (if you don’t know what I’m talking about, safely ignore until your site starts acting strangely, then pay a geek a lot of money to fix it :)

Anyway, in my case (a regular 3.5.1. multisite install) it was a plugin called “Portfolio slideshow” that caused a message like “you have no permission to view this page”. Just delete the plugin and things should work again.

If not, the malicious plugin might have changed that database, and if you’re mental like me, you don’t have a backup lying on the shelve, so you have to open phpmysql and edit your options table directly (look at table prefixes and user permissions)

Sunday, March 10, 2013

Multilingual translations

languagesFor some language obsessed people, alright let’s call them language geeks, like myself, it is a slight disappointment that Google Translate’s Web Interface, translate.google.com only translates into one language simultaneously.

Sometimes I want to know it all at once (and I do believe that this has benefits for language learning, because learning an expression in different languages creates an extra association, which in turn eases memorizing the words associated). Of course there are websites for that.

The easiest is www.nicetranslator.com, which simply uses Google Translate to produce results in some 37 languages. I use it to check a word in seven languages (Dutch, English, French, German, Korean, Russian, and Spanish) and it really helps me combat the occasional frustration of not knowing a word.

Another handy way is using Google Spreadsheets, which allows automated translation as well, like so:

=GoogleTranslate(A3,"en", "ru")

This would translate the contents of a cell from English into Russian. Note that the ISO language codes need to be in apostrophes. The source value can also be “auto”. I then simply apply this formula to different columns to obtain the desired result.

Saturday, February 16, 2013

Wordpress stuck in maintenance mode

Problem: You are using WordPress’ great feature of automatic theme or plugin updates, but the AJAX throbber doesn’t stop moving – your site seems to be stuck. You hit the reload button of your browser and this is what you get:

“Briefly unavailable for scheduled maintenance. Check back in a minute.”

Solution: Open your (S)FTP program and delete the file called “.maintenance” in the root of the WordPress folder. This lets WordPress ignore the failed update, which you can then try again. It might be useful to update plugins one by one, or to check if some of them have become unstable.

Thursday, February 7, 2013

Moving Wordpress, the Dirty Way

Sometimes it’s time to say goodbye. To a Web Host for example. But we want to take our beloved WordPress website with us. If the relocation is urgent (for example because the old host charges a ridiculous yearly fee) this can cause quite some stress. Calm down. Here is a short list of how to move any WordPress site in no time. Prepare some coffee and just follow these steps.


  1. Grab your files. I normally use SFTP to copy the files from my old host to my new host. This takes about 5 minutes if your WordPress installation is not too large. Transfer mode “auto” should be fine. In case you have a lot of large plugins installed you could use yet another plugin to backup your files and download them as a zip, that you upload to your new host later. (Of course, if you have shell-access to your server, you can use that).
  2. Grab your database. Your old host should provide access to a tool like PhpMyAdmin, where you can export the database. Just use the standard options and save the .sql file.
  3. Upload your files. Create a new directory in the root of your new web space and place the files there. You can of course copy them directly from one FTP site to another using a smart FTP client. (I install the site on my localhost WAMP server before I transfer it to the target).
  4. Create a (sub)domain. Your new web host has a web interface such as Plesk, where you create a new subdomain, or order a new domain. They should notify your old host and take care of domain registration. You map that (sub)domain to the directory created in the previous step.
  5. Create and upload the database. In the same web interface, you create a new database. Choose a password. Write down database name, username, and password. Use Import to import the .sql file you downloaded previously.
  6. Change your wp-config.php. You enter at least the following information:
    database host (often, but not always, localhost
    database name
    user name
    password 
  7. Change permalink structure. If you visit Settings > Permalinks, WordPress should automatically update your permalink structure, if you change the setting and save it. In my case, this didn’t happen, so I changed it directly in the MySql database using the following SQL statement (careful):
    UPDATE wp_posts
    SET guid = REPLACE (guid,'[old-url]', '[new-url]')
    WHERE guid LIKE '[old-url]'

    Replace [old-url] and [new-url] with the names of your urls.The WHERE-clause is not necessary, but added in case for whatever reason you have links to external pages in your database, that should not be changed.
All set. You have moved your WordPress installation. You might want to test it first, and fine-tune the settings of your plugins, particularly the ones handling caching and SEO.

Saturday, February 2, 2013

Web Stats with Piwik

Yesterday I started using the open source alternative to Google Analytics, Piwik (www.piwik.org) on my WordPress multisite network. Setup is fast and easy. Here are some comments on the setup steps and possible issues:

  1. Download the piwik zip (about 6 MB, fast);
  2. Upload to your browser. I placed it at {root}/piwik.
    SSH/SFTP is recommended as there are many thousands of files and it would take a long time using FTP. Make sure transfer mode is set to “binary”, because “ascii” or “auto” would result in messing up line breaks, so that you don’t pass the file integrity check of Piwik;
  3. Creating a database is trivial. I used a separate DB that I can DROP whenever I get enough of Piwik;
  4. It works pretty much out of the box. In the menu item “API” you’ll find your auth-code, that you put in the appropriate text field of the WP_piwik plugin.

Install was fast and with the WordPress plugin WP_piwik installed, tracking codes can be added automatically to all your blogs, and stats are integrated with your WordPress dashboard.

Enjoy the narcissism (or masochism) of watching your visitors come and go in real time :)

Friday, February 1, 2013

.htaccess rules

… or does it? I found this list of things you can do with .htaccess that I want to share with you.

http://devmoose.com/coding/20-htaccess-hacks-every-web-developer-should-know-about

Have a look if you like to

  • prevent spammy commenters
  • ban IP addresses
  • protect files or directories with a password
  • redirect to another site without being punished by the big G
  • create custom error pages
  • remove filename extensions from your URL

and more :)

 

Wednesday, January 30, 2013

jQRangeSlider

Some really well made jquery plugin today: jQRangeSlider: fully customizable UI slider elements to select a range of values. Nothing is hard coded, it integrates easily (although I had a little struggle integrating it in WordPress today – don’t ask why), it supports mousewheel actions and more.
Kudos to GHusse :)

By the way, if you’re working with the Javascript Date-object:
http://www.w3schools.com/jsref/jsref_obj_date.asp

Don’t confuse

getDay()

and

getDate()

as I did today because it was used wrongly in the documentation for JQDateRange, triggering a lenghty and useless debugging tract, and eventually the writing of this little note.

Friday, January 25, 2013

E-mail posting to Wordpress.com

Here's the situation: You've managed a Wordpress.com blog and it looks kind of neat, it has a lot of followers, and your heart grew attached to it. But you're too long in this game to ignore the obvious limitations of Wordpress.com, and you have moved to a self-hosted site. But you want to keep the old blog going... This can be done effortlessly using the posting by e-mail function of Wordpress.com. IT not only allows you to send HTML E-mails (provided the markup is correct), but it also accepts a number of shortcodes like so [tag cool, e-mail, posting, geek] [category Wordpress] [delay +2 hours] [more] [geotag on] [publicize on] Check out the full list of possibilities here: http://en.support.wordpress.com/post-by-email/ So, when sending these e-mails with a plugin from a self-hosted WP site, you can create an action hook to add the tag and category shortcodes. Will look into that next time.

Tuesday, January 22, 2013

Graigfind.com

Okay, I'm not going to mimic what dozens of writers have done before and compile a list of the best websites to find decently paid online work. It has been done, and it has been done well and the first five google results will get you were you want to go. It turns out that craigslist.org is very useful for the online workforce, because many job posters don't care where someone is located - they just want to get the job done. So we just do a keyword search on good old craigslist? Almost. We use the API, or rather make use of the work some other fine geek (thanks!) out there did and go to www.craigfind.com I don't know about bandwitdh limitations or how long this is going to be around, so just check it out for yourself.

Monday, January 21, 2013

FoxReplace

Did it ever happen that you couldn't stand a word or a phrase? Just don't like the ring of it, or the associations? Would it be nice to just replace all these expressions with things that we experience as more honest? I googled this three minutes ago and, flash! there it was: I found a Firefox plugin today that does just that: FoxReplace. Works like a charm. There are options to auto replace on page load, replace HTML or URLs, and it comes with a mechanism to match any URL like "http://*.example.net/| ". Here are a few words that I am replacing in order to make my news websites digestible:
  • worker > slave
  • NRA > gun fanatics
  • growth > expansion at all costs
  • capitalism > planetary rape
  • banker > wanker
  • the system > the corrupt system
You get the idea. And because words have an aura and when we read them often enough, they shape our world, this could be a small but meaningful contribution in the fight against the system. I think this is an awesome plugin ;-

Friday, January 18, 2013

Top 8 Best Wordpress Tutorial Sites

Okay, this is a subjective thing. I'm a very chaotic occasional wordpress developer and I google everything. Tons of good sites and some junk has turned up in those searches, and an occasional miss. Anyway, here are the sites that helped me most with Wordpress, fresh from my bookmarks, so all the links are pointing to some useful tuturial as a bonus
  1. DigWP
  2. Six Revisions
  3. Makeuseof
  4. Pippins Plugins
  5. CatsWhoCode.com
  6. Wptuts+
  7. How to use Ajax in WordPress
  8. Deluxe Blog Tips
   

Tuesday, January 15, 2013

www.imagesplitter.net: Online image splitting

Was searching today for a tool to split an image in many parts, for some web design idea. I know, that is something Photoshop or the Gimp do in a whim. I don't have these programs because my netbook is not powerful enough and its screen to small. I use paint.net and haven't yet figured out how to write macros/scripts or download a plugin for "splitting a photo into many equal parts" (hence my search string). What I found is www.imagesplitter.net that does this exact job well, along with resizing, cropping, and conversion.

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Lady Gaga, Salman Khan