1. Список говнокодов пользователя Lexchz2

    Всего: 3

  2. PHP / Говнокод #29268

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    function minifyJSCSS(&$content) {
    	global $USER;
    	global $APPLICATION;
    	if (is_object($USER) && $USER->IsAdmin()) return;
    
    	preg_match_all('/<link.+?href="\/bitrix\/cache[^>]+>/',$content, $result);
    
    	foreach ($result[0] as $css)
    	{
    		preg_match('/(href)=("[^"]*")/i',$css, $file);
    
    		$orig_file = reset(explode('?',str_replace('"','',$file[2])));
    
    		if (stristr($orig_file,'.css') === false)
    			continue;
    
    		$min_file = str_replace('.css','.min.css',$orig_file);
    
    		if (!file_exists($min_file))
    		{
    			$compress = file_get_contents($_SERVER["DOCUMENT_ROOT"].$orig_file);
    			$compress = preg_replace("!/\*[^*]*\*+([^/][^*]*\*+)*/!", "", $compress);
    			$compress = str_replace(array("\r\n", "\r", "\n", "\t", "  ", "    ", "    "), "", $compress);
    			file_put_contents($_SERVER["DOCUMENT_ROOT"].$min_file, $compress);
    		}
    
    		$content = str_replace($orig_file,$min_file,$content);
    	}
    
    
    
    	if (strpos($_SERVER['HTTP_USER_AGENT'],'Lighthouse'))
    	{
    		preg_match_all('/<script.+?src="\/bitrix\/cache[^>]+>/',$content, $result);
    
    		foreach ($result[0] as $js)
    		{
    			preg_match('/(src)=("[^"]*")/i',$js, $file);
    
    			$orig_file = reset(explode('?',str_replace('"','',$file[2])));
    
    			$orig_file = $orig_file;
    			$min_file = str_replace('.js','.min.js',$orig_file);
    
    			if (!file_exists($_SERVER["DOCUMENT_ROOT"].$min_file))
    			{
    
    				$url = 'https://javascript-minifier.com/raw';
    				$js = file_get_contents($_SERVER["DOCUMENT_ROOT"].$orig_file);
    
    				$ch = curl_init();
    
    				curl_setopt_array($ch, [
    					CURLOPT_URL => $url,
    					CURLOPT_RETURNTRANSFER => true,
    					CURLOPT_POST => true,
    					CURLOPT_HTTPHEADER => ["Content-Type: application/x-www-form-urlencoded"],
    					CURLOPT_POSTFIELDS => http_build_query([ "input" => $js ])
    				]);
    
    				$minified = curl_exec($ch);
    				curl_close($ch);
    
    				file_put_contents($_SERVER["DOCUMENT_ROOT"].$min_file,$minified);
    
    				$gzdata = gzencode($minified, 9);
    				file_put_contents($_SERVER["DOCUMENT_ROOT"].$min_file.'.gz', $gzdata);
    
    			}
    
    			$content = str_replace($orig_file,$min_file,$content);
    		}
    	}
    }

    Жулики-говнокодеры пытались улучшить оценку производительности

    Lexchz2, 28 Июня 2026

    Комментарии (1)
  3. PHP / Говнокод #29236

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <? // get current season for header styling
    		$current_month = date("m");
    		if($current_month >= "03" && $current_month <= "05") $season = "spring";
    		elseif($current_month >= "06" && $current_month <= "08") $season = "spring";
    		elseif($current_month >= "09" && $current_month <= "11") $season = "autumn";
    		else $season = "winter";
      ?>

    И про теги в стиле говноБитрикса не забыли

    Lexchz2, 25 Февраля 2026

    Комментарии (21)
  4. PHP / Говнокод #29214

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    <!-- <div class="news">
    	<div class="tch"></div>
    	<div class="container">
    		<h2 class="title"><span><small>Н</small>овости компании</span></h2>
    		<div class="flex">
    			<?php
    			query_posts('cat=21&posts_per_page=3'); // вместо "5" указываем идентификатор вашей рубрики.
    			while (have_posts()) : the_post();
    			?>
    				<div class="item">
    					<div class="img"><?= get_the_post_thumbnail(get_the_ID()); ?></div>
    					<div class="desk">
    						<div class="title"><?= get_the_title() ?></div>
    						<div class="date"><?= get_the_date(); ?></div>
    						<?php the_content() ?>
    						<a href="<?= get_the_permalink();  ?>" class="more">Читать далее</a>
    					</div>
    				</div>
    
    			<?php
    			endwhile;
    			wp_reset_query();
    			?>
    		</div>
    	</div>
    </div> -->

    На ровном месте быдлокодер получает мимимум 7 лишних запросов к БД.

    Lexchz2, 18 Декабря 2025

    Комментарии (1)