本文整理汇总了PHP中wfParseUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP wfParseUrl函数的具体用法?PHP wfParseUrl怎么用?PHP wfParseUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfParseUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
if (!$this->getUser()->isLoggedIn()) {
$this->dieUsage('Must be logged in to link accounts', 'notloggedin');
}
$params = $this->extractRequestParams();
$this->requireAtLeastOneParameter($params, 'continue', 'returnurl');
if ($params['returnurl'] !== null) {
$bits = wfParseUrl($params['returnurl']);
if (!$bits || $bits['scheme'] === '') {
$encParamName = $this->encodeParamName('returnurl');
$this->dieUsage("Invalid value '{$params['returnurl']}' for url parameter {$encParamName}", "badurl_{$encParamName}");
}
}
$helper = new ApiAuthManagerHelper($this);
$manager = AuthManager::singleton();
// Check security-sensitive operation status
$helper->securitySensitiveOperation('LinkAccounts');
// Make sure it's possible to link accounts
if (!$manager->canLinkAccounts()) {
$this->getResult()->addValue(null, 'linkaccount', $helper->formatAuthenticationResponse(AuthenticationResponse::newFail($this->msg('userlogin-cannot-' . AuthManager::ACTION_LINK))));
return;
}
// Perform the link step
if ($params['continue']) {
$reqs = $helper->loadAuthenticationRequests(AuthManager::ACTION_LINK_CONTINUE);
$res = $manager->continueAccountLink($reqs);
} else {
$reqs = $helper->loadAuthenticationRequests(AuthManager::ACTION_LINK);
$res = $manager->beginAccountLink($this->getUser(), $reqs, $params['returnurl']);
}
$this->getResult()->addValue(null, 'linkaccount', $helper->formatAuthenticationResponse($res));
}
示例2: checkContactLink
protected function checkContactLink($name, $url, &$countOk)
{
global $wgVersion;
$ok = false;
if (Sanitizer::validateEmail($url)) {
$ok = true;
// assume OK
} else {
$bits = wfParseUrl($url);
if ($bits && isset($bits['scheme'])) {
if ($bits['scheme'] == 'mailto') {
$ok = true;
// assume OK
} elseif (in_array($bits['scheme'], array('http', 'https'))) {
$req = MWHttpRequest::factory($url, array('method' => 'GET', 'timeout' => 8, 'sslVerifyHost' => false, 'sslVerifyCert' => false));
$req->setUserAgent("MediaWiki {$wgVersion}, CheckCongressLinks Checker");
$ok = $req->execute()->isOK();
}
}
}
if ($ok) {
++$countOk;
} else {
$this->output("Broken: [{$name}] [{$url}]\n");
}
}
示例3: send
/**
* @see RCFeedEngine::send
*/
public function send(array $feed, $line)
{
$parsed = wfParseUrl($feed['uri']);
$server = $parsed['host'];
$options = ['serializer' => 'none'];
$channel = 'rc';
if (isset($parsed['port'])) {
$server .= ":{$parsed['port']}";
}
if (isset($parsed['query'])) {
parse_str($parsed['query'], $options);
}
if (isset($parsed['pass'])) {
$options['password'] = $parsed['pass'];
}
if (isset($parsed['path'])) {
$channel = str_replace('/', '.', ltrim($parsed['path'], '/'));
}
$pool = RedisConnectionPool::singleton($options);
$conn = $pool->getConnection($server);
if ($conn !== false) {
$conn->publish($channel, $line);
return true;
} else {
return false;
}
}
示例4: determineLocalServerType
/**
* Determine whether this server is configured as the priority or normal server
*
* If this is neither the priority nor normal server, assumes 'local' - meaning
* this server should be handling the request.
*/
public function determineLocalServerType()
{
global $wgServer, $wgLandingCheckPriorityURLBase, $wgLandingCheckNormalURLBase;
$localServerDetails = wfParseUrl($wgServer);
// The following checks are necessary due to a bug in wfParseUrl that was fixed in r94352.
if ($wgLandingCheckPriorityURLBase) {
$priorityServerDetails = wfParseUrl($wgLandingCheckPriorityURLBase);
} else {
$priorityServerDetails = false;
}
if ($wgLandingCheckNormalURLBase) {
$normalServerDetails = wfParseUrl($wgLandingCheckNormalURLBase);
} else {
$normalServerDetails = false;
}
//$priorityServerDetails = wfParseUrl( $wgLandingCheckPriorityURLBase );
//$normalServerDetails = wfParseUrl( $wgLandingCheckNormalURLBase );
if ($localServerDetails['host'] == $priorityServerDetails['host']) {
return 'priority';
} elseif ($localServerDetails['host'] == $normalServerDetails['host']) {
return 'normal';
} else {
return 'local';
}
}
示例5: provideURLParts
/**
* Provider of URL parts for testing wfAssembleUrl()
*
* @return array
*/
public static function provideURLParts()
{
$schemes = array('' => array(), '//' => array('delimiter' => '//'), 'http://' => array('scheme' => 'http', 'delimiter' => '://'));
$hosts = array('' => array(), 'example.com' => array('host' => 'example.com'), 'example.com:123' => array('host' => 'example.com', 'port' => 123), 'id@example.com' => array('user' => 'id', 'host' => 'example.com'), 'id@example.com:123' => array('user' => 'id', 'host' => 'example.com', 'port' => 123), 'id:key@example.com' => array('user' => 'id', 'pass' => 'key', 'host' => 'example.com'), 'id:key@example.com:123' => array('user' => 'id', 'pass' => 'key', 'host' => 'example.com', 'port' => 123));
$cases = array();
foreach ($schemes as $scheme => $schemeParts) {
foreach ($hosts as $host => $hostParts) {
foreach (array('', '/path') as $path) {
foreach (array('', 'query') as $query) {
foreach (array('', 'fragment') as $fragment) {
$parts = array_merge($schemeParts, $hostParts);
$url = $scheme . $host . $path;
if ($path) {
$parts['path'] = $path;
}
if ($query) {
$parts['query'] = $query;
$url .= '?' . $query;
}
if ($fragment) {
$parts['fragment'] = $fragment;
$url .= '#' . $fragment;
}
$cases[] = array($parts, $url);
}
}
}
}
}
$complexURL = 'http://id:key@example.org:321' . '/over/there?name=ferret&foo=bar#nose';
$cases[] = array(wfParseUrl($complexURL), $complexURL);
return $cases;
}
示例6: execute
public function execute()
{
$params = $this->extractRequestParams();
$this->requireAtLeastOneParameter($params, 'continue', 'returnurl');
if ($params['returnurl'] !== null) {
$bits = wfParseUrl($params['returnurl']);
if (!$bits || $bits['scheme'] === '') {
$encParamName = $this->encodeParamName('returnurl');
$this->dieUsage("Invalid value '{$params['returnurl']}' for url parameter {$encParamName}", "badurl_{$encParamName}");
}
}
$helper = new ApiAuthManagerHelper($this);
$manager = AuthManager::singleton();
// Make sure it's possible to log in
if (!$manager->canAuthenticateNow()) {
$this->getResult()->addValue(null, 'clientlogin', $helper->formatAuthenticationResponse(AuthenticationResponse::newFail($this->msg('userlogin-cannot-' . AuthManager::ACTION_LOGIN))));
return;
}
// Perform the login step
if ($params['continue']) {
$reqs = $helper->loadAuthenticationRequests(AuthManager::ACTION_LOGIN_CONTINUE);
$res = $manager->continueAuthentication($reqs);
} else {
$reqs = $helper->loadAuthenticationRequests(AuthManager::ACTION_LOGIN);
if ($params['preservestate']) {
$req = $helper->getPreservedRequest();
if ($req) {
$reqs[] = $req;
}
}
$res = $manager->beginAuthentication($reqs, $params['returnurl']);
}
$this->getResult()->addValue(null, 'clientlogin', $helper->formatAuthenticationResponse($res));
}
示例7: __construct
/**
* @param UUID $srcWorkflow ID of the source Workflow
* @param Title $srcTitle Title of the page that the Workflow exists on
* @param String $objectType Output of getRevisionType for the AbstractRevision that this reference comes from.
* @param UUID $objectId Unique identifier for the revisioned object containing the reference.
* @param string $type Type of reference
* @param string $url URL of the reference's target.
* @throws InvalidReferenceException
*/
public function __construct(UUID $srcWorkflow, Title $srcTitle, $objectType, UUID $objectId, $type, $url)
{
$this->url = $url;
if (!is_array(wfParseUrl($url))) {
throw new InvalidReferenceException("Invalid URL {$url} specified for reference " . get_class($this));
}
parent::__construct($srcWorkflow, $srcTitle, $objectType, $objectId, $type);
}
示例8: getBaseUrl
/**
* Returns the basic hostname and port using wfParseUrl
* @param string $url URL to parse
* @return string
*/
public static function getBaseUrl($url)
{
$parse = wfParseUrl($url);
$site = $parse['host'];
if (isset($parse['port'])) {
$site .= ':' . $parse['port'];
}
return $site;
}
示例9: testUnwatchTopicLink
/**
* @dataProvider provideDataWatchTopicLink
*/
public function testUnwatchTopicLink(Title $title, $workflowId)
{
$anchor = $this->urlGenerator->unwatchTopicLink($title, $workflowId);
$this->assertInstanceOf('\\Flow\\Model\\Anchor', $anchor);
$link = $anchor->getFullURL();
$option = wfParseUrl($link);
$this->assertArrayHasKey('query', $option);
parse_str($option['query'], $query);
$this->assertEquals('unwatch', $query['action']);
}
示例10: execute
public function execute($par)
{
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->allowClickjacking();
$request = $this->getRequest();
$target = $request->getVal('target', $par);
$namespace = $request->getIntOrNull('namespace');
$protocols_list = [];
foreach ($this->getConfig()->get('UrlProtocols') as $prot) {
if ($prot !== '//') {
$protocols_list[] = $prot;
}
}
$target2 = $target;
// Get protocol, default is http://
$protocol = 'http://';
$bits = wfParseUrl($target);
if (isset($bits['scheme']) && isset($bits['delimiter'])) {
$protocol = $bits['scheme'] . $bits['delimiter'];
// Make sure wfParseUrl() didn't make some well-intended correction in the
// protocol
if (strcasecmp($protocol, substr($target, 0, strlen($protocol))) === 0) {
$target2 = substr($target, strlen($protocol));
} else {
// If it did, let LinkFilter::makeLikeArray() handle this
$protocol = '';
}
}
$out->addWikiMsg('linksearch-text', '<nowiki>' . $this->getLanguage()->commaList($protocols_list) . '</nowiki>', count($protocols_list));
$fields = ['target' => ['type' => 'text', 'name' => 'target', 'id' => 'target', 'size' => 50, 'label-message' => 'linksearch-pat', 'default' => $target, 'dir' => 'ltr']];
if (!$this->getConfig()->get('MiserMode')) {
$fields += ['namespace' => ['type' => 'namespaceselect', 'name' => 'namespace', 'label-message' => 'linksearch-ns', 'default' => $namespace, 'id' => 'namespace', 'all' => '', 'cssclass' => 'namespaceselector']];
}
$hiddenFields = ['title' => $this->getPageTitle()->getPrefixedDBkey()];
$htmlForm = HTMLForm::factory('ooui', $fields, $this->getContext());
$htmlForm->addHiddenFields($hiddenFields);
$htmlForm->setSubmitTextMsg('linksearch-ok');
$htmlForm->setWrapperLegendMsg('linksearch');
$htmlForm->setAction(wfScript());
$htmlForm->setMethod('get');
$htmlForm->prepareForm()->displayForm(false);
$this->addHelpLink('Help:Linksearch');
if ($target != '') {
$this->setParams(['query' => Parser::normalizeLinkUrl($target2), 'namespace' => $namespace, 'protocol' => $protocol]);
parent::execute($par);
if ($this->mungedQuery === false) {
$out->addWikiMsg('linksearch-error');
}
}
}
示例11: __construct
/**
* @param string $url Url to use. If protocol-relative, will be expanded to an http:// URL
* @param array $options (optional) extra params to pass (see Http::request())
* @param string $caller The method making this request, for profiling
* @param Profiler $profiler An instance of the profiler for profiling, or null
*/
protected function __construct($url, $options = [], $caller = __METHOD__, $profiler = null)
{
global $wgHTTPTimeout, $wgHTTPConnectTimeout;
$this->url = wfExpandUrl($url, PROTO_HTTP);
$this->parsedUrl = wfParseUrl($this->url);
if (isset($options['logger'])) {
$this->logger = $options['logger'];
} else {
$this->logger = new NullLogger();
}
if (!$this->parsedUrl || !Http::isValidURI($this->url)) {
$this->status = Status::newFatal('http-invalid-url', $url);
} else {
$this->status = Status::newGood(100);
// continue
}
if (isset($options['timeout']) && $options['timeout'] != 'default') {
$this->timeout = $options['timeout'];
} else {
$this->timeout = $wgHTTPTimeout;
}
if (isset($options['connectTimeout']) && $options['connectTimeout'] != 'default') {
$this->connectTimeout = $options['connectTimeout'];
} else {
$this->connectTimeout = $wgHTTPConnectTimeout;
}
if (isset($options['userAgent'])) {
$this->setUserAgent($options['userAgent']);
}
$members = ["postData", "proxy", "noProxy", "sslVerifyHost", "caInfo", "method", "followRedirects", "maxRedirects", "sslVerifyCert", "callback"];
foreach ($members as $o) {
if (isset($options[$o])) {
// ensure that MWHttpRequest::method is always
// uppercased. Bug 36137
if ($o == 'method') {
$options[$o] = strtoupper($options[$o]);
}
$this->{$o} = $options[$o];
}
}
if ($this->noProxy) {
$this->proxy = '';
// noProxy takes precedence
}
// Profile based on what's calling us
$this->profiler = $profiler;
$this->profileName = $caller;
}
示例12: execute
function execute($par)
{
global $wgUrlProtocols, $wgMiserMode, $wgScript;
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->allowClickjacking();
$request = $this->getRequest();
$target = $request->getVal('target', $par);
$namespace = $request->getIntorNull('namespace', null);
$protocols_list = array();
foreach ($wgUrlProtocols as $prot) {
if ($prot !== '//') {
$protocols_list[] = $prot;
}
}
$target2 = $target;
// Get protocol, default is http://
$protocol = 'http://';
$bits = wfParseUrl($target);
if (isset($bits['scheme']) && isset($bits['delimiter'])) {
$protocol = $bits['scheme'] . $bits['delimiter'];
// Make sure wfParseUrl() didn't make some well-intended correction in the
// protocol
if (strcasecmp($protocol, substr($target, 0, strlen($protocol))) === 0) {
$target2 = substr($target, strlen($protocol));
} else {
// If it did, let LinkFilter::makeLikeArray() handle this
$protocol = '';
}
}
$out->addWikiMsg('linksearch-text', '<nowiki>' . $this->getLanguage()->commaList($protocols_list) . '</nowiki>', count($protocols_list));
$s = Html::openElement('form', array('id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $wgScript)) . "\n" . Html::hidden('title', $this->getPageTitle()->getPrefixedDBkey()) . "\n" . Html::openElement('fieldset') . "\n" . Html::element('legend', array(), $this->msg('linksearch')->text()) . "\n" . Xml::inputLabel($this->msg('linksearch-pat')->text(), 'target', 'target', 50, $target) . "\n";
if (!$wgMiserMode) {
$s .= Html::namespaceSelector(array('selected' => $namespace, 'all' => '', 'label' => $this->msg('linksearch-ns')->text()), array('name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector'));
}
$s .= Xml::submitButton($this->msg('linksearch-ok')->text()) . "\n" . Html::closeElement('fieldset') . "\n" . Html::closeElement('form') . "\n";
$out->addHTML($s);
if ($target != '') {
$this->setParams(array('query' => $target2, 'namespace' => $namespace, 'protocol' => $protocol));
parent::execute($par);
if ($this->mMungedQuery === false) {
$out->addWikiMsg('linksearch-error');
}
}
}
示例13: isAllowedHost
/**
* Checks whether the URL is for an allowed host
*
* @param $url string
* @return bool
*/
public static function isAllowedHost($url)
{
global $wgCopyUploadsDomains;
if (!count($wgCopyUploadsDomains)) {
return true;
}
$parsedUrl = wfParseUrl($url);
if (!$parsedUrl) {
return false;
}
$valid = false;
foreach ($wgCopyUploadsDomains as $domain) {
if ($parsedUrl['host'] === $domain) {
$valid = true;
break;
}
}
return $valid;
}
示例14: hitThumbUrl
protected function hitThumbUrl($file, $transformParams)
{
global $wgUploadThumbnailRenderHttpCustomHost, $wgUploadThumbnailRenderHttpCustomDomain;
$thumbName = $file->thumbName($transformParams);
$thumbUrl = $file->getThumbUrl($thumbName);
if ($wgUploadThumbnailRenderHttpCustomDomain) {
$parsedUrl = wfParseUrl($thumbUrl);
if (!$parsedUrl || !isset($parsedUrl['path']) || !strlen($parsedUrl['path'])) {
return false;
}
$thumbUrl = '//' . $wgUploadThumbnailRenderHttpCustomDomain . $parsedUrl['path'];
}
wfDebug(__METHOD__ . ": hitting url {$thumbUrl}\n");
$request = MWHttpRequest::factory($thumbUrl, array('method' => 'HEAD', 'followRedirects' => true), __METHOD__);
if ($wgUploadThumbnailRenderHttpCustomHost) {
$request->setHeader('Host', $wgUploadThumbnailRenderHttpCustomHost);
}
$status = $request->execute();
return $request->getStatus();
}
示例15: execute
public function execute()
{
$params = $this->extractRequestParams();
$this->requireAtLeastOneParameter($params, 'continue', 'returnurl');
if ($params['returnurl'] !== null) {
$bits = wfParseUrl($params['returnurl']);
if (!$bits || $bits['scheme'] === '') {
$encParamName = $this->encodeParamName('returnurl');
$this->dieUsage("Invalid value '{$params['returnurl']}' for url parameter {$encParamName}", "badurl_{$encParamName}");
}
}
$helper = new ApiAuthManagerHelper($this);
$manager = AuthManager::singleton();
// Make sure it's possible to log in
if (!$manager->canAuthenticateNow()) {
$this->getResult()->addValue(null, 'clientlogin', $helper->formatAuthenticationResponse(AuthenticationResponse::newFail($this->msg('userlogin-cannot-' . AuthManager::ACTION_LOGIN))));
$helper->logAuthenticationResult('login', 'userlogin-cannot-' . AuthManager::ACTION_LOGIN);
return;
}
// Perform the login step
if ($params['continue']) {
$reqs = $helper->loadAuthenticationRequests(AuthManager::ACTION_LOGIN_CONTINUE);
$res = $manager->continueAuthentication($reqs);
} else {
$reqs = $helper->loadAuthenticationRequests(AuthManager::ACTION_LOGIN);
if ($params['preservestate']) {
$req = $helper->getPreservedRequest();
if ($req) {
$reqs[] = $req;
}
}
$res = $manager->beginAuthentication($reqs, $params['returnurl']);
}
// Remove CreateFromLoginAuthenticationRequest from $res->neededRequests.
// It's there so a RESTART treated as UI will work right, but showing
// it to the API client is just confusing.
$res->neededRequests = ApiAuthManagerHelper::blacklistAuthenticationRequests($res->neededRequests, [CreateFromLoginAuthenticationRequest::class]);
$this->getResult()->addValue(null, 'clientlogin', $helper->formatAuthenticationResponse($res));
$helper->logAuthenticationResult('login', $res);
}