From c80fc3dff8f41625d585ff82fb01c173165bd0b6 Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 26 Aug 2015 20:03:58 +0200 Subject: [PATCH] fix entry replacements on image MOVE now matches thumbs too and tries to be as strict as possible and necessary fixing any move Staticpages Dev will be fixed in v.4.51 for SP entries --- include/functions_images.inc.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/include/functions_images.inc.php b/include/functions_images.inc.php index 091ceaa8..1ee4d19e 100644 --- a/include/functions_images.inc.php +++ b/include/functions_images.inc.php @@ -3557,11 +3557,30 @@ function serendipity_moveMediaDirectory($oldDir, $newDir, $type = 'dir', $item_i return true; } - $q = "SELECT id, body, extended - FROM {$serendipity['dbPrefix']}entries - WHERE body REGEXP '(src=|href=|window.open.)(\'|\")(" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $oldDir) . "|" . serendipity_db_escape_string($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $oldDir) . ")' - OR extended REGEXP '(src=|href=|window.open.)(\'|\")(" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $oldDir) . "|" . serendipity_db_escape_string($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $oldDir) . ")' - "; + // prepare the SELECT query for filetypes + if ($type == 'filedir' || $type == 'file') { + $_file = ($type == 'filedir') ? $pick : $file; + // Path patterns to SELECT en detail + $oldDirThumb = $oldDir . $_file['name'] . '.' . $_file['thumbnail_name'] . (($_file['extension']) ? '.'.$_file['extension'] : ''); + $newDirThumb = $newDir . $_file['name'] . '.' . $_file['thumbnail_name'] . (($_file['extension']) ? '.'.$_file['extension'] : ''); + $oldDirFile = $oldDir . $_file['name'] . (($_file['extension']) ? '.'.$_file['extension'] : ''); + $newDirFile = $newDir . $_file['name'] . (($_file['extension']) ? '.'.$_file['extension'] : ''); + // REPLACE BY Path and Name only to also match Thumbs + $oldDir .= $_file['name']; + $newDir .= $_file['name']; + + $q = "SELECT id, body, extended + FROM {$serendipity['dbPrefix']}entries + WHERE body REGEXP '(src=|href=|window.open.)(\'|\")(" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $oldDirFile) . "|" . serendipity_db_escape_String($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $oldDirFile) . "|" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $oldDirThumb) . "|" . serendipity_db_escape_String($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $oldDirThumb) . ")' + OR extended REGEXP '(src=|href=|window.open.)(\'|\")(" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $oldDirFile) . "|" . serendipity_db_escape_String($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $oldDirFile) . "|" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $oldDirThumb) . "|" . serendipity_db_escape_String($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $oldDirThumb) . ")' + "; + } else { + $q = "SELECT id, body, extended + FROM {$serendipity['dbPrefix']}entries + WHERE body REGEXP '(src=|href=|window.open.)(\'|\")(" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $oldDir) . "|" . serendipity_db_escape_string($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $oldDir) . ")' + OR extended REGEXP '(src=|href=|window.open.)(\'|\")(" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $oldDir) . "|" . serendipity_db_escape_string($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $oldDir) . ")' + "; + } $dirs = serendipity_db_query($q); if (is_array($dirs)) {