function showList($msg) { global $wgOut; $wgOut->setPagetitle(wfMsg("ipblocklist")); if ("" != $msg) { $wgOut->setSubtitle($msg); } // Purge expired entries on one in every 10 queries if (!mt_rand(0, 10)) { Block::purgeExpired(); } $conds = array(); if ($this->ip == '') { // No extra conditions } elseif (substr($this->ip, 0, 1) == '#') { $conds['ipb_id'] = substr($this->ip, 1); } elseif (IP::toUnsigned($this->ip) !== false) { $conds['ipb_address'] = $this->ip; $conds['ipb_auto'] = 0; } elseif (preg_match("/^(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})\\/(\\d{1,2})\$/", $this->ip, $matches)) { $conds['ipb_address'] = Block::normaliseRange($this->ip); $conds['ipb_auto'] = 0; } else { $user = User::newFromName($this->ip); if ($user && ($id = $user->getID()) != 0) { $conds['ipb_user'] = $id; } else { // Uh...? $conds['ipb_address'] = $this->ip; $conds['ipb_auto'] = 0; } } $pager = new IPBlocklistPager($this, $conds); $s = $pager->getNavigationBar() . $this->searchForm(); if ($pager->getNumRows()) { $s .= "<ul>" . $pager->getBody() . "</ul>"; } else { $s .= '<p>' . wfMsgHTML('ipblocklistempty') . '</p>'; } $s .= $pager->getNavigationBar(); $wgOut->addHTML($s); }
function showList($msg) { global $wgOut, $wgUser; $wgOut->setPagetitle(wfMsg("ipblocklist")); if ("" != $msg) { $wgOut->setSubtitle($msg); } // Purge expired entries on one in every 10 queries if (!mt_rand(0, 10)) { Block::purgeExpired(); } $conds = array(); $matches = array(); // Is user allowed to see all the blocks? if (!$wgUser->isAllowed('suppress')) { $conds['ipb_deleted'] = 0; } if ($this->ip == '') { // No extra conditions } elseif (substr($this->ip, 0, 1) == '#') { $conds['ipb_id'] = substr($this->ip, 1); // Single IPs } elseif (IP::isIPAddress($this->ip) && strpos($this->ip, '/') === false) { if ($iaddr = IP::toHex($this->ip)) { # Only scan ranges which start in this /16, this improves search speed # Blocks should not cross a /16 boundary. $range = substr($iaddr, 0, 4); // Fixme -- encapsulate this sort of query-building. $dbr = wfGetDB(DB_SLAVE); $encIp = $dbr->addQuotes(IP::sanitizeIP($this->ip)); $encRange = $dbr->addQuotes("{$range}%"); $encAddr = $dbr->addQuotes($iaddr); $conds[] = "(ipb_address = {$encIp}) OR \n\t\t\t\t\t(ipb_range_start LIKE {$encRange} AND\n\t\t\t\t\tipb_range_start <= {$encAddr}\n\t\t\t\t\tAND ipb_range_end >= {$encAddr})"; } else { $conds['ipb_address'] = IP::sanitizeIP($this->ip); } $conds['ipb_auto'] = 0; // IP range } elseif (IP::isIPAddress($this->ip)) { $conds['ipb_address'] = Block::normaliseRange($this->ip); $conds['ipb_auto'] = 0; } else { $user = User::newFromName($this->ip); if ($user && ($id = $user->getId()) != 0) { $conds['ipb_user'] = $id; } else { // Uh...? $conds['ipb_address'] = $this->ip; $conds['ipb_auto'] = 0; } } // Apply filters if ($this->hideuserblocks) { $conds['ipb_user'] = 0; } if ($this->hidetempblocks) { $conds['ipb_expiry'] = 'infinity'; } if ($this->hideaddressblocks) { $conds[] = "ipb_user != 0 OR ipb_range_end > ipb_range_start"; } $pager = new IPBlocklistPager($this, $conds); if ($pager->getNumRows()) { $wgOut->addHTML($this->searchForm() . $pager->getNavigationBar() . Xml::tags('ul', null, $pager->getBody()) . $pager->getNavigationBar()); } elseif ($this->ip != '') { $wgOut->addHTML($this->searchForm()); $wgOut->addWikiMsg('ipblocklist-no-results'); } else { $wgOut->addHTML($this->searchForm()); $wgOut->addWikiMsg('ipblocklist-empty'); } }
function showList($msg) { global $wgOut, $wgUser; $wgOut->setPagetitle(wfMsg("ipblocklist")); if ("" != $msg) { $wgOut->setSubtitle($msg); } // Purge expired entries on one in every 10 queries if (!mt_rand(0, 10)) { Block::purgeExpired(); } $conds = array(); $matches = array(); // Is user allowed to see all the blocks? if (!$wgUser->isAllowed('oversight')) { $conds['ipb_deleted'] = 0; } if ($this->ip == '') { // No extra conditions } elseif (substr($this->ip, 0, 1) == '#') { $conds['ipb_id'] = substr($this->ip, 1); } elseif (IP::toUnsigned($this->ip) !== false) { $conds['ipb_address'] = $this->ip; $conds['ipb_auto'] = 0; } elseif (preg_match('/^(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})\\/(\\d{1,2})$/', $this->ip, $matches)) { $conds['ipb_address'] = Block::normaliseRange($this->ip); $conds['ipb_auto'] = 0; } else { $user = User::newFromName($this->ip); if ($user && ($id = $user->getID()) != 0) { $conds['ipb_user'] = $id; } else { // Uh...? $conds['ipb_address'] = $this->ip; $conds['ipb_auto'] = 0; } } $pager = new IPBlocklistPager($this, $conds); if ($pager->getNumRows()) { $wgOut->addHTML($this->searchForm() . $pager->getNavigationBar() . Xml::tags('ul', null, $pager->getBody()) . $pager->getNavigationBar()); } elseif ($this->ip != '') { $wgOut->addHTML($this->searchForm()); $wgOut->addWikiText(wfMsg('ipblocklist-no-results')); } else { $wgOut->addWikiText(wfMsg('ipblocklist-empty')); } }
function showList($msg) { global $wgOut, $wgUser; $wgOut->setPagetitle(wfMsg("ipblocklist")); if ($msg != "") { $wgOut->setSubtitle($msg); } // Purge expired entries on one in every 10 queries if (!mt_rand(0, 10)) { Block::purgeExpired(); } $conds = array(); $matches = array(); // Is user allowed to see all the blocks? if (!$wgUser->isAllowed('hideuser')) { $conds['ipb_deleted'] = 0; } if ($this->ip == '') { // No extra conditions } elseif (substr($this->ip, 0, 1) == '#') { $conds['ipb_id'] = substr($this->ip, 1); // Single IPs } elseif (IP::isIPAddress($this->ip) && strpos($this->ip, '/') === false) { if ($iaddr = IP::toHex($this->ip)) { # Only scan ranges which start in this /16, this improves search speed # Blocks should not cross a /16 boundary. $range = substr($iaddr, 0, 4); // Fixme -- encapsulate this sort of query-building. $dbr = wfGetDB(DB_SLAVE); $encIp = $dbr->addQuotes(IP::sanitizeIP($this->ip)); $encAddr = $dbr->addQuotes($iaddr); $conds[] = "(ipb_address = {$encIp}) OR \n\t\t\t\t\t(ipb_range_start" . $dbr->buildLike($range, $dbr->anyString()) . " AND\n\t\t\t\t\tipb_range_start <= {$encAddr}\n\t\t\t\t\tAND ipb_range_end >= {$encAddr})"; } else { $conds['ipb_address'] = IP::sanitizeIP($this->ip); } $conds['ipb_auto'] = 0; // IP range } elseif (IP::isIPAddress($this->ip)) { $conds['ipb_address'] = Block::normaliseRange($this->ip); $conds['ipb_auto'] = 0; } else { $user = User::newFromName($this->ip); if ($user && ($id = $user->getId()) != 0) { $conds['ipb_user'] = $id; } else { // Uh...? $conds['ipb_address'] = $this->ip; $conds['ipb_auto'] = 0; } } // Apply filters if ($this->hideuserblocks) { $conds['ipb_user'] = 0; } if ($this->hidetempblocks) { $conds['ipb_expiry'] = 'infinity'; } if ($this->hideaddressblocks) { $conds[] = "ipb_user != 0 OR ipb_range_end > ipb_range_start"; } // Search form $wgOut->addHTML($this->searchForm()); // Check for other blocks, i.e. global/tor blocks $otherBlockLink = array(); wfRunHooks('OtherBlockLogLink', array(&$otherBlockLink, $this->ip)); // Show additional header for the local block only when other blocks exists. // Not necessary in a standard installation without such extensions enabled if (count($otherBlockLink)) { $wgOut->addHTML(Html::rawElement('h2', array(), wfMsg('ipblocklist-localblock')) . "\n"); } $pager = new IPBlocklistPager($this, $conds); if ($pager->getNumRows()) { $wgOut->addHTML($pager->getNavigationBar() . Xml::tags('ul', null, $pager->getBody()) . $pager->getNavigationBar()); } elseif ($this->ip != '') { $wgOut->addWikiMsg('ipblocklist-no-results'); } else { $wgOut->addWikiMsg('ipblocklist-empty'); } if (count($otherBlockLink)) { $wgOut->addHTML(Html::rawElement('h2', array(), wfMsgExt('ipblocklist-otherblocks', 'parseinline', count($otherBlockLink))) . "\n"); $list = ''; foreach ($otherBlockLink as $link) { $list .= Html::rawElement('li', array(), $link) . "\n"; } $wgOut->addHTML(Html::rawElement('ul', array('class' => 'mw-ipblocklist-otherblocks'), $list) . "\n"); } }