"Fossies" - the Fresh Open Source Software Archive

Member "bad-behavior/bad-behavior/whitelist.inc.php" (11 Oct 2012, 1108 Bytes) of package /linux/www/bad-behavior.2.2.24.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php if (!defined('BB2_CORE')) die('I said no cheating!');
    2 
    3 function bb2_run_whitelist($package)
    4 {
    5     # FIXME: Transitional, until port maintainters implement bb2_read_whitelist
    6     if (function_exists('bb2_read_whitelist')) {
    7         $whitelists = bb2_read_whitelist();
    8     } else {
    9         $whitelists = @parse_ini_file(dirname(BB2_CORE) . "/whitelist.ini");
   10     }
   11 
   12     if (@!empty($whitelists['ip'])) {
   13         foreach (array_filter($whitelists['ip']) as $range) {
   14             if (match_cidr($package['ip'], $range)) return true;
   15         }
   16     }
   17     if (@!empty($whitelists['useragent'])) {
   18         foreach (array_filter($whitelists['useragent']) as $user_agent) {
   19             if (!strcmp($package['headers_mixed']['User-Agent'], $user_agent)) return true;
   20         }
   21     }
   22     if (@!empty($whitelists['url'])) {
   23         if (strpos($package['request_uri'], "?") === FALSE) {
   24             $request_uri = $package['request_uri'];
   25         } else {
   26             $request_uri = substr($package['request_uri'], 0, strpos($package['request_uri'], "?"));
   27         }
   28         foreach (array_filter($whitelists['url']) as $url) {
   29             $pos = strpos($request_uri, $url);
   30             if ($pos !== false && $pos == 0) return true;
   31         }
   32     }
   33     return false;
   34 }