1. Лучший говнокод

    В номинации:
    За время:
  2. PHP / Говнокод #29161

    +1

    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
    <?php
    function real_parse_headers($data) {
        $result = [];
        foreach($data as $line) {
            $parts = explode(':', $line, 2);
            if(!isset($parts[1])) continue;
            $key = trim($parts[0]);
            $key = implode('-', array_map(function($value) {return ucfirst($value);}, explode('-', $key)));
            $result[$key] = trim($parts[1]);
        }
        return $result;
    }
    
    function real_length($from, $original_context = null) {
        $context = stream_context_create(isset($original_context) ? stream_context_get_options($original_context) : null);
        stream_context_set_option($context, 'http', 'method', 'HEAD');
        @file_get_contents($from, false, $context);
        return intval(real_parse_headers($http_response_header)['Content-Length']);
    }
    
    function real_copy($from, string $to, $context = null) {
        define('BLOCK', 8192);
        $total = real_length($from, $context);
    
        if(!isset($context)) {
            $context = stream_context_create();
        }
        $headers = stream_context_get_options($context)['http']['header'] ?? [];
        stream_context_set_option($context, 'http', 'timeout', '1.0');
        stream_context_set_option($context, 'http', 'ignore_errors', true);
    
        for($start = 0; $start < $total; $start += $length) {
            $end = $start + BLOCK;
            stream_context_set_option($context, 'http', 'header', array_merge($headers, ["Range: bytes=$start-$end"]));
            $part = @file_get_contents($from, false, $context);
            if($part === false) break;
            $length = strlen($part);
            file_put_contents($to, $part, FILE_APPEND);
        }
    }
    
    /* The real example */
    $context = stream_context_create([
        'http' => ['method' => 'GET'],
        'ssl'  => ['verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, 'SNI_enabled' => true]
    ]);        
    
    real_copy('https://govnokod.ru/files/images/pony.jpg', 'pony.jpg', $context);

    Дрочилка для скачивания файлов с сайтов, расположенных за «Cloudflare». Теперь банановая и на «PHP»!

    nemyx, 25 Июля 2025

    Комментарии (28)
  3. bash / Говнокод #29158

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    #!/bin/sh
    
    while :; do
    wget -c -T 1 --no-check-certificate $1
    [ $? == 0 ] && break
    done

    Дрочилка для скачивания файлов с сайтов, расположенных за «Cloudflare».

    nemyx, 18 Июля 2025

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