• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Sanitizer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testSanitize

 public function testSanitize()
 {
     $given = array("field1" => "<p>A <strong>string</strong> with an <script></script>escaped apostrophe: it\\'s</p>", "field2" => array("it\\'s cool", "yeah it\\'s cool"));
     $expected = array("field1" => "<p>A <strong>string</strong> with an escaped apostrophe: it's</p>", "field2" => array("it's cool", "yeah it's cool"));
     $sanitizer = new Sanitizer($given);
     $sanitizer->stripslashes()->striptags(array("<p>", "<strong>"));
     $this->assertEquals($expected, $sanitizer->data);
 }
开发者ID:jenwachter,项目名称:html-form,代码行数:8,代码来源:SanitizerTest.php


示例2: __construct

    function __construct($job_id = false)
    {
        global $db;
        if (is_numeric($job_id)) {
            $sanitizer = new Sanitizer();
            $sql = 'SELECT a.type_id AS type_id, a.category_id AS category_id, a.title AS title, a.summary AS summary, 
			               a.description AS description, a.company AS company, a.url AS url, a.apply AS apply, 
			               DATE_FORMAT(a.created_on, "' . DATE_FORMAT . '") AS created_on, a.created_on AS mysql_date,
			               a.is_temp AS is_temp, a.is_active AS is_active, a.spotlight AS spotlight,
			               a.views_count AS views_count, a.auth AS auth, a.city_id AS city_id, a.outside_location AS outside_location,
			               a.poster_email AS poster_email, a.apply_online AS apply_online, b.name AS category_name,
			               c.var_name as type_var_name, c.name as type_name,
			               DATE_ADD(created_on, INTERVAL 30 DAY) AS closed_on, DATEDIFF(NOW(), created_on) AS days_old, cit.name AS city_name
			               FROM ' . DB_PREFIX . 'jobs a LEFT JOIN ' . DB_PREFIX . 'cities cit on a.city_id = cit.id, ' . DB_PREFIX . 'categories b, ' . DB_PREFIX . 'types c
			               WHERE a.category_id = b.id AND c.id = a.type_id AND a.id = ' . $job_id;
            $result = $db->query($sql);
            $row = $result->fetch_assoc();
            if (!empty($row)) {
                $this->mId = $job_id;
                $this->mTypeId = $row['type_id'];
                $this->mCategoryId = $row['category_id'];
                $this->mCategoryName = $row['category_name'];
                $this->mTitle = str_replace('&', '&amp;', $row['title']);
                $this->mSummary = str_replace('&', '&amp;', $row['summary']);
                $this->mDescription = $row['description'];
                $this->mCompany = $row['company'];
                $this->mUrl = $row['url'];
                $this->mApply = $row['apply'];
                $this->mCreatedOn = $row['created_on'];
                $this->mClosedOn = $row['closed_on'];
                $this->mIsTemp = $row['is_temp'];
                $this->mIsActive = $row['is_active'];
                $this->mViewsCount = $row['views_count'];
                $this->mAuth = $row['auth'];
                $this->mCityId = $row['city_id'];
                $this->mMySqlDate = $row['mysql_date'];
                $this->mLocation = $this->GetLocation($row);
                $this->mLocationOutsideRo = $row['outside_location'];
                $this->mPosterEmail = $row['poster_email'];
                $this->mUrlTitle = $sanitizer->sanitize_title_with_dashes($this->mTitle . ' at ' . $this->mCompany);
                $this->mApplyOnline = $row['apply_online'];
                $this->mDaysOld = $row['days_old'];
                $this->mIsSpotlight = $row['spotlight'];
                $this->mTypeName = $row['type_name'];
                $this->mTypeVarName = $row['type_var_name'];
            }
        }
    }
开发者ID:bklein01,项目名称:jobberbase,代码行数:48,代码来源:class.Job.php


示例3: getDiv

 public function getDiv($value)
 {
     global $wgOut, $wgPromoterAdPreview;
     if (array_key_exists('language', $this->mParams)) {
         $language = $this->mParams['language'];
     } else {
         $language = $wgOut->getContext()->getLanguage()->getCode();
     }
     $html = Xml::openElement('div', array('id' => Sanitizer::escapeId("pr-ad-list-element-{$this->mParams['ad']}"), 'class' => "pr-ad-list-element"));
     // Make the label; this consists of a text link to the ad editor, and a series of status icons
     if (array_key_exists('withlabel', $this->mParams)) {
         $adName = $this->mParams['ad'];
         $html .= Xml::openElement('div', array('class' => 'pr-ad-list-element-label'));
         $html .= Linker::link(SpecialPage::getTitleFor('PromoterAds', "edit/{$adName}"), htmlspecialchars($adName), array('class' => 'pr-ad-list-element-label-text'));
         $html .= ' (' . Linker::link(SpecialPage::getTitleFor('Randompage'), $this->msg('promoter-live-preview'), array('class' => 'pr-ad-list-element-label-text'), array('ad' => $adName, 'uselang' => $language, 'force' => '1')) . ')';
         // TODO: Output status icons
         $html .= Xml::tags('div', array('class' => 'pr-ad-list-element-label-icons'), '');
         $html .= Xml::closeElement('div');
     }
     // Add the ad preview
     if ($wgPromoterAdPreview) {
         $html .= $this->getInputHTML(null);
     }
     $html .= Xml::closeElement('div');
     return $html;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:26,代码来源:HTMLPromoterAd.php


示例4: execute

 function execute()
 {
     global $wgLang, $wgRequest;
     global $wgOut, $wgExtensionsPath;
     global $wgUser, $wgCaptchaClass, $wgJsMimeType;
     $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/SpecialContact/SpecialContact.scss'));
     $this->mName = null;
     $this->mRealName = null;
     $this->mWhichWiki = null;
     $this->mProblem = $wgRequest->getText('wpContactSubject');
     //subject
     $this->mProblemDesc = null;
     $this->mPosted = $wgRequest->wasPosted();
     $this->mAction = $wgRequest->getVal('action');
     $this->mEmail = $wgRequest->getText('wpEmail');
     $this->mBrowser = $wgRequest->getText('wpBrowser');
     $this->mAbTestInfo = $wgRequest->getText('wpAbTesting');
     $this->mCCme = $wgRequest->getCheck('wgCC');
     if ($this->mPosted && 'submit' == $this->mAction) {
         if (!$wgUser->isLoggedIn() && class_exists($wgCaptchaClass)) {
             $captchaObj = new $wgCaptchaClass();
             $captchaObj->retrieveCaptcha();
             $info = $captchaObj->retrieveCaptcha();
         }
         #ubrfzy note: these were moved inside to (lazy) prevent some stupid bots
         $this->mName = $wgRequest->getText('wpName');
         $this->mRealName = $wgRequest->getText('wpContactRealName');
         $this->mWhichWiki = $wgRequest->getText('wpContactWikiName');
         #sibject still handled outside of post check, because of existing hardcoded prefill links
         $this->mProblemDesc = $wgRequest->getText('wpContactDesc');
         //body
         #malformed email?
         if (!Sanitizer::validateEmail($this->mEmail)) {
             $this->err[] .= wfMsg('invalidemailaddress');
             $this->errInputs['wpEmail'] = true;
         }
         #empty message text?
         if (empty($this->mProblemDesc)) {
             $this->err[] .= wfMsg('specialcontact-nomessage');
             $this->errInputs['wpContactDesc'] = true;
         }
         #captcha
         if (!$wgUser->isLoggedIn() && class_exists($wgCaptchaClass)) {
             // logged in users don't need the captcha (RT#139647)
             if (!(!empty($info) && $captchaObj->keyMatch($wgRequest->getVal('wpCaptchaWord'), $info))) {
                 $this->err[] .= wfMsg('specialcontact-captchafail');
                 $this->errInputs['wpCaptchaWord'] = true;
             }
         }
         #no errors?
         if (empty($this->err)) {
             #send email
             $this->processCreation();
             #stop here
             return;
         }
         #if there were any ->err s, they will be displayed in ContactForm
     }
     $this->mainContactForm();
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:60,代码来源:SpecialContact.body.php


示例5: efGPManagerCustomToolboxAppend

function efGPManagerCustomToolboxAppend(&$skin)
{
    global $wgOut, $wgUser;
    $tb = explode("\n", wfMsg('toolbox_append'));
    $new = array();
    foreach ($tb as &$nt) {
        if (strpos($nt, '*') === 0) {
            $nt = trim($nt, '*');
            $parts = explode('|', $nt);
            foreach ($parts as &$part) {
                $part = trim($part);
            }
            $href = wfMsgForContent($parts[0]);
            $text = wfMsgForContent($parts[1]);
            $perm = array_key_exists(2, $parts) ? $parts[2] : 'read';
            if (!$wgUser->isAllowed($perm)) {
                continue;
            }
            if (wfEmptyMsg($parts[0], $href)) {
                $href = $parts[0];
            }
            if (wfEmptyMsg($parts[1], $text)) {
                $text = $parts[1];
            }
            $id = Sanitizer::escapeId($parts[1], 'noninitial');
            $new[] = array($href, $text, $id);
        }
    }
    foreach ($new as $t) {
        echo '<li id="t-' . $t[2] . '"><a href="' . htmlspecialchars($t[0]) . '">' . $t[1] . '</a></li>';
    }
    return true;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:33,代码来源:CustomToolbox.php


示例6: getHtml

 /**
  * Builds the HTML code for this component
  *
  * @return String the HTML code
  */
 public function getHtml()
 {
     $element = $this->getDomElement();
     if ($element === null) {
         return '';
     }
     $msgKey = $element->getAttribute('message');
     $menuFactory = new MenuFactory();
     if (empty($msgKey)) {
         $text = $element->textContent;
         $menu = $menuFactory->getMenuFromMessageText($text);
     } else {
         $menu = $menuFactory->getMenuFromMessage($msgKey);
     }
     $menu->setMenuItemFormatter(function ($href, $text, $depth, $subitems) {
         $href = \Sanitizer::cleanUrl($href);
         $text = htmlspecialchars($text);
         if ($depth === 1 && !empty($subitems)) {
             return "<li class=\"dropdown\"><a class=\"dropdown-toggle\" href=\"#\"  data-toggle=\"dropdown\">{$text}<b class=\"caret\"></b></a>{$subitems}</li>";
         } else {
             return "<li><a href=\"{$href}\">{$text}</a>{$subitems}</li>";
         }
     });
     $menu->setItemListFormatter(function ($rawItemsHtml, $depth) {
         if ($depth === 0) {
             return $rawItemsHtml;
         } elseif ($depth === 1) {
             return "<ul class=\"dropdown-menu\">{$rawItemsHtml}</ul>";
         } else {
             return "<ul>{$rawItemsHtml}</ul>";
         }
     });
     return $menu->getHtml();
 }
开发者ID:atawsports2,项目名称:mediawiki-skins-chameleon,代码行数:39,代码来源:Menu.php


示例7: execute

 /**
  * Main execution point
  *
  * @param null|string $code Confirmation code passed to the page
  * @throws PermissionsError
  * @throws ReadOnlyError
  * @throws UserNotLoggedIn
  */
 function execute($code)
 {
     // Ignore things like master queries/connections on GET requests.
     // It's very convenient to just allow formless link usage.
     $trxProfiler = Profiler::instance()->getTransactionProfiler();
     $this->setHeaders();
     $this->checkReadOnly();
     $this->checkPermissions();
     // This could also let someone check the current email address, so
     // require both permissions.
     if (!$this->getUser()->isAllowed('viewmyprivateinfo')) {
         throw new PermissionsError('viewmyprivateinfo');
     }
     if ($code === null || $code === '') {
         $this->requireLogin('confirmemail_needlogin');
         if (Sanitizer::validateEmail($this->getUser()->getEmail())) {
             $this->showRequestForm();
         } else {
             $this->getOutput()->addWikiMsg('confirmemail_noemail');
         }
     } else {
         $old = $trxProfiler->setSilenced(true);
         $this->attemptConfirm($code);
         $trxProfiler->setSilenced($old);
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:34,代码来源:SpecialConfirmemail.php


示例8: _stripMarkup

 /**
  * Strip markup to show plaintext
  * @param string $text
  * @return string
  * @access private
  */
 function _stripMarkup($text)
 {
     global $wgContLang;
     $text = substr($text, 0, 4096);
     // don't bother with long text...
     $text = str_replace("'''", "", $text);
     $text = str_replace("''", "", $text);
     $text = preg_replace('#__[a-z0-9_]+__#i', '', $text);
     // magic words
     $cleanChar = "[^|\\[\\]]";
     $subLink = "\\[\\[{$cleanChar}*(?:\\|{$cleanChar}*)*\\]\\]";
     $pipeContents = "(?:{$cleanChar}|{$subLink})*";
     $text = preg_replace_callback("#\n\t\t\t\\[\\[\n\t\t\t\t({$cleanChar}*)\n\t\t\t\t(?:\\|({$pipeContents}))?\n\t\t\t\t(?:\\|{$pipeContents})*\n\t\t\t\\]\\]\n\t\t\t#six", array($this, '_stripLink'), $text);
     $protocols = wfUrlProtocols();
     $text = preg_replace('#\\[(?:$protocols).*? (.*?)\\]#s', '$1', $text);
     // URL links
     $text = preg_replace('#</?[a-z0-9]+.*?>#s', '', $text);
     // HTML-style tags
     $text = preg_replace('#\\{\\|.*?\\|\\}#s', '', $text);
     // tables
     $text = preg_replace('#^:.*$#m', '', $text);
     // indented lines near start are usually disambigs or notices
     $text = Sanitizer::decodeCharReferences($text);
     return trim($text);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:31,代码来源:IndexAbstracts.php


示例9: formatSummaryRow

 /**
  * Creates HTML for the given tags
  *
  * @param string $tags Comma-separated list of tags
  * @param string $page A label for the type of action which is being displayed,
  *   for example: 'history', 'contributions' or 'newpages'
  * @return array Array with two items: (html, classes)
  *   - html: String: HTML for displaying the tags (empty string when param $tags is empty)
  *   - classes: Array of strings: CSS classes used in the generated html, one class for each tag
  */
 public static function formatSummaryRow($tags, $page)
 {
     global $wgLang;
     if (!$tags) {
         return array('', array());
     }
     $classes = array();
     $tags = explode(',', $tags);
     $displayTags = array();
     foreach ($tags as $tag) {
         if (!$tag) {
             continue;
         }
         $description = self::tagDescription($tag);
         if ($description === false) {
             continue;
         }
         $displayTags[] = Xml::tags('span', array('class' => 'mw-tag-marker ' . Sanitizer::escapeClass("mw-tag-marker-{$tag}")), $description);
         $classes[] = Sanitizer::escapeClass("mw-tag-{$tag}");
     }
     if (!$displayTags) {
         return array('', array());
     }
     $markers = wfMessage('tag-list-wrapper')->numParams(count($displayTags))->rawParams($wgLang->commaList($displayTags))->parse();
     $markers = Xml::tags('span', array('class' => 'mw-tag-markers'), $markers);
     return array($markers, $classes);
 }
开发者ID:agothro,项目名称:mediawiki,代码行数:37,代码来源:ChangeTags.php


示例10: parseWikitext

 protected function parseWikitext($title, $newRevId)
 {
     $apiParams = array('action' => 'parse', 'page' => $title->getPrefixedDBkey(), 'oldid' => $newRevId, 'prop' => 'text|revid|categorieshtml|displaytitle|modules|jsconfigvars');
     $api = new ApiMain(new DerivativeRequest($this->getRequest(), $apiParams, false), true);
     $api->execute();
     if (defined('ApiResult::META_CONTENT')) {
         $result = $api->getResult()->getResultData(null, array('BC' => array(), 'Types' => array(), 'Strip' => 'all'));
     } else {
         $result = $api->getResultData();
     }
     $content = isset($result['parse']['text']['*']) ? $result['parse']['text']['*'] : false;
     $categorieshtml = isset($result['parse']['categorieshtml']['*']) ? $result['parse']['categorieshtml']['*'] : false;
     $links = isset($result['parse']['links']) ? $result['parse']['links'] : array();
     $revision = Revision::newFromId($result['parse']['revid']);
     $timestamp = $revision ? $revision->getTimestamp() : wfTimestampNow();
     $displaytitle = isset($result['parse']['displaytitle']) ? $result['parse']['displaytitle'] : false;
     $modules = isset($result['parse']['modules']) ? $result['parse']['modules'] : array();
     $jsconfigvars = isset($result['parse']['jsconfigvars']) ? $result['parse']['jsconfigvars'] : array();
     if ($content === false || strlen($content) && $revision === null) {
         return false;
     }
     if ($displaytitle !== false) {
         // Escape entities as in OutputPage::setPageTitle()
         $displaytitle = Sanitizer::normalizeCharReferences(Sanitizer::removeHTMLtags($displaytitle));
     }
     return array('content' => $content, 'categorieshtml' => $categorieshtml, 'basetimestamp' => $timestamp, 'starttimestamp' => wfTimestampNow(), 'displayTitleHtml' => $displaytitle, 'modules' => $modules, 'jsconfigvars' => $jsconfigvars);
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:27,代码来源:ApiVisualEditorEdit.php


示例11: wfCSSRender

function wfCSSRender(&$parser, $css)
{
    global $wgOut, $wgRequest;
    $parser->mOutput->mCacheTime = -1;
    $url = false;
    if (preg_match('|\\{|', $css)) {
        # Inline CSS
        $css = htmlspecialchars(trim(Sanitizer::checkCss($css)));
        $parser->mOutput->addHeadItem(<<<EOT
<style type="text/css">
/*<![CDATA[*/
{$css}
/*]]>*/
</style>
EOT
);
    } elseif ($css[0] == '/') {
        # File
        $url = $css;
    } else {
        # Article?
        $title = Title::newFromText($css);
        if (is_object($title)) {
            $url = $title->getLocalURL('action=raw&ctype=text/css');
            $url = str_replace("&", "&amp;", $url);
        }
    }
    if ($url) {
        $wgOut->addScript("<link rel=\"stylesheet\" type=\"text/css\" href=\"{$url}\" />");
    }
    return '';
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:32,代码来源:CSS.php


示例12: PoemExtension

function PoemExtension($in, $param = array(), $parser = null)
{
    /* using newlines in the text will cause the parser to add <p> tags,
     * which may not be desired in some cases
     */
    $nl = isset($param['compact']) ? '' : "\n";
    if (method_exists($parser, 'recursiveTagParse')) {
        //new methods in 1.8 allow nesting <nowiki> in <poem>.
        $tag = $parser->insertStripItem("<br />", $parser->mStripState);
        $text = preg_replace(array("/^\n/", "/\n\$/D", "/\n/", "/^( +)/me"), array("", "", "{$tag}\n", "str_replace(' ','&nbsp;','\\1')"), $in);
        $text = $parser->recursiveTagParse($text);
    } else {
        $text = preg_replace(array("/^\n/", "/\n\$/D", "/\n/", "/^( +)/me"), array("", "", "<br />\n", "str_replace(' ','&nbsp;','\\1')"), $in);
        $ret = $parser->parse($text, $parser->getTitle(), $parser->getOptions(), true, false);
        $text = $ret->getText();
    }
    global $wgVersion;
    if (version_compare($wgVersion, "1.7alpha") >= 0) {
        // Pass HTML attributes through to the output.
        $attribs = Sanitizer::validateTagAttributes($param, 'div');
    } else {
        // Can't guarantee safety on 1.6 or older.
        $attribs = array();
    }
    // Wrap output in a <div> with "poem" class.
    if (isset($attribs['class'])) {
        $attribs['class'] = 'poem ' . $attribs['class'];
    } else {
        $attribs['class'] = 'poem';
    }
    return Xml::openElement('div', $attribs) . $nl . trim($text) . "{$nl}</div>";
}
开发者ID:akoehn,项目名称:wikireader,代码行数:32,代码来源:Poem.php


示例13: formatSummaryRow

 /**
  * Creates HTML for the given tags
  *
  * @param string $tags Comma-separated list of tags
  * @param string $page A label for the type of action which is being displayed,
  *   for example: 'history', 'contributions' or 'newpages'
  * @param IContextSource|null $context
  * @note Even though it takes null as a valid argument, an IContextSource is preferred
  *       in a new code, as the null value is subject to change in the future
  * @return array Array with two items: (html, classes)
  *   - html: String: HTML for displaying the tags (empty string when param $tags is empty)
  *   - classes: Array of strings: CSS classes used in the generated html, one class for each tag
  */
 public static function formatSummaryRow($tags, $page, IContextSource $context = null)
 {
     if (!$tags) {
         return array('', array());
     }
     if (!$context) {
         $context = RequestContext::getMain();
     }
     $classes = array();
     $tags = explode(',', $tags);
     $displayTags = array();
     foreach ($tags as $tag) {
         if (!$tag) {
             continue;
         }
         $description = self::tagDescription($tag);
         if ($description === false) {
             continue;
         }
         $displayTags[] = Xml::tags('span', array('class' => 'mw-tag-marker ' . Sanitizer::escapeClass("mw-tag-marker-{$tag}")), $description);
         $classes[] = Sanitizer::escapeClass("mw-tag-{$tag}");
     }
     if (!$displayTags) {
         return array('', array());
     }
     $markers = $context->msg('tag-list-wrapper')->numParams(count($displayTags))->rawParams($context->getLanguage()->commaList($displayTags))->parse();
     $markers = Xml::tags('span', array('class' => 'mw-tag-markers'), $markers);
     return array($markers, $classes);
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:42,代码来源:ChangeTags.php


示例14: receiverIsValid

 public static function receiverIsValid($receiver)
 {
     // Returns true if the parameter is a valid e-mail address, false if not
     $receiverIsValid = true;
     // There may be multiple e-mail addresses, divided by commas - which is valid
     // for us, but not for the validation functions we use below. So get the single
     // address into an array first, validate them one by one, and only if all are ok,
     // return true.
     $receiverArray = explode(',', str_replace(', ', ',', $receiver));
     // To make sure some joker doesn't copy in a large number of e-mail addresses
     // and spams them all, lets set a (admittedly arbitrary) limit of 10.
     if (count($receiverArray) > 10) {
         return false;
     }
     if (method_exists('Sanitizer', 'validateEmail')) {
         // User::isValidEmailAddr() has been moved to Sanitizer::validateEmail as of
         // MediaWiki version 1.18 (I think).
         foreach ($receiverArray as $singleEmailAddress) {
             if (!Sanitizer::validateEmail($singleEmailAddress)) {
                 $receiverIsValid = false;
             }
         }
     } else {
         foreach ($receiverArray as $singleEmailAddress) {
             if (!User::isValidEmailAddr($singleEmailAddress)) {
                 $receiverIsValid = false;
             }
         }
     }
     return $receiverIsValid;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:31,代码来源:Notificator.body.php


示例15: execute

 /**
  * Show the special page
  * @param string|null $par
  */
 public function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $out = $this->getOutput();
     $out->addModuleStyles('mediawiki.special');
     $out->addHTML(\Html::openElement('table', array('class' => 'wikitable mw-listgrouprights-table')) . '<tr>' . \Html::element('th', null, $this->msg('listgrants-grant')->text()) . \Html::element('th', null, $this->msg('listgrants-rights')->text()) . '</tr>');
     foreach ($this->getConfig()->get('GrantPermissions') as $grant => $rights) {
         $descs = array();
         $rights = array_filter($rights);
         // remove ones with 'false'
         foreach ($rights as $permission => $granted) {
             $descs[] = $this->msg('listgrouprights-right-display', \User::getRightDescription($permission), '<span class="mw-listgrants-right-name">' . $permission . '</span>')->parse();
         }
         if (!count($descs)) {
             $grantCellHtml = '';
         } else {
             sort($descs);
             $grantCellHtml = '<ul><li>' . implode("</li>\n<li>", $descs) . '</li></ul>';
         }
         $id = \Sanitizer::escapeId($grant);
         $out->addHTML(\Html::rawElement('tr', array('id' => $id), "<td>" . $this->msg("grant-{$grant}")->escaped() . "</td>" . "<td>" . $grantCellHtml . '</td>'));
     }
     $out->addHTML(\Html::closeElement('table'));
 }
开发者ID:Gomyul,项目名称:mediawiki,代码行数:29,代码来源:SpecialListgrants.php


示例16: recentChangesLine

 /**
  * Format a line using the old system (aka without any javascript).
  *
  * @param RecentChange $rc Passed by reference
  * @param bool $watched (default false)
  * @param int $linenumber (default null)
  *
  * @return string|bool
  */
 public function recentChangesLine(&$rc, $watched = false, $linenumber = null)
 {
     $classes = array();
     // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
     if ($linenumber) {
         if ($linenumber & 1) {
             $classes[] = 'mw-line-odd';
         } else {
             $classes[] = 'mw-line-even';
         }
     }
     // Indicate watched status on the line to allow for more
     // comprehensive styling.
     $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
     $html = $this->formatChangeLine($rc, $classes, $watched);
     if ($this->watchlist) {
         $classes[] = Sanitizer::escapeClass('watchlist-' . $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title']);
     }
     if (!Hooks::run('OldChangesListRecentChangesLine', array(&$this, &$html, $rc, &$classes))) {
         return false;
     }
     $dateheader = '';
     // $html now contains only <li>...</li>, for hooks' convenience.
     $this->insertDateHeader($dateheader, $rc->mAttribs['rc_timestamp']);
     return "{$dateheader}<li class=\"" . implode(' ', $classes) . "\">" . $html . "</li>\n";
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:35,代码来源:OldChangesList.php


示例17: testDecodeTagAttributes

 function testDecodeTagAttributes()
 {
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo=bar'), array('foo' => 'bar'), 'Unquoted attribute');
     $this->assertEquals(Sanitizer::decodeTagAttributes('    foo   =   bar    '), array('foo' => 'bar'), 'Spaced attribute');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo="bar"'), array('foo' => 'bar'), 'Double-quoted attribute');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo=\'bar\''), array('foo' => 'bar'), 'Single-quoted attribute');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo=\'bar\'   baz="foo"'), array('foo' => 'bar', 'baz' => 'foo'), 'Several attributes');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo=\'bar\'   baz="foo"'), array('foo' => 'bar', 'baz' => 'foo'), 'Several attributes');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo=\'bar\'   baz="foo"'), array('foo' => 'bar', 'baz' => 'foo'), 'Several attributes');
     $this->assertEquals(Sanitizer::decodeTagAttributes(':foo=\'bar\''), array(':foo' => 'bar'), 'Leading :');
     $this->assertEquals(Sanitizer::decodeTagAttributes('_foo=\'bar\''), array('_foo' => 'bar'), 'Leading _');
     $this->assertEquals(Sanitizer::decodeTagAttributes('Foo=\'bar\''), array('foo' => 'bar'), 'Leading capital');
     $this->assertEquals(Sanitizer::decodeTagAttributes('FOO=BAR'), array('foo' => 'BAR'), 'Attribute keys are normalized to lowercase');
     # Invalid beginning
     $this->assertEquals(Sanitizer::decodeTagAttributes('-foo=bar'), array(), 'Leading - is forbidden');
     $this->assertEquals(Sanitizer::decodeTagAttributes('.foo=bar'), array(), 'Leading . is forbidden');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo-bar=bar'), array('foo-bar' => 'bar'), 'A - is allowed inside the attribute');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo-=bar'), array('foo-' => 'bar'), 'A - is allowed inside the attribute');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo.bar=baz'), array('foo.bar' => 'baz'), 'A . is allowed inside the attribute');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo.=baz'), array('foo.' => 'baz'), 'A . is allowed as last character');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo6=baz'), array('foo6' => 'baz'), 'Numbers are allowed');
     # This bit is more relaxed than XML rules, but some extensions use it, like ProofreadPage (see bug 27539)
     $this->assertEquals(Sanitizer::decodeTagAttributes('1foo=baz'), array('1foo' => 'baz'), 'Leading numbers are allowed');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo$=baz'), array(), 'Symbols are not allowed');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo@=baz'), array(), 'Symbols are not allowed');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo~=baz'), array(), 'Symbols are not allowed');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo=1[#^`*%w/('), array('foo' => '1[#^`*%w/('), 'All kind of characters are allowed as values');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo="1[#^`*%\'w/("'), array('foo' => '1[#^`*%\'w/('), 'Double quotes are allowed if quoted by single quotes');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo=\'1[#^`*%"w/(\''), array('foo' => '1[#^`*%"w/('), 'Single quotes are allowed if quoted by double quotes');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo=&amp;&quot;'), array('foo' => '&"'), 'Special chars can be provided as entities');
     $this->assertEquals(Sanitizer::decodeTagAttributes('foo=&foobar;'), array('foo' => '&foobar;'), 'Entity-like items are accepted');
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:32,代码来源:SanitizerTest.php


示例18: execute

	/**
	 * Main execution point
	 *
	 * @param null|string $code Confirmation code passed to the page
	 */
	function execute( $code ) {
		$this->setHeaders();

		$this->checkReadOnly();
		$this->checkPermissions();

		// This could also let someone check the current email address, so
		// require both permissions.
		if ( !$this->getUser()->isAllowed( 'viewmyprivateinfo' ) ) {
			throw new PermissionsError( 'viewmyprivateinfo' );
		}

		if ( $code === null || $code === '' ) {
			if ( $this->getUser()->isLoggedIn() ) {
				if ( Sanitizer::validateEmail( $this->getUser()->getEmail() ) ) {
					$this->showRequestForm();
				} else {
					$this->getOutput()->addWikiMsg( 'confirmemail_noemail' );
				}
			} else {
				$llink = Linker::linkKnown(
					SpecialPage::getTitleFor( 'Userlogin' ),
					$this->msg( 'loginreqlink' )->escaped(),
					array(),
					array( 'returnto' => $this->getTitle()->getPrefixedText() )
				);
				$this->getOutput()->addHTML(
					$this->msg( 'confirmemail_needlogin' )->rawParams( $llink )->parse()
				);
			}
		} else {
			$this->attemptConfirm( $code );
		}
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:39,代码来源:SpecialConfirmemail.php


示例19: execute

 public function execute()
 {
     $this->commit = $this->hasOption('commit');
     $dbr = $this->getDB(DB_SLAVE);
     $dbw = $this->getDB(DB_MASTER);
     $lastId = 0;
     do {
         $rows = $dbr->select('user', array('user_id', 'user_email'), array('user_id > ' . $dbr->addQuotes($lastId), 'user_email != ""', 'user_email_authenticated IS NULL'), __METHOD__, array('LIMIT' => $this->mBatchSize));
         $count = $rows->numRows();
         $badIds = array();
         foreach ($rows as $row) {
             if (!Sanitizer::validateEmail(trim($row->user_email))) {
                 $this->output("Found bad email: {$row->user_email} for user #{$row->user_id}\n");
                 $badIds[] = $row->user_id;
             }
             if ($row->user_id > $lastId) {
                 $lastId = $row->user_id;
             }
         }
         if ($badIds) {
             $badCount = count($badIds);
             if ($this->commit) {
                 $this->output("Removing {$badCount} emails from the database.\n");
                 $dbw->update('user', array('user_email' => ''), array('user_id' => $badIds), __METHOD__);
                 foreach ($badIds as $badId) {
                     User::newFromId($badId)->invalidateCache();
                 }
                 wfWaitForSlaves();
             } else {
                 $this->output("Would have removed {$badCount} emails from the database.\n");
             }
         }
     } while ($count !== 0);
     $this->output("Done.\n");
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:35,代码来源:removeInvalidEmails.php


示例20: 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");
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:26,代码来源:checkContacts.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP SapphireTest类代码示例发布时间:2022-05-23
下一篇:
PHP Sanitize类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap