How does block page whitelisting work?
The related code is found in block_block_list_alter() function, inside /modules/block/block.module file.

Here's how you would perform a similar check in your code:

// Get the pages to check. This should be in the same format as what Drupal
// core uses - meaning one path per line and you can use placeholders.
//
// Variable below is just as an example.
$pages_to_check = 'page1' . PHP_EOL . 'page2' . PHP_EOL . 'page3/*';
// This is a good practice, because it will make sure that paths are always
// checked consistently and won't depend on the case.
$pages = drupal_strtolower($pages_to_check);
// Compare the lowercase internal and lowercase path alias (if any).
$page_match = drupal_match_path($path, $pages);
if ($path != $_GET['q']) {
  $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
}
// Now you can do whatever you want based on whether or not the current path
// matches the pattern. For example:
if ($page_match) {
  // You are on one of the listed pages.
}
else {
  // You are not on one of the listed pages.
}


Hope this helps.