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

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

    +146

    1. 1
    $news = new news($_GET["news"]);

    Обьект класса news. Выводит нужную новость в соответствии с get запросом.

    Somov, 09 Ноября 2010

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

    +162

    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
    // юзер просит :
    // "Дату выводит как записано в базе к примеру 2010-10-26 15:17:01. А мне нужно вывести Только 15:17. Как так сделать не меняя записи в базе?"
    $infochat=SQLrow("select datesend, id_user, message from minichat order by datesend desc limit 0,1");
    
    // и варианты
    
    $exp=explode(" ", $date); 
    $exp=explode(":", $exp); 
    echo $exp[0].':'.$exp[1];
    
    //.........
    
    $exp=substr("$date", 11, 3); 
    echo $exp;
    
    // :D

    С одного форума

    Morgan, 26 Октября 2010

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

    +157

    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
    protected function _defineUser()
        {
            if ($this->_getParam('controller') == 'profile')
            {
                // check for mb and sf
                if ($this->_getParam('action') == 'mb')
                {
                    $user = new Dbrow_User();
                    $this->userId = $user->getIdByMbId($this->currentId);
                }
                if ($this->_getParam('action') == 'sf')
                {
                    $user = new Dbrow_User();
                    $this->userId = $user->getIdBySfId($this->currentId);
                }
            }
            
            if ($this->userId <= 0)
            {
                $this->userId = (int)$this->_getParam('userId');
            }
            if ($this->userId <= 0)
            {
                $this->userId = (int)$this->currentId;
            }
            if ($this->userId <= 0 && Static_Auth::isLogged())
            {
                $this->user   = Static_Auth::getUser();
                $this->userId = $this->user->id;
            }
                else 
                {
                    $this->user = new Dbrow_User();
                    $this->user->loadById($this->userId, array());
                }
                
            $this->view->user = $this->user;
    
            self::$curUser = $this->user;
            //var_dump($this->user->parentEssences);
            //exit;
        }

    just piece of shit

    mykola, 25 Октября 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    int X,Y,Z;
    X=StrToInt(Edit1->Text);
    Y=StrToInt(Edit2->Text);
    Z=X+Y;
    Edit3->Text=IntToStr(Z),

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

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

    −120

    1. 1
    print qq(<div id="Layer26" class="blank" style="left:170mm; top:96mm; width:95mm;">$base1[17]);

    Верстаем в миллиметрах, используем магические числа и т.п.

    hdkeeper, 22 Октября 2010

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

    +125

    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
    <?
    # запускаем сессии
    session_start();
    # подключаем MySQL
    require "db.php";
    // Если существуют куки, то выполняем автовход!
    if(isset($_COOKIE['adminauto']))
    {$nik = $_COOKIE['adminnik'];
    $password = $_COOKIE['adminpassword'];
    $_SESSION['adminnik'] = $nik;
    $_SESSION['adminpassword'] = crc32(crypt(base64_encode(strrev(md5($password)))));
    }// Если переменные пустые, то запрещаем вход
    ....... Тут какое то говнишко 
    # если пользователь ввел данные, то проверяем их
    if(isset($go))
    {
    # принимаем данные через POST
    if (isset($_POST['nik'])) {$nik = $_POST['nik'];}
    if (isset($_POST['pass'])) {$pass = $_POST['pass'];}
    # проверяем нет ли пустых полей
    if(empty($nik) or empty($pass)) 
    {exit("<script language='javascript'>alert('Вы попытались получить доступ к Чату, но замечено, что Вы не ввели какое-то из полей, пожалуйста заполните их!');</script><head><meta http-equiv='refresh' content='0; URL=admin.php'></head>");}
    
    $result = mysql_query("SELECT nik,password FROM admin WHERE nik='$nik' and password='$pass'");
    if(mysql_num_rows($result) > 0) 
    { 
    
    $_SESSION['adminnik'] = $nik; 
    $_SESSION['adminpassword'] = crc32(crypt(base64_encode(strrev(md5($pass)))));}
    else {exit("<script language='javascript'>alert('Вы попытались получить доступ к Чату, но те данные которые Вы ввели, не совподают с правильными! Пожалуйста введите правильные!');</script><head><meta http-equiv='refresh' content='0; URL=admin.php'></head>");}}
    
    if( !isset($_SESSION['adminnik']) or !isset($_SESSION['adminpassword']) )  {
    echo "<br><br><br><br><br><br><br>
    <table bgcolor='#EAF3FF' width='300px' align='center' style='border:1px solid #000000; padding:10px;'>
    <tr><td><strong>Вход</strong></td></tr><br>
    <form method='post'><tr bgcolor='#F9F8FD'><td>
    <div style='font-size:11px; font-family:Verdana; color:#424242;'>Ваш ник:</div></td><td>
    <input style='border:1px solid #B3B9C3; font-size:12px;' type='text' name='nik'></td></tr>
    <tr bgcolor='#F9F8FD'><td>
    <div style='font-size:11px; font-family:Verdana; color:#424242;'>Ваш пароль:</div></td><td>
    <input style='border:1px solid #B3B9C3; font-size:12px;' type='password' name='pass'></td></tr><tr><td>
    <input type='checkbox' name='auto' cheked> Автовход<br>
    <input style='border:1px solid #000000; color:#3A4F6C; font-weight:700; padding:0px; background-color:#F0F5FA; margin-top:5px;' type='submit' name='go' value='Войти'></form>
    </td>
    </tr>
    </table>
    <br><table bgcolor='#EAF3FF' width='500px' align='center' style='border:1px solid #000000; padding:10px;'><tr align='center'><td><strong style='font-size:14px;'>Забыли пароль?</strong></td></tr><form method='post' action='newpass.php'><tr align='center'><td bgcolor='#F9F8FD' style='padding-bottom:7px;'><strong style='font-size:11px; font-family:Verdana;'>Введите Ваш email:   </strong><input type='text' name='email' style='border:1px solid #B3B9C3; font-size:11px; font-family:Verdana; padding:1px; margin-top:5px;'>  <input type='submit' style='border:1px solid #000000; color:#3A4F6C; font-weight:700; padding:0px; background-color:#F0F5FA; margin-top:5px;' name='newpass' value='Получить пароль!'></form></td></tr><tr><td align='center' style='font-size:11px; font-family:Verdana; color:#FF0000;'>* Вам на email будет выслан новый пароль!</td></tr></table>
    ";
    exit();
    }
    ?>

    Вот. это называется авто вход.

    Vasiliy, 18 Октября 2010

    Комментарии (10)
  8. Java / Говнокод #4374

    +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
    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
    public void onMessage(final NetConnection connection, final NetMessage message) {
        final ClientConnection client = (ClientConnection) connection;
        if (message.isCommand(Protocol.CMD_LOGIN)) {
          if (this.auth(client,
              message.getParameter(Protocol.PARAM_NAME, String.class))) {
            final NetMutableMessage msgLogin = new NetMutableMessage(
                Protocol.CMD_LOGIN);
            msgLogin.addParameter(Protocol.PARAM_FROM, client.getNick());
            this.writeMessage(client, null, msgLogin);
          } else {
            this.removeConnection(client);
          }
        }
        if (message.isCommand(Protocol.CMD_LOGOUT)) {
          final NetMutableMessage msgLogout = new NetMutableMessage(
              Protocol.CMD_LOGOUT);
          msgLogout.addParameter(Protocol.PARAM_FROM, client.getNick());
          this.writeMessage(client, null, msgLogout);
          this.removeConnection(client);
        }
        if (message.isCommand(Protocol.CMD_STATUS)) {
          final NetMutableMessage msgStatus = new NetMutableMessage(
              Protocol.CMD_STATUS);
          msgStatus.addParameter(Protocol.PARAM_TYPE,
              message.getParameter(Protocol.PARAM_TYPE));
          msgStatus.addParameter(Protocol.PARAM_FROM, client.getNick());
          this.writeMessage(client, null, message);
          this.removeConnection(client);
        }
        if (message.isCommand(Protocol.CMD_USERS)) {
          final NetMutableMessage msgUsers = new NetMutableMessage(
              Protocol.CMD_USERS);
          msgUsers.addParameter("list", this.getUsers(connection));
          this.writeMessage(client, msgUsers, null);
        }
        if (message.isCommand(Protocol.CMD_SAY)) {
          final NetMutableMessage msgSay = new NetMutableMessage(Protocol.CMD_SAY);
          msgSay.addParameter(Protocol.PARAM_FROM, client.getNick());
          msgSay.addParameter(Protocol.PARAM_MESSAGE,
              message.getParameter(Protocol.PARAM_MESSAGE));
          if (null == message.getParameter(Protocol.PARAM_TO)) {
            this.writeMessage(client, msgSay, msgSay);
          } else {
            this.writeMessage(
                message.getParameter(Protocol.PARAM_TO, String.class), msgSay, null);
          }
        }
        if (message.isCommand(Protocol.CMD_MOVE)) {
          final NetMutableMessage msgMove = new NetMutableMessage(Protocol.CMD_MOVE);
          msgMove.addParameter(Protocol.PARAM_FROM, client.getNick());
          msgMove.addParameter(Protocol.PARAM_CODE,
              message.getParameter(Protocol.PARAM_CODE));
          this.writeMessage(message.getParameter(Protocol.PARAM_TO, String.class),
              msgMove, null);
        }
        if (message.isCommand(Protocol.CMD_OFFER)) {
          final NetMutableMessage msgOffer = new NetMutableMessage(
              Protocol.CMD_OFFER);
          msgOffer.addParameter(Protocol.PARAM_FROM, client.getNick());
          this.writeMessage(message.getParameter(Protocol.PARAM_TO, String.class),
              msgOffer, null);
        }
        if (message.isCommand(Protocol.CMD_ACCEPT)) {
          final NetMutableMessage msgAccept = new NetMutableMessage(
              Protocol.CMD_ACCEPT);
          msgAccept.addParameter(Protocol.PARAM_FROM, client.getNick());
          this.writeMessage(message.getParameter(Protocol.PARAM_TO, String.class),
              msgAccept, null);
        }
        if (message.isCommand(Protocol.CMD_DECLINE)) {
          final NetMutableMessage msgDecline = new NetMutableMessage(
              Protocol.CMD_DECLINE);
          msgDecline.addParameter(Protocol.PARAM_FROM, client.getNick());
          this.writeMessage(message.getParameter(Protocol.PARAM_TO, String.class),
              msgDecline, null);
        }
        if (message.isCommand(Protocol.CMD_END)) {
          final NetMutableMessage msgEnd = new NetMutableMessage(Protocol.CMD_END);
          msgEnd.addParameter("player1",
              message.getParameter(Protocol.PARAM_TO, String.class));
          msgEnd.addParameter("player2", client.getNick());
          this.writeMessage(message.getParameter(Protocol.PARAM_TO, String.class),
              null, msgEnd);
        }
      }

    нагкодил свежачок, прямиком из IDE Eclipse :)

    разрабатываю сетевую мини-игрушку с чатом. Данный метод -- из серверной части, где сервер принимает приходящие сообщения и реагирует на них.
    Обьем метода и однородность кусков намекает, что это пора рефакторить - вот думаю как.

    Lure Of Chaos, 17 Октября 2010

    Комментарии (10)
  9. Java / Говнокод #4368

    +77

    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
    public void actionPerformed(ActionEvent e) {
                System.out.println("Przed utworzeniem resultseta");
                Statement stm=null;
                try{stm = Aplikacja.dajPolaczenieDB().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);}
                catch (SQLException ex){System.out.println("Wystąpił błąd przy próbie utworzemia Statement: "+ex.getLocalizedMessage());}
                String z_sql = "SELECT id,imie FROM crm_sl_imion";
                ResultSet rs=null;
                try{rs = stm.executeQuery(z_sql);}
                catch(SQLException e1){System.out.println("Wystąpił błąd przy próbie utworzeniu ResultSet'a: "+e1.getLocalizedMessage());}
                try{
                    System.out.println("Rozpoczynam transakcje");
                    Aplikacja.dajPolaczenieDB().setAutoCommit(false);
                }catch(SQLException e1){
                    System.out.println("Wystąpił błąd przy probie rozpoczęcia transkacji");
                }
                String z_insert="insert into crm_sl_imion(imie) values('Zdzisek')";
                Statement stm2=null;
                try{
                   stm2 = Aplikacja.dajPolaczenieDB().createStatement();
                }catch(SQLException e1){
                   System.out.println("Wystąpił błąd przy próbie utowrzenia drugiego Stadementa: "+e1.getLocalizedMessage());
                }
                try{
                   stm2.execute(z_insert);
                }catch(SQLException e1){
                   System.out.println("Wystąpił błąd przy próbie wykonywania sql'a: "+z_insert+", błąd: "+e1.getLocalizedMessage());
                }
                try{
                    System.out.println("Odwijam transakcje");
                    Aplikacja.dajPolaczenieDB().commit();
                    Aplikacja.dajPolaczenieDB().setAutoCommit(true);
                }catch(SQLException e1){
                    System.out.println("Wystąpił błąd przy odwijaniu transakcji");
                }
                try{
                while(rs.next()){
                    System.out.println("id: "+rs.getString("id")+" imie: "+rs.getString("imie"));
                }
                }catch(SQLException e2){
                    System.out.println("Wystąpił błąd przy próbie odczytania danych: "+e2.getLocalizedMessage());
                }
                try{
                    stm.close();
                    System.out.println("Po zamknięciu Statement'a");
                }catch(SQLException e1){
                    System.out.println("Wystąpił błąd przy próbie zamknięcia Statement'a");
                }
            }

    xaoc, 16 Октября 2010

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

    +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
    // Devide vector
    Tuple<Complex[], Complex[]> DevideVector(Complex[] vector){
    Complex[] firstPart = new Complex[vector.Length / 2],
    secondPart = new Complex[vector.Length / 2];
    for (int index = 0; index < firstPart.Length; index++) { firstPart[index] = vector[index]; }
    for (int index = 0, offset = firstPart.Length; index < secondPart.Length; index++) { secondPart[index] = vector[index + offset]; }
    return new Tuple<Complex[], Complex[]>(firstPart, secondPart);}
    
    // FFT
    public Complex[] Transform(Complex[] vector){
    inverse = false;
    Complex[] result = Operation(vector);
    result = InverceIndexBits(result);
    for (int index = 0; index < vector.Length; index++) { result[index] /= result.Length; }
    return result;}
    
    // IFFT
    public Complex[] InverseTransform(Complex[] vector){
    inverse = true;
    Complex[] result = Operation(vector);
    result = InverceIndexBits(result);
    return result;}
    }}

    Код из лабы моего одногруппника. Яркий пример того, как НЕ НАДО оформлять код

    KoirN, 11 Октября 2010

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

    +151

    1. 1
    2. 2
    $g_source= SF(qGet("source")); // $_GET['source'] со всякой фильтрацией
    if ($g_source=="") { $g_source=''; }

    ferry-very-good, 11 Октября 2010

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