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


PHP wfBaseConvert函数代码示例

本文整理汇总了PHP中wfBaseConvert函数的典型用法代码示例。如果您正苦于以下问题:PHP wfBaseConvert函数的具体用法?PHP wfBaseConvert怎么用?PHP wfBaseConvert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testTimestampedUID

 /**
  * @dataProvider provider_testTimestampedUID
  */
 public function testTimestampedUID($method, $digitlen, $bits, $tbits, $hostbits)
 {
     $id = call_user_func(array('UIDGenerator', $method));
     $this->assertEquals(true, ctype_digit($id), "UID made of digit characters");
     $this->assertLessThanOrEqual($digitlen, strlen($id), "UID has the right number of digits");
     $this->assertLessThanOrEqual($bits, strlen(wfBaseConvert($id, 10, 2)), "UID has the right number of bits");
     $ids = array();
     for ($i = 0; $i < 300; $i++) {
         $ids[] = call_user_func(array('UIDGenerator', $method));
     }
     $lastId = array_shift($ids);
     if ($hostbits) {
         $lastHost = substr(wfBaseConvert($lastId, 10, 2, $bits), -$hostbits);
     }
     $this->assertArrayEquals(array_unique($ids), $ids, "All generated IDs are unique.");
     foreach ($ids as $id) {
         $id_bin = wfBaseConvert($id, 10, 2);
         $lastId_bin = wfBaseConvert($lastId, 10, 2);
         $this->assertGreaterThanOrEqual(substr($id_bin, 0, $tbits), substr($lastId_bin, 0, $tbits), "New ID timestamp ({$id_bin}) >= prior one ({$lastId_bin}).");
         if ($hostbits) {
             $this->assertEquals(substr($id_bin, 0, -$hostbits), substr($lastId_bin, 0, -$hostbits), "Host ID of ({$id_bin}) is same as prior one ({$lastId_bin}).");
         }
         $lastId = $id;
     }
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:28,代码来源:UIDGeneratorTest.php

示例2: getTimestampedUUID

 /**
  * Get a statistically unique ID string
  *
  * @return string <9 char TS_MW timestamp in base 36><22 random base 36 chars>
  */
 public final function getTimestampedUUID()
 {
     $s = '';
     for ($i = 0; $i < 5; $i++) {
         $s .= mt_rand(0, 2147483647);
     }
     $s = wfBaseConvert(sha1($s), 16, 36, 31);
     return substr(wfBaseConvert(wfTimestamp(TS_MW), 10, 36, 9) . $s, 0, 31);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:14,代码来源:FileJournal.php

示例3: uuidConversionProvider

 public static function uuidConversionProvider()
 {
     $dbr = wfGetDB(DB_SLAVE);
     // sample uuid from UIDGenerator::newTimestampedUID128()
     $numeric_128 = '6709199728898751234959525538795913762';
     $hex_128 = wfBaseConvert($numeric_128, 10, 16, 32);
     $bin_128 = new UUIDBlob(pack('H*', $hex_128));
     $pretty_128 = wfBaseConvert($numeric_128, 10, 36);
     // Conversion from 128 bit to 88 bit takes the left
     // most 88 bits.
     $bits_88 = substr(wfBaseConvert($numeric_128, 10, 2, 128), 0, 88);
     $numeric_88 = wfBaseConvert($bits_88, 2, 10);
     $hex_88 = wfBaseConvert($numeric_88, 10, 16, 22);
     $bin_88 = new UUIDBlob(pack('H*', $hex_88));
     $pretty_88 = wfBaseConvert($numeric_88, 10, 36);
     return array(array('128 bit hex input must be truncated to 88bit output', $hex_128, $bin_88, $hex_88, $pretty_88), array('88 bit binary input', $bin_88, $bin_88, $hex_88, $pretty_88), array('88 bit numeric input', $numeric_88, $bin_88, $hex_88, $pretty_88), array('88 bit hex input', $hex_88, $bin_88, $hex_88, $pretty_88), array('88 bit pretty input', $pretty_88, $bin_88, $hex_88, $pretty_88));
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:17,代码来源:UUIDTest.php

示例4: store

 /**
  * @see ExternalStoreMedium::store()
  */
 public function store($backend, $data)
 {
     $be = FileBackendGroup::singleton()->get($backend);
     if ($be instanceof FileBackend) {
         // Get three random base 36 characters to act as shard directories
         $rand = wfBaseConvert(mt_rand(0, 46655), 10, 36, 3);
         // Make sure ID is roughly lexicographically increasing for performance
         $id = str_pad(UIDGenerator::newTimestampedUID128(32), 26, '0', STR_PAD_LEFT);
         // Segregate items by wiki ID for the sake of bookkeeping
         $wiki = isset($this->params['wiki']) ? $this->params['wiki'] : wfWikiID();
         $url = $be->getContainerStoragePath('data') . '/' . rawurlencode($wiki) . "/{$rand[0]}/{$rand[1]}/{$rand[2]}/{$id}";
         $be->prepare(array('dir' => dirname($url), 'noAccess' => 1, 'noListing' => 1));
         if ($be->create(array('dst' => $url, 'content' => $data))->isOK()) {
             return $url;
         }
     }
     return false;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:21,代码来源:ExternalStoreMwstore.php

示例5: __construct

 /**
  * Construct a new instance from configuration.
  * 
  * $config paramaters include:
  *     'lockServers'  : Associative array of server names to configuration.
  *                      Configuration is an associative array that includes:
  *                      'host'    - IP address/hostname
  *                      'port'    - TCP port
  *                      'authKey' - Secret string the lock server uses
  *     'srvsByBucket' : Array of 1-16 consecutive integer keys, starting from 0,
  *                      each having an odd-numbered list of server names (peers) as values.
  *     'connTimeout'  : Lock server connection attempt timeout. [optional]
  *
  * @param Array $config 
  */
 public function __construct(array $config)
 {
     $this->lockServers = $config['lockServers'];
     // Sanitize srvsByBucket config to prevent PHP errors
     $this->srvsByBucket = array_filter($config['srvsByBucket'], 'is_array');
     $this->srvsByBucket = array_values($this->srvsByBucket);
     // consecutive
     if (isset($config['connTimeout'])) {
         $this->connTimeout = $config['connTimeout'];
     } else {
         $this->connTimeout = 3;
         // use some sane amount
     }
     $this->session = '';
     for ($i = 0; $i < 5; $i++) {
         $this->session .= mt_rand(0, 2147483647);
     }
     $this->session = wfBaseConvert(sha1($this->session), 16, 36, 31);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:34,代码来源:LSLockManager.php

示例6: hashToSessionId

 /**
  * Hash data as a session ID
  *
  * Generally this will only be used when self::persistsSessionId() is false and
  * the provider has to base the session ID on the verified user's identity
  * or other static data.
  *
  * @param string $data
  * @param string|null $key Defaults to $this->config->get( 'SecretKey' )
  * @return string
  */
 protected final function hashToSessionId($data, $key = null)
 {
     if (!is_string($data)) {
         throw new \InvalidArgumentException('$data must be a string, ' . gettype($data) . ' was passed');
     }
     if ($key !== null && !is_string($key)) {
         throw new \InvalidArgumentException('$key must be a string or null, ' . gettype($key) . ' was passed');
     }
     $hash = \MWCryptHash::hmac("{$this}\n{$data}", $key ?: $this->config->get('SecretKey'), false);
     if (strlen($hash) < 32) {
         // Should never happen, even md5 is 128 bits
         // @codeCoverageIgnoreStart
         throw new \UnexpectedValueException('Hash fuction returned less than 128 bits');
         // @codeCoverageIgnoreEnd
     }
     if (strlen($hash) >= 40) {
         $hash = wfBaseConvert($hash, 16, 32, 32);
     }
     return substr($hash, -32);
 }
开发者ID:Gomyul,项目名称:mediawiki,代码行数:31,代码来源:SessionProvider.php

示例7: stashFile

 /**
  * Stash a file in a temp directory and record that we did this in the database, along with other metadata.
  *
  * @param $path String: path to file you want stashed
  * @param $sourceType String: the type of upload that generated this file (currently, I believe, 'file' or null)
  * @param $key String: optional, unique key for this file. Used for directory hashing when storing, otherwise not important
  * @throws UploadStashBadPathException
  * @throws UploadStashFileException
  * @throws UploadStashNotLoggedInException
  * @return UploadStashFile: file, or null on failure
  */
 public function stashFile($path, $sourceType = null, $key = null)
 {
     if (!file_exists($path)) {
         wfDebug(__METHOD__ . " tried to stash file at '{$path}', but it doesn't exist\n");
         throw new UploadStashBadPathException("path doesn't exist");
     }
     $fileProps = File::getPropsFromPath($path);
     wfDebug(__METHOD__ . " stashing file at '{$path}'\n");
     // we will be initializing from some tmpnam files that don't have extensions.
     // most of MediaWiki assumes all uploaded files have good extensions. So, we fix this.
     $extension = self::getExtensionForPath($path);
     if (!preg_match("/\\.\\Q{$extension}\\E\$/", $path)) {
         $pathWithGoodExtension = "{$path}.{$extension}";
         if (!rename($path, $pathWithGoodExtension)) {
             throw new UploadStashFileException("couldn't rename {$path} to have a better extension at {$pathWithGoodExtension}");
         }
         $path = $pathWithGoodExtension;
     }
     // If no key was supplied, make one.  a mysql insertid would be totally reasonable here, except
     // that some users of this function might expect to supply the key instead of using the generated one.
     if (is_null($key)) {
         // some things that when combined will make a suitably unique key.
         // see: http://www.jwz.org/doc/mid.html
         list($usec, $sec) = explode(' ', microtime());
         $usec = substr($usec, 2);
         $key = wfBaseConvert($sec . $usec, 10, 36) . '.' . wfBaseConvert(mt_rand(), 10, 36) . '.' . $this->userId . '.' . $extension;
     }
     $this->fileProps[$key] = $fileProps;
     if (!preg_match(self::KEY_FORMAT_REGEX, $key)) {
         throw new UploadStashBadPathException("key '{$key}' is not in a proper format");
     }
     wfDebug(__METHOD__ . " key for '{$path}': {$key}\n");
     // if not already in a temporary area, put it there
     $storeStatus = $this->repo->storeTemp(basename($path), $path);
     if (!$storeStatus->isOK()) {
         // It is a convention in MediaWiki to only return one error per API exception, even if multiple errors
         // are available. We use reset() to pick the "first" thing that was wrong, preferring errors to warnings.
         // This is a bit lame, as we may have more info in the $storeStatus and we're throwing it away, but to fix it means
         // redesigning API errors significantly.
         // $storeStatus->value just contains the virtual URL (if anything) which is probably useless to the caller
         $error = $storeStatus->getErrorsArray();
         $error = reset($error);
         if (!count($error)) {
             $error = $storeStatus->getWarningsArray();
             $error = reset($error);
             if (!count($error)) {
                 $error = array('unknown', 'no error recorded');
             }
         }
         throw new UploadStashFileException("error storing file in '{$path}': " . implode('; ', $error));
     }
     $stashPath = $storeStatus->value;
     // fetch the current user ID
     if (!$this->isLoggedIn) {
         throw new UploadStashNotLoggedInException(__METHOD__ . ' No user is logged in, files must belong to users');
     }
     // insert the file metadata into the db.
     wfDebug(__METHOD__ . " inserting {$stashPath} under {$key}\n");
     $dbw = $this->repo->getMasterDb();
     // select happens on the master so this can all be in a transaction, which
     // avoids a race condition that's likely with multiple people uploading from the same
     // set of files
     $dbw->begin();
     // first, check to see if it's already there.
     $row = $dbw->selectRow('uploadstash', 'us_user, us_timestamp', array('us_key' => $key), __METHOD__);
     // The current user can't have this key if:
     // - the key is owned by someone else and
     // - the age of the key is less than REPO_AGE
     if (is_object($row)) {
         if ($row->us_user != $this->userId && $row->wfTimestamp(TS_UNIX, $row->us_timestamp) > time() - UploadStash::REPO_AGE * 3600) {
             $dbw->rollback();
             throw new UploadStashWrongOwnerException("Attempting to upload a duplicate of a file that someone else has stashed");
         }
     }
     $this->fileMetadata[$key] = array('us_user' => $this->userId, 'us_key' => $key, 'us_orig_path' => $path, 'us_path' => $stashPath, 'us_size' => $fileProps['size'], 'us_sha1' => $fileProps['sha1'], 'us_mime' => $fileProps['mime'], 'us_media_type' => $fileProps['media_type'], 'us_image_width' => $fileProps['width'], 'us_image_height' => $fileProps['height'], 'us_image_bits' => $fileProps['bits'], 'us_source_type' => $sourceType, 'us_timestamp' => $dbw->timestamp(), 'us_status' => 'finished');
     // if a row exists but previous checks on it passed, let the current user take over this key.
     $dbw->replace('uploadstash', 'us_key', $this->fileMetadata[$key], __METHOD__);
     $dbw->commit();
     // store the insertid in the class variable so immediate retrieval (possibly laggy) isn't necesary.
     $this->fileMetadata[$key]['us_id'] = $dbw->insertId();
     # create the UploadStashFile object for this file.
     $this->initFile($key);
     return $this->getFile($key);
 }
开发者ID:natalieschauser,项目名称:csp_media_wiki,代码行数:95,代码来源:UploadStash.php

示例8: getSha1

 /**
  * @return bool|string
  */
 function getSha1()
 {
     if ($this->sha1base36) {
         return wfBaseConvert($this->sha1base36, 36, 16);
     }
     return false;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:10,代码来源:Import.php

示例9: getInfo


//.........这里部分代码省略.........
             }
         }
     }
     $canonicaltitle = isset($prop['canonicaltitle']);
     $url = isset($prop['url']);
     $sha1 = isset($prop['sha1']);
     $meta = isset($prop['metadata']);
     $extmetadata = isset($prop['extmetadata']);
     $commonmeta = isset($prop['commonmetadata']);
     $mime = isset($prop['mime']);
     $mediatype = isset($prop['mediatype']);
     $archive = isset($prop['archivename']);
     $bitdepth = isset($prop['bitdepth']);
     $uploadwarning = isset($prop['uploadwarning']);
     if ($uploadwarning) {
         $vals['html'] = SpecialUpload::getExistsWarning(UploadBase::getExistsWarning($file));
     }
     if ($file->isDeleted(File::DELETED_FILE)) {
         $vals['filehidden'] = true;
         $anyHidden = true;
     }
     if ($anyHidden && $file->isDeleted(File::DELETED_RESTRICTED)) {
         $vals['suppressed'] = true;
     }
     if (!$canShowField(File::DELETED_FILE)) {
         //Early return, tidier than indenting all following things one level
         return $vals;
     }
     if ($canonicaltitle) {
         $vals['canonicaltitle'] = $file->getTitle()->getPrefixedText();
     }
     if ($url) {
         if (!is_null($thumbParams)) {
             $mto = $file->transform($thumbParams);
             self::$transformCount++;
             if ($mto && !$mto->isError()) {
                 $vals['thumburl'] = wfExpandUrl($mto->getUrl(), PROTO_CURRENT);
                 // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
                 // thumbnail sizes for the thumbnail actual size
                 if ($mto->getUrl() !== $file->getUrl()) {
                     $vals['thumbwidth'] = intval($mto->getWidth());
                     $vals['thumbheight'] = intval($mto->getHeight());
                 } else {
                     $vals['thumbwidth'] = intval($file->getWidth());
                     $vals['thumbheight'] = intval($file->getHeight());
                 }
                 if (isset($prop['thumbmime']) && $file->getHandler()) {
                     list(, $mime) = $file->getHandler()->getThumbType($mto->getExtension(), $file->getMimeType(), $thumbParams);
                     $vals['thumbmime'] = $mime;
                 }
             } elseif ($mto && $mto->isError()) {
                 $vals['thumberror'] = $mto->toText();
             }
         }
         $vals['url'] = wfExpandUrl($file->getFullURL(), PROTO_CURRENT);
         $vals['descriptionurl'] = wfExpandUrl($file->getDescriptionUrl(), PROTO_CURRENT);
     }
     if ($sha1) {
         $vals['sha1'] = wfBaseConvert($file->getSha1(), 36, 16, 40);
     }
     if ($meta) {
         wfSuppressWarnings();
         $metadata = unserialize($file->getMetadata());
         wfRestoreWarnings();
         if ($metadata && $version !== 'latest') {
             $metadata = $file->convertMetadataVersion($metadata, $version);
         }
         $vals['metadata'] = $metadata ? self::processMetaData($metadata, $result) : null;
     }
     if ($commonmeta) {
         $metaArray = $file->getCommonMetaArray();
         $vals['commonmetadata'] = $metaArray ? self::processMetaData($metaArray, $result) : array();
     }
     if ($extmetadata) {
         // Note, this should return an array where all the keys
         // start with a letter, and all the values are strings.
         // Thus there should be no issue with format=xml.
         $format = new FormatMetadata();
         $format->setSingleLanguage(!$opts['multilang']);
         $format->getContext()->setLanguage($opts['language']);
         $extmetaArray = $format->fetchExtendedMetadata($file);
         if ($opts['extmetadatafilter']) {
             $extmetaArray = array_intersect_key($extmetaArray, array_flip($opts['extmetadatafilter']));
         }
         $vals['extmetadata'] = $extmetaArray;
     }
     if ($mime) {
         $vals['mime'] = $file->getMimeType();
     }
     if ($mediatype) {
         $vals['mediatype'] = $file->getMediaType();
     }
     if ($archive && $file->isOld()) {
         $vals['archivename'] = $file->getArchiveName();
     }
     if ($bitdepth) {
         $vals['bitdepth'] = $file->getBitDepth();
     }
     return $vals;
 }
开发者ID:sukesan1984,项目名称:agrarian-wiki,代码行数:101,代码来源:ApiQueryImageInfo.php

示例10: randomPassword

 /**
  * Return a random password.
  *
  * @return String new random password
  */
 public static function randomPassword()
 {
     global $wgMinimalPasswordLength;
     // Decide the final password length based on our min password length, stopping at a minimum of 10 chars
     $length = max(10, $wgMinimalPasswordLength);
     // Multiply by 1.25 to get the number of hex characters we need
     $length = $length * 1.25;
     // Generate random hex chars
     $hex = MWCryptRand::generateHex($length);
     // Convert from base 16 to base 32 to get a proper password like string
     return wfBaseConvert($hex, 16, 32);
 }
开发者ID:slackfaith,项目名称:deadbrain_site,代码行数:17,代码来源:User.php

示例11: doStoreInternal

 /**
  * @see FileBackendStore::doStoreInternal()
  */
 protected function doStoreInternal(array $params)
 {
     $status = Status::newGood();
     list($dstCont, $dstRel) = $this->resolveStoragePathReal($params['dst']);
     if ($dstRel === null) {
         $status->fatal('backend-fail-invalidpath', $params['dst']);
         return $status;
     }
     // (a) Check the destination container and object
     try {
         unset($this->objCache[$params['dst']]);
         $dContObj = $this->getContainer($dstCont);
         if (empty($params['overwrite']) && $this->fileExists(array('src' => $params['dst'], 'latest' => 1))) {
             $status->fatal('backend-fail-alreadyexists', $params['dst']);
             return $status;
         }
     } catch (NoSuchContainerException $e) {
         $status->fatal('backend-fail-copy', $params['src'], $params['dst']);
         $this->logException($e, __METHOD__, $params);
         return $status;
     } catch (InvalidResponseException $e) {
         $status->fatal('backend-fail-connect', $this->name);
         $this->logException($e, __METHOD__, $params);
         return $status;
     } catch (Exception $e) {
         // some other exception?
         $status->fatal('backend-fail-internal', $this->name);
         $this->logException($e, __METHOD__, $params);
         return $status;
     }
     // (b) Get a SHA-1 hash of the object
     $sha1Hash = sha1_file($params['src']);
     if ($sha1Hash === false) {
         // source doesn't exist?
         $status->fatal('backend-fail-copy', $params['src'], $params['dst']);
         return $status;
     }
     $sha1Hash = wfBaseConvert($sha1Hash, 16, 36, 31);
     // (c) Actually store the object
     try {
         // Create a fresh CF_Object with no fields preloaded.
         // We don't want to preserve headers, metadata, and such.
         $obj = new CF_Object($dContObj, $dstRel, false, false);
         // skip HEAD
         // Note: metadata keys stored as [Upper case char][[Lower case char]...]
         $obj->metadata = array('Sha1base36' => $sha1Hash);
         // The MD5 here will be checked within Swift against its own MD5.
         $obj->set_etag(md5_file($params['src']));
         // Use the same content type as StreamFile for security
         $obj->content_type = $this->getFileProps($params)['mime'];
         // Wikia cnange: use the same logic as for DB row (BAC-1199)
         // Actually write the object in Swift
         $obj->load_from_filename($params['src'], True);
         // calls $obj->write()
     } catch (BadContentTypeException $e) {
         $status->fatal('backend-fail-contenttype', $params['dst']);
         $this->logException($e, __METHOD__, $params);
     } catch (IOException $e) {
         $status->fatal('backend-fail-copy', $params['src'], $params['dst']);
         $this->logException($e, __METHOD__, $params);
     } catch (InvalidResponseException $e) {
         $status->fatal('backend-fail-connect', $this->name);
         $this->logException($e, __METHOD__, $params);
     } catch (Exception $e) {
         // some other exception?
         $status->fatal('backend-fail-internal', $this->name);
         $this->logException($e, __METHOD__, $params);
     }
     wfRunHooks('SwiftFileBackend::doStoreInternal', array($params, &$status));
     return $status;
 }
开发者ID:yusufchang,项目名称:app,代码行数:74,代码来源:SwiftFileBackend.php

示例12: getSha1

 /**
  * @return null|string
  */
 function getSha1()
 {
     return isset($this->mInfo['sha1']) ? wfBaseConvert(strval($this->mInfo['sha1']), 16, 36, 31) : null;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:7,代码来源:ForeignAPIFile.php

示例13: millisecondsSinceEpochBinary

 /**
  * @param array $time Result of UIDGenerator::millitime()
  * @return string 46 MSBs of "milliseconds since epoch" in binary (rolls over in 4201)
  * @throws MWException
  */
 protected function millisecondsSinceEpochBinary(array $time)
 {
     list($sec, $msec) = $time;
     $ts = 1000 * $sec + $msec;
     if ($ts > pow(2, 52)) {
         throw new MWException(__METHOD__ . ': sorry, this function doesn\'t work after the year 144680');
     }
     return substr(wfBaseConvert($ts, 10, 2, 46), -46);
 }
开发者ID:huatuoorg,项目名称:mediawiki,代码行数:14,代码来源:UIDGenerator.php

示例14: getSourceSha1Base36

 protected function getSourceSha1Base36()
 {
     return wfBaseConvert(sha1($this->params['content']), 16, 36, 31);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:4,代码来源:FileOp.php

示例15: doIPUsersRequest

 /**
  * @param string $ip
  * @param bool $xfor
  * @param string $reason
  * @param int $period
  * @param string $tag
  * @param string $talkTag
  * Lists all users in recent changes who used an IP, newest to oldest down
  * Outputs usernames, latest and earliest found edit date, and count
  * List unique IPs used for each user in time order, list corresponding user agent
  */
 protected function doIPUsersRequest($ip, $xfor = false, $reason = '', $period = 0, $tag = '', $talkTag = '')
 {
     global $wgUser, $wgOut, $wgLang;
     $dbr = wfGetDB(DB_SLAVE);
     # Invalid IPs are passed in as a blank string
     $ip_conds = self::getIpConds($dbr, $ip, $xfor);
     if (!$ip || $ip_conds === false) {
         $wgOut->addWikiMsg('badipaddress');
         return;
     }
     $logType = 'ipusers';
     if ($xfor) {
         $logType .= '-xff';
     }
     # Log the check...
     if (!self::addLogEntry($logType, 'ip', $ip, $reason)) {
         $wgOut->addHTML('<p>' . wfMsgHtml('checkuser-log-fail') . '</p>');
     }
     $ip_conds = $dbr->makeList($ip_conds, LIST_AND);
     $time_conds = $this->getTimeConds($period);
     $index = $xfor ? 'cuc_xff_hex_time' : 'cuc_ip_hex_time';
     # Ordered in descent by timestamp. Can cause large filesorts on range scans.
     # Check how many rows will need sorting ahead of time to see if this is too big.
     if (strpos($ip, '/') !== false) {
         # Quick index check only OK if no time constraint
         if ($period) {
             $rangecount = $dbr->selectField('cu_changes', 'COUNT(*)', array($ip_conds, $time_conds), __METHOD__, array('USE INDEX' => $index));
         } else {
             $rangecount = $dbr->estimateRowCount('cu_changes', '*', array($ip_conds), __METHOD__, array('USE INDEX' => $index));
         }
         // Sorting might take some time...make sure it is there
         wfSuppressWarnings();
         set_time_limit(120);
         wfRestoreWarnings();
     }
     // Are there too many edits?
     if (isset($rangecount) && $rangecount > 10000) {
         $ret = $dbr->select('cu_changes', array('cuc_ip_hex', 'COUNT(*) AS count', 'MIN(cuc_timestamp) AS first', 'MAX(cuc_timestamp) AS last'), array($ip_conds, $time_conds), __METHOD__, array('GROUP BY' => 'cuc_ip_hex', 'ORDER BY' => 'cuc_ip_hex', 'LIMIT' => 5001, 'USE INDEX' => $index));
         # List out each IP that has edits
         $s = '<h5>' . wfMsg('checkuser-too-many') . '</h5>';
         $s .= '<ol>';
         $counter = 0;
         foreach ($ret as $row) {
             if ($counter >= 5000) {
                 $wgOut->addHTML(wfMsgExt('checkuser-limited', array('parse')));
                 break;
             }
             # Convert the IP hexes into normal form
             if (strpos($row->cuc_ip_hex, 'v6-') !== false) {
                 $ip = substr($row->cuc_ip_hex, 3);
                 $ip = IP::HextoOctet($ip);
             } else {
                 $ip = long2ip(wfBaseConvert($row->cuc_ip_hex, 16, 10, 8));
             }
             $s .= '<li><a href="' . $this->getTitle()->escapeLocalURL('user=' . urlencode($ip) . '&reason=' . urlencode($reason) . '&checktype=subipusers') . '">' . $ip . '</a>';
             if ($row->first == $row->last) {
                 $s .= ' (' . $wgLang->timeanddate(wfTimestamp(TS_MW, $row->first), true) . ') ';
             } else {
                 $s .= ' (' . $wgLang->timeanddate(wfTimestamp(TS_MW, $row->first), true) . ' -- ' . $wgLang->timeanddate(wfTimestamp(TS_MW, $row->last), true) . ') ';
             }
             $s .= ' [<strong>' . $row->count . "</strong>]</li>\n";
             ++$counter;
         }
         $s .= '</ol>';
         $wgOut->addHTML($s);
         return;
     } elseif (isset($rangecount) && !$rangecount) {
         $s = $this->noMatchesMessage($ip, !$xfor) . "\n";
         $wgOut->addHTML($s);
         return;
     }
     global $wgMemc;
     # OK, do the real query...
     $ret = $dbr->select('cu_changes', array('cuc_user_text', 'cuc_timestamp', 'cuc_user', 'cuc_ip', 'cuc_agent', 'cuc_xff'), array($ip_conds, $time_conds), __METHOD__, array('ORDER BY' => 'cuc_timestamp DESC', 'LIMIT' => 10000, 'USE INDEX' => $index));
     $users_first = $users_last = $users_edits = $users_ids = array();
     if (!$dbr->numRows($ret)) {
         $s = $this->noMatchesMessage($ip, !$xfor) . "\n";
     } else {
         global $wgAuth;
         foreach ($ret as $row) {
             if (!array_key_exists($row->cuc_user_text, $users_edits)) {
                 $users_last[$row->cuc_user_text] = $row->cuc_timestamp;
                 $users_edits[$row->cuc_user_text] = 0;
                 $users_ids[$row->cuc_user_text] = $row->cuc_user;
                 $users_infosets[$row->cuc_user_text] = array();
                 $users_agentsets[$row->cuc_user_text] = array();
             }
             $users_edits[$row->cuc_user_text] += 1;
             $users_first[$row->cuc_user_text] = $row->cuc_timestamp;
//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:CheckUser_body.php


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