check if maniacode has been executed with PHP problem

Talk about ManiaLink development in this forum

Moderator: NADEO

Post Reply
jonasredant
Posts: 39
Joined: 10 Aug 2014, 17:26

check if maniacode has been executed with PHP problem

Post 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
jonasredant
Posts: 39
Joined: 10 Aug 2014, 17:26

Re: check if maniacode has been executed with PHP problem

Post by jonasredant »

Great, 34 views and not a single reply.
User avatar
steeffeen
Translator
Translator
Posts: 2463
Joined: 14 Oct 2012, 16:22
Location: Germany

Re: check if maniacode has been executed with PHP problem

Post 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
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks
    jonasredant
    Posts: 39
    Joined: 10 Aug 2014, 17:26

    Re: check if maniacode has been executed with PHP problem

    Post 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
    User avatar
    steeffeen
    Translator
    Translator
    Posts: 2463
    Joined: 14 Oct 2012, 16:22
    Location: Germany

    Re: check if maniacode has been executed with PHP problem

    Post 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;
    ?>
    
      Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

      ManiaControl, FancyManiaLinks
      jonasredant
      Posts: 39
      Joined: 10 Aug 2014, 17:26

      Re: check if maniacode has been executed with PHP problem

      Post 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.
      Post Reply

      Return to “ManiaLink”

      Who is online

      Users browsing this forum: No registered users and 1 guest