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

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

    −305.1

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    my ($_bonus1_l, $_bonus1_y, $_bonus2_l, $_bonus2_y) = ($l1*10 > rand(100) ? 1 : 0, $y1*10 > rand(100) ? 1 : 0, $l2*10 > rand(100) ? 1 : 0, $y2*10 > rand(100) ? 1 : 0);
          ($_bonus1_l, $_bonus2_l) = (0, 0) if $_bonus1_l == 1 and $_bonus2_l == 1;
          ($_bonus1_y, $_bonus2_y) = (0, 0) if $_bonus1_y == 1 and $_bonus2_y == 1;
    if($turn > 12){
          my ($_a1_def, $_b1_def, $_c1_def) = mass($pl1_mov, $User1, "def");
          my ($_a1_att, $_b1_att, $_c1_att) = mass($pl1_att, $User1, "att");
          my ($_a2_def, $_b2_def, $_c2_def) = mass($pl2_mov, $User2, "def");
          my ($_a2_att, $_b2_att, $_c2_att) = mass($pl2_att, $User2, "att");
    
    $N1 += $_a1_att if $_a2_def < 1000000;
    $N1 += $_b1_att if $_b2_def < 1000000;
    $N1 += $_c1_att if $_c2_def < 1000000;
    $N2 += $_a2_att if $_a1_def < 1000000;
    $N2 += $_b2_att if $_b1_def < 1000000;
    $N2 += $_c2_att if $_c1_def < 1000000;
    
          if($_bonus1_l){
           	 my $l = int(rand(3));
    	 ## сБНПНР
             if($l == 0){
             	my $r = 0;
    	 	($_a2_att, $r) = (0, 1) if $_a2_att > 0 and $_a1_def < 1000000;
          	 	($_b2_att, $r) = (0, 1) if $_b2_att > 0 and $_a1_def < 1000000 and $r == 0;
    		($_c2_att, $r) = (0, 1) if $_c2_att > 0 and $_a1_def < 1000000 and $r == 0;
                    $U1 = $r;
             } elsif($l == 1){
                    my $r = 0;
                    ($_a1_att, $r, $K2) = (int($_a1_att * 1.5), 1, int($_a1_att/2)) if $_a1_att > 0  and $_a2_def < 1000000;
                    ($_b1_att, $r, $K2) = (int($_b1_att * 1.5), 1, int($_b1_att/2)) if $_b1_att > 0  and $_b2_def < 1000000 and $r == 0;
                    ($_c1_att, $r, $K2) = (int($_c1_att * 1.5), 1, int($_c1_att/2)) if $_c1_att > 0  and $_c2_def < 1000000 and $r == 0;
             } elsif($l == 2){
                    my ($r, $ov, $v) = (0, 0, int(rand(3)));
                    ($_a1_att, $r, $ov) = (0, 1, (int($_a2_att/2))) if $_a2_att > 0 and $_a1_def > 1000000;
                    ($_b1_att, $r, $ov) = (0, 1, (int($_b2_att/2))) if $_b2_att > 0 and $_b1_def > 1000000 and $r == 0;
                    ($_c1_att, $r, $ov) = (0, 1, (int($_c2_att/2))) if $_c2_att > 0 and $_c1_def > 1000000 and $r == 0;
                    $_a1_att += $ov if $v == 0;
                    $_b1_att += $ov if $v == 1;
                    $_c1_att += $ov if $v == 2;
                    $O1 = $ov;
             }
          }
          if($_bonus2_l){
           	 my $l = int(rand(100));
             if($l == 0){
             	my $r = 0;
    	 	($_a1_att, $r) = (0, 1) if $_a1_att > 0 and $_a2_def < 1000000;
          	 	($_b1_att, $r) = (0, 1) if $_b1_att > 0 and $_a2_def < 1000000 and $r == 0;
    		($_c1_att, $r) = (0, 1) if $_c1_att > 0 and $_a2_def < 1000000 and $r == 0;
                     $U2 = $r;
             } elsif($l == 1){
                    my $r = 0;
                    ($_a2_att, $r, $K1) = (int($_a2_att * 1.5), 1, int($_a2_att/2)) if $_a2_att > 0  and $_a1_def < 1000000;
                    ($_b2_att, $r, $K1) = (int($_b2_att * 1.5), 1, int($_b2_att/2)) if $_b2_att > 0  and $_b1_def < 1000000 and $r == 0;
                    ($_c2_att, $r, $K1) = (int($_c2_att * 1.5), 1, int($_c2_att/2)) if $_c2_att > 0  and $_c1_def < 1000000 and $r == 0;
             } elsif($l == 2){
             	my ($r, $ov, $v) = (0, 0, int(rand(3)));
                    ($_a2_att, $r, $ov) = (0, 1, (int($_a1_att/2))) if $_a1_att > 0 and $_a2_def > 1000000;
                    ($_b2_att, $r, $ov) = (0, 1, (int($_b1_att/2))) if $_b1_att > 0 and $_b2_def > 1000000 and $r == 0;
                    ($_c2_att, $r, $ov) = (0, 1, (int($_c1_att/2))) if $_c1_att > 0 and $_c2_def > 1000000 and $r == 0;
                    $_a2_att += $ov if $v == 0;
                    $_b2_att += $ov if $v == 1;
                    $_c2_att += $ov if $v == 2;
                    $O2 = $ov;
             }
          }
          if($_bonus1_y){
              my $l = int(rand(2));
             if($l == 0){
                my ($r, $rik, $V1) = (0, 0, int(rand(3)) + 1);
                ($r, $rik) = (1, (int($_a1_att/2))) if $_a1_att > 0 and $_a2_def < 1000000 and $V1 == 1;
                ($r, $rik) = (1, (int($_b1_att/2))) if $_b1_att > 0 and $_b2_def < 1000000 and $r == 0 and $V1 == 2;
                ($r, $rik) = (1, (int($_c1_att/2))) if $_c1_att > 0 and $_c2_def < 1000000 and $r == 0 and $V1 == 3;
                $R2 = $rik;
                $db->query("UPDATE duel set pl1_rik = CONCAT(pl1_rik, $V1) where sid = \"$dsid\"") if $R2 > 0;
    
             } elsif($l == 1){
                my $r = 0;
                ($_a2_def, $r) = ($_a2_def - 1000000, 1) if $_a1_att > 0 and $_a2_def > 1000000;
                ($_b2_def, $r) = ($_b2_def - 1000000, 2) if $_b1_att > 0 and $_b2_def > 1000000 and $r == 0;
                ($_c2_def, $r) = ($_c2_def - 1000000, 3) if $_c1_att > 0 and $_c2_def > 1000000 and $r == 0;
                $T2 = $r;
             }
          }
          if($_bonus2_y){
              my $l = int(rand(2));
             if($l == 0){
                my ($r, $rik, $V2) = (0, 0, int(rand(3)) + 1);
                ($r, $rik) = (1, (int($_a2_att/2))) if $_a2_att > 0 and $_a1_def < 1000000 and $V2 == 1;
                ($r, $rik) = (1, (int($_b2_att/2))) if $_b2_att > 0 and $_b1_def < 1000000 and $r == 0 and $V2 == 2;
                ($r, $rik) = (1, (int($_c2_att/2))) if $_c2_att > 0 and $_c1_def < 1000000 and $r == 0 and $V2 == 3;
    
                #$_a2_att += $rik if $V2 == 1;
                #$_b2_att += $rik if $V2 == 2;
                #$_c2_att += $rik if $V2 == 3;
                $R1 = $rik;
                $db->query("UPDATE duel set pl2_rik = CONCAT(pl2_rik, $V2) where sid = \"$dsid\"") if $R1 > 0;
             } elsif($l == 1){
                my $r = 0;
                ($_a1_def, $r) = ($_a1_def - 1000000, 1) if $_a2_att > 0 and $_a1_def > 1000000;
                ($_b1_def, $r) = ($_b1_def - 1000000, 2) if $_b2_att > 0 and $_b1_def > 1000000 and $r == 0;

    Из браузерной игрушки на mod_perl/mysql. Код наглядно демонстрирует, что говнокод зависит не от языка, а от программиста.

    guest, 13 Марта 2009

    Комментарии (1)
  3. Perl / Говнокод #702

    −307.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    sub get_ppl{
    	my $self = shift;
            my ($U, $print_done, $team) = @_;
    
             return "<ppl team_id='$team' battle_stats='$U->{_CHAR}->{win},$U->{_CHAR}->{loose},$U->{_CHAR}->{nobody}' medals='".$U->get_medal_string_for_user($U)."' $clan team_id='0' av_id='$U->{_CHAR}->{av_id}' fn='$U->{_CHAR}->{avatara}' u='$U->{_CHAR}->{u}' hp_u='$U->{_CHAR}->{hp_u}' stat0_u='$U->{_CHAR}->{stat0_u}' stat0='$U->{_CHAR}->{f}' stat1='$U->{_CHAR}->{m}' stat2='$U->{_CHAR}->{y}'  stat3='$U->{_CHAR}->{l}' hpmax='$U->{_CHAR}->{maxhp}' hp='$U->{_CHAR}->{hp}' aname='$U->{_USER_NAME}' lvl='$U->{_CHAR}->{lvl}' cname='$U->{_CHAR}->{name}' id='$U->{_ID}' carma='$U->{_CHAR}->{carma}' sex='$U->{_CHAR}->{sex}' slot0='$Item[0]' slot8='$Item[8]' slot7='$Item[7]' slot6='$Item[6]' slot1='$Item[1]' weight='$U->{_CHAR}->{weight}' slot5='$Item[5]' slot4='$Item[4]' slot3='$Item[3]' slot2='$Item[2]' city_id='$U->{_CHAR}->{city_id}'/>" if !$print_done;
             return "<ppl done='true' battle_stats='$U->{_CHAR}->{win},$U->{_CHAR}->{loose},$U->{_CHAR}->{nobody}' medals='".$U->get_medal_string_for_user($U)."' $clan team_id='0' av_id='$U->{_CHAR}->{av_id}' fn='$U->{_CHAR}->{avatara}' u='$U->{_CHAR}->{u}' hp_u='$U->{_CHAR}->{hp_u}' stat0_u='$U->{_CHAR}->{stat0_u}' stat0='$U->{_CHAR}->{f}' stat1='$U->{_CHAR}->{m}' stat2='$U->{_CHAR}->{y}'  stat3='$U->{_CHAR}->{l}' hpmax='$U->{_CHAR}->{maxhp}' hp='$U->{_CHAR}->{hp}' aname='$U->{_USER_NAME}' lvl='$U->{_CHAR}->{lvl}' cname='$U->{_CHAR}->{name}' id='$U->{_ID}' carma='$U->{_CHAR}->{carma}' sex='$U->{_CHAR}->{sex}' slot0='$Item[0]' slot8='$Item[8]' slot7='$Item[7]' slot6='$Item[6]' slot1='$Item[1]' weight='$U->{_CHAR}->{weight}' slot5='$Item[5]' slot4='$Item[4]' slot3='$Item[3]' slot2='$Item[2]' city_id='$U->{_CHAR}->{city_id}'/>" if $print_done;
    }

    Забавная проверка

    guest, 12 Марта 2009

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

    +135.5

    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
    class PliggMailer{
    
    	var $subject = '';
    	var $body = '';
    	var $from = '';
    	var $to = '';
    
    	function PliggMailer($subj = '', $body = '', $from = '', $to = '', $cc = '', $bcc = ''){
    
    		if($subj != ''){$this->subject = $subj;}
    		if($body != ''){$this->body = $body;}
    		if($from != ''){$this->from = $from;}
    		if(!is_array($to)){$to[] = $to;}
    		if(count($to) == 0){$this->to = $to;}
    		if(!is_array($to)){$to[] = $to;}
    		if(count($to) == 0){$this->to = $to;}
    		if(!is_array($to)){$to[] = $to;}
    		if(count($to) == 0){$this->to = $to;}
    
    	}

    Блоговый движок pligg жжот.

    guest, 11 Марта 2009

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

    +130

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if(included.equals(INCLUDED_ALL) || fieldNames.indexOf(field.getName()) != -1) {
              if ((field.getDocumentMapping() != null && field.getDocumentMapping().trim().length() > 0)
                      || (isCase.booleanValue()
                          && ((field.getWorkflowMapping() != null && field.getWorkflowMapping().trim().length() > 0)
                              || (field.getContentMapping() != null && field.getContentMapping().trim().length() > 0))
                         ) {
        // тут еще насрано
    }}
                 ) {

    классический унылый говнокод, весь проект в таком стиле..

    guest, 11 Марта 2009

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

    +164.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if (USE_MAIN) {
        $templ = 'main';
        ....
    } elseif (!USE_MAIN) {
        $used = USE_MAIN ? 1 : 0;
        $templ = 'default';
        ....
    }
    ......
    if ( !$used ) $templ = 'default';

    Вычищая один проект помимо всего прочего встретил такое чудо

    guest, 08 Марта 2009

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

    +148.3

    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
    // Prevent any possible XSS attacks via $_GET.
    
    foreach ($_GET as $check_url) {
        if (!is_array($check_url)) {
    
            $check_url = str_replace("\"", "", $check_url);
    
            if ((eregi("<[^>]*script*\"?[^>]*>", $check_url)) || (eregi("<[^>]*object*\"?[^>]*>", $check_url)) ||
                (eregi("<[^>]*iframe*\"?[^>]*>", $check_url)) || (eregi("<[^>]*applet*\"?[^>]*>", $check_url)) ||
                (eregi("<[^>]*meta*\"?[^>]*>", $check_url)) || (eregi("<[^>]*style*\"?[^>]*>", $check_url)) ||
                (eregi("<[^>]*form*\"?[^>]*>", $check_url)) || (eregi("\([^>]*\"?[^)]*\)", $check_url)) ||
                (eregi("\"", $check_url))) {
            die ();
    
            }
    
        }
    
    }

    PHP-Fusion Content Management System (C)
    // напалмом по воробьям...

    guest, 08 Марта 2009

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

    +148

    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
    [root@v6704 ~]# service httpd restart
    Stopping httpd:                                            [  OK  ]
    Starting httpd:                                            [  OK  ]
    [root@v6704 ~]# cd /var/www/vhosts/i-tech.me/subdomains/store/httpdocs/
    [root@v6704 httpdocs]# ls
    access           dblist                   i2           installer    license.txt  settings.xml    showmucontent.php  update.xml
    ajaxhandler.php  domxml-php4-to-php5.php  includes     install.js   login        setupguide.htm  sitemap.php        www.tar.gz
    backup           dumper.php               index.php    install.log  published    shop            system
    data             help                     install.css  kernel       readme.txt   showdblist.php  temp
    [root@v6704 httpdocs]# rm -Rf *.*
    [root@v6704 httpdocs]# ls
    access  backup  data  dblist  help  i2  includes  installer  kernel  login  published  shop  system  temp
    [root@v6704 httpdocs]# rm -Rf *
    [root@v6704 httpdocs]# ls
    [root@v6704 httpdocs]#

    [root@v6704 ~]# service httpd restart
    Stopping httpd: [ OK ]
    Starting httpd: [ OK ]
    [root@v6704 ~]# cd /var/www/vhosts/i-tech.me/subdomains/store/httpdocs/

    guest, 06 Марта 2009

    Комментарии (1)
  9. SQL / Говнокод #677

    −856.5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    select sum(all_.allscores) as allscores, sum(all_.matched) as matched, all_.id, all_.title, cc.name, cc.id as cmpId 
    from 
    	(select SE.assid as id, SE.allcurrent as allscores, SE.matched, SE.title-- SE.name -- ,SE.title,SE.cmpId
    	FROM
    	(select allb.assid, sum(allb.allcurrent) as allcurrent, sum(allb.match_cnt) as matched, allb.title -- ,cc.name,cc.id as cmpId, -- , aa.id 
    	from 
    		(select * from
    			(SELECT assa.title, IFNULL(allcur.allcurrent,0) as allcurrent, assa.id as assid , IFNULL(SUM( res.weight),0) AS match_cnt 
    			   FROM 
    				ass_assignment assa LEFT JOIN 
    				(SELECT  DISTINCT pss.cv_i
    ....

    ёбаные лесенки...

    guest, 06 Марта 2009

    Комментарии (1)
  10. C++ / Говнокод #676

    +140.8

    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
    class vector_ptd    //pointed vector - вектор заданный 2 точками, т.е. привязанный к опр.месту в пространстве
    {
    ...
    /*vector operator =(point& _p)
    {
        vector _v;
        _v.vx=_p.x;
        _v.vy=_p.y;
        _v.vz=_p.z;
        return _v;
    }*/
    ...
    };
    
    vector vectorp(point& _p)
    {
    	vector _v;
    	_v.vx=_p.x;
    	_v.vy=_p.y;
    	_v.vz=_p.z;
    	return _v;
    }

    Класс, реализующий вектор в трёхмерном пространстве (для трассировщика лучей). Автор не осилил оператор присваивания и тихо закомментил его, сделав вместо него функцию преобразования.

    guest, 06 Марта 2009

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

    +145

    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
    <?php
    require_once('global.php');
    
    $id = $_GET['id'];
    if( !$lore_system->db->id_exists( $id, 'lore_articles') )
    {
    	$lore_system->te->assign('error_message', 'invalid_article');
    	$lore_system->te->display('error_message.tpl');
    	exit;
    }
    if( !$lore_db_interface->article_is_published( $id ) )
    {
    	$lore_system->te->assign('error_message', 'article_not_published');
    	$lore_system->te->display('error_message.tpl');
    	exit;
    }
    
    $action = ( isset( $_REQUEST['action'] ) ) ? $_REQUEST['action'] : 'article';
    switch( $action )
    {
    	case 'print':
    		$article = $lore_db_interface->get_article_info( $id );
    		$article['comments'] = $lore_db_interface->get_article_comments( $id );
    		
    		$lore_system->te->assign('category_path', $lore_db_interface->get_category_path( $article['category_id'] ));
    		$lore_system->te->assign('article', $article);
    		$lore_system->te->display('article_print.tpl');
    	break;
    		
    	case 'article':
    		if( !@in_array( $id, $lore_user_session->session_vars['viewed_articles'] ) )
    		{
    			$lore_db_interface->increment_article_views( $id );
    			$lore_user_session->session_vars['viewed_articles'][] = $id;
    		}
    		
    		$article			= $lore_db_interface->get_article_info( $id );
    		$article['comments']		= $lore_db_interface->get_article_comments( $id );
    		$article['num_comments']	= count($article['comments']);
    		$article['attachments']		= $lore_db_interface->get_article_attachments( $id );
    		$article['allow_comments']	= $lore_db_interface->can_comment_on_article( $id );
    		$article['related_articles']	= $lore_db_interface->get_related_articles( $id );
    
    		if( $lore_user_session->has_article_write_permission( $id ) )
    		{
    			$article['display_edit_link'] = true;
    		}
    
    		if( $lore_system->settings['enable_glossary_popups'] )
    		{
    			$glossary_terms = $lore_db_interface->get_glossary_terms();
    			if( count($glossary_terms) )
    			{
    				$term_html = array();
    				$html_tags = array();
    				$term_c = 0;
    
    				// strip out HTML tags first
    				@preg_match_all("/<[^>]+>/", $article['content'], $matches);
    				for( $i = 1; $i < count($matches[0]); $i++ )
    				{
    					// save html tag for later
    					$html_tags[$i] = $matches[0][$i];
    					
    					// parse in placeholder
    					$article['content'] = str_replace( $matches[0][$i], "{{h$i}}", $article['content']);
    				}
    					
    				foreach( $glossary_terms AS $term )
    				{
    					// Add "i" (NOT case sensitive) modifier to regular expression if necessary
    					$case = ( $term['case_sensitive'] ) ? '' : 'i';
    					
    					$term['definition'] = ereg_replace("[\n\r]", '', $term['definition']);
    					
    					$lore_system->te->assign('term', htmlspecialchars(str_replace("'", "\\'", $term['term'])) );

    guest, 05 Марта 2009

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