May 01
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

If you have ever had these errors or just want to be prepared in case they pop up somtime (and they surely will), then read on as I discuss various situations that lead to them and also their solutions.

I generally use desktop clients (mostly blogjet, but also Windows Live Writer and Scribe Fire sometimes) to blog to my WordPress based blogs. Some months ago, I started getting "Http 406: Not Acceptable" error while posting a particular post. Tried posting through the WordPress inbuilt TinyMCE editor, but got the same result. A little bit of research told me that this was because the post contained some words that were considered harmful by the "mod_security" plugin for apache that had been installed by my host to prevent hacking attempts. The quick resolution was to include the following lines in my .htaccess:

CODE:
  1. <ifmodule mod_security.c>
  2. SecFilterEngine Off
  3. SecFilterScanPOST Off
  4. </ifmodule>

Sure enough, I put them in, published the post, and it worked. But since this meant opening up my site to the real hacking attempts, I commented them out and went about my work, occassionally turning them on as and when required.

But, a few days ago, after a server upgrade, the problem reared its head again, and in a more vicious manner. I started getting the dreaded 406 error again, and this time for any post, even a blank post, and through all clients. But this time, TinyMCE was working without issues. A little bit of looking around my site told me that the problem was that my desktop clients were not able to connect to my "x mlrpc.php" file which is responsible for taking care of all the remote api provided by WordPress. Trying to access it through any means provided the 406 error. My site's error log was filled with:

An appropriate representation of the requested resource /x mlrpc.php could not be found on this server.

Now, the xml rpc methods are used not just by WordPress but many other CMS's (like drupal, joomla, etc) and sure enough a quick search resulted in many similar reports for all the platforms. Enabling my previous mod_security options resulted in "503: Server misconfiguration" errors, complicating things further.

On seeing the error logs, I found that the server could not understand the options, and then I discovered that the mod_security had been upgraded to and it wasn't backward compatible with old options. Modifying the options to their latest counterparts also didn't work, as further wading through mod_security manual told me that now, its options cannot be overridden through .htaccess and can only be changed by the web admin.

I found that my host has basically blocked the x mlrpc.php file from being accessed at all instead of using proper rules for blocking only the attacks while allowing valid accesses. This was the problem that a huge number of people are also having and moreover they (like me) are not able to convince their hosts to switch to proper rules.

However, not all hope is lost. I have "fixed" this issue with a workaround for now. It is pretty simple really. Just rename your x mlrpc.php to something else (e.g. myrpc123.php) and also replace all references to it in your CMS with your new file name. You can use sed to automate this task. I used perl however:

CODE:
  1. perl -e 's/x mlrpc.php/myrpc123.php/gi' -p -i *

Now, the 406 errors should be gone. If this worked for you, or you had any issues let me know. Also, if you have any other workarounds/fixes of your own, do drop me a word.

Note: In the above article, please ignore the space between "x" and "mlrpc" as the mod_security rules prevent them from being in content also. Moreover, use some unique name for rpc file.


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: Ralph: Me fail English? That's unpossible.

written by Shantanu Goel \\ tags: , , , , ,

Apr 15
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

Update: Modified the “Oxios Hibernate” app as well on public demand. Please redownload the below mentioned package. It now has Oxios Close as well as Oxios Hibernate.

Oxios developed a very useful tool for Windows Mobile (WM2003/5/6/6.1) called “Oxios Memory” sometime ago. On running it, it’ll flush your RAM (kind of) and recover substantial amounts of memory that can be used by the currently program. It is so good at this that many people run it regularly on their phones, and most of them want to run it in an automated mode (through a scheduler or a script). But the problem (so far) was that it generates a Message Box at the end for which the user has to press “OK” button to make it go away. There is no known way of disabling this message box and many attempts to work around it by scripting the “press OK” action have been very unreliable at best. Hence, it took it upon me today to remove this nagging problem and 5 minutes later we have a “clean” Oxios Memory.

Yes, no more nagging prompts :)

Download it here: Oxios Memory Hacked By Shantanu Goel

(Feel free to spread the message but please don’t hotlink to the file as it is anyways disabled. Provide a link to this page instead)

If you like it, then DIGG IT by clicking here or choose your favourite submission engine from the links below the post :-)


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: Morpheus: If real is what you can feel, smell, taste and see, then 'real' is simply electrical signals interpreted by your brain

written by Shantanu Goel \\ tags: , , , , , , , , ,

Mar 23
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

There are many code syntax highlighter plugins available for WordPress (e.g. iG Syntax Highlighter, WP-Syntax, etc) but almost all of them have a problem. They want you to write the code in “HTML editing mode”. If you use any kind of WYSIWYG or visual editors (like built in TinyMCE or offline clients’ similar modes), there is a grave problem. Your code becomes garbled. e.g.:

If you intend to write:

CODE:
  1.  cat abc > /dev/null

It might turn out as:

CODE:
  1. </p>
  2. <p>&nbsp;cat abc &gt; /dev/null
  3. </p><p>

 The issue here is that the code highlighting plugins use the “exact” text entered within the [ code ] (or similar) tags, and since we used the WYSIWYG/visual editors, they add html formatting tags to the code and also convert some special characters into HTML entities (e.g. > into &gt;, < into &lt;, white space into &nbsp;, etc).

The workaround is that you can write the code in html editing mode. But the problem here is that if you happen to switch to the visual mode or edit your post in this mode any time later, the problem will come back which makes editing posts a pain. So, here is a simple hack that will let you write your code in visual/WYSIWYG mode without doing anything special.

Continue reading »


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: Morpheus: Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony.

written by Shantanu Goel \\ tags: , , , , , , , , , , , , ,

Mar 19
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

Disclaimer: I’m neither a WordPress guru nor a PHP expert. This is what it is, a dirtly little hack, otherwise I’d have called it an “enhancement”

Now onto the main things.

Aim: You would have used wp_list_pages (or plugins like dd-list-subpages, that use it) to display a list of your pages/subpages on a particular page. e.g., I use it on my “Projects” pages hierarchy to list all the relevant projects under a particular heading. Now, the thing is that wp_list_pages gives you a lot of options to display things like dates, page title, page link, etc, but that’s not enough. I need to provide a small description for each page as well, to put things into perspective. Obviously, I don’t expect the visitors to go inside each link to see what it holds in store for them.

The Hack: What you need to do is locate a file called “classes.php” in your wordpress installation. It is usually located at <WordPress Base>/wp-includes.

Now, open the file and find a function called “start_el”. This is a function in the “Walker” class, which is used in WordPress to parse tree-like structures. Here, it used by wp_list_pages to list out all the pages. Now, at the very end of this function (just after the closing brace of if ( !empty($show_date) ) { ), place the following piece of code:


CODE:
  1. $description = get_post_meta($page->ID, "description", true);
  2.             if ($page->ID != $current_page)
  3.             {
  4.                 $output .= "    ";
  5.                 if (!$description)
  6.                 {
  7.                     $description = strip_tags(substr($page->post_content, 0, 250));
  8.                 }
  9.                 $output .= $description;
  10.             }!

What this code does is:

1) Look for a custom field called “description” in your pages. If present, it will show what you wrote there after each of your page in the list generated by wp_list_pages. (To add a custom field to your page, look at the very bottom of your “write” page or “manage” page in the WordPress dashboard.

2) If the “description” field is not present (obviously you might not like to go back and add a custom field to all your pages), it takes the first 250 characters of your page’s content and displays that.

The Hack Is Not Finished Yet: There is just one little thing left to do. As I mentioned, this function is used other times as well (e.g. making your navigation menu). So, you don’t want the description to be appearing always, otherwise it will wreak havoc on your site’s layout. So, there is again a dirty little trick to prevent this.

At the place where you are calling wp_list_pages, modify the call to include the following code before and after the call:

CODE:
  1. update_option('my_wp_list_pages_option', 1);
  2.         $content .= wp_list_pages($your_wp_list_pages_options);
  3.         update_option('my_wp_list_pages_option', 0);

And, modify the previously listed code as well to look like:

CODE:
  1. $my_wp_list_pages_option = get_option('my_wp_list_pages_option');
  2.  
  3.         if ($my_wp_list_pages_option == 1)
  4.         {
  5.             $description = get_post_meta($page->ID, "description", true);
  6.             if ($page->ID != $current_page)
  7.             {
  8.                 $output .= "    ";
  9.                 if (!$description)
  10.                 {
  11.                     $description = strip_tags(substr($page->post_content, 0, 250));
  12.                 }
  13.                 $output .= $description;
  14.             }
  15.         }

What this does now is that it adds an option/variable to WordPress database, which you set to 1 before calling wp_list_pages to tell your code that now its time to display the description, and then restore its state to 0, to prevent the description from being displayed for any other wp_list_pages call.

For your reference, I'm attaching my copy of classes.php here.File Attachment: classes.php.zip (6 KB).
For an example of how it finally looks like, take a look at my “Project” page.

Now It Is Finished: Yes, am not lying. It’s done. All your “Thank You’s” are accepted, and so are your flames, if any .


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: "There's a time and a place for everything, and it's called college." -- Chef

written by Shantanu Goel \\ tags: , , , , , , , , , ,

Feb 01
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

Sherlock

As the pic above says, it turned out to be quite elementary in the end. But what is “it” actually?

The Problem: Since the beginning of time (read launching of WM6), millions of WM users (ok ok, will not exaggerate from now on) have been facing a very peculiar issue. The issue is that people tell them all the time that they are avoiding those people, and not taking their calls. But as the perplexed WM’er flips through his calls log, he can’t find any sign of a missed call. Yes, the issue is that many times, the phone will go into a state where the caller will hear the ring go, there will be no sign on your phone of the same, not even a missed call. People all around the world have been after the solution with all their might, suggesting:

1) To change over to Radio Rom x.xx.xx and swear it solved all their issues but we have had equal number of people in both camps (fixed and non-fixed) for every radio rom.

2) Various kinds of flashing techniques and orders but no concrete solution here either.

3) Standing on their heads and chanting “OM” for 10000 years (I’m at it again  )

Anyways, the long and short of it is, they didn’t get anywhere. But worry no more, the messiah is here to save you all from social embarrassment. Click on Continue reading to find the solution.

Continue reading »


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: "If there are any questions, direct them to that brick wall over there." -- Network President

written by Shantanu Goel \\ tags: , , , , , , ,