-
Notifications
You must be signed in to change notification settings - Fork 0
/
genbill_platform_validate.php
64 lines (60 loc) · 1.84 KB
/
genbill_platform_validate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
include('useful.php');
include('strings.php');
session_start();
if(!isset($_SESSION['user'])) exit();
$user = $_SESSION['user'];
if(!(isset($_POST['value']) && isset($_POST['bill']))) exit();
$val = $_POST['value'];
$name = removeAcentos($_POST['name']);
$billraw = $_POST['bill'];
$bill = json_decode($billraw);
$valf = floatval(str_replace(',', '.', $val));
if(!is_numeric($valf)) exit();
if($valf < 2) exit();
$ch = curl_init();
//Debug with proxy
//curl_setopt($ch, CURLOPT_PROXY, "http://20.20.0.1:8080");
//curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
//curl_setopt ($ch, CURLOPT_PROXYUSERPWD, "aluno:aluno");
//END Debug with proxy
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$produto = 1.0;
foreach ($bill as $index => $aposta) {
$bill[$index][1] = removeAcentos($bill[$index][1]);
curl_setopt($ch, CURLOPT_URL, "{$SITEAPI}/futebolapi/api/VJogoOdds/" . $aposta[5]);
$jsonstr = curl_exec($ch);
$seg = json_decode($jsonstr);
if($seg->taxa != $aposta[4]){
exit();
}
$produto *= floatval($aposta[4]);
}
$premio = $produto*$valf;
if($premio >= 500*$valf){
exit();
} else if($premio >= 5000){
exit();
}
$billraw = json_encode($bill);
curl_close($ch);
require('database_conect.php');
$datanow = date("YmdHis") . rand();
$has = sha1($datanow);
$dateSQL = date("Y-m-d H:i:s");
try {
$stm = $conn->prepare("INSERT INTO bills (user,matchjson,valor,apostador,hash, premio, data_criado) VALUES (:user, :json, :val, :name, :hash, :premio, :data)");
$stm->bindParam(':user', $user);
$stm->bindParam(':json', $billraw);
$stm->bindParam(':val', $valf);
$stm->bindParam(':name', $name);
$stm->bindParam(':hash', $has);
$stm->bindParam(':premio', $premio);
$stm->bindParam(':data', $dateSQL);
$stm->execute();
} catch(PDOException $e){
exit();
}
$result = array('state' => 'SUCCESS', 'hash' => $has, 'date' => date("d/n/Y H:i:s"));
echo json_encode($result);
?>