Changeset 620


Ignore:
Timestamp:
Nov 24, 2014 4:27:40 PM (10 years ago)
Author:
dungnv
Message:
 
Location:
pro-violet-viettel/sourcecode
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/helpers/lockfile_helper.php

    r619 r620  
    33if ( ! function_exists('createLockFile'))
    44{
    5         function createLockFile ($lockFilePrefix, $maxReach, $timeToUnlock, $colSep = '|', $lockFilePath = '')
     5        function createLockFile ($lockFilePrefix, $maxReach, $timeToUnlock, $lockFilePath = '', $checkLockOnly = 0, $colSep = '|')
    66        {
    77                $currentTimeStamp = time();
     
    2424                $timeDiffMin = $lastTimeLock != '' ? dateDifference(date('Y-m-d H:i:s',$currentTimeStamp), date('Y-m-d H:i:s',$lastTimeLock), '%i') : 0;
    2525       
    26                 if ($lockCount < $maxReach && $timeDiffMin < $timeToUnlock) {
     26                if ($lockCount < $maxReach && $timeDiffMin < $timeToUnlock && $checkLockOnly == 0) {
    2727                        $lockCount ++;
    2828                        $isLocked = $lockCount < $maxReach ? 0:1;
     
    3737                $lockTime = ($isLocked == 1) ? $lastTimeLock : $currentTimeStamp;
    3838                $content = $lockCount . $colSep . $lockTime . $colSep . $isLocked;
    39                 if($ready == 1) {
     39               
     40                if($ready == 1 && $checkLockOnly == 0) {
    4041                        $fh = fopen ($filePath,'w');
    4142                        fwrite ($fh, $content);
     
    4344                }
    4445       
    45                 return $lockCount;
     46                return $isLocked;
    4647        }
    4748}
  • pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php

    r599 r620  
    192192               
    193193                if ($checkSentNumber) {
    194                         $sms = "So Dien thoai " . $sentNumber . " da dang ky tren he thong SBG Online. Tran trong.";
     194                        $sms = "So dien thoai " . $sentNumber . " da dang ky tai khoan tren he thong SBG Online. Tran trong.";
    195195                        $status = 0;
    196196                        return $status . '|' . $sms;
     
    234234                                        break;
    235235                                case 2:
    236                                         $sms = "So Dien thoai " . $sentNumber . " da dang ky tren he thong SBG Online. Tran trong";
     236                                        $sms = "So dien thoai " . $sentNumber . " da dang ky tai khoan tren he thong SBG Online. Tran trong";
    237237                                        $status = 0;
    238238                                        break;
     
    247247                        }
    248248                } else {
    249                         $sms = "Tai khoan ".$username." chua dang ky tai khoan tren he thong SBG Online. Tran trong.";
     249                        $sms = "So dien thoai ".$username." chua dang ky tai khoan tren he thong SBG Online. Tran trong.";
    250250                        $status = 0;
    251251                }
  • pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php

    r608 r620  
    476476                        </div>
    477477                        <div class="modal-body">
    478                                 <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>
     478                                <div id="no_success_charge_info" class="alert alert-block alert-success"><center></center></div>
    479479                                <center><button id="package_register_finish_button" data-dismiss="modal" class="btn btn-primary" >Đóng</button></center>
    480480                        </div>
  • pro-violet-viettel/sourcecode/application/modules/services/controllers/recharge.php

    r611 r620  
    66        {
    77                parent::__construct();
     8                $this->load->model('frontend/user_model', 'objUserModel');
     9                $this->load->helper('lockfile');
     10                $this->load->model('services_model');
    811        }
    912       
     
    1417                $cardSerial = $input['card_serial'];
    1518                $pinCard = $input['pin_card'];
    16                 $aryParams = array(
    17                         'EWalletID' => $this->config->item('EWalletID'),
    18                         'CardSerial' => $cardSerial,
    19                         'PinCard' => $pinCard,
    20                 );
    21                
    22                 $this->load->model('services_model');
    23                 $aryResult = array();
    24                 $data = $this->services_model->cardPaidProcess($aryParams,  $aryResult);
    25                 $this->load->model('frontend/user_model', 'objUserModel');
    26                 $paidType = 2;
    27                 $amount = $aryResult['TransactionAmount'];
    28                 $paidTime = date('Y-m-d H:i:s');
     19                $isLocked = 0;
    2920               
    3021                $user = $this->objUserModel->get_user_by_id($userID);
    31                 $user['acc_balanced'] = $user['acc_balanced'] + $amount;
    32                 $user['updated_time'] = date('Y-m-d H:i:s');
    33                 if ($amount>0){
    34                         $this->objUserModel->updateUser($userID, $user);
     22                $lockFilePreFix = $user['cellphone'];
     23                $lockFilePath = $this->config->item('topup_lock_path');
     24                $maxReach = $this->config->item('topup_lock_max_reach');
     25                $timeToUnlock = $this->config->item('topup_unlock_minute');
     26
     27                $isLocked = createLockFile($lockFilePreFix, $maxReach, $timeToUnlock, $lockFilePath, 1);
     28                $chargCard = _SBG_CARD_PAY_SUCCESS;
     29                $result = array();
     30                $result['maxReach'] = $maxReach;
     31                $result['timeToUnlock'] = $timeToUnlock;
     32                $result['isLocked'] = $isLocked;
     33                $result['tmp'] = $maxReach;
     34               
     35                $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!';
     36                $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!';
     37                $errMsg = '';
     38               
     39                if ($isLocked == 0) {
     40                        $aryParams = array(
     41                                        'EWalletID' => $this->config->item('EWalletID'),
     42                                        'CardSerial' => $cardSerial,
     43                                        'PinCard' => $pinCard,
     44                        );
     45                       
     46                        $aryResult = array();
     47                        $chargCard = $this->services_model->cardPaidProcess($aryParams,  $aryResult);
     48                       
     49                        $paidType = 2;
     50                        $amount = $aryResult['TransactionAmount'];
     51                        $paidTime = date('Y-m-d H:i:s');
     52                        $user['acc_balanced'] = $user['acc_balanced'] + $amount;
     53                        $user['updated_time'] = date('Y-m-d H:i:s');
     54                        if ($amount>0){
     55                                $this->objUserModel->updateUser($userID, $user);
     56                        }
     57                       
     58                        $result['success'] = $chargCard;
     59                       
     60                        if ($chargCard == _SBG_CARD_PAY_SUCCESS){
     61                                $result['username'] = $user['cellphone'];
     62                                $result['acc_balanced'] = $user['acc_balanced'];
     63                                $result['amount'] = $amount;
     64                                $this->objUserModel->insertPaidlog($user['cellphone'], $user['cellphone'], $paidType, $amount, $paidTime);
     65                                releaseLockFile($lockFilePreFix, $lockFilePath);
     66                        }
     67                        else {
     68                                $isLocked = createLockFile($lockFilePreFix, $maxReach, $timeToUnlock, $lockFilePath);
     69                                $errMsg = $isLocked == 1 ? $chargErrMsg .'<br />'.$lockedMsg : $chargErrMsg;
     70                        }
     71                }else if ($isLocked == 1) {
     72                        $errMsg = $lockedMsg;
     73                        $result['success'] = _SBG_CARD_PAY_FAIL;
    3574                }
    3675               
    37                 $result = array();
    38                 if ($data == 1){
    39                         $result['success'] = 1;
    40                         $result['username'] = $user['cellphone'];
    41                         $result['acc_balanced'] = $user['acc_balanced'];
    42                         $result['amount'] = $amount;
    43                         $this->objUserModel->insertPaidlog($user['cellphone'], $user['cellphone'], $paidType, $amount, $paidTime);
    44                 }else
    45                 {
    46                         $result['success'] = 0;
    47                 }
     76                $result['errMsg'] = $errMsg;
    4877                echo json_encode($result);
    4978        }
  • pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php

    r616 r620  
    1212
    1313if ( ! defined('_SBG_MO_SYNTAX_ERR')) define('_SBG_MO_SYNTAX_ERR', -1);
    14 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.');
     14if ( ! 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.');
    1515
    1616if ( ! defined('_SBG_CARD_PAY_FAIL')) define('_SBG_CARD_PAY_FAIL', -1);
  • pro-violet-viettel/sourcecode/assets/css/custom.css

    r563 r620  
    22   margin-right: 0;
    33}
     4
     5li {
     6        white-space: nowrap;
     7}
     8
     9.nav-tabs>li {
     10        margin-bottom: -2px
     11}
     12
    413.modal {
    514  overflow-y: auto;
    615}
    7 
     16.icon-a:before {
     17        content: "";
     18}
    819@media (max-width:993px) {
    920        .site-info {
     
    1728.login-container {
    1829        width:100%
    19 }
    20 
    21 .main-container {
    22         margin-top: 64px;
    2330}
    2431
     
    263270        left: 0
    264271}
     272
     273#not_success_charge .modal-dialog {
     274        width:620px;
     275}
  • pro-violet-viettel/sourcecode/assets/js/frontend/user.js

    r617 r620  
    158158                        }else
    159159                        {
     160                                /*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!';
     161                                if (result.isLocked == 1) {
     162                                        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!';
     163                                }*/
     164                               
     165                                $("#not_success_charge").find('div#no_success_charge_info > center').html (result.errMsg);
    160166                                $("#not_success_charge").modal('show');
    161167                        }
  • pro-violet-viettel/sourcecode/info.php

    r460 r620  
     1<script>
     2function addCommas(nStr)
     3{
     4   nStr += '';
     5   x = nStr.split('.');
     6   x1 = x[0];
     7   x2 = x.length > 1 ? '.' + x[1] : '';
     8   var rgx = /(\d+)(\d{3})/;
     9   while (rgx.test(x1)) {
     10      x1 = x1.replace(rgx, '$1' + ',' + '$2');
     11   }
     12   return x1 + x2;
     13}
     14
     15console.log(addCommas(1000000000));
     16</script>
    117<?php
    2 echo md5('123456'), "<br />";
     18echo md5('123456a'), "<br />";
    319echo md5('0988568786violet');
    420phpinfo();
  • pro-violet-viettel/sourcecode/service.php

    r473 r620  
    11<?php
    2 require_once('/srv/www/sbg/application/libraries/nusoap/nusoap.php');
    32
    4 $nusoap_server = new soap_server();
    5 $nusoap_server->configureWSDL('messageReceiverWSDL','urn:messageReceiverWSDL');
    6 
    7 $nusoap_server->soap_defencoding = 'UTF-8';
    8 $nusoap_server->methodreturnisliteral=TRUE;
    9 
    10 $nusoap_server->wsdl->schemaTargetNamespace = 'http://soapinterop.org/xsd/';
    11 $nusoap_server->wsdl->addComplexType(
    12                 'messageReceiver',
    13                 'simpleType',
    14                 'struct',
    15                 '',
    16                 'SOAP-ENC:Array',
    17                 array(
    18                                 'username'=>array('name'=>'username', 'type'=>'xsd:string'),
    19                                 'password'=>array('name'=>'password', 'type'=>'xsd:string'),
    20                                 'requestID'=>array('name'=>'requestID', 'type'=>'xsd:string'),
    21                                 'userID'=>array('name'=>'userID', 'type'=>'xsd:string'),
    22                                 'receiverID'=>array('name'=>'receiverID', 'type'=>'xsd:string'),
    23                                 'serviceID'=>array('name'=>'serviceID', 'type'=>'xsd:string'),
    24                                 'commandCode'=>array('name'=>'commandCode', 'type'=>'xsd:string'),
    25                                 'contentType'=>array('name'=>'contentType', 'type'=>'xsd:string'),
    26                                 'info'=>array('name'=>'info', 'type'=>'xsd:string'),
    27                                 'receiveTime'=>array('name'=>'receiveTime', 'type'=>'xsd:string')
    28                 )
    29 );
    30 
    31 $nusoap_server->register ( 'MOReceiver',
    32                 array( 'username' => 'xsd:string',
    33                                 'password' => 'xsd:string',
    34                                 'requestID' => 'xsd:string',
    35                                 'userID' => 'xsd:string',
    36                                 'receiverID' => 'xsd:string',
    37                                 'serviceID' => 'xsd:string',
    38                                 'commandCode' => 'xsd:string',
    39                                 'contentType' => 'xsd:string',
    40                                 'info' => 'xsd:string',
    41                                 'receiveTime' => 'xsd:string')
    42                 , array ('return' => 'xsd:string'),
    43                 'urn:messageReceiverWSDL',"urn:messageReceiverWSDL#MOReceiver","rpc","encoded");
    44 
    45 function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $contentType ,$info, $receiveTime)
     3function createLockFile ($lockFilePrefix, $maxReach, $timeToUnlock, $colSep = '|')
    464{
     5        $currentTimeStamp = time();
     6        $filePath = $lockFilePrefix.'_lock';
     7        $fileExisted = file_exists($filePath);
     8        $content = '';
     9        $lastTimeLock = '';
     10        $lockCount = 0;
     11        $isLocked = 0;
    4712       
     13        if ($fileExisted) {
     14                $content = file_get_contents($filePath);
     15        }
     16       
     17        if ($content != '') {
     18                list($lockCount, $lastTimeLock, $isLocked) = explode ($colSep, $content);
     19        }
     20       
     21        $timeDiffMin = $lastTimeLock != '' ? dateDifference(date('Y-m-d H:i:s',$currentTimeStamp), date('Y-m-d H:i:s',$lastTimeLock), '%i') : 0;
     22       
     23       
     24        if ($lockCount < $maxReach && $timeDiffMin < $timeToUnlock) {
     25                $lockCount ++;
     26                $isLocked = $lockCount < $maxReach ? 0:1;
     27        }
     28        else if ($timeDiffMin > $timeToUnlock) {
     29                $lockCount = 0;
     30                $isLocked = 0;
     31        }
     32       
     33        $lockTime = ($isLocked == 1) ? $lastTimeLock : $currentTimeStamp;
     34        $content = $lockCount . $colSep . $lockTime . $colSep . $isLocked;
     35        $fh = fopen ($filePath,'w');
     36        fwrite ($fh, $content);
     37        fclose ($fh);
     38       
     39        return $timeDiffMin;
    4840}
    4941
    50 $nusoap_server->service(file_get_contents("php://input"));
     42function releaseLockFile ($lockFilePrefix)
     43{
     44        $filePath = $lockFilePrefix.'_lock';
     45        $fileExisted = file_exists($filePath);
     46        if ($fileExisted) {
     47                unlink($filePath);
     48        }
     49}
     50
     51function dateDifference($date_1 , $date_2 , $differenceFormat = '%a' )
     52{
     53        $datetime1 = date_create($date_1);
     54        $datetime2 = date_create($date_2);
     55        $interval = date_diff($datetime1, $datetime2);
     56        return $interval->format($differenceFormat);
     57}
     58
     59$username = '0988568786';
     60$maxReach = 3;
     61$timeToUnlock = 1;
     62echo createLockFile($username, $maxReach, $timeToUnlock);
     63releaseLockFile ($username);
     64
     65
Note: See TracChangeset for help on using the changeset viewer.