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

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

    +71

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    try
                    {
                        //PI'я капец??
                        realStream.close();
                    }
                    catch (Throwable t)
                    {
                        throw new IOException(t);
                    }

    Примечание: realStream - это обычный java.io.OutputStream

    konsoletyper, 26 Марта 2012

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

    +158

    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
    public function delete_post($id_op){
            $ret = 'false';
            if((!empty($id_op))){
                    try{
                                        $ret1 = $this->getAdapter()->delete($this->users_posts_table,  'op_id = '.intval($id_op));
                                        $ret2 = $this->getAdapter()->delete($this->offer_posts_table,  'id_op = '.intval($id_op));
                                        if($ret1>0 && $ret2>0){
                                            $ret = 'true';
                                        }
                                        }catch(Exception $e){
                            $this->logger->log('module: deleting in  users_posts, offer_posts tables '.$e->getMessage(), Zend_Log::ERR);
                     }
            }
            else{
                            $ret = 'false';
                            $this->logger->log('function: delete_post : id_op is null', Zend_Log::ERR);
            }
            return $ret;
        }

    Код тим лидера.
    форматирование автора

    Quetzalcoatl, 23 Марта 2012

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

    +153

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $sql_query_result = mysql_query("select * from Organisations
    inner join Goods on (Organisations.ID = Goods.OrgID)
    where 1");
    while($result_string = mysql_fetch_array($sql_query_result)) { array_push ($search_array, $result_string[3]); }
    for($i=0;$i<=count($search_array);$i++)
    {
     if(eregi($search_string, $search_array[$i]))
     {
      array_push($search_matches, $search_array[$i]);
     }
    }

    поиск в интернет магазине:
    13000 записей
    в строке 15 полей
    в каждом строке есть 3 BLOB
    2 с текстом и одно с картинкой товара
    а жаловались что база тормозит

    papavel, 21 Марта 2012

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

    +150

    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
    <?php
    #Подключаем все модули
    include ("$_SERVER[DOCUMENT_ROOT]/engine/engine.php");
    
    //Берём из бд статьи
    $select = mysql_query("SELECT * FROM articles");
    $result = mysql_fetch_array($select);
    $num_rows = mysql_num_rows($select);
    //Берём из бд инфу о сайте
    $select_site = mysql_query("SELECT * FROM site");
    $result_site = mysql_fetch_array($select_site);
    // Переменные с $site
    $ID = $result_site['id'];
    $TITLE = $result_site['title'];
    $keywords = $result_site['keywords'];
    $description = $result_site['description'];
    #Подключаем шаблон
    
     include ("$server/template/main.php"); // Главный файл с title
     include ("$server/template/body.php");  // <body> всё что находится там
     if ($num_rows > 0){
    // В цикле прокручиваем все статьи из БД - $result
    do
    {
    $title = $result['title']; // Заголовок
    $id = $result['id']; // ID
    $full_text = $result['text']; // Весь текст
    $view = $result['view']; // Просмотры у топика
    $author = $result['author']; // Автор
    $date = $result['date']; // Дата добавления
    $short_text = $result['cat']; // Краткий текст (cat)
    $category_art = $result['category']; // Категория топика
    $select_category = mysql_query("SELECT * FROM category WHERE id = '".$category_art."'");
    $result_category = mysql_fetch_array($select_category);
    
    $category = $result_category['title'];
    $url = $result_category['url'];
    
    include ("$server/template/short_news.php"); #Берём (шаб)краткую версию топика
    }
    while ($result = mysql_fetch_array($select));
    
    }
    else 
    {
    echo 'Нет ни одной статьи!';
    }
    include ("$server/template/footer.php");#Наконец подгружаем футер
    
    ?>

    Изобретение говно-велосипеда

    kuler, 19 Марта 2012

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

    +149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    // Категории 
    
    $cat_get = textfilter($_GET['name']);
    $cat1 = mysql_query("SELECT * FROM category WHERE url = '".$cat_get."'");
    $cat2 = mysql_fetch_array($cat1);
    $id_cat = $cat2['id'];
    $result = mysql_query("SELECT * FROM articles WHERE category = '".$id_cat."'");
    $row = mysql_fetch_array($result);
    if ($cat_get) { echo $row['title']; }

    Мне до сих пор страшно, накодил и не понял как и что это, но работает!

    kuler, 19 Марта 2012

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

    +117

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    @if(@Html.Raw(message.Summary).ToString().IndexOf("Добавлен комментарий") >= 0) { 
                                    <a href="@href">
                                        @Html.Raw(@message.Summary)
                                   </a>
                                }

    Arbium, 16 Марта 2012

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

    +142

    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
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    static void Reading_instruction(string Command)
    {
    	string[] CommandLine = null;
    	try
    	{
    		#region Команды консоли.
    		#region -boxmessage выводит сообщение в диалоговом окне.
    				
    		//Пример: -boxmessage:Привет!*/
    				
    		if (Command.ToLower().StartsWith("-boxmessage"))
    		{
    			CommandLine = Command.Split(new char[] {':'});
    			System.Windows.Forms.MessageBox.Show(CommandLine[1]);
    		}
    		#endregion
    		#region -errormessage выводит сообщение c ошибкой в диалоговом окне.
    				
    		//Пример: -errormessage:Вы забанены!!!:Критическая ошибка!
    				
    		if (Command.ToLower().StartsWith("-errormessage"))
    		{
    			CommandLine = Command.Split(new char[] {':'});
    			System.Windows.Forms.MessageBox.Show(CommandLine[1], CommandLine[2], System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.ServiceNotification);
    		}
    		#endregion
    		#region -consolemessage выводит текст в консоль.
    				
    		//Пример: -consolemessage:Привет!
    				
    		if (Command.ToLower().StartsWith("-consolemessage"))
    		{
    			CommandLine = Command.Split(new char[] {':'});
    			Console.WriteLine(CommandLine[1]);
    		}
    		#endregion
    		#region -killprocess убивает процесс.
    				
    		//Пример: -killprocess explorer
    				
    		if (Command.ToLower().StartsWith("-killprocess"))
    		{
    			CommandLine = Command.Split(new char[] {' '});
    			System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName(CommandLine[1]);
    			foreach (System.Diagnostics.Process instance in myProcesses)
    			{
    				instance.Kill();
    			}
    		}
    		#endregion
    		#region -startprocess запускает новый процесс или открывает файл.
    				
    		//Пример: -startprocess explorer.exe
    				
    		if (Command.ToLower().StartsWith("-startprocess"))
    		{
    			CommandLine = Command.Split(new char[] {' '});
    			System.Diagnostics.Process.Start(CommandLine[1]);
    		}
    		#endregion
    		#region -createfile создает файл.
    				
    		//Пример: -createfile С:\TestFile.txt
    				
    		if (Command.ToLower().StartsWith("-createfile"))
    		{
    			CommandLine = Command.Split(new char[] {' '});
    			System.IO.File.Create(CommandLine[1]);
    		}
    		#endregion
    		#region -deletefile удаляет файл.
    				
    		//Пример: -deletefile С:\TestFile.txt
    				
    		if (Command.ToLower().StartsWith("-deletefile"))
    		{
    			CommandLine = Command.Split(new char[] {' '});
    			System.IO.File.Delete(CommandLine[1]);
    		}
    		#endregion
    		#region -shutdown выключает компьютер.
    				
    		//Пример: -shutdown
    				
    		if (Command.ToLower().StartsWith("-shutdown"))
    		System.Diagnostics.Process.Start("shutdown", "/s /t 0");
    		#endregion
    		#region -reboot перезагружает компьютер.
    				
    		//Пример: -reboot
    				
    		if (Command.ToLower().StartsWith("-reboot"))
    			System.Diagnostics.Process.Start("shutdown", "/r /t 0");
    		#endregion

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

    KusokGovna, 16 Марта 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    class store_mod_multi_ftp extends store_mod_ftp {
        public function __construct($options) {
            //...
        }
        protected function connect($url, $login) {
            parent::__construct($url, $login);
        }
        //...
    }

    ФТП-мод, который умеет стягивать файлы с разных серверов сразу, в отличие от своего родителя. И ведь работает, зараза!

    Lowezar, 14 Марта 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $phone = str_replace("с",",",$phone);
    $phone = str_replace("до","",$phone);
    $phone = str_replace("д",",",$phone);
    $phone = str_replace("раб","",$phone);
    $phone = str_replace("м.","",$phone);
    $phone = str_replace("т","",$phone);
    $phone = str_replace("и",",",$phone);

    Silverthorne, 14 Марта 2012

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

    −144

    1. 1
    СуммаРЗ = СуммаРЗ;

    Капитан, это вы?

    mrbus, 14 Марта 2012

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