Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Web Pingback script

Newbie Spellweaver
Joined
Apr 16, 2016
Messages
86
Reaction score
1
I'm trying to use a script provided by maplefreak here : http://forum.ragezone.com/f692/gtops-pingback-maplebit-1101794/

I've activated my pingback and stuff on GTOP but everytime I vote with "&pingUsername=", the rewards don't get credited.

I've tried removing the check (success = 1) to test it through failed pingbacks but not helping. I'm guessing there's something wrong with the way it updates the tables?

If anyone could help me I'd really appreciate it.

Latest script I've edited & using :
 
Junior Spellweaver
Joined
Apr 30, 2012
Messages
100
Reaction score
41
Code:
file_put_contents("umbreoniscool.log",print_r($_POST,true));

Use this to see what your POST contains.
If all of this information is correct, then it's likely your query at fault. If there is no information at all, look to here and verify you've authorized GTOP's proper ip address(es).

Code:
$authorized = array("198.148.82.98");
if(!in_array(($isCloudflare ? $_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER['REMOTE_ADDR']),$authorized)) {
    exit;
}
 
Upvote 0
Newbie Spellweaver
Joined
Apr 16, 2016
Messages
86
Reaction score
1
My PHP is real bad.. Do you mind letting me know how I should use the file_put_contents?
 
Upvote 0
Infraction Baɴɴed
Loyal Member
Joined
Apr 9, 2008
Messages
1,416
Reaction score
169
from
Code:
<?php
$authorized = array("198.148.82.98", "198.148.82.99"); // authorized ips to prevent exploitation


if(!in_array($_SERVER["REMOTE_ADDR"],$authorized))
    exit;


$voterIP = mysql_real_escape_string($_POST["VoterIP"]); // voter ip address
$success = abs($_POST["Successful"]); // 1 for error, 0 for successful
$reason = $_POST["Reason"]; // log reason the vote failed


// $pingUsername is a custom field you can use to track your players username or
//id number.
//
// You can do this by changing your votebutton code link to whatever your players 
//username or id is.
//
// Simply add this line to the end of your voting url where yyy is your
//players unique username or id ( &pingUsername=yyy ).
//
// Below is an example url of how it should look.
// Example: [YourSiteDetailsPageURL]?vote=1&pingUsername=yyy
$pingUsername = $_POST["pingUsername"]; 


$link = mysqli_connect("localhost", "user", "password", "db");


// if successfull vote reward your user, use your own database!
$result = mysqli_query($link, "SELECT Username FROM UserTbl WHERE LastIP = "{$voterIP}"");
if($result !== FALSE)
{
    $row = mysqli_fetch_row($result);
    if(is_array($row))
    {
        if($success == 0)
        {
            // send reward to $row["Username"]
        }
        // Log reason here(optional)
    }
    mysqli_free_result($result);
}


mysqli_close($link);
?>
 
Upvote 0
Newbie Spellweaver
Joined
Apr 16, 2016
Messages
86
Reaction score
1
@Umbreon Thanks for the log method, I found out that the issue is with my rewarding part but I'm not sure what's wrong with it, do you mind taking a glance at this & see if you can figure anything off it?

$giveReward = $db->query("UPDATE accounts SET ".$colnx." = ".$colnx." + ".$nx.", ".$colvp." = ".$colvp." + ".$vp." WHERE name = ".$pingUsername.";");
 
Upvote 0
Junior Spellweaver
Joined
Apr 30, 2012
Messages
100
Reaction score
41
Run the query manually and see if it's a problem with your database or how you're processing the POST data.
 
Upvote 0
Back
Top