Page 1 of 1

check if maniacode has been executed with PHP problem

Posted: 11 Sep 2014, 10:32
by jonasredant
Hi,

I know this forum is for Trackmania 2, but for the older games there aren't many people
creating manialinks anymore or visiting that section of the forum...
I'm adding a simple poker game to my manialink (for Trackmania United Forever)
using PHP 5.2. The idea is that users can buy credits to play with coppers.
Suppose you have a quad like this:

<quad posn="0 0 0" sizen="12 6" style="Bgs1" substyle="BgIconBorder" manialink="buyCreditsForGame"></quad>

with buyCreditsForGame a registered maniacode that charges the user 50 coppers and points to an xml file
with the maniacode:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<maniacode>
<show_message>
<message>You've bought 5 credits.</message>
</show_message>
</maniacode> 
The PHP script has to check whether the maniacode has been executed and if so connect to a MySQL database
and increment credits by 5, update the jackpot,... Is there a way to check with PHP that the above maniacode
has indeed been executed? Remember: the manialink is for Trackmania United Forever, not for maniaplanet/Trackmania 2.

Greetings,

Jonas

Re: check if maniacode has been executed with PHP problem

Posted: 11 Sep 2014, 12:56
by jonasredant
Great, 34 views and not a single reply.

Re: check if maniacode has been executed with PHP problem

Posted: 11 Sep 2014, 13:42
by steeffeen
i would say there is no secure way of checking that
you might need to use the web service sdk to create payments and check for their status on the next request

Re: check if maniacode has been executed with PHP problem

Posted: 11 Sep 2014, 14:02
by jonasredant
I only want to check if the code has been executed, not that I actually received the coppers

would this work?

Code: Select all

<?php

echo <<<EOT
<?xml version="1.0" encoding="UTF-8" ?>
<maniacode>
<show_message>
<message>You've bought 5 credits.</message>
</show_message>
</maniacode> 
EOT;

$_SESSION["executed"] = True;
?>
what i fear is that if a user has for eg 30 coppers and want to spend 50 the code will also be executed

Re: check if maniacode has been executed with PHP problem

Posted: 11 Sep 2014, 16:58
by steeffeen
i also thought of this but if i simply open the url in the browser 1000 times i will be the king

there's no need for an echo btw, everything outside the <?php?> tags will be printed:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<maniacode>
<show_message>
<message>You've bought 5 credits.</message>
</show_message>
</maniacode>
<?php
$_SESSION["executed"] = True;
?>

Re: check if maniacode has been executed with PHP problem

Posted: 11 Sep 2014, 18:32
by jonasredant
I appreciate the help :-), but I'm not going to be able to solve the problem today. It's just one of these days on which I can't make a visual representation of the problem in my head lol. Too tired. Been messing around for hours now, not willing to admit that I can't solve it today.