| @@ 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 | ||
| @@ 910-943 (lines=34) @@ | ||
| 907 | } |
|
| 908 | // If not exists, file an image file from the content |
|
| 909 | $is_tmp_file = false; |
|
| 910 | if(!$source_file) |
|
| 911 | { |
|
| 912 | $random = new Password(); |
|
| 913 | ||
| 914 | preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER); |
|
| 915 | ||
| 916 | foreach($matches as $target_image) |
|
| 917 | { |
|
| 918 | $target_src = trim($target_image[1]); |
|
| 919 | if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue; |
|
| 920 | ||
| 921 | if(!preg_match('/^(http|https):\/\//i',$target_src)) |
|
| 922 | { |
|
| 923 | $target_src = Context::getRequestUri().$target_src; |
|
| 924 | } |
|
| 925 | ||
| 926 | $target_src = htmlspecialchars_decode($target_src); |
|
| 927 | ||
| 928 | $tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex'); |
|
| 929 | FileHandler::getRemoteFile($target_src, $tmp_file); |
|
| 930 | if(!file_exists($tmp_file)) continue; |
|
| 931 | ||
| 932 | $imageinfo = getimagesize($tmp_file); |
|
| 933 | list($_w, $_h) = $imageinfo; |
|
| 934 | if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) { |
|
| 935 | FileHandler::removeFile($tmp_file); |
|
| 936 | continue; |
|
| 937 | } |
|
| 938 | ||
| 939 | $source_file = $tmp_file; |
|
| 940 | $is_tmp_file = true; |
|
| 941 | break; |
|
| 942 | } |
|
| 943 | } |
|
| 944 | ||
| 945 | if($source_file) |
|
| 946 | { |
|