本文整理汇总了PHP中htmlentities函数的典型用法代码示例。如果您正苦于以下问题:PHP htmlentities函数的具体用法?PHP htmlentities怎么用?PHP htmlentities使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了htmlentities函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: html_purify
function html_purify($dirty_html, $config = FALSE)
{
require_once APPPATH . 'third_party/htmlpurifier-4.6.0-standalone/HTMLPurifier.standalone.php';
if (is_array($dirty_html)) {
foreach ($dirty_html as $key => $val) {
$clean_html[$key] = html_purify($val, $config);
}
} else {
$ci =& get_instance();
switch ($config) {
//settings for rhe WYSIWYG
case 'comment':
$config = HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', $ci->config->item('charset'));
$config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$config->set('HTML.Allowed', 'a[href|title],img[title|src|alt],em,strong,cite,blockquote,code,ul,ol,li,dl,dt,dd,p,br,h1,h2,h3,h4,h5,h6,span,*[style]');
$config->set('AutoFormat.AutoParagraph', TRUE);
$config->set('AutoFormat.Linkify', TRUE);
$config->set('AutoFormat.RemoveEmpty', TRUE);
break;
case FALSE:
$config = HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', $ci->config->item('charset'));
$config->set('HTML.Doctype', 'XHTML 1.0 Strict');
break;
default:
show_error('The HTMLPurifier configuration labeled "' . htmlentities($config, ENT_QUOTES, 'UTF-8') . '" could not be found.');
}
$purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($dirty_html);
}
return $clean_html;
}
示例2: doCompile
/**
* Methode to compile a Smarty template
*
* @param $_content template source
* @return bool true if compiling succeeded, false if it failed
*/
protected function doCompile($_content)
{
/* here is where the compiling takes place. Smarty
tags in the templates are replaces with PHP code,
then written to compiled files. */
// init the lexer/parser to compile the template
$this->lex = new $this->lexer_class($_content, $this);
$this->parser = new $this->parser_class($this->lex, $this);
if (isset($this->smarty->_parserdebug)) $this->parser->PrintTrace();
// get tokens from lexer and parse them
while ($this->lex->yylex() && !$this->abort_and_recompile) {
if (isset($this->smarty->_parserdebug)) echo "<pre>Line {$this->lex->line} Parsing {$this->parser->yyTokenName[$this->lex->token]} Token " . htmlentities($this->lex->value) . "</pre>";
$this->parser->doParse($this->lex->token, $this->lex->value);
}
if ($this->abort_and_recompile) {
// exit here on abort
return false;
}
// finish parsing process
$this->parser->doParse(0, 0);
// check for unclosed tags
if (count($this->_tag_stack) > 0) {
// get stacked info
list($_open_tag, $_data) = array_pop($this->_tag_stack);
$this->trigger_template_error("unclosed {" . $_open_tag . "} tag");
}
// return compiled code
// return str_replace(array("? >\n<?php","? ><?php"), array('',''), $this->parser->retvalue);
return $this->parser->retvalue;
}
示例3: toXml
public static function toXml($data, $rootNodeName = 'data', $xml = null)
{
// turn off compatibility mode as simple xml throws a wobbly if you don't.
if (ini_get('zend.ze1_compatibility_mode') == 1) {
ini_set('zend.ze1_compatibility_mode', 0);
}
if ($xml == null) {
$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><{$rootNodeName} />");
}
// loop through the data passed in.
foreach ($data as $key => $value) {
// no numeric keys in our xml please!
if (is_numeric($key)) {
// make string key...
$key = "child_" . (string) $key;
}
// replace anything not alpha numeric
$key = preg_replace('/[^a-z]/i', '', $key);
// if there is another array found recrusively call this function
if (is_array($value)) {
$node = $xml->addChild($key);
// recrusive call.
ArrayToXML::toXml($value, $rootNodeName, $node);
} else {
// add single node.
$value = htmlentities($value);
$xml->addChild($key, $value);
}
}
// pass back as string. or simple xml object if you want!
return $xml->asXML();
}
示例4: addeditBanner
public function addeditBanner($Data, $id)
{
if ($id == 0) {
$fields = 'title';
$_POST['md_title'] = htmlentities($_POST['md_title'], ENT_QUOTES);
$_POST['md_description'] = htmlentities($_POST['md_description'], ENT_QUOTES);
if ($_FILES['db_background']['name'] != '') {
$fileName = removeUnsed($_FILES['db_background']['name']);
move_uploaded_file($_FILES['db_background']['tmp_name'], UPLOAD_ROOT_PATH . $fileName);
$FileNameArray = pathinfo('upload/' . $fileName);
mpeg2flv('upload/' . $fileName, $FileNameArray['filename']);
$_POST['db_background'] = $fileName;
$fields .= ', background';
//$fieldValues .=",'".htmlspecialchars($_POST['db_background'],ENT_QUOTES)."'";
$_POST['db_background'] = htmlentities($_POST['db_background'], ENT_QUOTES);
}
} else {
if (isset($_POST['video_name'])) {
$_POST['db_background'] = $_POST['video_name'];
}
}
$query = $this->db->query("select title from tbl_banner where id!=" . $id . " and title='" . $Data['md_title'] . "'");
$RsCount = $query->result_array();
if (count($RsCount) == 0) {
if ($id == 0) {
$this->insertFormContent();
} else {
$this->updateFormContent($id);
}
return $id;
} else {
return 0;
}
}
示例5: msg
public static function msg($msg, $type)
{
$core = core::getInstance();
if (ROOT == './') {
$class = array('error' => 'error', 'success' => 'success', 'info' => 'info', 'warning' => 'warning');
if (!isset($class[$type])) {
$type = 'info';
}
$data = '';
eval($core->callHook('startShowMsg'));
if ($msg != '') {
$data = '<div id="msg" class="' . $class[$type] . '"><p>' . nl2br(htmlentities($msg)) . '</p></div>';
}
} else {
$class = array('error' => 'alert', 'success' => 'success', 'info' => 'info', 'warning' => 'warning');
if (!isset($class[$type])) {
$type = 'info';
}
$data = '';
eval($core->callHook('startShowMsg'));
if ($msg != '') {
$data = '<div data-alert class="alert-box ' . $class[$type] . ' radius">
<p>' . nl2br(htmlentities($msg)) . '</p><a href="#" class="close">×</a>
</div>';
}
}
eval($core->callHook('endShowMsg'));
echo $data;
}
示例6: standard_error
/**
* Prints one ore more errormessages on screen
*
* @param array Errormessages
* @param string A %s in the errormessage will be replaced by this string.
* @author Florian Lippert <flo@syscp.org>
* @author Ron Brand <ron.brand@web.de>
*/
function standard_error($errors = '', $replacer = '')
{
global $userinfo, $s, $header, $footer, $lng, $theme;
$_SESSION['requestData'] = $_POST;
$replacer = htmlentities($replacer);
if (!is_array($errors)) {
$errors = array($errors);
}
$link = '';
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
$link = '<a href="' . htmlentities($_SERVER['HTTP_REFERER']) . '">' . $lng['panel']['back'] . '</a>';
}
$error = '';
foreach ($errors as $single_error) {
if (isset($lng['error'][$single_error])) {
$single_error = $lng['error'][$single_error];
$single_error = strtr($single_error, array('%s' => $replacer));
} else {
$error = 'Unknown Error (' . $single_error . '): ' . $replacer;
break;
}
if (empty($error)) {
$error = $single_error;
} else {
$error .= ' ' . $single_error;
}
}
eval("echo \"" . getTemplate('misc/error', '1') . "\";");
exit;
}
示例7: get_input_box
function get_input_box()
{
global $msg, $charset;
//R�cup�ration de la valeur de saisie
$valeur_ = "field_" . $this->n_ligne . "_s_" . $this->id;
global ${$valeur_};
$valeur = ${$valeur_};
if (!$valeur && $_SESSION["checked_sources"]) {
$valeur = $_SESSION["checked_sources"];
}
if (!is_array($valeur)) {
$valeur = array();
}
//Recherche des sources
$requete = "SELECT connectors_categ_sources.num_categ, connectors_sources.source_id, connectors_categ.connectors_categ_name as categ_name, connectors_sources.name, connectors_sources.comment, connectors_sources.repository, connectors_sources.opac_allowed, source_sync.cancel FROM connectors_sources LEFT JOIN connectors_categ_sources ON (connectors_categ_sources.num_source = connectors_sources.source_id) LEFT JOIN connectors_categ ON (connectors_categ.connectors_categ_id = connectors_categ_sources.num_categ) LEFT JOIN source_sync ON (connectors_sources.source_id = source_sync.source_id AND connectors_sources.repository=2) WHERE connectors_sources.opac_allowed=1 ORDER BY connectors_categ_sources.num_categ DESC, connectors_sources.name";
$resultat = mysql_query($requete);
$r = "<select name='field_" . $this->n_ligne . "_s_" . $this->id . "[]' multiple='yes'>";
$current_categ = 0;
$count = 0;
while ($source = mysql_fetch_object($resultat)) {
if ($current_categ !== $source->num_categ) {
$current_categ = $source->num_categ;
$source->categ_name = $source->categ_name ? $source->categ_name : $msg["source_no_category"];
$r .= "<optgroup label='" . $source->categ_name . "'>";
$count++;
}
$r .= "<option id='op_" . $source->source_id . "_" . $count . "' value='" . $source->source_id . "'" . (array_search($source->source_id, $valeur) !== false ? " selected" : "") . ">" . htmlentities($source->name . ($source->comment ? " : " . $source->comment : ""), ENT_QUOTES, $charset) . "</option>\n";
}
$r .= "</select>";
return $r;
}
示例8: smarty_modifier_currency
/**
* Formats a given decimal value to a local aware currency value
*
*
* @link http://framework.zend.com/manual/de/zend.currency.options.html
* @param float $value Value can have a coma as a decimal separator
* @param array $config
* @param string $position where the currency symbol should be displayed
* @return float|string
*/
function smarty_modifier_currency($value, $config = null, $position = null)
{
if (!Enlight_Application::Instance()->Bootstrap()->hasResource('Currency')) {
return $value;
}
if (!empty($config) && is_string($config)) {
$config = strtoupper($config);
if (defined('Zend_Currency::' . $config)) {
$config = array('display' => constant('Zend_Currency::' . $config));
} else {
$config = array();
}
} else {
$config = array();
}
if (!empty($position) && is_string($position)) {
$position = strtoupper($position);
if (defined('Zend_Currency::' . $position)) {
$config['position'] = constant('Zend_Currency::' . $position);
}
}
$currency = Enlight_Application::Instance()->Currency();
$value = floatval(str_replace(',', '.', $value));
$value = $currency->toCurrency($value, $config);
if (function_exists('mb_convert_encoding')) {
$value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
}
$value = htmlentities($value, ENT_COMPAT, 'UTF-8', false);
return $value;
}
示例9: filter
/**
* Detects all images in shortcode format and converts them into images, clickable links or raw URLs
*
* @param string $text HTML-encoded string
* @param boolean $imagesEnabled Whether to convert shortcodes into real images
* @param boolean $linksEnabled Whether to convert shortcodes into real hyperlinks
*
* @return string
*/
public function filter($text, $imagesEnabled, $linksEnabled = true)
{
if (preg_match_all(self::SHORTCODE_REGEXP, $text, $matches)) {
if (count($matches) < 3) {
return $text;
}
foreach ($matches[0] as $key => $shortCode) {
$imageSrc = $matches[2][$key];
$imageThumbnailSrc = $matches[3][$key];
$imageOrgSrc = $matches[4][$key];
$replace = '';
if ($imagesEnabled) {
$replace = sprintf(self::IMAGE_TAG_TEMPLATE, $imageSrc, $imageThumbnailSrc);
} else {
if ($linksEnabled) {
if ($imageOrgSrc == '_') {
$imageOrgSrc = $imageSrc;
}
$url = (!preg_match(self::URL_PROTOCOLS_REGEXP, $imageOrgSrc) ? 'http://' : '') . $imageOrgSrc;
$linkBody = htmlentities(urldecode($imageOrgSrc), ENT_QUOTES, 'UTF-8', false);
$replace = sprintf('<a href="%s" target="_blank" rel="nofollow">%s</a>', $url, $linkBody);
} else {
$replace = $imageOrgSrc != '_' ? $imageOrgSrc : $imageSrc;
}
}
$text = $this->strReplaceFirst($shortCode, $replace, $text);
}
}
return $text;
}
示例10: printCorePropertyRow
function printCorePropertyRow($title, $field, $value, $formText)
{
global $previewMode, $f, $fp;
if ($value == '') {
$text = '<div class="ccm-attribute-field-none">' . t('None') . '</div>';
} else {
$text = htmlentities($value, ENT_QUOTES, APP_CHARSET);
}
if ($fp->canEditFileProperties() && !$previewMode) {
$html = '
<tr class="ccm-attribute-editable-field">
<td><strong><a href="javascript:void(0)">' . $title . '</a></strong></td>
<td width="100%" class="ccm-attribute-editable-field-central"><div class="ccm-attribute-editable-field-text">' . $text . '</div>
<form method="post" action="' . REL_DIR_FILES_TOOLS_REQUIRED . '/files/properties">
<input type="hidden" name="attributeField" value="' . $field . '" />
<input type="hidden" name="fID" value="' . $f->getFileID() . '" />
<input type="hidden" name="task" value="update_core" />
<div class="ccm-attribute-editable-field-form ccm-attribute-editable-field-type-text">
' . $formText . '
</div>
</form>
</td>
<td class="ccm-attribute-editable-field-save"><a href="javascript:void(0)"><img src="' . ASSETS_URL_IMAGES . '/icons/edit_small.png" width="16" height="16" class="ccm-attribute-editable-field-save-button" /></a>
<img src="' . ASSETS_URL_IMAGES . '/throbber_white_16.gif" width="16" height="16" class="ccm-attribute-editable-field-loading" />
</td>
</tr>';
} else {
$html = '
<tr>
<td><strong>' . $title . '</strong></td>
<td width="100%" colspan="2">' . $text . '</td>
</tr>';
}
print $html;
}
示例11: format
public function format($in, $options = POST_BBCODE)
{
$strtr = array();
if (!($options & POST_HTML)) {
$in = htmlentities($in, ENT_COMPAT, 'UTF-8');
}
if ($options & POST_BBCODE) {
$in = $this->pre_parse_links($in);
$in = $this->bbcode_parse($in);
}
// Yes, this looks silly, but trust me.
if (!($options & POST_HTML) || $options & POST_HTML && $options & POST_BREAKS) {
$strtr["\n"] = "<br />\n";
}
// Don't format emoticons!
if ($options & POST_EMOTICONS) {
if (isset($this->emoticons['click_replacement'])) {
$strtr = array_merge($strtr, $this->emoticons['click_replacement']);
}
if (isset($this->emoticons['replacement'])) {
$strtr = array_merge($strtr, $this->emoticons['replacement']);
}
}
$in = strtr($in, $strtr);
return $in;
}
示例12: fromString
/**
* Set count and period from the string or throw Exception
*/
function fromString($string)
{
if ($string instanceof Am_Period) {
$this->count = $string->getCount();
$this->unit = $string->getUnit();
}
$string = trim(strtolower($string));
if ($string === '') {
$this->count = $this->unit = null;
} elseif (preg_match('/^(\\d{4}-\\d{2}-\\d{2})(fixed|lifetime)*$/', $string, $regs)) {
$this->count = $regs[1];
$this->unit = self::FIXED;
} elseif (preg_match($regex = '/^(\\d+)\\s*(|w|' . join('|', array(self::DAY, self::MONTH, self::YEAR)) . ')$/', $string, $regs)) {
$this->count = intval($regs[1]);
$this->unit = $regs[2] == '' ? self::DAY : $regs[2];
if ($this->unit == 'w') {
$this->count *= 7;
$this->unit = self::DAY;
}
} elseif (preg_match('/lifetime$/', $string)) {
$this->count = self::MAX_SQL_DATE;
$this->unit = self::FIXED;
} else {
throw new Am_Exception_InternalError("Unknown format of Am_Period string : [" . htmlentities($string) . "]");
}
}
示例13: tfb_getRequestVar
/**
* get Request Var
*
* @param $varName
* @param $return
* @return string
*/
function tfb_getRequestVar($varName, $return = '')
{
if (array_key_exists($varName, $_REQUEST)) {
// If magic quoting on, strip magic quotes:
/**
* TODO:
* Codebase needs auditing to remove any unneeded stripslashes
* calls before uncommenting this. Also using this really means
* checking any addslashes() calls to see if they're really needed
* when magic quotes is on.
if(ini_get('magic_quotes_gpc')){
tfb_strip_quotes($_REQUEST[$varName]);
}
*/
$return = htmlentities(trim($_REQUEST[$varName]), ENT_QUOTES);
/*
disabled, need to fix deadeye's implementation
if ($varName == 'transfer' && isHash($return)) {
$name = getTransferFromHash($return);
if (!empty($name))
return $name;
else
return $return;
}
*/
}
return $return;
}
示例14: directPostDemo
/**
* Implements all 3 steps of the Direct Post Method for demonstration
* purposes.
*/
public static function directPostDemo($url, $api_login_id, $transaction_key, $amount = "0.00", $md5_setting = "")
{
// Step 1: Show checkout form to customer.
if (!count($_POST) && !count($_GET)) {
$fp_sequence = time();
// Any sequential number like an invoice number.
echo M2_AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $url, $api_login_id, $transaction_key);
} elseif (count($_POST)) {
$response = new M2_AuthorizeNetSIM($api_login_id, $md5_setting);
if ($response->isAuthorizeNet()) {
if ($response->approved) {
// Do your processing here.
$redirect_url = $url . '?response_code=1&transaction_id=' . $response->transaction_id;
} else {
// Redirect to error page.
$redirect_url = $url . '?response_code=' . $response->response_code . '&response_reason_text=' . $response->response_reason_text;
}
// Send the Javascript back to AuthorizeNet, which will redirect user back to your site.
echo M2_AuthorizeNetDPM::getRelayResponseSnippet($redirect_url);
} else {
echo "Error -- not AuthorizeNet. Check your MD5 Setting.";
}
} elseif (!count($_POST) && count($_GET)) {
if ($_GET['response_code'] == 1) {
echo "Thank you for your purchase! Transaction id: " . htmlentities($_GET['transaction_id']);
} else {
echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']);
}
}
}
示例15: podPress_feedSafeContent
function podPress_feedSafeContent($input, $aggressive = FALSE, $removescripts = FALSE)
{
global $podPress;
// All values should be plain text (no markup or HTML). [...] CDATA sections are strongly discouraged. (see http://www.apple.com/itunes/podcasts/specs.html#encoding)
if (TRUE === $removescripts) {
// this option is only reachable via php source code and via the WP backend
$input = preg_replace('/<script[\\w\\W]*<\\/script>/i', '', $input);
}
$input = strip_tags($input);
// replace the relevant characters with their HTML entities
if (TRUE === $aggressive) {
if (TRUE === version_compare(PHP_VERSION, '5.2.3', '>=')) {
$result = htmlentities($input, ENT_NOQUOTES, get_bloginfo('charset'), FALSE);
} else {
$result = htmlentities($input, ENT_NOQUOTES, get_bloginfo('charset'));
}
} else {
if (TRUE === version_compare(PHP_VERSION, '5.2.3', '>=')) {
$result = htmlspecialchars($input, ENT_NOQUOTES, get_bloginfo('charset'), FALSE);
} else {
$result = htmlspecialchars($input, ENT_NOQUOTES, get_bloginfo('charset'));
}
}
$input = $result;
$result = str_replace(' ', ' ', $input);
// transform all HTML entities in to their numeric equivalents
$result = ent2ncr($result);
return $result;
}