-
@@ -110,8 +86,8 @@ if ( 'post' == $_REQUEST['action'] ) {
// Ajax Requests
$title = wp_specialchars(stripslashes($_GET['t']));
-$selection = trim(wp_specialchars(str_replace("\n", ' ',stripslashes($_GET['s']))));
-$url = $_GET['u'];
+$selection = trim(str_replace('\\n', "
", wp_specialchars(js_escape($_GET['s']))));
+$url = clean_url($_GET['u']);
$image = $_GET['i'];
if($_REQUEST['ajax'] == 'thickbox') { ?>
@@ -154,33 +129,29 @@ if($_REQUEST['ajax'] == 'video') { ?>
}
if($_REQUEST['ajax'] == 'photo_images') {
- error_log('photo images');
function get_images_from_uri($uri) {
if(preg_match('/\.(jpg|png|gif)/', $uri))
return "'".$uri."'";
-
+
$content = wp_remote_fopen($uri);
- $host = parse_url($uri);
-
if ( false === $content ) return '';
+ $host = parse_url($uri);
+
$pattern = '/
![]()
]*)src=(\"|\')(.+?)(\2)([^>\/]*)\/*>/is';
preg_match_all($pattern, $content, $matches);
- if ( empty($matches[1]) ) { error_log('empty'); return ''; };
+
+ if ( empty($matches[1]) ) return '';
+
$sources = array();
-
foreach ($matches[3] as $src) {
- error_log($src);
- #if ( false !== strpos($src, '&') ) continue;
- if(strpos($src, 'http') === false) {
- if(strpos($src, '../') === false && strpos($src, './') === false) {
- $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
- } else {
- $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src);
- }
- }
-
- $sources[] = $src;
+ if(strpos($src, 'http') === false)
+ if(strpos($src, '../') === false && strpos($src, './') === false)
+ $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
+ else
+ $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src);
+
+ $sources[] = $src;
}
return "'" . implode("','", $sources) . "'";
}
@@ -226,11 +197,8 @@ if($_REQUEST['ajax'] == 'photo_js') { ?>
if (img.width && img.height) {
if (img.width * img.height < 2500) skip = true;
aspect = img.width / img.height;
- if (aspect > 1) { // Image is wide
- scale = 75 / img.width;
- } else { // Image is tall or square
- scale = 75 / img.height;
- }
+ scale = (aspect > 1) ? (75 / img.width) : (75 / img.height);
+
if (scale < 1) {
w = parseInt(img.width * scale);
h = parseInt(img.height * scale);
@@ -252,15 +220,12 @@ if($_REQUEST['ajax'] == 'photo_js') { ?>
-
-
>
@@ -317,7 +282,8 @@ if($_REQUEST['ajax'] == 'photo') { ?>
accessibility_focus : false,
tab_focus : ":next",
plugins : "safari,inlinepopups",
- entities : "38,amp,60,lt,62,gt"
+ entities : "38,amp,60,lt,62,gt",
+ force_p_newlines : true
});
@@ -349,6 +315,7 @@ if($_REQUEST['ajax'] == 'photo') { ?>
jQuery("#post_type").val(type);
}
function set_editor(text) {
+
if(tinyMCE.activeEditor) tinyMCE.activeEditor.setContent('');
if(tinyMCE.activeEditor) tinyMCE.execCommand('mceInsertContent' ,false, text);
}
@@ -369,11 +336,7 @@ if($_REQUEST['ajax'] == 'photo') { ?>
jQuery('#content_type').show();
set_menu('text');
set_title('');
-
- set_editor('
'.$selection.' '; ?>');
-
- set_editor('
'.$title.' '; ?>');
-
+
return false;
break;
case 'quote' :
@@ -499,7 +462,29 @@ if($_REQUEST['ajax'] == 'photo') { ?>