· 8 years ago · Jul 13, 2018, 11:46 AM
1<?php
2 require_once('./pieces/inc.php');
3
4/*
5 Automatically setup the database tables for use with this script by passing the setup option in the URL.
6 Ex: http://www.example.com/app/postback.php?setup=1
7
8*/
9define('DB_USER', 'ni628482_1_DB'); // Your database user.
10define('DB_PASSWORD', 'Hidden'); // Your database password.
11define('DB_HOST', 'ms674.gamedata.io'); // Your database host (usually 127.0.0.1).
12define('DB_HOST_PORT', '3306'); // Your database host port (usually 3306).
13define('DB_NAME', 'ni628482_1_DB'); // Your database name.
14define('DB_PREFIX', 'adscendmedia'); // OPTIONAL: A database table prefix, such as 'app1_'. This easily allows multiple apps to be served from the same database.
15error_reporting(E_WARNING);
16// *** No more configuration below this line. ***
17header('Content-Type:text/plain');
18// If &setup is passed in, setup tables needed to use this script.
19if(isset($_REQUEST['setup']))
20{
21 $query =
22 "CREATE TABLE IF NOT EXISTS `".DB_PREFIX."transactions` (
23 `userid` BIGINT,
24 `oid` int,
25 `pay` int,
26 `status` int,
27 `time` DATETIME,
28 PRIMARY KEY (`userid`))
29 CHARACTER SET utf8 COLLATE utf8_general_ci;
30 CREATE TABLE IF NOT EXISTS `".DB_PREFIX."users` (
31 `userid` BIGINT NOT NULL,
32 `time` DATETIME,
33 PRIMARY KEY (`userid`))
34 CHARACTER SET utf8 COLLATE utf8_general_ci;";
35 try
36 {
37 // Connect to Database.
38 $dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME.";port=".DB_HOST_PORT, DB_USER, DB_PASSWORD, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING ));
39 $query = $dbh->prepare($query);
40 if(!$query->execute())
41 echo "Could not create tables in database: ".DB_NAME." @ ".DB_HOST.'. Check your configuration above.';
42 else
43 echo "Tables setup successfully!";
44 $dbh = null;
45 }
46 catch (PDOException $e)
47 {
48 exit($e->getMessage());
49 }
50 exit();
51}
52$userid = $_REQUEST['[SB1]'];
53$oid = $_REQUEST['[OID]'];
54$name= $_REQUEST['[ONM]'];
55$paydollar = $_REQUEST['[CUR]'];
56$status = $_REQUEST['[STS]'];
57$ip = $_REQUEST['[IP]'];
58
59$timestamp = date("Y-m-d H:i:s", time());
60try
61 {
62
63
64 // Connect to Database.
65 $dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME.";port=".DB_HOST_PORT, DB_USER, DB_PASSWORD, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING ));
66 // Add new transaction
67 $query = $dbh->prepare("INSERT INTO ".DB_PREFIX."transactions(userid, oid, pay, status, time) VALUES (:userid,:oid,:pay,:status,:time) ON DUPLICATE KEY UPDATE userid=:userid,oid=:oid,pay=:pay,status=:status,time=:time");
68 $query->bindParam(':userid', $userid, PDO::PARAM_INT);
69 $query->bindParam(':oid', $oid, PDO::PARAM_INT);
70 $query->bindParam(':pay', $paydollar, PDO::PARAM_INT);
71 $query->bindParam(':status', $status, PDO::PARAM_INT);
72 $query->bindParam(':time', $timestamp, PDO::PARAM_STR);
73
74 if ($status=='1' || $status=='2') {
75 global $sql;
76
77 $sql->query("update users set anzahl = anzahl + $paydollar where steamid = $userid");
78
79 }
80
81 $query = $dbh->prepare("INSERT INTO ".DB_PREFIX."users(userid, time) VALUES (:userid,:time) ON DUPLICATE KEY UPDATE userid=:userid,time=:time");
82 $query->bindParam(':userid', $userid, PDO::PARAM_INT);
83 $query->bindParam(':time', $timestamp, PDO::PARAM_STR);
84
85
86 }
87 catch (PDOException $e)
88 {
89 exit($e->getMessage());
90 }
91
92?>