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

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

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $query = " SELECT * FROM `costs` WHERE NID = ".$id;
    $res = mysql_query($query);
    $result = "var gggg = new Array(";
    while($row = mysql_fetch_row($res)) {
      $result = $result. "Array(".$row[0].",".$row[2].",".$row[3].",".$row[4].",".$row[5].",".$row[6].",'".$row[7]."'),";
    }
    echo $result;

    И так везде — все возвращаемые аяксом JS-массивы имеют название gggg, которое полностью соответствует тематике ресурса.

    guest, 17 Марта 2009

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

    +145

    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
    <?php
    require_once('global.php');
    
    $id = $_GET['id'];
    if( !$lore_system->db->id_exists( $id, 'lore_articles') )
    {
    	$lore_system->te->assign('error_message', 'invalid_article');
    	$lore_system->te->display('error_message.tpl');
    	exit;
    }
    if( !$lore_db_interface->article_is_published( $id ) )
    {
    	$lore_system->te->assign('error_message', 'article_not_published');
    	$lore_system->te->display('error_message.tpl');
    	exit;
    }
    
    $action = ( isset( $_REQUEST['action'] ) ) ? $_REQUEST['action'] : 'article';
    switch( $action )
    {
    	case 'print':
    		$article = $lore_db_interface->get_article_info( $id );
    		$article['comments'] = $lore_db_interface->get_article_comments( $id );
    		
    		$lore_system->te->assign('category_path', $lore_db_interface->get_category_path( $article['category_id'] ));
    		$lore_system->te->assign('article', $article);
    		$lore_system->te->display('article_print.tpl');
    	break;
    		
    	case 'article':
    		if( !@in_array( $id, $lore_user_session->session_vars['viewed_articles'] ) )
    		{
    			$lore_db_interface->increment_article_views( $id );
    			$lore_user_session->session_vars['viewed_articles'][] = $id;
    		}
    		
    		$article			= $lore_db_interface->get_article_info( $id );
    		$article['comments']		= $lore_db_interface->get_article_comments( $id );
    		$article['num_comments']	= count($article['comments']);
    		$article['attachments']		= $lore_db_interface->get_article_attachments( $id );
    		$article['allow_comments']	= $lore_db_interface->can_comment_on_article( $id );
    		$article['related_articles']	= $lore_db_interface->get_related_articles( $id );
    
    		if( $lore_user_session->has_article_write_permission( $id ) )
    		{
    			$article['display_edit_link'] = true;
    		}
    
    		if( $lore_system->settings['enable_glossary_popups'] )
    		{
    			$glossary_terms = $lore_db_interface->get_glossary_terms();
    			if( count($glossary_terms) )
    			{
    				$term_html = array();
    				$html_tags = array();
    				$term_c = 0;
    
    				// strip out HTML tags first
    				@preg_match_all("/<[^>]+>/", $article['content'], $matches);
    				for( $i = 1; $i < count($matches[0]); $i++ )
    				{
    					// save html tag for later
    					$html_tags[$i] = $matches[0][$i];
    					
    					// parse in placeholder
    					$article['content'] = str_replace( $matches[0][$i], "{{h$i}}", $article['content']);
    				}
    					
    				foreach( $glossary_terms AS $term )
    				{
    					// Add "i" (NOT case sensitive) modifier to regular expression if necessary
    					$case = ( $term['case_sensitive'] ) ? '' : 'i';
    					
    					$term['definition'] = ereg_replace("[\n\r]", '', $term['definition']);
    					
    					$lore_system->te->assign('term', htmlspecialchars(str_replace("'", "\\'", $term['term'])) );

    guest, 05 Марта 2009

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

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function update_order($d)
    {
        /* 
         * [...] Всё погрызли злобные снусмумрики
         */
    
        return $true;
    }
    Ъ

    guest, 20 Февраля 2009

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

    +145

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    <?
    
    $mytext = iconv('windows-1251', 'utf-8', $mytext);
    echo $mytext;
    
    //There is a little problem with iconv in such using
    //This code isn't work correctly. Solution is:
    
    $mytext = iconv('windows-1251', 'utf-8', $mytext);
    echo $mytext;
    
    ?>

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

    guest, 13 Февраля 2009

    Комментарии (1)
  6. Java / Говнокод #525

    +145

    1. 1
    2. 2
    Field maxx, minx, maxy, miny = row.getFields().toArray(new Field[0])[0];
    minx = maxx = maxy = miny;

    Адская комбинация.

    guest, 10 Февраля 2009

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

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function get_comments($ident,$id,$type,$feedback=false){
    	...
    	$tree_id = $id*10+$type;
            ...
    	$TL = TreeLoad(0,$tree_id,-1,$ident,$feedback);

    Стыдно

    guest, 26 Января 2009

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

    +144.9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    // Руководство по созданию плагинов к асечке qutIM
    QWidget *simplePlugin::settingsWidget()
    {
        QWidget* form = new QWidget;
        return form;
    }

    Программирование на Qt, Java-style.
    Горбатый дворник, где же ты? :)

    Пруфлинк: http://www.qutim.org/forum/viewtopic.php?f=55&t=720

    Orfest, 04 Марта 2010

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

    +144.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
    bool userNameChanged = true;
    bool passwordChanged = true;
    
    if(userNameChanged)
    {
    	// какие-то операции
    }
    
    if(passwordChanged)
    
    {
    	// ещё какие-то операции
    }

    Вот ещё один код от нашего шефа-индуса...

    Highlander, 27 Февраля 2010

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

    +144.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
    class SmoothingModeManager
    {
    public:
    	SmoothingModeManager(Context* context, Gdiplus::SmoothingMode mode = Gdiplus::SmoothingModeHighQuality);
    	virtual ~SmoothingModeManager();
    	
    protected:
    	Context* context_;		
    };
    
    ////////////////////////
    
    SmoothingModeManager::SmoothingModeManager(Context* context, Gdiplus::SmoothingMode mode)
    : context_(context)
    {
    	context_->getCanvas()->SetSmoothingMode(mode);
    }
    
    
    SmoothingModeManager::~SmoothingModeManager()
    {
    	context_->getCanvas()->SetSmoothingMode(Gdiplus::SmoothingModeNone);
    }

    Инициализируем класс и контекст со сглаживанием до конца метода.

    Altravert, 26 Февраля 2010

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

    +144.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
    public class YobaButton : Button
    {
        public YobaButton ()
        {
            this.Click += (s1, e1) =>
            {
                MessageBox.Show ("Оп хуй.");
     
                this.Click -= (EventHandler)Delegate.CreateDelegate (typeof (EventHandler), this, (MethodInfo)MethodBase.GetCurrentMethod ());
     
                this.Click += (s2, e2) =>
                {
                    MessageBox.Show ("Оп тупой хуй.");
                };
            };
        }
    }

    Yurik, 30 Января 2010

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