Index: /pro-violet-viettel/sourcecode/application/helpers/lockfile_helper.php
===================================================================
--- /pro-violet-viettel/sourcecode/application/helpers/lockfile_helper.php	(revision 619)
+++ /pro-violet-viettel/sourcecode/application/helpers/lockfile_helper.php	(revision 620)
@@ -3,5 +3,5 @@
 if ( ! function_exists('createLockFile'))
 {
-	function createLockFile ($lockFilePrefix, $maxReach, $timeToUnlock, $colSep = '|', $lockFilePath = '')
+	function createLockFile ($lockFilePrefix, $maxReach, $timeToUnlock, $lockFilePath = '', $checkLockOnly = 0, $colSep = '|')
 	{
 		$currentTimeStamp = time();
@@ -24,5 +24,5 @@
 		$timeDiffMin = $lastTimeLock != '' ? dateDifference(date('Y-m-d H:i:s',$currentTimeStamp), date('Y-m-d H:i:s',$lastTimeLock), '%i') : 0;
 	
-		if ($lockCount < $maxReach && $timeDiffMin < $timeToUnlock) {
+		if ($lockCount < $maxReach && $timeDiffMin < $timeToUnlock && $checkLockOnly == 0) {
 			$lockCount ++;
 			$isLocked = $lockCount < $maxReach ? 0:1;
@@ -37,5 +37,6 @@
 		$lockTime = ($isLocked == 1) ? $lastTimeLock : $currentTimeStamp;
 		$content = $lockCount . $colSep . $lockTime . $colSep . $isLocked;
-		if($ready == 1) {
+		
+		if($ready == 1 && $checkLockOnly == 0) {
 			$fh = fopen ($filePath,'w');
 			fwrite ($fh, $content);
@@ -43,5 +44,5 @@
 		}
 	
-		return $lockCount;
+		return $isLocked;
 	}
 }
Index: /pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php
===================================================================
--- /pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 619)
+++ /pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 620)
@@ -192,5 +192,5 @@
 		
 		if ($checkSentNumber) {
-			$sms = "So Dien thoai " . $sentNumber . " da dang ky tren he thong SBG Online. Tran trong.";
+			$sms = "So dien thoai " . $sentNumber . " da dang ky tai khoan tren he thong SBG Online. Tran trong.";
 			$status = 0;
 			return $status . '|' . $sms;
@@ -234,5 +234,5 @@
 					break;
 				case 2:
-					$sms = "So Dien thoai " . $sentNumber . " da dang ky tren he thong SBG Online. Tran trong";
+					$sms = "So dien thoai " . $sentNumber . " da dang ky tai khoan tren he thong SBG Online. Tran trong";
 					$status = 0;
 					break;
@@ -247,5 +247,5 @@
 			}
 		} else {
-			$sms = "Tai khoan ".$username." chua dang ky tai khoan tren he thong SBG Online. Tran trong.";
+			$sms = "So dien thoai ".$username." chua dang ky tai khoan tren he thong SBG Online. Tran trong.";
 			$status = 0;
 		}
Index: /pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php
===================================================================
--- /pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php	(revision 619)
+++ /pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php	(revision 620)
@@ -476,5 +476,5 @@
 			</div>
 			<div class="modal-body">
-				<div id="no_success_charge_info" class="alert alert-block alert-success"><center>MÃ£ tháº» hoáº·c Serial khÃŽng ÄÃºng hoáº·c ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng. QuÃ­ vá» vui lÃ²ng kiá»m tra láº¡i!</center></div>
+				<div id="no_success_charge_info" class="alert alert-block alert-success"><center></center></div>
 				<center><button id="package_register_finish_button" data-dismiss="modal" class="btn btn-primary" >ÄÃ³ng</button></center>
 			</div>
Index: /pro-violet-viettel/sourcecode/application/modules/services/controllers/recharge.php
===================================================================
--- /pro-violet-viettel/sourcecode/application/modules/services/controllers/recharge.php	(revision 619)
+++ /pro-violet-viettel/sourcecode/application/modules/services/controllers/recharge.php	(revision 620)
@@ -6,4 +6,7 @@
 	{
 		parent::__construct();
+		$this->load->model('frontend/user_model', 'objUserModel');
+		$this->load->helper('lockfile');
+		$this->load->model('services_model');
 	}
 	
@@ -14,36 +17,62 @@
 		$cardSerial = $input['card_serial'];
 		$pinCard = $input['pin_card'];
-		$aryParams = array(
-			'EWalletID' => $this->config->item('EWalletID'),
-			'CardSerial' => $cardSerial,
-			'PinCard' => $pinCard,
-		);
-		
-		$this->load->model('services_model');
-		$aryResult = array();
-		$data = $this->services_model->cardPaidProcess($aryParams,  $aryResult);
-		$this->load->model('frontend/user_model', 'objUserModel');
-		$paidType = 2;
-		$amount = $aryResult['TransactionAmount'];
-		$paidTime = date('Y-m-d H:i:s');
+		$isLocked = 0;
 		
 		$user = $this->objUserModel->get_user_by_id($userID);
-		$user['acc_balanced'] = $user['acc_balanced'] + $amount;
-		$user['updated_time'] = date('Y-m-d H:i:s');
-		if ($amount>0){
-			$this->objUserModel->updateUser($userID, $user);
+		$lockFilePreFix = $user['cellphone'];
+		$lockFilePath = $this->config->item('topup_lock_path');
+		$maxReach = $this->config->item('topup_lock_max_reach');
+		$timeToUnlock = $this->config->item('topup_unlock_minute');
+
+		$isLocked = createLockFile($lockFilePreFix, $maxReach, $timeToUnlock, $lockFilePath, 1);
+		$chargCard = _SBG_CARD_PAY_SUCCESS;
+		$result = array();
+		$result['maxReach'] = $maxReach;
+		$result['timeToUnlock'] = $timeToUnlock;
+		$result['isLocked'] = $isLocked;
+		$result['tmp'] = $maxReach;
+		
+		$lockedMsg = 'QuÃœ vá» ÄÃ£ nháº­p sai thÃŽng tin tháº» cÃ o '. $maxReach .' láº§n liÃªn tiáº¿p.<br />Xin chá» '. $timeToUnlock .' phÃºt sau Äá» thao tÃ¡c láº¡i!';
+		$chargErrMsg = 'MÃ£ tháº» hoáº·c Serial khÃŽng ÄÃºng hoáº·c ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng. QuÃ­ vá» vui lÃ²ng kiá»m tra láº¡i!';
+		$errMsg = '';
+		
+		if ($isLocked == 0) {
+			$aryParams = array(
+					'EWalletID' => $this->config->item('EWalletID'),
+					'CardSerial' => $cardSerial,
+					'PinCard' => $pinCard,
+			);
+			
+			$aryResult = array();
+			$chargCard = $this->services_model->cardPaidProcess($aryParams,  $aryResult);
+			
+			$paidType = 2;
+			$amount = $aryResult['TransactionAmount'];
+			$paidTime = date('Y-m-d H:i:s');
+			$user['acc_balanced'] = $user['acc_balanced'] + $amount;
+			$user['updated_time'] = date('Y-m-d H:i:s');
+			if ($amount>0){
+				$this->objUserModel->updateUser($userID, $user);
+			}
+			
+			$result['success'] = $chargCard;
+			
+			if ($chargCard == _SBG_CARD_PAY_SUCCESS){
+				$result['username'] = $user['cellphone'];
+				$result['acc_balanced'] = $user['acc_balanced'];
+				$result['amount'] = $amount;
+				$this->objUserModel->insertPaidlog($user['cellphone'], $user['cellphone'], $paidType, $amount, $paidTime);
+				releaseLockFile($lockFilePreFix, $lockFilePath);
+			}
+			else {
+				$isLocked = createLockFile($lockFilePreFix, $maxReach, $timeToUnlock, $lockFilePath);
+				$errMsg = $isLocked == 1 ? $chargErrMsg .'<br />'.$lockedMsg : $chargErrMsg; 
+			}
+		}else if ($isLocked == 1) {
+			$errMsg = $lockedMsg; 
+			$result['success'] = _SBG_CARD_PAY_FAIL;
 		}
 		
-		$result = array();
-		if ($data == 1){
-			$result['success'] = 1;
-			$result['username'] = $user['cellphone'];
-			$result['acc_balanced'] = $user['acc_balanced'];
-			$result['amount'] = $amount;
-			$this->objUserModel->insertPaidlog($user['cellphone'], $user['cellphone'], $paidType, $amount, $paidTime);
-		}else
-		{
-			$result['success'] = 0;
-		}
+		$result['errMsg'] = $errMsg;
 		echo json_encode($result);
 	}
Index: /pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php
===================================================================
--- /pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 619)
+++ /pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 620)
@@ -12,5 +12,5 @@
 
 if ( ! defined('_SBG_MO_SYNTAX_ERR')) define('_SBG_MO_SYNTAX_ERR', -1);
-if ( ! defined('_SBG_MO_SYNTAX_ERR_MSG')) define('_SBG_MO_SYNTAX_ERR_MSG', 'SBG Online khong co dich vu nÃ y, ban vui long kiem tra lai. Tran trong.');
+if ( ! defined('_SBG_MO_SYNTAX_ERR_MSG')) define('_SBG_MO_SYNTAX_ERR_MSG', 'SBG Online khong co dich vu nay, ban vui long kiem tra lai. Tran trong.');
 
 if ( ! defined('_SBG_CARD_PAY_FAIL')) define('_SBG_CARD_PAY_FAIL', -1);
Index: /pro-violet-viettel/sourcecode/assets/css/custom.css
===================================================================
--- /pro-violet-viettel/sourcecode/assets/css/custom.css	(revision 619)
+++ /pro-violet-viettel/sourcecode/assets/css/custom.css	(revision 620)
@@ -2,8 +2,19 @@
    margin-right: 0;
 }
+
+li {
+	white-space: nowrap;
+}
+
+.nav-tabs>li {
+	margin-bottom: -2px
+}
+
 .modal {
   overflow-y: auto;
 }
-
+.icon-a:before {
+	content: "";
+}
 @media (max-width:993px) {
 	.site-info {
@@ -17,8 +28,4 @@
 .login-container {
 	width:100%
-}
-
-.main-container {
-	margin-top: 64px;
 }
 
@@ -263,2 +270,6 @@
 	left: 0
 }
+
+#not_success_charge .modal-dialog {
+	width:620px;
+}
Index: /pro-violet-viettel/sourcecode/assets/js/frontend/user.js
===================================================================
--- /pro-violet-viettel/sourcecode/assets/js/frontend/user.js	(revision 619)
+++ /pro-violet-viettel/sourcecode/assets/js/frontend/user.js	(revision 620)
@@ -158,4 +158,10 @@
 			}else
 			{
+				/*var notSuccessMsg = 'MÃ£ tháº» hoáº·c Serial khÃŽng ÄÃºng hoáº·c ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng. QuÃ­ vá» vui lÃ²ng kiá»m tra láº¡i!';
+				if (result.isLocked == 1) {
+					notSuccessMsg = 'QuÃœ vá» ÄÃ£ nháº­p sai thÃŽng tin tháº» cÃ o ' + result.maxReach + ' láº§n liÃªn tiáº¿p.<br />Xin chá» ' + result.timeToUnlock + ' phÃºt sau Äá» thao tÃ¡c láº¡i!';
+				}*/
+				
+				$("#not_success_charge").find('div#no_success_charge_info > center').html (result.errMsg);
 				$("#not_success_charge").modal('show');
 			}
Index: /pro-violet-viettel/sourcecode/info.php
===================================================================
--- /pro-violet-viettel/sourcecode/info.php	(revision 619)
+++ /pro-violet-viettel/sourcecode/info.php	(revision 620)
@@ -1,4 +1,20 @@
+<script>
+function addCommas(nStr)
+{
+   nStr += '';
+   x = nStr.split('.');
+   x1 = x[0];
+   x2 = x.length > 1 ? '.' + x[1] : '';
+   var rgx = /(\d+)(\d{3})/;
+   while (rgx.test(x1)) {
+      x1 = x1.replace(rgx, '$1' + ',' + '$2');
+   }
+   return x1 + x2;
+}
+
+console.log(addCommas(1000000000));
+</script>
 <?php
-echo md5('123456'), "<br />";
+echo md5('123456a'), "<br />";
 echo md5('0988568786violet');
 phpinfo();
Index: /pro-violet-viettel/sourcecode/service.php
===================================================================
--- /pro-violet-viettel/sourcecode/service.php	(revision 619)
+++ /pro-violet-viettel/sourcecode/service.php	(revision 620)
@@ -1,50 +1,65 @@
 <?php 
-require_once('/srv/www/sbg/application/libraries/nusoap/nusoap.php');
 
-$nusoap_server = new soap_server();
-$nusoap_server->configureWSDL('messageReceiverWSDL','urn:messageReceiverWSDL');
-
-$nusoap_server->soap_defencoding = 'UTF-8';
-$nusoap_server->methodreturnisliteral=TRUE;
-
-$nusoap_server->wsdl->schemaTargetNamespace = 'http://soapinterop.org/xsd/';
-$nusoap_server->wsdl->addComplexType(
-		'messageReceiver',
-		'simpleType',
-		'struct',
-		'',
-		'SOAP-ENC:Array',
-		array(
-				'username'=>array('name'=>'username', 'type'=>'xsd:string'),
-				'password'=>array('name'=>'password', 'type'=>'xsd:string'),
-				'requestID'=>array('name'=>'requestID', 'type'=>'xsd:string'),
-				'userID'=>array('name'=>'userID', 'type'=>'xsd:string'),
-				'receiverID'=>array('name'=>'receiverID', 'type'=>'xsd:string'),
-				'serviceID'=>array('name'=>'serviceID', 'type'=>'xsd:string'),
-				'commandCode'=>array('name'=>'commandCode', 'type'=>'xsd:string'),
-				'contentType'=>array('name'=>'contentType', 'type'=>'xsd:string'),
-				'info'=>array('name'=>'info', 'type'=>'xsd:string'),
-				'receiveTime'=>array('name'=>'receiveTime', 'type'=>'xsd:string')
-		)
-);
-
-$nusoap_server->register ( 'MOReceiver',
-		array( 'username' => 'xsd:string',
-				'password' => 'xsd:string',
-				'requestID' => 'xsd:string',
-				'userID' => 'xsd:string',
-				'receiverID' => 'xsd:string',
-				'serviceID' => 'xsd:string',
-				'commandCode' => 'xsd:string',
-				'contentType' => 'xsd:string',
-				'info' => 'xsd:string',
-				'receiveTime' => 'xsd:string')
-		, array ('return' => 'xsd:string'),
-		'urn:messageReceiverWSDL',"urn:messageReceiverWSDL#MOReceiver","rpc","encoded");
-
-function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $contentType ,$info, $receiveTime)
+function createLockFile ($lockFilePrefix, $maxReach, $timeToUnlock, $colSep = '|') 
 {
+	$currentTimeStamp = time();
+	$filePath = $lockFilePrefix.'_lock';
+	$fileExisted = file_exists($filePath);
+	$content = '';
+	$lastTimeLock = '';
+	$lockCount = 0;
+	$isLocked = 0;
 	
+	if ($fileExisted) {
+		$content = file_get_contents($filePath);
+	}
+	
+	if ($content != '') {
+		list($lockCount, $lastTimeLock, $isLocked) = explode ($colSep, $content);
+	}
+	
+	$timeDiffMin = $lastTimeLock != '' ? dateDifference(date('Y-m-d H:i:s',$currentTimeStamp), date('Y-m-d H:i:s',$lastTimeLock), '%i') : 0;
+	
+	
+	if ($lockCount < $maxReach && $timeDiffMin < $timeToUnlock) {
+		$lockCount ++;
+		$isLocked = $lockCount < $maxReach ? 0:1;
+	}
+	else if ($timeDiffMin > $timeToUnlock) {
+		$lockCount = 0;
+		$isLocked = 0;
+	}
+	
+	$lockTime = ($isLocked == 1) ? $lastTimeLock : $currentTimeStamp;
+	$content = $lockCount . $colSep . $lockTime . $colSep . $isLocked;
+	$fh = fopen ($filePath,'w');
+	fwrite ($fh, $content);
+	fclose ($fh);
+	
+	return $timeDiffMin;
 }
 
-$nusoap_server->service(file_get_contents("php://input"));
+function releaseLockFile ($lockFilePrefix) 
+{
+	$filePath = $lockFilePrefix.'_lock';
+	$fileExisted = file_exists($filePath);
+	if ($fileExisted) {
+		unlink($filePath);
+	}
+}
+
+function dateDifference($date_1 , $date_2 , $differenceFormat = '%a' )
+{
+	$datetime1 = date_create($date_1);
+	$datetime2 = date_create($date_2);
+	$interval = date_diff($datetime1, $datetime2);
+	return $interval->format($differenceFormat);
+}
+
+$username = '0988568786';
+$maxReach = 3;
+$timeToUnlock = 1;
+echo createLockFile($username, $maxReach, $timeToUnlock);
+releaseLockFile ($username);
+
+
