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

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

    +179

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <?php
      $node = node_load($nid);
      $node->coupons += rand(1, 100);
      print 'К акции было добавлено ' . rand(1, 100) . ' купонов';
    ?>

    Добавление количества купонов к акции и вывод сообщения о количестве добавленых купонов. Ну что тут скажешь.. =)

    spleshka, 10 Марта 2012

    Комментарии (12)
  3. Java / Говнокод #9588

    +67

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public static boolean areEquals(Object [] ... paires){
            for(Object [] paire : paires){
                if(paire[0] == null || !paire[0].equals(paire[1])){
                    return false;
                }
            }
            return true;
        }

    Целый день убил из-за этого говна

    roman-kashitsyn, 02 Марта 2012

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

    −133

    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
    Функция ПроверкаНогИВанны()
    	Строка = ТаблицаНоменклатуры.Найти(Справочники.Номенклатура.НайтиПоКоду("50641     "), "Номенклатура");
    	Если Строка = Неопределено Тогда
    		Возврат Ложь;
    	Иначе 
    		СтрокаВанна = ТаблицаНоменклатуры.Найти(Справочники.Номенклатура.НайтиПоКоду("50624     "), "Номенклатура");
    		Если СтрокаВанна = Неопределено Тогда 
    			Возврат Истина
    		Иначе 
    			Возврат Ложь
    		КонецЕсли;
    	КонецЕсли;
    КонецФункции

    glavdir, 02 Марта 2012

    Комментарии (12)
  5. Куча / Говнокод #9562

    +134

    1. 1
    0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /path-to-script

    Замечательный конфиг крона)

    imsamurai, 28 Февраля 2012

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <html>
    <title>NOTICE</title>
    <body>
    <img src="/banner.jpg"/>
    </body>
    </html>

    megaupload.com

    bot, 27 Февраля 2012

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

    +956

    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
    using System;
    
    namespace Угадай_цифру
    {
    class Program
     { 
    struct IntNull
     {
    public static Random Rand = new Random();
    public static int CompInt;
    public static string UserInt;
     }
    
    public static void Main(string[] args)
     {
    try 
     {
     Console.WriteLine("Игра: отгадай число.");
     Console.Write("Правила игры просты, компьютер загадывает цисло от одного до 10, вы должны его отгадать.");
     Console.ReadLine();
     Console.Clear();
     GetInt();
     } 
    catch (Exception ex) 
     {
     Console.WriteLine(ex.Message);
     Console.ReadLine();
     }
     }
    
    public static void GetInt()
     {
    try 
     {
     IntNull.CompInt = IntNull.Rand.Next(0, 10);
     Console.Clear();
     Console.WriteLine("Комптютер загадал число, отгадайте его");
    string User = Console.ReadLine();
     IntNull.UserInt = User;
     Console.Clear();
     GetProverka();
     } 
    catch (Exception ex) 
     {
     Console.WriteLine(ex.Message);
     Console.ReadLine();
     }
     }
    
    public static void GetProverka()
     {
    try 
     {
    if(IntNull.CompInt == Convert.ToInt32(IntNull.UserInt))
     {
     Console.Clear();
     Console.WriteLine("Молодец, правильный ответ {0}", IntNull.CompInt);
     Console.WriteLine("Нажмите Enter для продолжения");
     Console.ReadLine();
     GetInt();
     }
    else
     {
     Console.Clear();
     Console.WriteLine("Лошара, ответ неверный, правильный ответ {0}", IntNull.CompInt);
     Console.WriteLine("Нажмите Enter для продолжения");
     Console.ReadLine();
     GetInt();
     }
     } 
    catch (Exception ex) 
     {
     Console.WriteLine(ex.Message);
     Console.ReadLine();
     }
     } 
     }
    }

    Один программист выложил на малоизвестном сайте

    IIIypuk, 27 Февраля 2012

    Комментарии (12)
  8. JavaScript / Говнокод #9510

    +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
    <script language="JavaScript">
                    <!--
                        document.write('<a href="#top" onclick="takeThis(\'<?php echo $PMA_Theme; ?>\'); return false;">');
                        document.write('<img src="<?php echo $screen_directory; ?>/screen.png" border="1" ');
                        if (document.getElementById) {
                            document.write('style="border: 1px solid #000000;" ');
                        }
                        document.write('alt="<?php echo htmlspecialchars(addslashes($theme_name)); ?>" ');
                        document.write('title="<?php echo htmlspecialchars(addslashes($theme_name)); ?>" />');
                        document.write('</a><br />');
                        document.write('[ <b><a href="#top" onclick="takeThis(\'<?php echo $PMA_Theme; ?>\'); return false;">');
                        document.write('<?php echo addslashes($strTakeIt); ?>');
                        document.write('</a></b> ]');
                    //-->
                    </script>

    Чужая самописная CMF. Файл themes в админке.

    zii, 22 Февраля 2012

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

    +163

    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
    $textb = Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product` = ".$idProduct);
    		$count_otz = count($textb);
    		if ($p==0) $p = 1;
    		$limit = 99;
    		$texta = get("SELECT *, date_format(data, '%d.%m.%Y') as data_ FROM "._DB_PREFIX_."productotzyv WHERE `id_product` = ".$idProduct." LIMIT ".$limit);
    		$ed = count(Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product`=".intval($_GET['id_product'])." and `rating`=1"));
    		$dva = count(Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product`=".intval($_GET['id_product'])." and `rating`=2"));
    		$tri = count(Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product`=".intval($_GET['id_product'])." and `rating`=3"));
    		$four = count(Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product`=".intval($_GET['id_product'])." and `rating`=4"));
    		$five = count(Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product`=".intval($_GET['id_product'])." and `rating`=5"));
            $uri = $_SERVER['REQUEST_URI'];
            $i = strrpos($uri, "/");
            $uri1 = substr($uri, 0, $i);
            $i = strrpos($uri1, "/");
            $uri = substr($uri1, 0, $i);
            $uri = $uri."/";
            $monUrl = "http://".$_SERVER['HTTP_HOST'].$uri;
    		foreach ($textb as $s => $a){
    			$text += $a['rating'];
    		}
    
    		$smarty->assign('ed', $ed);
    		$smarty->assign('dva', $dva);
    		$smarty->assign('tri', $tri);
    		$smarty->assign('four', $four);
    		$smarty->assign('five', $five);
    		$smarty->assign('ed_proc', $ed/$count_otz*100);
    		$smarty->assign('dva_proc', $dva/$count_otz*100);
    		$smarty->assign('tri_proc', $tri/$count_otz*100);
    		$smarty->assign('four_proc', $four/$count_otz*100);
    		$smarty->assign('five_proc', $five/$count_otz*100);
    		$smarty->assign('rating2', round($text/$count_otz, 0));
    		$smarty->assign('countotz', $count_otz.' '.endingsForm($count_otz,"отзыв","отзыва","отзывов"));
    		$smarty->assign('monUrl',$monUrl);
    		$smarty->assign('text',$texta);

    Prestashop, реализация отображения отзывов и рейтига товара

    uint, 19 Февраля 2012

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

    +154

    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
    <?php
    iconv_set_encoding("input_encoding", "UTF-8");
    iconv_set_encoding("internal_encoding", "UTF-8");
    iconv_set_encoding("output_encoding", "UTF-8");
    
    $curl = curl_init();
    $curl_set = array(
            CURLOPT_COOKIESESSION => 0,
            CURLOPT_VERBOSE => 1,
            CURLOPT_USERAGENT => 'Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.14912/812; U; ru) Presto/2.4.15',
            CURLOPT_RETURNTRANSFER => 1
        );
    
    curl_setopt_array($curl, $curl_set);
    
    for($i=1;$i<50;$i++){
        $url = 'http://utemplate.ru/load/19-1-0-'.$i;
        curl_setopt($curl, CURLOPT_URL ,$url);
        $data = curl_exec($curl);
        preg_match_all('#<div class="entrytitle">(.*)</div>(.*)<hr>#isU', $data, $matches);
        $content[title] = $matches[1][0];
        $content[desc] = $matches[2][0];
        unset($matches);
        preg_match_all('#<img src\="http://utemplate.ru/_ld/0/(.*)"/>#isU', $data, $matches);
        $content[img] = $matches[1][0];
        if($content[title] AND $content[desc] AND $content[img]){
            unset($matches);
            mkdir($content[title], 0777);
            curl_setopt($curl, CURLOPT_URL ,'http://utemplate.ru/_ld/0/'.$content[img]);
            $image = curl_exec($curl);
            curl_setopt($curl, CURLOPT_URL ,'http://utemplate.ru/load/0-0-0-'.$i.'-20');
            $file_inf = curl_exec($curl);
            preg_match_all('#<A HREF="(.*)"#isU', $file_inf, $matches);
            $ext_file = substr($matches[1][0], -4);
            $ext_img = substr($content[img], -4);
            curl_setopt($curl, CURLOPT_URL , $matches[1][0]);
            $file = curl_exec($curl);
            file_put_contents($content[title].'/'.$content[title].$ext_file, $file);
            file_put_contents($content[title].'/'.$content[title].$ext_img, $image);
            file_put_contents($content[title].'/'.$content[title].'.txt', $content[title]."\n".$content[desc]);
        }
    
    };

    Злобный самописный, рабочий граббер uCoz сайта

    __construct, 19 Февраля 2012

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

    +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
    function run_service($ivf_service)
    {
        $ivf_result = null;
    
        if ( file_exists('base/services/'.$ivf_service.'/config.php') )
        {
            $ivf_result.= include_once('base/services/'.$ivf_service.'/config.php');
        }
    
        if ( file_exists('base/services/'.$ivf_service.'/index.php') )
        {
            $ivf_result.= include_once('base/services/'.$ivf_service.'/index.php');
        }
    
        return $ivf_result;
    }

    Проблема в том что каждый раз "вручную" писать это ни к чему. А такой вид вызывает сомнения в рациональности и скорости обработки. Как можно это удобно реализовать без юзания классов и автоинклудинга?

    belkir, 16 Февраля 2012

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