本文整理汇总了PHP中Block::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::load方法的具体用法?PHP Block::load怎么用?PHP Block::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block::load方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Block
/**
* This is the method previously used to load block info in CheckUser etc
* passing an empty value (empty string, null, etc) as the ip parameter bypasses IP lookup checks.
*
* This stopped working with r84475 and friends: regression being fixed for bug 29116.
*
* @dataProvider dataBug29116
*/
function testBug29116LoadWithEmptyIp($vagueTarget)
{
$uid = User::idFromName('UTBlockee');
$this->assertTrue($uid > 0, 'Must be able to look up the target user during tests');
$block = new Block();
$ok = $block->load($vagueTarget, $uid);
$this->assertTrue($ok, "Block->load() with empty IP and user ID '{$uid}' should return a block");
$this->assertTrue($this->block->equals($block), "Block->load() returns the same block as the one that was made when given empty ip param " . var_export($vagueTarget, true));
}
示例2: newFromDB
static function newFromDB($address, $user = 0, $killExpired = true)
{
$block = new Block();
$block->load($address, $user, $killExpired);
if ($block->isValid()) {
return $block;
} else {
return null;
}
}
示例3: getBlockedStatus
/**
* Get blocking information
* @private
* @param bool $bFromSlave Specify whether to check slave or master. To improve performance,
* non-critical checks are done against slaves. Check when actually saving should be done against
* master.
*/
function getBlockedStatus($bFromSlave = true)
{
global $wgEnableSorbs, $wgProxyWhitelist;
if (-1 != $this->mBlockedby) {
wfDebug("User::getBlockedStatus: already loaded.\n");
return;
}
$fname = 'User::getBlockedStatus';
wfProfileIn($fname);
wfDebug("{$fname}: checking...\n");
$this->mBlockedby = 0;
$ip = wfGetIP();
# User/IP blocking
$block = new Block();
$block->fromMaster(!$bFromSlave);
if ($block->load($ip, $this->mId)) {
wfDebug("{$fname}: Found block.\n");
$this->mBlockedby = $block->mBy;
$this->mBlockreason = $block->mReason;
if ($this->isLoggedIn()) {
$this->spreadBlock();
}
} else {
wfDebug("{$fname}: No block.\n");
}
# Proxy blocking
# FIXME ? proxyunbannable is to deprecate the old isSysop()
if (!$this->isAllowed('proxyunbannable') && !in_array($ip, $wgProxyWhitelist)) {
# Local list
if (wfIsLocallyBlockedProxy($ip)) {
$this->mBlockedby = wfMsg('proxyblocker');
$this->mBlockreason = wfMsg('proxyblockreason');
}
# DNSBL
if (!$this->mBlockedby && $wgEnableSorbs && !$this->getID()) {
if ($this->inSorbsBlacklist($ip)) {
$this->mBlockedby = wfMsg('sorbs');
$this->mBlockreason = wfMsg('sorbsreason');
}
}
}
# Extensions
wfRunHooks('GetBlockedStatus', array(&$this));
wfProfileOut($fname);
}
示例4: getBlockedStatus
/**
* Get blocking information
* @access private
* @param bool $bFromSlave Specify whether to check slave or master. To improve performance,
* non-critical checks are done against slaves. Check when actually saving should be done against
* master.
*
* Note that even if $bFromSlave is false, the check is done first against slave, then master.
* The logic is that if blocked on slave, we'll assume it's either blocked on master or
* just slightly outta sync and soon corrected - safer to block slightly more that less.
* And it's cheaper to check slave first, then master if needed, than master always.
*/
function getBlockedStatus($bFromSlave = true)
{
global $wgIP, $wgBlockCache, $wgProxyList, $wgEnableSorbs, $wgProxyWhitelist;
if (-1 != $this->mBlockedby) {
return;
}
$this->mBlockedby = 0;
# User blocking
if ($this->mId) {
$block = new Block();
$block->forUpdate($bFromSlave);
if ($block->load($wgIP, $this->mId)) {
$this->mBlockedby = $block->mBy;
$this->mBlockreason = $block->mReason;
$this->spreadBlock();
}
}
# IP/range blocking
if (!$this->mBlockedby) {
# Check first against slave, and optionally from master.
$block = $wgBlockCache->get($wgIP, true);
if (!$block && !$bFromSlave) {
# Not blocked: check against master, to make sure.
$wgBlockCache->clearLocal();
$block = $wgBlockCache->get($wgIP, false);
}
if ($block !== false) {
$this->mBlockedby = $block->mBy;
$this->mBlockreason = $block->mReason;
}
}
# Proxy blocking
if (!$this->isSysop() && !in_array($wgIP, $wgProxyWhitelist)) {
# Local list
if (array_key_exists($wgIP, $wgProxyList)) {
$this->mBlockedby = wfMsg('proxyblocker');
$this->mBlockreason = wfMsg('proxyblockreason');
}
# DNSBL
if (!$this->mBlockedby && $wgEnableSorbs && !$this->getID()) {
if ($this->inSorbsBlacklist($wgIP)) {
$this->mBlockedby = wfMsg('sorbs');
$this->mBlockreason = wfMsg('sorbsreason');
}
}
}
}
示例5: getRobotPolicy
/**
* Get the robot policy to be used for the current view
* @param $action String the action= GET parameter
* @return Array the policy that should be set
* TODO: actions other than 'view'
*/
public function getRobotPolicy($action)
{
global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies;
global $wgDefaultRobotPolicy, $wgRequest;
$ns = $this->mTitle->getNamespace();
if ($ns == NS_USER || $ns == NS_USER_TALK) {
# Don't index user and user talk pages for blocked users (bug 11443)
if (!$this->mTitle->isSubpage()) {
$block = new Block();
if ($block->load($this->mTitle->getText())) {
return array('index' => 'noindex', 'follow' => 'nofollow');
}
}
}
if ($this->getID() === 0 || $this->getOldID()) {
# Non-articles (special pages etc), and old revisions
return array('index' => 'noindex', 'follow' => 'nofollow');
} elseif ($wgOut->isPrintable()) {
# Discourage indexing of printable versions, but encourage following
return array('index' => 'noindex', 'follow' => 'follow');
} elseif ($wgRequest->getInt('curid')) {
# For ?curid=x urls, disallow indexing
return array('index' => 'noindex', 'follow' => 'follow');
}
# Otherwise, construct the policy based on the various config variables.
$policy = self::formatRobotPolicy($wgDefaultRobotPolicy);
if (isset($wgNamespaceRobotPolicies[$ns])) {
# Honour customised robot policies for this namespace
$policy = array_merge($policy, self::formatRobotPolicy($wgNamespaceRobotPolicies[$ns]));
}
if ($this->mTitle->canUseNoindex() && is_object($this->mParserOutput) && $this->mParserOutput->getIndexPolicy()) {
# __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
# a final sanity check that we have really got the parser output.
$policy = array_merge($policy, array('index' => $this->mParserOutput->getIndexPolicy()));
}
if (isset($wgArticleRobotPolicies[$this->mTitle->getPrefixedText()])) {
# (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
$policy = array_merge($policy, self::formatRobotPolicy($wgArticleRobotPolicies[$this->mTitle->getPrefixedText()]));
}
return $policy;
}
示例6: Block
function add_block($parent, $type)
{
$page_path = $_POST['page_path'];
PC::page_paths($page_path);
$this->BuilderEngine->set_page_path($page_path);
//$this->blocks->set_page_path($this->blocks->get_page_path_of($parent));
$max_id = $this->blocks->get_max_block_id();
$new_id = $max_id + 1;
$new_block_name = "custom-block-" . $new_id;
$block = new Block($parent);
$block->load();
$new_block = new Block($new_block_name);
$new_block->set_type($type);
if (isset($_POST['data_class']) && $_POST['data_class'] != "") {
$new_block->add_css_class($_POST['data_class']);
}
if ($block->is_global()) {
$new_block->set_global(true);
}
$block->add_block_first($new_block);
$block->save();
$new_block->set_content("Your new block.");
$new_block->show();
}
示例7: Block
function _integrate_builderengine_styles()
{
?>
<script src="<?php
echo home_url("/builderengine/public/js/jquery.js");
?>
"></script>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<link href="http://vitalets.github.io/angular-xeditable/dist/css/xeditable.css" rel="stylesheet" />
<link rel='stylesheet' id='font-awesome-4-css' href="<?php
echo base_url('/builderengine/public/css/font-awesome.css?ver=4.0.3');
?>
" type='text/css' media='all' />
<?php
if (is_installed()) {
?>
<?php
$block = new Block('be_body_styler_' . $this->BuilderEngine->get_option('active_frontend_theme'));
$block->set_global(true);
if (!$block->load()) {
$block->save();
}
?>
<style>
body
{
<?php
echo $block->build_style(true);
?>
}
<?php
}
?>
#virtual-block-holder{
position: absolute;
z-index:999;
}
.area {
position: relative;
display: inline-block;
min-width: 50px;
min-height: 25px;
}
#admin-window {
z-index: 999999 !important;
}
.block-children {
/*min-height: 20px;*/
position:relative;
/*display: inline-block;*/
/*float: left;*/
}
.block {
position: relative;
/*float: left;*/
/*display: inline-block;*/
}
.placeholder {
border: 1px dotted #888;
-webkit-box-shadow: 0px 0px 10px #888;
-moz-box-shadow: 0px 0px 10px #888;
box-shadow: 0px 0px 10px #888;
}
.ui-sortable-placeholder {
border: 2px dotted #333;
-webkit-box-shadow: 0px 0px 10px #888;
-moz-box-shadow: 0px 0px 10px #888;
box-shadow: 0px 0px 10px #888;
visibility: visible !important;
}
</style>
<?php
}
示例8: initialize
public function initialize($db_result)
{
//print_r($db_result);
//echo debug_print_backtrace();
$this->id = $db_result->id;
$this->data = json_decode($db_result->data, true);
$this->global = $db_result->global == 'yes';
$this->type = $db_result->type;
$this->html = $this->data('html');
$this->blocks = array();
foreach ($db_result->children as $child_name) {
$child = new Block($child_name);
$child->load();
$this->add_block($child);
}
}
示例9: newFromDB
function newFromDB($address, $user = 0, $killExpired = true)
{
$ban = new Block();
$ban->load($address, $user, $killExpired);
return $ban;
}
示例10: doUserIPsRequest
/**
* @param string $ip
* @param bool $xfor
* @param string $reason
* Get all IPs used by a user
* Shows first and last date and number of edits
*/
function doUserIPsRequest($user, $reason = '')
{
global $wgOut, $wgTitle, $wgLang, $wgUser, $wgDBname;
$fname = 'CheckUser::doUserIPsRequest';
$userTitle = Title::newFromText($user, NS_USER);
if (!is_null($userTitle)) {
// normalize the username
$user = $userTitle->getText();
}
#IPs are passed in as a blank string
if (!$user) {
$s = wfMsgHtml('nouserspecified');
$wgOut->addHTML($s);
return;
}
#get ID, works better than text as user may have been renamed
$user_id = User::idFromName($user);
#if user is not IP or nonexistant
if (!$user_id) {
$s = wfMsgExt('nosuchusershort', array('parseinline'), $user);
$wgOut->addHTML($s);
return;
}
if (!$this->addLogEntry('userips', 'user', $user, $reason, $user_id)) {
$wgOut->addHTML('<p>' . wfMsgHtml('checkuser-log-fail') . '</p>');
}
$dbr = wfGetDB(DB_SLAVE);
# Ordering by the latest timestamp makes a small filesort on the IP list
$cu_changes = $dbr->tableName('cu_changes');
$use_index = $dbr->useIndexClause('cuc_user_ip_time');
$sql = "SELECT cuc_ip,cuc_ip_hex, COUNT(*) AS count, \n\t\t\tMIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last \n\t\t\tFROM {$cu_changes} {$use_index} WHERE cuc_user = {$user_id} \n\t\t\tGROUP BY cuc_ip ORDER BY last DESC";
$ret = $dbr->query($sql, __METHOD__);
if (!$dbr->numRows($ret)) {
$s = wfMsgHtml("checkuser-nomatch") . "\n";
} else {
$blockip = SpecialPage::getTitleFor('blockip');
$ips_edits = array();
while ($row = $dbr->fetchObject($ret)) {
$ips_edits[$row->cuc_ip] = $row->count;
$ips_first[$row->cuc_ip] = $row->first;
$ips_last[$row->cuc_ip] = $row->last;
$ips_hex[$row->cuc_ip] = $row->cuc_ip_hex;
}
$logs = SpecialPage::getTitleFor('Log');
$blocklist = SpecialPage::getTitleFor('Ipblocklist');
$s = '<ul>';
foreach ($ips_edits as $ip => $edits) {
$s .= '<li>';
$s .= '<a href="' . $wgTitle->escapeLocalURL('user=' . urlencode($ip) . '&reason=' . urlencode($reason)) . '">' . htmlspecialchars($ip) . '</a>';
$s .= ' (<a href="' . $blockip->escapeLocalURL('ip=' . urlencode($ip)) . '">' . wfMsgHtml('blocklink') . '</a>)';
if ($ips_first[$ip] == $ips_last[$ip]) {
$s .= ' (' . $wgLang->timeanddate($ips_first[$ip], true) . ') ';
} else {
$s .= ' (' . $wgLang->timeanddate($ips_first[$ip], true) . ' -- ' . $wgLang->timeanddate($ips_last[$ip], true) . ') ';
}
$s .= ' <strong>[' . $edits . ']</strong>';
# If we get some results, it helps to know if the IP in general
# has a lot more edits, e.g. "tip of the iceberg"...
global $wgMiserMode;
if ($wgMiserMode) {
$ipedits = $dbr->estimateRowCount('cu_changes', '*', array('cuc_ip_hex' => $ips_hex[$ip]), __METHOD__);
} else {
$ipedits = $dbr->selectField('cu_changes', 'COUNT(*)', array('cuc_ip_hex' => $ips_hex[$ip]), __METHOD__);
}
# Kludge a little for estimates...
if (!$wgMiserMode || $ipedits > 1.5 * $ips_edits[$ip]) {
$s .= ' <i>(' . wfMsgHtml('checkuser-ipeditcount', $ipedits) . ')</i>';
}
# If this IP is blocked, give a link to the block log
$block = new Block();
$block->fromMaster(false);
// use slaves
if ($block->load($ip, 0)) {
if (IP::isIPAddress($block->mAddress) && strpos($block->mAddress, '/')) {
$userpage = Title::makeTitle(NS_USER, $block->mAddress);
$blocklog = $this->sk->makeKnownLinkObj($logs, wfMsgHtml('checkuser-blocked'), 'type=block&page=' . urlencode($userpage->getPrefixedText()));
$s .= ' <strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>';
} else {
if ($block->mAuto) {
$blocklog = $this->sk->makeKnownLinkObj($blocklist, wfMsgHtml('checkuser-blocked'), 'ip=' . urlencode("#{$block->mId}"));
$s .= ' <strong>(' . $blocklog . ')</strong>';
} else {
$userpage = Title::makeTitle(NS_USER, $ip);
$blocklog = $this->sk->makeKnownLinkObj($logs, wfMsgHtml('checkuser-blocked'), 'type=block&page=' . urlencode($userpage->getPrefixedText()));
$s .= ' <strong>(' . $blocklog . ')</strong>';
}
}
}
$s .= "</li>\n";
}
$s .= '</ul>';
}
$wgOut->addHTML($s);
//.........这里部分代码省略.........
示例11: get
/**
* Find out if a given IP address is blocked
*
* @param String $ip IP address
* @param bool $bFromSlave True means to load check against slave, else check against master.
*/
function get($ip, $bFromSlave)
{
$this->load($bFromSlave);
$ipint = ip2long($ip);
$blocked = false;
foreach ($this->mData as $networkBits => $blockInts) {
if (array_key_exists($ipint >> 32 - $networkBits, $blockInts)) {
$blocked = true;
break;
}
}
if ($blocked) {
# Clear low order bits
if ($networkBits != 32) {
$ip .= '/' . $networkBits;
$ip = Block::normaliseRange($ip);
}
$block = new Block();
$block->forUpdate($bFromSlave);
$block->load($ip);
} else {
$block = false;
}
return $block;
}
示例12: loadBlocks
public function loadBlocks()
{
// Load the grid
$this->grid = new Grid($this);
$this->setPredefinedTags($this->grid);
if (!is_array($this->instanceBlocks)) {
$this->instanceBlocks = array();
}
// Merge the blocks lists
$blocks = array_merge($this->blocks, $this->userBlocks, $this->instanceBlocks);
// Load the parsed blocks
foreach ($blocks as $blockDef) {
$block = Block::load($this->context, $this, $this->grid, $blockDef['module'], $blockDef['name'], $blockDef['counter'], $blockDef['row'], $blockDef['column'], $blockDef['position'], $blockDef['params']);
if (!is_null($block)) {
$this->setPredefinedTags($block);
$block->set('block_module', $blockDef['module']);
$block->set('block_name', $blockDef['name']);
$block->set('block_row', $blockDef['row']);
$block->set('block_column', $blockDef['column']);
$block->set('block_position', $blockDef['position']);
$block->set('block_counter', $blockDef['counter']);
$this->grid->addBlock($block, $blockDef['row'], $blockDef['column'], $blockDef['position']);
}
}
// Blocks must be properly sorted for the grid loop
$this->grid->sortBlocks();
}
示例13: Block
function add_block($parent, $type)
{
$page_path = $_POST['page_path'];
PC::page_paths($page_path);
$this->BuilderEngine->set_page_path($page_path);
//$this->blocks->set_page_path($this->blocks->get_page_path_of($parent));
$max_id = $this->blocks->get_max_block_id();
$new_id = $max_id + 1;
$new_block_name = "custom-block-" . $new_id;
$block = new Block($parent);
$block->load();
$new_block = new Block($new_block_name);
$new_block->set_type($type);
$block->add_block($new_block);
$block->save();
$new_block->set_content("Your new block.");
$new_block->show();
}
示例14: view
/**
* This is the default action of the script: just view the page of
* the given title.
*/
public function view()
{
global $wgUser, $wgOut, $wgRequest, $wgContLang;
global $wgEnableParserCache, $wgStylePath, $wgParser;
global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies;
global $wgDefaultRobotPolicy;
# Let the parser know if this is the printable version
if ($wgOut->isPrintable()) {
$wgOut->parserOptions()->setIsPrintable(true);
}
wfProfileIn(__METHOD__);
# Get variables from query string
$oldid = $this->getOldID();
# Try client and file cache
if ($oldid === 0 && $this->checkTouched()) {
global $wgUseETag;
if ($wgUseETag) {
$parserCache = ParserCache::singleton();
$wgOut->setETag($parserCache->getETag($this, $wgOut->parserOptions()));
}
# Is is client cached?
if ($wgOut->checkLastModified($this->getTouched())) {
wfProfileOut(__METHOD__);
return;
# Try file cache
} else {
if ($this->tryFileCache()) {
# tell wgOut that output is taken care of
$wgOut->disable();
$this->viewUpdates();
wfProfileOut(__METHOD__);
return;
}
}
}
$ns = $this->mTitle->getNamespace();
# shortcut
$sk = $wgUser->getSkin();
# getOldID may want us to redirect somewhere else
if ($this->mRedirectUrl) {
$wgOut->redirect($this->mRedirectUrl);
wfProfileOut(__METHOD__);
return;
}
$diff = $wgRequest->getVal('diff');
$rcid = $wgRequest->getVal('rcid');
$rdfrom = $wgRequest->getVal('rdfrom');
$diffOnly = $wgRequest->getBool('diffonly', $wgUser->getOption('diffonly'));
$purge = $wgRequest->getVal('action') == 'purge';
$return404 = false;
$wgOut->setArticleFlag(true);
# Discourage indexing of printable versions, but encourage following
if ($wgOut->isPrintable()) {
$policy = 'noindex,follow';
} elseif (isset($wgArticleRobotPolicies[$this->mTitle->getPrefixedText()])) {
$policy = $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()];
} elseif (isset($wgNamespaceRobotPolicies[$ns])) {
# Honour customised robot policies for this namespace
$policy = $wgNamespaceRobotPolicies[$ns];
} else {
$policy = $wgDefaultRobotPolicy;
}
$wgOut->setRobotPolicy($policy);
# Allow admins to see deleted content if explicitly requested
$delId = $diff ? $diff : $oldid;
$unhide = $wgRequest->getInt('unhide') == 1 && $wgUser->matchEditToken($wgRequest->getVal('token'), $delId);
# If we got diff and oldid in the query, we want to see a
# diff page instead of the article.
if (!is_null($diff)) {
$wgOut->setPageTitle($this->mTitle->getPrefixedText());
$htmldiff = $wgRequest->getVal('htmldiff', false);
$de = new DifferenceEngine($this->mTitle, $oldid, $diff, $rcid, $purge, $htmldiff, $unhide);
// DifferenceEngine directly fetched the revision:
$this->mRevIdFetched = $de->mNewid;
$de->showDiffPage($diffOnly);
// Needed to get the page's current revision
$this->loadPageData();
if ($diff == 0 || $diff == $this->mLatest) {
# Run view updates for current revision only
$this->viewUpdates();
}
wfProfileOut(__METHOD__);
return;
}
if ($ns == NS_USER || $ns == NS_USER_TALK) {
# User/User_talk subpages are not modified. (bug 11443)
if (!$this->mTitle->isSubpage()) {
$block = new Block();
if ($block->load($this->mTitle->getBaseText())) {
$wgOut->setRobotpolicy('noindex,nofollow');
}
}
}
# Should the parser cache be used?
$pcache = $this->useParserCache($oldid);
wfDebug('Article::view using parser cache: ' . ($pcache ? 'yes' : 'no') . "\n");
//.........这里部分代码省略.........