1. Pascal / Говнокод #9979

    +73

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function ADHasFactory(const AIID: TGUID): Boolean;
    var
      oIntf: IUnknown;
    begin
      try
        ADCreateInterface(AIID, oIntf, False);
        Result := oIntf <> nil;
      except
        Pointer(oIntf) := nil;
        Result := False;
      end;
    end;

    AnyDAC. Проверка наличия фабрики для заданного интерфейса.

    LightBlack, 18 Апреля 2012

    Комментарии (11)
  2. C# / Говнокод #9978

    +110

    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
    this.pictureBox14.BeginInit();
          this.pictureBox15.BeginInit();
          this.pictureBox15.BeginInit();
          this.pictureBox21.BeginInit();
          this.pictureBox21.BeginInit();
          this.pictureBox22.BeginInit();
          this.pictureBox22.BeginInit();
          this.pictureBox23.BeginInit();
          this.pictureBox23.BeginInit();
          this.pictureBox24.BeginInit();
          this.pictureBox24.BeginInit();
          this.pictureBox16.BeginInit();
          this.pictureBox16.BeginInit();
          this.pictureBox17.BeginInit();
          this.pictureBox17.BeginInit();
          this.pictureBox18.BeginInit();
          this.pictureBox18.BeginInit();
          this.pictureBox19.BeginInit();
          this.pictureBox19.BeginInit();
          this.pictureBox20.BeginInit();
          this.pictureBox20.BeginInit();
          this.pictureBox9.BeginInit();
          this.pictureBox9.BeginInit();
          this.pictureBox6.BeginInit();
          this.pictureBox6.BeginInit();
          this.pictureBox5.BeginInit();
          this.pictureBox5.BeginInit();
          this.pictureBox7.BeginInit();
          this.pictureBox7.BeginInit();
          this.pictureBox10.BeginInit();
          this.pictureBox10.BeginInit();
          this.panel1.SuspendLayout();
          this.panel1.SuspendLayout();
          this.SuspendLayout();
          this.SuspendLayout();
          this.panel3.Location = new Point(140, 36);
          this.panel3.Location = new Point(140, 36);
          this.panel3.Name = "panel3";
          this.panel3.Name = "panel3";
          this.panel3.Size = new Size(740, 436);
          this.panel3.Size = new Size(740, 436);
          this.panel3.TabIndex = 4;
          this.panel3.TabIndex = 4;
          this.panel3.MouseDown += new MouseEventHandler(this.panel3_MouseDown);
          this.panel3.MouseDown += new MouseEventHandler(this.panel3_MouseDown);
          this.panel3.MouseUp += new MouseEventHandler(this.panel3_MouseUp);
          this.panel3.MouseUp += new MouseEventHandler(this.panel3_MouseUp);
          this.pictureBox2.BackColor = Color.Gray;
          this.pictureBox2.BackColor = Color.Gray;
          this.pictureBox2.Location = new Point(-11, 0);
          this.pictureBox2.Location = new Point(-11, 0);
          this.pictureBox2.Name = "pictureBox2";
          this.pictureBox2.Name = "pictureBox2";
          this.pictureBox2.Size = new Size(938, 36);
          this.pictureBox2.Size = new Size(938, 36);
          this.pictureBox2.TabIndex = 1;
          this.pictureBox2.TabIndex = 1;
          this.pictureBox2.TabStop = false;
          this.pictureBox2.TabStop = false;
          this.pictureBox3.BackColor = Color.Gray;
          this.pictureBox3.BackColor = Color.Gray;
          this.pictureBox3.Location = new Point(880, 12);
          this.pictureBox3.Location = new Point(880, 12);
          this.pictureBox3.Name = "pictureBox3";
          this.pictureBox3.Name = "pictureBox3";
          this.pictureBox3.Size = new Size(36, 466);
          this.pictureBox3.Size = new Size(36, 466);
          this.pictureBox3.TabIndex = 0;
          this.pictureBox3.TabIndex = 0;
          this.pictureBox3.TabStop = false;
          this.pictureBox3.TabStop = false;
          this.pictureBox1.BackColor = Color.Gray;
          this.pictureBox1.BackColor = Color.Gray;
          this.pictureBox1.Location = new Point(-4, 472);
          this.pictureBox1.Location = new Point(-4, 472);
          this.pictureBox1.Name = "pictureBox1";
          this.pictureBox1.Name = "pictureBox1";
          this.pictureBox1.Size = new Size(938, 36);
          this.pictureBox1.Size = new Size(938, 36);
          this.pictureBox1.TabIndex = 0;

    Полная версия: http://pastebin.com/KwDzLR4s

    P4R4, 18 Апреля 2012

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

    +174

    1. 1
    2. 2
    3. 3
    4. 4
    private function FunctionFalse()
    	{
    		return false;
    	}

    битрикс он такой

    minisot, 18 Апреля 2012

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

    +111

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    private IEnumerable<Tuple<IList<string>, IList<string>>> GetFieldInfo(IField Field)
    {
    		foreach (var val in Field.Fields["info"].Values)
    		{
    				yield return new Tuple<IList<string>, IList<string>>(val["Id"].Values, val["ip"].Values);
    		}
    }

    beardeddev, 18 Апреля 2012

    Комментарии (0)
  5. JavaScript / Говнокод #9975

    +155

    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
    var d = new Date();
        dom = d.getDate();
        month = d.getMonth();
        year = d.getYear();
        if (year < 2000) year = year - 100;
        else year = year - 2000;
    
        if (year == 12 && month == 3)
            days = 26 - dom;
        else 
            days = 0;
        if (days < 0) days = 0;
        if (days < 10) days = '0' + days.toString();
    
    
    var base = 'http://ubuntu.ru/media/countdown/1204_1/';
    
    document.write('<a href="http://ubuntu.ru/"><img id="countdownimage" src="'+base+days+'.png" width="180" height="150" border="0" alt="Ubuntu 12.04 LTS" title="Ubuntu 12.04 LTS - Уже скоро!"></a>');
    //document.write('<a href="http://ubuntu.ru/get"><img id="countdownimage" src="'+base+'here.png" width="180" height="150" border="0" alt="Ubuntu 12.04 LTS" title="Ubuntu 12.04 LTS - Уже здесь!"></a>');

    http://ubuntu.ru/media/countdown/display.js

    хуита, 18 Апреля 2012

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

    +110

    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
    public  Operation.OperationStatus   OperState
            {
                get { return fOperState; }
                set
                {
                    fOperState  =   value;
                    // Надписи кнопок смены статуса
                    TOperation.TOperationState  
                        OperationState  =   TOperation.OperationState(value);
                    btnOldState.Text    =   OperationState.OldName;
                    btnNewState.Text    =   OperationState.NewName;
                    // Видимость кнопок смены статуса
                    switch (value)
                    {
                        case Operation.OperationStatus.New          :
                            btnOldState.Visible =   OperationState.OldName.Length > 0 && !ReadOnlyMode;
                            btnNewState.Visible =   OperationState.NewName.Length > 0 && OwnerOper.AccessInput && !ReadOnlyMode;
                            break;
    
                        case Operation.OperationStatus.DataInput    :
                            btnOldState.Visible =   OperationState.OldName.Length > 0 && OwnerOper.AccessInput && !ReadOnlyMode;
                            btnNewState.Visible =   OperationState.NewName.Length > 0 && OwnerOper.AccessCheck && !ReadOnlyMode;
                            break;
    
                        case Operation.OperationStatus.DataCheck    :
                            btnOldState.Visible =   OperationState.OldName.Length > 0 && OwnerOper.AccessCheck && !ReadOnlyMode;
                            btnNewState.Visible =   OperationState.NewName.Length > 0 && OwnerOper.AccessConfirm && !ReadOnlyMode;
                            break;
    
                        case Operation.OperationStatus.Closed       :
                            btnOldState.Visible =   OperationState.OldName.Length > 0 && OwnerOper.AccessConfirm && !ReadOnlyMode;
                            btnNewState.Visible =   OperationState.NewName.Length > 0 && !ReadOnlyMode;
                            break;
                    }
                }
            }
    public  static  TOperationState OperationState(Operation.OperationStatus pState)
            {
                TOperationState Result  =   new TOperationState();
                switch (pState)
                {
                    case Operation.OperationStatus.New          :
                        Result.OldName  =   "";
                        Result.NewName  =   "Данные введены";
                        break;
                    case Operation.OperationStatus.DataInput    :
                        Result.OldName  =   "Отменить \"Данные введены\"";
                        Result.NewName  =   "Данные проверены";
                        break;
                    case Operation.OperationStatus.DataCheck    :
                        Result.OldName  =   "Отменить \"Данные проверены\"";
                        Result.NewName  =   "Завершена";
                        break;
                    case Operation.OperationStatus.Closed       :
                        Result.OldName  =   "Отменить \"Завершена\"";
                        Result.NewName  =   "";
                        break;
                }
                return Result;
            }

    Не прям штобы очень, но шоколад есть...

    gcoder, 18 Апреля 2012

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

    +113

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    StringBuilder script = new StringBuilder();
    script.Append("<script type=text/javascript>alert('Данные не сохранены');</");
    script.Append("script>");
    
    Page.ClientScript.RegisterStartupScript(this.GetType(), "catchScript", script.ToString());

    Поддерживаю проект от других разработчиков.
    Если честно казалось бы придраться не к чему, все будет работать - но почему нужно было делать такой разрыв строки и посреди тега? Это меня в ступор вгоняет. Совпадений по проекту 83 таких.

    sergey_sh, 18 Апреля 2012

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

    +158

    1. 1
    if($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") die("Вот тебе и лол...");

    неибическая защита от обычных запросов через урл в адресной строке)

    nur, 17 Апреля 2012

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

    +146

    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
    <div class="whitestar<?=preg_replace ("/^[^0-9\s]*$/","",$array[0]->OriginalStarName);?>" style="z-index:4;position:absolute;top:187px;left:196px;"></div>
    <!--<div style="z-index:4;font-family:'Arial';font-weight:normal;font-size:9px;color:#000000;position:absolute;top:185px;left:250px;width:150px;"><input type=checkbox value='Сравнить' chechked><a href="#" style="color:#000000;border:0px;font-size:10px;text-decoration:underline;">Сравнить</a></div>-->
    </div>
    		<div class="pr_cover">
    <div style="z-index:26;font-family:'Arial';font-weight:bold;text-decoration:none;text-transform:uppercase;font-size:12px;color:#FFFFFF;position:absolute;top:18px;left:24px;width:100px;"><?=$array[0]->OriginalMealName;?></div>
    <div style="z-index:26;font-family:'Arial';font-weight:normal;text-decoration:none;text-transform:none;font-size:12px;color:#FFFFFF;position:absolute;top:39px;left:24px;width:95px;">Цена указана за одного человека в номере <?=$array[0]->RoomName;?><br/> за <?=$array[0]->Nights;?> ночей<br/><a href=# style="font-family:'Arial';font-weight:normal;text-decoration:underline;text-transform:none;font-size:12px;color:#FFFFFF;border: 0px none;">На карте</a><div class="whitearrow" style="z-index:26;position:relative;top:-11px;left:55px;"></div></div>
    
    <?//get hotel url for colorbox popup
    //var_dump($array[0]);die();
    $urlParams = "?HotelId={$array[0]->HotelId}"."&HotelName=".urlencode($array[0]->HotelName)."&CityFromName=".urlencode($array[0]->CityFromName)."&CountryName=".urlencode($array[0]->CountryName)."&ResortName=".urlencode($array[0]->ResortName)."&CheckInDate=".urlencode($array[0]->CheckInDate)."&Nights=".urlencode($array[0]->Nights)."&MealName=".urlencode($array[0]->MealName)."&Price=".urlencode($array[0]->Price)."&StarId=".urlencode($array[0]->StarId).'&RoomName=' . urlencode($array[0]->RoomName) . '&HotelDescriptionUrl=' . urlencode($array[0]->HotelDescriptionUrl);
    $open_hotel_url = "http://_удалено_/stranica_informacii_ob_otele/" . $urlParams;
    $open_contact_url = "http://_удалено_/oformlenie_zakaza_iframe/" . $urlParams;
    $open_hotel_title=strtoupper($array[0]->CountryName).', '.$array[0]->ResortName;?>
    
    <div style="z-index:26;position:absolute;top:182px;left:24px;width:100px;"><a href='<?=$open_hotel_url;?>' title='<?=$open_hotel_title?>' class='vitrina_open_hotel_popup' style="font-family:'Arial';font-weight:normal;text-decoration:underline;text-transform:none;font-size:12px;color:#FFFFFF;border: 0px none;">Подробнее</a></div>
    <div class="whitearrow" style="z-index:26;position:absolute;top:185px;left:96px;"></div>
    
    <div style="z-index:26;font-family:'Arial';font-weight:bold;text-decoration:none;text-transform:none;font-size:10px;color:#FFFFFF;position:absolute;top:18px;left:150px;width:160px;"><b style="text-transform:uppercase;">Стоимость включает:</b>

    Это кусочек кода из проекта, в который меня пригласили "кое-что дописать".

    chlap, 17 Апреля 2012

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

    +171

    1. 1
    2. 2
    3. 3
    4. 4
    <?php
    class Modules_Admin_Parser_Driver_SiteCom implements Modules_Admin_Parser_Interface {
    }
    ?>

    Старый добрый неймспейс

    Zho, 17 Апреля 2012

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