Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
 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;
 }