Guest User

Untitled

a guest
Jun 14th, 2017
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. if (stripos ( $tpl->copy_template, "{fullimage-" ) !== false || stripos ( $tpl->copy_template, "{imagelarge-" ) !== false ) {
  2.  
  3. $images = array();
  4. preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['xfields'], $media);
  5. $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
  6.  
  7. foreach($data as $url) {
  8. $info = pathinfo($url);
  9. if (isset($info['extension'])) {
  10. if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
  11. $info['extension'] = strtolower($info['extension']);
  12. if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
  13. }
  14. }
  15.  
  16. if ( count($images) ) {
  17. $i=0;
  18. foreach($images as $url) {
  19. $i++;
  20. $tpl->copy_template = str_replace( '{fullimage-'.$i.'}', $url, $tpl->copy_template );
  21. $tpl->copy_template = str_replace( '[fullimage-'.$i.']', "", $tpl->copy_template );
  22. $tpl->copy_template = str_replace( '[/fullimage-'.$i.']', "", $tpl->copy_template );
  23.  
  24. //Проверяем на нашем ли хостинге находится картинка
  25. $checkMyServer = parse_url($url);
  26. if(stripos($config['http_home_url'], $checkMyServer['host'] ) !== false && stripos($checkMyServer['path'],'/thumbs/') !== false){
  27. $tpl->copy_template = str_replace( '{imagelarge-'.$i.'}', str_replace('thumbs/','',$url), $tpl->copy_template );
  28. }else{$tpl->copy_template = str_replace( '{imagelarge-'.$i.'}',$url, $tpl->copy_template );}
  29. $tpl->copy_template = str_replace( '[imagelarge-'.$i.']', "", $tpl->copy_template );
  30. $tpl->copy_template = str_replace( '[/imagelarge-'.$i.']', "", $tpl->copy_template );
  31.  
  32. }
  33.  
  34. }
  35.  
  36. $tpl->copy_template = preg_replace( "#\[fullimage-(.+?)\](.+?)\[/fullimage-(.+?)\]#is", "", $tpl->copy_template );
  37. $tpl->copy_template = preg_replace( "#\\{fullimage-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );
  38. $tpl->copy_template = preg_replace( "#\[imagelarge-(.+?)\](.+?)\[/imagelarge-(.+?)\]#is", "", $tpl->copy_template );
  39. $tpl->copy_template = preg_replace( "#\\{imagelarge-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment