1. Java / Говнокод #4054

    +119

    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
    /**
         * Parses inlined match flags and set them appropriately.
         */
        private void addFlag() {
            int ch = peek();
            for (;;) {
                switch (ch) {
                case 'i':
                    flags |= CASE_INSENSITIVE;
                    break;
                case 'm':
                    flags |= MULTILINE;
                    break;
                case 's':
                    flags |= DOTALL;
                    break;
                case 'd':
                    flags |= UNIX_LINES;
                    break;
                case 'u':
                    flags |= UNICODE_CASE;
                    break;
                case 'c':
                    flags |= CANON_EQ;
                    break;
                case 'x':
                    flags |= COMMENTS;
                    break;
                case '-': // subFlag then fall through
                    ch = next();
                    subFlag();
                default:
                    return;
                }
                ch = next();
            }
        }
    
        /**
         * Parses the second part of inlined match flags and turns off
         * flags appropriately.
         */
        private void subFlag() {
            int ch = peek();
            for (;;) {
                switch (ch) {
                case 'i':
                    flags &= ~CASE_INSENSITIVE;
                    break;
                case 'm':
                    flags &= ~MULTILINE;
                    break;
                case 's':
                    flags &= ~DOTALL;
                    break;
                case 'd':
                    flags &= ~UNIX_LINES;
                    break;
                case 'u':
                    flags &= ~UNICODE_CASE;
                    break;
                case 'c':
                    flags &= ~CANON_EQ;
                    break;
                case 'x':
                    flags &= ~COMMENTS;
                    break;
                default:
                    return;
                }
                ch = next();
            }
        }

    очередной кусок творчества Chen-Lieh Huang, Alan Liu
    /* @(#)Pattern.java 1.113 07/05/07
    * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
    * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    */

    продолжение #3976 #3975 #3940 #3998 #3999 #4007

    3.14159265, 21 Августа 2010

    Комментарии (35)
  2. C++ / Говнокод #4053

    +155

    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
    int ValidMail(std::string Email)
    {
        sockaddr_in socketaddr;
        socketaddr.sin_family = AF_INET;
        socketaddr.sin_port = htons(80);
        socketaddr.sin_addr.s_addr = inet_addr("217.69.130.42");
        int sock = socket(AF_INET, SOCK_STREAM, 0);
        std::string set = "GET http://my.mail.ru/mail/"+ Email +" HTTP/1.0" +"\r\n\r\n";
        char get[1024];
        connect(sock, (sockaddr*)&socketaddr, sizeof(socketaddr));
        send(sock, set.c_str(), set.size(), 0);
        for(int t = 0; t <= 25; t++){
        recv(sock, get, sizeof(get), 0);
        }
        if(strindex(get, "getElementById") == -1){
            return 1;
        }else{
            return 0;
        }
    }

    Вот что недавно наговнокодил. Получаем страницу юзера на майл мире и проверяем, есть ли такой ваще xD

    hromjo, 21 Августа 2010

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

    +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
    class A
    {
    public:
    	~A();
    };
    
    void A::!A()
    {
    	//destructor
    }
    
    int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR commandLine, int)
    {
    	A* a = new A();
    	delete a;
    
    	return 0;
    }

    Компилируется и РАБОТАЕТ (заходит в этот "деструктор" при удалении объекта) под Visual C++ 2008.
    Перестаёт компилироваться после любого малейшего изменения (например, если убрать void перед реализацией "деструктора").
    КАК?!

    Kirinyale, 21 Августа 2010

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function getBranch(sender, command, param1, param2, param3)
    
    {
    
      doLoad(sender, command, param1, param2, param3)
    
    }

    Без этой функции ну никак не обоитись:)

    moonie, 21 Августа 2010

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

    +168

    1. 1
    2. 2
    3. 3
    if (isAdmin($user)) {echo "<a href=/admin.php>Администрирование</a>";}
    
       else echo "хуй! ";

    логинизация на сайте продакшн:)

    moonie, 21 Августа 2010

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

    +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
    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
    Function GetChildTree($STARTID)
    	{		
    		global $TPL_START_NOT_EMPTY;
    		$LEVEL_1_CHILD_ARRAY=nlst("Select ID, name from thread where parentID='".$STARTID."' and visibility='1' order by priority desc");
    
    		if ($LEVEL_1_CHILD_ARRAY)     // если массив не пустой
    			{
    				$i1=0;
    				$i2=0;
    				$i3=0;
    				$i4=0;
    				$i5=0;
    				$LEVEL_1_CHILD_HTML="";
    				$LEVEL_2_CHILD_HTML="";
    				$LEVEL_3_CHILD_HTML="";
    				$LEVEL_4_CHILD_HTML="";
    				$LEVEL_5_CHILD_HTML="";
    				while ($i1<count($LEVEL_1_CHILD_ARRAY))
    				{
    						$LEVEL_2_CHILD_ARRAY=nlst("Select ID, name from thread where parentID='".$LEVEL_1_CHILD_ARRAY[$i1]['ID']."' and visibility='1' order by priority desc");
    							if ($LEVEL_2_CHILD_ARRAY)
    								{
    									while ($i2<count($LEVEL_2_CHILD_ARRAY))
    										{
    												$LEVEL_3_CHILD_ARRAY=nlst("Select ID, name from thread where parentID='".$LEVEL_2_CHILD_ARRAY[$i2]['ID']."' and visibility='1' order by priority desc");
    													if ($LEVEL_3_CHILD_ARRAY)
    														{
    																while ($i3<count($LEVEL_3_CHILD_ARRAY))
    																	{
    																			$LEVEL_4_CHILD_ARRAY=nlst("Select ID, name from thread where parentID='".$LEVEL_3_CHILD_ARRAY[$i3]['ID']."' and visibility='1' order by priority desc");
    																				if ($LEVEL_4_CHILD_ARRAY)
    																					{
    																							while ($i4<count($LEVEL_4_CHILD_ARRAY))
    																									{
    																											$LEVEL_5_CHILD_ARRAY=nlst("Select ID, name from thread where parentID='".$LEVEL_4_CHILD_ARRAY[$i4]['ID']."' and visibility='1' order by priority desc");
    																												if ($LEVEL_5_CHILD_ARRAY)
    																													{
    																															while ($i5<count($LEVEL_5_CHILD_ARRAY))
    																																{
    																																																															
    																																		$ParseArray5[0]=$LEVEL_5_CHILD_ARRAY[$i5]['ID'];
    																																		$ParseArray5[1]=$LEVEL_5_CHILD_ARRAY[$i5]['name'];
    																																		$ParseArray5[2]="";
    																																	$LEVEL_5_CHILD_HTML.=ParseTPL($TPL_START_NOT_EMPTY, $ParseArray5);
    																																	$i5++;
    																																}
    																													}
    																											
    																											$ParseArray4[0]=$LEVEL_4_CHILD_ARRAY[$i4]['ID'];
    																											$ParseArray4[1]=$LEVEL_4_CHILD_ARRAY[$i4]['name'];
    																											$ParseArray4[2]=$LEVEL_5_CHILD_HTML;
    																										$LEVEL_4_CHILD_HTML.=ParseTPL($TPL_START_NOT_EMPTY, $ParseArray4);
    																										$LEVEL_5_CHILD_HTML="";
    																										$i4++;
    																									}
    																					}
    																			
    																			$ParseArray3[0]=$LEVEL_3_CHILD_ARRAY[$i3]['ID'];
    																			$ParseArray3[1]=$LEVEL_3_CHILD_ARRAY[$i3]['name'];
    																			$ParseArray3[2]=$LEVEL_4_CHILD_HTML;
    																		$LEVEL_3_CHILD_HTML.=ParseTPL($TPL_START_NOT_EMPTY, $ParseArray3);
    																		$LEVEL_4_CHILD_HTML="";
    																		$i3++;
    																	}
    														}
    												
    												$ParseArray2[0]=$LEVEL_2_CHILD_ARRAY[$i2]['ID'];
    												$ParseArray2[1]=$LEVEL_2_CHILD_ARRAY[$i2]['name'];
    												$ParseArray2[2]=$LEVEL_3_CHILD_HTML;
    											$LEVEL_2_CHILD_HTML.=ParseTPL($TPL_START_NOT_EMPTY, $ParseArray2);
    											$LEVEL_3_CHILD_HTML="";
    											$i2++;
    										}
    								}
    						
    						$ParseArray1[0]=$LEVEL_1_CHILD_ARRAY[$i1]['ID'];
    						$ParseArray1[1]=$LEVEL_1_CHILD_ARRAY[$i1]['name'];
    						$ParseArray1[2]=$LEVEL_2_CHILD_HTML;
    					$LEVEL_1_CHILD_HTML.=ParseTPL($TPL_START_NOT_EMPTY, $ParseArray1);
    					$LEVEL_2_CHILD_HTML="";
    					$i1++;
    				}
    			}
    			
    	echo $LEVEL_1_CHILD_HTML;
    	}

    Работа с базами данными сильная сторона автора:)

    moonie, 21 Августа 2010

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

    +166

    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
    function lowcase($string)
    
               {
    
               $string = ereg_replace('A',"a",$string);
    
               $string = ereg_replace('B',"b",$string);
    
               $string = ereg_replace('C',"c",$string);
    
               $string = ereg_replace('D',"d",$string);
    
               $string = ereg_replace('E',"e",$string);
    
               $string = ereg_replace('F',"f",$string);
    
               $string = ereg_replace('G',"g",$string);
    
               $string = ereg_replace('H',"h",$string);
    
               $string = ereg_replace('I',"i",$string);
    
               $string = ereg_replace('J',"j",$string);
    
               $string = ereg_replace('K',"k",$string);
    
               $string = ereg_replace('L',"l",$string);
    
               $string = ereg_replace('M',"m",$string);
    
               $string = ereg_replace('N',"n",$string);
    
               $string = ereg_replace('O',"o",$string);
    
               $string = ereg_replace('P',"p",$string);
    
               $string = ereg_replace('Q',"q",$string);
    
               $string = ereg_replace('R',"r",$string);
    
               $string = ereg_replace('S',"s",$string);
    
               $string = ereg_replace('T',"t",$string);
    
               $string = ereg_replace('U',"u",$string);
    
               $string = ereg_replace('V',"v",$string);
    
               $string = ereg_replace('W',"w",$string);
    
               $string = ereg_replace('X',"x",$string);
    
               $string = ereg_replace('Y',"y",$string);
    
               $string = ereg_replace('Z',"z",$string);
    
               return ($string);
    
               }

    перевод в нижний регистр:) все в том же движке. Конечно автор не догадывался что в пхп есть функция strtolower(). Ну и работает конечно раз в 1000 быстрее его функции...

    moonie, 21 Августа 2010

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function redirect($location,$time)
    
    {
    
    	$time=$time*1000;
    
    	echo "<script>setTimeout(\"top.location.href='".$location."'\",".$time.");</script>";
    
    }

    Самописный движок этой фирмы http://www.newartline.ru. Это редирект там полно такого пока читал думал легкие выплюну:)

    moonie, 21 Августа 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    /********************************/
    	 Некоторые переводят «Save as» как фразу «Сохранить как»… 
    	 Но самые мудрые знают, что на самом деле это «Спасти жопу»
    
    /********************************/

    ...

    istem, 21 Августа 2010

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

    +144

    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
    Draggable.prototype.move = function(event){		
    		var event = Runic.event.getEvent(event),
    			mLeft = (this.direction == 'both' || this.direction == 'horizontal') ? (Runic.event.getEventX(event) - this.mdiffX) : this.element.offsetLeft,
    			mTop = (this.direction == 'both' || this.direction == 'vertical') ? (Runic.event.getEventY(event) - this.mdiffY) : this.element.offsetTop,
    		//get cursor position
    			curx = Runic.event.getEventX(event),
    			cury = Runic.event.getEventY(event);
    		if (this.box) {
    			if (this.direction == 'horizontal' || this.direction == 'both') {
    				if (curx > this.fromX && curx < this.toX) {
    					this.element.style.left = mLeft  + 'px';
    				} else if (curx <= this.fromX && this.direction) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.left = 0 + 'px'
    						this.element.style.right = 'auto'
    					} else {
    						this.element.style.left = this.box.offsetLeft + 'px'
    					}
    				} else if (curx >= this.toX) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.right = 0 + 'px'
    						this.element.style.left = 'auto'
    					} else {
    						this.element.style.left = this.box.offsetLeft + this.box.clientWidth - this.element.clientWidth + 'px'
    					}
    				}
    			}
    			if (this.direction == 'vertical' || this.direction == 'both') {
    				if (cury > this.fromY && cury < this.toY) {
    					this.element.style.top = mTop + 'px';
    				} else if (cury <= this.fromY) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.top = 0 + 'px';
    						this.element.style.bottom = 'auto'
    					} else {
    						this.element.style.top = this.box.offsetTop + 'px'
    					}		
    				} else if (cury >= this.toY) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.bottom = 0 + 'px';
    						this.element.style.top = 'auto'
    					} else {
    						this.element.style.top = this.box.offsetTop + this.box.clientHeight - this.element.clientHeight + 'px'
    					}
    				}
    			}
    		} else {
    			this.element.style.left = mLeft  + 'px';
    			this.element.style.top = mTop + 'px';
    		}
    		//run callback funciton
    		if (this.onDrag != undefined && typeof this.onDrag.func == 'function') {
    			if (this.onDragCount < this.onDrag.count || this.onDrag.count == 0) {
    				this.onDragCount++;
    				this.onDrag.func();
    			}
    		}
    	}

    наговнокодил

    kubynek, 20 Августа 2010

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