Well since Mac OSX Leopard created an issue with synergys running in the background I have updated my script which was just for creating the reverse ssh link and starting synergyc on the remote system. Now since at least synergys runs in the foreground I decided to run it in a screen.
So the updated script will start synergys then create the reverse ssh tunnel and finally start the remote synergyc.
Added other nerdy features like status and display output formatting.
So get the script if it interests you.
Wednesday, October 31, 2007
Friday, October 5, 2007
[PHP] masking a credit card number
So if you have ever had to create a shopping cart and on the receipt page you want to display the last 4 digits of the credit card number and just x out the rest well you would prolly create a bit of code like on the php.net comments such as:
But of course I don't like that solutions so here is my version:
function mask ( $str, $start = 0, $length = null ) {
$mask = preg_replace ( "/\S/", "*", $str );
if ( is_null ( $length )) {
$mask = substr ( $mask, $start );
$str = substr_replace ( $str, $mask, $start );
} else {
$mask = substr ( $mask, $start, $length );
$str = substr_replace ( $str, $mask, $start, $length );
}
return $str;
}But of course I don't like that solutions so here is my version:
$maskedCcn = substr_replace(
preg_replace( '/\S/', 'X',
preg_replace( '/[^0-9]*/', null, $cardNumber );
),
substr( $maskedCcn, -4 ),
strlen( $maskedCcn ) - 4,
4
);
Subscribe to:
Posts (Atom)