public function build($runData) { // get current blocks! $site = $runData->getTemp("site"); $c = new Criteria(); $c->add("site_id", $site->getSiteId()); $c->addOrderDescending("block_id"); $blocks = DB_IpBlockPeer::instance()->select($c); if (count($blocks) > 0) { $runData->contextAdd("blocks", $blocks); } }
public function deleteIpBlockEvent($runData) { $pl = $runData->getParameterList(); $site = $runData->getTemp("site"); $blockId = $pl->getParameterValue("blockId"); $block = DB_IpBlockPeer::instance()->selectByPrimaryKey($blockId); if ($block == null) { $runData->ajaxResponseAdd("status", "no_block"); $runData->ajaxResponseAdd("message", _("No such IP block.")); return; } $c = new Criteria(); $c->add("site_id", $site->getSiteId()); $c->add("block_id", $blockId); // ok, remove $db = Database::connection(); $db->begin(); DB_IpBlockPeer::instance()->delete($c); $db->commit(); }
private function checkIpBlocked($ipString, $site) { $c = new Criteria(); $ips = explode("|", $ipString); $q = "SELECT * FROM ip_block WHERE site_id='" . $site->getSiteId() . "' " . "AND (ip <<= '" . db_escape_string($ips[0]) . "' "; if ($ips[1]) { $q .= "OR ip <<= '" . db_escape_string($ips[1]) . "'"; } $q .= ")"; $c->setExplicitQuery($q); $blocks = DB_IpBlockPeer::instance()->select($c); return $blocks; }