<?php
function proceedFilter($filter, $botID, $botCountry, $botPrivileges, $botOS, $botAntivirus, $botGPU, $botInstallDate, $gi){
    $filters = explode(';', $filter);
    foreach($filters as &$currentFilter){
        if (strpos($currentFilter, 'country') !== false){
            if(strpos($currentFilter, strtolower(geoip_country_name_by_id($gi, $botCountry))) ||
               strpos($currentFilter, geoip_country_name_by_id($gi, $botCountry))
            ){
                continue;
            }
            else return false;
        }
        else if (strpos($currentFilter, 'privileges') !== false){
           if(strpos($currentFilter, strtolower($botPrivileges)) ||
              strpos($currentFilter, $botPrivileges)){
                continue;
            }
            else return false;
        }
        else if (strpos($currentFilter, 'os') !== false){
           if(strpos($currentFilter, strtolower($botOS)) ||
              strpos($currentFilter, $botOS)){
                continue;
            }
            else return false;
        }
        else if (strpos($currentFilter, 'antivirus') !== false){
           if(strpos($currentFilter, strtolower($botAntivirus)) ||
              strpos($currentFilter, $botAntivirus)){
                continue;
            }
            else return false;
        }
        else if (strpos($currentFilter, 'hwid') !== false){
           if(strpos($currentFilter, $botID) ||
              strpos($currentFilter, strtolower($botID))){
                continue;
            }
            else return false;
        }
        else if (strpos($currentFilter, 'date') !== false){
            $dateFilter = explode(":", $currentFilter);
            if(sizeof($dateFilter)==2){
                $dates = explode("_",$dateFilter[1]);
                if(sizeof($dates)==2){
                    if($dates[0]<$dates[1]){
                        if($dates[0] <= $botInstallDate && $botInstallDate <= $dates[1]){
                            continue;
                        }
                    }
                }
            }
            return false;
         }
        else if (strpos($currentFilter, 'gpu') !== false){
           if(strpos($currentFilter, $botGPU) ||
              strpos($currentFilter, strtolower($botGPU))){
                continue;
            }
            else return false;
        }
    }
    return true;
}
?>