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

    В номинации:
    За время:
  2. Куча / Говнокод #17481

    +129

    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
    import std.uuid;
    import std.file;
    import std.path;
    import std.string;
    ubyte[] sdlBytes = cast(ubyte[]) import("SDL2.dll");   // SDL2.dll contents
    void main(string[] args)
    {
        auto uuid = randomUUID();
        string uuid = randomUUID().toString();
        string filename = format("SDL2-%s.dll", uuid);     // Making an unique file name.
        string depacked = buildPath(tempDir(), filename);
        std.file.write(depacked, sdlBytes);                // Writing the dynlib to a temporary file.
        DerelictSDL2.load(depacked);                       // Use the depacked dynlib and load its symbols.
    }

    лол, надо поюзать.

    DlangGovno, 19 Января 2015

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

    +167

    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
    final public static function getSomething($version_line = "pro") {
    		$default_domain = domainsCollection::getInstance()->getDefaultDomain();
    
    		if($_SERVER['SERVER_ADDR']) {
    			$cs2 = md5($_SERVER['SERVER_ADDR']);
    		} else {
    			$cs2 = md5(str_replace("\\","",$_SERVER['DOCUMENT_ROOT']));
    		}
    		     
    		switch($version_line) {
    			case "pro":
    				$cs3 = md5(md5(md5(md5(md5(md5(md5(md5(md5(md5($default_domain->getHost()))))))))));
    				break;
    
    			case "free":
    				$cs3 = md5(md5(md5($default_domain->getHost())));
    				break;
    
    			case "lite":
    				$cs3 = md5(md5(md5(md5(md5($default_domain->getHost())))));
    				break;
    
    			case "freelance":
    				$cs3 = md5(md5(md5(md5(md5(md5(md5($default_domain->getHost())))))));
    				break;
    				
    			case "trial": {
    				$cs3 = md5(md5(md5(md5(md5(md5($default_domain->getHost()))))));
    			}
    		}
    
    		$licenseKeyCode = strtoupper(substr($cs2, 0, 11) . "-" . substr($cs3, 0, 11));
    		return $licenseKeyCode;
    	}

    сложная система нипель

    deconf, 15 Января 2015

    Комментарии (17)
  4. Assembler / Говнокод #17424

    +143

    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
    dw 0 ; reserved, must be 0
    dw 1 ; icon type, must be 1
    dw 2 ; number of images in file
    
    ; 1st icon header
    db 32 ; width
    db 32 ; height
    db 0 ; no color palette
    db 0 ; reserved, must be 0
    dw 1 ; planes
    dw 32 ; bits per pixel
    dd icon32_end-icon32_start ; length
    dd icon32_start ; offset
    
    ; 2nd icon header
    db 16 ; width
    db 16 ; height
    db 0 ; no color palette
    db 0 ; reserved, must be 0
    dw 1 ; planes
    dw 32 ; bits per pixel
    dd icon16_end-icon16_start ; length
    dd icon16_start ; offset
    
    ; 1st icon body
    icon32_start:
    file 'icon32.png'
    icon32_end:
    
    ; 2nd icon body
    icon16_start:
    file 'icon16.png'
    icon16_end:

    http://habrahabr.ru/post/247425/
    Сборка иконки FASMом

    govnokod3r, 09 Января 2015

    Комментарии (17)
  5. PHP / Говнокод #17384

    +157

    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
    <?php
    function clear($field){
        $field = htmlspecialchars($field);
        $field = str_replace("\"","", $field);
        $field = str_replace("'","\'",$field);
     
        return $field;
    }
      if(isset($_POST['name'])){
       $name = clear($_POST['name']);
        echo $name;
      }
    ?>
    <form method="post">
     <p>you name:<br>
     <input name="name" type="text" value="">
     </p>
     <input type="submit" value="Send">
    </form>

    Прафисианналы "PHP" пишут защиту от XSS.
    Отсюда: http://mzcoding.com/php_articles/xss__csrf__ataki_i_zashhita_ot_nikh/11/

    gost, 29 Декабря 2014

    Комментарии (17)
  6. Куча / Говнокод #17300

    +131

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    next_int() ->
      receive {next_int, N} -> 
        self() ! {next_int, N + 1}, 
        N
      after 0 ->
        self() ! {next_int, 0}, 
        0
      end.
    
    ...
    [{A, next_int()}|| A <- SomeList]

    Простейший способ пронумеровать элементы списка эрланге. Найдено в продакшне, ошибки сохранены.

    lesmugfrog, 12 Декабря 2014

    Комментарии (17)
  7. 1C / Говнокод #17254

    −125

    1. 1
    2. 2
    Движение = Движения.Добавить();
    Движение.СчетДт = ПланыСчетов.Хозрасчетный.НайтиПоКоду(Счет.Код);

    facepeeler, 04 Декабря 2014

    Комментарии (17)
  8. C# / Говнокод #17209

    +100

    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
    class Book
        {
            public void BookName(ref string file, ref int Index)
            {
                string[] ReadFile = File.ReadAllLines("NameFile.txt", Encoding.Default);
                file = ReadFile[Index];
            }
    
            public void BookAuthor(ref string file, ref int Index)
            {
                string[] ReadFile = File.ReadAllLines("AuthorFile.txt", Encoding.Default);
                file = ReadFile[Index];
            }
    
            public void BookDescription(ref string file, ref int Index)
            {
                string[] ReadFile = File.ReadAllLines("DescriptionFile.txt", Encoding.Default);
                file = ReadFile[Index];
            }
    
            public void BookTags(ref string file, ref int Index)
            {
                string[] ReadFile = File.ReadAllLines("TagFile.txt", Encoding.Default);
                file = ReadFile[Index];
            }
        }

    LightningAtom, 28 Ноября 2014

    Комментарии (17)
  9. C# / Говнокод #17142

    +135

    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
    public void SelectStep(int stepNumber)
    {
        //1.HTTPCore
        //2.find cat
        //3find p.cat
        //4.find products
        //5.parse products info
        //6.save
        //7.complete
        if (stepNumber != 1) ((Label)(this.panel.Controls.Cast<Control>()
            .First(c => c.TabIndex == stepNumber - 1))).ForeColor = Color.Black;
        ((Label)(this.panel.Controls.Cast<Control>()
            .First(c => c.TabIndex == stepNumber))).ForeColor = Color.Red;
        if (stepNumber == 6)
        {
            labelStatusSecondLine.ForeColor = Color.Black;
            labelStatusFirstLine.Text = "Готово."; buttonStart.Enabled = buttonRefreshCats.Enabled = true; timer.Stop();
        }
        if (stepNumber == 7)
        {
            labelStatusSecondLine.Text = "Обновление категорий...";
        }
    }

    Досталось в наследство. Слегка переписано мной (ранее у всех лейблов были имена вроде "label1" – к лейблам аффтар обращался по распарсенным оттуда цифрам).

    pushistayapodmyshka, 20 Ноября 2014

    Комментарии (17)
  10. Perl / Говнокод #16965

    −161

    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
    sub check_license {
        my ($license) = @_;
    
        my $is_valid = 0;
        if (-f $license) {
            open(my $fh, '<', $license);
            my $content = do { local $/ = undef; <$fh> };
            close($fh);
            $content =~ s/\r\n/\n/g;
    
            $is_valid = $content =~ /^-{5}BEGIN LICENSE-{5}$/m;
            $is_valid = $content =~ /^-{5}END LICENSE-{5}$/m;
        }
    
        return $is_valid;
    }

    Ну ок.

    Elvenfighter, 29 Октября 2014

    Комментарии (17)
  11. PHP / Говнокод #16956

    +158

    1. 1
    2. 2
    3. 3
    $element['yandex'] = 14;
    unset($element['yandex']);
    $element['yandex'] = 60;

    Разраб упоролся в каштан :)

    sautchenkov, 28 Октября 2014

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