本文整理汇总了PHP中wfAppendQuery函数的典型用法代码示例。如果您正苦于以下问题:PHP wfAppendQuery函数的具体用法?PHP wfAppendQuery怎么用?PHP wfAppendQuery使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfAppendQuery函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: passCaptcha
/**
* Check, if the user solved the captcha.
*
* Based on reference implementation:
* https://github.com/google/recaptcha#php
*
* @return boolean
*/
function passCaptcha()
{
global $wgRequest, $wgReCaptchaSecretKey, $wgReCaptchaSendRemoteIP;
$url = 'https://www.google.com/recaptcha/api/siteverify';
// Build data to append to request
$data = array('secret' => $wgReCaptchaSecretKey, 'response' => $wgRequest->getVal('g-recaptcha-response'));
if ($wgReCaptchaSendRemoteIP) {
$data['remoteip'] = $wgRequest->getIP();
}
$url = wfAppendQuery($url, $data);
$request = MWHttpRequest::factory($url, array('method' => 'GET'));
$status = $request->execute();
if (!$status->isOK()) {
$this->error = 'http';
$this->logStatusError($status);
return false;
}
$response = FormatJson::decode($request->getContent(), true);
if (!$response) {
$this->error = 'json';
$this->logStatusError($this->error);
return false;
}
if (isset($response['error-codes'])) {
$this->error = 'recaptcha-api';
$this->logCheckError($response['error-codes']);
return false;
}
return $response['success'];
}
示例2: fetchScriptList
protected function fetchScriptList()
{
$data = array('action' => 'query', 'format' => 'php', 'list' => 'allpages', 'apnamespace' => '8', 'aplimit' => '500');
$baseUrl = $this->getArg(0);
$pages = array();
do {
$url = wfAppendQuery($baseUrl, $data);
$strResult = Http::get($url);
//$result = FormatJson::decode( $strResult ); // Still broken
$result = unserialize($strResult);
if (!empty($result['query']['allpages'])) {
foreach ($result['query']['allpages'] as $page) {
if (substr($page['title'], -3) === '.js') {
strtok($page['title'], ':');
$pages[] = strtok('');
}
}
}
if (!empty($result['query-continue'])) {
$data['apfrom'] = $result['query-continue']['allpages']['apfrom'];
$this->output("Fetching new batch from {$data['apfrom']}\n");
}
} while (isset($result['query-continue']));
return $pages;
}
示例3: stage
public function stage(GatewayType $adapter, $normalized, &$stagedData)
{
if ($adapter->isBatchProcessor()) {
// Only makes sense for real users.
return;
}
if (!empty($normalized['returnto'])) {
$returnto = $normalized['returnto'];
} else {
$returnto = '';
}
if (isset($normalized['payment_method']) && $normalized['payment_method'] === 'cc') {
// Add order ID to the returnto URL, only if it's not already there.
//TODO: This needs to be more robust (like actually pulling the
//qstring keys, resetting the values, and putting it all back)
//but for now it'll keep us alive.
if ($adapter->getOrderIDMeta('generate') && !empty($returnto) && !strpos($returnto, 'order_id')) {
$queryArray = array('order_id' => $normalized['order_id']);
$stagedData['returnto'] = wfAppendQuery($returnto, $queryArray);
}
} else {
// FIXME: An empty returnto should be handled by the result switcher instead.
$stagedData['returnto'] = ResultPages::getThankYouPage($adapter);
}
}
示例4: getFailPageFromParams
/**
* @param bool $rapidFail if true, render a form as a fail page rather than redirect
* @param string $failPage either a wiki page title, or a URL to an external wiki
* page title.
* @param array $data information about the current request.
* language, gateway, payment_method, and payment_submethod must be set
* @param Psr\Log\LoggerInterface $logger
* @return string full URL of the fail page, or just form name in case of rapidFail
*/
private static function getFailPageFromParams($rapidFail, $failPage, $data, LoggerInterface $logger)
{
if (isset($data['language'])) {
$language = $data['language'];
} else {
$language = WmfFramework::getLanguageCode();
}
// Prefer RapidFail.
if ($rapidFail) {
// choose which fail page to go for.
try {
$fail_ffname = GatewayFormChooser::getBestErrorForm($data['gateway'], $data['payment_method'], $data['payment_submethod']);
return $fail_ffname;
} catch (Exception $e) {
$logger->error('Cannot determine best error form. ' . $e->getMessage());
}
}
if (filter_var($failPage, FILTER_VALIDATE_URL)) {
return self::appendLanguageAndMakeURL($failPage, $language);
}
// FIXME: either add Special:FailPage to avoid depending on wiki content,
// or update the content on payments to be consistent with the /lang
// format of ThankYou pages so we can use appendLanguageAndMakeURL here.
$failTitle = Title::newFromText($failPage);
$url = wfAppendQuery($failTitle->getFullURL(), array('uselang' => $language));
return $url;
}
示例5: getSupportUrl
/**
* Target URL for a link provided by a support button/aid.
*
* @param $title Title Title object for the translation message.
* @since 2015.09
*/
public static function getSupportUrl(Title $title)
{
global $wgTranslateSupportUrl, $wgTranslateSupportUrlNamespace;
$namespace = $title->getNamespace();
// Fetch the configuration for this namespace if possible, or the default.
if (isset($wgTranslateSupportUrlNamespace[$namespace])) {
$config = $wgTranslateSupportUrlNamespace[$namespace];
} elseif ($wgTranslateSupportUrl) {
$config = $wgTranslateSupportUrl;
} else {
throw new TranslationHelperException("Support page not configured");
}
// Preprocess params
$params = array();
if (isset($config['params'])) {
foreach ($config['params'] as $key => $value) {
$params[$key] = str_replace('%MESSAGE%', $title->getPrefixedText(), $value);
}
}
// Return the URL or make one from the page
if (isset($config['url'])) {
return wfAppendQuery($config['url'], $params);
} elseif (isset($config['page'])) {
$page = Title::newFromText($config['page']);
if (!$page) {
throw new TranslationHelperException("Support page not configured properly");
}
return $page->getFullUrl($params);
} else {
throw new TranslationHelperException("Support page not configured properly");
}
}
示例6: fetchScriptList
protected function fetchScriptList()
{
$data = ['action' => 'query', 'format' => 'json', 'list' => 'allpages', 'apnamespace' => '8', 'aplimit' => '500', 'continue' => ''];
$baseUrl = $this->getArg(0);
$pages = [];
while (true) {
$url = wfAppendQuery($baseUrl, $data);
$strResult = Http::get($url, [], __METHOD__);
$result = FormatJson::decode($strResult, true);
$page = null;
foreach ($result['query']['allpages'] as $page) {
if (substr($page['title'], -3) === '.js') {
strtok($page['title'], ':');
$pages[] = strtok('');
}
}
if ($page !== null) {
$this->output("Fetched list up to {$page['title']}\n");
}
if (isset($result['continue'])) {
// >= 1.21
$data = array_replace($data, $result['continue']);
} elseif (isset($result['query-continue']['allpages'])) {
// <= 1.20
$data = array_replace($data, $result['query-continue']['allpages']);
} else {
break;
}
}
return $pages;
}
示例7: execute
public function execute( $par ) {
global $wgOut, $wgRequest;
global $wgVariablePagePossibilities;
$lang = ( preg_match( '/^[A-Za-z-]+$/', $wgRequest->getVal( 'lang' ) ) )
? $wgRequest->getVal( 'lang' )
: 'en' ;
$utm_source = $wgRequest->getVal( 'utm_source' );
$utm_medium = $wgRequest->getVal( 'utm_medium' );
$utm_campaign = $wgRequest->getVal( 'utm_campaign' );
$referrer = ( $wgRequest->getVal( 'referrer' ))
? $wgRequest->getVal( 'referrer' )
: $wgRequest->getHeader( 'referer' );
$query = array();
if ( strlen( $lang ) ) $query[ 'language' ] = $lang;
if ( strlen( $utm_source ) ) $query[ 'utm_source' ] = $utm_source;
if ( strlen( $utm_medium ) ) $query[ 'utm_medium' ] = $utm_medium;
if ( strlen( $utm_campaign ) ) $query[ 'utm_campaign' ] = $utm_campaign;
if ( strlen( $referrer ) ) $query[ 'referrer' ] = $referrer;
// determine the URL to which we will redirect the user
$url = $this->determinePage( $wgVariablePagePossibilities );
$wgOut->redirect( wfAppendQuery( $url, $query ) );
}
示例8: execute
public function execute()
{
global $wgUser, $wgArticleFeedbackRatingTypes, $wgArticleFeedbackSMaxage, $wgArticleFeedbackNamespaces;
$params = $this->extractRequestParams();
// Anon token check
if ($wgUser->isAnon()) {
if (!isset($params['anontoken'])) {
$this->dieUsageMsg(array('missingparam', 'anontoken'));
} elseif (strlen($params['anontoken']) != 32) {
$this->dieUsage('The anontoken is not 32 characters', 'invalidtoken');
}
$token = $params['anontoken'];
} else {
$token = '';
}
// Load check, is this page ArticleFeedback-enabled ?
// Keep in sync with ext.articleFeedback.startup.js
$title = Title::newFromID($params['pageid']);
if (is_null($title) || !in_array($title->getNamespace(), $wgArticleFeedbackNamespaces) || $title->isRedirect()) {
// ...then error out
$this->dieUsage('ArticleFeedback is not enabled on this page', 'invalidpage');
}
$dbw = wfGetDB(DB_MASTER);
// Query the latest ratings by this user for this page,
// possibly for an older revision
// Select from the master to prevent replag-induced bugs
$res = $dbw->select('article_feedback', array('aa_rating_id', 'aa_rating_value', 'aa_revision'), array('aa_user_text' => $wgUser->getName(), 'aa_page_id' => $params['pageid'], 'aa_rating_id' => array_keys($wgArticleFeedbackRatingTypes), 'aa_user_anon_token' => $token), __METHOD__, array('ORDER BY' => 'aa_revision DESC', 'LIMIT' => count($wgArticleFeedbackRatingTypes)));
$lastRatings = array();
foreach ($res as $row) {
$lastRatings[$row->aa_rating_id]['value'] = $row->aa_rating_value;
$lastRatings[$row->aa_rating_id]['revision'] = $row->aa_revision;
}
$pageId = $params['pageid'];
$revisionId = $params['revid'];
foreach ($wgArticleFeedbackRatingTypes as $ratingID => $unused) {
$lastPageRating = false;
$lastRevRating = false;
if (isset($lastRatings[$ratingID])) {
$lastPageRating = intval($lastRatings[$ratingID]['value']);
if (intval($lastRatings[$ratingID]['revision']) == $revisionId) {
$lastRevRating = $lastPageRating;
}
}
$thisRating = false;
if (isset($params["r{$ratingID}"])) {
$thisRating = intval($params["r{$ratingID}"]);
}
$this->insertRevisionRating($pageId, $revisionId, $ratingID, $thisRating - $lastRevRating, $thisRating, $lastRevRating);
$this->insertPageRating($pageId, $ratingID, $thisRating - $lastPageRating, $thisRating, $lastPageRating);
$this->insertUserRatings($pageId, $revisionId, $wgUser, $token, $ratingID, $thisRating, $params['bucket']);
}
$this->insertProperties($revisionId, $wgUser, $token, $params);
$squidUpdate = new SquidUpdate(array(wfAppendQuery(wfScript('api'), array('action' => 'query', 'format' => 'json', 'list' => 'articlefeedback', 'afpageid' => $pageId, 'afanontoken' => '', 'afuserrating' => 0, 'maxage' => 0, 'smaxage' => $wgArticleFeedbackSMaxage))));
$squidUpdate->doUpdate();
wfRunHooks('ArticleFeedbackChangeRating', array($params));
$r = array('result' => 'Success');
$this->getResult()->addValue(null, $this->getModuleName(), $r);
}
示例9: getApiURL
/**
* Get the API URL constructed from the domain template of sites
*/
public static function getApiURL($language, $params = null)
{
global $wgContentTranslationSiteTemplates;
$domain = self::getDomainCode($language);
// $wgContentTranslationSiteTemplates['api'] is protocol relative path
$url = 'https:' . str_replace('$1', $domain, $wgContentTranslationSiteTemplates['api']);
$url = wfAppendQuery($url, $params);
return $url;
}
示例10: doRequest
private function doRequest($apiUrl)
{
$params = array('action' => 'query', 'list' => 'allpages', 'apnamespace' => 120, 'aplimit' => 300, 'format' => 'json', 'rawcontinue' => 1);
if (isset($this->continuation) && $this->continuation !== null) {
$params['apfrom'] = $this->continuation;
}
$json = Http::get(wfAppendQuery($apiUrl, $params), array(), __METHOD__);
return json_decode($json, true);
}
示例11: doRequest
private function doRequest(array $ids)
{
$params = array('action' => 'wbgetentities', 'ids' => implode('|', $ids), 'format' => 'json');
$json = Http::get(wfAppendQuery($this->apiUrl, $params), array(), __METHOD__);
$data = json_decode($json, true);
if ($data) {
return $data;
}
$this->logger->error('Failed to decode json api response');
}
示例12: getPreloadedText
/**
@brief Fetch the edit form and return the text in #wpTextbox1.
@param title The page to be opened for editing.
*/
public function getPreloadedText($title)
{
$url = wfAppendQuery(wfScript('index'), array('title' => $title, 'action' => 'edit'));
$this->loadFromURL($url);
$elem = $this->getElementById('wpTextbox1');
if (!$elem) {
return null;
}
return trim($elem->textContent);
}
示例13: wfCSSRender
function wfCSSRender(&$parser, $css)
{
global $wgCSSPath, $wgStylePath, $wgCSSIdentifier;
$css = trim($css);
$title = Title::newFromText($css);
$rawProtection = "{$wgCSSIdentifier}=1";
$headItem = '<!-- Begin Extension:CSS -->';
if (is_object($title) && $title->exists()) {
# Article actually in the db
$params = "action=raw&ctype=text/css&{$rawProtection}";
$url = $title->getLocalURL($params);
$headItem .= HTML::linkedStyle($url);
} elseif ($css[0] == '/') {
# Regular file
$base = $wgCSSPath === false ? $wgStylePath : $wgCSSPath;
$url = wfAppendQuery($base . $css, $rawProtection);
# Verify the expanded URL is still using the base URL
if (strpos(wfExpandUrl($url), wfExpandUrl($base)) === 0) {
$headItem .= HTML::linkedStyle($url);
} else {
$headItem .= '<!-- Invalid/malicious path -->';
}
} else {
# Inline CSS; use data URI to prevent injection. JavaScript
# will use a canary to verify load and will safely convert to
# style tag if load fails.
# Generate random CSS color that isn't black or white.
$color = dechex(mt_rand(1, hexdec('fffffe')));
$color = str_pad($color, 6, '0', STR_PAD_LEFT);
# Prepend canary CSS to sanitized user CSS
$canaryId = "{$wgCSSIdentifier}-canary-{$color}";
$canaryCSS = "#{$canaryId}{background:#{$color} !important}";
$css = $canaryCSS . Sanitizer::checkCss($css);
# Encode data URI and append link tag
$dataPrefix = 'data:text/css;charset=UTF-8;base64,';
$url = $dataPrefix . base64_encode($css);
$headItem .= HTML::linkedStyle($url);
# Calculate URI prefix to match link tag
$hrefPrefix = $dataPrefix . base64_encode('#' . $canaryId);
$hrefPrefix = substr($url, 0, strlen($hrefPrefix));
# Add JS to verify the link tag loaded and fallback if needed
$parser->getOutput()->addModules('ext.CSS');
$headItem .= HTML::inlineScript(<<<INLINESCRIPT
jQuery( function( \$ ) {
\t\$( 'link[href^="{$hrefPrefix}"]' )
\t\t.cssExtensionDataURIFallback( '{$canaryId}', '{$color}' );
} );
INLINESCRIPT
);
}
$headItem .= '<!-- End Extension:CSS -->';
$parser->getOutput()->addHeadItem($headItem);
return '';
}
示例14: addMatchedText
/**
* Hook function called with &match=lang
* Transform $text into a bilingual version
* @param $out OutputPage
* @param $text
*/
function addMatchedText(&$out, &$text)
{
global $wgContLang, $wgContLanguageCode, $wgRequest, $wgLang, $wgMemc, $wgDoubleWikiCacheTime;
$match_request = $wgRequest->getText('match');
if ($match_request === '') {
return true;
}
$this->addMatchingTags($text, $match_request);
$langLinks = $out->getLanguageLinks();
foreach ($langLinks as $l) {
$nt = Title::newFromText($l);
$iw = $nt->getInterwiki();
if ($iw !== $match_request) {
continue;
}
$key = wfMemcKey('doublewiki', $wgLang->getCode(), $nt->getPrefixedDbKey());
$cachedText = $wgMemc->get($key);
if ($cachedText) {
$text = $cachedText;
} else {
$url = $nt->getCanonicalURL();
$myURL = $out->getTitle()->getLocalURL();
$languageName = $wgContLang->getLanguageName($iw);
$myLanguage = $wgLang->getLanguageName($wgContLang->getCode());
$translation = Http::get(wfAppendQuery($url, array('action' => 'render')));
if ($translation !== null) {
break;
}
/**
* first find all links that have no 'class' parameter.
* these links are local so we add '?match=xx' to their url,
* unless it already contains a '?'
*/
$translation = preg_replace("/<a href=\"http:\\/\\/([^\"\\?]*)\"(([\\s]+)(c(?!lass=)|[^c\\>\\s])([^\\>\\s]*))*\\>/i", "<a href=\"http://\\1?match={$wgContLanguageCode}\"\\2>", $translation);
// now add class='extiw' to these links
$translation = preg_replace("/<a href=\"http:\\/\\/([^\"]*)\"(([\\s]+)(c(?!lass=)|[^c\\>\\s])([^\\>\\s]*))*\\>/i", "<a href=\"http://\\1\" class=\"extiw\"\\3>", $translation);
// use class='extiw' for images too
$translation = preg_replace("/<a href=\"http:\\/\\/([^\"]*)\"([^\\>]*)class=\"image\"([^\\>]*)\\>/i", "<a href=\"http://\\1\"\\2class=\"extiw\"\\3>", $translation);
// add prefixes to internal links, in order to prevent duplicates
$translation = preg_replace("/<a href=\"#(.*?)\"/i", "<a href=\"#l_\\1\"", $translation);
$translation = preg_replace("/<li id=\"(.*?)\"/i", "<li id=\"l_\\1\"", $translation);
$text = preg_replace("/<a href=\"#(.*?)\"/i", "<a href=\"#r_\\1\"", $text);
$text = preg_replace("/<li id=\"(.*?)\"/i", "<li id=\"r_\\1\"", $text);
// add ?match= to local links of the local wiki
$text = preg_replace("/<a href=\"\\/([^\"\\?]*)\"/i", "<a href=\"/\\1?match={$match_request}\"", $text);
// do the job
$text = $this->matchColumns($text, $myLanguage, $myURL, $wgContLanguageCode, $translation, $languageName, $url, $match_request);
$wgMemc->set($key, $text, $wgDoubleWikiCacheTime);
}
break;
}
return true;
}
示例15: onSkinTemplateTabs
/**
* Purpose: Add custom tabs
*
* When editing in read-only data-set, if you have the copy permission, you can
* make a copy into the designated community dataset and edit the data there.
* This is accessible through an 'edit copy' tab which is added below.
*
* @param $skin Skin as passed by MW
* @param $tabs as passed by MW
*/
public static function onSkinTemplateTabs( $skin, $content_actions ) {
global $wgUser, $wgCommunity_dc, $wdShowEditCopy, $wdHandlerClasses;
$title = $skin->getTitle();
if ( !self::isWikidataNs( $title ) ) {
return true;
}
$ns = $title->getNamespace();
$editChanged = false;
$dc = wdGetDataSetContext();
if ( $wdHandlerClasses[ $ns ] == 'DefinedMeaning' ) {
# Hackishly determine which DMID we're on by looking at the page title component
$tt = $title->getText();
$rpos1 = strrpos( $tt, '(' );
$rpos2 = strrpos( $tt, ')' );
$dmid = ( $rpos1 && $rpos2 ) ? substr( $tt, $rpos1 + 1, $rpos2 - $rpos1 - 1 ) : 0;
if ( $dmid ) {
$copyTitle = SpecialPage::getTitleFor( 'Copy' );
if ( $dc != $wgCommunity_dc && $wdShowEditCopy ) {
$editChanged = true;
$content_actions['edit'] = array(
'class' => false,
'text' => wfMsg( 'ow_nstab_edit_copy' ),
'href' => $copyTitle->getLocalUrl( "action=copy&dmid=$dmid&dc1=$dc&dc2=$wgCommunity_dc" )
);
}
$content_actions['nstab-definedmeaning'] = array(
'class' => 'selected',
'text' => wfMsg( 'ow_nstab_definedmeaning' ),
'href' => $title->getLocalUrl( "dataset=$dc" )
);
}
}
// Prevent move tab being shown.
unset( $content_actions['move'] );
// Add context dataset (old hooks 'GetEditLinkTrail' and 'GetHistoryLinkTrail')
if ( !$editChanged && $content_actions['edit'] != null ) {
$content_actions['edit']['href'] = wfAppendQuery( $content_actions['edit']['href'], "dataset=$dc" );
}
$content_actions['history']['href'] = wfAppendQuery( $content_actions['history']['href'], "dataset=$dc" );
return true;
}