本文整理汇总了PHP中cleanSource函数的典型用法代码示例。如果您正苦于以下问题:PHP cleanSource函数的具体用法?PHP cleanSource怎么用?PHP cleanSource使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cleanSource函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define
define('VERSION', '1.14');
// version number (to force a cache refresh)
define('DIRECTORY_CACHE', './cache');
// cache directory
define('DIRECTORY_TEMP', './temp');
// temp directory
if (function_exists('imagefilter') && defined('IMG_FILTER_NEGATE')) {
$imageFilters = array("1" => array(IMG_FILTER_NEGATE, 0), "2" => array(IMG_FILTER_GRAYSCALE, 0), "3" => array(IMG_FILTER_BRIGHTNESS, 1), "4" => array(IMG_FILTER_CONTRAST, 1), "5" => array(IMG_FILTER_COLORIZE, 4), "6" => array(IMG_FILTER_EDGEDETECT, 0), "7" => array(IMG_FILTER_EMBOSS, 0), "8" => array(IMG_FILTER_GAUSSIAN_BLUR, 0), "9" => array(IMG_FILTER_SELECTIVE_BLUR, 0), "10" => array(IMG_FILTER_MEAN_REMOVAL, 0), "11" => array(IMG_FILTER_SMOOTH, 0));
}
// sort out image source
$src = get_request("src", "");
if ($src == '' || strlen($src) <= 3) {
displayError('no image specified');
}
// clean params before use
$src = cleanSource($src);
// last modified time (for caching)
$lastModified = filemtime($src);
// get properties
$new_width = preg_replace("/[^0-9]+/", '', get_request('w', 0));
$new_height = preg_replace("/[^0-9]+/", '', get_request('h', 0));
$zoom_crop = preg_replace("/[^0-9]+/", '', get_request('zc', 1));
$quality = preg_replace("/[^0-9]+/", '', get_request('q', 80));
$filters = get_request('f', '');
$sharpen = get_request('s', 0);
if ($new_width == 0 && $new_height == 0) {
$new_width = 100;
$new_height = 100;
}
// get mime type of src
$mime_type = mime_type($src);
示例2: woothemes_uploader_custom_fields
/**
* woothemes_uploader_custom_fields function.
*
* @access public
* @param int $pID
* @param string $id
* @param string $std
* @param string $desc
* @return void
*/
function woothemes_uploader_custom_fields($pID, $id, $std, $desc)
{
// Start Uploader
$upload = get_post_meta($pID, $id, true);
$href = cleanSource($upload);
$uploader = '';
$uploader .= '<input class="woo_input_text" name="' . $id . '" type="text" value="' . esc_attr($upload) . '" />';
$uploader .= '<div class="clear"></div>' . "\n";
$uploader .= '<input type="file" name="attachement_' . $id . '" />';
$uploader .= '<input type="submit" class="button button-highlighted" value="Save" name="save"/>';
if ($href) {
$uploader .= '<span class="woo_metabox_desc">' . $desc . '</span></td>' . "\n" . '<td class="woo_metabox_image"><a href="' . $upload . '"><img src="' . get_template_directory_uri() . '/functions/thumb.php?src=' . $href . '&w=150&h=80&zc=1" alt="" /></a>';
}
return $uploader;
}
示例3: woo_image
//.........这里部分代码省略.........
if (!empty($img_link)) {
if ($link == 'img') {
// Output the image without anchors
$output .= wp_kses_post($before);
$output .= $img_link;
$output .= wp_kses_post($after);
} elseif ($link == 'url') {
// Output the large image
$src = wp_get_attachment_image_src($thumb_id, 'large', true);
$custom_field = esc_url($src[0]);
$output .= $custom_field;
} else {
// Default - output with link
if ((is_single() || is_page()) && $single == false) {
$rel = 'rel="lightbox"';
$href = false;
} else {
$href = get_permalink($id);
$rel = '';
}
$title = 'title="' . esc_attr(get_the_title($id)) . '"';
$output .= wp_kses_post($before);
if ($href == false) {
$output .= $img_link;
} else {
$output .= '<a ' . $title . ' href="' . esc_url($href) . '" ' . $rel . '>' . $img_link . '</a>';
}
$output .= wp_kses_post($after);
}
} elseif (get_option('woo_resize') == 'true' && empty($vt_image['url'])) {
foreach ($src_arr as $key => $custom_field) {
// Clean the image URL
$href = esc_url($custom_field);
$custom_field = cleanSource($custom_field);
// Check if WPMU and set correct path AND that image isn't external
if (function_exists('get_current_site')) {
get_current_site();
//global $blog_id; Breaks with WP3 MS
if (!$blog_id) {
global $current_blog;
$blog_id = $current_blog->blog_id;
}
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('files/', $custom_field);
if (isset($imageParts[1])) {
$custom_field = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
}
//Set the ID to the Attachment's ID if it is an attachment
if ($is_auto_image == true) {
$quick_id = $attachment_id[$key];
} else {
$quick_id = $id;
}
//Set custom meta
if ($meta) {
$alt = $meta;
$title = 'title="' . esc_attr($meta) . '"';
} else {
if ($alt != '' || !($alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true))) {
$alt = esc_attr(get_post_meta($thumb_id, '_wp_attachment_image_alt', true));
} else {
$alt = esc_attr(get_the_title($quick_id));
}
$title = 'title="' . esc_attr(get_the_title($quick_id)) . '"';
示例4: woo_image
//.........这里部分代码省略.........
}
}
// Return if there is no attachment or custom field set
if (empty($custom_field)) {
return;
}
$output = '';
// Get standard sizes
if (!$width && !$height) {
$width = '100';
$height = '100';
}
$set_width = ' width="' . $width . '" ';
$set_height = ' height="' . $height . '" ';
if ($height == null or $height == '') {
$set_height = '';
}
// Set standard class
if ($class) {
$class .= ' woo-image';
} else {
$class = 'woo-image';
}
// Do check to verify if images are smaller then specified.
$force_all = get_option('woo_force_all');
$force_single = get_option('woo_force_single');
if ($force == true or $force_all == true or $force_single == true and is_single()) {
$set_width = '';
$set_height = '';
}
if (get_option('woo_resize') == 'true') {
// Clean the image URL
$href = $custom_field;
$custom_field = cleanSource($custom_field);
// Check if WPMU and set correct path
global $blog_id;
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('/files/', $custom_field);
if (isset($imageParts[1])) {
$custom_field = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
} else {
// Try again
$imageParts = explode('files/', $custom_field);
if (isset($imageParts[1])) {
$custom_field = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
}
//Set the ID to the Attachent's ID if it is an attachment
if ($is_auto_image == true) {
$quick_id = $attachment_id;
} else {
$quick_id = $id;
}
if ($auto_meta == true) {
$alt = 'alt="' . get_the_title($quick_id) . '"';
$title = 'title="' . get_the_title($quick_id) . '"';
} elseif ($auto_meta == false) {
$alt = 'alt="' . $meta . '"';
$title = 'title="' . $meta . '"';
} else {
$alt = 'alt=""';
$title = '';
}
$img_link = '<img src="' . get_bloginfo('template_url') . '/thumb.php?src=' . $custom_field . '&w=' . $width . '&h=' . $height . '&zc=1&q=' . $quality . '" ' . $alt . ' class="' . $class . '" ' . $set_width . $set_height . ' />';
if ($link == 'img') {
示例5: timthumb_deprecated
/**
* timthumb_deprecated handles legacy timthumb logic
* @since 6.1.0
* @param array $args old timthumb arguments
* @return html markup output
*/
function timthumb_deprecated($args = array())
{
//Defaults
$output = '';
$src_arr = array();
$attachment_id = array();
$id = null;
$meta = '';
$alt = '';
$thumb_id = '';
$alignment = '';
$width = null;
$height = null;
$quality = 90;
$class = '';
$set_width = '';
$set_height = '';
$before = '';
$after = '';
$link = 'src';
$is_auto_image = false;
$single = false;
if (!is_array($args)) {
parse_str($args, $args);
}
extract($args);
foreach ($src_arr as $key => $custom_field) {
// Clean the image URL
$href = esc_url($custom_field);
$custom_field = cleanSource($custom_field);
// Check if WPMU and set correct path AND that image isn't external
if (function_exists('get_current_site')) {
get_current_site();
//global $blog_id; Breaks with WP3 MS
if (!isset($blog_id) || !$blog_id) {
global $current_blog;
$blog_id = $current_blog->blog_id;
}
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('files/', $custom_field);
if (isset($imageParts[1])) {
$custom_field = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
}
//Set the ID to the Attachment's ID if it is an attachment
if ($is_auto_image == true) {
$quick_id = $attachment_id[$key];
} else {
$quick_id = $id;
}
//Set custom meta
if ($meta) {
$alt = $meta;
$title = 'title="' . esc_attr($meta) . '"';
} else {
if ($alt != '' || !($alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true))) {
$alt = esc_attr(get_post_meta($thumb_id, '_wp_attachment_image_alt', true));
} else {
$alt = esc_attr(get_the_title($quick_id));
}
$title = 'title="' . esc_attr(get_the_title($quick_id)) . '"';
}
// Set alignment parameter
if ($alignment != '') {
$alignment = '&a=' . urlencode($alignment);
}
$img_url = esc_url(get_template_directory_uri() . '/functions/thumb.php?src=' . $custom_field . '&w=' . $width . '&h=' . $height . '&zc=1&q=' . $quality . $alignment);
$img_link = '<img src="' . $img_url . '" alt="' . esc_attr($alt) . '" class="' . esc_attr(stripslashes($class)) . '" ' . $set_width . $set_height . ' />';
if ($link == 'img') {
// Just output the image
$output .= wp_kses_post($before);
$output .= $img_link;
$output .= wp_kses_post($after);
} elseif ($link == 'url') {
// Output the image without anchors
if ($is_auto_image == true) {
$src = wp_get_attachment_image_src($thumb_id, 'large', true);
$custom_field = esc_url($src[0]);
}
$output .= $href;
} else {
// Default - output with link
if ((is_single() || is_page()) && $single == false) {
$rel = 'rel="lightbox"';
} else {
$href = get_permalink($id);
$rel = '';
}
$output .= wp_kses_post($before);
$output .= '<a ' . $title . ' href="' . esc_url($href) . '" ' . $rel . '>' . $img_link . '</a>';
$output .= wp_kses_post($after);
}
}
//.........这里部分代码省略.........
示例6: colabs_image
//.........这里部分代码省略.........
if (!empty($img_link)) {
if ('img' == $link) {
// Output the image without anchors
$output .= $before;
$output .= $img_link;
$output .= $after;
} elseif ('url' == $link) {
// Output the large image
$src = wp_get_attachment_image_src($thumb_id, 'large', true);
$custom_field = $src[0];
$output .= $custom_field;
} else {
// Default - output with link
if ((is_single() or is_page()) and $single == false) {
$rel = 'rel="lightbox"';
$href = false;
} else {
$href = get_permalink($id);
$rel = '';
}
$title = 'title="' . get_the_title($id) . '"';
$output .= $before;
if ($href == false) {
$output .= $img_link;
} else {
$output .= '<a ' . $title . ' href="' . $href . '" ' . $rel . '>' . $img_link . '</a>';
}
$output .= $after;
}
} elseif ('true' == get_option('colabs_resize') && empty($vt_image['url'])) {
foreach ($src_arr as $key => $custom_field) {
// Clean the image URL
$href = $custom_field;
$custom_field = cleanSource($custom_field);
// Check if WPMU and set correct path AND that image isn't external
if (function_exists('get_current_site') && strpos($custom_field, "http://") !== 0) {
get_current_site();
//global $blog_id; Breaks with WP3 MS
if (!$blog_id) {
global $current_blog;
$blog_id = $current_blog->blog_id;
}
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('files/', $custom_field);
if (isset($imageParts[1])) {
$custom_field = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
}
//Set the ID to the Attachment's ID if it is an attachment
if ($is_auto_image == true) {
$quick_id = $attachment_id[$key];
} else {
$quick_id = $id;
}
//Set custom meta
if ($meta) {
$alt = $meta;
$title = 'title="' . $meta . '"';
} else {
if ('' == $alt and get_post_meta($thumb_id, '_wp_attachment_image_alt', true)) {
$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
} else {
$alt = get_the_title($quick_id);
}
$title = 'title="' . get_the_title($quick_id) . '"';
示例7: woo_image
//.........这里部分代码省略.........
if ($force == true or $force_all == true or $force_single == true and is_single()) {
$set_width = '';
$set_height = '';
}
// WordPress's the_post_thumbnail
if (!empty($img_link)) {
if ($link == 'img') {
// Just output the image
$output .= $before;
$output .= $img_link;
$output .= $after;
} else {
// Default - output with link
if ((is_single() or is_page()) and $single == false) {
$rel = 'rel="lightbox"';
$href = false;
} else {
$href = get_permalink($id);
$rel = '';
}
$title = 'title="' . get_the_title($id) . '"';
$output .= $before;
if ($href == false) {
$output .= $img_link;
} else {
$output .= '<a ' . $title . ' href="' . $href . '" ' . $rel . '>' . $img_link . '</a>';
}
$output .= $after;
}
} elseif (get_option('woo_resize') == 'true') {
foreach ($src_arr as $key => $custom_field) {
// Clean the image URL
$href = $custom_field;
$custom_field = cleanSource($custom_field);
// Check if WPMU and set correct path AND that image isn't external
if (function_exists('get_current_site') && strpos($custom_field, "http://") !== 0) {
get_current_site();
//global $blog_id; Breaks with WP3 MS
if (!$blog_id) {
global $current_blog;
$blog_id = $current_blog->blog_id;
}
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('files/', $custom_field);
if (isset($imageParts[1])) {
$custom_field = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
}
// Set alignment if any
//Set the ID to the Attachent's ID if it is an attachment
if ($is_auto_image == true) {
$quick_id = $attachment_id[$key];
} else {
$quick_id = $id;
}
if ($auto_meta == true) {
$alt = 'alt="' . get_the_title($quick_id) . '"';
$title = 'title="' . get_the_title($quick_id) . '"';
} elseif ($auto_meta == false) {
$alt = 'alt="' . $meta . '"';
$title = 'title="' . $meta . '"';
} else {
$alt = 'alt=""';
$title = '';
}