1. C++ / Говнокод #3383

    +1005

    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
    void bvnr(char *text)
    {
    for(int f=0; f<=strlen(text); f++)
    {
    switch(text[f])
    {
    case 'Q' : text[f] = 'q' ; break;
    case 'W' : text[f] = 'w' ; break;
    case 'E' : text[f] = 'e' ; break;
    case 'R' : text[f] = 'r' ; break;
    case 'T' : text[f] = 't' ; break;
    case 'Y' : text[f] = 'y' ; break;
    case 'U' : text[f] = 'u' ; break;
    case 'I' : text[f] = 'i' ; break;
    case 'O' : text[f] = 'o' ; break;
    case 'P' : text[f] = 'p' ; break;
    case 'A' : text[f] = 'a' ; break;
    case 'S' : text[f] = 's' ; break;
    case 'D' : text[f] = 'd' ; break;
    case 'F' : text[f] = 'f' ; break;
    case 'G' : text[f] = 'g' ; break;
    case 'H' : text[f] = 'h' ; break;
    case 'J' : text[f] = 'j' ; break;
    case 'K' : text[f] = 'k' ; break;
    case 'L' : text[f] = 'l' ; break;
    case 'Z' : text[f] = 'z' ; break;
    case 'X' : text[f] = 'x' ; break;
    case 'C' : text[f] = 'c' ; break;
    case 'V' : text[f] = 'v' ; break;
    case 'B' : text[f] = 'b' ; break;
    case 'N' : text[f] = 'n' ; break;
    case 'M' : text[f] = 'm' ; break;
    )
    }
    }

    Перевод текста в нижний регистр. Можно пугать детей на ночь))

    hromjo, 03 Июня 2010

    Комментарии (144)
  2. Куча / Говнокод #3382

    +132

    1. 1
    oSqlStr[0, 12] = " '<DIV onclick=\"fShowWindow(''../ReglamSchemesDoc.aspx?code='+Cast(s1.n_pp AS VarChar(50))+''')\" align=\"center\"><img border=\"0\" src=\"../Image/sxemaRed.gif\"></DIV>'+CASE WHEN s1.s_reglament>'' THEN '<DIV onclick=\"fShowFile('''+Replace(Replace(s1.s_reglament,' ',''),';',''')\" align=\"center\"><img border=\"0\" src=\"../Image/sxema.gif\"></DIV><DIV onclick=\"fShowFile(''')+''')\" align=\"center\"><img border=\"0\" src=\"../Image/sxema.gif\"></DIV>' ELSE '' END ";

    Однострочная каша из трёх языков
    Взято отсюда...
    http://www.aspnetmania.com/Forums/ForumMessage/336926.html

    mrbig66, 03 Июня 2010

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

    +112

    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
    static void Main(string[] args)
            {
                IPEndPoint myIP = null;
                TcpListener server = null;
                bool loop = true;
                while (loop)
                {
                    try
                    {
                        Random rnd = new Random(DateTime.Now.Millisecond);
                        new IPEndPoint(new IPAddress(new byte[] { 127, 0, 0, 1 }), rnd.Next(1000, 9999));
                        server = new TcpListener(myIP);
                        loop = false;
                    }
                    catch
                    {
                        loop = true;
                    }
                }
               //...
    }

    Подключаемся к серверу =)

    psina-from-ua, 02 Июня 2010

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php
    session_start();
    // супер-мега защита от ддоса
    $_SESSION['antiddos']==time() ? exit() : $_SESSION['antiddos']=time();
    //конец супер мега защиты
    ....
    ?>

    Найдено в старом проекте, код не мой.
    Но вы знаете, от толпы школьников с кнопками F5 это реально помогает!

    mr.The, 02 Июня 2010

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

    +158

    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
    /**
     * Метод проверяет права доступа на использование этого модуля, возвращает результат проверки.
     * Кроме этого, происходит запись в лог
     *
     * @return boolean
     */
    private function check_access() {
    	Logger::log_exception($_SERVER['REQUEST_URI'].'?'.$_SERVER['QUERY_STRING'], $this->log_file_name);
    	return true;
    }
    
    // [...]
    
    /**
     * Попытка переключить рабочую базу данных
     */
    public function actionChange_db() {
    	if (!$this->check_access()) {
    		echo strval($this->err_failure_access);
    		return;
    	}
    
    // [...]

    Вот такое иногда встречается в коде коллеги, про название метода "log_exception" я промолчу, т.к. это тоже его рук дело, а общий для всех метод Logger::log() ему почему-то не понравился? Я уже просто устал ругаться с ним...

    cr0t, 02 Июня 2010

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

    +122

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    SqlCommand SomeCommand = new SqlCommand(SelectString, ConnectionString);
    int result;
    if(SomeCommand.ExecuteScalar() == null)
        {
            result = 0;
         }
    else
         {
             result = (int)SomeCommand.ExecuteScalar();
          }

    Why bad ?! The method execute twice ...

    O_O, 02 Июня 2010

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

    +121

    1. 1
    2. 2
    3. 3
    private static readonly char SPECIFIER = "$"[0];
    private static readonly char DELIMITER = ":"[0];
    private static readonly char[] DELIMITER_ARRAY = new char[1] { DELIMITER };

    В глубинах довольно большой CRM'ки

    MegaHerz, 02 Июня 2010

    Комментарии (14)
  8. Си / Говнокод #3376

    +103

    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
    /*    Copyright 2009 10gen Inc.
     *
     *    Licensed under the Apache License, Version 2.0 (the "License");
     *    you may not use this file except in compliance with the License.
     *    You may obtain a copy of the License at
     *
     *    http://www.apache.org/licenses/LICENSE-2.0
     *
     *    Unless required by applicable law or agreed to in writing, software
     *    distributed under the License is distributed on an "AS IS" BASIS,
     *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     *    See the License for the specific language governing permissions and
     *    limitations under the License.
     */
    
    /* all the numbers that fit in a 4 byte string */
    const char bson_numstrs[1000][4] = {
        "0",  "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",
        "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
    	/* 105 строк поскипано */
        "980", "981", "982", "983", "984", "985", "986", "987", "988", "989",
        "990", "991", "992", "993", "994", "995", "996", "997", "998", "999",
    };

    Взято отсюда - http://github.com/mongodb/mongo-c-driver/blob/master/src/numbers.c . А это коммит - http://github.com/mongodb/mongo-c-driver/commit/0198225180a51e0b0b8a84f25b34b3047d3b9c80

    raorn, 02 Июня 2010

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

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <table width="500" height="10">
    <td>
     <br>
    
    </tr>
    </table>

    Дипломная работа... no comments

    Sinless, 02 Июня 2010

    Комментарии (48)
  10. SQL / Говнокод #3374

    −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
    $SQL            =  "SELECT rq.*, c.login, r.name as raceName,                                                                                                                                                                   
        IF(rq.status = 1, '<span style=\'color:green\'>".$this->kernel->msg->get('raceRequest.status.done')."</span>',                                                                          
            IF(rq.status = -1, '<span style=\'color:red\'>".$this->kernel->msg->get('raceRequest.status.cancel')."</span>',                                                                 
                '".$this->kernel->msg->get('raceRequest.status.request')."')) as statusMsg,                                                                                             
        IF(rq.currentLevel = 1, '<span style=\'color:#eeb300\'>".$this->kernel->msg->get('raceRequest.level.gold')."</span>',                                                                   
            IF(rq.currentLevel = 2, '<span style=\'color:#c6cccd\'>".$this->kernel->msg->get('raceRequest.level.silver')."</span>',                                                         
                '<span style=\'color:#d58b72\'>".$this->kernel->msg->get('raceRequest.level.bronzet')."</span>')) as currentLevelMsg,                                                   
        IF(rq.requestLevel = 1, '<span style=\'color:#eeb300\'>".$this->kernel->msg->get('raceRequest.level.gold')."</span>',                                                                   
            IF(rq.requestLevel = 2, '<span style=\'color:#c6cccd\'>".$this->kernel->msg->get('raceRequest.level.silver')."</span>',                                                         
                '<span style=\'color:#d58b72\'>".$this->kernel->msg->get('raceRequest.level.bronzet')."</span>')) as requestLevelMsg                                                    
        FROM raceRequests rq                                                                                                                                                                            
        LEFT JOIN customers c ON c.ID = rq.customerID                                                                                                                                                   
        LEFT JOIN races r ON r.ID = rq.raceID                                                                                                                                                           
        WHERE rq.ID = '%ID'";

    Формирование HTML с помощью SQL

    blaster999, 01 Июня 2010

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