Weet iemand wat er hier fout gaat?

Gestart doorRiick8 reacties28 weergaven

9 berichten · pagina 1 van 1

Riick

Lid · Topicstarter

Berichten
3.425
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,
Ik heb een vraagje, namelijk weet iemand wat er mis gaat in mijn postback.php?
Het is de bedoeling dat hij succesvol de punten bijschrijft bij een lid.
Bij de secret code staat normaal mijn secret code in plaats van alle xs.
Mijn paymentwall stuurt de onderstaande request.

Het enige wat er dus niet gebeurd is dat de credits worden bijgeschreven in de row uCoins onder de tabel naam member_accounts.

pingback.php

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]config.php[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]SECRET[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]xxxxxxxxxxxxxxxxxxxxx[/COLOR][COLOR= #007700]);[/COLOR]
 
[COLOR= #FF8000]// YOUR SECRET KEY[/COLOR]
 
[URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]CREDIT_TYPE_CHARGEBACK[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]2[/COLOR][COLOR= #007700]);[/COLOR]
 
[COLOR= #0000BB]$ipsWhitelist[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR]
[COLOR= #DD0000]174.36.92.186[/COLOR][COLOR= #007700],[/COLOR]
 
[COLOR= #DD0000]174.36.96.66[/COLOR][COLOR= #007700],[/COLOR]
 
[COLOR= #DD0000]174.36.92.187[/COLOR][COLOR= #007700],[/COLOR]
 
[COLOR= #DD0000]174.36.92.192[/COLOR][COLOR= #007700],[/COLOR]
 
[COLOR= #DD0000]174.37.14.28[/COLOR]
[COLOR= #007700]);[/COLOR]
 
[COLOR= #0000BB]$userId[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uid[/COLOR][COLOR= #007700]]) ?[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uid[/COLOR][COLOR= #007700]] :[/COLOR] null[COLOR= #007700];[/COLOR]
 
[COLOR= #0000BB]$credits[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]currency[/COLOR][COLOR= #007700]]) ?[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]currency[/COLOR][COLOR= #007700]] :[/COLOR] null[COLOR= #007700];[/COLOR]
 
[COLOR= #0000BB]$type[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]type[/COLOR][COLOR= #007700]]) ?[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]type[/COLOR][COLOR= #007700]] :[/COLOR] null[COLOR= #007700];[/COLOR]
 
[COLOR= #0000BB]$refId[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ref[/COLOR][COLOR= #007700]]) ?[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ref[/COLOR][COLOR= #007700]] :[/COLOR] null[COLOR= #007700];[/COLOR]
 
[COLOR= #0000BB]$signature[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]sig[/COLOR][COLOR= #007700]]) ?[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]sig[/COLOR][COLOR= #007700]] :[/COLOR] null[COLOR= #007700];[/COLOR]
 
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] false[COLOR= #007700];[/COLOR]
 
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$userId[/COLOR][COLOR= #007700]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$credits[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$type[/COLOR][COLOR= #007700]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$refId[/COLOR][COLOR= #007700]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$signature[/COLOR][COLOR= #007700])) {[/COLOR]
[COLOR= #0000BB]$signatureParams[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR]
[COLOR= #DD0000]uid[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$userId[/COLOR][COLOR= #007700],[/COLOR]
 
[COLOR= #DD0000]currency[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$credits[/COLOR][COLOR= #007700],[/COLOR]
 
[COLOR= #DD0000]type[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$type[/COLOR][COLOR= #007700],[/COLOR]
 
[COLOR= #DD0000]ref[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$refId[/COLOR]
[COLOR= #007700]);[/COLOR]
 
[COLOR= #0000BB]$signatureCalculated[/COLOR] [COLOR= #007700]=[/COLOR] calculatePingbackSignature[COLOR= #007700]([/COLOR][COLOR= #0000BB]$signatureParams[/COLOR][COLOR= #007700],[/COLOR] SECRET[COLOR= #007700]);[/COLOR]
 
[COLOR= #FF8000]// check if IP is in whitelist and if signature matches[/COLOR]
 
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/in_array"]in_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$ipsWhitelist[/COLOR][COLOR= #007700]) && ([/COLOR][COLOR= #0000BB]$signature[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$signatureCalculated[/COLOR][COLOR= #007700])) {[/COLOR]
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] true[COLOR= #007700];[/COLOR]
 
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$type[/COLOR] [COLOR= #007700]==[/COLOR] CREDIT_TYPE_CHARGEBACK[COLOR= #007700]) {[/COLOR]
[COLOR= #FF8000]// Deduct credits from user
 
// This is optional, but we recommend this type of crediting to be implemented as well
 
// Note that currency amount sent for chargeback is negative, e.g. -5, so be caferul about the sign
 
// Don"™t deduct negative number, otherwise user will get credits instead of losing them[/COLOR]
[COLOR= #007700]}[/COLOR]
 
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE member_accounts SET uCoins = uCoins + $credits WHERE id = $userId"[/COLOR][COLOR= #007700]);
}
}
}[/COLOR]
 
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]OK[/COLOR][COLOR= #007700];
}
 
function[/COLOR] calculatePingbackSignature[COLOR= #007700]([/COLOR][COLOR= #0000BB]$params[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$secret[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$str[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
 
[URL="http://www.php.net/foreach"]foreach[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$params[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$k[/COLOR][COLOR= #007700]=>[/COLOR][COLOR= #0000BB]$v[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$str[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"$k=$v"[/COLOR][COLOR= #007700];
}[/COLOR]
 
[COLOR= #0000BB]$str[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #0000BB]$secret[/COLOR][COLOR= #007700];[/COLOR]
 
[URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$str[/COLOR][COLOR= #007700]);
}[/COLOR]


Request:

GET http://www.gamerscash.nl:80/pingback.php?uid=1&currency=100&type=0&ref=100010101010&sig=bf0562ed591948f9d98fa7267f52f9df HTTP/1.1
Host: www.gamerscash.nl
Connection: close
Accept-encoding: gzip, deflate
User-Agent: Paymentwall API


Response:

HTTP/1.0 200 OK
Date: Fri, 01 Mar 2013 13:47:47 GMT
Server: Apache/2
X-powered-by: PHP/5.4.11
Set-cookie: PHPSESSID=734563fd4d08d6ae61e5fab6921ecc07; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Vary: User-Agent
Content-length: 2
Content-type: text/html
Connection: close

OK
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Misschien de code uitlijnen? confusedDan kan je al veel meer vinden.
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Regel 64
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je hebt in je query $credits staan

dan wordt het dus: credits=credits+100
Dat is dus een getal + een string -> gaat niet werken.

edit: dat is het dus niet puh2Zou je er iets bij kunnen maken, zodat je ziet of er een error is mbv mysql_error(); ?

Ook raad ik het je het aan om bijvoorbeeld mysql_real_escape_string() te gebruiken om je $credits en $userId, of deze twee variabelen te checken met ctype_digit
0
Riick

Lid · Topicstarter

Berichten
3.425
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
Regel 64
Wat is er fout aan?
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE member_accounts SET uCoins = uCoins + "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$credits[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]" WHERE id = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$userId[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
?>
0
Riick

Lid · Topicstarter

Berichten
3.425
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt, maar ik heb het even anders gedaan.
Helaas heb ik hiervoor een opensource script genomen.

Voor de lief hebbers:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// +---------------------------------------------+
// | Super Rewards Call back script WITH loging  |
// +---------------------------------------------+
// | DONOT REMOVE THIS                           |
// +---------------------------------------------+
// | Copyright Rodney Cheney 2011-2015           |
// +---------------------------------------------+[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR]

    [COLOR= #0000BB]$SECRET[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"HIER JOU GEHEIME CODE"[/COLOR][COLOR= #007700];[/COLOR]   [COLOR= #FF8000]///this is you apps secret key get this from app info[/COLOR]
    [COLOR= #0000BB]$snuid[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_REQUEST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uid[/COLOR][COLOR= #007700]];[/COLOR]      [COLOR= #FF8000]// this grabs the snuid from the url[/COLOR]
    [COLOR= #0000BB]$currency[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_REQUEST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]new[/COLOR][COLOR= #007700]];[/COLOR]   [COLOR= #FF8000]// this grabs amount of points to award user[/COLOR]
    [COLOR= #0000BB]$total[/COLOR][COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_REQUEST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]total[/COLOR][COLOR= #007700]];[/COLOR]     [COLOR= #FF8000]// this grabs total points super rewards has ever sent user[/COLOR]
    [COLOR= #0000BB]$offerwallID[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_REQUEST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]oid[/COLOR][COLOR= #007700]];[/COLOR][COLOR= #FF8000]// this grabs the offer walls offer ID[/COLOR]
    [COLOR= #0000BB]$transactionID[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_REQUEST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR][COLOR= #FF8000]//this grabs the taransaction id from super rewards[/COLOR]
    [COLOR= #0000BB]$sidverify[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_REQUEST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]sig[/COLOR][COLOR= #007700]];[/COLOR]  [COLOR= #FF8000]// this grabs the hashed info for you to authenticate with
   
    // make  a hash of our own to verify authenicc transaction[/COLOR]
    [COLOR= #0000BB]$sig[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_REQUEST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]:[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_REQUEST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]new[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]:[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_REQUEST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uid[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]:[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$SECRET[/COLOR][COLOR= #007700]);[/COLOR]
    
    [COLOR= #FF8000]//here we are gonna count the total points loged each time user has recived points[/COLOR]
    [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT SUM(`points`) as `DeadWeight` FROM `sr_log` WHERE `userID`=$snuid"[/COLOR][COLOR= #007700];[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]( !([/COLOR][COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700])) ) 
        {[/COLOR]
            [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Failed to query database. srlogs.[/COLOR][COLOR= #007700]);
        }[/COLOR]
 
 [COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]);[/COLOR]
 [COLOR= #0000BB]$DeadWeight[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]DeadWeight[/COLOR][COLOR= #007700]];[/COLOR] 
 
    

[COLOR= #FF8000]// 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.[/COLOR]
[URL="http://www.php.net/if"]if[/URL]  [COLOR= #007700]([/COLOR][COLOR= #0000BB]$sidverify[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$sig[/COLOR][COLOR= #007700])
    {[/COLOR]
        [COLOR= #FF8000]//Insert Super Rewards transaction info into your database[/COLOR]
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO sr_log SET points=$currency,total=$total,oid=$offerwallID,userID=$snuid, transID=$transactionID"[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #FF8000]//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.[/COLOR]
        [URL="http://www.php.net/if"]if[/URL]  [COLOR= #007700]([/COLOR][COLOR= #0000BB]$DeadWeight[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]$total[/COLOR][COLOR= #007700])
            {[/COLOR]
                [COLOR= #FF8000]//If all is good Update the user with there points from the url request.[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE member_accounts SET uCoins = uCoins + "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$currency[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" WHERE uId = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$snuid[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);
  
            }[/COLOR]
      [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"1"[/COLOR][COLOR= #007700];
    }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"0"[/COLOR][COLOR= #007700];     
    }[/COLOR]
    

  
?>
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Je vergeet mysql_real_escape_string();
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Fout afhandeling op de query
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren