ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programmingระบบตัดบัตร TrueMoney ใช้ไฟล์ class ไฟล์เดียว ( TrueMoney Wallet )
หน้า: 1 [2] 3   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ระบบตัดบัตร TrueMoney ใช้ไฟล์ class ไฟล์เดียว ( TrueMoney Wallet )  (อ่าน 39428 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
GothicRaccoon
Newbie
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 2



ดูรายละเอียด
« ตอบ #20 เมื่อ: 07 มิถุนายน 2017, 19:41:03 »

น่าสนใจมากครับ PM หน่อยครับส่งไม่ไป
บันทึกการเข้า
lnwnuyhod
คนรักเสียว
*

พลังน้ำใจ: 7
ออฟไลน์ ออฟไลน์

กระทู้: 123



ดูรายละเอียด เว็บไซต์
« ตอบ #21 เมื่อ: 07 มิถุนายน 2017, 23:08:06 »

ไม่ได้เข้ามาซะนาน
มาเจอของดีเลยวันนี้
ลดค่าใช้จ่ายได้อีกหน่อยนึง
เอาไปลองใช้แล้ว ตัดบัตรก็ไว
ขอบคุณมากครับ
บันทึกการเข้า

seeza
คนรักเสียว
*

พลังน้ำใจ: 5
ออฟไลน์ ออฟไลน์

กระทู้: 144



ดูรายละเอียด
« ตอบ #22 เมื่อ: 07 มิถุนายน 2017, 23:45:43 »

ดีเลยครับ แต่ถ้าเอาไปใส่เว็บ จะติดตรงที่มีคนมาแกล้งใส่รหัสผิดบ่อยๆ เนี้ยแหละ
บันทึกการเข้า

โฆษณาแฟนเพจ 4 เพจ 2 แสนกว่าไลค์(ไลค์ธรรมชาติ) สนใจ พีเอ็มคุยกันครับ
xindy
Newbie
*

พลังน้ำใจ: 4
ออฟไลน์ ออฟไลน์

กระทู้: 11



ดูรายละเอียด
« ตอบ #23 เมื่อ: 08 มิถุนายน 2017, 05:24:39 »

เท่าที่ทดสอบใส่ผิด ผิดได้หลายครั้งยังไม่โดนบล๊อคเลยนะครับ
ดีเลยครับ แต่ถ้าเอาไปใส่เว็บ จะติดตรงที่มีคนมาแกล้งใส่รหัสผิดบ่อยๆ เนี้ยแหละ

« แก้ไขครั้งสุดท้าย: 08 มิถุนายน 2017, 05:29:40 โดย xindy » บันทึกการเข้า
wich2009
สมุนแก๊งเสียว
*

พลังน้ำใจ: 44
ออฟไลน์ ออฟไลน์

กระทู้: 860



ดูรายละเอียด เว็บไซต์
« ตอบ #24 เมื่อ: 08 มิถุนายน 2017, 06:03:06 »

ขอบคุณ ครับ
บันทึกการเข้า

lnwnuyhod
คนรักเสียว
*

พลังน้ำใจ: 7
ออฟไลน์ ออฟไลน์

กระทู้: 123



ดูรายละเอียด เว็บไซต์
« ตอบ #25 เมื่อ: 08 มิถุนายน 2017, 10:08:26 »

เท่าที่ทดสอบใส่ผิด ผิดได้หลายครั้งยังไม่โดนบล๊อคเลยนะครับ
ดีเลยครับ แต่ถ้าเอาไปใส่เว็บ จะติดตรงที่มีคนมาแกล้งใส่รหัสผิดบ่อยๆ เนี้ยแหละ

ผมว่าไม่น่าจะบล็อคน่ะ
เราก็เอาเลขบัตรผิดที่คิดว่าจะมีคนผิดใส่ในฐาน แล้วก็ให้เช็คจากฐานก่อนว่ามีบัตรนี้แล้วหรือยัง ถ้ามีแล้วก็ไม่ต้องให้มันส่งไป แค่นี้มันก็ไม่ส่งไปทุกครั่งที่ผิดหรือเติมซ้ำละครับ
บันทึกการเข้า

SSpeed
Newbie
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 39



ดูรายละเอียด
« ตอบ #26 เมื่อ: 09 มิถุนายน 2017, 06:43:42 »

โพสน้อย แต่ต่อยหนัก มากครับ
บันทึกการเข้า
xindy
Newbie
*

พลังน้ำใจ: 4
ออฟไลน์ ออฟไลน์

กระทู้: 11



ดูรายละเอียด
« ตอบ #27 เมื่อ: 09 มิถุนายน 2017, 10:00:23 »

อัพเดทใหม่ล่าสุดน่าจะดีขึ้นเยอะแล้วครับ

ระบบตัดบัตร TrueMoney เข้า TrueWallet เลยไม่ผ่านตัวกลางของใครทั้งนั้นเข้าตรงกระเป๋าเลยครับ

Update Code 9/6/2560
โค๊ด:
class TrueWallet{
public  $username;
public  $password;
private $passhash;
//Config TrueWallet ห้ามแก้ไขหากไม่รู้ค่าที่แท้จริง
private $login_type = "email";
private $api_signin = "https://api-ewm.truemoney.com/api/v1/signin?&";
private $api_profile = "https://api-ewm.truemoney.com/api/v1/profile/";
private $api_topup = "https://api-ewm.truemoney.com/api/api/v1/topup/mobile/";
private $device_os = "android";
private $device_id = "d520d0d12d0d48cb89394905168c6ed5";
private $device_type = "CPH1611";
private $device_version = "6.0.1";
private $app_name = "wallet";
private $app_version = "2.9.14";
private $deviceToken = "fUUbZJ9nwBk:APA91bHHgBBHhP9rqBEon_BtUNz3rLHQ-sYXnezA10PRSWQTwFpMvC9QiFzh-CqPsbWEd6x409ATC5RVsHAfk_-14cSqVdGzhn8iX2K_DiNHvpYfMMIzvFx_YWpYj5OaEzMyIPh3mgtx";
private $mobileTracking = "dJyFzn\/GIq7lrjv2RCsZbphpp0L\/W2+PsOTtOpg352mgWrt4XAEAAA==";
//End Config

public function __construct($user,$pass) {
$this->username = $user;
$this->password = $pass;
$this->passhash = sha1($user.$pass);
}

public function GetToken(){
$url = $this->api_signin.'device_os='.$this->device_os.'&device_id='.$this->device_id.'&device_type='.$this->device_type.'&device_version='.$this->device_version.'&app_name='.$this->app_name.'&app_version='.$this->app_version;
$header = array(
"Host: api-ewm.truemoney.com",
"Content-Type: application/json"
);
$postfield = array(
"username"=>$this->username,
"password"=>$this->passhash,
"type"=>$this->login_type,
"deviceToken"=>$this->deviceToken,
"mobileTracking"=>$this->mobileTracking,
);
$data_string = json_encode($postfield);

return $this->wallet_curl($url,$data_string,$header);
}

public function Profile($token){
$url = $this->api_profile.$token.'?&device_os=android&device_id='.$this->device_id.'&device_type='.$this->device_type.'&device_version='.$this->device_version.'&app_name='.$this->app_name.'&app_version='.$this->app_version;
$header = array("Host: api-ewm.truemoney.com");
return $this->wallet_curl($url,false,$header);

}

public function Topup($cashcard,$token){
$url = $this->api_topup.time()."/".$token."/cashcard/".$cashcard;
$header = array("Host: api-ewm.truemoney.com");
return $this->wallet_curl($url,true,$header);
}

private function wallet_curl($url,$data,$header){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); 
if($data){
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch,CURLOPT_POSTFIELDS, $data);         
}                                 
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);   
curl_setopt($ch,CURLOPT_USERAGENT,'');
$result = curl_exec($ch);
return $result;
}
}
โค๊ด:
$wallet = new TrueWallet('YOUR EMAIL','YOUR PASSWORD');
$token = json_decode($wallet->GetToken(),true)['data']['accessToken'];
$profile = $wallet->Profile($token);
$topup = $wallet->Topup('เลขบบัตรทรูมั่นนี่',$token);
Download https://github.com/exzajung/class.truewallet.php
ทดสอบได้ที่ https://www.xindy.in/truewallet
เข้าตรวจสอบผ่านเว็บ https://wallet.truemoney.com/ หรือจะเช็คที่แอพก็ได้นะครับ
บันทึกการเข้า
AbuseMan
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 104
ออฟไลน์ ออฟไลน์

กระทู้: 1,104



ดูรายละเอียด เว็บไซต์
« ตอบ #28 เมื่อ: 09 มิถุนายน 2017, 10:08:39 »

deviceToken / mobileTracking ใช้ sniff ค่าเอาหรอครับ?
บันทึกการเข้า

ฟังเพลงออนไลน์ : เว็บเพลงออนไลน์ที่คุณขอฟังเพลงได้ด้วยตัวคุณเอง
ห้องแชท : บริการฟรีห้องแชทสำหรับติดเว็บ
เพลงใหม่ : เพลงใหม่ เพลงฮิต
บ้านคุ้มค่า : ลงประกาศขายบ้าน ที่ดิน พร้อมอัพเดทโครงการบ้านและคอนโดใหม่ที่น่าสนใจ
xindy
Newbie
*

พลังน้ำใจ: 4
ออฟไลน์ ออฟไลน์

กระทู้: 11



ดูรายละเอียด
« ตอบ #29 เมื่อ: 09 มิถุนายน 2017, 10:10:45 »

ครับ
deviceToken / mobileTracking ใช้ sniff ค่าเอาหรอครับ?
บันทึกการเข้า
gemble40
ก๊วนเสียว
*

พลังน้ำใจ: 14
ออฟไลน์ ออฟไลน์

กระทู้: 405



ดูรายละเอียด
« ตอบ #30 เมื่อ: 09 มิถุนายน 2017, 11:35:56 »

เยี่ยมจริงๆ เยี่ยมจริงๆ
บันทึกการเข้า
neverdiexxl
Newbie
*

พลังน้ำใจ: 1
ออฟไลน์ ออฟไลน์

กระทู้: 20



ดูรายละเอียด
« ตอบ #31 เมื่อ: 09 มิถุนายน 2017, 14:56:06 »

Config TrueWallet โค๊ดส่วนตรงนี้ไปเอามาจากไหนเหรอครับ
แล้วมันใช้ได้ตลอดหรือเปล่าครับ
บันทึกการเข้า
thaisew
ก๊วนเสียว
*

พลังน้ำใจ: 19
ออฟไลน์ ออฟไลน์

กระทู้: 274



ดูรายละเอียด
« ตอบ #32 เมื่อ: 09 มิถุนายน 2017, 21:19:10 »

แจ่มครับ   Kiss
บันทึกการเข้า
lnwnuyhod
คนรักเสียว
*

พลังน้ำใจ: 7
ออฟไลน์ ออฟไลน์

กระทู้: 123



ดูรายละเอียด เว็บไซต์
« ตอบ #33 เมื่อ: 09 มิถุนายน 2017, 22:24:31 »

ขออนุญาตคุณ xindy ยืมหน้าเว็บนะครับ
อันนี้เป็นระบบให้ยูเซอร์เติมเงิน สำหรับ mysql เผื่อใครเขียนไม่ค่อยเก่ง ผมก็ยังเขียนไม่เก่ง เอามาแบ่งๆกัน
แก้จากของคุณ xindy นิดหน่อย
แก้ไข config ที่ class.truewallet.php

index.php
โค๊ด:
<?php
@session_start();
if(!isset(
$_SESSION['uid']))
$_SESSION['uid'] = '';
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Test API TrueWallet</title>

    <!-- Bootstrap -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Kanit" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
<script type="text/javascript">
function isNumberKey(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
}
</script>
  </head>
  <style>
html,body {
 padding: 0px;
 margin-top:25px;
 width: 100%;
 height: 100%;
}
body {
 font-family: 'Kanit', sans-serif;
 font-size: 14px;
 background: #1c1e21;
 color:  #878383 ;
 position: relative;
}
.form-signin {
  max-width: 330px;
  padding: 15px;
  margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
  margin-bottom: 10px;
}
.form-signin .checkbox {
  font-weight: normal;
}
.form-signin .form-control {
  position: relative;
  height: auto;
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
  padding: 10px;
  font-size: 16px;
}
.form-signin .form-control:focus {
  z-index: 2;
}
.form-signin input[type="email"] {
  margin-bottom: -1px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
  margin-bottom: 10px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.error_code {
    color: #F00;
    font-size: 15px;
    font-width: bold;
    margin-left: 15px;
    line-height: 16px;
    margin-bottom: 4px;
    height: 16px;
    text-align: center;
}
  </style>
  <body style="background: url(bg.png);">
<div class="container free_tck">
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">TrueWallet ( Test API )</div>
<div class="panel-body">
<?php
if($_SESSION['uid'] == '')
{
?>

  <form role="form" method="post" class="col-md-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">User</div>
<input type="text" id="user" name="user" class="form-control" placeholder="UserName" required autocomplete="off">
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">Pass</div>
<input type="password" id="pass" name="pass" class="form-control" placeholder="Password" required autocomplete="off">
</div>
</div>
<button class="btn btn-lg btn-primary btn-block free_btn" name="login" type="submit">เข้าสู่ระบบ</button>
</form>
<?php
if(!isset($_POST['login']))
$_POST['login'] = '';
else
{
include("class.truewallet.php");
$wallet = new TrueWallet();
$wallet->Connect();
if(!$wallet->Login($_POST['user'],$_POST['pass'],false))
echo "cant login";
else
{
$_SESSION['uid'] = $_POST['user'];
header("Location: ./");
}
}
}
else if($_SESSION['uid'] <> '')
{
?>

<form role="form" method="post" class="col-md-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">True Money</div>
<input type="text" id="number" name="number" class="form-control" placeholder="รหัสบัตรทรูมันนี่" onkeypress="return isNumberKey(event)" maxlength=14 required autocomplete="off">
</div>
</div>
<button class="btn btn-lg btn-primary btn-block free_btn" name="topup" type="submit">เติมเงิน</button>
</form>

<form role="form" method="post" class="col-md-12">
<p></p>
<button class="btn btn-lg btn-primary btn-block free_btn" name="logout" type="submit">ออกจากระบบ</button>
</form>
<?php
if(!isset($_POST['topup']))
$_POST['topup'] = '';
else
{
include("class.truewallet.php");
$wallet = new TrueWallet();
$wallet->Connect();
$a $wallet->Topup($_SESSION['uid'],$_POST['number']);
print_r($a);
}
if(!isset($_POST['logout']))
$_POST['logout'] = '';
else
{
@session_destroy();
header("Location: ./");
}
}
?>

</div>
</div>
</div>
</div>
    </div> <!-- /container -->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </body>
</html>

class.truewallet.php
โค๊ด:
<?php
class TrueWallet{
//mysql
private $DbHost  ''; //ไอพี sql
private $DbUser  ''; //ไอดี sql
private $DbPass  ''; //รหัส sql
private $DbName  ''; //ชื่อฐานข้อมูล
private $DbPort  ''; //พอร์ต sql
private $tbName  ''; //ชื่อตารางที่เก็บข้อมูลยูเซอร์
private $fdID  ''; //ฟิลด์ไอดี
private $fdPS  ''; //ฟิลด์พาสเวิร์ด
private $fdCS ''; //ฟิลด์พ้อย
private $DbQuery;

//True Money
private $trueID  ''; //อีเมลสำหรับล็อคอินทรูวอเล็ต
private $truePS ''; //พาสเวิร์ดสำหรับล็อคอินทรูวอเล็ต
private $passhash;

//Config TrueWallet ห้ามแก้ไขหากไม่รู้ค่าที่แท้จริง
private $login_type "email"
private $api_signin "https://api-ewm.truemoney.com/api/v1/signin?&"
private $api_profile "https://api-ewm.truemoney.com/api/v1/profile/"
private $api_topup "https://api-ewm.truemoney.com/api/api/v1/topup/mobile/"
private $device_os "android"
private $device_id "d520d0d12d0d48cb89394905168c6ed5"
private $device_type "CPH1611"
private $device_version "6.0.1"
private $app_name "wallet"
private $app_version "2.9.14"
private $deviceToken "fUUbZJ9nwBk:APA91bHHgBBHhP9rqBEon_BtUNz3rLHQ-sYXnezA10PRSWQTwFpMvC9QiFzh-CqPsbWEd6x409ATC5RVsHAfk_-14cSqVdGzhn8iX2K_DiNHvpYfMMIzvFx_YWpYj5OaEzMyIPh3mgtx"
private $mobileTracking "dJyFzn/GIq7lrjv2RCsZbphpp0L/W2 PsOTtOpg352mgWrt4XAEAAA=="
private $walletToken '';
//End Config

//พ้อยที่จะได้รับ ตามราคาบัตร
private $point1  = 50;
private $point2  = 90;
private $point3  = 150;
private $point4  = 300;
private $point5  = 500;
private $point6  = 1000;
//

public function __construct() {
$this->passhash sha1($this->trueID.$this->truePS);
}

private function GetToken(){
$url $this->api_signin.'device_os='.$this->device_os.'&device_id='.$this->device_id.'&device_type='.$this->device_type.'&device_version='.$this->device_version.'&app_name='.$this->app_name.'&app_version='.$this->app_version;
$header = array(
"Host: api-ewm.truemoney.com",
"Content-Type: application/json"
);
$postfield = array(
"username"=>$this->trueID,
"password"=>$this->passhash,
"type"=>$this->login_type,
"deviceToken"=>$this->deviceToken,
"mobileTracking"=>$this->mobileTracking,
);
return $this->wallet_curl($url,json_encode($postfield),$header);
}

public function Profile(){
$url $this->api_profile.$this->walletToken.'?&device_os=android&device_id='.$this->device_id.'&device_type='.$this->device_type.'&device_version='.$this->device_version.'&app_name='.$this->app_name.'&app_version='.$this->app_version;
$header = array("Host: api-ewm.truemoney.com");
return $this->wallet_curl($url,false,$header);
}

/*
*/
private function wallet_curl($url,$data,$header){
$ch curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);  
if($data){
curl_setopt($ch,CURLOPT_CUSTOMREQUEST"POST");                                                                     
curl_setopt($ch,CURLOPT_POSTFIELDS$data);         
}                                  
curl_setopt($ch,CURLOPT_RETURNTRANSFERtrue);   
curl_setopt($ch,CURLOPT_USERAGENT,'');
$result curl_exec($ch);
return json_decode($result,true);
}

/*
@param1 $user = ไอดีที่จะเติม
@param2 $card = เลขบัตรทรูมันนี่

return code -9999 = ยูเซอร์ที่จะเติมว่างเปล่า หรือ เลขบัตรว่างเปล่า หรือ เลขบัตรไม่ใช่ตัวเลข หรือ เลขบัตรน้อยกว่า 14 หลัก
return code -1001 = บัตรใช้ไปแล้ว หรือ มีในฐานข้อมูลแล้ว
return code -1002 = เติมผิด หรือ บัตรมั่ว
return code 20000 = เติมสำเร็จ
*/

public function Topup($user,$card){
//เช็คไอดีและบัตร
if($user == '' || $card == '' || !is_numeric($card) || strlen($card) < 14)
{
return -9999;
}
//เช็คเลขบัตรซ้ำ
if(!$this->CheckCard($card))
{
return -1001;
}
//
$token $this->GetToken();
$url $this->api_topup.time()."/".$token['data']['accessToken']."/cashcard/".$card;
$header = array("Host: api-ewm.truemoney.com");
$topup $this->wallet_curl($url,true,$header);

if($topup['code'] < 0){ //-1001 = บัตรใช้ไปแล้ว  // -1002 = บัตรผิด หรือ บัตรมั่ว
$amount 0;
$status $topup['code'];
}else if($topup['transactionId'] <> ''){ //เติมเงินสำเร็จ
$amount $topup['amount'];
$status 20000;
}
if(!$this->InsertCard($user$card$amount$status)){
//หาก insert ไม่ได้ให้สร้าง error log
$update "INSERT INTO truemoney (card, uid, uip, amount, status, time) VALUES ('$card', '$user', '".$this->GetUserIP()."', $amount$status, '".$this->GetTime()."')";
$this->LogError("Error : " .$update);
$this->LogError("Card : " $card);
$this->LogError("User : " $user);
$this->LogError("IP : " $this->GetUserIP());
$this->LogError("Amount : " $amount);
$this->LogError("Status : " $status);
$this->LogError("Time : " $this->GetTime());
$this->LogError("=============================================================");
}
if($amount && !$this->Update($this->tbName$this->fdCS$this->GetPoint($amount), $user)){
//หาก update ไม่ได้ให้สร้าง error log
$update "UPDATE $this->tbName SET $this->fdCS = $this->fdCS   $this->GetPoint($amount) WHERE $this->fdID = '$user'";
$this->LogError("Error : " $update);
$this->LogError("User : " $user);
$this->LogError("Amount : " $this->GetPoint($amount));
$this->LogError("Time : " $this->GetTime());
$this->LogError("=============================================================");
}
return $status;
}

/**/
public function Connect(){
$this->DbQuery = new mysqli($this->DbHost$this->DbUser$this->DbPass$this->DbName$this->DbPort);
if ($this->DbQuery->connect_errno
{
printf("Connect failed: %s
"
$this->DbQuery->connect_error);
exit();
}
$this->DbQuery->query("SET NAMES UTF8");
}

/**/
public function Close(){
$this->DbQuery->close();
}

/*
@param1 $user = ไอดี 
@param2 $card = หมายเลขบัตรทรูมันนี่
@param3 $amount = ราคาบัตร
@param4 $status = สถานะ
*/
private function InsertCard($user$card$amount$status){
$query "INSERT INTO truemoney (card, uid, uip, amount, status, time) VALUES ('$card', '$user', '".$this->GetUserIP()."', $amount$status, '".$this->GetTime()."')";
if(!mysqli_query($this->DbQuery$query))
{
return false;
}
return true;
}

/*
@param1 $table = ชื่อตารางของฐานข้อมูล
@param2 $column = ชื่อคอลั่มน์ของฐานข้อมูล 
@param3 $value = ค่าที่จะอัพเดท ตัวอย่าง หากต้องการลบให้ใส่ -5 / หากต้องการบวกให้ใส่ 5
@param4 $where = จะให้อัพเดทที่ไอดีไหน/ตรงไหน
*/
private function Update($table$field$value$where){
$query = ("UPDATE $table SET $field = $field   $value WHERE $this->fdID = '$where'");
if(!mysqli_query($this->DbQuery$query))
{
return false;
}
return true;
}

/*
@param1 $user = ไอดี
@param2 $pass = พาส
@param3 $md5  = 0 ไม่ใช้ md5 / 1 ใช้ md5
ตัวอย่าง ไม่ใช้ MD5 = LogIn('testID', 'testPS', 0);
ตัวอย่าง ใช้ MD5 = LogIn('testID', 'testPS', 1);
*/
public function Login($user$pass$md5){
$pass $md5 md5($pass) : $pass;
$query "SELECT * FROM $this->tbName where $this->fdID = '$user' and $this->fdPS = '$pass'";
if(!mysqli_query($this->DbQuery$query))
return false;

$result $this->DbQuery->query($query);
if ($result->num_rows <= 0)
return false;

return true;
}

/*
@param1 $card = เลขบัตรทรูมันนี่
*/
private function CheckCard($card){
$result $this->DbQuery->query("SELECT card FROM truemoney WHERE card = '$card'");
if ($result->num_rows 0)
return false;
return true;
}

private function GetPoint($amount){
if($amount == 50)
return $this->point1;
else if($amount == 90)
return $this->point2;
else if($amount == 150)
return $this->point3;
else if($amount == 300)
return $this->point4;
else if($amount == 500)
return $this->point5;
else if($amount == 1000)
return $this->point6;
return 0;
}

private function GetUserIP()
{
$client  = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote  = @$_SERVER['REMOTE_ADDR'];
if(filter_var($clientFILTER_VALIDATE_IP))
$ip $client;
elseif(filter_var($forwardFILTER_VALIDATE_IP))
$ip $forward;
else
$ip $remote;
return $ip;
}

private function GetTime()
{
return date("Y-m-d H:i:s");
}

/*
@param1 $str = log text
*/
private function LogError($str){
if (!file_exists('log')) {
@mkdir('log'0777true);
@file_put_contents('log/index.html''');
}
$now1 date("Y-m-d");
$now2 date("Y-m-d H:i:s");
$file 'log/log_'.$now1.'.txt';
$current = @file_get_contents($file);
$current .= '['.$now2.'] '.$str."
"
;
@file_put_contents($file$current);
}
}
?>


truemoney.sql
โค๊ด:
DROP TABLE IF EXISTS `truemoney`;
CREATE TABLE `truemoney` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `card` varchar(14) COLLATE utf8_unicode_ci NOT NULL,
  `uid` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `uip` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `amount` int(4) NOT NULL DEFAULT '0',
  `status` int(11) NOT NULL,
  `time` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
« แก้ไขครั้งสุดท้าย: 15 มิถุนายน 2017, 06:25:51 โดย lnwnuyhod » บันทึกการเข้า

darkonwrite
ก๊วนเสียว
*

พลังน้ำใจ: 13
ออฟไลน์ ออฟไลน์

กระทู้: 305



ดูรายละเอียด
« ตอบ #34 เมื่อ: 11 มิถุนายน 2017, 00:48:26 »

จัดไปครับ
บันทึกการเข้า
SSpeed
Newbie
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 39



ดูรายละเอียด
« ตอบ #35 เมื่อ: 11 มิถุนายน 2017, 15:32:55 »

เวบรับตัดบัตร หลายค่ายลดราคา เหลือ 14%-14.4% กันหมด
ต้อนรับ api ที่ท่านๆ เอามาแจก
บันทึกการเข้า
SaveYourLife
Newbie
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 2



ดูรายละเอียด
« ตอบ #36 เมื่อ: 14 มิถุนายน 2017, 16:48:42 »


แหล่มเลย true money มี API ด้วยหรอเนี้ย
บันทึกการเข้า
ANALOGY
สมุนแก๊งเสียว
*

พลังน้ำใจ: 83
ออฟไลน์ ออฟไลน์

กระทู้: 750



ดูรายละเอียด เว็บไซต์
« ตอบ #37 เมื่อ: 14 มิถุนายน 2017, 17:21:59 »

ขออนุญาตคุณ xindy ยืมหน้าเว็บนะครับ
อันนี้เป็นระบบให้ยูเซอร์เติมเงิน สำหรับ mysql เผื่อใครเขียนไม่ค่อยเก่ง ผมก็ยังเขียนไม่เก่ง เอามาแบ่งๆกัน
แก้จากของคุณ xindy นิดหน่อย
แก้ไข config ที่ class.truewallet.php

index.php
โค๊ด:
<?php
@session_start();
if(!isset(
$_SESSION['uid']))
$_SESSION['uid'] = '';
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Test API TrueWallet</title>

    <!-- Bootstrap -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Kanit" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
<script type="text/javascript">
function isNumberKey(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
}
</script>
  </head>
  <style>
html,body {
 padding: 0px;
 margin-top:25px;
 width: 100%;
 height: 100%;
}
body {
 font-family: 'Kanit', sans-serif;
 font-size: 14px;
 background: #1c1e21;
 color:  #878383 ;
 position: relative;
}
.form-signin {
  max-width: 330px;
  padding: 15px;
  margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
  margin-bottom: 10px;
}
.form-signin .checkbox {
  font-weight: normal;
}
.form-signin .form-control {
  position: relative;
  height: auto;
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
  padding: 10px;
  font-size: 16px;
}
.form-signin .form-control:focus {
  z-index: 2;
}
.form-signin input[type="email"] {
  margin-bottom: -1px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
  margin-bottom: 10px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.error_code {
    color: #F00;
    font-size: 15px;
    font-width: bold;
    margin-left: 15px;
    line-height: 16px;
    margin-bottom: 4px;
    height: 16px;
    text-align: center;
}
  </style>
  <body style="background: url(bg.png);">
<div class="container free_tck">
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">TrueWallet ( Test API )</div>
<div class="panel-body">
<?php
if($_SESSION['uid'] == '')
{
?>

  <form role="form" method="post" class="col-md-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">User</div>
<input type="text" id="user" name="user" class="form-control" placeholder="UserName" required autocomplete="off">
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">Pass</div>
<input type="password" id="pass" name="pass" class="form-control" placeholder="Password" required autocomplete="off">
</div>
</div>
<button class="btn btn-lg btn-primary btn-block free_btn" name="login" type="submit">เข้าสู่ระบบ</button>
</form>
<?php
if(!isset($_POST['login']))
$_POST['login'] = '';
else
{
include("class.truewallet.php");
$wallet = new TrueWallet();
$wallet->Connect();
if(!$wallet->Login($_POST['user'],$_POST['pass'],false))
echo "cant login";
else
{
$_SESSION['uid'] = $_POST['user'];
header("Location: ./");
}
}
}
else if($_SESSION['uid'] <> '')
{
?>

<form role="form" method="post" class="col-md-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">True Money</div>
<input type="text" id="number" name="number" class="form-control" placeholder="รหัสบัตรทรูมันนี่" onkeypress="return isNumberKey(event)" maxlength=14 required autocomplete="off">
</div>
</div>
<button class="btn btn-lg btn-primary btn-block free_btn" name="topup" type="submit">เติมเงิน</button>
</form>

<form role="form" method="post" class="col-md-12">
<p></p>
<button class="btn btn-lg btn-primary btn-block free_btn" name="logout" type="submit">ออกจากระบบ</button>
</form>
<?php
if(!isset($_POST['topup']))
$_POST['topup'] = '';
else
{
include("class.truewallet.php");
$wallet = new TrueWallet();
$wallet->Connect();
$a $wallet->Topup($_SESSION['uid'],$_POST['number']);
print_r($a);
}
if(!isset($_POST['logout']))
$_POST['logout'] = '';
else
{
@session_destroy();
header("Location: ./");
}
}
?>

</div>
</div>
</div>
</div>
    </div> <!-- /container -->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </body>
</html>

class.truewallet.php
โค๊ด:
<?php
class TrueWallet{
//mysql
private $DbHost  ''; //ไอพี sql
private $DbUser  ''; //ไอดี sql
private $DbPass  ''; //รหัส sql
private $DbName  ''; //ชื่อฐานข้อมูล
private $DbPort  ''; //พอร์ต sql
private $tbName  ''; //ชื่อตารางที่เก็บข้อมูลยูเซอร์
private $fdID  ''; //ฟิลด์ไอดี
private $fdPS  ''; //ฟิลด์พาสเวิร์ด
private $fdCS ''; //ฟิลด์พ้อย
private $DbQuery;

//True Money
private $trueID  ''; //อีเมลสำหรับล็อคอินทรูวอเล็ต
private $truePS ''; //พาสเวิร์ดสำหรับล็อคอินทรูวอเล็ต
private $passhash;

//Config TrueWallet ห้ามแก้ไขหากไม่รู้ค่าที่แท้จริง
private $login_type "email"
private $api_signin "https://api-ewm.truemoney.com/api/v1/signin?&"
private $api_profile "https://api-ewm.truemoney.com/api/v1/profile/"
private $api_topup "https://api-ewm.truemoney.com/api/api/v1/topup/mobile/"
private $device_os "android"
private $device_id "d520d0d12d0d48cb89394905168c6ed5"
private $device_type "CPH1611"
private $device_version "6.0.1"
private $app_name "wallet"
private $app_version "2.9.14"
private $deviceToken "fUUbZJ9nwBk:APA91bHHgBBHhP9rqBEon_BtUNz3rLHQ-sYXnezA10PRSWQTwFpMvC9QiFzh-CqPsbWEd6x409ATC5RVsHAfk_-14cSqVdGzhn8iX2K_DiNHvpYfMMIzvFx_YWpYj5OaEzMyIPh3mgtx"
private $mobileTracking "dJyFzn/GIq7lrjv2RCsZbphpp0L/W2 PsOTtOpg352mgWrt4XAEAAA=="
private $walletToken '';
//End Config

//พ้อยที่จะได้รับ ตามราคาบัตร
private $point1  = 50;
private $point2  = 90;
private $point3  = 150;
private $point4  = 300;
private $point5  = 500;
private $point6  = 1000;
//

public function __construct() {
$this->passhash sha1($this->trueID.$this->truePS);
}

private function GetToken(){
$url $this->api_signin.'device_os='.$this->device_os.'&device_id='.$this->device_id.'&device_type='.$this->device_type.'&device_version='.$this->device_version.'&app_name='.$this->app_name.'&app_version='.$this->app_version;
$header = array(
"Host: api-ewm.truemoney.com",
"Content-Type: application/json"
);
$postfield = array(
"username"=>$this->trueID,
"password"=>$this->passhash,
"type"=>$this->login_type,
"deviceToken"=>$this->deviceToken,
"mobileTracking"=>$this->mobileTracking,
);
return $this->wallet_curl($url,json_encode($postfield),$header);
}

public function Profile(){
$url $this->api_profile.$this->walletToken.'?&device_os=android&device_id='.$this->device_id.'&device_type='.$this->device_type.'&device_version='.$this->device_version.'&app_name='.$this->app_name.'&app_version='.$this->app_version;
$header = array("Host: api-ewm.truemoney.com");
return $this->wallet_curl($url,false,$header);
}

/*
*/
private function wallet_curl($url,$data,$header){
$ch curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);  
if($data){
curl_setopt($ch,CURLOPT_CUSTOMREQUEST"POST");                                                                     
curl_setopt($ch,CURLOPT_POSTFIELDS$data);         
}                                  
curl_setopt($ch,CURLOPT_RETURNTRANSFERtrue);   
curl_setopt($ch,CURLOPT_USERAGENT,'');
$result curl_exec($ch);
return json_decode($result,true);
}

/*
@param1 $user = ไอดีที่จะเติม
@param2 $card = เลขบัตรทรูมันนี่

return code -9999 = ยูเซอร์ที่จะเติมว่างเปล่า หรือ เลขบัตรว่างเปล่า หรือ เลขบัตรไม่ใช่ตัวเลข หรือ เลขบัตรน้อยกว่า 14 หลัก
return code -1001 = บัตรใช้ไปแล้ว หรือ มีในฐานข้อมูลแล้ว
return code -1002 = เติมผิด หรือ บัตรมั่ว
return code 20000 = เติมสำเร็จ
*/

public function Topup($user,$card){
//เช็คไอดีและบัตร
if($user == '' || $card == '' || !is_numeric($card) || strlen($card) < 14)
{
return -9999;
}
//เช็คเลขบัตรซ้ำ
if(!$this->CheckCard($card))
{
return -1001;
}
//
$token $this->GetToken();
$url $this->api_topup.time()."/".$token['data']['accessToken']."/cashcard/".$card;
$header = array("Host: api-ewm.truemoney.com");
$topup $this->wallet_curl($url,true,$header);

if($topup['code'] < 0){ //-1001 = บัตรใช้ไปแล้ว  // -1002 = บัตรผิด หรือ บัตรมั่ว
$amount 0;
$status $topup['code'];
}else if($topup['transactionId'] <> ''){ //เติมเงินสำเร็จ
$amount $topup['amount'];
$status 20000;
}
if(!$this->InsertCard($user$card$amount$status)){
//หาก insert ไม่ได้ให้สร้าง error log
$update "INSERT INTO truemoney (card, uid, uip, amount, status, time) VALUES ('$card', '$user', '".$this->GetUserIP()."', $amount$status, '".$this->GetTime()."')";
$this->LogError("Error : " .$update);
$this->LogError("Card : " $card);
$this->LogError("User : " $user);
$this->LogError("IP : " $this->GetUserIP());
$this->LogError("Amount : " $amount);
$this->LogError("Status : " $status);
$this->LogError("Time : " $this->GetTime());
$this->LogError("=============================================================");
}
if($amount && !$this->Update($this->tbName$this->fdCS$this->GetPoint($amount), $user)){
//หาก update ไม่ได้ให้สร้าง error log
$update "UPDATE $this->tbName SET $this->fdCS = $this->fdCS   $this->GetPoint($amount) WHERE $this->fdID = '$user'";
$this->LogError("Error : " $update);
$this->LogError("User : " $user);
$this->LogError("Amount : " $this->GetPoint($amount));
$this->LogError("Time : " $this->GetTime());
$this->LogError("=============================================================");
}
return $status;
}

/**/
public function Connect(){
$this->DbQuery = new mysqli($this->DbHost$this->DbUser$this->DbPass$this->DbName$this->DbPort);
if ($this->DbQuery->connect_errno
{
printf("Connect failed: %s
"
$this->DbQuery->connect_error);
exit();
}
$this->DbQuery->query("SET NAMES UTF8");
}

/**/
public function Close(){
$this->DbQuery->close();
}

/*
@param1 $user = ไอดี 
@param2 $card = หมายเลขบัตรทรูมันนี่
@param3 $amount = ราคาบัตร
@param4 $status = สถานะ
*/
private function InsertCard($user$card$amount$status){
$query "INSERT INTO truemoney (card, uid, uip, amount, status, time) VALUES ('$card', '$user', '".$this->GetUserIP()."', $amount$status, '".$this->GetTime()."')";
if(!mysqli_query($this->DbQuery$query))
{
return false;
}
return true;
}

/*
@param1 $table = ชื่อตารางของฐานข้อมูล
@param2 $column = ชื่อคอลั่มน์ของฐานข้อมูล 
@param3 $value = ค่าที่จะอัพเดท ตัวอย่าง หากต้องการลบให้ใส่ -5 / หากต้องการบวกให้ใส่ 5
@param4 $where = จะให้อัพเดทที่ไอดีไหน/ตรงไหน
*/
private function Update($table$field$value$where){
$query = ("UPDATE $table SET $field = $field   $value WHERE $this->fdID = '$where'");
if(!mysqli_query($this->DbQuery$query))
{
return false;
}
return true;
}

/*
@param1 $user = ไอดี
@param2 $pass = พาส
@param3 $md5  = 0 ไม่ใช้ md5 / 1 ใช้ md5
ตัวอย่าง ไม่ใช้ MD5 = LogIn('testID', 'testPS', 0);
ตัวอย่าง ใช้ MD5 = LogIn('testID', 'testPS', 1);
*/
public function Login($user$pass$md5){
$pass $md5 md5($pass) : $pass;
$query "SELECT * FROM $this->tbName where $this->fdID = '$user' and $this->fdPS = '$pass'";
if(!mysqli_query($this->DbQuery$query))
return false;

$result $this->DbQuery->query($query);
if ($result->num_rows <= 0)
return false;

return true;
}

/*
@param1 $card = เลขบัตรทรูมันนี่
*/
private function CheckCard($card){
$result $this->DbQuery->query("SELECT card FROM truemoney WHERE card = '$card'");
if ($result->num_rows 0)
return false;
return true;
}

private function GetPoint($amount){
if($amount == 50)
return $this->point1;
else if($amount == 90)
return $this->point2;
else if($amount == 150)
return $this->point3;
else if($amount == 300)
return $this->point4;
else if($amount == 500)
return $this->point5;
else if($amount == 1000)
return $this->point6;
return 0;
}

private function GetUserIP()
{
$client  = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote  = @$_SERVER['REMOTE_ADDR'];
if(filter_var($clientFILTER_VALIDATE_IP))
$ip $client;
elseif(filter_var($forwardFILTER_VALIDATE_IP))
$ip $forward;
else
$ip $remote;
return $ip;
}

private function GetTime()
{
return date("Y-m-d H:i:s");
}

/*
@param1 $str = log text
*/
private function LogError($str){
if (!file_exists('log')) {
@mkdir('log'0777true);
@file_put_contents('log/index.html''');
}
$now1 date("Y-m-d");
$now2 date("Y-m-d H:i:s");
$file 'log/log_'.$now1.'.txt';
$current = @file_get_contents($file);
$current .= '['.$now2.'] '.$str."
"
;
@file_put_contents($file$current);
}
}
?>


truemoney.sql
โค๊ด:
DROP TABLE IF EXISTS `truemoney`;
CREATE TABLE `truemoney` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `card` varchar(14) COLLATE utf8_unicode_ci NOT NULL,
  `uid` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `uip` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `amount` int(4) NOT NULL DEFAULT '0',
  `status` int(11) NOT NULL,
  `time` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

wanwan017 ขอบคุณอีกครั้งคับ
บันทึกการเข้า

kanesz12
สมุนแก๊งเสียว
*

พลังน้ำใจ: 16
ออฟไลน์ ออฟไลน์

กระทู้: 762



ดูรายละเอียด เว็บไซต์
« ตอบ #38 เมื่อ: 14 มิถุนายน 2017, 17:26:44 »

แจ่มแมวแวววับ!! wanwan017
บันทึกการเข้า

buakaew
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 41
ออฟไลน์ ออฟไลน์

กระทู้: 1,365



ดูรายละเอียด เว็บไซต์
« ตอบ #39 เมื่อ: 14 มิถุนายน 2017, 17:32:19 »

เยี่ยมเลย  wanwan017
บันทึกการเข้า

Affiliate ไทยจ่ายจริงกินหลายชั้นลึกหลากหลายผลิตภัณฑ์Affiliate ไทย
รีวิว คูปองฟรี Hosting ไทยและเทศรีวิว Hosting
ดูดวงออนไลน์ฟรีดูดวง
พระเครื่องออนไลน์พระเครื่อง

หน้า: 1 [2] 3   ขึ้นบน
พิมพ์