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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. Pascal / Говнокод #9439

    +87

    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
    var
    x,y,R:real;
    l11,l12,l1,l21,l22,l2,l3,l41,l42,l4,l51,l52,l5,l6,l71,l72,l7:boolean;
    begin
    x:= StrToFloat(edit1.text);
    y:= StrToFloat(edit2.text);
    R:=StrToFloat(edit3.text);
    l11:=(y<x) and (x*x+y*y<R*R) and (y>0);
    l12:=(x*x+y*y<r*r) and (x<0)and (y>0);
    l1:=l11 or l12;
    l21:=(y>0) and (x*x+y*y<R*R)and (y>x);
    l22:= ( x*x+y*y<R*R)and (y>x) and (x<0);
    l2:= l21 or l22;
    l3:=(y<0) and ( x*x+y*y<R*R)and (y>x);
    l41:= (x>0) and ( x*x+y*y<R*R)and (y<x);
    l42:= (x<-1) and ( x*x+y*y>R*R)and (y>x);
    l4:= l41 or l42;
    l51:= (x>1) and ( x*x+y*y>R*R)and (y<x);
    l52:= (x>-1) and ( x*x+y*y>R*R)and (y<x);
    l5:= l51 or l52;
    l6:= (y>0) and ( x*x+y*y<R*R)and (y>x);
    l71:= (x>0) and (x*x+y*y>R*R) and (y<0);
    l72:= (y<0) and (x*x+y*y>R*R) and (y<x) and (x<0);
    l7:= l71 or l72;
    if l1= true then
    begin
    edit4.text:='T принадлежит 1 области';
    end
    else
    begin
    edit4.text:='T не принадлежит 1 области';
    end;
    if l2= true then
    begin
    edit4.text:='T принадлежит 2 области';
    end
    else
    begin
    edit4.text:='T не принадлежит 2 области'
    end;
    if l3= true then
    begin
    edit4.text:='T принадлежит 3 области'
    end
    else
    begin
    edit4.text:='T не принадлежит 3 области'
    end;
    if l4= true then
    begin
    edit4.text:='T принадлежит 4 области'
    end
    else
    begin
    edit4.text:='T не принадлежит 4 области'
    end;
    if l5= true then
    begin
    edit4.text:='T принадлежит 5 области'
    end
    else
    begin
    edit4.text:='T не принадлежит 5 области'
    end;
    if l6= true then
    begin
    edit4.text:='T принадлежит 6 области'
    end
    else
    begin
    edit4.text:='T не принадлежит 6 области'
    end;
    if l4= true then
    begin
    edit4.text:='T принадлежит 7 области'
    end
    else
    begin
    edit4.text:='T не принадлежит 7 области'
    end;
    end;
    
    end.

    ...

    Cyanide, 15 Февраля 2012

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

    −138

    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
    Для Каждого СтрПЛ Из ПутевыеЛисты Цикл
    	ЗаказСсылкаИзПЛ = СтрПЛ.ЗаказНаИспользованиеТС;
    	Если Не ЗаказСсылкаИзПЛ.Пустая() Тогда
    		ЗапросВыборкаЗаказовПоСсылкеИЗПЛ = Новый Запрос;
    		ЗапросВыборкаЗаказовПоСсылкеИЗПЛ.Текст = "ВЫБРАТЬ
    					   |	АСУ_ЗаказНаИспользованиеТС.Ссылка
    					   |ИЗ
    					   |	Документ.АСУ_ЗаказНаИспользованиеТС КАК АСУ_ЗаказНаИспользованиеТС
    					   |ГДЕ
    					   |	АСУ_ЗаказНаИспользованиеТС.ДатаС <= &Дата1
    					   |	И АСУ_ЗаказНаИспользованиеТС.ДатаПо >= &Дата2
    					   |	И АСУ_ЗаказНаИспользованиеТС.Ответственный = &Ответственный
    					   |	И АСУ_ЗаказНаИспользованиеТС.Номер = &Номер";	
    		ЗапросВыборкаЗаказовПоСсылкеИЗПЛ.УстановитьПараметр("Дата1", КонецДня(Дата));
    		ЗапросВыборкаЗаказовПоСсылкеИЗПЛ.УстановитьПараметр("Дата2", НачалоДня(Дата)); 
    		ЗапросВыборкаЗаказовПоСсылкеИЗПЛ.УстановитьПараметр("Ответственный", Ответственный);
    		ЗапросВыборкаЗаказовПоСсылкеИЗПЛ.УстановитьПараметр("Номер", ЗаказСсылкаИзПЛ.Номер);
    		РезультатЗаказыПоСсылкеИзПЛ = ЗапросВыборкаЗаказовПоСсылкеИЗПЛ.Выполнить().Выгрузить();
    		Если РезультатЗаказыПоСсылкеИзПЛ.Количество() > 0 Тогда
    			Для Каждого СтрЗаказПоСсылкеИзПЛ Из РезультатЗаказыПоСсылкеИзПЛ Цикл
    				...
    			КонецЦикла;
    		КонецЕсли;
    	КонецЕсли;
    КонецЦикла;

    Ищем заказ по номеру. А номер берем из заказа. И, конечно же, их может оказаться множество. (КонтрольУникальности = Истина, периодичность = Непериодический).
    А также хитровылепленный способ убедиться, что заказ попадает в указанный период и имеет указанного ответственного.
    И, конечно же, запрос надо создавать заново для каждой СтрПЛ, а вдруг он испортился...
    Вот такие у нас крайне осторожные прогромисты.

    mrbus, 13 Февраля 2012

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

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <p class="info">
    	<span>Дата начала: <b><?=$custom_fields['Дата начала'][0];?></b></span>
    	<span>Продолжительность: <b><?=$custom_fields['Продолжительность'][0];?></b></span>
    	<span>Стоимость: <b><?=$custom_fields['Стоимость'][0];?></b></span>
    </p>

    Сумрачный германский тургайский гений.

    varg242, 13 Февраля 2012

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

    +143

    1. 1
    $fullness = $what ? '1' : '0';

    $what это boolean
    наверняка уже было, но такие конструкции меня просто убивают

    ghost404, 07 Февраля 2012

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

    +127

    1. 1
    <span class="main_dnnmenu_rootitem mi mi1 id83 root" id="menuprod">

    Оттуда же...
    Ищу форму в которую мне надо передать значение, радуюсь что ния поддерживаю сайт.

    kyzi007, 06 Февраля 2012

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

    +120

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if (tval.ToLower() == "true")
                                {
                                    if (!chkResp.Checked)
                                        restart = true;
                                    chkResp.Checked = true;
                                }
                                else if (tval.ToLower() == "false")
                                {
                                    if (chkResp.Checked)
                                        restart = true;
                                    chkResp.Checked = false;
                                }

    LOIC

    kasthack, 24 Января 2012

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