public static function setBlockLists()
 {
     $localCache = new _FileCache('blacklistmonitor-Utilities-BlockLists', 60);
     $cacheKey = 'bl';
     $cacheData = $localCache->get($cacheKey);
     if ($cacheData !== false) {
         if (isset($cacheData['domains']) && isset($cacheData['ips'])) {
             self::$domainBlacklists = $cacheData['domains'];
             self::$ipBlacklists = $cacheData['ips'];
             return true;
         }
     }
     $mysql = new _MySQL();
     $mysql->connect(Setup::$connectionArray);
     $sql = "select host,monitorType from blockLists where isActive = '1';";
     $rs = $mysql->runQuery($sql);
     $cacheData['domains'] = array();
     $cacheData['ips'] = array();
     while ($row = mysqli_fetch_array($rs, MYSQL_ASSOC)) {
         if ($row['monitorType'] == 'ip') {
             $cacheData['ips'][] = $row['host'];
         } else {
             $cacheData['domains'][] = $row['host'];
         }
     }
     $mysql->close();
     $localCache->set($cacheKey, $cacheData);
     self::$domainBlacklists = $cacheData['domains'];
     self::$ipBlacklists = $cacheData['ips'];
     return false;
 }
Beispiel #2
0
     Utilities::updateDomains($data);
     $result['status'] = 'success';
     break;
 case 'updateIPs':
     Utilities::updateIPs($data);
     $result['status'] = 'success';
     break;
 case 'checkHostStatus':
     $result['status'] = 'success';
     Utilities::setBlockLists();
     $result['result'] = Utilities::checkBlacklists($data);
     break;
 case 'blacklistStatus':
     $localCache = new _FileCache('blacklistmonitor-api', 90);
     $cacheKey = md5("{$username}|{$passwd}|{$apiKey}|{$type}|{$data}");
     $cacheData = $localCache->get($cacheKey);
     if ($cacheData !== false) {
         output($cacheData);
     }
     $mysql = new _MySQL();
     $mysql->connect(Setup::$connectionArray);
     $searchSQL = '';
     switch ($data) {
         case 'changed':
             $searchSQL .= " and lastStatusChanged = 1 ";
             break;
         case 'blocked':
             $searchSQL .= " and isBlocked = 1 ";
             break;
         case 'clean':
             $searchSQL .= " and isBlocked = 0 ";