public static function convertDataToAttributes($data) { // get ID of current CK instance $instance = RTE::getInstanceId(); // properly encode JSON $encoded = RTEReverseParser::encodeRTEData($data); $encoded = Sanitizer::encodeAttribute($encoded); return " data-rte-meta=\"{$encoded}\" data-rte-instance=\"{$instance}\" "; }
/** * Given an array of ('attributename' => 'value'), it generates the code * to set the XML attributes : attributename="value". * The values are passed to Sanitizer::encodeAttribute. * Return null if no attributes given. * @param array $attribs of attributes for an XML element * @throws MWException * @return null|string */ public static function expandAttributes( $attribs ) { $out = ''; if ( is_null( $attribs ) ) { return null; } elseif ( is_array( $attribs ) ) { foreach ( $attribs as $name => $val ) { $out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"'; } return $out; } else { throw new MWException( 'Expected attribute array, got something else in ' . __METHOD__ ); } }
public function index() { wfProfileIn(__METHOD__); if (!$this->getUser()->isAllowed('coppatool')) { wfProfileOut(__METHOD__); $this->displayRestrictionError(); return false; } $this->specialPage->setHeaders(); $this->response->setTemplateEngine(WikiaResponse::TEMPLATE_ENGINE_MUSTACHE); $this->userName = trim($this->getVal('username', $this->getPar())); $this->isIP = false; $this->validUser = false; if (IP::isIPAddress($this->userName)) { $this->userName = IP::sanitizeIP($this->userName); $this->isIP = true; $this->validUser = true; } else { $userObj = User::newFromName($this->userName); if (!$userObj || $userObj->getId() === 0) { $this->validUser = false; } else { $this->userName = $userObj->getName(); $this->validUser = true; } } $this->userForm = $this->app->renderView('WikiaStyleGuideForm', 'index', ['form' => ['isInvalid' => $this->validUser || $this->userName === '' ? false : true, 'errorMsg' => $this->validUser || $this->userName === '' ? '' : $this->msg('coppatool-nosuchuser', $this->userName)->escaped(), 'inputs' => [['type' => 'text', 'name' => 'username', 'isRequired' => true, 'label' => $this->msg('coppatool-label-username')->escaped(), 'value' => Sanitizer::encodeAttribute($this->userName)], ['type' => 'submit', 'value' => $this->msg('coppatool-submit')->escaped()]], 'method' => 'GET', 'action' => $this->getTitle()->getLocalUrl()]]); if ($this->validUser) { $this->getOutput()->addModules('ext.coppaTool'); $this->buttons = []; $this->blankImgUrl = wfBlankImgUrl(); $this->formHeading = $this->msg('coppatool-form-header')->escaped(); if (!$this->isIP) { $this->buttons[] = ['buttonAction' => 'disable-account', 'buttonLink' => Html::element('a', ['href' => '#'], $this->msg('coppatool-disable')->escaped()), 'done' => $userObj->getGlobalFlag('disabled', false)]; $this->buttons[] = ['buttonAction' => 'blank-profile', 'buttonLink' => Html::element('a', ['href' => '#'], $this->msg('coppatool-blank-user-profile')->escaped())]; $this->buttons[] = ['buttonAction' => 'delete-userpages', 'buttonLink' => Html::element('a', ['href' => '#'], $this->msg('coppatool-delete-user-pages')->escaped())]; $this->buttons[] = ['buttonAction' => 'coppa-imagereview', 'buttonLink' => Linker::link(Title::newFromText('CoppaImageReview', NS_SPECIAL), $this->msg('coppatool-imagereview')->escaped(), ['target' => '_blank'], ['username' => $this->userName], ['known', 'noclasses'])]; } else { $this->buttons[] = ['buttonAction' => 'phalanx-ip', 'buttonLink' => Linker::link(Title::newFromText('Phalanx', NS_SPECIAL), $this->msg('coppatool-phalanx-ip')->escaped(), ['target' => '_blank'], ['type' => Phalanx::TYPE_USER, 'wpPhalanxCheckBlocker' => $this->userName, 'target' => $this->userName], ['known', 'noclasses'])]; $this->buttons[] = ['buttonAction' => 'rename-ip', 'buttonLink' => Html::element('a', ['href' => '#'], $this->msg('coppatool-rename-ip')->escaped())]; } } wfProfileOut(__METHOD__); }
/** * Format an XML element with given attributes and, optionally, text content. * Element and attribute names are assumed to be ready for literal inclusion. * Strings are assumed to not contain XML-illegal characters; special * characters (<, >, &) are escaped but illegals are not touched. * * @param $element String: * @param $attribs Array: Name=>value pairs. Values will be escaped. * @param $contents String: NULL to make an open tag only; '' for a contentless closed tag (default) * @return string */ public static function element($element, $attribs = null, $contents = '') { $out = '<' . $element; if (!is_null($attribs)) { foreach ($attribs as $name => $val) { $out .= ' ' . $name . '="' . Sanitizer::encodeAttribute($val) . '"'; } } if (is_null($contents)) { $out .= '>'; } else { if ($contents === '') { $out .= ' />'; } else { $out .= '>' . htmlspecialchars($contents) . "</{$element}>"; } } return $out; }
/** * This method takes an array and converts it to XML. * There are several noteworthy cases: * * If array contains a key '_element', then the code assumes that ALL other keys are not important and replaces them with the value['_element']. * Example: name='root', value = array( '_element'=>'page', 'x', 'y', 'z') creates <root> <page>x</page> <page>y</page> <page>z</page> </root> * * If any of the array's element key is '*', then the code treats all other key->value pairs as attributes, and the value['*'] as the element's content. * Example: name='root', value = array( '*'=>'text', 'lang'=>'en', 'id'=>10) creates <root lang='en' id='10'>text</root> * * If neither key is found, all keys become element names, and values become element content. * The method is recursive, so the same rules apply to any sub-arrays. * * @param $elemName * @param $elemValue * @param $indent * @param $doublequote bool * * @return string */ public static function recXmlPrint($elemName, $elemValue, $indent, $doublequote = false) { $retval = ''; if (!is_null($indent)) { $indent += 2; $indstr = "\n" . str_repeat(' ', $indent); } else { $indstr = ''; } $elemName = str_replace(' ', '_', $elemName); switch (gettype($elemValue)) { case 'array': if (isset($elemValue['*'])) { $subElemContent = $elemValue['*']; if ($doublequote) { $subElemContent = Sanitizer::encodeAttribute($subElemContent); } unset($elemValue['*']); // Add xml:space="preserve" to the // element so XML parsers will leave // whitespace in the content alone $elemValue['xml:space'] = 'preserve'; } else { $subElemContent = null; } if (isset($elemValue['_element'])) { $subElemIndName = $elemValue['_element']; unset($elemValue['_element']); } else { $subElemIndName = null; } $indElements = array(); $subElements = array(); foreach ($elemValue as $subElemId => &$subElemValue) { if (is_string($subElemValue) && $doublequote) { $subElemValue = Sanitizer::encodeAttribute($subElemValue); } if (gettype($subElemId) === 'integer') { $indElements[] = $subElemValue; unset($elemValue[$subElemId]); } elseif (is_array($subElemValue)) { $subElements[$subElemId] = $subElemValue; unset($elemValue[$subElemId]); } } if (is_null($subElemIndName) && count($indElements)) { ApiBase::dieDebug(__METHOD__, "({$elemName}, ...) has integer keys without _element value. Use ApiResult::setIndexedTagName()."); } if (count($subElements) && count($indElements) && !is_null($subElemContent)) { ApiBase::dieDebug(__METHOD__, "({$elemName}, ...) has content and subelements"); } if (!is_null($subElemContent)) { $retval .= $indstr . Xml::element($elemName, $elemValue, $subElemContent); } elseif (!count($indElements) && !count($subElements)) { $retval .= $indstr . Xml::element($elemName, $elemValue); } else { $retval .= $indstr . Xml::element($elemName, $elemValue, null); foreach ($subElements as $subElemId => &$subElemValue) { $retval .= self::recXmlPrint($subElemId, $subElemValue, $indent); } foreach ($indElements as &$subElemValue) { $retval .= self::recXmlPrint($subElemIndName, $subElemValue, $indent); } $retval .= $indstr . Xml::closeElement($elemName); } break; case 'object': // ignore break; default: $retval .= $indstr . Xml::element($elemName, null, $elemValue); break; } return $retval; }
$isNumber1 = false; if ($index == 1 && !$number1Found && !empty($items[$index]) && $items[$index]->getVotesCount() != $item->getVotesCount()) { $isNumber1 = true; $number1Found = true; } ?> <div class="ItemNumber<?php echo $isNumber1 ? ' No1' : ' NotVotable'; ?> "> <span>#<?php echo $index; ?> </span> <button class="VoteButton" id="<?php echo Sanitizer::encodeAttribute($item->getTitle()->getSubpageText()); ?> "> <img src="<?php echo wfBlankImgUrl(); ?> " class="chevron"/> <?php echo wfMessage('toplists-list-vote-up')->inContentLanguage()->escaped(); ?> </button> </div> <div class="ItemContent"> <?php echo $item->getParsedContent(); ?>
<?php echo F::app()->renderView('MenuButton', 'Index', array('action' => array("text" => wfMessage('category-exhibition-' . $current)->escaped(), "id" => "category-exhibition-form-current"), 'class' => 'secondary', 'dropdown' => $dropdown, 'name' => 'sortType')); ?> <?php } ?> <a title="<?php echo wfMessage('category-exhibition-display-old')->escaped(); ?> " id="category-exhibition-form-new" href="<?php echo Sanitizer::encodeAttribute($path . '?display=page&sort=' . urlencode($current)); ?> " ><div id="category-exhibition-display-old" <?php if ($displayType == 'page') { echo ' class="active"'; } ?> ></div></a> | <a title="<?php echo wfMessage('category-exhibition-display-new')->escaped(); ?> " id="category-exhibition-form-old" href="<?php echo Sanitizer::encodeAttribute($path . '?display=exhibition&sort=' . urlencode($current)); ?> " ><div id="category-exhibition-display-new" <?php if ($displayType == 'exhibition') { echo ' class="active"'; } ?> ></div></a> </div>
/** * Format a single list item from a database row. * @param $row Database row object * @param $params An array of flags. Valid flags: * * admin (user can show/hide feedback items) * * show-anyway (user has asked to see this hidden item) * @param $response An array of response for feedback * @return string HTML */ public static function formatListItem($row, $params = array(), $response = array()) { global $wgLang, $wgUser; $classes = array('fbd-item'); $toolLinks = array(); //in case there is an error constructing the feedbackitem object, //we don't want to throw an error for the entire page. try { $feedbackItem = MBFeedbackItem::load($row); } catch (Exception $e) { $classes = Sanitizer::encodeAttribute(implode(' ', $classes)); $error_message = wfMessage('moodbar-feedback-load-record-error')->escaped(); return <<<HTML \t\t\t<li class="{$classes}"> \t\t\t\t<div class="fbd-item-message" dir="auto">{$error_message}</div> \t\t\t\t<div style="clear:both"></div> \t\t\t</li> HTML; } // Type $type = $feedbackItem->getProperty('type'); $typeMsg = wfMessage("moodbar-type-{$type}")->params($feedbackItem->getProperty('user'))->escaped(); // Timestamp $timestamp = wfTimestamp(TS_UNIX, $feedbackItem->getProperty('timestamp')); $timeMsg = wfMessage('ago')->params(MoodBarUtil::formatTimeSince($timestamp))->escaped(); // Comment $comment = htmlspecialchars($feedbackItem->getProperty('comment')); // User information $userInfo = self::buildUserInfo($feedbackItem); // Tool links $toolLinks[] = self::getPermalink($feedbackItem); // Continuation data $id = $feedbackItem->getProperty('id'); $continueData = wfTimestamp(TS_MW, $timestamp) . '|' . intval($id); // Now handle hiding, showing, etc if ($feedbackItem->getProperty('hidden-state') > 0) { $toolLinks = array(); if (!in_array('show-anyway', $params)) { $userInfo = wfMessage('moodbar-user-hidden')->escaped(); $comment = wfMessage('moodbar-comment-hidden')->escaped(); $type = 'hidden'; $typeMsg = ''; $classes[] = 'fbd-hidden'; } if (in_array('admin', $params)) { if (in_array('show-anyway', $params)) { $toolLinks[] = self::getHiddenFooter($feedbackItem, 'shown'); } else { $toolLinks[] = self::getHiddenFooter($feedbackItem, 'hidden'); } } } elseif (in_array('admin', $params)) { $toolLinks[] = self::getHideLink($feedbackItem); } $responseElements = self::buildResponseElement($feedbackItem, $response); $classes = Sanitizer::encodeAttribute(implode(' ', $classes)); $toolLinks = implode("\n", $toolLinks); return <<<HTML \t\t<li class="{$classes}" data-mbccontinue="{$continueData}"> \t\t\t<div class="fbd-item-emoticon fbd-item-emoticon-{$type}"> \t\t\t\t<span class="fbd-item-emoticon-label">{$typeMsg}</span> \t\t\t</div> \t\t\t<div class="fbd-item-time">{$timeMsg}</div> \t\t\t{$userInfo} \t\t\t<div class="fbd-item-message" dir="auto">{$comment}</div> \t\t\t{$toolLinks} \t\t\t{$responseElements} \t\t\t<div style="clear:both"></div> \t\t</li> HTML; }
/** * * @param $par String subpage string, if one was specified */ function execute($par) { global $wgOut; global $wgRequest, $wgUser, $wgMemc; $MAX_RESULTS = 100; $CACHE_KEY_PREFIX = "LW_SOAP_FAILURES"; $CACHE_KEY_DATA = wfMemcKey($CACHE_KEY_PREFIX, "data"); $CACHE_KEY_TIME = wfMemcKey($CACHE_KEY_PREFIX, "cachedOn"); $CACHE_KEY_STATS = wfMemcKey($CACHE_KEY_PREFIX, "stats"); $wgOut->setPageTitle(wfMsg('soapfailures')); // This processes any requested for removal of an item from the list. if (isset($_POST['artist']) && isset($_POST['song'])) { $artist = $_POST['artist']; $song = $_POST['song']; $songResult = array(); $failedLyrics = "Not found"; /* GLOBAL $IP; define('LYRICWIKI_SOAP_FUNCS_ONLY', true); // so that we can use the SOAP functions but not actually instantiate a SOAP server & process a request. include_once 'server.php'; // the SOAP functions $songResult = getSong($artist, $song);*/ // Pull in the NuSOAP code $dir = dirname(__FILE__) . '/'; require_once $dir . 'nusoap.php'; // Create the client instance $wsdlUrl = 'http://' . $_SERVER['SERVER_NAME'] . '/server.php?wsdl&1'; $PROXY_HOST = "127.0.0.1"; $PROXY_PORT = "6081"; // use local-varnish for the proxy $client = new nusoapclient($wsdlUrl, true, $PROXY_HOST, $PROXY_PORT); $err = $client->getError(); if ($err) { echo '<h2>Constructor error</h2><pre>' . $err . '</pre>'; } else { // Create the proxy $proxy = $client->getProxy(); global $LW_USERNAME, $LW_PASSWORD; if ($LW_USERNAME != "" || $LW_PASSWORD != "") { $headers = "<username>{$LW_USERNAME}</username><password>{$LW_PASSWORD}</password>\n"; $proxy->setHeaders($headers); } $songResult = $proxy->getSongResult($artist, $song); } if ($songResult['lyrics'] == $failedLyrics || $songResult['lyrics'] == "") { print "<html><head><title>Error</title></head><body>\n"; // TODO: i18n print '<div style="background-color:#fcc">Sorry, but ' . htmlspecialchars($artist) . ':' . htmlspecialchars($song) . " song still failed.</div>\n"; print_r($songResult); } else { $dbw = wfGetDB(DB_MASTER); print "<html><head><title>Success</title></head><body>\n"; // TODO: i18n print "Deleting record... "; $result = $dbw->delete('lw_soap_failures', ['request_artist' => $artist, 'request_song' => $song], __METHOD__); if ($result) { print "Deleted."; } else { print "Failed. " . mysql_error(); } print "<br/>Clearing the cache... "; $wgMemc->delete($CACHE_KEY_DATA); // purge the entry from memcached $wgMemc->delete($CACHE_KEY_TIME); $wgMemc->delete($CACHE_KEY_STATS); print "<div style='background-color:#cfc'>The song was retrieved successfully and "; print "was removed from the failed requests list."; print "</div>\n"; } global $wgScriptPath; print "<br/>Back to <a href='{$wgScriptPath}/Special:Soapfailures'>SOAP Failures</a>\n"; print "</body></html>"; exit; // wiki system throws database-connection errors if the page is allowed to display itself. } else { $wgOut->addHTML("<style type='text/css'>\n\t\t\t\ttable.soapfailures{\n\t\t\t\t\tborder-collapse:collapse;\n\t\t\t\t}\n\t\t\t\t.soapfailures tr.odd{background-color:#eef}\n\t\t\t\t.soapfailures td, .soapfailures th{\n\t\t\t\t\tborder:1px solid;\n\t\t\t\t\tcell-padding:0px;\n\t\t\t\t\tcell-spacing:0px;\n\t\t\t\t\tvertical-align:top;\n\t\t\t\t\tpadding:5px;\n\t\t\t\t}</style>\n"); // Allow the cache to be manually cleared. $msg = ""; if (isset($_GET['cache']) && $_GET['cache'] == "clear") { $msg .= "Forced clearing of the cache...\n"; $wgMemc->delete($CACHE_KEY_DATA); // purge the entry from memcached $wgMemc->delete($CACHE_KEY_TIME); $wgMemc->delete($CACHE_KEY_STATS); unset($_GET['cache']); $_SERVER['REQUEST_URI'] = str_replace("?cache=clear", "", $_SERVER['REQUEST_URI']); $_SERVER['REQUEST_URI'] = str_replace("&cache=clear", "", $_SERVER['REQUEST_URI']); } $msg = $msg == "" ? "" : "<pre>{$msg}</pre>"; $wgOut->addWikiText($msg); // Form for clearing a fixed song. $wgOut->addHTML(wfMsg('soapfailures-mark-as-fixed') . "\n\t\t\t\t\t\t\t<form method='post'>\n\t\t\t\t\t\t\t\t" . wfMsg('soapfailures-artist') . " <input type='text' name='artist'/><br/>\n\t\t\t\t\t\t\t\t" . wfMsg('soapfailures-song') . " <input type='text' name='song'/><br/>\n\t\t\t\t\t\t\t\t<input type='submit' name='fixed' value='" . wfMsg('soapfailures-fixed') . "'/>\n\t\t\t\t\t\t\t</form><br/>"); $data = $wgMemc->get($CACHE_KEY_DATA); $cachedOn = $wgMemc->get($CACHE_KEY_TIME); $statsHtml = $wgMemc->get($CACHE_KEY_STATS); if (!$data) { $db =& wfGetDB(DB_SLAVE)->getProperty('mConn'); $queryString = "SELECT * FROM lw_soap_failures ORDER BY numRequests DESC LIMIT {$MAX_RESULTS}"; if ($result = mysql_query($queryString, $db)) { $data = array(); if (($numRows = mysql_num_rows($result)) && $numRows > 0) { for ($cnt = 0; $cnt < $numRows; $cnt++) { $row = array(); $row['artist'] = mysql_result($result, $cnt, "request_artist"); $row['song'] = mysql_result($result, $cnt, "request_song"); $row['numRequests'] = mysql_result($result, $cnt, "numRequests"); $row['lookedFor'] = mysql_result($result, $cnt, "lookedFor"); $row['lookedFor'] = formatLookedFor($row['lookedFor']); $data[] = $row; } } } else { $wgOut->addHTML("<br/><br/><strong>Error: with query</strong><br/><em>{$queryString}</em><br/><strong>Error message: </strong>" . mysql_error($db)); } $cachedOn = date('m/d/Y \\a\\t g:ia'); } // Stats HTML is just an unimportant feature, hackily storing HTML instead of the data - FIXME: It's BAD to cache output rather than data. if (!$statsHtml) { // Display some hit-rate stats. ob_start(); include_once __DIR__ . "/soap_stats.php"; // for tracking success/failure print "<br/><br/><br/>"; print "<em>" . wfMsg('soapfailures-stats-header') . "</em><br/>\n"; print "<table border='1px' cellpadding='5px'>\n"; print "\t<tr><th>" . wfMsg('soapfailures-stats-timeperiod') . "</th><th>" . wfMsg('soapfailures-stats-numfound') . "</th><th>" . wfMsg('soapfailures-stats-numnotfound') . "</th><th> </th></tr>\n"; $stats = lw_soapStats_getStats(LW_TERM_DAILY, "", LW_API_TYPE_WEB); print "\t<tr><td>" . wfMsg('soapfailures-stats-period-today') . "</td><td>{$stats[LW_API_FOUND]}</td><td>{$stats[LW_API_NOT_FOUND]}</td><td>{$stats[LW_API_PERCENT_FOUND]}%</td></tr>\n"; $stats = lw_soapStats_getStats(LW_TERM_WEEKLY, "", LW_API_TYPE_WEB); print "\t<tr><td>" . wfMsg('soapfailures-stats-period-thisweek') . "</td><td>{$stats[LW_API_FOUND]}</td><td>{$stats[LW_API_NOT_FOUND]}</td><td>{$stats[LW_API_PERCENT_FOUND]}%</td></tr>\n"; $stats = lw_soapStats_getStats(LW_TERM_MONTHLY, "", LW_API_TYPE_WEB); print "\t<tr><td>" . wfMsg('soapfailures-stats-period-thismonth') . "</td><td>{$stats[LW_API_FOUND]}</td><td>{$stats[LW_API_NOT_FOUND]}</td><td>{$stats[LW_API_PERCENT_FOUND]}%</td></tr>\n"; print "</table>\n"; $statsHtml = ob_get_clean(); } if ($data) { $wgOut->addWikiText(wfMsg('soapfailures-intro')); $wgOut->addHTML("This page is cached every 2 hours - \n"); // TODO: i18n $wgOut->addHTML("last cached: <strong>{$cachedOn}</strong>\n"); // TODO: i18n $totFailures = 0; if (!empty($data)) { $wgOut->addHTML("<table class='soapfailures'>\n"); $wgOut->addHTML("<tr><th nowrap='nowrap'>" . wfMsg('soapfailures-header-requests') . "</th><th>" . wfMsg('soapfailures-header-artist') . "</th><th>" . wfMsg('soapfailures-header-song') . "</th><th>" . wfMsg('soapfailures-header-looked-for') . "</th><th>" . wfMsg('soapfailures-header-fixed') . "</th></tr>\n"); $REQUEST_URI = $_SERVER['REQUEST_URI']; $rowIndex = 0; foreach ($data as $row) { $artist = $row['artist']; $song = $row['song']; $numRequests = $row['numRequests']; $lookedFor = $row['lookedFor']; $totFailures += $numRequests; $wgOut->addHTML(utf8_encode("<tr" . ($rowIndex % 2 != 0 ? " class='odd'" : "") . "><td>{$numRequests}</td><td>")); $wgOut->addWikiText("[[{$artist}]]"); $wgOut->addHTML("</td><td>"); $wgOut->addWikiText("[[{$artist}:{$song}|{$song}]]"); $delim = "&"; $prefix = ""; // If the short-url is in the REQUEST_URI, make sure to add the index.php?title= prefix to it. if (strpos($REQUEST_URI, "index.php?title=") === false) { $prefix = "/index.php?title="; // If we're adding the index.php ourselves, but the request still started with a slash, remove it because that would break the request if it came after the "title=" if (substr($REQUEST_URI, 0, 1) == "/") { $REQUEST_URI = substr($REQUEST_URI, 1); } } $wgOut->addHTML("</td><td>"); $wgOut->addWikiText("{$lookedFor}"); $wgOut->addHTML("</td><td>"); $wgOut->addHTML("<form action='' method='POST' target='_blank'>\n\t\t\t\t\t\t\t\t<input type='hidden' name='artist' value=\"" . Sanitizer::encodeAttribute($artist) . "\"/>\n\t\t\t\t\t\t\t\t<input type='hidden' name='song' value=\"" . Sanitizer::encodeAttribute($song) . "\"/>\n\t\t\t\t\t\t\t\t<input type='submit' name='fixed' value=\"" . wfMessage('soapfailures-fixed')->escaped() . "\"/>\n\t\t\t\t\t\t\t</form>\n"); $wgOut->addHTML("</td>"); $wgOut->addHTML("</tr>\n"); $rowIndex++; } $wgOut->addHTML("</table>\n"); $wgOut->addHTML("<br/>Total of <strong id='lw_numFailures'>{$totFailures}</strong> requests in the top {$MAX_RESULTS}. This number will increase slightly over time, but we should fight to keep it as low as possible!"); } else { $wgOut->addHTML("<em>No results found.</em>\n"); } if (!empty($data)) { $TWO_HOURS_IN_SECONDS = 60 * 60 * 2; $wgMemc->set($CACHE_KEY_TIME, $cachedOn, $TWO_HOURS_IN_SECONDS); $wgMemc->set($CACHE_KEY_STATS, $statsHtml, $TWO_HOURS_IN_SECONDS); // We use CACHE_KEY_DATA to determine when all of these keys have expired, so it should expire a few microseconds after the other two (that's why it's below the other set()s). $wgMemc->set($CACHE_KEY_DATA, $data, $TWO_HOURS_IN_SECONDS); } } $wgOut->addHTML($statsHtml); } }
} ?> <form method=post action="<?php echo $formPostAction; ?> "> <input type=hidden name=loginToken id='loginToken' value="<?php echo Sanitizer::encodeAttribute($loginToken); ?> "> <input type=hidden name=keeploggedin value=true> <?php if (!empty($returnto)) { ?> <input type=hidden name=returnto value="<?php echo Sanitizer::encodeAttribute($returnto); ?> "> <?php } ?> <input type=text name=username class=wkInp placeholder='<?php echo wfMessage('yourname')->escaped(); ?> '<?php echo $username ? ' value="' . htmlspecialchars($username) . '"' : ''; echo $userErr ? ' class=inpErr' : ''; ?> > <?php
?> </th> <?php } ?> </tr> <?php foreach ($content as $item) { ?> <tr class="insights-list-item"> <td class="insights-list-item-page insights-list-cell insights-list-first-column"> <a class="insights-list-item-title <?php echo Sanitizer::encodeAttribute($item['link']['classes']); ?> " title="<?php echo Sanitizer::encodeAttribute($item['link']['title']); ?> " href="<?php echo Sanitizer::cleanUrl($item['link']['url']); ?> "><?php echo Sanitizer::escapeHtmlAllowEntities($item['link']['text']); ?> </a> <?php if (isset($item['metadata'])) { ?> <p class="insights-list-item-metadata"> <?php if (isset($item['metadata']['lastRevision'])) { ?>
* @var string $birthday * @var bool $isEn * @var string $createAccountButtonLabel * @var string $returnto * @var string $msg * @var array $avatars * @var array $popularWikis */ $form = ['id' => 'WikiaSignupForm', 'method' => 'post', 'inputs' => [['type' => 'hidden', 'name' => 'signupToken', 'value' => Sanitizer::encodeAttribute($signupToken)], ['type' => 'hidden', 'name' => 'username', 'value' => '', 'label' => wfMessage('yourname')->escaped()], ['type' => 'text', 'name' => 'userloginext01', 'value' => htmlspecialchars($username), 'label' => wfMessage('yourname')->escaped(), 'isRequired' => true, 'isInvalid' => !empty($errParam) && $errParam === 'username', 'errorMsg' => !empty($msg) ? $msg : ''], ['type' => 'text', 'name' => 'email', 'value' => Sanitizer::encodeAttribute($email), 'label' => wfMessage('email')->escaped(), 'isRequired' => true, 'isInvalid' => !empty($errParam) && $errParam === 'email', 'errorMsg' => !empty($msg) ? $msg : ''], ['type' => 'hidden', 'name' => 'password', 'value' => '', 'label' => wfMessage('yourpassword')->escaped()], ['type' => 'password', 'name' => 'userloginext02', 'value' => '', 'label' => wfMessage('yourpassword')->escaped(), 'isRequired' => true, 'isInvalid' => !empty($errParam) && $errParam === 'password', 'errorMsg' => !empty($msg) ? $msg : ''], ['type' => 'hidden', 'name' => 'wpRegistrationCountry', 'value' => ''], ['type' => 'nirvanaview', 'controller' => 'UserSignupSpecial', 'view' => 'birthday', 'isRequired' => true, 'isInvalid' => !empty($errParam) && $errParam === 'birthyear' || !empty($errParam) && $errParam === 'birthmonth' || !empty($errParam) && $errParam === 'birthday', 'errorMsg' => !empty($msg) ? $msg : '', 'params' => ['birthyear' => $birthyear, 'birthmonth' => $birthmonth, 'birthday' => $birthday, 'isEn' => $isEn]], ['type' => 'nirvana', 'controller' => 'UserSignupSpecial', 'method' => 'captcha', 'isRequired' => true, 'class' => 'captcha', 'isInvalid' => !empty($errParam) && $errParam === 'wpCaptchaWord', 'errorMsg' => !empty($msg) ? $msg : ''], ['class' => 'opt-in-container hidden', 'type' => 'checkbox', 'name' => 'wpMarketingOptIn', 'label' => wfMessage('userlogin-opt-in-label')->escaped()], ['type' => 'nirvanaview', 'controller' => 'UserSignupSpecial', 'view' => 'submit', 'class' => 'submit-pane error', 'params' => ['createAccountButtonLabel' => $createAccountButtonLabel]]]]; $form['isInvalid'] = !empty($result) && $result === 'error' && empty($errParam); $form['errorMsg'] = $form['isInvalid'] ? $msg : ''; if (!empty($returnto)) { $form['inputs'][] = ['type' => 'hidden', 'name' => 'returnto', 'value' => Sanitizer::encodeAttribute($returnto)]; } if (!empty($byemail)) { $form['inputs'][] = ['type' => 'hidden', 'name' => 'byemail', 'value' => Sanitizer::encodeAttribute($byemail)]; } ?> <section class="WikiaSignup"> <?php if (!$isMonobookOrUncyclo) { ?> <h2 class="pageheading"> <?php echo $pageHeading; ?> </h2> <h3 class="subheading"></h3> <div class="wiki-info"> <?php
<div class="UserLogin ChangePassword"> <?php if (!empty($pageHeading)) { ?> <h1><?php echo $pageHeading; ?> </h1> <?php } ?> <?php if (!empty($subheading)) { ?> <h2 class="subheading"><?php echo $subheading; ?> </h2> <?php } ?> <?php $form = array('method' => 'post', 'action' => $formPostAction, 'inputs' => array(array('type' => 'hidden', 'name' => 'editToken', 'value' => htmlspecialchars($editToken)), array('type' => 'hidden', 'name' => 'loginToken', 'value' => htmlspecialchars($loginToken)), array('type' => 'hidden', 'name' => 'username', 'value' => htmlspecialchars($username)), array('type' => 'hidden', 'name' => 'returnto', 'value' => Sanitizer::encodeAttribute($returnto)), array('type' => 'custom', 'output' => '<label>' . wfMessage('yourname')->escaped() . '</label><p class="username">' . htmlspecialchars($username) . '</p>'), array('type' => 'password', 'name' => 'password', 'id' => 'password', 'label' => wfMessage('userlogin-oldpassword')->escaped(), 'value' => htmlspecialchars($password)), array('type' => 'password', 'name' => 'newpassword', 'id' => 'newpassword', 'label' => wfMessage('userlogin-newpassword')->escaped()), array('type' => 'password', 'name' => 'retype', 'id' => 'retype', 'label' => wfMessage('userlogin-retypenew')->escaped())), 'submits' => array(array('value' => wfMessage('resetpass_submit')->escaped(), 'name' => 'action', 'class' => 'big login-button'))); $form['isInvalid'] = $result == 'error'; $form['errorMsg'] = !empty($msg) ? $msg : ''; echo F::app()->renderView('WikiaStyleGuideForm', 'index', array('form' => $form)); ?> </div>
<div id="UserLoginDropdown" class="UserLoginDropdown subnav"> <?php $tabIndex = 0; $form = array('inputs' => array(array('type' => 'hidden', 'name' => 'loginToken', 'value' => ''), array('type' => 'hidden', 'name' => 'returnto', 'value' => Sanitizer::encodeAttribute($returnto)), array('type' => 'hidden', 'name' => 'returntoquery', 'value' => Sanitizer::encodeAttribute($returntoquery)), array('type' => 'text', 'name' => 'username', 'isRequired' => true, 'label' => wfMessage('yourname')->escaped(), 'tabindex' => ++$tabIndex), array('type' => 'password', 'name' => 'password', 'class' => 'password-input', 'isRequired' => true, 'label' => wfMessage('yourpassword')->escaped(), 'tabindex' => ++$tabIndex), array('type' => 'nirvanaview', 'controller' => 'UserLogin', 'view' => 'forgotPasswordLink'), array('type' => 'checkbox', 'name' => 'keeploggedin', 'class' => 'keep-logged-in', 'value' => '1', 'label' => wfMessage('userlogin-remembermypassword')->escaped(), 'tabindex' => ++$tabIndex), array('type' => 'submit', 'value' => wfMessage('login')->escaped(), 'class' => 'login-button', 'tabindex' => ++$tabIndex)), 'method' => 'post', 'action' => $formPostAction); $form['isInvalid'] = true; $form['errorMsg'] = ''; echo $app->renderView('WikiaStyleGuideForm', 'index', array('form' => $form)); // 3rd party providers buttons echo $app->renderView('UserLoginSpecial', 'Providers', array('tabindex' => ++$tabIndex)); ?> </div>
<footer class="global-footer"> <nav> <div class="branding <?php echo !empty($verticalShort) ? 'vertical-' . $verticalShort : ''; ?> <?php echo !$isCorporate ? 'black' : ''; ?> "> <a class="wikia-logo" href="<?php echo Sanitizer::encodeAttribute($logoLink); ?> "> <img src="<?php echo $wg->BlankImgUrl; ?> "> <?php if (!$isCorporate && !empty($verticalShort)) { ?> <span><?php echo $verticalNameMessage->escaped(); ?> </span> <?php } ?> </a> </div> <ul> <?php
"> <div class="category-gallery-item-image"> <?php if (!empty($row['img'])) { ?> <img src="<?php echo Sanitizer::encodeAttribute($row['img']); ?> " alt="<?php echo Sanitizer::encodeAttribute($row['title']); ?> " width="<?php echo Sanitizer::encodeAttribute($row['width']); ?> " height="<?php echo Sanitizer::encodeAttribute($row['height']); ?> " /> <?php } elseif (!empty($row['snippet'])) { ?> <div class="snippet"> <span class="quote">“</span> <span class="text"><?php echo htmlspecialchars($row['snippet']); ?> </span> </div> <?php } else { ?>
<?php if (empty($code)) { echo "<p class=\"error\">{$resultMessage}</p>"; } else { ?> <div class="UserLogin UserConfirm"> <h2 class="subheading"><?php echo wfMessage('wikiaconfirmemail-subheading')->escaped(); ?> </h2> <?php $form = ['method' => 'post', 'inputs' => [['type' => 'hidden', 'name' => 'code', 'value' => Sanitizer::encodeAttribute($code)], ['type' => 'hidden', 'name' => 'editToken', 'value' => htmlspecialchars($editToken)], ['type' => 'hidden', 'name' => 'loginToken', 'value' => htmlspecialchars($loginToken)], ['type' => 'text', 'name' => 'username', 'label' => wfMessage('wikiaconfirmemail-username')->escaped(), 'value' => Sanitizer::encodeAttribute($username), 'isInvalid' => !empty($errParam) && $errParam === 'username', 'errorMsg' => !empty($resultMessage) ? $resultMessage : ''], ['type' => 'password', 'name' => 'password', 'label' => wfMessage('yourpassword')->escaped(), 'isInvalid' => !empty($errParam) && $errParam === 'password', 'errorMsg' => !empty($resultMessage) ? $resultMessage : '']], 'submits' => [['name' => 'action', 'value' => wfMessage('wikiaconfirmemail-login-button')->escaped(), 'class' => 'big login-button']]]; $form['isInvalid'] = empty($success) && empty($errParam) && !empty($resultMessage); $form['errorMsg'] = !empty($resultMessage) ? $resultMessage : ''; echo F::app()->renderView('WikiaStyleGuideForm', 'index', ['form' => $form]); ?> </div> <?php }
<div class="UserLoginModal"> <?php $tabIndex = 5; $specialSignupLink = SpecialPage::getTitleFor('UserSignup')->getLocalURL(); $form = array('inputs' => array(array('type' => 'hidden', 'name' => 'loginToken', 'value' => Sanitizer::encodeAttribute($loginToken)), array('type' => 'hidden', 'name' => 'returnto', 'value' => ''), array('type' => 'text', 'name' => 'username', 'isRequired' => true, 'label' => wfMessage('yourname')->escaped(), 'tabindex' => ++$tabIndex), array('type' => 'password', 'name' => 'password', 'class' => 'password-input', 'isRequired' => true, 'label' => wfMessage('yourpassword')->escaped(), 'tabindex' => ++$tabIndex), array('type' => 'custom', 'output' => '<a href="#" class="forgot-password" tabindex="0">' . wfMessage('userlogin-forgot-password')->escaped() . '</a>'), array('type' => 'checkbox', 'name' => 'keeploggedin', 'value' => '1', 'label' => wfMessage('userlogin-remembermypassword')->escaped(), 'class' => 'keep-logged-in', 'tabindex' => ++$tabIndex), array('type' => 'submit', 'value' => wfMessage('login')->escaped(), 'class' => 'login-button big', 'tabindex' => ++$tabIndex), array('type' => 'custom', 'output' => wfMessage('userlogin-get-account', array($specialSignupLink, ++$tabIndex))->inContentLanguage()->text(), 'class' => 'get-account', 'tabindex' => ++$tabIndex)), 'method' => 'post', 'action' => $formPostAction); //$form['isInvalid'] = true; //$form['errorMsg'] = ''; echo $app->renderView('WikiaStyleGuideForm', 'index', array('form' => $form)); echo $app->renderView('UserLoginSpecial', 'Providers', array('tabindex' => ++$tabIndex)); ?> </div>
/** * Renders and returns the output. * @see ParserHook::render * * @since 0.1 * * @param array $parameters * * @return string */ public function render(array $parameters) { $title = $this->getTitle($parameters['page']); $pages = $this->getSubPages($title, $parameters); // There is no need in encoding `$parameters['element']', because it is validated and can // be only one of `span', `p', or `div'. $element = $parameters['element']; // Using `$parameters['class']' is dangerous and may be a security hole, because it may lead // to incorrect (or malicious) HTML code. `encodeAttribute' solves the issue. $class = Sanitizer::encodeAttribute($parameters['class']); $open = "<{$element} class=\"{$class}\">"; $close = "</{$element}>"; $inlineList = $parameters['format'] == 'list' || $parameters['format'] == 'bar'; $inlineText = $element == 'span'; $list = ''; if (count($pages) > 0) { $intro = $parameters['intro']; $outro = $parameters['outro']; if ($inlineText && !$inlineList) { if ($intro !== '') { $list .= $open . $intro . $close; } $list .= "<div class=\"{$class}\">" . $this->makeList($title, $parameters, $pages) . "</div>"; if ($outro !== "") { $list .= $open . $outro . $close; } } else { $list = $open . $intro . $this->makeList($title, $parameters, $pages) . $outro . $close; } $list = $this->parseWikitext($list); } else { $default = $parameters['default']; if ($default === "") { if (is_null($title)) { $list = "''" . wfMsg('spl-noparentpage', $parameters['page']) . "''"; } elseif ($title instanceof Title) { $list = "''" . wfMsg('spl-nosubpages', '[[' . $title->getFullText() . ']]') . "''"; } else { $list = "''" . wfMsg('spl-nopages', $parameters['page']) . "''"; } } elseif ($default !== "-") { $list = $default; } // Format element only if content is not empty. if ($list !== "") { $list = $open . $this->parseWikitext($list) . $close; } } return $list; }
"> <input type="submit" value="<?php echo wfMessage('usersignup-confirm-email-resend-email')->escaped(); ?> " class="link"> </div> </fieldset> </form> <?php if (!$isMonobookOrUncyclo) { ?> <p> <?php echo $app->sendRequest('WikiaStyleGuideTooltipIconController', 'index', array('text' => wfMessage('usersignup-confirm-email-change-email-content'), 'classes' => 'email-tooltip', 'tooltipIconTitle' => wfMessage('usersignup-confirm-email-tooltip')->escaped())); ?> <br /> <a href="#" class="change-email-link"><?php echo wfMessage('usersignup-confirm-email-change-email')->escaped(); ?> </a> </p> <?php $form = array('method' => 'post', 'class' => 'email-form' . (!empty($msgEmail) ? ' show' : ''), 'inputs' => array(array('type' => 'hidden', 'name' => 'action', 'value' => 'changeemail'), array('type' => 'hidden', 'name' => 'username', 'value' => htmlspecialchars($username)), array('type' => 'text', 'label' => wfMessage('usersignup-confirm-email-new-email-label')->escaped(), 'name' => 'email', 'isInvalid' => !empty($errParam) && $errParam === 'email', 'value' => !empty($email) ? Sanitizer::encodeAttribute($email) : '', 'errorMsg' => !empty($msgEmail) ? $msgEmail : '')), 'submits' => array(array('value' => wfMessage('usersignup-confirm-email-update')->escaped(), 'class' => 'update-button'))); echo F::app()->renderView('WikiaStyleGuideForm', 'index', array('form' => $form)); } //$isMonobookOrUncyclo } //$isbyemail ?> </section>
<div id="UserLoginDropdown" class="UserLoginDropdown global-nav-dropdown"> <div class="ajaxRegisterContainer"><?php echo $registerLink; ?> </div> <?php $tabIndex = 0; $cachedMessages = ['yourname' => wfMessage('yourname')->escaped(), 'yourpassword' => wfMessage('yourpassword')->escaped()]; $form = ['inputs' => [['type' => 'hidden', 'name' => 'loginToken', 'value' => ''], ['type' => 'hidden', 'name' => 'returnto', 'value' => Sanitizer::encodeAttribute($returnto)], ['type' => 'hidden', 'name' => 'returntoquery', 'value' => Sanitizer::encodeAttribute($returntoquery)], ['id' => 'usernameInput', 'type' => 'text', 'name' => 'username', 'class' => 'hide-label', 'isRequired' => true, 'placeholder' => $cachedMessages['yourname'], 'label' => $cachedMessages['yourname'], 'tabindex' => ++$tabIndex], ['id' => 'passwordInput', 'type' => 'password', 'name' => 'password', 'class' => 'hide-label', 'isRequired' => true, 'placeholder' => $cachedMessages['yourpassword'], 'label' => $cachedMessages['yourpassword'], 'tabindex' => ++$tabIndex], ['type' => 'nirvanaview', 'controller' => 'UserLogin', 'view' => 'forgotPasswordLink'], ['type' => 'checkbox', 'name' => 'keeploggedin', 'class' => 'keep-logged-in', 'value' => '1', 'label' => wfMessage('userlogin-remembermypassword')->escaped(), 'tabindex' => ++$tabIndex], ['type' => 'submit', 'value' => wfMessage('login')->escaped(), 'class' => 'login-button', 'tabindex' => ++$tabIndex]], 'method' => 'post', 'action' => $formPostAction]; $form['isInvalid'] = true; $form['errorMsg'] = ''; echo $app->renderView('WikiaStyleGuideForm', 'index', ['form' => $form]); // 3rd party providers buttons echo $app->renderView('UserLoginSpecial', 'Providers', ['tabindex' => ++$tabIndex]); ?> </div>
<div class="UserLogin"> <?php $tabIndex = 5; $loginTokenInput = array('type' => 'hidden', 'name' => 'loginToken', 'value' => Sanitizer::encodeAttribute($loginToken)); $userNameInput = array('type' => 'text', 'name' => 'username', 'isRequired' => true, 'label' => wfMessage('yourname')->escaped(), 'isInvalid' => !empty($errParam) && $errParam === 'username', 'value' => htmlspecialchars($username), 'tabindex' => ++$tabIndex); $userNameInput['errorMsg'] = $userNameInput['isInvalid'] ? $msg : ''; $passwordInput = array('type' => 'password', 'name' => 'password', 'class' => 'password-input', 'isRequired' => true, 'label' => wfMessage('yourpassword')->escaped(), 'isInvalid' => !empty($errParam) && $errParam === 'password', 'value' => htmlspecialchars($password), 'tabindex' => ++$tabIndex); $passwordInput['errorMsg'] = $passwordInput['isInvalid'] ? $msg : ''; $forgotPasswordLinkUrl = SpecialPage::getTitleFor('UserLogin')->getLocalURL(array('type' => 'forgotPassword')); $forgotPasswordLink = array('type' => 'custom', 'output' => '<a href="' . $forgotPasswordLinkUrl . '" class="forgot-password" tabindex="0">' . wfMessage('userlogin-forgot-password')->escaped() . '</a>'); $rememberMeInput = array('type' => 'checkbox', 'name' => 'keeploggedin', 'class' => 'keep-logged-in', 'isRequired' => false, 'value' => '1', 'checked' => $keeploggedin, 'label' => wfMessage('userlogin-remembermypassword')->escaped(), 'tabindex' => ++$tabIndex); $loginBtn = array('type' => 'submit', 'value' => wfMessage('login')->escaped(), 'class' => 'login-button big', 'tabindex' => ++$tabIndex); $specialSignupLink = SpecialPage::getTitleFor('UserSignup')->getLocalURL(); $createAccount = array('type' => 'custom', 'output' => wfMessage('userlogin-get-account', array($specialSignupLink, ++$tabIndex))->inContentLanguage()->text(), 'class' => 'get-account', 'tabindex' => ++$tabIndex); $form = array('inputs' => array($loginTokenInput, $userNameInput, $passwordInput, $forgotPasswordLink, $rememberMeInput, $loginBtn, $createAccount), 'method' => 'post'); $form['isInvalid'] = !empty($result) && empty($errParam) && !empty($msg); $form['errorMsg'] = !empty($msg) ? $msg : ''; if (!empty($returnto)) { $form['inputs'][] = array('type' => 'hidden', 'name' => 'returnto', 'value' => Sanitizer::encodeAttribute($returnto)); } if (!empty($returntoquery)) { $form['inputs'][] = array('type' => 'hidden', 'name' => 'returntoquery', 'value' => Sanitizer::encodeAttribute($returntoquery)); } echo $app->renderView('WikiaStyleGuideForm', 'index', array('form' => $form)); // 3rd party providers buttons if (!$isMonobookOrUncyclo) { echo $app->renderView('UserLoginSpecial', 'Providers', array('tabindex' => ++$tabIndex)); } ?> </div>
private function doubleQuote($text) { return Sanitizer::encodeAttribute($text); }
static function newFromExternalLink($url, $label) { $item = new ALItem(); $item->label = $label; $item->text = "<a class=\"external text\" rel=\"nofollow\" href=\"" . Sanitizer::encodeAttribute($url) . "\">" . htmlspecialchars($label) . "</a>"; return $item; }
/** * Encode an attribute value for HTML tags, with extra armoring * against further wiki processing. * @param string $text * @return string HTML-encoded text fragment */ static function safeEncodeAttribute($text) { $encValue = Sanitizer::encodeAttribute($text); # Templates and links may be expanded in later parsing, # creating invalid or dangerous output. Suppress this. $encValue = strtr($encValue, array('<' => '<', '>' => '>', '"' => '"', '{' => '{', '[' => '[', "''" => '''', 'ISBN' => 'ISBN', 'RFC' => 'RFC', 'PMID' => 'PMID', '|' => '|', '__' => '__')); # Stupid hack $encValue = preg_replace_callback('/((?i)' . wfUrlProtocols() . ')/', array('Sanitizer', 'armorLinksCallback'), $encValue); return $encValue; }
?> </a> </li> <?php break; case 'devinfo': /* Temporary, BugId:5497; TODO: call getPerformanceStats in DevInfoUserCommand.php rather than here */ ?> <li class="loadtime"> <span><?php echo wfGetPerformanceStats(); ?> </span> </li> <?php break; case 'disabled': ?> <li class="overflow"> <span title="<?php echo Sanitizer::encodeAttribute($item['error-message']); ?> "><?php echo htmlspecialchars($item['caption']); ?> </span> </li> <?php break; } }
echo $userName; } else { echo wfMessage('userlogin-login-heading')->text(); } ?> </header> <?php if ($loggedIn) { ?> <ul class=wkLst> <li><a class=chg href="<?php echo Sanitizer::encodeAttribute(AvatarService::getUrl($userName)); ?> "><?php echo wfMessage('wikiamobile-profile')->escaped(); ?> </a></li> <li><a class=logout href="<?php echo Sanitizer::encodeAttribute(str_replace("\$1", SpecialPage::getSafeTitleFor('UserLogout')->getPrefixedText() . '?returnto=' . $wg->Title->getPrefixedURL(), $wg->ArticlePath)); ?> "><?php echo wfMessage('logout')->escaped(); ?> </a></li> </ul> <?php } ?> </div> </section>
/** * Encode an attribute value for HTML tags, with extra armoring * against further wiki processing. * @param $text * @return HTML-encoded text fragment */ static function safeEncodeAttribute($text) { $encValue = Sanitizer::encodeAttribute($text); # Templates and links may be expanded in later parsing, # creating invalid or dangerous output. Suppress this. $encValue = strtr($encValue, array('<' => '<', '>' => '>', '"' => '"', '{' => '{', '[' => '[', "''" => '''', 'ISBN' => 'ISBN', 'RFC' => 'RFC', 'PMID' => 'PMID', '|' => '|', '__' => '__')); # Stupid hack $rawProtocols = array('http://', 'https://', 'ftp://', 'irc://', 'gopher://', 'telnet://', 'nntp://', 'worldwind://', 'mailto:', 'news:'); $protocols = array(); foreach ($rawProtocols as $protocol) { $protocols[] = preg_quote($protocol, '/'); } $encValue = preg_replace_callback('/(' . implode('|', $protocols) . ')/', array('Sanitizer', 'armorLinksCallback'), $encValue); return $encValue; }
private function getLanguageOptions() { $options = []; $languages = $this->getClient()->getSupportedLanguages(); foreach ($languages as $code => $language) { $options[] = ['value' => $code, 'content' => Sanitizer::encodeAttribute($code . ' - ' . $language)]; } return $options; }
protected function getIndexParams($forPaginator = false) { if ($forPaginator) { $page = '%s'; } else { $page = $this->page; } $indexParams = ['searchPhrase' => $this->searchPhrase, 'verticalId' => Sanitizer::encodeAttribute($this->selectedVerticalId), 'langCode' => $this->selectedLangCode, 'date' => isset($this->selectedDate) ? $this->selectedDate : null, 'page' => Sanitizer::encodeAttribute($page)]; return $indexParams; }