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

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

    +69

    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
    /**
         * Инициализация набора действий, определенных для контейнера.
         * @param context
         * @throws DfException
         */
        protected void initializeTransitions(EditorContext context) throws DfException{
            AbstractDocumentModel documentModel = getDocumentModel();
            AbstractState state = documentModel.getLifeCyclePolicy(context).getState(context);
            
            if (!documentModel.isNew())
            {
                addTransition(TransitionName.CREATE_DETACHED_COMMISSION, TransitionHandler.CREATE_DETACHED_COMMISSION);
                addTransition(TransitionName.PRINT, TransitionHandler.PRINT);
            }
            AbstractTaskModel taskModel = context.getTaskModel();
            if (taskModel  instanceof ReviewDocumentTaskModel && !(taskModel  instanceof ExpeditionaryProcessingDocumentTaskModel)){
    //                 && !(taskModel instanceof AttachFileAndReviewDocumentTaskModel)){
    
                      
            if ((taskModel instanceof AttachFileToDocumentTaskModel || taskModel instanceof WaitForScanningTaskModel) && ((documentModel instanceof InternalDocumentModel) || (documentModel instanceof OutgoingDocumentModel) || (documentModel instanceof IncomingDocumentModel)))
                addTransition(TransitionName.PRINT_BARCODE, TransitionHandler.PRINT_BARCODE);
    
            if (taskModel instanceof AbstractDocumentTaskModel){
                if ( state instanceof AbstractDraftState ){
                    if( state instanceof NewProtocolDraftState)
                        addTransition(ContainerAction.ACTION_NAME, TransitionName.SEND_DRAFT, TransitionName.REGISTER, TransitionHandler.SEND_DRAFT);
                    else if (state instanceof NewDraftState)
                        addTransition(TransitionName.SEND_DRAFT, TransitionHandler.SEND_DRAFT);
                    if (state instanceof AbstractApprovalDraftState)
                        addTransition(TransitionName.REWORK_DRAFT, TransitionHandler.REWORK_DRAFT);
                    if (state instanceof AnalyseDraftState)
                        addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_ANALYSE, TransitionHandler.SEND_DRAFT);
                    if (state instanceof ControlDraftState)
                        addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_CONTROL, TransitionHandler.SEND_DRAFT);
                    if (state instanceof ApproveDraftState)
                        addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_APPROVAL, TransitionHandler.SEND_DRAFT);
                    if (state instanceof SignDraftState)
                        addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_SIGN, TransitionHandler.SEND_DRAFT);
                    if (state instanceof ExternalApproveDraftState)
                        addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_APPROVAL, TransitionHandler.SEND_DRAFT);
                    if (state instanceof ControlApproveDraftState)
                        addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_CONTROLED, TransitionHandler.SEND_DRAFT);
                    if (state instanceof ConfirmationDraftState)
                        addTransition(TransitionName.SEND_DRAFT, TransitionDescription.SEND_DRAFT_CONFIRM, TransitionHandler.SEND_DRAFT);
                }
              }
            }
            
    .................. несколько страниц такого кода ...........................
          
            if (state instanceof AbstractApprovalDraftState ||
                state instanceof ReworkDraftState ||
                state instanceof NewDocumentState ||
                state instanceof RegisterDocumentState ||
                state instanceof ReviewDocumentState ||
                state instanceof ExecuteDocumentState){
            	addTransition(TransitionName.SAVE, TransitionHandler.SAVE);
            }
    
            super.initializeTransitions(context);
        }

    Автор решил захардкодить в одном месте логику переходов между всеми состояниями всех жизненных циклов всех документов, реализованных в системе документооборота. Получился говнокод-BPM-движок. А внешне код очень даже солидный: с константами и комментариями... и названиями классов вроде: ExpeditionaryProcessingDocumentTaskModel

    dab84, 06 Сентября 2010

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

    +134

    1. 1
    http://youex.ru/skins/default/pages/search/

    В продолжение =)

    hybroid, 05 Сентября 2010

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

    −856

    1. 1
    SELECT i.*, p.link as p_link, p.title as p_title, p.p_id FROM `items` i, `places` p WHERE i.public='1' and i.place=p.id and  (i.place='1' or i.place='1972' or i.place='2' or i.place='3' or i.place='4' or i.place='5' or i.place='6' or i.place='7' or i.place='8' or i.place='9' or i.place='10' or i.place='11' or i.place='12' or i.place='13' or i.place='14' or i.place='15' or i.place='16' or i.place='17' or i.place='18' or i.place='19' or i.place='20' or i.place='21' or i.place='22' or i.place='23' or i.place='24' or i.place='25' or i.place='26' or i.place='27' or i.place='28' or i.place='29' or i.place='30' or i.place='31' or i.place='32' or i.place='33' or i.place='34' or i.place='35' or i.place='36' or i.place='37' or i.place='38' or i.place='39' or i.place='40' or i.place='41' or i.place='42' or i.place='43' or i.place='44' or i.place='45' or i.place='46' or i.place='47' or i.place='48' or i.place='49' or i.place='50' or i.place='51' or i.place='52' or i.place='53' or i.place='54' or i.place='55' or i.place='56' or i.place='57' or i.place='58' or i.place='59' or i.place='60' or i.place='61' or i.place='62' or i.place='63' or i.place='64' or i.place='65' or i.place='66' or i.place='67' or i.place='68' or i.place='69' or i.place='70' or i.place='71' or i.place='72' or i.place='73' or i.place='74' or i.place='75' or i.place='76' or i.place='77' or i.place='78' or i.place='79' or i.place='80' or i.place='81' or i.place='82' or i.place='83' or i.place='84' or i.place='85' or i.place='86' or i.place='87' or i.place='88' or i.place='89' or i.place='90' or i.place='91' or i.place='92' or i.place='93' or i.place='94' or i.place='95' or i.place='96' or i.place='97' or i.place='98' or i.place='99' or i.place='100' or i.place='101' or i.place='102' or i.place='103' or i.place='104' or i.place='105' or i.place='106' or i.place='107' or i.place='108' or i.place='109' or i.place='110' or i.place='111' or i.place='112' or i.place='113' or i.place='114' or i.place='115' or i.place='116' or i.place='117' or i.place='118' or i.place='119' or i.place='120' or i.place='121' or i.place='122' or i.place='123' or i.place='124' or i.place='125' or i.place='126' or i.place='127' or i.place='128' or i.place='129' or i.place='130' or i.place='131' or i.place='132' or i.place='133' or i.place='134' or i.place='135' or i.place='136' or i.place='137' or i.place='138' or i.place='139' or i.place='140' or i.place='141' or i.place='142' or i.place='143' or i.place='144' or i.place='145' or i.place='146' or i.place='147' or i.place='148' or i.place='149' or i.place='150' or i.place='151' or i.place='152' or i.place='153' or i.place='154' or i.place='155' or i.place='156' or i.place='157' or i.place='158' or i.place='159' or i.place='160' or i.place='161' or i.place='162' or i.place='163' or i.place='164' or i.place='165' or i.place='166')  ORDER BY i.lastupdated DESC LIMIT 18160, 10;

    есть ещё примерно такой же, но с JOINами

    wiz, 01 Сентября 2010

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

    +144

    1. 1
    exit; ?>

    Самая последняя строчка в скрипте.

    7ion, 25 Августа 2010

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

    +176

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $submit=($a!=0)?true:false;
    if($submit==true)
    {
        redirect("index.php");
    }
    else
    {
        if($submit==false)
        {
    	  include_once("module.php");
        }
    }

    железная индусская логика

    zloiia, 22 Августа 2010

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

    +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
    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
    <?php
    
    include "conf_db.php";
    if(!empty($_REQUEST['doreg'])){
    $error=array();
    if(!$_REQUEST['name']) $error['name']="Имя";
    if(!$_REQUEST['pass']) $error['pass']="Пароль";
    if(!$_REQUEST['pass_to']) $error['pass_to']="Снова пароль";
    if(!$_REQUEST['e_mail']) $error['e_mail']="E-mail";
    
    if(!empty($error))
     {
     foreach ($error as $value)
      {
      echo "Не заполнено поле $value<br>";
      }
     include "form.php";
     }
     
     if(empty($error))
    {
     $error_to=array();
    if(trim($_REQUEST['pass']) !== trim($_REQUEST['pass_to'])) $error_to['pass']="Пароли не совпадают!";
    
    if(empty($error_to)) 
    {
    $query="select * from users where name='".$_REQUEST['name']."'";
    $id=mysql_query($query)or die(mysql_error());
    $arr=mysql_fetch_array($id);
    if(!empty($arr)) $error_to['db']="пользователь с таким именем уже зарегистрирован!"; 
    }
    if(!empty($error_to))
     {
      foreach($error_to as $value)
      {
      echo $value;
      }
     include "form.php";
     }
    }
    if(empty ($error_to)  && empty($error))
    {
    
    //Здесь проверка прошла.
    
    }
    ?>

    Скрипт регистрации

    desty, 20 Августа 2010

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

    +143

    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
    void Draw(object sender, PaintEventArgs e)
            {
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
    
                //X
                e.Graphics.DrawLine(new Pen(Color.Blue, 3), new Point(0, this.Height / 2), new Point(this.Width, this.Height / 2));
    
                //Y
                e.Graphics.DrawLine(new Pen(Color.Red, 3), new Point(this.Width / 2, this.Height), new Point(this.Width / 2, 0));
    
    
                PointF[] p = new PointF[this.Width];
    
                //MessageBox.Show((Math.PI / 180 * 1).ToString());
                for(int i = 0, z = this.Width; i < (this.Height / 2); i++, z++)
                {
                    p[i].X = (float)Math.Cos(z) * this.Width;
                    p[i].Y = (float)Math.Sin(i) * this.Height;
                }
    
                e.Graphics.DrawCurve(new Pen(Color.LightSkyBlue, 2), p, 2);
            }

    sergylens, 13 Августа 2010

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

    +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
    public static List<string> GetWords(string text, out List<int> index)
            {
                MatchCollection matches = Regex.Matches(text, @"[\w.]+|[\W]+");
                List<string> m = new List<string>();
                index = new List<int>();
                foreach (Match match in matches)
                {
                    if (match.Value.IndexOf('.', match.Value.Length - 1) != -1 && !isPart(match.Value) && match.Value.Length > 1)
                    {
                        string str = match.Value.Remove(match.Value.Length - 1, 1);
                        m.Add(str);
                        m.Add(".");
                    }
                    else
                    {
                        m.Add(match.Value);
                        index.Add(match.Index);
                    }
                }
                return m;
            }

    Нужно подать текст, который будет разбит на <Word> ... </Word>. При этом нужно отслеживать сокращения типа "г.", "т.д.", "др" и т.д. Но возникает проблема, слова типа "привет." будут также рассматриваться как единое целое, поэтому приходиться проверять, сокращение это или нет в строках 8-13, если есть другой (оптимальный) способ, то был бы благодарен )

    Attila, 10 Августа 2010

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

    +114

    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
    static void Main(string[] args)
            {
    
            metka:
                int exit = 0;
                Console.Clear();
                TextRead ob1 = new TextRead();
                Meneger ob2 = new Meneger();
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("                             " + "ДОБРО ПОЖАЛОВАТЬ");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("--------------------------------------------------------------------------------");
                Thread.Sleep(500);
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Выберите нужную программу:");
                Thread.Sleep(500);
                Console.WriteLine();
                string vib;
                Console.WriteLine("1)Текстовый редактор");
                Thread.Sleep(500);
                Console.WriteLine("2)Файловый менеджер");
                Console.WriteLine("3)Выход");
                vib = Console.ReadLine();
                switch (vib)
                {
                    case "1" : ob1.read();
                        break;
                    case "2": ob2.med();
                        break;
                    case "3":  exit = 1;
                        break;
                    default: Console.WriteLine("Выберите 1 или 2 ");
                        break;
                }
               
                
                if (exit == 0)
                {
                    goto metka;
                }
    
               
                
            }

    Имитация загрузки
    Thread.Sleep(500);хВВDDDD

    Nigma143, 08 Августа 2010

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

    +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
    function toup($str) {
    #перевод в верхний регистр (просто strtoupper не всегда корректно работает с русскими буквами)
    $str=strtoupper($str);
    $str=str_replace("а","А",$str);$str=str_replace("б","Б",$str);$str=str_replace("в","В",$str);
    $str=str_replace("г","Г",$str);$str=str_replace("д","Д",$str);$str=str_replace("е","Е",$str);
    $str=str_replace("ж","Ж",$str);$str=str_replace("з","З",$str);$str=str_replace("и","И",$str);$str=str_replace("й","Й",$str);
    $str=str_replace("к","К",$str);$str=str_replace("л","Л",$str);$str=str_replace("м","М",$str);
    $str=str_replace("н","Н",$str);$str=str_replace("о","О",$str);$str=str_replace("п","П",$str);
    $str=str_replace("р","Р",$str);$str=str_replace("с","С",$str);$str=str_replace("т","Т",$str);
    $str=str_replace("у","У",$str);$str=str_replace("ф","Ф",$str);$str=str_replace("х","Х",$str);
    $str=str_replace("ц","Ц",$str);$str=str_replace("ч","Ч",$str);$str=str_replace("ш","Ш",$str);
    $str=str_replace("щ","Щ",$str);$str=str_replace("ъ","Ъ",$str);$str=str_replace("ы","Ы",$str);
    $str=str_replace("ь","Ь",$str);$str=str_replace("э","Э",$str);$str=str_replace("ю","Ю",$str);
    $str=str_replace("я","Я",$str);
    return $str;}
    
    function tolower($str) {
    #перевод в нижний регистр (просто strtolower не всегда корректно работает с русскими буквами)
    $str=strtolower($str);
    $str=str_replace("А","а",$str);$str=str_replace("Б","б",$str);$str=str_replace("В","в",$str);
    $str=str_replace("Г","г",$str);$str=str_replace("Д","д",$str);$str=str_replace("Е","е",$str);
    $str=str_replace("Ж","ж",$str);$str=str_replace("З","з",$str);$str=str_replace("И","и",$str);$str=str_replace("Й","й",$str);
    $str=str_replace("К","к",$str);$str=str_replace("Л","л",$str);$str=str_replace("М","м",$str);
    $str=str_replace("Н","н",$str);$str=str_replace("О","о",$str);$str=str_replace("П","п",$str);
    $str=str_replace("Р","р",$str);$str=str_replace("С","с",$str);$str=str_replace("Т","т",$str);
    $str=str_replace("У","у",$str);$str=str_replace("Ф","ф",$str);$str=str_replace("Х","х",$str);
    $str=str_replace("Ц","ц",$str);$str=str_replace("Ч","ч",$str);$str=str_replace("Ш","ш",$str);
    $str=str_replace("Щ","щ",$str);$str=str_replace("Ъ","ъ",$str);$str=str_replace("Ы","ы",$str);
    $str=str_replace("Ь","ь",$str);$str=str_replace("Э","э",$str);$str=str_replace("Ю","ю",$str);
    $str=str_replace("Я","я",$str);
    return $str;}

    Еще 2 шикарные функции, того же автора, что и в предыдущем моем посте.
    про setlocale никто и не слыхивал.

    Mihard, 03 Августа 2010

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