| @@ 642-675 (lines=34) @@ | ||
| 639 | ||
| 640 | // get an image file from the doc content if no file attached. |
|
| 641 | $is_tmp_file = false; |
|
| 642 | if(!$source_file) |
|
| 643 | { |
|
| 644 | $random = new Password(); |
|
| 645 | ||
| 646 | preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER); |
|
| 647 | ||
| 648 | foreach($matches as $target_image) |
|
| 649 | { |
|
| 650 | $target_src = trim($target_image[1]); |
|
| 651 | if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 652 | ||
| 653 | if(!preg_match('/^(http|https):\/\//i',$target_src)) |
|
| 654 | { |
|
| 655 | $target_src = Context::getRequestUri().$target_src; |
|
| 656 | } |
|
| 657 | ||
| 658 | $target_src = htmlspecialchars_decode($target_src); |
|
| 659 | ||
| 660 | $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
|
| 661 | FileHandler::getRemoteFile($target_src, $tmp_file); |
|
| 662 | if(!file_exists($tmp_file)) continue; |
|
| 663 | ||
| 664 | $imageinfo = getimagesize($tmp_file); |
|
| 665 | list($_w, $_h) = $imageinfo; |
|
| 666 | if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 667 | FileHandler::removeFile($tmp_file); |
|
| 668 | continue; |
|
| 669 | } |
|
| 670 | ||
| 671 | $source_file = $tmp_file; |
|
| 672 | $is_tmp_file = true; |
|
| 673 | break; |
|
| 674 | } |
|
| 675 | } |
|
| 676 | ||
| 677 | $output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type); |
|
| 678 | ||
| @@ 916-949 (lines=34) @@ | ||
| 913 | } |
|
| 914 | // If not exists, file an image file from the content |
|
| 915 | $is_tmp_file = false; |
|
| 916 | if(!$source_file) |
|
| 917 | { |
|
| 918 | $random = new Password(); |
|
| 919 | ||
| 920 | preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER); |
|
| 921 | ||
| 922 | foreach($matches as $target_image) |
|
| 923 | { |
|
| 924 | $target_src = trim($target_image[1]); |
|
| 925 | if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 926 | ||
| 927 | if(!preg_match('/^(http|https):\/\//i',$target_src)) |
|
| 928 | { |
|
| 929 | $target_src = Context::getRequestUri().$target_src; |
|
| 930 | } |
|
| 931 | ||
| 932 | $target_src = htmlspecialchars_decode($target_src); |
|
| 933 | ||
| 934 | $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
|
| 935 | FileHandler::getRemoteFile($target_src, $tmp_file); |
|
| 936 | if(!file_exists($tmp_file)) continue; |
|
| 937 | ||
| 938 | $imageinfo = getimagesize($tmp_file); |
|
| 939 | list($_w, $_h) = $imageinfo; |
|
| 940 | if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 941 | FileHandler::removeFile($tmp_file); |
|
| 942 | continue; |
|
| 943 | } |
|
| 944 | ||
| 945 | $source_file = $tmp_file; |
|
| 946 | $is_tmp_file = true; |
|
| 947 | break; |
|
| 948 | } |
|
| 949 | } |
|
| 950 | ||
| 951 | if($source_file) |
|
| 952 | { |
|