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

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

    +150.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $result_row = $db->query("SELECT DISTINCT good_vars.coef_value, good_vars.coef_type ... ");
    $row = $db->fetch_array($result_row);
    $coef_type = $row['coef_type'];
    $coef_value = $row['coef_value'];
    $array = explode(',', ($coef_type.','.$coef_value));
     
    $result = 0;
    if ($array[0] == 2) {
    	$result = $price * $array[1] / 100;
    } elseif ($array[0] == 3) {
    	$result = $array[1];
    }

    ох уж эти студенты...

    wasa, 08 Декабря 2009

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

    +158.2

    1. 1
    2. 2
    3. 3
    if(empty($_SESSION['login'])) {
        die("<script>top.location.href='index.php';</script>");
    }

    dicos, 03 Декабря 2009

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

    +71.7

    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
    //это метод
    public Integer getNoDeletedSubscribers() {
            Integer count = 0;
            for (int i = 0, n = subscribers.size(); i < n; count += (!subscribers.get(i++).isDeleted() ? 1 : 0));
            return count;
        }
    
    //а вот  пример использования этого  метода в коде))
    private void actionValidateInput() {
            saveTaskBtn.setEnabled(!(((taskName.getText().equals("") ||
                                     subscriberBox.getSelectedItem()==null ||
                                     f51Box.getSelectedItem()==null || getTask().getNoDeletedSubscribers()==0  ) && getTask().getTaskType()==TaskType.SEND_MAIL) ||
                                     ((taskName.getText().equals("") && getTask().getTaskType()==TaskType.RECIVE_MAIL))));
        }

    кусочек мазгоразрывающей логики

    nicolas.patsevich, 01 Декабря 2009

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

    +159.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
    <?php
    //#main.php
    //Инициализация скрипта
    ....      
              $a=10;
              $setadmin=0;
              $Check=_GET['admincheck']/0; //Dark, !!не трогай!!, !!оно работает!!
              if ($Check==0) {
                  ban_usr($a,$cu_ipad);
                  die('You are not administrator:banned for ten minutes...');
              }else{
                   getusrrg($setadmin,$cu);
                   set_access($setadmin,$cu_ipadб,$cu,$c_time);               
               }      
    ....

    скрипт был написан моим другом пол года назад
    похоже тогда он знал что я в него залезу

    darksvesh, 29 Ноября 2009

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

    +156.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    #topBlock
    <script language="JavaScript">
    function process(){}
    today = new Date()
    if((today.getHours() < 12) && (today.getHours() >= 6)) {background:url('http://site/1.png') top center no-repeat;height:243px;}
    if((today.getHours() >= 12) && (today.getHours() < 18)) {background:url('http://site/2.png') top center no-repeat;height:243px;}
    if((today.getHours() >= 18) && (today.getHours() <= 23)) {background:url('http://site/3.png') top center no-repeat;height:243px;}
    if((today.getHours() >= 0) && (today.getHours() < 6)) {background:url('http://site/4.png') top center no-repeat;height:243px;}
    </script>
    #tobTable.... ну и дальше неважно

    Отчаянная попытка сделать логотип, сменяющий цвет в зависимости от времени суток =) Как выяснилос, поциент вставлял это в CSS. http://helper.ucoz.ru/forum/20-6633

    fuckyounoob, 25 Ноября 2009

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

    +160.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <?php 
    // ...
    $vars = get_class_vars($class_name);
    		if(is_array($vars)) {
    			foreach($vars as $var => $val) {
    				eval('$this->' . $var . ' = \'' . $val . '\';');
    			}
    		}

    некакая UNI-CMS
    это не самое худшее. что я там нашел ... в общем мрак... (

    nicolay-punin, 22 Ноября 2009

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

    +98.6

    1. 1
    private bool IsNamesAreEqual(string itemName, string nodeName) { ... }

    Правда это скорее относится к английскому языку, нежели к шарпу.
    Иногда полезно перечитывать давно написаный код, много нового узнаешь )))

    plsc_rover, 20 Ноября 2009

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

    −864.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    select to_char(null) from dual  
    union
    select to_number(null) from dual
    
    ORA-01790:	expression must have same datatype as corresponding expression

    Когда смотришь на пустую чашку, то можно сказать, что в ней нет, например, чая или ,например, нет кофе. Но нельзя сказать, что в нет ни чая ни кофе.

    dim1r, 16 Ноября 2009

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

    +164.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    while ($rst=mysql_fetch_array($rst_query))
    {
        $clist.="," . $rst["es_id"];
        $thislist="-1," . $rst["es_id"];
        while ($rst=mysql_fetch_array($rst_query))
        {
            $clist.="," . $rst["es_id"];
            $thislist.="," . $rst["es_id"];
        }
        $rst_query=mysql_query("Select * from esb2b_categories where es_pid in (" . $thislist . ")" );
    }

    разрыв мозга
    made by какой-то индус

    primpil, 16 Ноября 2009

    Комментарии (11)
  11. Си / Говнокод #2135

    +136.8

    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
    ...
    
    // TODO: remove this godless "switch()"!
                    switch(tuntype) { // TODO: Important: do as in documentation instead of reverse-ingeniering!
    #define PACKET_TRY {\
                    if(packet->ip_v == 4) {\
                            hl=packet->ip_hl<<2;\
                            if(hl>=sizeof(*packet))\
                                    break;\
                            /* TODO: Check in RFC something about of ICMP send-back in this case */\
                            fprintf(stderr, "Got too short IP-header (%i)...\n",hl);\
                    }\
                    if((packet->ip_v&IPV6_VERSION_MASK) == IPV6_VERSION) {\
                            break;\
                    }\
    }
    #define NEXT(a) tuntype=a;\
                    if(tuntry>=2)\
                            goto tun_process_switch_end;\
                    tuntry++;
    #define CASE(a) NEXT(a);\
            case a
    tun_process_switch:
    //              switch(tuntype) {
                            case TUNTYPE_NORM:              // NetBSD-like?
                                    packet=(typeof(packet))ptr;
                                    PACKET_TRY;
                            CASE(TUNTYPE_EXT):              // FreeBSD-like?
                                    packet=(typeof(packet))((char *)ptr + 4);
                                    if(s>4)
                                            if(*ptr==0x02)
                                                    PACKET_TRY;
                            CASE(TUNTYPE_ETH):              // Ethernet? TODO: Implement VLAN-tagging
                                    packet=(typeof(packet))((char *)ptr + sizeof(*eth));
                                    eth=(typeof(eth))ptr;
                                    if(!teth) {
                                            teth=alloca(sizeof(*teth));
                                            memcpy(&teth->ether_shost, &eth->ether_dhost, sizeof(teth->ether_shost));
                                            memcpy(&teth->ether_dhost, &eth->ether_shost, sizeof(teth->ether_dhost));
                                            teth->ether_type=ETHERTYPE_IP;
                                    }
                                    if(s>sizeof(*eth))
    //                                      if((*(char *)&eth->ether_type==0x08/* not IPv4? */)||(*(char *)&eth->ether_type==0x86/* not IPv6? */))  // TODO: Implement compatibility with all protocols over ethernet
                                                    PACKET_TRY;
                                    NEXT(TUNTYPE_NORM);
                                    goto tun_process_switch;
                            
                            default:                        
                                    tuntype=TUNTYPE_NORM;
                                    goto tun_process_switch;
    //              }
    tun_process_switch_end:
    #undef CASE
    #undef NEXT
    #undef PACKET_TRY
                                    if(tuntry<~0)
                                            tuntry=0;
                                    tuntype=oldtuntype;
                                    fprintf(stderr, "Got unknown packet. Flushing...\n");
                                    FLUSH;  // Flush all. We don't know the length of packet with unknown type.. So, we have to flush the buffer, to probably get new packets from the start.
                                    goto tun_process_while;
                    }
    
    ...

    "Ляпотааааа"... Очень "структурный" switch...

    xaionaro, 11 Ноября 2009

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