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

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

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    switch($op){
            case 'main': IndexNewszMain();
                    break;
    // ......
            case 'savepost':
                    if(CommentsEditPostSave(SafeEnv($_GET['newsz'], 11, int), 'newsz_comments')){
                            break;
                    }
    // .....
            // //
            default: IndexNewszMain();
    }

    Роутинг из модуля одной русской CMS

    Мартин, 24 Июля 2015

    Комментарии (7)
  3. Куча / Говнокод #18522

    +141

    1. 1
    https://www.youtube.com/watch?v=pphRRTK7KsY

    Я не смог пройти мимо этого. Это прекрасно.

    Vasiliy, 24 Июля 2015

    Комментарии (4)
  4. JavaScript / Говнокод #18503

    +141

    1. 1
    $('.basket-table').closest('body').find('.basket');

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

    blablabla2, 21 Июля 2015

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

    +141

    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
    private void FontsComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        ExampleTextBox.FontFamily = ((FontFamilyItem)FontsComboBox.SelectedItem).FontFamily;
    
        //combobox values disappears after selected
        //TODO: OPTIMIZE
        FontsComboBox.SelectionChanged -= FontsComboBoxSelectionChanged;
        int iSelIndex = FontsComboBox.SelectedIndex;
        FontsComboBox.Items.Clear();
        foreach (var item in _aFonts)
            FontsComboBox.Items.Add(item);
        FontsComboBox.SelectedIndex = iSelIndex;
        FontsComboBox.SelectionChanged += FontsComboBoxSelectionChanged;
    }

    Значения из списка ComboBox'а исчезают после выбора их.
    Решил проблему костылем говнокодом. Правда теперь стало чуть-чуть тормозить. Но на это можно забить.

    Janycz, 18 Июля 2015

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

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    /* Костылек START */
    // Ибо всё тлен
    function m_r_e_s(&$arr){
    	foreach($arr as $k=>$v){
    		if(is_array($v)) m_r_e_s($v);
    		else $arr[$k]=mysql_real_escape_string($v);
    	}
    }
    m_r_e_s($_GET);
    m_r_e_s($_POST);
    /* Костылек END */

    VokaMut, 13 Июля 2015

    Комментарии (3)
  7. C# / Говнокод #18467

    +141

    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
    private string Time
            {
                get
                {
                    DateTime d;
                    d = DateTime.Now;
    
                    string t;
    
                    // Get the Date
                    if (d.Month.ToString().Trim().Length == 1)
                    {
                        t = "0" + d.Month.ToString().Trim() + "/";
                    }
                    else
                    {
                        t = d.Month.ToString().Trim() + "/";
                    }
                    if (d.Day.ToString().Trim().Length == 1)
                    {
                        t += "0" + d.Day.ToString().Trim() + "/";
                    }
                    else
                    {
                        t += d.Day.ToString().Trim() + "/";
                    }
                    t += d.Year.ToString().Trim() + " ";
    
                    // Get the time
                    if (d.Hour.ToString().Trim().Length == 1)
                    {
                        t += "0" + d.Hour.ToString().Trim() + ":";
                    }
                    else
                    {
                        t += d.Hour.ToString().Trim() + ":";
                    }
                    if (d.Minute.ToString().Trim().Length == 1)
                    {
                        t += "0" + d.Minute.ToString().Trim() + ":";
                    }
                    else
                    {
                        t += d.Minute.ToString().Trim() + ":";
                    }
                    if (d.Second.ToString().Trim().Length == 1)
                    {
                        t += "0" + d.Second.ToString().Trim() + ".";
                    }
                    else
                    {
                        t += d.Second.ToString().Trim() + ".";
                    }
                    if (d.Millisecond.ToString().Trim().Length == 1)
                    {
                        t += "00" + d.Millisecond.ToString().Trim() + ".";
                    }
                    else if (d.Millisecond.ToString().Trim().Length == 2)
                    {
                        t += "0" + d.Millisecond.ToString().Trim() + ".";
                    }
                    else
                    {
                        t += d.Millisecond.ToString().Trim() + ".";
                    }
    
                    return t;
                }
            }

    Классическая вариация на тему DateTime, чтобы получить 07/10/2015 18:45:03.647.

    adoconnection, 10 Июля 2015

    Комментарии (0)
  8. Куча / Говнокод #18464

    +141

    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
    <div class="zz">
          <p2><span class="yy"><img src="pic.png" alt="..." name="..." class="yx" id="..."></span></2p>
          <div class="xx">
            <p2>1.<strong><a href="link1.html" title="..."> <span class="x">...</span></a><span class="x">.</span></strong>...</p2>
            <p>
            <p2>2. <strong class="x"><a href="link2.html" title="...">...</a></strong>...</p2>
            <p>
            <p2>3. <a href="link3.html" title=" ..." class="x"><strong>...</strong></a>, ...</p2>
            <p>
            <p2>4.<a href="link4.html" title="..." class="x"><strong>...</strong></a>. ...</p2>
            <p>
            <p2>5. <strong class="x"><a href="link5.html" title="..."><strong>...</strong></a></strong> ... </p2>
          </div>
    </div>

    html гуру

    username255, 10 Июля 2015

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

    +141

    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
    <?
    /*
    =====================================================================================================================================================
    
    	DB COOPERATION
    	Developer:	Yudin Roman
    	Description:
    	Cooperation with databases.
    	
    	ВЗАИМОДЕЙСТВИЕ С БД
    	Разработка:	Юдин Роман
    	Описание:
    	Взаимодействие с базами данных.
    	
    =====================================================================================================================================================
    */
    
    class database
    {
        function connect()
        {
            global $config;
            $this->db = mysql_connect($config['db']['host'], $config['db']['user'], $config['db']['pass'])
            or die("база данных не доступна: " . mysql_error());
            mysql_query("SET character_set_results=utf8", $this->db);
            mysql_query("SET character_set_client=utf8", $this->db);
            mysql_query("SET character_set_connection=utf8", $this->db);
            mb_language('uni');
            mb_internal_encoding('UTF-8');
            mysql_select_db($config['db']['database'], $this->db);
            mysql_query("set names 'utf8'",$this->db);
        }
    
        function query($sql)
        {
            //$result = mysql_query($sql);
            //$this->result=$result;
            return mysql_query($sql);
        }
    
        function num_rows($res)
        {
            return @mysql_num_rows($res);
        }
    
        function fetch($res)
        {
            return @mysql_fetch_array($res, MYSQL_ASSOC);
        }
    
        function insert_id()
        {
            return @mysql_insert_id($this->db);
        }
    }
    
    
    if (!isset($_SESSION)) session_start();

    2015 год, есть PDO, есть фреймворки, есть компоненты и классы, но нет, этот идёт другим путём. И самое приятное - $_SESSION в файле класса.

    damir, 09 Июля 2015

    Комментарии (1)
  10. Си / Говнокод #18435

    +141

    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
    void perestanovka(int a[13][13], int n, int m){
    	 int maxim, minim, temp,i;
    	
    	 for (i=0; i<n; i++){
             minim=0;
    	 	 for (int j=1; j<m; j++){
     	  	if(a[i][j]<a[i][minim]) minim=j;
       	  }
    	 temp=a[i][0];
         a[i][0]=a[i][minim];
         a[i][minim]=temp;}
    			 
     	  for (int j=0; i<n; i++){
    	  	  maxim=0;
    	 	 for (int j=1; j<m; j++){
    		 	 if(a[i][j]>a[i][maxim]) maxim=j;
    		 }
    		 temp=a[i][m-1];
             a[i][m-1]=a[i][maxim];
    	     a[i][maxim]=temp; }
     }

    lanior, 04 Июля 2015

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    foo() ->
        Du =  os:cmd("du -b "++?PM_LOGS_PATH),
        [DiscSize|_] = string:tokens(Du, "\t"),
        case list_to_integer(DiscSize) > 10000000000 of
          ...

    Вся мощь эрланга. В строке может быть не только число? Let it crash!

    lesmugfrog, 01 Июля 2015

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