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
https://forums.phpfreaks.com/topic/188678-no-symbols/#findComment-996069
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
https://forums.phpfreaks.com/topic/188678-no-symbols/#findComment-996218
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
https://forums.phpfreaks.com/topic/188678-no-symbols/#findComment-996261
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
https://forums.phpfreaks.com/topic/188678-no-symbols/#findComment-996633
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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