Guest User

Untitled

a guest
Sep 13th, 2023
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 5.0.1.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.04.2022
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. /**
  15. * @author emrenogay.com
  16. */
  17. function ngy_new_buffer($buffer)
  18. {
  19. $amp_domain = get_field('nogay_amp_domain', 'option');
  20. $amp_domain_prefix = get_field('nogay_current_amp_domain', 'option');
  21. if ((strpos($buffer, 'https://cdn.ampproject.org/') !== false) && !is_admin()) {
  22. if (get_field('nogay_is_active_ampcdn', 'option')) {
  23. $searchForAMP = ['action="' . get_site_url()];
  24. $replaceForAMP = ['action="' . generateCdnLinks()];
  25. $buffer = str_replace($searchForAMP, $replaceForAMP, $buffer);
  26. $site = str_replace('/', '\\/', get_site_url());
  27. $pattern = '@<a(.*?)href="' . $site . '@si';
  28. $replace = '<a$1href="' . generateCdnLinks();
  29. $buffer = preg_replace($pattern, $replace, $buffer);
  30.  
  31. if (get_field('nogay_remove_amp_prefix', 'option')) {
  32. $dom = new DOMDocument();
  33. $dom->loadHTML($buffer, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
  34. $aTags = $dom->getElementsByTagName('a');
  35.  
  36. foreach ($aTags as $a) {
  37. $href = $a->getAttribute('href');
  38.  
  39. if (strpos($href, '/amp') !== false) {
  40. $newHref = str_replace('/amp', '', $href);
  41. $a->setAttribute('href', $newHref);
  42. }
  43. }
  44.  
  45. $buffer = $dom->saveHTML();
  46. }
  47. }
  48.  
  49. if (get_field('nogay_image_is_active_ampcdn', 'option')) {
  50. $addon = generateCdnLinks(true);
  51. $pattern = '@<(amp-img|img|amp-anim)(.*?)src="' . str_replace('/', '\\/', get_site_url()) . '@si';
  52. $replace = '<$1$2$3src="' . $addon;
  53. $buffer = preg_replace($pattern, $replace, $buffer);
  54. $removeSrcSet = '@srcset="(.*?)"@si';
  55. $buffer = preg_replace($removeSrcSet, '', $buffer);
  56. $bgPattern = '@(.*?)background-image:(.*?)url\\(' . get_site_url() . '@si';
  57. $bgReplace = '$1background-image:$2url(' . generateCdnLinks(true);
  58. $buffer = preg_replace($bgPattern, $bgReplace, $buffer);
  59. }
  60. }
  61.  
  62. if (!empty($amp_domain)) {
  63. $amp_domain = str_replace(['https://', 'http://'], NULL, $amp_domain);
  64. $amp_domain_prefix = str_replace(['https://', 'http://'], NULL, $amp_domain_prefix);
  65. $currentSchema = str_replace('/', '\\/', nogay_is_ssl()) . $_SERVER['HTTP_HOST'];
  66. $newSchema = $amp_domain;
  67. if (!empty($amp_domain_prefix) && get_field('nogay_auto_subdomain', 'option')) {
  68. $newSchema = $amp_domain_prefix . '.' . $newSchema;
  69. }
  70.  
  71. if (get_field('nogay_remove_amp_prefix', 'option')) {
  72. ...............................................................
  73. ...................................
  74. ..............
Advertisement
Add Comment
Please, Sign In to add comment