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

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    for (conn_vector::iterator i = m_connections.begin(); i != m_connections.end(); ++i) {
        if (*i == conn) {
            toDelete = *i;
            m_connections.erase(i);
            break;
        }
    }

    Да, С++98. Да, в std::find не умеем. Да, сегфолт. Да, моё.

    Elvenfighter, 27 Августа 2014

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

    +135

    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
    try
    {
    	HttpWebRequest httpWebReq = (HttpWebRequest)WebRequest.Create(this.OURURL);
    	httpWebReq.Timeout = 2000;
    	httpWebReq.Method = "POST";
    
    	string Response = ResponseStreamReader.ReadToEnd();
    	
    	// bla-bla-bla ...
    
    	httpWebReq.GetResponse().Close();
    	httpWebReq = null;
    	Response = null;
    }

    Smekalisty, 19 Августа 2014

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

    +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
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    .error(function(error) {
                                                                    sendResult(500, "ERROR. " + error);
                                                                })
                                                        })
                                                        .error(function(error) {
                                                            sendResult(500, "ERROR. " + error);
                                                        })
                                                })
                                                .error(function(error) {
                                                    sendResult(500, "ERROR. " + error);
                                                })
                                        })
                                        .error(function(error) {
                                            sendResult(500, "ERROR. " + error);
                                        });
                                })
                                .error(function(error) {
                                    sendResult(500, "ERROR. " + error);
                                });
                        })
                        .error(function(error) {
                            sendResult(500, "ERROR. " + error);
                        });
                })
                .error(function(error) {
                    sendResult(500, "ERROR. " + error);
                });

    strax, 31 Июля 2014

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

    +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
    function parseString($str) {
         $op = array();
        $pairs = explode("&", $str);
        foreach ($pairs as $pair) {
            list($k, $v) = array_map("urldecode", explode("=", trim($pair)));
            $op[$k] = $v;
        }
        return $op;
    }
    
    if (!isset($HTTP_RAW_POST_DATA))
    {
            $HTTP_RAW_POST_DATA = file_get_contents("php://input");
    }

    И это уже не в первый раз. А когда надо отправить форму, то php-шники делают это через raw socket.

    cottonzoom, 30 Июля 2014

    Комментарии (3)
  6. JavaScript / Говнокод #16411

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    jQuery(document).ready(function($) {
    	var url=document.location.href;
    	$.each($(".menu a"),function(){
    	if(this.href==url){$(this).addClass('activetopmenu');};
    	});
    	});

    И это при том, что для генерации страниц используется php...

    mkramer, 23 Июля 2014

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

    +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
    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
    /*
         * BANERS
         */
        $IMG="<div class=\"tovMain\" id=\"bnList1_imgBlock\"></div>
              <script type=\"text/javascript\">
                var bnList1_images=[";
        $banerId=$res->show1Var("s_rzd","page='".PAGE_BANER."'","id");
        $imgPreRes=$res->showTabAsPage("s_cnt","rzdId='".$banerId."' AND image>'' AND `show`='Y'","image","id",0);
        foreach($imgPreRes as $imgRes){
            $IMG.="'{ROOTPATH}images/".$imgRes["image"]."',";
        }
        $IMG=substr($IMG,0,-1);
        $IMG.="];
                var bnList1_old_image='';
                var bnList1_x=10;
                var bnList1_y=3;
                var bnList1_mercaniy=2;
                var bnList1_speed=500;
                var bnList1_speed1=800;
                var bnList1_w=Math.round(document.getElementById(\"bnList1_imgBlock\").offsetWidth/bnList1_x);
                var bnList1_h=Math.round(document.getElementById(\"bnList1_imgBlock\").offsetHeight/bnList1_y);
            
                var tek=0;
                bnList1Listing(bnList1_images[tek]);
                setInterval(\"tek=(bnList1_images.length>(tek+1)?tek+1:0);bnList1Listing(bnList1_images[tek]);\",5000);
                
                for(var i=1;i<=bnList1_x;i++){
                    for(var j=1;j<=bnList1_y;j++){
                        bnList1CreateBlocks(\"bnList1_block_\"+i+\"_\"+j+\"_1\",bnList1_w,bnList1_h,bnList1_w*(i-1),bnList1_h*(j-1));
                        bnList1CreateBlocks(\"bnList1_block_\"+i+\"_\"+j+\"_2\",bnList1_w,bnList1_h,bnList1_w*(i-1),bnList1_h*(j-1));
                    }
                }
            </script>";
        /*$rndBanerId=array_rand($imgPreRes);
        $img=$imgPreRes[$rndBanerId]["image"];
        $IMG="<div class=\"tovMain\" id=\"slideshow\">
                <img src=\"{ROOTPATH}images/empty.gif\" alt=\"\" />
                <img src=\"{ROOTPATH}img.php?image=".$img."&w=656&h=189\" alt=\"\" />
              </div>"; // Простая сквозная картинка
        //$HD_IMG="<div class=\"tovMain\">".($cntRes->hdImg())."</div>"; // Сменяющиеся картинки
         * s
         */
        $BANER=$cntRes->site_simpleStr(PAGE_BANER,"text");
            $content=str_replace("{BANER}",$BANER,$content);
            $content=str_replace("{IMG}",$IMG,$content);
        
        /*
         * IMAG
         */
        $TOVMAIN=$imagRes->showAsTovList("main");
            $content=str_replace("{TOVMAIN}",$TOVMAIN,$content);
        unset($TOVMAIN);
            
        /*
         * CONTENT
         */
        
        $NAV_ROW=$cntRes->site_nav();
        $STR=$cntRes->site_pageHd();
        $STR.=$cntRes->site_imagFilter();
        $STR.=$cntRes->site_cont();
        $SUB_STR=$cntRes->commonStr();
            $content=str_replace("{NAV_ROW}",$NAV_ROW,$content);
            $content=str_replace("{STR}",$STR,$content);
            $content=str_replace("{SUB_STR}",$SUB_STR,$content);
        unset($STR,$SUB_STR);
    
                $content=str_replace("{BACK}",BACK,$content);
                $content=str_replace("{UP}",UP,$content);
                $content=str_replace("{SEND}",SEND,$content);
                $content=str_replace("{FORM_SEND_ZAG}",FORM_SEND_ZAG,$content);
                $content=str_replace("{FORM_NAME}",FORM_NAME,$content);
                $content=str_replace("{FORM_POSTADDR}",FORM_POSTADDR,$content);
                $content=str_replace("{FORM_PHONE}",FORM_PHONE,$content);
                $content=str_replace("{FORM_EML}",FORM_EML,$content);
                $content=str_replace("{FORM_MSG}",FORM_MSG,$content);
                $content=str_replace("{FORM_SEND_SUCCESS}",FORM_SEND_SUCCESS,$content);
                $content=str_replace("{FORM_SEND_ERROR}",FORM_SEND_ERROR,$content);
                $content=str_replace("{REQUIRED_FIELDS}",REQUIRED_FIELDS,$content);
                $content=str_replace("{MAIN}",MAIN,$content);
      if(__lang=="en"){
        $content=str_replace("logo.png","logo_en.png",$content);
      }

    templates/default/template.php
    Знакомьтесь, "DEFAULT SITE TEMPLATE" (Кусок 2-й) ;)

    RuJack, 21 Июля 2014

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $mas=split("/",$_FILES["filename"]["type"]);
    if ((count($mas)==2) and ($mas[0]=="audio"))
    {
      ...
    }

    А то вдруг там в MIME-типе двадцать слешей.

    vocal_hydra, 21 Июля 2014

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

    +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
    function page_from_template_no_headers($t,$vl) {
    global $s,$m;
    if (!is_array($vl)) $vl = array();
    $vl = array_merge($vl,get_common_variables());
    $style = find_style(); $t = template_select($t,0,$style);
    $vl[styles] = '<LINK href="'.$s[site_url].'/styles/'.$style.'/bootstrap.css" rel="StyleSheet">';
    $fh = fopen($t,'r'); while(!feof($fh)) $line .= fgets($fh, 4096); fclose($fh);
    foreach ($vl as $k=>$v) $line = str_replace("#%$k%#",$v,$line);
    $line = preg_replace("/#%[a-z0-9_]*%#/i",'',$line);
    echo stripslashes($line);
    exit;
    }

    Напоминает частушку,
    Опа опа срослась ...зда и ..опа.
    Этого не может быть
    Промежуток должен быть.

    reddevil, 17 Июля 2014

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

    +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
    [ITEAM] => Array
            (
                [0] => Array
                    (
                        [CITY_NAME] => value
                        [CITY_DETAIL_URL] => value
                        [OBJECT_NAME] => value
                        [OBJECT_ID] => 2487
                        [DATE_CREATE] => 02.07.2006
                        [STATUS] => Y
                        [PAID_STATUS] => Y
                        [DATEIL_OBJECT_URL] => value
                    )
    
                [1] => Array
                    (
                        [CITY_NAME] => value
                        [CITY_DETAIL_URL] => value
                        [OBJECT_NAME] => value
                        [OBJECT_ID] => 2489
                        [DATE_CREATE] => 02.07.2006
                        [STATUS] => Y
                        [PAID_STATUS] => N
                        [DATEIL_OBJECT_URL] => value
                    )

    Битрикс!!
    Особое внимание на ключи:
    ITEAM и DATEIL_OBJECT_URL )))

    http://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=43&LESSON_ID=3014

    #bitrix #black chi

    waspar, 17 Июля 2014

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

    +41

    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
    catch(...)
    {	
    	static int j = 0;
    
    	//if we enter this catch clause more than 1 time
    	//it is very likely that the RestartSystem() command
    	//did not succeed. If this is the case we just exit.
    	if(j>0)
    		exit(0);
    	else
    		SWFMonitorT::GetInstance()->RestartSystem();
    	j++;
    	throw;
    }

    Приключения в мире байтоёбиков...

    blackhearted, 16 Июля 2014

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