Jump to content

No symbols


Gubbins

Recommended Posts

ok well its from a roulette script and i need to stop people using the + or - symbols as it can be exploited and i thought by modifying that line of code would do the trick.

so if zero, - or + was used it would return the error as "One or more of your bet(s) was invalid."

Link to comment
Share on other sites

You could use regex to see if $bet only contains numbers,

 

if ( $bet < 0 || preg_match('/[^0-9]+/', $bet) ){
    $error = "One or more of your bet(s) was invalid.";
    error($error);
}

 

umm it didnt work, i just tested it and it let me use the minus sign, any ideas?

Link to comment
Share on other sites

Mattal, you cannot typecast a string into an int, as it would hide the error (allowing a-z to be parsed in the conditional statement). Try this:

$bet = -20;
$bet = abs($bet);
if(!is_numeric($bet) || $bet < 0) {
    $error = "One or more of your bet(s) was invalid.";
    error($error);
}

 

It will remove the +- from the string, as the absolute (abs) function is supposed to do, and then check based upon if it is above zero, and is numeric.

Link to comment
Share on other sites

Mattal, you cannot typecast a string into an int, as it would hide the error (allowing a-z to be parsed in the conditional statement). Try this:

$bet = -20;
$bet = abs($bet);
if(!is_numeric($bet) || $bet < 0) {
    $error = "One or more of your bet(s) was invalid.";
    error($error);
}

 

It will remove the +- from the string, as the absolute (abs) function is supposed to do, and then check based upon if it is above zero, and is numeric.

 

Thank you for trying but it still lets me use the minus sign to make a bet thus exploiting the game for cheaters.

I dont know what to do next?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.