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

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

    +162

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    # Если ошибка при авторизации
    begin_page("Вход");
    
    echo("<font color='red'>Ошибка при наборе логина или пароля</font>\n");
    
    }
    
    # Форма авторизации
    if (!headers_sent())
    begin_page("Вход");

    Поручили мне отрефакторить систему "Компьютерный класс" и баги в ней пофиксить.
    В login.php сразу же гениальнейшая конструкция.

    7ion, 23 Сентября 2011

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

    +163

    1. 1
    2. 2
    3. 3
    if (is_null($var) === false) {
    // не важно что
    }

    Встретил такой код в примерах одного Merchant-сервиса.
    Вот что значит простое сделать сложным.

    darth_ixis, 21 Сентября 2011

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

    +124

    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
    public object Data 
                {
                    get
                    {
                        return this._data;
                    }
                    set
                    {
                        (((value is byte ||
                           value is short ||
                           value is ushort ||
                           value is int ||
                           value is uint ||
                           value is long ||
                           value is ulong ||
                           value is decimal ||
                           value is double ||
                           value is float) && (DataType == JsonNodeDataType.Number)) ||
                         ((value is string) && (DataType == JsonNodeDataType.String)) ||
                         ((value is object[]) && (DataType == JsonNodeDataType.Array)) ||
                         ((value is Json) && (DataType == JsonNodeDataType.SubObject)) ||
                         ((value is bool) && (DataType == JsonNodeDataType.Boolean))).Assert();
                        this._data = value;
                    }
                }

    Изобретаю велосипед для работы с Json

    psina-from-ua, 20 Сентября 2011

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

    +170

    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
    function timeProceed() {
    	second++;
    	if (second >= 60) {
    		minute++;
    		second = 0;
    	}
    	if (minute >= 60) {
    		hour++;
    		minute = 0;
    	}
    	if (hour > 23)
    	{
    		hour = 0;
    		minute = 0;
    		second = 0;
    	}
    
    	var cHour = hour;
    	var cMinute = minute;
    	var cSecond = second;
    	var cStyleVis  = "visible";
    	// Т.к. переменные целочисленные, то в них может содержаться только по одной цифре, будет выглядеть не очень красиво (типа 1:5:3, а надо 01:05:03), проверим это.
    	// Не C++ и преобразование типов нам не нужно
    	if (second < 10) cSecond = "0" + second;
    	if (minute < 10) cMinute = "0" + minute;
    	if (hour < 10) 	 cHour 	 = "0" + hour;
    	
    	// Итоговое время
    	//time = cHour + ":" + cMinute + ":" + cSecond;
    	if(dotsShow == 1){
       		cStyleVis = "visible";
       		dotsShow  = 0;
    	}
    	else{
    		cStyleVis = "hidden";
    		dotsShow  = 1;
    	}
    	time = '<b>' + cHour + '</b> <b class="dots" style="visibility:' + cStyleVis + ';">:</b> <b>' + cMinute + '</b>';
    	//alert(time);
    	// Кроосбраузерность уже самостоятельно прописываем
    	document.getElementById('clock').innerHTML = time;
    	timeChanged = 1;
    	return true;
    }

    Борьба со временем

    dens, 16 Сентября 2011

    Комментарии (11)
  6. 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)
  7. 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)
  8. 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)
  9. 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)
  10. 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)
  11. 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)