本文整理汇总了PHP中htmlentities2函数的典型用法代码示例。如果您正苦于以下问题:PHP htmlentities2函数的具体用法?PHP htmlentities2怎么用?PHP htmlentities2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了htmlentities2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_email_to_db
function add_email_to_db()
{
global $wpdb, $current_user;
if ($_REQUEST['action'] == 'add') {
$email_name = $_REQUEST['email_name'];
$email_subject = $_REQUEST['email_subject'];
$email_text = $_REQUEST['email_text'];
if (!function_exists('espresso_member_data')) {
$current_user->ID = 1;
}
$sql = array('email_name' => $email_name, 'email_text' => $email_text, 'email_subject' => $email_subject, 'wp_user' => $current_user->ID);
$sql_data = array('%s', '%s', '%s', '%s');
if ($wpdb->insert(EVENTS_EMAIL_TABLE, $sql, $sql_data)) {
?>
<div id="message" class="updated fade"><p><strong>The email <?php
echo htmlentities2($_REQUEST['email_name']);
?>
has been added.</strong></p></div>
<?php
} else {
?>
<div id="message" class="error"><p><strong>The email <?php
echo htmlentities2($_REQUEST['email_name']);
?>
was not saved. <?php
print mysql_error();
?>
.</strong></p></div>
<?php
}
}
}
示例2: event_espresso_form_builder_insert
function event_espresso_form_builder_insert()
{
global $wpdb, $current_user;
//$wpdb->show_errors();
$event_id = empty($_REQUEST['event_id']) ? 0 : $_REQUEST['event_id'];
$event_name = empty($_REQUEST['event_name']) ? '' : $_REQUEST['event_name'];
$question = $_POST['question'];
$question_type = $_POST['question_type'];
$question_values = empty($_POST['values']) ? NULL : $_POST['values'];
$required = !empty($_POST['required']) ? $_POST['required'] : 'N';
$admin_only = !empty($_POST['admin_only']) ? $_POST['admin_only'] : 'N';
$sequence = $_POST['sequence'] ? $_POST['sequence'] : '0';
if (!function_exists('espresso_member_data')) {
$current_user->ID = 1;
}
if ($wpdb->query("INSERT INTO " . EVENTS_QUESTION_TABLE . " (question_type, question, response, required, admin_only, sequence,wp_user)" . " VALUES ('" . $question_type . "', '" . $question . "', '" . $question_values . "', '" . $required . "', '" . $admin_only . "', " . $sequence . ",'" . $current_user->ID . "')")) {
?>
<div id="message" class="updated fade"><p><strong>The question <?php
echo htmlentities2($_REQUEST['question']);
?>
has been added.</strong></p></div>
<?php
} else {
?>
<div id="message" class="error"><p><strong>The question <?php
echo htmlentities2($_REQUEST['question']);
?>
was not saved. <?php
//$wpdb->print_error();
?>
.</strong></p></div>
<?php
}
}
示例3: smarty_modifier_escape
/**
* Smarty escape modifier plugin
*
* Type: modifier<br>
* Name: escape<br>
* Purpose: Escape the string according to escapement type
* @link http://smarty.php.net/manual/en/language.modifier.escape.php
* escape (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param html|htmlall|url|quotes|hex|hexentity|javascript
* @return string
*/
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-8859-1')
{
switch ($esc_type) {
case 'html':
return htmlspecialchars2($string, ENT_QUOTES, $char_set);
case 'htmlall':
return htmlentities2($string, ENT_QUOTES, $char_set);
case 'url':
return rawurlencode($string);
case 'urlpathinfo':
return str_replace('%2F', '/', rawurlencode($string));
case 'quotes':
// escape unescaped single quotes
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
case 'hex':
// escape every character into hex
$return = '';
for ($x = 0; $x < strlen($string); $x++) {
$return .= '%' . bin2hex($string[$x]);
}
return $return;
case 'hexentity':
$return = '';
for ($x = 0; $x < strlen($string); $x++) {
$return .= '&#x' . bin2hex($string[$x]) . ';';
}
return $return;
case 'decentity':
$return = '';
for ($x = 0; $x < strlen($string); $x++) {
$return .= '&#' . ord($string[$x]) . ';';
}
return $return;
case 'javascript':
// escape quotes and backslashes, newlines, etc.
return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\\/'));
case 'mail':
// safe way to display e-mail address on a web page
return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
case 'nonstd':
// escape non-standard chars, such as ms document quotes
$_res = '';
for ($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
$_ord = ord(substr($string, $_i, 1));
// non-standard char, escape it
if ($_ord >= 126) {
$_res .= '&#' . $_ord . ';';
} else {
$_res .= substr($string, $_i, 1);
}
}
return $_res;
default:
return $string;
}
}
示例4: esc_xss
/**
* Escape string conter XSS attack
*
* @since 1.0
* @param String $value
* @param String $type
* @return String
*/
private static function esc_xss($value, $type)
{
switch ($type) {
case 'html':
$value = self::rip_tags($value);
break;
case 'code':
$value = htmlentities2($value);
break;
}
return $value;
}
示例5: wpi_get_author_name
/**
* author display_name
*
*/
function wpi_get_author_name($type = 'hcard')
{
global $authordata;
$name = $display_name = apply_filters('the_author', $authordata->display_name);
$name = $display_name = ent2ncr(htmlentities2($name));
$author_url = $authordata->user_url;
$author_url = $author_url != 'http://' ? $author_url : WPI_URL;
switch ($type) {
case 'link':
/** simple links
*
*/
$attribs = array('href' => $author_url, 'class' => 'url fn dc-creator', 'rel' => 'colleague foaf.homepage foaf.maker', 'title' => 'Visit ' . $display_name . ''s Website', 'rev' => 'author:' . $authordata->user_nicename);
$output = _t('a', $display_name, $attribs);
break;
case 'hcard':
/** convert to microformats
* address:a:span
*/
// split the name
$name = explode('name', $name);
if (is_array($name)) {
if (Wpi::hasCount($name)) {
if (isset($name[0])) {
$output = _t('span', $name[0], array('class' => 'nickname'));
}
if (isset($name[1])) {
$output = _t('span', $name[0], array('class' => 'given-name')) . ' ';
$output .= _t('span', $name[1], array('class' => 'family-name'));
}
}
} else {
$output = _t('span', $author_name, array('class' => 'nickname'));
}
// author post url;
$url = get_author_posts_url($authordata->ID, $authordata->user_nicename);
$url = apply_filters(wpiFilter::FILTER_LINKS, $url);
$attribs = array('href' => $url, 'class' => 'url fn dc-creator', 'rel' => 'colleague foaf.homepage foaf.maker', 'title' => 'Visit ' . $display_name . ''s Author page', 'rev' => 'author:' . $authordata->user_nicename);
$output = _t('a', $output, $attribs);
// microID sha-1 hash
$hash = get_microid_hash($authordata->user_email, $author_url);
// wrap hcard
$output = _t('cite', $output, array('class' => 'vcard microid-' . $hash));
break;
default:
$output = $name;
break;
}
return apply_filters(wpiFilter::FILTER_AUTHOR_NAME . $type, $output);
}
示例6: affwp_search_users
function affwp_search_users()
{
if (empty($_POST['search'])) {
die('-1');
}
if (!current_user_can('manage_affiliates')) {
die('-1');
}
$search_query = htmlentities2(trim($_POST['search']));
do_action('affwp_pre_search_users', $search_query);
$args = array();
if (isset($_POST['status'])) {
$status = mb_strtolower(htmlentities2(trim($_POST['status'])));
switch ($status) {
case 'none':
$affiliates = affiliate_wp()->affiliates->get_affiliates(array('number' => 9999));
$args = array('exclude' => array_map('absint', wp_list_pluck($affiliates, 'user_id')));
break;
case 'any':
$affiliates = affiliate_wp()->affiliates->get_affiliates(array('number' => 9999));
$args = array('include' => array_map('absint', wp_list_pluck($affiliates, 'user_id')));
break;
default:
$affiliates = affiliate_wp()->affiliates->get_affiliates(array('number' => 9999, 'status' => $status));
$args = array('include' => array_map('absint', wp_list_pluck($affiliates, 'user_id')));
}
}
//make sure we filter the search columns so they only include the columns we want to search
//this filter was exposed by WordPress in WP 3.6.0
add_filter('user_search_columns', function ($search_columns, $search, WP_User_Query $WP_User_Query) {
return array('user_login', 'display_name', 'user_email');
}, 10, 3);
//add search string to args
$args['search'] = mb_strtolower(htmlentities2(trim($_POST['search'])));
//get users matching search
$found_users = get_users($args);
if ($found_users) {
$user_list = '<ul>';
foreach ($found_users as $user) {
$user_list .= '<li><a href="#" data-id="' . esc_attr($user->ID) . '" data-login="' . esc_attr($user->user_login) . '">' . esc_html($user->user_login) . '</a></li>';
}
$user_list .= '</ul>';
echo json_encode(array('results' => $user_list, 'id' => 'found'));
} else {
echo json_encode(array('results' => '<p>' . __('No users found', 'affiliate-wp') . '</p>', 'id' => 'fail'));
}
die;
}
示例7: affwp_search_users
function affwp_search_users()
{
if (empty($_POST['search'])) {
die('-1');
}
if (!current_user_can('manage_affiliates')) {
die('-1');
}
$search_query = htmlentities2(trim($_POST['search']));
do_action('affwp_pre_search_users', $search_query);
$args = array();
if (isset($_POST['status'])) {
$status = mb_strtolower(htmlentities2(trim($_POST['status'])));
switch ($status) {
case 'none':
$affiliates = affiliate_wp()->affiliates->get_affiliates(array('number' => 9999));
$args = array('exclude' => array_map('absint', wp_list_pluck($affiliates, 'user_id')));
break;
case 'any':
$affiliates = affiliate_wp()->affiliates->get_affiliates(array('number' => 9999));
$args = array('include' => array_map('absint', wp_list_pluck($affiliates, 'user_id')));
break;
default:
$affiliates = affiliate_wp()->affiliates->get_affiliates(array('number' => 9999, 'status' => $status));
$args = array('include' => array_map('absint', wp_list_pluck($affiliates, 'user_id')));
}
}
$found_users = array_filter(get_users($args), function ($user) {
$q = mb_strtolower(htmlentities2(trim($_POST['search'])));
$user_login = mb_strtolower($user->user_login);
$display_name = mb_strtolower($user->display_name);
$user_email = mb_strtolower($user->user_email);
// Detect query term matches from these user fields (in order of priority)
return false !== mb_strpos($user_login, $q) || false !== mb_strpos($display_name, $q) || false !== mb_strpos($user_email, $q);
});
if ($found_users) {
$user_list = '<ul>';
foreach ($found_users as $user) {
$user_list .= '<li><a href="#" data-id="' . esc_attr($user->ID) . '" data-login="' . esc_attr($user->user_login) . '">' . esc_html($user->user_login) . '</a></li>';
}
$user_list .= '</ul>';
echo json_encode(array('results' => $user_list, 'id' => 'found'));
} else {
echo json_encode(array('results' => '<p>' . __('No users found', 'affiliate-wp') . '</p>', 'id' => 'fail'));
}
die;
}
示例8: add_to_calendar
function add_to_calendar()
{
global $wpdb, $current_user, $org_options;
$event_id = $_REQUEST['id'];
$results = $wpdb->get_results("SELECT * FROM " . get_option('events_detail_tbl') . " WHERE id =" . $event_id);
foreach ($results as $result) {
$event_id = $result->id;
$event_name = $result->event_name;
$event_desc = $result->event_desc;
$start_date = $result->start_date;
$end_date = $result->end_date;
$start_time = $result->start_time;
$end_time = $result->end_time;
$calendar_category = $_REQUEST['calendar_category'];
$linky = home_url() . '/?page_id=' . $org_options['event_page_id'] . '®event_action=register&event_id=' . $event_id . '&name_of_event=' . $event_name;
$sql = "INSERT INTO " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($event_name) . "', event_desc='" . mysql_escape_string($event_desc) . "', event_begin='" . mysql_escape_string($start_date) . "', event_recur='S', event_repeats='0', event_end='" . mysql_escape_string($end_date) . "', event_time='" . mysql_escape_string($start_time) . "', event_author=" . $current_user->ID . ", event_category=" . mysql_escape_string($calendar_category) . ", event_link='" . mysql_escape_string($linky) . "'";
}
if ($wpdb->query($sql)) {
?>
<div id="message" class="updated fade"><p><strong><?php
_e('The event', 'event_espresso');
?>
<a href="<?php
echo $_SERVER["REQUEST_URI"];
?>
#event-id-<?php
echo $wpdb->insert_id;
?>
"><?php
echo htmlentities2($event_name);
?>
</a> <?php
_e('has been added.', 'event_espresso');
?>
</strong></p></div>
<?php
} else {
?>
<div id="message" class="error"><p><strong><?php
_e('There was an error in your submission, please try again. The event was not saved!', 'event_espresso');
print mysql_error();
?>
.</strong></p></div>
<?php
}
}
示例9: update_event_email
function update_event_email()
{
global $wpdb;
$email_id = $_REQUEST['email_id'];
$email_name = $_REQUEST['email_name'];
$email_subject = $_REQUEST['email_subject'];
$email_text = $_REQUEST['email_text'];
$sql = array('email_name' => $email_name, 'email_text' => $email_text, 'email_subject' => $email_subject);
$update_id = array('id' => $email_id);
$sql_data = array('%s', '%s', '%s');
if ($wpdb->update(EVENTS_EMAIL_TABLE, $sql, $update_id, $sql_data, array('%d'))) {
?>
<div id="message" class="updated fade"><p><strong><?php
_e('The email', 'event_espresso');
?>
<?php
echo stripslashes(htmlentities2($_REQUEST['email_name']));
?>
<?php
_e('has been updated', 'event_espresso');
?>
.</strong></p></div>
<?php
} else {
?>
<div id="message" class="error"><p><strong><?php
_e('The email', 'event_espresso');
?>
<?php
echo stripslashes(htmlentities2($_REQUEST['email_name']));
?>
<?php
_e('was not updated', 'event_espresso');
?>
. <?php
print mysql_error();
?>
.</strong></p></div>
<?php
}
}
示例10: affwp_search_users
function affwp_search_users()
{
if (empty($_POST['user_name'])) {
die('-1');
}
if (!current_user_can('manage_affiliates')) {
die('-1');
}
$search_query = htmlentities2(trim($_POST['user_name']));
do_action('affwp_pre_search_users', $search_query);
$found_users = get_users(array('number' => 9999, 'search' => $search_query . '*'));
if ($found_users) {
$user_list = '<ul>';
foreach ($found_users as $user) {
$user_list .= '<li><a href="#" data-id="' . esc_attr($user->ID) . '" data-login="' . esc_attr($user->user_login) . '">' . esc_html($user->user_login) . '</a></li>';
}
$user_list .= '</ul>';
echo json_encode(array('results' => $user_list, 'id' => 'found'));
} else {
echo json_encode(array('results' => '<p>' . __('No users found', 'affiliate-wp') . '</p>', 'id' => 'fail'));
}
die;
}
示例11: ga_options_do_network_errors
protected function ga_options_do_network_errors()
{
if (isset($_REQUEST['updated']) && $_REQUEST['updated']) {
?>
<div id="setting-error-settings_updated" class="updated settings-error">
<p>
<strong><?php
_e('Settings saved.', 'google-apps-login');
?>
</strong>
</p>
</div>
<?php
}
if (isset($_REQUEST['error_setting']) && is_array($_REQUEST['error_setting']) && isset($_REQUEST['error_code']) && is_array($_REQUEST['error_code'])) {
$error_code = $_REQUEST['error_code'];
$error_setting = $_REQUEST['error_setting'];
if (count($error_code) > 0 && count($error_code) == count($error_setting)) {
for ($i = 0; $i < count($error_code); ++$i) {
?>
<div id="setting-error-settings_<?php
echo $i;
?>
" class="error settings-error">
<p>
<strong><?php
echo htmlentities2($this->get_error_string($error_setting[$i] . '|' . $error_code[$i]));
?>
</strong>
</p>
</div>
<?php
}
}
}
}
示例12: _setContent
private function _setContent()
{
$content = false;
if (is_object($this->osd)) {
$blog_name = htmlentities2($this->osd->blog_name);
$title = sprintf(__('%s Search', WPI_META), $blog_name);
$desc = $blog_name . ', ' . $this->osd->blog_desc;
$email = 'postmaster+abuse@' . parse_url($this->osd->blog_url, PHP_URL_HOST);
$search_uri = $this->osd->blog_url . '/' . $this->osd->search_param;
$xml = "\t" . '<ShortName>' . $title . '</ShortName>' . "\n";
$xml .= "\t" . '<Description>' . $desc . '</Description>' . "\n";
$xml .= "\t" . '<Contact>' . $email . '</Contact>' . "\n";
$xml .= "\t" . '<Url type="' . $this->osd->blog_html_type . '" method="get" template="' . $search_uri . '"></Url>' . "\n";
$xml .= "\t" . '<LongName>' . $title . '</LongName>' . "\n";
if ($this->osd->blog_favicon) {
$xml .= "\t" . '<Image height="16" width="16" type="image/vnd.microsoft.icon">' . $this->osd->blog_favicon . '</Image>' . "\n";
}
$xml .= "\t" . '<Query role="example" searchTerms="blogging" />';
$xml .= "\n\t" . '<Developer>ChaosKaizer</Developer>';
$xml .= "\n\t" . '<Attribution>Search data &copy; ' . date('Y', $_SERVER['REQUEST_TIME']) . ', ' . $blog_name . ', Some Rights Reserved. CC by-nc 2.5.</Attribution>';
$xml .= "\n\t" . '<SyndicationRight>open</SyndicationRight>';
$xml .= "\n\t" . '<AdultContent>false</AdultContent>';
$xml .= "\n\t" . '<Language>' . $this->osd->language . '</Language>';
$xml .= "\n\t" . '<OutputEncoding>UTF-8</OutputEncoding>';
$xml .= "\n\t" . '<InputEncoding>UTF-8</InputEncoding>' . "\n";
}
$this->content = $xml;
unset($xml);
}
示例13: espresso_google_map_link
function espresso_google_map_link($atts)
{
extract($atts);
$address = "{$address}";
$city = "{$city}";
$state = "{$state}";
$zip = "{$zip}";
$country = "{$country}";
$text = isset($text) ? "{$text}" : "";
$type = isset($type) ? "{$type}" : "";
$map_w = isset($map_w) ? "{$map_w}" : 400;
$map_h = isset($map_h) ? "{$map_h}" : 400;
$gaddress = ($address != '' ? $address : '') . ($city != '' ? ',' . $city : '') . ($state != '' ? ',' . $state : '') . ($zip != '' ? ',' . $zip : '') . ($country != '' ? ',' . $country : '');
$google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode($gaddress));
switch ($type) {
case 'text':
default:
$text = $text == '' ? __('Map and Directions', 'event_espresso') : $text;
break;
case 'url':
$text = $google_map;
break;
case 'map':
$google_map_link = '<a href="' . $google_map . '" target="_blank">' . '<img id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2('http://maps.googleapis.com/maps/api/staticmap?center=' . urlencode($gaddress) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode($gaddress) . '&sensor=false') . '" /></a>';
return $google_map_link;
}
$google_map_link = '<a href="' . $google_map . '" target="_blank">' . $text . '</a>';
return $google_map_link;
}
示例14: searchandreplace_action
function searchandreplace_action()
{
if (isset($_POST['submitted'])) {
check_admin_referer('searchandreplace_nonce');
$myecho = '';
if (empty($_POST['search_text'])) {
$myecho .= '<div class="error"><p><strong>» ' . __('You must specify some text to replace!', FB_SAR_TEXTDOMAIN) . '</strong></p></div><br class="clear">';
} else {
$myecho .= '<div class="updated fade">';
$myecho .= '<p><strong>» ' . __('Performing search', FB_SAR_TEXTDOMAIN);
if (!isset($_POST['sall'])) {
$_POST['sall'] = NULL;
}
if ($_POST['sall'] == 'srall') {
$myecho .= ' ' . __('and replacement', FB_SAR_TEXTDOMAIN);
}
$myecho .= ' ...</strong></p>';
$myecho .= '<p>» ' . __('Searching for', FB_SAR_TEXTDOMAIN) . ' <code>' . stripslashes(htmlentities2($_POST['search_text'])) . '</code>';
if (isset($_POST['replace_text']) && $_POST['sall'] == 'srall') {
$myecho .= __('and replacing with', FB_SAR_TEXTDOMAIN) . ' <code>' . stripslashes(htmlentities2($_POST['replace_text'])) . '</code></p>';
}
$myecho .= '</div><br class="clear" />';
if (!isset($_POST['replace_text'])) {
$_POST['replace_text'] = NULL;
}
$error = searchandreplace_doit($_POST['search_text'], $_POST['replace_text'], $_POST['sall'], isset($_POST['content']), isset($_POST['guid']), isset($_POST['id']), isset($_POST['title']), isset($_POST['excerpt']), isset($_POST['meta_value']), isset($_POST['comment_content']), isset($_POST['comment_author']), isset($_POST['comment_author_email']), isset($_POST['comment_author_url']), isset($_POST['comment_count']), isset($_POST['cat_description']), isset($_POST['tag']), isset($_POST['user_id']), isset($_POST['user_login']), isset($_POST['singups']));
if ($error != '') {
$myecho .= $error;
} else {
$myecho .= '<p>' . __('Completed successfully!', FB_SAR_TEXTDOMAIN) . '</p></div>';
}
}
echo $myecho;
}
}
示例15: openid_login_errors
/**
* Setup OpenID errors to be displayed to the user.
*/
function openid_login_errors()
{
$self = basename($GLOBALS['pagenow']);
if ($self != 'wp-login.php') {
return;
}
if (array_key_exists('openid_error', $_REQUEST)) {
global $error;
$error = htmlentities2($_REQUEST['openid_error']);
}
}