Press This: Fetch offsite images, fix slashing. see #6813

git-svn-id: http://svn.automattic.com/wordpress/trunk@7934 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-05-15 00:20:27 +00:00
parent 36badd926e
commit 6762f6169e
1 changed files with 12 additions and 8 deletions

View File

@ -87,26 +87,30 @@ function get_images_from_uri($uri) {
if ( false === $content ) if ( false === $content )
return ''; return '';
$pattern = '/img.+?src=[\'"]?([^\'" >]+)[\'" >]/'; $pattern = '/<img[^>]+src=[\'"]([^\'" >]+?)[\'" >]/is';
preg_match_all($pattern, $content, $matches); preg_match_all($pattern, $content, $matches);
if ( empty($matches[1]) ) if ( empty($matches[1]) )
return ''; return '';
/*
$from_host = parse_url($uri); $from_host = parse_url($uri);
$from_host = $from_host['host']; $from_host = $from_host['host'];
$from_host = explode('.', $from_host); $from_host = explode('.', $from_host);
$count = count($from_host); $count = count($from_host);
$from_host = $from_host[$count - 2] . '.' . $from_host[$count - 1]; $from_host = $from_host[$count - 2] . '.' . $from_host[$count - 1];
*/
$sources = array(); $sources = array();
foreach ($matches[1] as $src) { foreach ($matches[1] as $src) {
if ( false !== strpos($src, '&') ) if ( false !== strpos($src, '&') )
continue; continue;
/*
$img_host = parse_url($src); $img_host = parse_url($src);
$img_host = $img_host['host']; $img_host = $img_host['host'];
if ( false === strpos($img_host, $from_host) ) if ( false === strpos($img_host, $from_host) )
continue; continue;
*/
$sources[] = $src; $sources[] = $src;
} }
@ -229,11 +233,11 @@ if ( empty($_GET['tab']) ) {
jQuery(document).ready(function() { jQuery(document).ready(function() {
<?php if ( preg_match("/youtube\.com\/watch/i", $_GET['u']) ) { ?> <?php if ( preg_match("/youtube\.com\/watch/i", $_GET['u']) ) { ?>
jQuery('#container > ul').tabs({ selected: 3, fx: { height: 'toggle', opacity: 'toggle', fxSpeed: 'fast' } }); jQuery('#container > ul').tabs({ selected: 3 });
<?php } elseif ( preg_match("/flickr\.com/i", $_GET['u']) ) { ?> <?php } elseif ( preg_match("/flickr\.com/i", $_GET['u']) ) { ?>
jQuery('#container > ul').tabs({ selected: 1, fx: { height: 'toggle', opacity: 'toggle', fxSpeed: 'fast' } }); jQuery('#container > ul').tabs({ selected: 1 });
<?php } else { ?> <?php } else { ?>
jQuery('#container > ul').tabs({ selected: 1, fx: { height: 'toggle', opacity: 'toggle', fxSpeed: 'fast' } }); jQuery('#container > ul').tabs();
<?php } ?> <?php } ?>
}); });
@ -254,10 +258,10 @@ if ( empty($_GET['tab']) ) {
?> ?>
<div id="container"> <div id="container">
<ul> <ul>
<li><a href="<?php echo clean_url(add_query_arg('tab', 'text')) ?>"><span><?php _e('Text/Link') ?></span></a></li> <li><a href="<?php echo clean_url(add_query_arg('tab', 'text', stripslashes($_SERVER['REQUEST_URI']))) ?>"><span><?php _e('Text/Link') ?></span></a></li>
<li><a href="<?php echo clean_url(add_query_arg('tab', 'photo')) ?>"><span><?php _e('Photo') ?></span></a></li> <li><a href="<?php echo clean_url(add_query_arg('tab', 'photo', stripslashes($_SERVER['REQUEST_URI']))) ?>"><span><?php _e('Photo') ?></span></a></li>
<li><a href="<?php echo clean_url(add_query_arg('tab', 'quote')) ?>"><span><?php _e('Quote') ?></span></a></li> <li><a href="<?php echo clean_url(add_query_arg('tab', 'quote', stripslashes($_SERVER['REQUEST_URI']))) ?>"><span><?php _e('Quote') ?></span></a></li>
<li><a href="<?php echo clean_url(add_query_arg('tab', 'video')) ?>"><span><?php _e('Video') ?></span></a></li> <li><a href="<?php echo clean_url(add_query_arg('tab', 'video', stripslashes($_SERVER['REQUEST_URI']))) ?>"><span><?php _e('Video') ?></span></a></li>
</ul> </ul>
</div> </div>