Monday, 31 October 2011

HSBC API: PayerTxnId is not in a valid base64 encoding

That pesky HSBC API caused me a lot of grief when I first had to set it up on a client site. For various reasons I ended up using the XML method of performing the transaction.

Having recently implemented the 3D secure (Payer Authentication Specification (PAS)) I was getting a PayerTxnId 'LOADS_OF CHARS' is not in a valid  base64 encoding. The PayerTxnId is pulled from the posted data from HSBC. It comes from the XID field.

It took me a while to spot it and, to be honest, I thought I would have to contact HSBC technical support yet again (who , by the by, are very good). But I did spot it! There was a space in the string. I swapped that out for a + and hey presto, the HSBC API processed it just fine.

Wednesday, 19 October 2011

Block IP Addresses on Windows Server 2003

A big thank you goes out to CodeHill today for allowing me to find out how to easily block IP addresses with built-in Windows server functionality.

The idea is that you create an IP Security Policy on the server and add each IP, range or subnet to it. Perfect :)

Tuesday, 18 October 2011

Unicode Characters in an Email Subject using PHP and PEAR

I've been working on a PHP site recently where I have had to cater for all languages and more importantly Unicode languages.

So after quite a lot of messing about and hunting around I found that I needed to do the following with the subject:

if (function_exists("mb_internal_encoding"))
if (function_exists("mb_encode_mimeheader"))
 $subject = mb_encode_mimeheader($subject, "UTF-8", "B", "\n");

Obviously if you know if the mb_* functions are available, then you can do away with the if statements.

This works using the PEAR Mail_Mime library. I haven't tested it with the built-in PHP mail function. I would assume it does not work.

Tuesday, 4 October 2011

How To Reset an Identity Column in MSSQL / SQL Server

Something I often find myself needing to do is reset the identity column on auto incrementing field in MS SQL / SQL Server.

There are a couple of ways of doing it:
  1. If you are emptying the table, instead of using a DELETE, use a TRUNCATE. That will automatically reset the identity.
  2. The ID can be set to a specific number by using DBCC CHECKIDENT([TABLE_NAME], RESEED, n). Where n is the number that is to be set.
If you already have data in the table and you want to make sure that the sequence is followed, then use this:


.net (7) ajax (1) android (7) apache (1) (3) asus (2) blogger (2) blogspot (3) c# (16) compact framework (2) cron (1) css (1) data (1) data recovery (2) dns (1) eclipse (1) encryption (1) excel (1) font (1) ftp (1) gmail (5) google (4) gopro (1) html (1) iis (3) internet explorer IE (1) iphone (1) javascript (3) kinect (1) linux (1) macro (1) mail (9) mercurial (1) microsoft (3) microsoft office (3) monitoring (1) mootools (1) ms access (1) mssql (13) mysql (2) open source (1) openvpn (1) pear (2) permissions (1) php (12) plesk (4) proxy (1) qr codes (1) rant (4) reflection (3) regex (1) replication (1) reporting services (5) security (2) signalr (1) sql (11) sqlce (1) sqlexpress (1) ssis (1) ssl (1) stuff (1) svn (2) syntax (1) tablet (2) telnet (3) tools (1) twitter (1) unix (3) vb script (3) (9) vba (1) visual studio (2) vpc (2) vpn (1) windows (4) woff (1) xbox 360 (1)