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

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

    +33.6

    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
    <?
     function ShowImage($strImage, $iMaxW=0, $iMaxH=0, $sParams=null, $strImageUrl="", $bPopup=false, $sPopupTitle=false, $iSizeWHTTP=0, $iSizeHHTTP=0)
     {
      global $DOCUMENT_ROOT, $DB;
    
      if(!($arImgParams = CFile::_GetImgParams($strImage, $iSizeWHTTP, $iSizeHHTTP)))
       return "";
    
      if($sParams === null || $sParams === false)
       $sParams = ' border="0" ';
    
      $iMaxW = intval($iMaxW);
      $iMaxH = intval($iMaxH);
    
      $strImage = htmlspecialchars($arImgParams["SRC"]);
      $intWidth = $arImgParams["WIDTH"];
      $intHeight = $arImgParams["HEIGHT"];
      $strAlt = $arImgParams["ALT"];
    
      if($sPopupTitle===false)
       $sPopupTitle=GetMessage("FILE_ENLARGE");
    
      $file_type = GetFileType($strImage);
      switch($file_type):
       case "FLASH":
        $iWidth = $intWidth;
        $iHeight = $intHeight;
        if($iMaxW>0 && $iMaxH>0 && ($intWidth > $iMaxW || $intHeight > $iMaxH))
        {
         $coeff = ($intWidth/$iMaxW > $intHeight/$iMaxH? $intWidth/$iMaxW : $intHeight/$iMaxH);
         $iWidth = intval(roundEx($intHeight/$coeff));
         $iHeight = intval(roundEx($intWidth/$coeff));
        }
        $strReturn = '
         <object
          classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000"
          codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
          id="banner"
          WIDTH="'.$iWidth.'"
          HEIGHT="'.$iHeight.'"
          ALIGN="">
           <PARAM NAME="movie" VALUE="'.$strImage.'" />
           <PARAM NAME="quality" VALUE="high" />
           <PARAM NAME="bgcolor" VALUE="#FFFFFF" />
           <embed
            src="'.$strImage.'"
            quality="high"
            bgcolor="#FFFFFF"
            WIDTH="'.$iWidth.'"
            HEIGHT="'.$iHeight.'"
            NAME="banner"
            ALIGN=""
            TYPE="application/x-shockwave-flash"
            PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
           </embed>
         </object>
         ';
        return $bPopup? $strReturn : print_url($strImageUrl, $strReturn);
    
       default:
        $strReturn = "<img src=\"".$strImage."\" ".$sParams." width=\"".$intWidth."\" height=\"".$intHeight."\" alt=\"".htmlspecialchars($strAlt)."\" />";
        if($iMaxW > 0 && $iMaxH > 0) //need to check scale, maybe show actual size in the popup window
        {
         //check for max dimensions exceeding
         if($intWidth > $iMaxW || $intHeight > $iMaxH)
         {
          $coeff = ($intWidth/$iMaxW > $intHeight/$iMaxH? $intWidth/$iMaxW : $intHeight/$iMaxH);
          $strReturn = "<img src=\"".$strImage."\" ".$sParams." width=\"".intval(roundEx($intWidth/$coeff))."\" height=\"".intval(roundEx($intHeight/$coeff))."\" alt=\"".htmlspecialchars($strAlt)."\" />";
    
          if($bPopup) //show in JS window
          {
           if(strlen($strImageUrl)>0)
           {
            $strReturn =
             '<a href="'.$strImageUrl.'" title="'.$sPopupTitle.'" target="_blank">'.
             '<img src="'.$strImage.'" '.$sParams.' width="'.intval(roundEx($intWidth/$coeff)).'" height="'.intval(roundEx($intHeight/$coeff)).' alt="'.htmlspecialchars($sPopupTitle).'" />'.
             '</a>';
           }
           else
           {
            CFile::OutputJSImgShw();
    
            $strReturn =
             "<a title=\"".$sPopupTitle."\" onClick=\"ImgShw('".AddSlashes($strImage)."','".$intWidth."','".$intHeight."', '".AddSlashes(htmlspecialcharsex(htmlspecialcharsex($strAlt)))."'); return false;\" href=\"".$strImage."\" target=\"_blank\">".
             "<img src=\"".$strImage."\" ".$sParams." width=\"".intval(roundEx($intWidth/$coeff))."\" height=\"".intval(roundEx($intHeight/$coeff))."\" /></a>";
           }
          }
         }
        }
        return $bPopup? $strReturn : print_url($strImageUrl, $strReturn);
    
      endswitch;
    
      return $bPopup? $strReturn : print_url($strImageUrl, $strReturn);
     }
    ?>

    Уникальный фрагмент кода из CMS Bitrix 7.x.
    Судя по всему его писал индус который не проверял его работы.
    Некотором будет непонятен тонкий юмор автора этого кода, но когда пытаешься решить с его помощью конкретную задачу становится совсем не смешно а наоборот обидно, за себя и толпы тысяч людей полагающих что Bitrix решение всех его проблем логика работы в котором напрочь отсутствует так же как и здравый смысл.
    Сделаю небольшой намёк. Весь фокус во взаимной зависимости параметров
    $iMaxW=0, $iMaxH=0, $strImageUrl="", $bPopup=false

    guest, 22 Января 2009

    Комментарии (3)
  3. JavaScript / Говнокод #70

    +33.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <script>
    function changeLogo(imgLoc){
        document.getElementById("module_logo").src = "./site/" + imgLoc + "_logo.jpg";
    }
    function returnLogo(imgLoc){
        document.getElementById("module_logo").src = "./site/" + imgLoc + "_logo.jpg";
    }
    </script>

    guest, 08 Декабря 2008

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

    +33.4

    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
    <div id="timer">
    Включи JS
    </div>
    
    <script language="Javasсript" type="text/javasсript">
    //<![CDАТА[
    x642=10;
    function countdown() 
    {
    if ((0 <= 100) || (0 > 0))
    {
    x642--;
    if(x642 == 0)
    {
    document.getElementById("timer").innerHTML = '<a href="ссыла">bla<\/a>';
    }
    if(x642 > 0)
    {
    document.getElementById("timer").innerHTML = '<p align=center>Вы будете перенаправлены на страницу загрузки файлов через '+x642+' сек.</p>';
    setTimeout('countdown()',1000);
    }
    }
    }
    countdown();
    //]]>
    </script>

    счетчик...
    взято отсюда: http://vkontakte.ru/topic14311792

    guest, 19 Января 2009

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

    +33.2

    1. 1
    cStaticObject * CreateStaticObject	( obj_id_t object_id, mesh_id_t mesh_id, material_id_t material_id, int32_t coord_x, int32_t coord_y, int32_t coord_z, int32_t angle_azimuth, int32_t angle_zenith, int32_t angle_longitudinal, uint32_t size_x, uint32_t size_y, uint32_t size_z, uint16_t flags );

    stup, 11 Августа 2009

    Комментарии (6)
  6. PHP / Говнокод #304

    +33.1

    1. 1
    $this->mm = ($this->md[2] < 4) ? ($this->md[2] < 3) ? ($this->md[2] < 2) ? imagecreatefromgif($this->mi) : imagecreatefromjpeg($this->mi) : imagecreatefrompng($this->mi) : Null;

    Загрузка изображения в VaMShop

    guest, 29 Декабря 2008

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

    +33

    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
    template<typename F, typename... Fns>
    struct Overloaded
    {
      std::tuple<F,Fns...> fns;
      
      // эта и следующая за ней функция нужны для рекурсивного
      // накопления кортежа из всех входящих функций
      template<typename First, typename... Others>
      std::tuple<First,Others...> collect(First f, Others... others) {
        auto t = std::make_tuple(f);
        return std::tuple_cat(t, collect(others...));
      }
      template<typename Single>
      std::tuple<Single> collect(Single f) {
        return std::make_tuple(f);
      }
      
      Overloaded(F f, Fns... others) {
        // сохраняем кортеж функций
        fns = collect(f, others...);
      }
    };
    
    template<typename F, typename... Fns>
    Overloaded<F,Fns...> make_overloaded(F f, Fns... fns) {
      return Overloaded<F,Fns...>(f,fns...);
    }
    
    //...
    
    void F1(int) {}
    void F2(int, float) {}
    // ...
    auto f = make_overloaded(F1, F2);

    Не хочется связываться с бустом ввиду его убогости громоздкости. Поэтому пытаюсь сделать сам на чистом C++11 без макросов.
    Не понятно теперь как перегрузить оператор ()?
    Задействовать enable_if? Ни чего в голову не приходит.
    Есть у кого идеи?

    Оттуда

    LispGovno, 03 Февраля 2014

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

    +33

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    std::vector<int> data;
    	// ...
    	for (int i = 0; i < data.size(); ++i) {
    		int item = data.begin()[i];
    		// ...
    	}

    Cpp, 22 Февраля 2013

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

    +33

    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
    std::function<int()> gl()
    {
       int a=0;
       return [=]()mutable{return a++;};
    }
    
    int main() 
    {
       auto a=gl();
       cout 
          <<a()
          <<endl
          <<a()
          <<endl
          <<a()
          <<endl
          <<a();
       return 0;
    }

    http://liveworkspace.org/code/22012a32e91743cd7357c86930df4b9c

    Не совсем гавно, но порядок выполнения операторов вывода C++ для меня оказался неожиданным и не интуитивным.

    LispGovno, 17 Октября 2012

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

    +33

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    class Chatter : public QListBoxItem {
        [...]
        private:
            static ChatterRef *chatters[MAX_NUM_CHATTERS];
            [...]
            friend int main(int, char *argv[]);	// to destroy chatters[]
    };

    Сам проект: http://www.qtchat.org/qtchat/
    Пример дается в этой книге: http://books.google.ru/books?id=8lYbNfsAVT4C&dq=qtchat&source=g bs_navlinks_s как пример friend-функций

    myaut, 07 Октября 2012

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

    +33

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
    <meta http-equiv=Content-Type content="text/html; charset=windows-1251">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel=File-List href="SL_php2weeks_box.files/filelist.xml">
    
    <title>PHP за 2 недели - курс обучения PHP от Школы Программирования</title>
    <style type="text/css">
    <!--
    .style1 {font-family: Georgia, "Times New Roman", Times, serif}
    .style5 {font-family: Georgia, "Times New Roman", Times, serif; font-style: italic; }
    .style6 {font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; }
    .style7 {font-family: Verdana, Arial, Helvetica, sans-serif}
    .style8 {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-weight: bold;
    	font-style: italic;
    	color: #009000;
    }
    .style9 {
    	font-family: Georgia, "Times New Roman", Times, serif;
    	font-size: 18px;
    }
    .style10 {
    	font-family: "Courier New", Courier, monospace;
    	font-size: 12px;
    }
    .style11 {
    	font-size: 24px;
    	font-weight: bold;
    }
    .style12 {font-size: 24px; font-weight: bold; font-family: Georgia, "Times New Roman", Times, serif; }
    .style13 {font-size: 24px; font-weight: bold; font-family: Georgia, "Times New Roman", Times, serif; font-style: italic; }
    .style14 {font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; font-style: italic; }
    .style15 {
    	color: #0000FF;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    }
    .style17 {font-family: Georgia, "Times New Roman", Times, serif; font-style: italic; font-size: 16px; }
    .style18 {
    	font-size: 20px
    }
    -->
    </style>
    </head>
    
    
    
    <body lang=RU link=blue vlink=purple>
    
    <!-- SmartResponder.ru PopOver code (begin) -->
    <script language="javascript" type="text/javascript" src="popover.js"></script>
    <span style="margin: 0pt; padding: 0pt; width: 400px; height: 400px; position: absolute; left: 0pt; top: 0pt; right: 0pt; z-index: 1; display: none;" id="SR_PopOver">
    <table cellpadding="0" cellspacing="0" height="246" width="400">
    <tbody>
    <tr>
    <td style="border: 1px solid rgb(0, 0, 0);">
    <table bgcolor="#ffffff" cellpadding="3" cellspacing="0" height="100%" width="100%">
    <tbody>
    <tr bgcolor="#dddddd" valign="middle">
    <td onMouseDown="popover_drag_start(event, this, 'SR_PopOver')" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 255); font-weight: bold;" align="center" width="100%">
    <b>Подарок Вам - <font style="color:#009000;">Курс Web-Старт!</font><br /> 7 Бесплатных Видеоуроков По PHP!</b></td>
    <td align="right">
    <table cellspacing="0">
    <tbody>
    
    <tr>
    <td style="padding: 0pt 3px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: rgb(0, 0, 0); font-weight: bold;" onClick="popover_close(this, 'popover_start_to(\'SR_PopOver\', 21, 0, \'windowWidth\', parseInt(popover_obj.style.top) - popover_base_y)')" onMouseOver="this.style.cursor='pointer'" onMouseOut="this.style.cursor='default'">X</td>
    </tr>
    </tbody>
    </table>

    http://prog-school.ru/php2weeks/

    вот как бывает! исходник страницы смотрите сами :)

    brainstorm, 11 Декабря 2010

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