From 45f439ba6894924252a430807b6b72672eb45d20 Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Tue, 28 Feb 2012 13:00:45 +0100 Subject: [PATCH] Bug fixes and code beautification * Fixed password masking when the message has more than one password * Reading php://input in a separate line, for later debugging purposes --- jsonRPCServer.php | 3 ++- smsSender.php | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jsonRPCServer.php b/jsonRPCServer.php index aa318f3..b3dc75d 100644 --- a/jsonRPCServer.php +++ b/jsonRPCServer.php @@ -47,7 +47,8 @@ class jsonRPCServer { } // reads the input data - $request = json_decode(file_get_contents('php://input'),true); + $request_string = file_get_contents('php://input'); + $request = json_decode($request_string,true); // executes the task on local object try { diff --git a/smsSender.php b/smsSender.php index 2d7ea24..db3122a 100644 --- a/smsSender.php +++ b/smsSender.php @@ -6,6 +6,7 @@ class smsSender protected $sessionId = null; protected $dbBackend; protected $smsBackend; + const password_mask = ''; public function __construct($dbBackend, $smsBackend, $sessionId) { @@ -66,9 +67,11 @@ class smsSender { $msg = $message; + $mod = 0; foreach ($passwordLocations as $loc) { - $msg = substr_replace($msg, '', $loc[0], $loc[1]); + $msg = substr_replace($msg, self::password_mask, $loc[0] + $mod, $loc[1]); + $mod += (strlen(self::password_mask) - $loc[1]); } return $msg;