You are here

function _filebrowser_match_path in Filebrowser 7.2

Same name and namespace in other branches
  1. 8 filebrowser.helpers.inc \_filebrowser_match_path()
  2. 6.2 includes/helpers.inc \_filebrowser_match_path()
  3. 7.4 filebrowser.helpers.inc \_filebrowser_match_path()
  4. 7.3 filebrowser.helpers.inc \_filebrowser_match_path()

Helper function to match a pattern on the path

Parameters

path path to process:

patterns to search (seperated by cr):

Return value

TRUE if at least one pattern is found

3 calls to _filebrowser_match_path()
filebrowser_form_upload_validate in ./filebrowser.module
uploads validation.
_filebrowser_cant_view_file in ./filebrowser.common.inc
Check if user should not view a specific file.
_filebrowser_can_view_file in ./filebrowser.common.inc
Check if user can view a specific file.

File

./filebrowser.helpers.inc, line 74
Misc helper functions.

Code

function _filebrowser_match_path($path, $patterns) {
  static $regexps = NULL;
  if (!isset($regexps[$patterns])) {
    $regexps[$patterns] = '/^(' . preg_replace(array(
      '/(\\r\\n?|\\n)/',
      '/\\\\\\*/',
    ), array(
      '|',
      '.*',
    ), preg_quote($patterns, '/')) . ')$/';
  }
  $result = preg_match($regexps[$patterns], _filebrowser_safe_basename($path)) == 1;
  return $result;
}