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

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

    +168

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    foreach ($_POST as $k=>$v)
            if (!is_array($v))
                    $_POST[$k] = htmlspecialchars($v);
            else
                    foreach ($v as $kk=>$vv)
                            if (!is_array($vv))
                                    $_POST[$k][$kk] = htmlspecialchars($vv);
                            else
                                    foreach ($vv as $kkk=>$vvv)
                                            if (!is_array($vvv))
                                                    $_POST[$k][$kk][$kkk] = htmlspecialchars($vvv);

    atarix12, 14 Сентября 2011

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $NpjCaps = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЪЫЭЮЯЇЄІ";
            $NpjSmall = "абвгдеёжзийклмнопрстуфхцчшщьъыэюяїєі";
    
            $var = str_replace( ".php", "", $var );
            $var = trim( strip_tags( $var ) );
            $var = preg_replace( "/\s+/ms", "-", $var );
            $var = strtr( $var, $NpjCaps, $NpjSmall );
            $var = strtr( $var, $NpjLettersFrom, $NpjLettersTo );
            $var = strtr( $var, $NpjBiLetters );

    Нашел в одном из "хороших" скриптов D

    SaNcHeS, 13 Сентября 2011

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

    −112

    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
    CREATE TRIGGER after_update_limit AFTER UPDATE ON limits
    FOR EACH ROW
    BEGIN
    	SET @annual_normative = NULL;
    	SET @ud_use = NULL;
    	SET @ud_disposal = NULL;
    	SET @placed_deposited = NULL;
    	SET @placed_disposal = NULL;
    	SET @custom1_disposal = NULL;
    	SET @custom1_deposited = NULL;
    	SET @custom1_use = NULL;
    	SET @custom1_neutralization = NULL;
    	SET @custom2_disposal = NULL;
    	SET @custom2_deposited = NULL;
    	SET @custom2_use = NULL;
    	SET @custom2_neutralization = NULL;
    	SET @custom3_disposal = NULL;
    	SET @custom3_deposited = NULL;
    	SET @custom3_use = NULL;
    	SET @custom3_neutralization = NULL;
    	SET @custom4_disposal = NULL;
    	SET @custom4_deposited = NULL;
    	SET @custom4_use = NULL;
    	SET @custom4_neutralization = NULL;
    	SET @custom5_disposal = NULL;
    	SET @custom5_deposited = NULL;
    	SET @custom5_use = NULL;
    	SET @custom5_neutralization = NULL;
    	SELECT
    		SUM(annual_normative), SUM(ud_use), SUM(ud_disposal), SUM(placed_deposited), SUM(placed_disposal),
    		SUM(custom1_disposal), SUM(custom1_deposited), SUM(custom1_use), SUM(custom1_neutralization),
    		SUM(custom2_disposal), SUM(custom2_deposited), SUM(custom2_use), SUM(custom2_neutralization),
    		SUM(custom3_disposal), SUM(custom3_deposited), SUM(custom3_use), SUM(custom3_neutralization),
    		SUM(custom4_disposal), SUM(custom4_deposited), SUM(custom4_use), SUM(custom4_neutralization),
    		SUM(custom5_disposal), SUM(custom5_deposited), SUM(custom5_use), SUM(custom5_neutralization)
    	INTO
    		@annual_normative, @ud_use, @ud_disposal, @placed_deposited, @placed_disposal,
    		@custom1_disposal, @custom1_deposited, @custom1_use, @custom1_neutralization,
    		@custom2_disposal, @custom2_deposited, @custom2_use, @custom2_neutralization,
    		@custom3_disposal, @custom3_deposited, @custom3_use, @custom3_neutralization,
    		@custom4_disposal, @custom4_deposited, @custom4_use, @custom4_neutralization,
    		@custom5_disposal, @custom5_deposited, @custom5_use, @custom5_neutralization
    	FROM limits
    	WHERE id_enterprise = NEW.id_enterprise;
    	UPDATE limits_total
    	SET
    		annual_normative = @annual_normative, ud_use = @ud_use, ud_disposal = @ud_disposal, placed_deposited = @placed_deposited, placed_disposal = @placed_disposal,
    		custom1_disposal = @custom1_disposal, custom1_deposited = @custom1_deposited, custom1_use = @custom1_use, custom1_neutralization = @custom1_neutralization,
    		custom2_disposal = @custom2_disposal, custom2_deposited = @custom2_deposited, custom2_use = @custom2_use, custom2_neutralization = @custom2_neutralization,
    		custom3_disposal = @custom3_disposal, custom3_deposited = @custom3_deposited, custom3_use = @custom3_use, custom3_neutralization = @custom3_neutralization,
    		custom4_disposal = @custom4_disposal, custom4_deposited = @custom4_deposited, custom4_use = @custom4_use, custom4_neutralization = @custom4_neutralization,
    		custom5_disposal = @custom5_disposal, custom5_deposited = @custom5_deposited, custom5_use = @custom5_use, custom5_neutralization = @custom5_neutralization
    	WHERE id_enterprise = NEW.id_enterprise
    	LIMIT 1;
    END;

    Сперва можно посмеяться, а затем подскажите, пжл, как тоже самое написать по человечески ???

    DarkThinker, 12 Сентября 2011

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

    +169

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    reset($err_list);
    //создаем все необходимые переменные
    while ($var = each($err_list)) {
        eval('if(!isset($_POST["'.$var['key'].'"])){$_POST["'.$var['key'].'"]="";}');
    }

    ...

    temka, 10 Сентября 2011

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?
    if($page!='/volga' && $page!='/volga/index.php'){
    // Тут всякий код
    } if($page=='/volga' or $page=='/volga/index.php'){?>
    // И тут тоже	
    <?}?>

    Tairesh, 08 Сентября 2011

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

    +173

    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
    //Функция возвращает номер месяца по названию
    	  function month_to_num ($month) {
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("январь"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("января"),"UTF-8")) {$num = 1;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("февраль"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("февраля"),"UTF-8")) {$num = 2;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("март"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("марта"),"UTF-8")) {$num = 3;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("апрель"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("апреля"),"UTF-8")) {$num = 4;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("май"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("мая"),"UTF-8")) {$num = 5;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("июнь"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("июня"),"UTF-8")) {$num = 6;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("июль"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("июля"),"UTF-8")) {$num = 7;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("август"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("августа"),"UTF-8")) {$num = 8;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("сентябрь"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("сентября"),"UTF-8")) {$num = 9;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("октябрь"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("октября"),"UTF-8")) {$num = 10;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("ноябрь"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("ноября"),"UTF-8")) {$num = 11;}
          if (mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("декабрь"),"UTF-8") || mb_strtolower($month,"UTF-8") == mb_strtolower($this->t("декабря"),"UTF-8")) {$num = 12;}
    				  return $month;
    	  }

    vaska_proger, 01 Сентября 2011

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

    +161

    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
    //============= 'game' это, собственно, сама игра ==================
    void SUPERMARIO::Game()
    {
      InitForStartGame(0);
      //music(NORMAL_MUSIC);
      while (GAMECYCLE)  //цикл игры
      {
      //I. построение изображения 
      MOVEOBJ::TotalAnimatedObject=0;
      prMonetsChangePhase();
      prPuziri();
      prBuildGamePicture();
      prShowDebugInfo();
      //II. логика игры
      BirdsOtSten();      //птички отталкиваются от стен
      SkeletonCollect();    //собираем скелетов
      prCleverobjRefresh();  //обновляем все у умных объектов
      prMarioDeathOnShipah();  //марио гасится на шипах
      prForMarioProtected();  //чтобы марио был защищенным
      prPrizeCatch(Rick, Prize);//призы не проходят сквозь стенки и марио ловит призы
      prBricksNudgePrize();  //кирпичи могут подталкивать призы
      prBricksRestore();    //восстанавливаем кирпичи
      prTurtleCikAlien();    //черепаха сбивает других чужих
      prMonetsTimeEndTimeLiveAndScoreCreate();//надо создать очки когда монетка пропадает
      prIfGameOver();      //если конец игры 
      prBossSalivaDeathMario();// кегли башки гасят марио и не пролетают через стены
      prBossSendSaliveAndKeepAtMario();//башка пускает "кегли" и находится вблизи от марио
      ArmsKillAlien();    // оружие убивает чужих
      prLiftUpDown();      //меняем направление лифта и обновляем его координаты
      prMarioDeathOnFlower();//марио гасится на зубастых цветках
      prFlowersUpDown();    //поднимаем и опускаем зубастые цветки
      MindobjFunctions(Rick, Cleverobj);//различные функции
      MindobjFunctions(Rick, CleverAlien);//предусмотренные для Mindobj
      prMarioFlyDownCleverobj();  //марио слетает с клевых объектов
      prMarioPositionerOnCleverobject();//позиционируем Mario  на клевый объект
      prMarioRenewXY();//обновляем координаты Mario
      //если ноги марио близко к лифту, марио падает
      prMarioClammyToLift();  //на лифт и его ускорение приравнять к нулю
      prMarioDownsBrickDestroy();//обрушиваем кирпичи под ногами у марио
      prArmsCollisionWithWall();//оружие сталкивается со стенами *
      prRememberOldMarioCoordinates();//запоминаем старые координаты Mario
      prKeyboardProcess();    //обработка НАЖАТИЙ клавиш 
      GameModesTreat();    //обрабатываем ситуацию загрузки и рестарта уровня режимы игры
      if (DoorOpenCounter) DoorOpenCounter--;  //чтобы дверь успела открыться
      prScrollBricks();    //двигается фон (спрайты воды и огня)
      prChangeEffect();    //эффект перехода на другой экран
      prShowFPS();      //показать FPS
      prSynhronization();    //синхронизируемся (ждем когда таймер станет равным 1)
      
      ShowLevelNumberTimeCounter++;
    
      if (ShowLevelNumberTimeCounter<100)
      {
        
        Msg("  УРОВЕНЬ    ", 9, MSG_NOUPDATE);
        
    
        /*if (LevelNumber<40)
        {
          scr.putNumb(LevelNumber/4+1,1);
          scr<< '-';
          scr.putNumb(LevelNumber%4+1,1);
        }
        else
        {
          scr.putNumb(LevelNumber);
        }*/
        scr.putNumb(LevelNumber);
    
      }
      
      static int ShowLog=0;
      //выводим изображение на экран из DoubleBuffer
      if (Keyb[KEY_L] && Keyb[KEY_LEFTCTRL]) 
      {
        Keyb^KEY_L;
        ShowLog^=1;
      }
      
      if (ShowLog) 
      {
        //сжимаем картинку
        for(int i=0; i<100; i++)
        {
          memcpy(scr.DoubleBuffer+i*320, scr.DoubleBuffer+i*2*320,320);
        }
        
        scr.rectangle(0,100,320,100,0);
        Log.Show();
      }
      scr.update();      
      } //конец цикла while
    }//конец функции game

    Ностальгия...

    CPPGovno, 31 Августа 2011

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

    +159

    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
    Obj = 0;
      while (dsmodel1.tellg () < LEN)
      {
        dsmodel1.read ( (char*)&ID, 2);
        dsmodel1.read ( (char*)&length, 4);
    
        switch (ID)
        {
        case 0x4d4d: break;
        case 0xb000: break;
        case 0xb002: break;
        case 0xb010: 
    
          char ch;
                do
                {
                    dsmodel1.read ( (char*)&ch, 1);
                }while (ch != '\0' && !dsmodel1.eof ());
    
          dsmodel1.ignore (4);
          dsmodel1.read ( (char*)&father_id [Obj], 2); // айди родительского объекта в иерархии
    
          break;
    
        case 0xb013:
    
          dsmodel1.read ( (char*)&(pivot [Obj].x), 4);   //координаты точки, вокруг которой будет вращаться объект
          dsmodel1.read ( (char*)&(pivot [Obj].y), 4);
          dsmodel1.read ( (char*)&(pivot [Obj].z), 4);
          break;
    
    
        case 0xb020:                                                                             // это поле описывает перенос объекта
          dsmodel1.ignore (10);
          number_of_keys [Obj] = new DWORD;
    
          dsmodel1.read ( (char*)&(number_of_keys [Obj][0]), 4);  //сколько кадров анимации будет у объекта
          key_number [Obj] = new DWORD [number_of_keys [Obj][0]];
          frameTran [Obj] = new D3DXVECTOR3 [number_of_keys [Obj][0]];
    
          how_much_to_ignore = 0;
    
          accel_flags = 0;
          for (i = 0; i < number_of_keys [Obj][0]; i++)
          {
            dsmodel1.read ( (char*)&(key_number [Obj][i]), 4);  
            dsmodel1.read ( (char*)&(accel_flags), 2);              //это флаги сплайнов, в этом примере всегда = 0
    
            if (accel_flags && (1 << 15)) how_much_to_ignore++;
            if (accel_flags && (1 << 14)) how_much_to_ignore++;
            if (accel_flags && (1 << 13)) how_much_to_ignore++;
    //...
     dsmodel1.read ( (char*)&(frameRot [Obj][i].y), 4);    // как я понял он должен быть помещен в точку pivot (она считывалась выше в поле 0хb013)
    //...
    case 0xb030:
          dsmodel1.read ( (char*)&(hierarchy_id [Obj]), 2);            // номер объекта в иерархии, в нашем примере = номеру объекта по порядку считывания

    Полный код:

    http://www.gamedev.ru/code/forum/?id=151570

    CPPGovno, 26 Августа 2011

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

    +158

    1. 1
    2. 2
    3. 3
    typedef int IntHack;
    const intHack operator+(const intHack, const intHack)
    {

    Счастливой отладки. ^_^

    Говногость, 20 Августа 2011

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

    −321

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    typedef double NSTimeInterval;//Убило
    typedef signed char		BOOL; //??????????????
    #define YES             (BOOL)1
    #define NO              (BOOL)0
    typedef char *STR; //????

    Кокоа - рекомендует использовать свои типы вместо стандартных, но то что я нашел в библиотеках - тут писал наверное Кэп!

    Psionic, 18 Августа 2011

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