public function getByIPAddress($ip) { $bipm = BannedIPModel::getInstance(); $bip = $bipm->getByIPAddress($ip); if (!$bip) { return $bip; } return $bip->getMapped('permissionset'); }
$ipstoban[] = $user->last_ip; } // And now, let's get all known IPs $query = new Query('SELECT'); $query->field('submitter_ip'); $query->from('links'); $query->where('submitter_id = ?', $banid); $stmt = $query->prepare(); $stmt->execute(); while ($obj = $stmt->fetchObj()) { $ipstoban[] = $obj->submitter_ip; } // Filter out the dupes and query to see which are already banned $ipadded = array(); $toban = array(); $bipm = BannedIPModel::getInstance(); foreach ($ipstoban as $ip) { if (!isset($ipadded[$ip])) { $ipadded[$ip] = true; if (!$bipm->isBanned($ip)) { $toban[] = $ip; echo "Banning {$ip}...<br />\n"; } else { echo "IP {$ip} already banned.<br />\n"; } } } // Do it to it if ($toban) { $bipm->banIPs($user->name, $toban); echo "Done.<br />\n";