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

    В номинации:
    За время:
  2. Куча / Говнокод #4505

    +144

    1. 1
    ((100 - ((coef - 1) * 10)) / 0.5)

    Охренительные познания математики 5 класса комплектуются абсолютным отсутствием здравого смысла.

    KirAmp, 01 Ноября 2010

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

    +168

    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
    <?php
    Class Draw
    {
    // вырисовка графика баланса
    	function Graph($y1,$y2,$y3,$y4,$y5,$y6,$y7,$firstday) {
    		header ("Content-type: image/png");
    		$im = imagecreatefrompng("graph.png");
    		$text_color = imagecolorallocate($im, 233, 14, 91);
    		$color = imagecolorallocate($im, 0, 0, 0);
    		$bg = imagecolorallocate($im, 180, 180, 200);
    		#--------------------------------------------------------
    		imagefill ($im, 0, 0, $bg);
    		#---------------------------------------------------------
    		imageline($im, 50, 0, 1000, 0, $color);
    // в это же духе еще ~10 строк
    		imageline($im, 50, 900, 1000, 900, $color);
    		#---------------------------------------------------------
    		imageline($im, 100, 950, 100, 0, $color);
    // аналогично
    		imageline($im, 700, 950, 700, 0, $color);
    		#---------------------------------------------------------
    		imageline($im, 100, 1000-$y1, 200, 1000-$y2, $text_color);
    		imagefilledellipse ($im, 100, 1000-$y1, 10, 10, $color);
    		imagestring($im, 3, 115, 1000-$y1, $y1 . " RUB", $text_color);
    		imagestring($im, 5, 90, 960, $firstday, $text_color);
    		#-----------------------------------------------------------
    		imageline($im, 200, 1000-$y2, 300, 1000-$y3, $text_color);
    		imagefilledellipse ($im, 200, 1000-$y2, 10, 10, $color);
    		imagestring($im, 3, 215, 1000-$y2, $y2 . " RUB", $text_color);
    		imagestring($im, 5, 190, 960, $firstday+1, $text_color);
    		#-------------------------------------------------------------
    		imageline($im, 300, 1000-$y3, 400, 1000-$y4, $text_color);
    		imagefilledellipse ($im, 300, 1000-$y3, 10, 10, $color);
    		imagestring($im, 3, 315, 1000-$y3, $y3 . " RUB", $text_color);
    		imagestring($im, 5, 290, 960, $firstday+2, $text_color);
    		#------------------------------------------------------------
    		imageline($im, 400, 1000-$y4, 500, 1000-$y5, $text_color);
    		imagefilledellipse ($im, 400, 1000-$y4, 10, 10, $color);
    		imagestring($im, 3, 415, 1000-$y4, $y4 . " RUB", $text_color);
    		imagestring($im, 5, 390, 960, $firstday+3, $text_color);
    		#-----------------------------------------------------------
    		imageline($im, 500, 1000-$y5, 600, 1000-$y6, $text_color);
    		imagefilledellipse ($im, 500, 1000-$y5, 10, 10, $color);
    		imagestring($im, 3, 515, 1000-$y5, $y5 . " RUB", $text_color);
    		imagestring($im, 5, 490, 960, $firstday+4, $text_color);
    		#------------------------------------------------------------
    		imageline($im, 600, 1000-$y6, 700, 1000-$y7, $text_color);
    		imagefilledellipse ($im, 600, 1000-$y6, 10, 10, $color);
    		imagestring($im, 3, 615, 1000-$y6, $y6 . " RUB", $text_color);
    		imagestring($im, 5, 590, 960, $firstday+5, $text_color);
    		#------------------------------------------------------------
    		imagefilledellipse ($im, 700, 1000-$y7, 10, 10, $color);
    		imagestring($im, 3, 715, 1000-$y7, $y7 . " RUB", $text_color);
    		imagestring($im, 5, 690, 960, $firstday+6, $text_color);
    		#---------------------------------------------------------
    		imagestring($im, 5, 0, 900, 100, $text_color);
    		imagestring($im, 5, 0, 800, 200, $text_color);
    		imagestring($im, 5, 0, 700, 300, $text_color);
    		imagestring($im, 5, 0, 600, 400, $text_color);
    		imagestring($im, 5, 0, 500, 500, $text_color);
    		imagestring($im, 5, 0, 400, 600, $text_color);
    		imagestring($im, 5, 0, 300, 700, $text_color);
    		imagestring($im, 5, 0, 200, 800, $text_color);
    		imagestring($im, 5, 0, 100, 900, $text_color);
    		imagestring($im, 5, 0, 0, 1000, $text_color);
    		#---------------------------------------------------------
    		imagepng($im);
    		imagedestroy($im);
    	}
    }
    ?>

    той же 3х летней давности.....комментарии излишни

    Steel2010, 31 Октября 2010

    Комментарии (4)
  4. Perl / Говнокод #4477

    −122

    1. 1
    my $exp_data = $map->get_experiments_data($gg, $map, $signals_sign, $distinct_lists);

    Пуленепробиваемый код! На случае, если вдруг объект забудет, кто он такой.

    krushi, 29 Октября 2010

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

    +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
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    // To protect MySQL injection
    $username = stripslashes($username);
    $password = stripslashes($password);
    $username = mysqli_real_escape_string($connect, $username);
    $password = mysqli_real_escape_string($connect, $password);
                                                   
    $login = mysqli_query($connect, "SELECT * FROM users WHERE username = '$username'");
    while ($row = mysqli_fetch_assoc($login))
    {
        $db_password = $row['password'];
        if (sha1($password) == $db_password)
            $loginok = TRUE;
        else
            $loginok = FALSE;
    
        if ($loginok == TRUE)
        {
            // Register $username, $password
            $_SESSION["username"] = $username;
            exit();
        }
        else
            die('Feil brukernavn/passord.');
    }

    pastebin временами радует :)
    http://pastebin.com/hW8BbEmt

    fork, 26 Октября 2010

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

    +161

    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
    function getItinerary($IID){
        $connection = initDB();
        $query;
    
        if($IID == 0){
                $query = "SELECT * FROM Itinerary";                
            }
            else{
                $query = "SELECT * FROM Itinerary WHERE IID='".$IID."'";               
            }
    
    
        $result = mysql_query($query);
            //or die ("Query Failed ".mysql_error());
    
        $itineraryID = 0;
        $itineraryData;
    
        while($row = mysql_fetch_array($result)){   
                $GID = $row['GID'];
                $FID = $row['FID'];
                $SID = $row['SID'];
                    
                    //Retrieve Guest Information
                $query2 = "SELECT * FROM Guest WHERE GID='".$GID."'";
                $result2 = mysql_query($query2);
                $row2 = mysql_fetch_array($result2);
                $firstName = $row2['FirstName'];
                $lastName = $row2['LastName'];
                    
                    //Retrieve Travel Schedule Information
                $query3 = "SELECT * FROM Schedule WHERE SID='".$SID."'";
                $result3 = mysql_query($query3);
                $row3 = mysql_fetch_array($result3);
                $travelDate = $row3['Date'];
                    
                    //Retrieve Sector Information
                $query3 = "SELECT * FROM Flights WHERE FID='".$FID."'";
                $result3 = mysql_query($query3);
                $row3 = mysql_fetch_array($result3);
                $sourceSID = $row3['SourceSID'];
                $destSID = $row3['DestSID'];
                $fName = $row3['FName'];
            
                $query4 = "SELECT Sector FROM Sectors WHERE SID='".$sourceSID."'";
                $result4 = mysql_query($query4);
                $row4 = mysql_fetch_array($result4);
                $source = $row4['Sector'];
                $query4 = "SELECT Sector FROM Sectors WHERE SID='".$destSID."'";
                $result4 = mysql_query($query4);
                $row4 = mysql_fetch_array($result4);
                $dest = $row4['Sector'];
                    
                    //Build GuestItinerary object   
                $guestItinerary = new GuestItinerary();
            
                $guestItinerary->set_FID($FID);
                $guestItinerary->set_FName($fName);
                $guestItinerary->set_SID($SID);
                $guestItinerary->set_source($source);
                $guestItinerary->set_dest($dest);
                $guestItinerary->set_travelDate($travelDate);
            
                $guestItinerary->set_GID($GID);
                $guestItinerary->set_firstName($firstName);
                $guestItinerary->set_lastName($lastName);    
            
                $itineraryData[$itineraryID]=$guestItinerary;
                $itineraryID = $itineraryID + 1; 
            
            }
    
        closeDB($connection);      
        return $itineraryData;
    }

    Из демонстрационного приложения к NetBeans. Для обучения новичков, ага.

    seonull, 25 Октября 2010

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

    +167

    1. 1
    <h2>".($sub==171&&$f_title=="Новый номер"?s_list_class(172,205,"nc_ctpl=172"):"")."</h2>

    NetCat'овцы поймут :) Обожаю проверки по тайтлу ))

    Yanovsky, 25 Октября 2010

    Комментарии (4)
  8. Pascal / Говнокод #4431

    +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
    var
    s:string;
    function f(s:string):string;
    var
    i:integer;
    s1:string;
    begin
    s1:=#13#10's:=''';
    for i:=1to length(s)do begin
    if s[i]=#13then
    s1:=s1+'''#13#10+'#13#10+''''
    else if s[i]=''''then
    s1:=s1+''''''
    else if s[i]<>#10 then
    s1:=s1+s[i];
    f:=s1+''';'#13#10+
    's:=s+f(s);'#13#10+
    'write(s);'#13#10+
    'close(output);'#13#10+
    'end.';
    end;
    end;
    begin
    assign(output,'s.txt');
    rewrite(output);
    s:='var'#13#10+
    's:string;'#13#10+
    'function f(s:string):string;'#13#10+
    'var'#13#10+
    'i:integer;'#13#10+
    's1:string;'#13#10+
    'begin'#13#10+
    's1:=#13#10''s:='''''';'#13#10+
    'for i:=1to length(s)do begin'#13#10+
    'if s[i]=#13then'#13#10+
    's1:=s1+''''''#13#10+''#13#10+'''''''''#13#10+
    'else if s[i]=''''''''then'#13#10+
    's1:=s1+'''''''''''''#13#10+
    'else if s[i]<>#10 then'#13#10+
    's1:=s1+s[i];'#13#10+
    'f:=s1+'''''';''#13#10+'#13#10+
    '''s:=s+f(s);''#13#10+'#13#10+
    '''write(s);''#13#10+'#13#10+
    '''close(output);''#13#10+'#13#10+
    '''end.'';'#13#10+
    'end;'#13#10+
    'end;'#13#10+
    'begin'#13#10+
    'assign(output,''s.txt'');'#13#10+
    'rewrite(output);';
    s:=s+f(s);
    write(s);
    close(output);
    end.

    Нарыл свой высер на тему программы, выводящей свой текст.

    TarasB, 23 Октября 2010

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

    +114

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public class XmlSettings
    {
        XDocument x = XDocument.Load(@"...Settings.xml");
        public XDocument Settings { get { return x; } }
    }

    Manager настроек из предудыщего проекта

    HIMen, 23 Октября 2010

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

    +108

    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
    private void InitializeUser()
    {
    	textBoxFirstname.Text = _user.FirstName;
    	textBoxLastname.Text = _user.LastName;
    	textBoxPassword.Text = _user.Password;
    	textBoxUsername.Text = _user.UserName;
    	textBoxMail.Text = _user.Mail;
    	comboBoxRoles.Text = _user.UserRole.Id>0 ? _user.UserRole.RoleName : "";
    	
    	comboBoxRoles.Enabled = true;
    
    	if(User.CurrentUser.isLoanOfficer || User.CurrentUser.isVisitor || User.CurrentUser.isCashier)
    	{
    		comboBoxRoles.Enabled = false;
    	}
    	else if(User.CurrentUser.isAdmin)
    	{
    		if(_user.isAdmin || _user.isSuperAdmin) comboBoxRoles.Enabled = false;
    	}
    	else if(User.CurrentUser.isSuperAdmin)
    	{
    		if(_user.isSuperAdmin) comboBoxRoles.Enabled = false;
    	}
    }

    Код взят из реального open source проекта. Реализация многоуровневой проверки прав текущего пользователя :).

    _Ru55_, 22 Октября 2010

    Комментарии (4)
  11. Pascal / Говнокод #4377

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    program test;
    var i : boolean;
    begin
    i := true;
    if i then while true do Writeln('WAR IS TRUE!!!')
    else Writeln('FALSE');
    end.

    Pascal...

    Мартин, 17 Октября 2010

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