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

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

    +157

    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
    MYCString  myexport
    operator+(const MYCString& s, const char* pstr)
    {
      return MYCString(s, pstr);	// Use the special concatenation constructor
    }            
    
    MYCString myexport
    operator+(const char* c, const MYCString& s)
    {
      return MYCString(c) + s.data();
    }
    
    MYCString  myexport
    operator+(const MYCString& a, const MYCString& s)
    {
      return a + s.data();
    }

    Название класса изменено. Он встречается в одном большом проекте в библиотеке-заменителе STL )

    DarthBobr, 02 Июля 2010

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

    +166

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function Check_email(mail1)
        {
            var found = false;
          for (i=0;i<mail1.length;i++)
          {
            if (mail1.charAt(i) == '@') found = true;
            if (mail1.charAt(i) == '.' && found) return true;
          }
          return false;
        }

    ух щи-

    wiz, 01 Июля 2010

    Комментарии (24)
  4. PHP / Говнокод #3522

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $_GET = array_merge($_GET, $_POST);
    	if($_GET['kalba']) {
    		$kalba=$_GET['kalba'];
    		if($_GET[admin]) echo "".$connect[1]."_".$connect[2]."_".$connect[3]."";
    	} else $kalba="LT";
    
    		if($_SESSION['kalba']="") {
    			session_start(); 
    			$_SESSION['kalba'] = $kalba;
    		} else $_SESSION['kalba'] = $kalba;

    вот кусок из сайта, как писал в http://govnokod.ru/3511#comment33961
    исходное форматирование сохранено

    продолжение причем еще следует

    зы: "kalba" переводится как "язык"

    Lure Of Chaos, 21 Июня 2010

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

    +152

    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
    private function http_post($url, $post_string) {
            
            // add any additional curl options here
            $options = array(CURLOPT_URL => $url,
                             CURLOPT_POST => true,
                             CURLOPT_POSTFIELDS => $post_string,
                             CURLOPT_USERAGENT => "PubSubHubbub-Publisher-PHP/1.0");
            
            $ch = curl_init();
            curl_setopt_array($ch, $options);
                
            $response = curl_exec($ch);
            $this->last_response = $response;
            $info = curl_getinfo($ch);
        
            curl_close($ch);
            
            // all good
            if ($info['http_code'] == 204) 
                return true;
            
            return false;   
        }

    http_post ):

    wiz, 17 Июня 2010

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function nameFilter(str){
    
    		var re = /^(oxypit|Штемп|хуй|пиде|пидр|пидо|пида|гыы|Techn|PIZDA)/i
    		if (re.test(str)) return true; else return false;
    
    }

    hromjo, 12 Июня 2010

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

    +164

    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
    /**
     * Constructs a URL encoded query string from an array of key/value pairs
     *
     * @access protected
     * @since 2.0
     * @param array $array query string key/value pairs
     * @return string
     */
    protected function _glue( $array )
    {
        $query_string = '';
        foreach( $array as $key => $val ) :
            $query_string .= $key . '=' . rawurlencode( $val ) . '&';
        endforeach;
        
        return '?' . substr( $query_string, 0, strlen( $query_string )-1 );
    }

    http://code.google.com/p/php-twitter/
    опять велосипеды

    striker, 25 Мая 2010

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

    +153

    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
    switch(num_q)
    			{
    				case 0: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q] = true; break;
    				case 1:	if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q]= true ; break;
    				case 2: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q] = true; break;
    				case 3: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q]= true; break;
    				case 4: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q]= true; break;
    				case 5: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q]= true; break;
    				case 6: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q]= true; break;
    				case 7: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q]= true; break;
    				case 8: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q]= true; break;
    				case 9: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q] = true; break;
    				case 10: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q] = true; break;
    				case 11: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q] = true; break;
    				case 12: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q] = true; break;
    				case 13: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q] = true; break;
    				case 14: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q]= true; break;
    				case 15: if(Terminated)MForm->term[num_q] = true;
    						else MForm->pausa[num_q] = true; break;
    			}

    ночью надо спать...

    o_jumi, 23 Мая 2010

    Комментарии (24)
  9. VisualBasic / Говнокод #3177

    −359

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Private Function Leto(ByVal Dat1 As Date) As Boolean
    Return IIf(Dat1.Month > 3 And Dat1.Month < 9, True, False)
    End Function
    
    Private Function Bas(ByVal Cost1 As Decimal, ByVal Kol1 As Integer)
    Return Cost1 * Kol1
    End Function

    вообще это по линку cfdevа лежало в #3142
    http://www.sql.ru/forum/actualthread.aspx?bid=9&tid=467673&hl=

    но он не запостил самое гавно - то есть этот кусок
    и его походу мало кто заметил

    3.14159265, 07 Мая 2010

    Комментарии (24)
  10. JavaScript / Говнокод #3120

    +171

    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
    function showResults()
    {var i=0;if(document.getElementById('choice12').checked==true)
    {i++;}
    if(document.getElementById('choice23').checked==true)
    {i++;}
    if((document.getElementById('choice31').checked==true)&&(document.getElementById('choice32').checked==false)&&(document.getElementById('choice33').checked==true)&&(document.getElementById('choice34').checked==false))
    {i++;}
    if((document.getElementById('choice41').checked==false)&&(document.getElementById('choice42').checked==true)&&(document.getElementById('choice43').checked==true)&&(document.getElementById('choice44').checked==false))
    {i++;}
    if(document.getElementById('text5').value=='type')
    {i++;}
    if(document.getElementById('choice62').checked==true)
    {i++;}
    if(document.getElementById('text7').value=='alt')
    {i++;}
    if((document.getElementById('choice81').checked==false)&&(document.getElementById('choice82').checked==true)&&(document.getElementById('choice83').checked==false)&&(document.getElementById('choice84').checked==true))
    {i++;}
    if(document.getElementById('text9').value=='target')
    {i++;}
    if((document.getElementById('choice101').checked==true)&&(document.getElementById('choice102').checked==false)&&(document.getElementById('choice103').checked==false)&&(document.getElementById('choice104').checked==true))
    {i++;}
    if(document.getElementById('text11').value=='<input>')
    {i++;}
    if(document.getElementById('choice123').checked==true)
    {i++;}
    if((document.getElementById('choice131').checked==false)&&(document.getElementById('choice132').checked==true)&&(document.getElementById('choice133').checked==false)&&(document.getElementById('choice134').checked==true))
    {i++;}
    if(document.getElementById('text14').value=='action')
    {i++;}
    if((document.getElementById('choice151').checked==false)&&(document.getElementById('choice152').checked==true)&&(document.getElementById('choice153').checked==true)&&(document.getElementById('choice154').checked==true))
    {i++;}
    if((document.getElementById('choice161').checked==false)&&(document.getElementById('choice162').checked==false)&&(document.getElementById('choice163').checked==true)&&(document.getElementById('choice164').checked==true))
    {i++;}
    if(document.getElementById('choice174').checked==true)
    {i++;}
    if(document.getElementById('choice182').checked==true)
    {i++;}
    if(document.getElementById('text19').value=='background')
    {i++;}
    if(document.getElementById('choice201').checked==true)
    {i++;}
    document.getElementById('questions').style.display='none';document.getElementById('results').style.display='block';document.getElementById('results').innerHTML='<h2 style="color: #377">Результаты теста</h2>\n<p>Количество правильных ответов: <strong>'+i+'</strong>.</p>';if(i>=18)
    {document.getElementById('results').innerHTML+='<p style="color: #096">Поздравляем с отличным результатом!</p>\n<p style="color: #f00">Оценка 5</p>';}
    if((i<18)&&(i>=14))
    {document.getElementById('results').innerHTML+='<p style="color: #096">Поздравляем с хорошим результатом!</p>\n<p style="color: #f00">Оценка 4</p>';}
    if((i<14)&&(i>=6))
    {document.getElementById('results').innerHTML+='<p style="color: #096">Результат удовлетворительный!</p>\n<p style="color: #f00">Оценка 3</p>';}
    if(i<=6)
    {document.getElementById('results').innerHTML+='<p style="color: #c00">К сожалению, результат очень плохой!!!</p>\n<p style="color: #f00">Оценка 2</p>';}
    document.getElementById('results').innerHTML+='<p class="buttons"> <input type="button" value="Подсказать ответы" onclick= "showQuestions();getHelp();" /></p>';}

    Тест на знание html. Мало того, что говнокод, так там и ответы ещё неправильные. Источник — http://www.cssblok.ru/test/test1.html

    P.S. копирайт снизу на том сайте ("Школьная веб-студия , 2007") всё оправдывает.

    Infamous, 27 Апреля 2010

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

    +924

    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
    // придерживаюсь оригинала как могу
    // код как был:
    
    static char message_buf[64000];  // must be actually 64K == 64<<10 == 65536
    
    class MessageHandler {
       // [...]
       char *header;         // point into the message_buf
       char *content;
       std::list<char *> tlvs; // pointers to the elements of the message
    };
    
    // я пожаловался - пообещали исправить в новой версии по ходу реализации новой фичи.
    
    // новый "усовершенствованый" код, с "поддержкой" многопоточности.
    
    static char message_buf[100][65000];  // 100 == max threads, buffer size now is much closer to the standard
    
    class MessageHandler {
       // [...]
       int threadId;             // index into the new message_buf[]
       char *header;          // point into the message_buf[threadId]
       char *content;
       std::vector<char *> tlvs; // same, but in std::vector because it is "faster"
    };

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

    Dummy00001, 26 Апреля 2010

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