Jump to content
MakeWebGames

Super Rewards


Cronic

Recommended Posts

So, I'm trying to implement Super Rewards into my game..

Here's the following code:

postback.php

 

<?php

include 'dbcon.php';
include 'classes.php';
include 'codeparser.php';
$earn = ($_GET['new']);
$userid = ($_GET['uid']);
$totaluser = ($_GET['total']);
$offerid = ($_GET['oid']);
store_lead($_GET['oid'], $_GET['uid'], $_GET['total'], $_GET['new']);

echo 1;

//ASSIGN VARIABLES TO USER INFO
$time = date("M j G:i:s Y");
$ip = getenv('REMOTE_ADDR');
$userAgent = getenv('HTTP_USER_AGENT');
$referrer = getenv('HTTP_REFERER');
$query = getenv('QUERY_STRING');

//COMBINE VARS INTO OUR LOG ENTRY
$msg = "IP: " . $ip . " TIME: " . $time . " REFERRER: " . $referrer . " SEARCHSTRING: " . $query . " USERAGENT: " . $userAgent;

//CALL OUR LOG FUNCTION
writeToLogFile($msg);

function writeToLogFile($msg)
{
    $today = date("Y_m_d");
    $logfile = $today."_log.txt";
    $dir = 'postbacklogs';
    $saveLocation=$dir . '/' . $logfile;
    if (!$handle = @fopen($saveLocation, "a"))
    {
         exit;
    }
    else
    {
         if(@fwrite($handle,"$msg\r\n")===FALSE)
         {
              exit;
         }

         @fclose($handle);
    }
}
?>

 

classes.php



function store_lead($offerid, $userid, $totaluser, $earn){
$result = mysql_query("SELECT * FROM `sr_log` WHERE `oid`='{$offerid}', `uid`='{$userid}', `total`='{$totaluser}', `new`='{$earn}'");

$result = mysql_query("INSERT INTO `sr_log` (`oid`, `uid`, `total`, `new`) VALUES ('$offerid', '$userid', '$totaluser', '$earn')");


 $result = mysql_query("UPDATE `grpgusers` SET points = points+ $earn WHERE userid=$userid"); //give user crystals//
 Send_Event($userid, "You have been credited ".$earn." points for completing a offer.");

} 



?>

 

When I click on [ADMIN USER TEST]

Send 100 Points

 

Its sending a postback, but only the event will be send to the players log, but it isn't giving the points its not even putting a query in database for the logs.

Does anyone know what i'm doing wrong?

Greetings.

Link to comment
Share on other sites

Nevermind, managed to get it working with the following code, modified a little bits of it.

 


<?php
// +---------------------------------------------+
// | Super Rewards Call back script WITH loging  |
// +---------------------------------------------+
// | DONOT REMOVE THIS                           |
// +---------------------------------------------+
// | Copyright Rodney Cheney 2011-2015           |
// +---------------------------------------------+
include("dbcon.php");
include("classes.php");

   $SECRET = "PutYourAPPIDInHere";   ///this is you apps secret key get this from app info
   $snuid = $_REQUEST['uid'];      // this grabs the snuid from the url
   $currency = $_REQUEST['new'];   // this grabs amount of points to award user
   $total= $_REQUEST['total'];     // this grabs total points super rewards has ever sent user
   $offerwallID = $_REQUEST['oid'];// this grabs the offer walls offer ID
   $transactionID = $_REQUEST['id'];//this grabs the taransaction id from super rewards
   $sidverify = $_REQUEST['sig'];  // this grabs the hashed info for you to authenticate with

   // make  a hash of our own to verify authenicc transaction
   $sig = md5($_REQUEST['id'] . ':' . $_REQUEST['new'] . ':' . $_REQUEST['uid'] . ':' . $SECRET);

   //here we are gonna count the total points loged each time user has recived points
   $sql = "SELECT SUM(`points`) as `DeadWeight` FROM `sr_log` WHERE `userID`='$snuid'";

   if( !($result = mysql_query($sql)) ) 
       {
           die('Failed to query database. srlogs.');
       }

$row = mysql_fetch_array($result);
$DeadWeight = $row['DeadWeight']; 



// You may want to add other checks to ensure that the user exists in your system

//Check if hashed info is same as hashed info from superrewards if not do nothing.
if  ($sidverify == $sig)
   {
       //Insert Super Rewards transaction info into your database
       mysql_query("INSERT INTO sr_log SET points=$currency,total=$total,oid=$offerwallID,userID=$snuid, transID=$transactionID");
       //Check if the total amount of points awarded to users is less then or the same as total from super rewards
       //This will make sure you dont give more then you should.
       if  ($DeadWeight <= $total)
           {
               //If all is good Update the user with there points from the url request.
mysql_query("UPDATE grpgusers SET points = points + ".$currency." WHERE id = '".$snuid."'");
//Send event to the player [silent Mafia Edit]
Send_Event($snuid, "You have been credited ".$currency." points for completing a offer");


           }
     echo "1";
   }else{
       echo "0";     
   }



?> 


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...