Archive for April, 2009

Changing a Microsoft Office Product Key

April 21st, 2009

I just had a problem at work whereby the version of office installed in the last 30 days needed activating and the product key was not working. Luckily we have several Office keys sitting in the server room so I set about trying to change the key on the machine without having to reinstall. This means you don’t need to uninstall/reinstall Office which will take half an hour. This took me 2 minutes :)

After a short Google search I came across a Microsoft article that told me exactly how to do it. Here are the steps I took:

  1. Close any Microsoft Office Applications
  2. Open the registry (Start -> Run -> regedit)
  3. Find the appropriate office installation key under  HKEY_LOCAL_MACHINE \Software\Microsoft\Office followed by your version
    • Office XP ->…\10.0\Registration
    • Office 2003 -> …11.0\Registration
    • Office 2007 -> …\12.0\Registration
  4. In one of the subfolders you will see a product name field. Select the subfolder with your Office name in it (IE: Microsoft Office 2003)
  5. Delete the following key names:
    • DigitalProductID
    • ProductID
  6. Close the registry (no need to look for a save button, there isn’t one!)
  7. Open up any Office Application and you will be prompted for your product key and then to activate.

Thanks to Microsoft for writing a clear and concise how-to for a change without referring you to various knowledgebase articles. I used the following site for reference: http://support.microsoft.com/kb/895456

Welcome Email Editor for Wordpress

April 20th, 2009

Something which regular readers might be aware of is that Wordpress has taken up most of my attention for the last year or so. It seems a very flexible Blogging engine come CMS that can almost deal with anything… almost. When you begin to use it you think wow great flashy AJAX everywhere but when you take a look at getting it work with a site you start to see where it’s downfalls lie. I am, however, not a Wordpress hater. In fact it’s the opposite, I love it! Wordpress really comes into it’s own with it’s fantastic plugin API. It means that anyone can write their own noddy (technical term :) ) bit of code and get it to do something in no time. Or so I thought…

One of the least customisable parts of Wordpress is the Login/Register process. The register page seems unmoveable without a bit of copy and pasting of the code and the email you get when you register is very dire indeed. There are no hooks for editing the welcome email text or Wordpress admin page for updating the from address or headers.

Well, as it stood I needed to be able to edit the welcome email and registration process for work so I went about writing a standalone registration system (to follow) and Welcome Email Editor. Unfortunately the copy/paste method was required for the registration widget but the Welcome Email Editor is done properly.

As there were no hooks for the welcome email I had to override the wp_new_user_notification function and write my own then simply converted it to use Options and wrote a nice admin page for it. Let me know if I can extend it at all or if you find any bugs..

Download Wordpress Welcome Email Editor (14.03 KB)

Admin Email Received

Admin Email Received

Admin Page for Plugin

Admin Page for Plugin

Email Received By User

Email Received By User

Wordpress PHP Execution from within a Post or Page

April 8th, 2009

I have just written a plugin which allows you to run PHP code from a Wordpress post or page. The story is that I needed to allow a Wordpress user to hook into a bespoke function from the body of a page. There were two obvious ways to do this:

  • Add a new Wordpress Page custom template and put your code in there (no security holes but severely limited in its uses)
  • Add a new plugin to allow PHP code to be embedded into post content

Obviously I have gone with the plugin method for its increased flexibility and portability but I must mention before we go any further that it makes use of the PHP exec command. As you may well know this allows the user two run ANY code they like and this plugin merely facilitates that by adding it to Wordpress. There are, however, so many more plus points for this type of ability so it’s an acceptable risk (to me :) ).

The plugin uses the Wordpress shortcode API (so no horrible regular expressions) to add a new hook into the content of a post or page. Any content encapsulated in the hook is considered to be PHP code and will be executed every time that page or post is shown. The plugin can easily handle smart quotes and HTML so there is no need to use the HTML tab within the post edit page like some other plugins require you to do.

Usage

To use the plugin you simply use [sb_php][/sb_php] and put PHP code between the hooks as follows:

[sb_php]echo 'this is PHP code';[/sb_php]

will output:

this is PHP code

Download: SB Post PHP (408 bytes)