Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Checker Always Return True #12

Open
abilsabili50 opened this issue Aug 15, 2024 · 0 comments
Open

Request Checker Always Return True #12

abilsabili50 opened this issue Aug 15, 2024 · 0 comments

Comments

@abilsabili50
Copy link

This is because the code below will return false if string "/charge" doesn't exists and 0 (falsy value) if exists.

!strpos($_SERVER['REQUEST_URI'], '/charge')

To fix this, you should explicitly check if strpos returns false instead of relying on the falsy nature of 0. Here's the corrected code:

if (strpos($_SERVER['REQUEST_URI'], '/charge') === false) {
  http_response_code(404); 
  echo "wrong path, make sure it's `/charge`"; 
  exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant