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

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

    +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
    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
    (function($) {
      core = {
        verticalOffset: -390,
        horizontalOffset: 0,
        repositionOnResize: true,
        overlayOpacity: 0.2,
        overlayColor: '#ffffff',
        draggable: true,
        send: 'Отправить',
        ok: 'Продолжить',
        close: 'Закрыть',
        save: 'Сохранить',
        cancel: 'Отмена',
        dialogClass: null,
        alert: function(message, title, callback) {
          if( title == null ) title = 'Alert';
          this._show_mess(title, message, null, 'alert', function(result) {
            if(callback) callback(result);
          });
        },
        confirm: function(message, title, callback) {
          if(title == null) title = 'Подтверждение действия';
            this._show_mess(title, message, null, 'confirm', function(result) {
              if(result) callback(result);
            });
        },
        prompt: function(message, value, title, callback) {
          if( title == null ) title = 'Prompt';
            this._show_mess(title, message, value, 'prompt', function(result) {
            if( callback ) callback(result);
          });
        },
        message: function(title){
          if(title == null) title = '';
          this._show_mess(title, '', '', 'message');
        },
        box_close: function() {
          $('#popup_container').fadeOut(200, function(){
            $('#popup_overlay, #popup_container').remove();
          });
        },
        _show_mess: function(title, msg, value, type, callback) {
          if ($('#popup_container').length > 0) {
            $('#popup_overlay, #popup_container').remove();
          }
          var html = "<div id='popup_container'>" +
            "<table>" +
              "<tbody>" +
              "<tr>" +
                "<td class='tl'/><td class='b'/><td class='tr'/>" +
              "</tr>" +
              "<tr>" +
                "<td class='b'/>" +
                "<td class='body'>" +
                  "<div class='popup_title_wrap'><div class='popup_x_button'/><div id='popup_title'/></div>" +
                  "<div id='popup_progress'><img src='/images/progress.gif' alt='Загрузка...' /></div>" +
                  "<div id='popup_content'/>" +
                  "<div id='popup_message'/>" +
                  "<div id='popup_panel'>" +
                    "<span class='ajax-loader'>&nbsp;</span>" +
                    "<div id='popup_info'/>" +
                    "<input id='popup_ok' type='button' class='button_yes' value='" + this.ok + "'/>" +
                    "<input id='popup_cancel' type='button' class='button_no' value='" + this.cancel + "'/>" +
                    "<input id='popup_close' type='button' class='button_no' value='" + this.close + "'/>" +
                  "</div>" +
                "</td>" +
                "<td class='b'/>" +
              "</tr>" +
              "<tr>" +
                "<td class='bl'/><td class='b'/><td class='br'/>" +
              "</tr>" +
              "</tbody>" +
            "</table>" +
          "</div>";
    
          this._overlay('show');
          $('body').append(html);
          $('#popup_panel input').hide();
          if(this.dialogClass) {
            $('#popup_container').addClass(this.dialogClass);
          }
          var pos = (($.browser.msie && parseInt($.browser.version) <= 6 )||(($(window).height()<480)||($(window).width()<700))) ? 'absolute' : 'fixed';
          $('#popup_container').css({
            position: pos,
            zIndex: 999,
            padding: 0,
            margin: 0
          });

    Govnisti_Diavol, 20 Ноября 2012

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

    −100

    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
    eval_prefix = lambda inp:\
                reduce(lambda stack, symbol:\
                (
                  (stack+[symbol]) if symbol.isdigit() \
                 else \
                  (
                    stack[:-2]+\
                    [str(
                          eval(
                               stack[-1]+symbol+stack[-2]
                              )
                        )
                    ]
                  )
                ), inp[::-1], [])[0]

    Здесь вам не хаскель!

    serpinski, 15 Ноября 2012

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

    +13

    1. 1
    class TSettingGrouperator

    Говногость, 12 Ноября 2012

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

    +60

    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
    function GetEndUTCTime($stime) {
            $ddd = split('-', $stime);
            if ($ddd[1] == '01')
                $ddd[1] = '02'; else if ($ddd[1] == '02')
                $ddd[1] = '03'; else if ($ddd[1] == '03')
                $ddd[1] = '04'; else if ($ddd[1] == '04')
                $ddd[1] = '05'; else if ($ddd[1] == '05')
                $ddd[1] = '06'; else if ($ddd[1] == '06')
                $ddd[1] = '07'; else if ($ddd[1] == '07')
                $ddd[1] = '08'; else if ($ddd[1] == '08')
                $ddd[1] = '09'; else if ($ddd[1] == '09')
                $ddd[1] = '10'; else if ($ddd[1] == '10')
                $ddd[1] = '11'; else if ($ddd[1] == '11')
                $ddd[1] = '12'; else if ($ddd[1] == '12') {
                $ddd[1] = '01';
                $ddd[0]++;
            } $result = $ddd[0] . '-' . $ddd[1] . '-' . $ddd[2];
            return $result;
        }
    
    // Returns submitted time in appropriate format (e.g. 2009-04-01T09:43:25.5244704Z)

    Документацыя по API SmartMove.

    Hits, 31 Октября 2012

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

    +160

    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
    jQuery('#items > div > a > img').hover(
        function(){
          jQuery(this).css('border', 'solid 1px gray');
          var pos = jQuery(this).parent().parent().position().left;
          var posTop = jQuery(this).parent().parent().position().top;
          jQuery(this).parent().parent().css('left', (pos-1));
          jQuery(this).parent().parent().css('top', (posTop-1));
        },
        function(){
          jQuery(this).css('border', '0');
          var pos = jQuery(this).parent().parent().position().left;
          var posTop = jQuery(this).parent().parent().position().top;
          jQuery(this).parent().parent().css('left', (pos+1));
          jQuery(this).parent().parent().css('top', (posTop+1));
        }
      )

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

    nbspjr, 30 Октября 2012

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

    +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
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {		
    	// ...skipped...
    });  
    </script>
    <!-- end script vert menu -->
    
    <!-- spoiler -->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"> </script>
    <script type="text/javascript"> 
    $(document).ready(function(){ 
    // ...skipped...
    });
    </script>
    <!-- spoiler -->
    
    <!-- up-->
    <script language="JavaScript" type="text/javascript"
    src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
    </script><!--up-->
    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' type='text/javascript'></script>
    <script type="text/javascript" src="ajax.js"></script>
    <!-- gallery -->  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>

    jQuery в организме не хватает?..

    telnet, 29 Октября 2012

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

    +117

    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
    class traffic {
            function traffic() {
                global $mosConfig_live_site;
    
                $remhost = @$_SERVER['REMOTE_HOST'];
                if (strpos($remhost,".") != false) { $remhost = strtok($remhost,"."); }
                $remhost = strtoupper($remhost);
    
                $mb = @$_COOKIE['mb'];
                //if ($mb ==  -1 || $mb ==  0) { return; }
                if (isset($mb)) {
                    if ($mb < 300) { $colormb = "green"; }
                else { $colormb = "red"; }
                    $t =<<<TXT
                     <center><b> 
                    <font size="4" style="line-height: 40px"><font color="$colormb"><p>eto prosto tak</p> $mb </font> </font> 
                    <br><font size="2" color="blue" style="line-height: 20px">$remhost</font></br></b></center>
                    <font color="brown" size="1" style="line-height: 8px">* -01:00</font> 
    TXT;
                    echo $t ;
                    echo @$_SERVER['HTTP_USER_AGENT'];
                    return;
                 }
                $headers = apache_request_headers(); //    
                if (!isset($headers['Authorization'])) {     //    
                  header('HTTP/1.0 401 Unauthorized');     //    
                  header('WWW-Authenticate: NTLM');      //    - NTLM
                  return; } //   
    
                //     
                if (substr($headers['Authorization'],0,5) == 'NTLM ') { // ,   NTLM-
                  $chain = base64_decode(substr($headers['Authorization'],5)); //   
                  switch (ord($chain{8})) { //     
                    case 3: //  5 -   type-3
                      foreach (array('LM_resp','NT_resp','domain','user','host') as $k=>$v) {
                        extract(unpack('vlength/voffset',substr($chain,$k*8+14,4)));
                        $val = substr($chain,$offset,$length);
                        //echo "$v: ".($k<2 ? hex_dump($val) : iconv('UTF-16LE','CP1251',$val))."<br>\r\n";
                        switch ($k) {
                             case 2:
                                $domain = iconv('UTF-16LE','CP1251',$val);
                              case 3:
                                  $username = iconv('UTF-16LE','CP1251',$val);
                              //case 4:
                              //    $hostname = iconv('UTF-16LE','CP1251',$val);
                              }
                      }
                      $sdlt = fopen("http://sdlt/sdlt.php?username=".$username."&domainname=".$domain."&key=4125896370","r");
                      $str = fscanf($sdlt,"%s");
                      fclose($sdlt);
                      list($mb) = $str;
                      if ($mb ==  -1) { return; }
                      setcookie("mb",$mb,time()+64800);
                      if ($mb < 300) { $colormb = "green"; }
                      else { $colormb = "red"; }
    $t =<<<TXT
                    <center><b> -<br>  :<br>
                    <font size="4" style="line-height: 40px"><font color="$colormb"><p>privet ilya!!!!!!!!!!!!!!!!!!!!!! </p> $mb </font><font color="brown">*</font></font><br>
                    <font style="line-height: 24px">  :</font><br>
                    <font size="1" color="blue" style="line-height: 20px">$remhost ($domain - $username)</font><br></b></center>
                    <font color="brown" size="1" style="line-height: 8px">* -  01:00</font>
    
    TXT;
                      echo $t;
                      
                      return;
                  case 1: //  3
                    //if (ord($chain{13}) == 0xB2 || ord($chain{13}) == 0x8201) { //   NTLM 0xb2   13   type-1:
                      $chain = "NTLMSSP\x00".// 
                                 "\x02" /*   */ ."\x00\x00\x00\x00\x00\x00\x00".
                                 "\x28\x00" /*    */ ."\x00\x00".
                                 "\x01\xB2" /*  */ ."\x00\x00".
                                 "\x00\x02\x02\x02\x00\x00\x00\x00". // nonce
                                 "\x00\x00\x00\x00\x00\x00\x00\x00";
                      header('HTTP/1.0 401 Unauthorized');
                      header('WWW-Authenticate: NTLM '.base64_encode($chain)); //   type-2
                      return;// }
                    }
                  }
                }
            }
        }
    
    $traffic=new traffic();

    безжалостный и беспощадный ООП в php

    Vasiliy, 22 Октября 2012

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

    +156

    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 ValidatePhone(strphone)
    {
        for(j=0;j<strphone.length;j++)
        {
        var cut;
        cut=strphone.charAt(  j )
        if(cut!=0&&cut!=1&&cut!=2&&cut!=3&&cut!=4&&cut!=5&&cut!=6&&cut!=7&&cut!=8&&cut!=9&&cut!="("&&cut!=")"&&cut!=".")
          return false;
     
        } 
        return true;
    }

    классика

    bytes, 16 Октября 2012

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

    +46

    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
    // БреДскрамс и выделение текущих категорий
    
    		if($level==1){	
    			$query = $conn->newStatement("SELECT * FROM item_level WHERE id=:parent_id:");
    			$query->setInteger('parent_id', $parent_id);
    			$data_1ur = $query->getFirstRecord();
    			$this->template->assign('data_1ur', $data_1ur);
    		}
    		if($level==2){
    			// первым делом досается сама категория
    			$query = $conn->newStatement("SELECT * FROM item_level WHERE id=:parent_id:");
    			$query->setInteger('parent_id', $parent_id);
    			$data_2ur = $query->getFirstRecord();
    			$this->template->assign('data_2ur', $data_2ur);
    			
    			// ее родители
    			$query = $conn->newStatement("SELECT * FROM item_level WHERE id=:parent_id:");
    			$query->setInteger('parent_id', $data_2ur['parent_id']);
    			$data_1ur = $query->getFirstRecord();
    			$this->template->assign('data_1ur', $data_1ur);
    		}
    		if($level==3){
    			$query = $conn->newStatement("SELECT * FROM item_level WHERE id=:parent_id:");
    			$query->setInteger('parent_id', $parent_id);
    			$data_3ur = $query->getFirstRecord();
    			$this->template->assign('data_3ur', $data_3ur);
    			
    			$query = $conn->newStatement("SELECT * FROM item_level WHERE id=:parent_id:");
    			$query->setInteger('parent_id', $data_3ur['parent_id']);
    			$data_2ur = $query->getFirstRecord();
    			$this->template->assign('data_2ur', $data_2ur);
    			
    			$query = $conn->newStatement("SELECT * FROM item_level WHERE id=:parent_id:");
    			$query->setInteger('parent_id', $data_2ur['parent_id']);
    			$data_1ur = $query->getFirstRecord();
    			$this->template->assign('data_1ur', $data_1ur);
    		}

    да, да, да...

    nkarakin, 16 Октября 2012

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

    +137

    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
    public List<int> parseInt(string input)
    {
      string res = "";
      int i = 0;
      while (input[i] != ' ')
      {
        res = res + input[i];
        //System.Console.WriteLine(res + " = res[" + i + "]");
        i++;
      }
      i = res.Length - 4;
      List<int> num = new List<int>();
      for (int j = 0; i > -4; i = i - 4, j++)
      {
        try
        {
          num.Add(int.Parse(res.Substring(i, 4)));
        }
        catch (Exception e1)
        {
          try
          {
            num.Add(int.Parse(res.Substring(i + 1, 3)));
          }
          catch (Exception e2)
          {
            try
            {
              num.Add(int.Parse(res.Substring(i + 2, 2)));
            }
            catch (Exception e3)
            {
              num.Add(int.Parse(res.Substring(i + 3, 1)));
            }
          }
        }
      //System.Console.WriteLine(num[j]+" = num["+j+"]");
      }
      return num;
    }

    Опять студенты.
    Задание: реализовать длинную арифметику.

    один из примеров чтения длинного числа

    graph_di5, 16 Октября 2012

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