1. JavaScript / Говнокод #15040

    +174

    1. 1
    if (!jQuery(this).html().length > 0) {....}

    нашел в своем старом проекте

    voltaren, 26 Февраля 2014

    Комментарии (10)
  2. PHP / Говнокод #15013

    +177

    1. 1
    2. 2
    $lists['arrDateYear']=array(2000=>2000,2001=>2001,2002=>2002,2003=>2003,2004=>2004,2005=>2005,2006=>2006,2007=>2007,2008=>2008,2009=>2009,2010=>2010);
    $lists['arrDateDay']=array(1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,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);

    1=1

    Merisho, 26 Февраля 2014

    Комментарии (5)
  3. Java / Говнокод #15009

    +69

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    final double base = 10.0;
    final int minCode = (int)Math.pow(base, CODE_LENGTH - 1) - 1;
    final int maxCode = (int)Math.pow(base, CODE_LENGTH) - 1;
    
    while (true)
    {
        final int code = codeGenerator.nextInt();
        if ((code > minCode) && (code <= maxCode))
        {
            return String.valueOf(code);
        }
    }

    Геренация случайного пина с определенным интервалом.

    rvller, 26 Февраля 2014

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

    +155

    1. 1
    http://govnokod.reformal.ru/proj/govnokod?ia=613048

    надеюсь, меня поддержат

    Lokich, 26 Февраля 2014

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

    +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
    $infopage = file_get_contents("http://instagram.com/api/v1/users/".$match."/info/", false, $context);
    $isprivate = substr($infopage,strpos($infopage,',"is_private":')+14,strpos($infopage,',"external_url":"')-strpos($infopage,',"is_private":')-14);
    $fullname = substr($infopage,strpos($infopage,'","full_name":"')+15,strpos($infopage,'","follower_count":')-strpos($infopage,'","full_name":"')-15);
    $mediacount = substr($infopage,strpos($infopage,',"media_count":')+15,strpos($infopage,',"following_count":')-strpos($infopage,',"media_count":')-15);
    $following = substr($infopage,strpos($infopage,',"following_count":')+19,strpos($infopage,',"geo_media_count":')-strpos($infopage,',"following_count":')-19);
    $isint2 = is_numeric($following);
    if ($isint2 == false){$following = substr($infopage,strpos($infopage,',"following_count":')+19,strpos($infopage,',"profile_pic_url":"')-strpos($infopage,',"following_count":')-19);}
    $followers = substr($infopage,strpos($infopage,',"follower_count":')+18,strpos($infopage,',"pk":')-strpos($infopage,',"follower_count":')-18);
    $avatar = stripslashes(substr($infopage,strpos($infopage,'"profile_pic_url":"')+19,strpos($infopage,'","biography":"')-strpos($infopage,'"profile_pic_url":"')-19));
    $bio = substr($infopage,strpos($infopage,'","biography":')+15,strpos($infopage,'","full_name":"')-strpos($infopage,'","biography":')-15);
    $website = stripslashes(substr($infopage,strpos($infopage,'"external_url":"')+16,strpos($infopage,'"}}')-strpos($infopage,'"external_url":"')-16));
    $countq = mysql_query("SELECT COUNT(*) FROM `links` WHERE `ownerID` = '".$match."'");
    $countf = mysql_fetch_array($countq);

    Парсинг API Instagram. JSON - слишком неправославно, да.

    olenyash, 26 Февраля 2014

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

    +143

    1. 1
    2. 2
    if (medicalRecords == null)
        new List<MedicalRecordDispatchingInfoViewModel>();

    Просто сделай мне лист

    Vadimyan, 26 Февраля 2014

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

    +115

    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
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    library ch;
    uses
      Windows,SysUtils,controls,graphics,extctrls,shellapi,Unit1 in 'Unit1.pas' {Form1};
    type
      NTStatus = cardinal;
      far_jmp = packed record
        push: byte;
        PProc: pointer;
        ret: byte;
      end;
      OldCode = packed record
        one: dword;
        two: dword;
      end;
    const
      STATUS_ACCESS_DENIED = NTStatus($C0000022);
      STATUS_SUCCESS = NTStatus($00000000);
    function CreateProcessW(lpApplicationName: PWideChar; lpCommandLine: PWideChar;
      lpProcessAttributes, lpThreadAttributes: PSecurityAttributes;
      bInheritHandles: BOOL; dwCreationFlags: dword; lpEnvironment: pointer;
      lpCurrentDirectory: PWideChar; const lpStartupInfo: TStartupInfo;
      var lpProcessInformation: TProcessInformation): BOOL; stdcall;
      external 'kernel32.dll' name 'CreateProcessW';
    var
      CPA: pointer;
      OldCPA: OldCode;
      JmpCPA: far_jmp;
      b:cardinal;
    
    procedure UnHook;
    begin
      WriteProcessMemory(INVALID_HANDLE_VALUE, CPA, @OldCPA, sizeof(OldCode), b);
    end;
    
    function FalseCreateProcessW():boolean;
    begin
      SetLastError(ERROR_ACCESS_DENIED);
      result:=falsecreateprocessw
    end;
    function TrueCreateProcessW(lpApplicationName: PWideChar;
      lpCommandLine: PWideChar; lpProcessAttributes, lpThreadAttributes
      : PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: dword;
      lpEnvironment: pointer; lpCurrentDirectory: PWideChar;
      const lpStartupInfo: TStartupInfo;
      var lpProcessInformation: TProcessInformation): BOOL; stdcall;
    begin
      WriteProcessMemory(INVALID_HANDLE_VALUE, CPA, @OldCPA, sizeof(OldCode), b);
      Result := CreateProcessW(lpApplicationName, lpCommandLine,
        lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags,
        lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
      WriteProcessMemory(INVALID_HANDLE_VALUE, CPA, @JmpCPA, sizeof(far_jmp), b);
    end;
     function NewCreateProcessW(lpApplicationName: PWideChar;
      lpCommandLine: PWideChar; lpProcessAttributes, lpThreadAttributes
      : PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: dword;
      lpEnvironment: pointer; lpCurrentDirectory: PWideChar;
      const lpStartupInfo: TStartupInfo;
      var lpProcessInformation: TProcessInformation): bool; stdcall;
      var
        reason:string;
    begin
      result:=true;// подавляем ошибку "Доступ запрещен"
     // если что-то нам не понравилось, выходм
      else
      // или выполняем командную строку 
        Result := TrueCreateProcessW(lpApplicationName, lpCommandLine,
        lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags,
        lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
    end;
    procedure SetHook;
    begin
       CPA := GetProcAddress(getmodulehandle('kernel32.dll'), 'CreateProcessW');
       ReadProcessMemory(INVALID_HANDLE_VALUE, CPA, @OldCPA, sizeof(OldCode), b);
       JmpCPA.push := $68;
       JmpCPA.PProc := @NewCreateProcessW;
       JmpCPA.ret := $C3;
       WriteProcessMemory(INVALID_HANDLE_VALUE, CPA, @JmpCPA, sizeof(far_jmp), b);
    
    end;
    function MessageProc(code: integer; wParam: word; lParam: longint)
      : longint; stdcall;
    begin
      Result := CallNextHookEx(0, code, wParam, lParam);
    end;
    procedure SetGlobalHookProc();
    begin
      SetWindowsHookEx(WH_GETMESSAGE, @MessageProc, HInstance, 0);
      sleep(infinite);
    end;
    procedure SetGlobalHook();
    var
      //hMutex: dword;
      TrId: dword;
    begin
        CreateMutex(nil, False, 'Vhook@016');
        if GetLastError = 0 then
        CreateThread(nil, 0, @SetGlobalHookProc, nil, 0, trid)
    end;

    procedure DLLEntryPoint(dwReason: dword);
    begin
    case dwReason of
    DLL_PROCESS_ATTACH:
    begin
    SetHook;
    SetGlobalHook;
    end;
    DLL_PROCESS_DETACH:
    begin
    UnHook;
    end;
    end;
    end;
    begin
    DllProc := @DLLEntryPoint;
    DLLEntryPoint(DLL_PROCESS_ATTACH);
    end.


    Товарищи, как можно поправить этот код, чтобы библиотека подгружалась только к процессу "explorer.exe" и патчила в его памяти CreateProcessW?

    Stertor, 26 Февраля 2014

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

    +131

    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
    private void аффинныйШифрToolStripMenuItem_Click(object sender, EventArgs e)
    {
                foreach (Form childForm in MdiChildren)
                {
                    childForm.Close();
                }
                foreach (Form f in this.MdiChildren)
                {
                    return;
                }
                Affiniy af = new Affiniy();
                af.TopLevel = false;
                af.Show();
                tabPage1.Controls.Add(af);
                af.WindowState = System.Windows.Forms.FormWindowState.Maximized;
    }

    Попросили посмотреть код. 15 методов с различными простейшими шифрами, но чудо foreach -> return, присутствует в каждом. И не лень кому-то было...

    MoN, 26 Февраля 2014

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

    +135

    1. 1
    2. 2
    3. 3
    public static void InsertSalesPerson(
                        ref int? SalesPersonID, int DealerProfileID, int DealerID, int? WebSiteID, string LastName, string FirstName, string Phone, string Email, string Password,
                        int AccessLevelID, int? StatusID, int? LanguageID, int? TimeZoneID, string Title, string SpokenLanguages, bool IsShownInWebSite, bool IsUserInWebSite, string UserName)

    agrynco, 26 Февраля 2014

    Комментарии (4)
  10. C# / Говнокод #14983

    +130

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    catch (Exception e)
                {
                    CommonAPI.SetErrorApp(0, MethodBase.GetCurrentMethod().DeclaringType.Name + "." + MethodBase.GetCurrentMethod().Name, e.Message);
    #if DEBUG
                    throw e;
    #else
                    return 0;
    #endif
                }

    agrynco, 26 Февраля 2014

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