Supertext Home
Chief of the System Blog

blogger.getUsersBlogs method received from the blog server was invalid

July 13th, 2011 by

Invalid response document returned from XmlRpc server

I’m using Windows Live Writer to publish to my WordPress 3.2 Blog that runs on a Windows Server 2008 R2. This all worked fine for a while until I upgraded the blog today. Now I got the following error message:

 

Can’t connect to your blog service:

Invalid Server Response – The response to the blogger.getUsersBlogs method received from the blog was invalid:

Invalid response document returned from XmlRpc server

Please try fixing the problem and then try again.

 

Lovely. Try fixing the problem or call the system administrator. Unfortunately I’m the administrator, so nobody there to call.

But then I remembered that I had a similar issue a while back. I wrote about it in the post WordPress XML-RPC Issues.

And, oh wonder, this solved the problem again!

Quick repetition:

Edit the class-IXR.php file from the wp-includes directory. Change

header(‘Content-Length: ‘.$length);

to

header(‘Content-Length: ‘.$length + 2);

And you are fine until next time.


Simple C# encryption and decryption

January 20th, 2011 by

There are various ways to encrypt and decrypt a string in with .Net. The simplest is to use Base64. But this just makes the string unreadable for a human, but it is not a real encryption. Although, for most case is is likely enough.

If you want something a little fancier, I have a simple solution for you:

 

public static String Encrypt(string source)
{
   
DESCryptoServiceProvider des = new DESCryptoServiceProvider
();
   
byte
[] Key = { 12, 13, 14, 15, 16, 17, 18, 19 };
   
byte
[] IV =  { 12, 13, 14, 15, 16, 17, 18, 19 };

    ICryptoTransform encryptor = des.CreateEncryptor(Key, IV);

    try
    {
       
byte[] IDToBytes = ASCIIEncoding
.ASCII.GetBytes(source);
       
byte
[] encryptedID = encryptor.TransformFinalBlock(IDToBytes, 0, IDToBytes.Length);
       
return Convert
.ToBase64String(encryptedID);
    }
   
catch (FormatException
)
    {
       
return null
;
    }
   
catch (Exception
)
    {
       
throw
;
    }
}


public static string Decrypt(string
encrypted)
{
   
byte
[] Key = { 12, 13, 14, 15, 16, 17, 18, 19 };
   
byte
[] IV =  { 12, 13, 14, 15, 16, 17, 18, 19 };

    DESCryptoServiceProvider des = new DESCryptoServiceProvider();
   
ICryptoTransform
decryptor = des.CreateDecryptor(Key, IV);

    try
    {
       
byte[] encryptedIDToBytes = Convert
.FromBase64String(encrypted);
       
byte
[] IDToBytes = decryptor.TransformFinalBlock(encryptedIDToBytes, 0, encryptedIDToBytes.Length);
       
return ASCIIEncoding
.ASCII.GetString(IDToBytes);
    }
   
catch (FormatException
)
    {
       
return
null;
    }
   
catch (Exception
)
    {
       
throw
;
    }
}

Just make sure that you replace the Key and IV values.

I had to use the  Base64 Encoding in addition to the encryption so you can use the result string like a normal string and write it somewhere. Otherwise it could contain non ASCII characters and you couldn’t easily use it.

 

If you want to use the encrypted string in a url, you should HTML encode it too:

System.Web.HttpUtility.UrlEncode(Encrypt(mystring));
 

Have fun and let me know if you have any questions.


SDL Trados Studio 2009 startup slow?

December 10th, 2010 by

SDL_License_Manager

Does it take minutes to load Trados? In our case, it took up to 20 minutes to load Trados. Normally Trados should start in a few seconds.

We are using a floating license with a license server in our private network. I think all this does not apply if you have a local license on your PC.

If you have the same problem, check the following things first:

  • Switch off the firewalls on both the client and the license server.
  • If VM Ware is running parallel on the server, disable it.
  • Are you using switches on the network? Could cause problems. Try a direct connection.
  • The Flex License Server should run on Port 27000, make sure it does and make sure the  client connects to it on that port. Eg. 27000@<my_server>
  • Make sure you everything is from Trados 2009 and that you don’t have any other versions running.
  • The license server has to run on a fixed IP. This is core!

Got the hints from Grzegorz Gryc.

Now, in our case the problem was a bit complicated. Our license server was not running on a fixed IP, for some reason the DHCP server is handing out the IP addresses in some weird way (normally every PC gets the same address every time it connects). Anyway, we fixed that, but still it took ages for Trades to start up. At least we didn’t get the License Server Dialog anymore.

The 2nd problem was, that Trados was scanning all possible IP addresses that the license server ever had (even though now it was fixed).

To solve this do the following:

  1. Start the SDL License Manager (under the SDL Program group)
  2. Click on “License Locations”
  3. Remove all locations and make sure there is just one with the right fixed IP of the license server

That’s it! I hope your Trados is starting faster now!


MySQL–Update and Insert if not exists

November 23rd, 2010 by

Often you have the situation that you need to check if an table entry exists, before you can make an update. If it does not exist, you have to do an insert first.

The simple straightforward approach is this:

(The example is for an entry in the WordPress wp_postmeta table)

SELECT meta_id FROM wp_postmeta
WHERE post_id = ?id AND meta_key = ‘page_title’


If ResultCount == 0


INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
VALUES (?id, ‘page_title’, ?page_title)


Else


UPDATE wp_postmeta SET meta_value = ?page_title
WHERE post_id = ?id AND meta_key = ‘page_title’

This is not too bad, but we could actually combine everything into one query. I found different solutions on the internet. The simplest, but MySQL only solution is this:

INSERT INTO users (username, email) VALUES (‘Jo’, ‘jo@email.com’)
ON DUPLICATE KEY UPDATE email =
‘jo@email.com’

Unfortunately, this the ‘ON DUPLICATE KEY’ statement only works on PRIMARY KEY and UNIQUE columns. Which is not a solution for my case.

You can follow the discussion here on Sql Recipes.

What worked best for me, was this solution:

INSERT INTO wp_postmeta (post_id, meta_key) SELECT ?id, ‘page_title’  FROM DUAL WHERE NOT EXISTS (SELECT meta_id FROM wp_postmeta WHERE post_id = ?id AND meta_key = ‘page_title’);
UPDATE wp_postmeta SET meta_value = ?page_title WHERE post_id = ?id AND meta_key = ‘page_title’;

It’s a bit more complex, but you can run that in one go and it will do the trick. If you adjust it a little it should even work on different database systems.


Can’t save new post with WordPress 3.0

September 10th, 2010 by

After upgrading WordPress to 3.0 and then to 3.0.1 I couldn’t save newly created posts anymore.

Creating new users didn’t work either.

Turns out there is a problem with the DB tables. For some reason some of the fields don’t have default values and if you try to save something, the save SQL operation fails.

You can easy check if you have the same issue:

Just add define(‘WP_DEBUG’, true); to your wp-config.php file and then you should see the error messages.

To fix it, just run this query:

ALTER TABLE wp_posts CHANGE COLUMN post_mime_type post_mime_type VARCHAR(100) NOT NULL DEFAULT ”;

Same for creating a new user. This is the error message:

WordPress database error: [Field 'user_activation_key' doesn't have a default value]

INSERT INTO `wp_users` (`user_pass`,`user_email`,`user_url`,`user_nicename`,
`display_name`,`user_registered`,`user_login`) VALUES (‘$P$BdvJNscOoULkBECWck8tL0′,’natasa@email.ch’,
‘http://www.supertext.ch’,'natasa’,'Natasa’,
’2010-09-10 15:08:08′,’Natasa’)

And this is the solution:

ALTER TABLE wp_users CHANGE COLUMN user_activation_key user_activation_key VARCHAR(60) NOT NULL DEFAULT ”;

Maybe there are other places where something similar is missing. I’m sure you can fix it in the same way.


Import terminology from Excel into SDL MultiTerm 2009

August 5th, 2010 by

I wanted to setup a new SDL Multiterm 2009 Termbase to organize our Terminology. Since we have lots of stuff already in existing Excel spreadsheets, importing them would make sense. This is a post about how to do this.

First, to get a little order into the whole thing, I figured adding a Category setting to every Term would help later on.

image

In the picture above, you can see the Category. It’s built into Multiterm and is of the type Picklist. But that Picklist does not contain the categories that I wanted yet, so you have to add them manually.

Add a entry into the Category Picklist

First, you need to have a Termbase open. I used the predefined termbase template “Multilingual termbase”.

image

Extending the Category itself is actually pretty simple:

  1. Go to the  Catalog of your Termbase
  2. Right-click on Definition and then Edit
  3. Go through the Wizard until Step 4
  4. Select Category and then Properties below
  5. Now you can add new Entries (see in the pictures below)

image

image

Get the Excel ready

Now that we prepared our Termbase, we can get the Excel ready. Besides the two obvious columns with the terms, we need 2 more  columns with the Category. The title needs to be exactly the same as in Multiterm. In this case “Category”. The same is true for the entries, I’ve added an entry “amount” to the termbase, which is exactly the same as in the Excel spreadsheet. Upper and Lowercase matters too. Otherwise there will be no match.

Make sure the titles are on the first line, otherwise Trados will not recognize them.

Excel with Terminology

Now we have to start SDL MultiTerm Convert 2009. You cannot import an Excel directly into MultiTerm unfortunately.

The Excel import wizard is pretty straight forward. There are only two points that need a little attention. On Step 5 make sure that you set the 2 Term columns to be Index fields with the right language and the Category column to be a Descriptive field of type Picklist. Don’t worry if you only see the Category column once.

image

In the next step we have to add the two Category fields to the structure, as you can see in the picture below, I’ve added Category #1 to the Term below CH-DE and Category #2 to EN-US.

image

This all we have to do in MultiTerm Convert. Finish the wizard and go back to the SDL MultiTerm 2009 main application.

Import into MultiTerm

Go to the Catalog of your termbase, click on Import and then I would use the “default import” definition. Right-click and choose Process. You should have an *.mtf.xml file from the Excel converting process. Choose that and just follow the Wizard.

That’s about it.

Please post comments below if you run into issues.


  • Topics
  • Archive
  • Subscribe
  • Facebook
  • Twitter