<?php /** * Updates the cache of Project Honeypot IPs */ require_once getenv('MW_INSTALL_PATH') !== false ? getenv('MW_INSTALL_PATH') . "/maintenance/commandLine.inc" : dirname(__FILE__) . '/../../maintenance/commandLine.inc'; HoneypotIntegration::loadHoneypotData(); HoneypotIntegration::loadHoneypotURLs();
public static function loadHoneypotDataFromFile() { global $wgHoneypotDataFile; $fh = fopen($wgHoneypotDataFile, 'r'); $save_data = array(); $ips = array(); $count = 0; while (!feof($fh)) { $line = trim(fgets($fh)); $data = preg_split('/\\s/', $line, 3); if (IP::isIPAddress($data[0])) { $subnet = substr(IP::toHex($data[0]), 0, -6); if (!isset($ips[$subnet])) { $ips[$subnet] = array(); } if (!isset($save_data[$subnet])) { $save_data[$subnet] = array(); } $save_data[$subnet][$data[0]] = $data; $ips[$subnet][$data[0]] = true; $count++; if ($count % 100 == 0) { wfDebugLog('HoneypotDebug', "Done {$count} IPs -- {$data['0']}"); } } } fclose($fh); self::$IPs = $ips; self::$Data = $save_data; return array($save_data, $ips); }