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

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

    +137

    1. 1
    2. 2
    $users_count = count($this->db->exe('select * from px_users'));  
    $users = $this->db->exe('select * from px_users order by name limit ' . $from . ',' . $perpage);

    guest, 10 Февраля 2009

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

    −349

    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
    def MappingRights(i, s, u, d):
        INS=i.split(":")
        SEL=s.split(":")
        UPD=u.split(":")
        DEL=d.split(":")
    
        id_group=INS[0];
        right=str(int(bool(INS[1].capitalize()))) + \
              str(int(bool(SEL[1].capitalize()))) + \
              str(int(bool(UPD[1].capitalize()))) + \
              str(int(bool(DEL[1].capitalize())))
    
        return id_group, right;

    Парсим массив с правами переданный из JavaScript.
    нужно из "true" получить "1", соответственно из "false" "0"

    guest, 10 Февраля 2009

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

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    callable Malkovich() as Malkovich
    
    def malkovich() as Malkovich:
        print("Malkovich!")
        return malkovich
    
    malkovich()()()

    из Boo manifest. Не говнокод конечно же.

    guest, 08 Февраля 2009

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

    +165.9

    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
    //Shop-Script PREMIUM  
    
    // -------------------------INITIALIZATION-----------------------------//
    	//include core files
    	include("./cfg/connect.inc.php");
    	include("./includes/database/".DBMS.".php");
    	include("./cfg/language_list.php");
    	include("./core_functions/functions.php");
    	include("./core_functions/category_functions.php");
    	include("./core_functions/cart_functions.php");
    	include("./core_functions/product_functions.php");
    	include("./core_functions/statistic_functions.php");
    	include("./core_functions/reg_fields_functions.php" );
    	include("./core_functions/registration_functions.php" );
    	include("./core_functions/country_functions.php" );
    	include("./core_functions/zone_functions.php" );
    	include("./core_functions/datetime_functions.php" );
    	include("./core_functions/order_status_functions.php" );
    	include("./core_functions/order_functions.php" );
    	include("./core_functions/aux_pages_functions.php" );
    	include("./core_functions/picture_functions.php" ); 
    	include("./core_functions/configurator_functions.php" );
    	include("./core_functions/option_functions.php" );
    	include("./core_functions/search_function.php" );
    	include("./core_functions/discount_functions.php" ); 
    	include("./core_functions/custgroup_functions.php" ); 
    	include("./core_functions/shipping_functions.php" );
    	include("./core_functions/payment_functions.php" );
    	include("./core_functions/tax_function.php" ); 
    	include("./core_functions/currency_functions.php" );
    	include("./core_functions/module_function.php" );
    	include("./core_functions/crypto/crypto_functions.php");
    	include("./core_functions/quick_order_function.php" ); 
    	include("./core_functions/setting_functions.php" );
    	include("./core_functions/subscribers_functions.php" );
    	include("./core_functions/version_function.php" );
    	include("./core_functions/discussion_functions.php" );
    	include("./core_functions/order_amount_functions.php" ); 
    	include("./core_functions/linkexchange_functions.php" ); 
    	include("./core_functions/affiliate_functions.php" );
    
    	include('./classes/xml2array.php');
    	include('./classes/class.virtual.shippingratecalculator.php');
    	include('./classes/class.virtual.paymentmodule.php');
    
    	include('./classes/class.virtual.smsmail.php');
    	include('./modules/smsmail/class.smsnotify.php');
    
    
    	MagicQuotesRuntimeSetting();
    
    	//init Smarty
    	require 'smarty/smarty.class.php';

    500!
    Весь сайт работает только на index.php. И грузит систему это безбожно.
    Взято из Shop-Script PREMIUM.

    guest, 04 Февраля 2009

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

    +169.8

    1. 1
    2. 2
    3. 3
    if ( isset($_GET['action']) && !isset($_GET['action']) ) {
        die('Не не не, Девид Блейн, не не не!!!!! Сдрысни демон!!!!!');
    }

    o_O

    guest, 31 Января 2009

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

    +32

    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
    /** 
     * Сабж: Проверка формы 
     * Для каждого поля в форме было понаколбашено по отдельной(!) функции для проверки
     * Но и это цветочки...
     */ 
    
    // Поехали!(С)
     
    // запуск проверки всех полей формы <- это древний комент
    function checkAll()
    	{
    	var elements = new Array('avto', 'duration', 'start_adress', 'end_adress', 'orderer_name', 'orderer_phone', 'orderer_mail');
    
    	for (i = 0; i < 7; i++)
    		{
    		    var	curEl = document.getElementById(elements[i]);
    		    curEl.focus(); // тут, suka, особенно жестоко!
    		    curEl.blur();  //
    		}
    
    	var StatSum = "";
    
    	for (j = 0; j < 7; j++)
    		{
    			// в форме сделаны были ккрытые инпупуты, куда
    			// проверяющая функция писала 0 или 1 в зависимости от результата проверки
    			var	curStat = document.getElementById(elements[j]+"Status");
    			if (curStat.value == "1")
    				{StatSum = StatSum + "1";}
    			if (curStat.value == "0" || curStat.value == "")
    				{StatSum = StatSum + "";}
    		}
    
    	// ну тут ваще пиздец)))
    	// семь нулей - это семь удачно проверенных полей формы 
    	if 	(StatSum == "" || StatSum == "0000000")
    		{
    			// щёлкаем, suka, по самбмиту..
    			var btn = document.getElementById("submit");
    			btn.click();
    		}
    	return (false);
    	}
    	// занавес...
    	
    /************************************************************/

    Блин, попёрло сейчас покурить свои извращения на JS двухлетней давности...
    У меня истерика = )

    guest, 23 Января 2009

    Комментарии (3)
  8. 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)
  9. PHP / Говнокод #437

    +18.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
    function convert_code_tag_for_email($text = "", $lang=false)
    {
    	global $MESS;
    	if (strlen($text)<=0) return;
    	if($lang===false) $lang = LANGUAGE_ID;
    	$text = stripslashes($text);
    	$text = preg_replace("#<#", "&lt;", $text);
    	$text = preg_replace("#>#", "&gt;", $text);
    	$text = preg_replace("#^(.*?)$#", "   \\1", $text);
    	$OLD_MESS = $MESS;
    	$MESS = array();
    	include($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/lang/".$lang."/tools.php");
    	$s1 = "--------------- ".$MESS["MAIN_CODE_S"]." -------------------";
    	$MESS = $OLD_MESS;
    	$s2 = str_repeat("-",strlen($s1));
    	$text = "\n\n>".$s1."\n".$text."\n>".$s2."\n\n";
    	return $text;
    }

    говнобитрикс

    guest, 22 Января 2009

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

    −13.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    decimal QuantityOut = TehnoMap.Table["Брутто"].ToDecimal() * productionQuantity / TehnoMap["Норма закладки"].ToDecimal();
    
    				string separator = NumberFormatInfo.InvariantInfo.NumberDecimalSeparator;
    				string quantityString = QuantityOut.ToString(NumberFormatInfo.InvariantInfo);
    				if (quantityString.Contains(separator) && quantityString.IndexOf(separator) + 4 < quantityString.Length)
    				{
    					quantityString = quantityString.Remove(quantityString.IndexOf(separator) + 4);
    					QuantityOut = decimal.Parse(quantityString, NumberFormatInfo.InvariantInfo);
    				}

    Нужно было в дроби оставить первые 3 знака после запятой

    guest, 21 Января 2009

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

    +25

    1. 1
    2. 2
    3. 3
    4. 4
    pX := CalcDipol(coord1[index], coord2[index]).X;
    pY := CalcDipol(coord1[index], coord2[index]).Y;
    MoveTo(center.X, center.Y);
    LineTo(pX, pY);

    guest, 19 Января 2009

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