当前位置: 首页>>代码示例>>PHP>>正文


PHP Block::parseExpiryInput方法代码示例

本文整理汇总了PHP中Block::parseExpiryInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::parseExpiryInput方法的具体用法?PHP Block::parseExpiryInput怎么用?PHP Block::parseExpiryInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Block的用法示例。


在下文中一共展示了Block::parseExpiryInput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addLogParams

 /**
  * @static
  * @param $result ApiResult
  * @param $vals
  * @param $params
  * @param $type
  * @param $ts
  * @return array
  */
 public static function addLogParams($result, &$vals, $params, $type, $ts)
 {
     $params = explode("\n", $params);
     switch ($type) {
         case 'move':
             if (isset($params[0])) {
                 $title = Title::newFromText($params[0]);
                 if ($title) {
                     $vals2 = array();
                     ApiQueryBase::addTitleInfo($vals2, $title, 'new_');
                     $vals[$type] = $vals2;
                 }
             }
             if (isset($params[1]) && $params[1]) {
                 $vals[$type]['suppressedredirect'] = '';
             }
             $params = null;
             break;
         case 'patrol':
             $vals2 = array();
             list($vals2['cur'], $vals2['prev'], $vals2['auto']) = $params;
             $vals[$type] = $vals2;
             $params = null;
             break;
         case 'rights':
             $vals2 = array();
             list($vals2['old'], $vals2['new']) = $params;
             $vals[$type] = $vals2;
             $params = null;
             break;
         case 'block':
             $vals2 = array();
             list($vals2['duration'], $vals2['flags']) = $params;
             // Indefinite blocks have no expiry time
             if (Block::parseExpiryInput($params[0]) !== Block::infinity()) {
                 $vals2['expiry'] = wfTimestamp(TS_ISO_8601, strtotime($params[0], wfTimestamp(TS_UNIX, $ts)));
             }
             $vals[$type] = $vals2;
             $params = null;
             break;
     }
     if (!is_null($params)) {
         $result->setIndexedTagName($params, 'param');
         $vals = array_merge($vals, $params);
     }
     return $vals;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:56,代码来源:ApiQueryLogEvents.php

示例2: doMassUserBlock

 /**
  * Block a list of selected users
  * @param array $users
  * @param string $reason
  * @param string $tag replaces user pages
  * @param string $talkTag replaces user talk pages
  * @returns array, list of html-safe usernames
  */
 public static function doMassUserBlock($users, $reason = '', $tag = '', $talkTag = '')
 {
     global $wgUser;
     $counter = $blockSize = 0;
     $safeUsers = array();
     $log = new LogPage('block');
     foreach ($users as $name) {
         # Enforce limits
         $counter++;
         $blockSize++;
         # Lets not go *too* fast
         if ($blockSize >= 20) {
             $blockSize = 0;
             wfWaitForSlaves(5);
         }
         $u = User::newFromName($name, false);
         // If user doesn't exist, it ought to be an IP then
         if (is_null($u) || !$u->getId() && !IP::isIPAddress($u->getName())) {
             continue;
         }
         $userTitle = $u->getUserPage();
         $userTalkTitle = $u->getTalkPage();
         $userpage = new Article($userTitle);
         $usertalk = new Article($userTalkTitle);
         $safeUsers[] = '[[' . $userTitle->getPrefixedText() . '|' . $userTitle->getText() . ']]';
         $expirestr = $u->getId() ? 'indefinite' : '1 week';
         $expiry = Block::parseExpiryInput($expirestr);
         $anonOnly = IP::isIPAddress($u->getName()) ? 1 : 0;
         // Create the block
         $block = new Block($u->getName(), $u->getId(), $wgUser->getId(), $reason, wfTimestampNow(), 0, $expiry, $anonOnly, 1, 1, 0, 0);
         $oldblock = Block::newFromDB($u->getName(), $u->getId());
         if (!$oldblock) {
             $block->insert();
             # Prepare log parameters
             $logParams = array();
             $logParams[] = $expirestr;
             if ($anonOnly) {
                 $logParams[] = 'anononly';
             }
             $logParams[] = 'nocreate';
             # Add log entry
             $log->addEntry('block', $userTitle, $reason, $logParams);
         }
         # Tag userpage! (check length to avoid mistakes)
         if (strlen($tag) > 2) {
             $userpage->doEdit($tag, $reason, EDIT_MINOR);
         }
         if (strlen($talkTag) > 2) {
             $usertalk->doEdit($talkTag, $reason, EDIT_MINOR);
         }
     }
     return $safeUsers;
 }
开发者ID:rocLv,项目名称:conference,代码行数:61,代码来源:SpecialBlockip.php

示例3: takeConsequenceAction

 public static function takeConsequenceAction($action, $parameters, $title, $vars, $rule_desc)
 {
     wfLoadExtensionMessages('AbuseFilter');
     $display = '';
     switch ($action) {
         case 'disallow':
             if (strlen($parameters[0])) {
                 $display .= wfMsgExt($parameters[0], 'parseinline', array($rule_desc)) . "\n";
             } else {
                 // Generic message.
                 $display .= wfMsgExt('abusefilter-disallowed', 'parseinline', array($rule_desc)) . "<br />\n";
             }
             break;
         case 'block':
             global $wgUser, $wgAbuseFilterBlockDuration;
             $filterUser = AbuseFilter::getFilterUser();
             // Create a block.
             $block = new Block();
             $block->mAddress = $wgUser->getName();
             $block->mUser = $wgUser->getId();
             $block->mBy = $filterUser->getId();
             $block->mByName = $filterUser->getName();
             $block->mReason = wfMsgForContent('abusefilter-blockreason', $rule_desc);
             $block->mTimestamp = wfTimestampNow();
             $block->mAnonOnly = 1;
             $block->mCreateAccount = 1;
             $block->mExpiry = Block::parseExpiryInput($wgAbuseFilterBlockDuration);
             $block->insert();
             // Log it
             # Prepare log parameters
             $logParams = array();
             if ($block->mExpiry == 'infinity') {
                 $logParams[] = 'indefinite';
             } else {
                 $logParams[] = $wgAbuseFilterBlockDuration;
             }
             $logParams[] = 'nocreate, angry-autoblock';
             $log = new LogPage('block');
             $log->addEntry('block', Title::makeTitle(NS_USER, $wgUser->getName()), wfMsgForContent('abusefilter-blockreason', $rule_desc), $logParams, self::getFilterUser());
             $display .= wfMsgExt('abusefilter-blocked-display', 'parseinline', array($rule_desc)) . "<br />\n";
             break;
         case 'rangeblock':
             global $wgUser;
             $filterUser = AbuseFilter::getFilterUser();
             $range = IP::toHex(wfGetIP());
             $range = substr($range, 0, 4) . '0000';
             $range = long2ip(hexdec($range));
             $range .= '/16';
             $range = Block::normaliseRange($range);
             // Create a block.
             $block = new Block();
             $block->mAddress = $range;
             $block->mUser = 0;
             $block->mBy = $filterUser->getId();
             $block->mByName = $filterUser->getName();
             $block->mReason = wfMsgForContent('abusefilter-blockreason', $rule_desc);
             $block->mTimestamp = wfTimestampNow();
             $block->mAnonOnly = 0;
             $block->mCreateAccount = 1;
             $block->mExpiry = Block::parseExpiryInput('1 week');
             $block->insert();
             // Log it
             # Prepare log parameters
             $logParams = array();
             $logParams[] = 'indefinite';
             $logParams[] = 'nocreate, angry-autoblock';
             $log = new LogPage('block');
             $log->addEntry('block', Title::makeTitle(NS_USER, $range), wfMsgForContent('abusefilter-blockreason', $rule_desc), $logParams, self::getFilterUser());
             $display .= wfMsgExt('abusefilter-blocked-display', 'parseinline', $rule_desc) . "<br />\n";
             break;
         case 'degroup':
             global $wgUser;
             if (!$wgUser->isAnon()) {
                 // Remove all groups from the user. Ouch.
                 $groups = $wgUser->getGroups();
                 foreach ($groups as $group) {
                     $wgUser->removeGroup($group);
                 }
                 $display .= wfMsgExt('abusefilter-degrouped', 'parseinline', array($rule_desc)) . "<br />\n";
                 // Don't log it if there aren't any groups being removed!
                 if (!count($groups)) {
                     break;
                 }
                 // Log it.
                 $log = new LogPage('rights');
                 $log->addEntry('rights', $wgUser->getUserPage(), wfMsgForContent('abusefilter-degroupreason', $rule_desc), array(implode(', ', $groups), wfMsgForContent('rightsnone')), self::getFilterUser());
             }
             break;
         case 'blockautopromote':
             global $wgUser, $wgMemc;
             if (!$wgUser->isAnon()) {
                 $blockPeriod = (int) mt_rand(3 * 86400, 7 * 86400);
                 // Block for 3-7 days.
                 $wgMemc->set(self::autoPromoteBlockKey($wgUser), true, $blockPeriod);
                 $display .= wfMsgExt('abusefilter-autopromote-blocked', 'parseinline', array($rule_desc)) . "<br />\n";
             }
             break;
         case 'flag':
             // Do nothing. Here for completeness.
             break;
//.........这里部分代码省略.........
开发者ID:ErdemA,项目名称:wikihow,代码行数:101,代码来源:AbuseFilter.class.php


注:本文中的Block::parseExpiryInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。