本文整理汇总了PHP中SugarCleaner::cleanHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarCleaner::cleanHtml方法的具体用法?PHP SugarCleaner::cleanHtml怎么用?PHP SugarCleaner::cleanHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarCleaner
的用法示例。
在下文中一共展示了SugarCleaner::cleanHtml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEmailCleanup
function testEmailCleanup()
{
$inStr = <<<EOS
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt">hello, <o:p></o:p></SPAN><BR>
<SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt">i recently got Batman Arkham City and tried to get catwoman as an add-on character but when i put the code in it said that my code had already been used. <o:p></o:p></SPAN><BR>
<SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt">what can i do, so that i can play catwoman?<o:p></o:p></SPAN><BR>
<BR> </div></body>
</html>
EOS;
$outStr = <<<EOS
<div dir="ltr">
<span style="font-family:Tahoma, 'sans-serif';font-size:10pt;">hello, </span><p></p><br /><span style="font-family:Tahoma, 'sans-serif';font-size:10pt;">i recently got Batman Arkham City and tried to get catwoman as an add-on character but when i put the code in it said that my code had already been used. </span><p></p><br /><span style="font-family:Tahoma, 'sans-serif';font-size:10pt;">what can i do, so that i can play catwoman?</span><p></p><br /><br /></div>
EOS;
$actual = SugarCleaner::cleanHtml($inStr);
// Normalize the line endings - Bug #51227
$outStr = str_replace("\r\n", "\n", $outStr);
$actual = str_replace("\r\n", "\n", $actual);
$this->assertEquals(trim($outStr), trim($actual));
}
示例2: save
/**
* Saves the current comment.
* @param boolean $check_notify
* @return string|bool GUID of saved comment or false.
*/
public function save($check_notify = false)
{
//if a string convert to object
if (is_string($this->data)) {
$this->data = json_decode($this->data, true);
}
if (!empty($this->data['value'])) {
$this->data['value'] = SugarCleaner::cleanHtml($this->data['value']);
}
if (!is_string($this->data)) {
$this->data = json_encode($this->data);
}
$activity = BeanFactory::getBean('Activities', $this->parent_id);
if (!empty($activity) && $activity->id) {
$isNew = empty($this->id) || $this->new_with_id;
if (parent::save($check_notify)) {
if ($isNew) {
$activity->addComment($this);
$this->processCommentTags($activity);
}
return $this->id;
}
}
return false;
}
示例3: save
function save($df)
{
$this->ext3 = 'text';
// clean the field of any dangerous html tags like the script tag, etc
$this->ext4 = SugarCleaner::cleanHtml($this->ext4, true);
parent::save($df);
}
示例4: handleSave
/**
* Takes in the request params from a save request and processes
* them for the save.
* @param REQUEST $params Labels as "label_".System label => Display label pairs
* @param string $language Language key, for example 'en_us'
*/
function handleSave($params, $language)
{
$labels = array();
foreach ($params as $key => $value) {
if (preg_match('/^label_/', $key) && strcmp($value, 'no_change') != 0) {
$labels[strtoupper(substr($key, 6))] = SugarCleaner::cleanHtml(from_html($value), false);
}
}
if (!empty($this->packageName)) {
return self::addLabels($language, $labels, $this->moduleName, "custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/language");
} else {
$addLabelsResult = true;
$addExtLabelsResult = true;
$extLabels = array();
$extFile = "custom/modules/" . $this->moduleName . "/Ext/Language/" . $language . ".lang.ext.php";
if (is_file($extFile)) {
include $extFile;
foreach ($labels as $key => $value) {
if (isset($mod_strings[$key])) {
$extLabels[$key] = $value;
unset($labels[$key]);
}
}
}
if (!empty($labels)) {
$addLabelsResult = self::addLabels($language, $labels, $this->moduleName);
}
if (!empty($extLabels)) {
$addExtLabelsResult = self::addLabels($language, $extLabels, $this->moduleName, null, true);
}
return $addLabelsResult && $addExtLabelsResult;
}
}
示例5: testEmailCleanup
/**
* @dataProvider getUrls
* @param string $url
*/
function testEmailCleanup($url, $imgShouldBeRemoved)
{
$data = "Test: <img src=\"{$url}\">";
if ($imgShouldBeRemoved) {
$res = str_replace("<img />", "", SugarCleaner::cleanHtml($data));
$this->assertNotContains("<img", $res);
} else {
$this->assertContains("<img", SugarCleaner::cleanHtml($data));
}
}
示例6: handleSave
/**
* Takes in the request params from a save request and processes
* them for the save.
* @param REQUEST $params Labels as "label_".System label => Display label pairs
* @param string $language Language key, for example 'en_us'
*/
function handleSave($params, $language)
{
$labels = array();
foreach ($params as $key => $value) {
if (preg_match('/^label_/', $key) && strcmp($value, 'no_change') != 0) {
$labels[strtoupper(substr($key, 6))] = SugarCleaner::cleanHtml(from_html($value), false);
}
}
if (!empty($this->packageName)) {
return self::addLabels($language, $labels, $this->moduleName, "custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/language");
} else {
return self::addLabels($language, $labels, $this->moduleName);
}
}
示例7: save
function save($check_notify = false)
{
$this->name = SugarCleaner::cleanHtml($this->name);
$this->description = SugarCleaner::cleanHtml($this->description);
global $current_user, $sugar_config;
parent::save($check_notify);
$email_template = new EmailTemplate();
if ($_REQUEST['module'] == 'Import') {
//Don't send email on import
return;
}
if (!isAOPEnabled()) {
return;
}
if ($this->internal) {
return;
}
$signature = array();
$addDelimiter = true;
$aop_config = $sugar_config['aop'];
if ($this->assigned_user_id) {
if ($aop_config['contact_email_template_id']) {
$email_template = $email_template->retrieve($aop_config['contact_email_template_id']);
$signature = $current_user->getDefaultSignature();
}
if ($email_template) {
foreach ($this->getContacts() as $contact) {
$GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
$emails = array();
$emails[] = $contact->emailAddress->getPrimaryAddress($contact);
$res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter, $contact->id);
}
}
} else {
$emails = $this->getEmailForUser();
if ($aop_config['user_email_template_id']) {
$email_template = $email_template->retrieve($aop_config['user_email_template_id']);
}
$addDelimiter = false;
if ($emails && $email_template) {
$GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
$res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter, $this->contact_id);
}
}
if ($emails && $email_template) {
$GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
$res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter);
}
}
示例8: save
function save($check_notify = false)
{
$this->name = SugarCleaner::cleanHtml($this->name);
$this->description = SugarCleaner::cleanHtml($this->description);
parent::save($check_notify);
if (file_exists('custom/modules/AOP_Case_Updates/CaseUpdatesHook.php')) {
require_once 'custom/modules/AOP_Case_Updates/CaseUpdatesHook.php';
} else {
require_once 'modules/AOP_Case_Updates/CaseUpdatesHook.php';
}
if (class_exists('CustomCaseUpdatesHook')) {
$hook = new CustomCaseUpdatesHook();
} else {
$hook = new CaseUpdatesHook();
}
$hook->sendCaseUpdate($this);
}
示例9: remove_xss
/**
* Remove potential xss vectors from strings
* @param string str String to search for XSS attack vectors
* @deprecated
* @return string
*/
function remove_xss($str)
{
return SugarCleaner::cleanHtml($str, false);
}
示例10: saveText
/**
* Used to save text on textarea blur. Accessed via Home/CallMethodDashlet.php
* This is an example of how to to call a custom method via ajax
*/
function saveText()
{
$json = getJSONobj();
if (isset($_REQUEST['savedText'])) {
$optionsArray = $this->loadOptions();
$optionsArray['savedText'] = $json->decode(html_entity_decode($_REQUEST['savedText']));
$optionsArray['savedText'] = SugarCleaner::cleanHtml(nl2br($optionsArray['savedText']));
$this->storeOptions($optionsArray);
} else {
$optionsArray['savedText'] = '';
}
echo 'result = ' . $json->encode(array('id' => $_REQUEST['id'], 'savedText' => $optionsArray['savedText']));
}
示例11: cleanBean
/**
* Cleans char, varchar, text, etc. fields of XSS type materials
*/
function cleanBean()
{
foreach ($this->field_defs as $key => $def) {
if (isset($def['type'])) {
$type = $def['type'];
}
if (isset($def['dbType'])) {
$type .= $def['dbType'];
}
if ($def['type'] == 'html' || $def['type'] == 'longhtml') {
$this->{$key} = SugarCleaner::cleanHtml($this->{$key}, true);
} elseif ((strpos($type, 'char') !== false || strpos($type, 'text') !== false || $type == 'enum') && !empty($this->{$key})) {
$this->{$key} = SugarCleaner::cleanHtml($this->{$key});
}
}
}
示例12: getMessageText
/**
* returns the HTML text part of a multi-part message
*
* @param int msgNo the relative message number for the monitored mailbox
* @param string $type the type of text processed, either 'PLAIN' or 'HTML'
* @return string UTF-8 encoded version of the requested message text
*/
function getMessageText($msgNo, $type, $structure, $fullHeader, $clean_email = true, $bcOffset = "")
{
global $sugar_config;
$msgPart = '';
$bc = $this->buildBreadCrumbs($structure->parts, $type);
//Add an offset if specified
if (!empty($bcOffset)) {
$bc = $this->addBreadCrumbOffset($bc, $bcOffset);
}
if (!empty($bc)) {
// multi-part
// HUGE difference between PLAIN and HTML
if ($type == 'PLAIN') {
$msgPart = $this->getMessageTextFromSingleMimePart($msgNo, $bc, $structure);
} else {
// get part of structure that will
$msgPartRaw = '';
$bcArray = $this->buildBreadCrumbsHTML($structure->parts, $bcOffset);
// construct inline HTML/Rich msg
foreach ($bcArray as $bcArryKey => $bcArr) {
foreach ($bcArr as $type => $bcTrail) {
if ($type == 'html') {
$msgPartRaw .= $this->getMessageTextFromSingleMimePart($msgNo, $bcTrail, $structure);
} else {
// deal with inline image
$part = $this->getPartByPath($bcTrail, $structure->parts);
if (empty($part) || empty($part->id)) {
continue;
}
$partid = substr($part->id, 1, -1);
// strip <> around
if (isset($this->inlineImages[$partid])) {
$imageName = $this->inlineImages[$partid];
$newImagePath = "class=\"image\" src=\"{$this->imagePrefix}{$imageName}\"";
$preImagePath = "src=\"cid:{$partid}\"";
$msgPartRaw = str_replace($preImagePath, $newImagePath, $msgPartRaw);
}
}
}
}
$msgPart = $msgPartRaw;
}
} else {
// either PLAIN message type (flowed) or b0rk3d RFC
// make sure we're working on valid data here.
if ($structure->subtype != $type) {
return '';
}
$decodedHeader = $this->decodeHeader($fullHeader);
// now get actual body contents
$text = imap_body($this->conn, $msgNo);
$upperCaseKeyDecodeHeader = array();
if (is_array($decodedHeader)) {
$upperCaseKeyDecodeHeader = array_change_key_case($decodedHeader, CASE_UPPER);
}
// if
if (isset($upperCaseKeyDecodeHeader[strtoupper('Content-Transfer-Encoding')])) {
$flip = array_flip($this->transferEncoding);
$text = $this->handleTranserEncoding($text, $flip[strtoupper($upperCaseKeyDecodeHeader[strtoupper('Content-Transfer-Encoding')])]);
}
if (is_array($upperCaseKeyDecodeHeader['CONTENT-TYPE']) && isset($upperCaseKeyDecodeHeader['CONTENT-TYPE']['charset']) && !empty($upperCaseKeyDecodeHeader['CONTENT-TYPE']['charset'])) {
// we have an explicit content type, use it
$msgPart = $this->handleCharsetTranslation($text, $upperCaseKeyDecodeHeader['CONTENT-TYPE']['charset']);
} else {
// make a best guess as to what our content type is
$msgPart = $this->convertToUtf8($text);
}
}
// end else clause
$msgPart = $this->customGetMessageText($msgPart);
/* cn: bug 9176 - htmlEntitites hide XSS attacks. */
if ($type == 'PLAIN') {
return SugarCleaner::cleanHtml(to_html($msgPart), false);
}
// Bug 50241: can't process <?xml:namespace .../> properly. Strip <?xml ...> tag first.
$msgPart = preg_replace("/<\\?xml[^>]*>/", "", $msgPart);
return SugarCleaner::cleanHtml($msgPart, false);
}
示例13: die
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/*
* Your installation or use of this SugarCRM file is subject to the applicable
* terms available at
* http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/.
* If you do not agree to all of the applicable terms or do not have the
* authority to bind the entity as an authorized representative, then do not
* install or use this SugarCRM file.
*
* Copyright (C) SugarCRM Inc. All rights reserved.
*/
if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'show_raw') {
if (!class_exists("Email")) {
}
$email = BeanFactory::getBean('Emails', $_REQUEST['metadata']);
echo nl2br(SugarCleaner::cleanHtml($email->raw_source));
} else {
require_once 'include/Popups/Popup_picker.php';
$popup = new Popup_Picker();
echo $popup->process_page();
}
示例14: clean
protected function clean($str)
{
return SugarCleaner::cleanHtml($str, false);
}
示例15: save
function save($check_notify = false)
{
global $current_user;
if ($this->isDuplicate) {
$GLOBALS['log']->debug("EMAIL - tried to save a duplicate Email record");
} else {
if (empty($this->id)) {
$this->id = create_guid();
$this->new_with_id = true;
}
$this->from_addr_name = $this->cleanEmails($this->from_addr_name);
$this->to_addrs_names = $this->cleanEmails($this->to_addrs_names);
$this->cc_addrs_names = $this->cleanEmails($this->cc_addrs_names);
$this->bcc_addrs_names = $this->cleanEmails($this->bcc_addrs_names);
$this->reply_to_addr = $this->cleanEmails($this->reply_to_addr);
$this->description = SugarCleaner::cleanHtml($this->description);
$this->description_html = SugarCleaner::cleanHtml($this->description_html, true);
$this->raw_source = SugarCleaner::cleanHtml($this->raw_source, true);
$this->saveEmailText();
$this->saveEmailAddresses();
$GLOBALS['log']->debug('-------------------------------> Email called save()');
// handle legacy concatenation of date and time fields
//Bug 39503 - SugarBean is not setting date_sent when seconds missing
if (empty($this->date_sent)) {
global $timedate;
$date_sent_obj = $timedate->fromUser($timedate->merge_date_time($this->date_start, $this->time_start), $current_user);
if (!empty($date_sent_obj) && $date_sent_obj instanceof SugarDateTime) {
$this->date_sent = $date_sent_obj->asDb();
}
}
parent::save($check_notify);
if (!empty($this->parent_type) && !empty($this->parent_id)) {
if (!empty($this->fetched_row) && !empty($this->fetched_row['parent_id']) && !empty($this->fetched_row['parent_type'])) {
if ($this->fetched_row['parent_id'] != $this->parent_id || $this->fetched_row['parent_type'] != $this->parent_type) {
$mod = strtolower($this->fetched_row['parent_type']);
$rel = array_key_exists($mod, $this->field_defs) ? $mod : $mod . "_activities_emails";
//Custom modules rel name
if ($this->load_relationship($rel)) {
$this->{$rel}->delete($this->id, $this->fetched_row['parent_id']);
}
}
}
$mod = strtolower($this->parent_type);
$rel = array_key_exists($mod, $this->field_defs) ? $mod : $mod . "_activities_emails";
//Custom modules rel name
if ($this->load_relationship($rel)) {
$this->{$rel}->add($this->parent_id);
}
}
}
$GLOBALS['log']->debug('-------------------------------> Email save() done');
}