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

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

    +89

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?php
    /* Посоветовали делать так, чтобы решить проблемы с выводом на страницу чисел. Всё зависло */
    $x=0;
    echo "Пожалуйста, подождите 1 минуту. Сейчас напечатаем";
    while ($x++) echo $x."_";
    ?>

    Хм... Что-то тут не так.

    a_e, 21 Мая 2012

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

    +89

    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
    <?php
     
     
    if((isset($_FILES['file1'])) || 
       (isset($_FILES['file2'])) || 
       (isset($_FILES['file3'])) || 
       (isset($_FILES['file4']))){
     
                                if($_FILES['file1'] ['error'] || 
                                    $_FILES['file2'] ['error'] || 
                                    $_FILES['file3'] ['error'] || 
                                    $_FILES['file4'] ['error'] == 0 && 
     
                                                                              $_FILES['file1'] ['saze'] || 
                                                                              $_FILES['file2'] ['saze'] || 
                                                                       $_FILES['file3'] ['saze'] || 
                                                                       $_FILES['file4'] ['saze'] > 0) { 
                                                                      
                                                 $path1 = "E:\\apache\\";
                                                 $path1 .= basename($_FILES['file1'] ['name']);
                                                 $path2 = "E:\\apache\\";
                                                 $path2 .= basename($_FILES['file2'] ['name']);
                                                 $path3 = "E:\\apache\\";
                                                 $path3 .= basename($_FILES['file3'] ['name']);
                                                 $path4 = "E:\\apache\\";
                                                 $path4 .= basename($_FILES['file4'] ['name']);
                                                                     
                if(@move_uploaded_file($_FILES['file1'] ['tmp_name'],$path1)){ 
                   if(@move_uploaded_file($_FILES['file2'] ['tmp_name'],$path2)){
                      if(@move_uploaded_file($_FILES['file3'] ['tmp_name'],$path3)){
                         if(@move_uploaded_file($_FILES['file4'] ['tmp_name'],$path4)){
                         
                  }else{}
                }else{}     
              }else{}
            }else{}
          }else{}
        }else{}
     
     
    ?>

    я даже не знаю, как это прокомментировать. особенно нравится $_FILES['file1'] ['saze']

    heleg, 10 Мая 2012

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

    +89

    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
    function uIsCommentAllowed($id_all)
    	{
    		$db = 'i_all';
    		$this->db->select('comment');
    		$this->db->where('id_all',$id_all);
    		$query = $this->db->get($db);
    		if ($query->num_rows() == 0) return false;
    		else 
    		{
    			$row = $query->row();
    			if ($row->comment == 1) return true;
    			if ($row->comment == 1) return false;
    		}	
    		return false;
    	}

    Кто не видит где говно, показываю: if ($row->comment == 1) return true; if ($row->comment == 1) return false;
    Теперь главный вопрос - почему на при тестировании данная ошибка не проявляется, и все вообще работает верно?

    increazon, 25 Апреля 2012

    Комментарии (31)
  5. Pascal / Говнокод #9773

    +89

    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
    procedure TRashetDate_Form.Button1Click(Sender: TObject);
      var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, aa, ee: real;
      res1: real;
      res2: real;
      res3: real;
      res4: real;
      res5: real;
      res6: real;
      res7: real;
      res8: real;
      res9: real;
      res10: real;
      res11: real;
      res12: real;
      res13: real;
      res14: real;
      res15: real;
      res16: real;
      res17: real;
      res18: real;
      res19: real;
      res20: real;
      res21: real;
      res22: real;
      res23: real;
      Field: real;
    <...>

    Брал отсюда и рыдал...
    http://www.cyberforum.ru/delphi-beginners/thread527956.html#post2835591

    Psilon, 26 Марта 2012

    Комментарии (4)
  6. Pascal / Говнокод #9609

    +89

    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
    // пароль как при входе в Win XP
     Edit1.Font.Name:='Wingdings';
     Edit1.PasswordChar:='l'; // символ "точка"
     //
     j:=78575;
     j1:=j;
     Edit6.Text:='1234567890АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~ .,:;"-=+\/|!?@#$%^&*_№<>()[]{}`';
     try
      RichEdit2.Lines.LoadFromFile('conf.ps');
     except
      MessageDlg('Файл "conf.ps" не найден!',mtError,[mbOK],0);
      Close;
     end;
     st:='1234567890АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~ .,:;"-=+\/|!?@#$%^&*_№<>()[]{}`';
     a:=RichEdit2.Lines.Strings[0];
     x:=length(a);
     try
      for i:=1 to x do
       begin
        if pos(a[i],Edit6.Text)<>0 then
         begin
          Edit6.SelStart:=pos(a[i],Edit6.Text)-1;
          n:=Edit6.SelStart;
          s1:=n+1;
          j:=j1;
          s:=s1-j;
          if ((s<=159) and (s>=0)) then
           begin
            s:=s1-j;
            a[i]:=st[s];
            goto M;
           end;
          j:=j1-n-1;
          repeat
           tt:=j-159;
           s:=abs(tt);
           j:=s;
          until (s<=159);
          s:=159-s;
          a[i]:=st[s];
          M:
         end
        else
       end;
      shif_str:=a;
     except
      MessageDlg('Ошибка открытия пароля!',mtError,[mbOK],0);
     end;

    вот такая процедура "проверки" пароля попалась)))

    stasuss, 05 Марта 2012

    Комментарии (7)
  7. Pascal / Говнокод #8906

    +89

    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
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    unit DllUnit; interface
    
    uses windows, sysutils;
    
    Procedure GuPrcA(var p:PAnsiChar;const l:integer); StdCall;
    Procedure GuPrcW(var p:PWideChar;const l:integer); StdCall;
    
    Exports GuPrcA,GuPrcW;
    
    implementation
    
    procedure GuMes(s:string);
    begin
    MessageBox(0,pchar(s),'From dll',mb_iconinformation);
    end;
    
    Procedure GuPrcW(var p:PWideChar;const l:integer); // wide
    var s:widestring;
    begin
    if (p=nil)or(l<1) then begin p:=nil;exit;end;
    SetLength(s,trunc(l/sizeof(widechar)));Move(p^,Pointer(s)^,l);
    gumes('l: '+inttostr(l)+', nl: '+inttostr(length(s))+#10+'-'+s+'-');
    s:=widestring(Uppercase(s));Move(Pointer(s)^,p^,l);
    end;
    
    Procedure GuPrcA(var p:Pansichar;const l:integer); // ansi
    var s:ansistring;
    begin
    if (p=nil)or(l<1) then begin p:=nil;exit;end;
    SetLength(s,l);Move(p^,Pointer(s)^,l);
    gumes('l: '+inttostr(l)+', nl: '+inttostr(length(s))+#10+'-'+s+'-');
    s:=ansistring(AnsiUppercase(s));Move(Pointer(s)^,p^,l);
    end;
    
    Initialization
    
    ReportMemoryLeaksOnShutdown:=true;
    
    end.
    
    (* выше - DLL, ниже импорт из неё *)
    ...
    implementation
    
    {$R *.dfm}
    
    Procedure GuPrcA(var p:PansiChar;const l:cardinal); StdCall; external 'mydll.dll' name 'GuPrcA';
    Procedure GuPrcW(var p:PwideChar;const l:cardinal); StdCall; external 'mydll.dll' name 'GuPrcW';
    
    procedure TForm1.Button6Click(Sender: TObject);
    var p:pwidechar;c:cardinal;s:widestring;
    begin
    s:=widestring(memo1.Text);
    c:=length(s)*sizeof(widechar);
    p:=allocmem(c);
    Move(Pointer(s)^,p^,c);
    GuPrcW(p,c);
    s:='';setlength(s,trunc(c/sizeof(widechar)));
    Move(p^,Pointer(s)^,c);
    Freemem(p,c);
    memo1.Text:='='+s+'= l:'+inttostr(c);
    end;
    
    procedure TForm1.Button7Click(Sender: TObject);
    var p:pansichar;c:cardinal;s:ansistring;
    begin
    s:=ansistring(memo1.text);
    c:=length(s);
    p:=allocmem(c);
    Move(Pointer(s)^,p^,c);
    GuPrcA(p,c);
    s:='';setlength(s,c);
    Move(p^,Pointer(s)^,c);
    Freemem(p,c);
    memo1.Text:='='+s+'= l:'+inttostr(c);
    end;
    
    Initialization
    
    ReportMemoryLeaksOnShutdown:=true;
    
    end.

    На стековерфловочке завелся некий GuSoft (sic!), который регулярно постит свои высеры через гоогле транслате. Сегодня вот таким шедевром разродился, хочет бесплатных консультаций чтобы в этой херне ему поискали ошибки и «оптимизировали».

    bugmenot, 05 Января 2012

    Комментарии (11)
  8. Java / Говнокод #8865

    +89

    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
    /*
         * helper function that will complete the entire compile
         * process, but allow both filestreams and regular input
         * streams to be compiled.
         */
        static boolean doCompile(InputStream in,
            String pathspec,
            String scriptname,
            String filename,
            String encoding,
    		String swf_options,
    		String avmplus_exe,
            ObjectList<IncludeInfo> includes,
        ObjectList<String> import_filespecs,
        ObjectList<String> use_namespaces,
    	String language,
        ObjectList<ConfigVar> configs,
        ObjectList<CompilerPlug> plugs,
        CompilerHandler handler,
            boolean emit_doc_info /*false*/,
    			boolean emit_debug_info /*=false*/,
                    boolean show_instructions /*=false*/,
                        boolean show_machinecode /*=false*/,
                            boolean show_linenums /*=false*/,
                                boolean show_parsetrees /*=false*/,
                                    boolean show_bytes /*=false*/,
                                        boolean show_flow /*=false*/,
                                            boolean lint_mode /*=false*/,
                                                boolean use_static_semantics /*=false*/,
                                                    boolean emit_metadata,
                                                        boolean save_comment_nodes/*=false*/,
                                                            int dialect /*=0*/,
                                                                int target,
                                                                    boolean optimize,
    							 ObjectList<ConfigVar> optimizer_configs,
    							 int api_version)
        { ... }

    От меня что-то ускользает, или это так нормально?
    http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/modules/asc/src/java/macromedia/asc/embedding/Compiler.java

    wvxvw, 18 Декабря 2011

    Комментарии (21)
  9. Pascal / Говнокод #8141

    +89

    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
    unit uIsPalindrome; 
      
    interface
      
    function IsPalindrome(const aString: string): Boolean; 
      
    implementation
      
    uses
           Spring.Collections 
         , {$IF CompilerVersion >= 230}System.{$IFEND}SysUtils 
         ; 
      
    function CleanString(const aString: string): string; 
    var
      C: char; 
    begin
      // Remove all non-alpha chars and make all lower case 
      // Spaces don't matter, so let's count only letters 
      Result := ''; 
      for C in LowerCase(aString) do
      begin
        if CharInSet(C, ['a'..'z', 'A'..'Z']) then
        begin
          Result := Result + C; 
        end; 
      end; 
    end; 
      
    function IsPalindrome(const aString: string): Boolean; 
    var
      Stack: IStack<Char>; 
      C: Char; 
      NoSpaces: string; 
      Temp: string; 
    begin
      NoSpaces :=  CleanString(aString); 
      
      Stack := TCollections.CreateStack<Char>; 
      for C in NoSpaces do
      begin
        Stack.Push(C); 
      end; 
      Temp := ''; 
      repeat
        Temp := Temp + Stack.Pop; 
      until Stack.Count = 0; 
      Result := Temp = NoSpaces; 
    end; 
      
    end.

    true java style...

    d_dev, 10 Октября 2011

    Комментарии (31)
  10. Java / Говнокод #7486

    +89

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    while (m.find()) {
        String sentence = m.group(0);
        setterMethodName = "setElement" + sentence;
        break;
    }

    Чем автора не устроил оператор if остается загадкой.

    askell, 08 Августа 2011

    Комментарии (40)
  11. Pascal / Говнокод #7095

    +89

    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
    // qsort.inc:
    procedure SortRow(var A: array of T);
    
      procedure sort(l,r: integer);
      var
        i,j: integer;
        x,y: T;
      begin
        i := l;
        j := r;
        x := a[random(r-l+1)+l];
        repeat
          while LESS(a[i],x) do inc(i);
          while LESS(x,a[j]) do dec(j);
          if i<=j then begin
            y    := a[i];
            a[i] := a[j];
            a[j] := y;
            inc(i);
            dec(j);
          end;
        until i>=j;
        if l<j then sort(l,j);
        if i<r then sort(i,r);
      end;
    
    begin
      Sort(Low(A), High(A));
    end;
    
    // unit1.pas
      T = TPoint;
      function LESS(const a,b: T): boolean;
      begin
        result := a.x<b.x;
      end;
      {$I qsort.inc}
    
    var 
      a: array of TPoint;
    begin  
      ...
      SortRow(a);
      ...
    end;

    Я использую шаблоны в Дельфи-7 ололо.

    TarasB, 28 Июня 2011

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