SuperRewards Pingback
#4


<?php

define('APP_SECRET', 'yoursecretkey'); // App Secret Key. Find it by going to the Apps page, select Edit on the App of your choice, then Integrate.
define('DB_USER', 'root'); // Your database user.
define('DB_PASSWORD', ''); // Your database password.
define('DB_HOST', 'localhost'); // Your database host (usually 127.0.0.1).
define('DB_HOST_PORT', '3306'); // Your database host port (usually 3306).
define('DB_NAME', 'newproject_db_auth'); // Your database name.
define('DB_NAME_SITE', 'website'); // Your database name.

error_reporting(E_WARNING);

// *** No more configuration below this line. ***

header('Content-Type:text/plain');

$id = $_REQUEST['id']; // ID of this transaction.
$uid = $_REQUEST['uid']; // ID of the user which performed this transaction.
$oid = $_REQUEST['oid']; // ID of the offer or direct payment method.
$new = $_REQUEST['new']; // Number of in-game currency your user has earned by completing this offer.
$total = $_REQUEST['total']; // Total number of in-game currency your user has earned on this App.
$sig = $_REQUEST['sig']; // Security hash used to verify the authenticity of the postback.

/**
* Sanity check.
*
* If you are using alphanumeric user ids, remove the is_numeric($uid) check. Alphanumeric
* ids can only be enabled by Super Rewards Support
*
* If you are using alphanumeric user ids, please ensure that you use the appropriate URL-encoding
* for non-text or unicode characters. For example: ~ should be encoded as %7E
*/
if(!(is_numeric($id) && is_numeric($uid) && is_numeric($oid) && is_numeric($new) && is_numeric($total)))
exit('0'); // Fail.

$result = 1;

$sig_compare = md5($id.':'.$new.':'.$uid.':'.APP_SECRET);

// Only accept if the Security Hash matches what we have.
if($sig == $sig_compare)
{
$timestamp = date("Y-m-d H:iConfused", time());

try
{
// Connect to Database.
$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 ));
$dbh5 = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME_SITE.";port=".DB_HOST_PORT, DB_USER, DB_PASSWORD, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING ));

// Add new transaction
$query = $dbh5->prepare("INSERT INTO t_donation_log SET a_account_index = :user, a_cash = :cash, a_transaction_id = :ref, a_type = :type, a_date = :today");
$query->bindParam(':ref', $id, PDO:TongueARAM_INT);
$query->bindParam(':user', $uid, PDO:TongueARAM_INT);
$query->bindParam(':type', $oid, PDO:TongueARAM_INT);
$query->bindParam(':cash', $new, PDO:TongueARAM_INT);
$query->bindParam(':today', $timestamp, PDO:TongueARAM_STR);
if(!$query->execute())
$result = 0; // Problems executing SQL. Fail.

// Add/Update user.
$query2 = $dbh->prepare("UPDATE bg_user SET cash = cash + :new WHERE user_code = :uid");
$query2->bindParam(':new', $new, PDO:TongueARAM_INT);
$query2->bindParam(':uid', $uid, PDO:TongueARAM_INT);
if(!$query2->execute())
$result = 0; // Problems executing SQL. Fail.

//Update max cash.
$query1 = $dbh5->prepare("UPDATE t_user_log SET a_total_donate = a_total_donate + :cash WHERE a_account_index = :user");
$query1->bindParam(':user', $uid, PDO:TongueARAM_INT);
$query1->bindParam(':cash', $new, PDO:TongueARAM_INT);
if(!$query1->execute())
$result = 0; // Problems executing SQL. Fail.

$dbh = null;
}
catch (PDOException $e)
{
exit($e->getMessage());
}
}
else
$result = 0; // Security hash incorrect. Fail.

echo $result;

// This script will output a status code of 1 (Success) or 0 (Try sending again later).

?>

Script I wrote especially for lc-cms from ToXiC to auto-update cash + donation rank + list donations* done to see them in the  admin panel.

 

*Haven't finished yet the system to write which method got used so it'll only show you the number.



Messages In This Thread
[No subject] - by Sutz - 06-27-2014, 10:06 AM
[No subject] - by luoo - 07-04-2014, 07:55 PM
[No subject] - by Sutz - 07-04-2014, 07:57 PM
[No subject] - by ren0d1 - 07-04-2014, 08:24 PM
[No subject] - by Vogelj1988 - 11-28-2014, 03:14 AM
[No subject] - by bignoob77 - 01-04-2015, 08:20 AM
[No subject] - by KissLC - 04-09-2015, 07:23 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)